Author: dlanglais Date: 2010-03-11 07:52:56 +0100 (Thu, 11 Mar 2010) New Revision: 211 Log: Modification de l'int?\195?\169gration des plugins d'import/export dans l'application : - Suppression des JInternalFrame contenant un menu d?\195?\169roulant (noms des plugins d'im/export) et un bouton permettant de lancer l'im/export ; - Remplac?\195?\169 par deux sous-menu fichier Im/Export contenant un JMenuItem pour chaque plugin assurant l'im/export. Am?\195?\169lioration (avec JOptionPane) : - Il n'est plus possible de im/exporter une base si l'on n'est pas connect?\195?\169 ?\195?\160 une base (cela g?\195?\169n?\195?\169rait une NullPointerException...), - V?\195?\169rification que le plugin d'im/export est bien trouv?\195?\169, - ?\195?\160 la fin de l'import/export on avertit l'utilisateur du succ?\195?\168s ou de l'echec de l'op?\195?\169ration. Modified: trunk/msm-fromtoXPP3/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXMLXPP3.java trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/MainUI.css trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/MainUI.jaxx trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/gui/ApplicationEngine.java trunk/msm/src/main/resources/i18n/msm-en_GB.properties trunk/msm/src/main/resources/i18n/msm-fr_FR.properties Modified: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/MainUI.css =================================================================== --- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/MainUI.css 2010-03-11 01:13:57 UTC (rev 210) +++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/MainUI.css 2010-03-11 06:52:56 UTC (rev 211) @@ -49,14 +49,14 @@ mnemonic:D; } -#menuImport { +#menuImport, #menuImportBis { text:"mapstoragemanager.action.import"; toolTipText:"mapstoragemanager.action.import.tip"; actionIcon:"databaseImport_16"; mnemonic:I; } -#menuExport { +#menuExport, #menuExportBis { text:"mapstoragemanager.action.export"; toolTipText:"mapstoragemanager.action.export.tip"; actionIcon:"databaseExport_16"; Modified: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/MainUI.jaxx =================================================================== --- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/MainUI.jaxx 2010-03-11 01:13:57 UTC (rev 210) +++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/MainUI.jaxx 2010-03-11 06:52:56 UTC (rev 211) @@ -95,6 +95,14 @@ m.start(); } +public void doActionPerformed__on__menuImport2(java.awt.event.ActionEvent event) { + engine.showImportFrame(); +} + +public void doActionPerformed__on__menuExport2(java.awt.event.ActionEvent event) { + engine.showExportFrame(); +} + /** * Test. */ @@ -117,10 +125,13 @@ <JMenuItem id='menuDisconnect' enabled='false' onActionPerformed='engine.disposeToolBar()'/> <JSeparator/> - <JMenuItem id='menuImport' + <!--JMenuItem id='menuImport' onActionPerformed='engine.showImportFrame()'/> <JMenuItem id='menuExport' onActionPerformed='engine.showExportFrame()'/> + <JSeparator/--> + <JMenu id='menuImportBis' enabled='false'/> + <JMenu id='menuExportBis' enabled='false'/> <JSeparator/> <JMenuItem id='menuExit' onActionPerformed='engine.close()'/> Modified: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/gui/ApplicationEngine.java =================================================================== --- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/gui/ApplicationEngine.java 2010-03-11 01:13:57 UTC (rev 210) +++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/ui/gui/ApplicationEngine.java 2010-03-11 06:52:56 UTC (rev 211) @@ -1,12 +1,15 @@ package org.nuiton.mapstoragemanager.ui.gui; import java.awt.Desktop; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.util.Locale; import java.util.Properties; import javax.swing.JFileChooser; +import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; @@ -130,18 +133,40 @@ ui.getNameBase().setSelectedItem(bigTableItem); } for (Plugin imPlugin : pluginLoader.getAllPlugin(Importer.class)) { - String imName = imPlugin.getPluginName(); - jaxx.runtime.swing.Item importerItem = - new jaxx.runtime.swing.Item(imName, null, imName, true); - ui.getImporter().addItem(importerItem); - ui.getImporter().setSelectedItem(importerItem); + final String imName = imPlugin.getPluginName(); +// jaxx.runtime.swing.Item importerItem = +// new jaxx.runtime.swing.Item(imName, null, imName, true); +// ui.getImporter().addItem(importerItem); +// ui.getImporter().setSelectedItem(importerItem); + + JMenuItem menuItem = new JMenuItem(imName); + menuItem.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + importBase(imName); + } + }); + ui.getMenuImportBis().add(menuItem); + ui.getMenuImportBis ().setEnabled(true); } for (Plugin exPlugin : pluginLoader.getAllPlugin(Exporter.class)) { - String exName = exPlugin.getPluginName(); - jaxx.runtime.swing.Item exporterItem = - new jaxx.runtime.swing.Item(exName, null, exName, true); - ui.getExporter().addItem(exporterItem); - ui.getExporter().setSelectedItem(exporterItem); + final String exName = exPlugin.getPluginName(); +// jaxx.runtime.swing.Item exporterItem = +// new jaxx.runtime.swing.Item(exName, null, exName, true); +// ui.getExporter().addItem(exporterItem); +// ui.getExporter().setSelectedItem(exporterItem); + + JMenuItem menuItem = new JMenuItem(exName); + menuItem.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + exportBase(exName); + } + }); + ui.getMenuExportBis().add(menuItem); + ui.getMenuExportBis().setEnabled(true); } for (Plugin exPlugin : pluginLoader.getAllPlugin(Monitoring.class)) { Monitoring monitor = (Monitoring) exPlugin; @@ -413,57 +438,179 @@ Item selectedItem = ui.getImporter().getSelectedJaxxItem(); String importerName = selectedItem.getValue().toString(); + this.importBase(importerName); +// Importer importer = (Importer) pluginLoader.getPlugin(importerName); +// +// /** Create FileChooser and set FileFilter. */ +// JFileChooser jfc = new JFileChooser(lastPath); +// jfc.setFileFilter(importer.getFileFilter()); +// +// /** ShowOpenDialog and get the return value. */ +// int jfcReturn = jfc.showOpenDialog(MainUI.getFrames()[0]); +// +// if( JFileChooser.APPROVE_OPTION == jfcReturn ) { +// +// lastPath = jfc.getSelectedFile().getAbsolutePath(); +// +// File importFile = jfc.getSelectedFile(); +// LOG.info("chosen file for import : " + importFile.getPath()); +// +// /** Import. */ +// importer.importFrom(bigTable, importFile); +// clean(ui); +// uptableNavigationTree(ui.getNavigation(), importFile.getName()); +// } + } + + /** + * Export the database into a file. + */ + public void exportBase() { + + /** Get exporter plugin. */ + MainUI ui = MainUI.getInstance(); + Item selectedItem = ui.getExporter().getSelectedJaxxItem(); + String exporterName = selectedItem.getValue().toString(); + + this.exportBase(exporterName); +// Exporter exporter = (Exporter) pluginLoader.getPlugin(exporterName); +// +// /** Create FileChooser and set FileFilter. */ +// JFileChooser jfc = new JFileChooser(lastPath); +// jfc.setFileFilter(exporter.getFileFilter()); +// +// /** ShowOpenDialog and get the return value. */ +// int jfcReturn = jfc.showOpenDialog(MainUI.getFrames()[0]); +// +// if (JFileChooser.APPROVE_OPTION == jfcReturn) { +// +// lastPath = jfc.getSelectedFile().getAbsolutePath(); +// +// File importFile = jfc.getSelectedFile(); +// LOG.info("chosen file for export : " + importFile.getPath()); +// +// /** Export */ +// exporter.exportTo(bigTable, importFile); +// } + } + + /** + * Import database from a file. + * @param importName the name of the importer plugin. + */ + public void importBase(final String importerName) { + + /** Get importer plugin. */ Importer importer = (Importer) pluginLoader.getPlugin(importerName); - /** Create FileChooser and set FileFilter. */ - JFileChooser jfc = new JFileChooser(lastPath); - jfc.setFileFilter(importer.getFileFilter()); - - /** ShowOpenDialog and get the return value. */ - int jfcReturn = jfc.showOpenDialog(MainUI.getFrames()[0]); - - if( JFileChooser.APPROVE_OPTION == jfcReturn ) { + if (importer == null) { + JOptionPane.showMessageDialog(MainUI.getInstance(), + _("notFoundPlugin.JOptionPaneTitle"), + _("notFoundPlugin.JOptionPaneMessage"), + JOptionPane.ERROR_MESSAGE); + } else if (! bigTableIsSet()) { + JOptionPane.showMessageDialog(MainUI.getInstance(), + _("unconnectedError.JOptionPaneTitle"), + _("unconnectedError.JOptionPaneMessage"), + JOptionPane.ERROR_MESSAGE); - lastPath = jfc.getSelectedFile().getAbsolutePath(); + } else { - File importFile = jfc.getSelectedFile(); - LOG.info("chosen file for import : " + importFile.getPath()); + /** Create FileChooser and set FileFilter. */ + JFileChooser jfc = new JFileChooser(lastPath); + jfc.setFileFilter(importer.getFileFilter()); - /** Import. */ - importer.importFrom(bigTable, importFile); - clean(ui); - uptableNavigationTree(ui.getNavigation(), importFile.getName()); + /** ShowOpenDialog and get the return value. */ + int jfcReturn = jfc.showOpenDialog(MainUI.getFrames()[0]); + + if( JFileChooser.APPROVE_OPTION == jfcReturn ) { + + lastPath = jfc.getSelectedFile().getAbsolutePath(); + + File importFile = jfc.getSelectedFile(); + LOG.info("chosen file for import : " + importFile.getPath()); + + try { + /** Import. */ + importer.importFrom(bigTable, importFile); + MainUI ui = MainUI.getInstance(); + clean(ui); + uptableNavigationTree(ui.getNavigation(), + importFile.getName()); + + JOptionPane.showMessageDialog(MainUI.getInstance(), + _("importSuccessfull.JOptionPaneTitle"), + _("importSuccessfull.JOptionPaneMessage"), + JOptionPane.INFORMATION_MESSAGE); + } catch (Exception ex) { + LOG.error(ex, ex); + JOptionPane.showMessageDialog(MainUI.getInstance(), + _("importUnsuccessfull.JOptionPaneTitle"), + _("importUnsuccessfull.JOptionPaneMessage"), + JOptionPane.ERROR_MESSAGE); + } + } } } /** * Export the database into a file. + * @param exporterName the name of the exporter plugin. */ - public void exportBase() { + public void exportBase(final String exporterName) { /** Get exporter plugin. */ - MainUI ui = MainUI.getInstance(); - Item selectedItem = ui.getExporter().getSelectedJaxxItem(); - String exporterName = selectedItem.getValue().toString(); - Exporter exporter = (Exporter) pluginLoader.getPlugin(exporterName); - /** Create FileChooser and set FileFilter. */ - JFileChooser jfc = new JFileChooser(lastPath); - jfc.setFileFilter(exporter.getFileFilter()); + if (exporter == null) { + JOptionPane.showMessageDialog(MainUI.getInstance(), + _("notFoundPlugin.JOptionPaneTitle"), + _("notFoundPlugin.JOptionPaneMessage"), + JOptionPane.ERROR_MESSAGE); + } else if (! bigTableIsSet()) { + JOptionPane.showMessageDialog(MainUI.getInstance(), + _("unconnectedError.JOptionPaneTitle"), + _("unconnectedError.JOptionPaneMessage"), + JOptionPane.ERROR_MESSAGE); + } else { - /** ShowOpenDialog and get the return value. */ - int jfcReturn = jfc.showOpenDialog(MainUI.getFrames()[0]); + /** Create FileChooser and set FileFilter. */ + JFileChooser jfc = new JFileChooser(lastPath); + jfc.setFileFilter(exporter.getFileFilter()); - if (JFileChooser.APPROVE_OPTION == jfcReturn) { + /** ShowOpenDialog and get the return value. */ + int jfcReturn = jfc.showOpenDialog(MainUI.getFrames()[0]); - lastPath = jfc.getSelectedFile().getAbsolutePath(); + if (JFileChooser.APPROVE_OPTION == jfcReturn) { - File importFile = jfc.getSelectedFile(); - LOG.info("chosen file for export : " + importFile.getPath()); + lastPath = jfc.getSelectedFile().getAbsolutePath(); - /** Export */ - exporter.exportTo(bigTable, importFile); + File importFile = jfc.getSelectedFile(); + LOG.info("chosen file for export : " + importFile.getPath()); + + try { + /** Export */ + exporter.exportTo(bigTable, importFile); + JOptionPane.showMessageDialog(MainUI.getInstance(), + _("exportSuccessfull.JOptionPaneTitle"), + _("exportSuccessfull.JOptionPaneMessage"), + JOptionPane.INFORMATION_MESSAGE); + } catch (Exception ex) { + LOG.error(ex, ex); + JOptionPane.showMessageDialog(MainUI.getInstance(), + _("exportUnsuccessfull.JOptionPaneTitle"), + _("exportUnsuccessfull.JOptionPaneMessage"), + JOptionPane.ERROR_MESSAGE); + } + } } } + + /** + * Method to control if the bigtable is set. + * @return true if bigTable is set, false otherwise. + */ + public boolean bigTableIsSet() { + return this.bigTable != null; + } } Modified: trunk/msm/src/main/resources/i18n/msm-en_GB.properties =================================================================== --- trunk/msm/src/main/resources/i18n/msm-en_GB.properties 2010-03-11 01:13:57 UTC (rev 210) +++ trunk/msm/src/main/resources/i18n/msm-en_GB.properties 2010-03-11 06:52:56 UTC (rev 211) @@ -19,7 +19,7 @@ mapstoragemanager.action.exit=Exit mapstoragemanager.action.exit.tip= mapstoragemanager.action.export=Export -mapstoragemanager.action.export.tip= +mapstoragemanager.action.export.tip=Export the base mapstoragemanager.action.file=File mapstoragemanager.action.file.tip= mapstoragemanager.action.fr=French @@ -27,7 +27,7 @@ mapstoragemanager.action.help=Help mapstoragemanager.action.help.tip= mapstoragemanager.action.import=Import -mapstoragemanager.action.import.tip= +mapstoragemanager.action.import.tip=Import the base mapstoragemanager.action.language=Choose language mapstoragemanager.action.language.tip= mapstoragemanager.action.menuHelp=Help @@ -52,3 +52,16 @@ table.keys=Keys table.values=Values welcome.MapStorageManager=Welcome to MapStorageManager + +unconnectedError.JOptionPaneTitle=No bigtable connected ! +unconnectedError.JOptionPaneMessage=No bigtable connected ! +notFoundPlugin.JOptionPaneTitle=Plugin not found ! +notFoundPlugin.JOptionPaneMessage=Plugin not found ! +importSuccessfull.JOptionPaneTitle=Import successfully proceded. +importSuccessfull.JOptionPaneMessage=Import successfully proceded. +exportSuccessfull.JOptionPaneTitle=Export successfully proceded. +exportSuccessfull.JOptionPaneMessage=Export successfully proceded. +importUnsuccessfull.JOptionPaneTitle=Exception while import. +importUnsuccessfull.JOptionPaneMessage=An exception occured while import database. +exportUnsuccessfull.JOptionPaneTitle=Exception while export. +exportUnsuccessfull.JOptionPaneMessage=An exception occured while export database. \ No newline at end of file Modified: trunk/msm/src/main/resources/i18n/msm-fr_FR.properties =================================================================== --- trunk/msm/src/main/resources/i18n/msm-fr_FR.properties 2010-03-11 01:13:57 UTC (rev 210) +++ trunk/msm/src/main/resources/i18n/msm-fr_FR.properties 2010-03-11 06:52:56 UTC (rev 211) @@ -19,7 +19,7 @@ mapstoragemanager.action.exit=Quitter mapstoragemanager.action.exit.tip=Quitte l'application mapstoragemanager.action.export=Exporter -mapstoragemanager.action.export.tip= +mapstoragemanager.action.export.tip=Exporter la base mapstoragemanager.action.file=Fichier mapstoragemanager.action.file.tip= mapstoragemanager.action.fr=Fran\u00E7ais @@ -27,7 +27,7 @@ mapstoragemanager.action.help=Aide mapstoragemanager.action.help.tip= mapstoragemanager.action.import=Importer -mapstoragemanager.action.import.tip= +mapstoragemanager.action.import.tip=Import la base mapstoragemanager.action.language=Choisir la langue mapstoragemanager.action.language.tip= mapstoragemanager.action.menuHelp=Aide @@ -52,3 +52,16 @@ table.keys=Cl\u00E9s table.values=Valeurs welcome.MapStorageManager=Bienvenue dans MapStorageManager + +unconnectedError.JOptionPaneTitle=Connect\u00E9 \u00E0 aucune base ! +unconnectedError.JOptionPaneMessage=Connect\u00E9 \u00E0 aucune base ! +notFoundPlugin.JOptionPaneTitle=Plugin non trouv\u00E9 ! +notFoundPlugin.JOptionPaneMessage=Plugin non trouv\u00E9 ! +importSuccessfull.JOptionPaneTitle=Import r\u00E9alis\u00E9 avec succ\u00E8s. +importSuccessfull.JOptionPaneMessage=Import r\u00E9alis\u00E9 avec succ\u00E8s. +exportSuccessfull.JOptionPaneTitle=Export r\u00E9alis\u00E9 avec succ\u00E8s. +exportSuccessfull.JOptionPaneMessage=Export r\u00E9alis\u00E9 avec succ\u00E8s. +importUnsuccessfull.JOptionPaneTitle=Exception durant l'import. +importUnsuccessfull.JOptionPaneMessage=Une exception s'est produite lors de l'import de la base. +exportUnsuccessfull.JOptionPaneTitle=Exception durant l'export. +exportUnsuccessfull.JOptionPaneMessage=Une exception s'est produite lors de l'export de la base. \ No newline at end of file Modified: trunk/msm-fromtoXPP3/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXMLXPP3.java =================================================================== --- trunk/msm-fromtoXPP3/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXMLXPP3.java 2010-03-11 01:13:57 UTC (rev 210) +++ trunk/msm-fromtoXPP3/src/main/java/org/nuiton/mapstoragemanager/plugins/exporter/ToXMLXPP3.java 2010-03-11 06:52:56 UTC (rev 211) @@ -80,7 +80,8 @@ serializer.endTag(NAMESPACE, "database"); serializer.endDocument(); - + + serializer.flush(); } catch (IOException ex) { LOG.fatal(ex, ex); } catch (IllegalArgumentException ex) {