diff --git a/.~lock.MIPMap Report.docx# b/.~lock.MIPMap Report.docx# new file mode 100644 index 0000000..1a3a8f5 --- /dev/null +++ b/.~lock.MIPMap Report.docx# @@ -0,0 +1 @@ +,kostis,kostis-lab-pc,14.04.2020 17:40,file:///home/kostis/.config/libreoffice/4; \ No newline at end of file diff --git a/.~lock.MIPMap Tutorial.docx# b/.~lock.MIPMap Tutorial.docx# new file mode 100644 index 0000000..a1f978e --- /dev/null +++ b/.~lock.MIPMap Tutorial.docx# @@ -0,0 +1 @@ +,kostis,kostis-lab-pc,29.04.2020 18:08,file:///home/kostis/.config/libreoffice/4; \ No newline at end of file diff --git a/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/Bundle.properties b/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/Bundle.properties index ec63b1a..9c885cc 100755 --- a/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/Bundle.properties +++ b/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/Bundle.properties @@ -389,3 +389,7 @@ SOLUTION =Solution # MESSAGE_BEST_MAPPINGS =Following is a list of the solutions that have been found.\nSelect the ones you want to view MESSAGE_NO_BEST_MAPPINGS =No solutions were found. Add more lines and run the search again MESSAGE_RANKED_TRANSFORMATIONS =Following is a ranked list of transformations for this mapping task.\nSelect the ones you want to view +getPropertiesFilePanel1.AccessibleContext.accessibleName= +getPropertiesFileJFrame.jTextField1.text=Select the database properties file: +getPropertiesFileJFrame.jLabel1.text=Please select the database properties file: +DBPropertiesChooserJFrame.jLabel1.text=Please provide the db properties file. diff --git a/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/DBPropertiesChooserJFrame.form b/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/DBPropertiesChooserJFrame.form new file mode 100644 index 0000000..05b66d0 --- /dev/null +++ b/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/DBPropertiesChooserJFrame.form @@ -0,0 +1,67 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/DBPropertiesChooserJFrame.java b/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/DBPropertiesChooserJFrame.java new file mode 100644 index 0000000..8c42ec4 --- /dev/null +++ b/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/DBPropertiesChooserJFrame.java @@ -0,0 +1,159 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package it.unibas.spicygui; + +import it.unibas.spicygui.vista.Vista; +import java.io.File; +import java.sql.Timestamp; +import javax.swing.JFileChooser; +import javax.swing.filechooser.FileNameExtensionFilter; +import org.openide.util.Lookup; +import org.openide.windows.WindowManager; + +/** + * + * @author kostis + */ +public class DBPropertiesChooserJFrame extends javax.swing.JFrame { + private Vista vista; + private String dbPropertiesFile; + private Installer installer; + private int returnVal; + /** + * Creates new form DBPropertiesChooserJFrame + */ + public DBPropertiesChooserJFrame(Installer inst) { + System.out.println("~~~ This is the DBPropertiesChooserJFrame constructor ~~~"); + executeInjection(); + initComponents(); + this.installer = inst; + setFileChooserProperties(); + System.out.println("~~~ We done initializing and preparing swing components!! ~~~"); + } + + //kostisk + public void setFileChooserProperties() { + this.jFileChooser1.resetChoosableFileFilters(); + this.jFileChooser1.setDialogType(JFileChooser.SAVE_DIALOG); + this.jFileChooser1.setFileFilter(new FileNameExtensionFilter("PROPERTIES FILE", "properties")); + this.jFileChooser1.setFileSelectionMode(JFileChooser.FILES_ONLY); + //return fileChooser; + } + + private void executeInjection() { + /*if (this.modello == null) { + this.modello = Lookup.getDefault().lookup(Modello.class); + }*/ + if (this.vista == null) { + this.vista = Lookup.getDefault().lookup(Vista.class); + } + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jFileChooser1 = new javax.swing.JFileChooser(); + jLabel1 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setMinimumSize(new java.awt.Dimension(500, 450)); + + jFileChooser1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jFileChooser1ActionPerformed(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(DBPropertiesChooserJFrame.class, "DBPropertiesChooserJFrame.jLabel1.text")); // NOI18N + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(78, Short.MAX_VALUE) + .addComponent(jFileChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(66, 66, 66)) + .addGroup(layout.createSequentialGroup() + .addGap(92, 92, 92) + .addComponent(jLabel1) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(68, Short.MAX_VALUE) + .addComponent(jLabel1) + .addGap(18, 18, 18) + .addComponent(jFileChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(66, 66, 66)) + ); + + pack(); + }// //GEN-END:initComponents + + private void jFileChooser1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFileChooser1ActionPerformed + // TODO add your handling code here: + //this.returnVal = jFileChooser1.showOpenDialog(WindowManager.getDefault().getMainWindow()); + + if (returnVal == jFileChooser1.APPROVE_OPTION) { + File file = jFileChooser1.getSelectedFile(); + this.dbPropertiesFile=file.getAbsolutePath(); + this.installer.setPostgresDbConfFile(this.dbPropertiesFile); + this.installer.configureDatabaseProperties(); + this.installer.createDB(); + java.util.Date date2= new java.util.Date(); + System.out.println("~~~ MIPMap done loading: "+new Timestamp(date2.getTime())+" ~~~"); + this.dispose(); + } + }//GEN-LAST:event_jFileChooser1ActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Metal".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(DBPropertiesChooserJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(DBPropertiesChooserJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(DBPropertiesChooserJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(DBPropertiesChooserJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + //new DBPropertiesChooserJFrame().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JFileChooser jFileChooser1; + private javax.swing.JLabel jLabel1; + // End of variables declaration//GEN-END:variables +} diff --git a/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/Installer.java b/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/Installer.java index b88ea60..6eeec5d 100755 --- a/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/Installer.java +++ b/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/Installer.java @@ -25,12 +25,14 @@ import it.unibas.spicygui.commons.Modello; import com.jgoodies.looks.plastic.Plastic3DLookAndFeel; import com.jgoodies.looks.plastic.theme.LightGray; + import it.unibas.spicy.persistence.DAOException; import it.unibas.spicy.persistence.DAOHandleDB; import it.unibas.spicy.utility.SpicyEngineConstants; import it.unibas.spicygui.commons.LastActionBean; import it.unibas.spicygui.controllo.Scenario; import it.unibas.spicygui.controllo.Scenarios; +import it.unibas.spicygui.vista.Vista; import java.awt.Image; import java.awt.SystemTray; import java.awt.TrayIcon; @@ -51,6 +53,7 @@ import java.sql.Timestamp; import java.util.Properties; import java.util.logging.Logger; +import javax.swing.JFileChooser; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import org.apache.log4j.PatternLayout; @@ -76,10 +79,11 @@ public class Installer extends ModuleInstall { public static final String LOG4J_CONFIGURATION_FILE = "/conf/spicyGUI-log4j.properties"; - public static final String POSTGRESDB_CONFIGURATION_FILE = "postgresdb.properties"; + public static String postgres_db_conf_file; //= "postgresdb.properties"//kostisk: going from constant to variable... // private ActionExitApplication actionExitApplication = new ActionExitApplication(); private boolean close; + @Override public void close() { @@ -190,20 +194,28 @@ public void restored() { configureLog4j(); configuraObservable(); configureFavoriteWindow(); - //giannisk - configureDatabaseProperties(); - createDB(); - java.util.Date date2= new java.util.Date(); - System.out.println("MIPMap loaded: "+new Timestamp(date2.getTime())); + //kostisk + new DBPropertiesChooserJFrame(this).setVisible(true); + //this.postgres_db_conf_file=adbpc.getConfigurationFile(); + //giannisk commented by kostisk, they run once the user selects the properties db file in ActionDBPropertiesChooser + //configureDatabaseProperties(); + //createDB(); + //java.util.Date date2= new java.util.Date(); + //System.out.println("MIPMap loaded: "+new Timestamp(date2.getTime())); } - private void createDB(){ + public void setPostgresDbConfFile(String fullPathFilename) + { this.postgres_db_conf_file = fullPathFilename;} + + public void createDB(){ DAOHandleDB daoCreateDB = new DAOHandleDB(); try { daoCreateDB.createNewDatabase(); } catch (DAOException ex) { + System.err.println("*** Something went wrong while creating the auxiliary db for the mapping-tasks I guess..? ***"); Exceptions.printStackTrace(ex); } + System.out.println("*** DB created ***"); } private File getClassLocation() { @@ -259,7 +271,7 @@ private File getClassLocation() { //giannisk //reads the properties file with database configuration and sets the appropriate variables - private void configureDatabaseProperties() { + public void configureDatabaseProperties() { Properties dbproperties = new Properties(); //TO RUN AS AN APPLICATION: //uncomment the following block and the "else" block @@ -274,7 +286,15 @@ private void configureDatabaseProperties() { try { stream = new FileInputStream(propertyFile);*/ //// - InputStream stream = Installer.class.getResourceAsStream("/conf/"+POSTGRESDB_CONFIGURATION_FILE); //comment for application + //InputStream stream = Installer.class.getResourceAsStream(postgres_db_conf_file); //comment for application + System.out.println("DB Properties file is "+this.postgres_db_conf_file) ; + InputStream stream=null;//changes by kostisk + try { + stream = new FileInputStream(new File (postgres_db_conf_file)); + } catch (FileNotFoundException ex) { + Exceptions.printStackTrace(ex); + } + //if (stream == null){System.out.println("---> Why stream is null here (1)...?? <---");} try { //comment for application dbproperties.load(stream); SpicyEngineConstants.setDatabaseParameters(dbproperties.getProperty("driver"),dbproperties.getProperty("uri"), @@ -284,6 +304,7 @@ private void configureDatabaseProperties() { Logger.getLogger(Installer.class.getName()).severe("Unable to load database configuration file"); } finally { try { + //if (stream == null){System.out.println("---> Why stream is null here (2)...?? <---");} stream.close(); } catch (IOException ex) { DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(NbBundle.getMessage(Costanti.class, Costanti.NEW_ERROR) + " : " + ex.getMessage(), DialogDescriptor.ERROR_MESSAGE)); @@ -365,13 +386,29 @@ private Properties caricaProperties() { } private void setLookAndFeel() { - try { + /*try { if ((Utilities.getOperatingSystem() & Utilities.OS_LINUX) != 0) { Plastic3DLookAndFeel.setPlasticTheme(new LightGray()); UIManager.setLookAndFeel(new Plastic3DLookAndFeel()); } } catch (UnsupportedLookAndFeelException ex) { Exceptions.printStackTrace(ex); + }*/ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Metal".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(DBPropertiesChooserJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(DBPropertiesChooserJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(DBPropertiesChooserJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(DBPropertiesChooserJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } } diff --git a/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/controllo/file/ActionFileChooserSchema.java b/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/controllo/file/ActionFileChooserSchema.java index 4bb0645..23e362f 100755 --- a/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/controllo/file/ActionFileChooserSchema.java +++ b/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/controllo/file/ActionFileChooserSchema.java @@ -47,6 +47,7 @@ public ActionFileChooserSchema() { super("..."); } + @Override public void actionPerformed(ActionEvent e) { executeInjection(); diff --git a/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/vista/Vista.java b/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/vista/Vista.java index 76c0142..383772b 100755 --- a/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/vista/Vista.java +++ b/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/vista/Vista.java @@ -135,6 +135,15 @@ public JFileChooser getFileChooserSalvaFolder() { // fileChooserFolder.updateUI(); return fileChooserFolder; } + + //kostisk + public JFileChooser getFileChooserProperties() { + fileChooser.resetChoosableFileFilters(); + fileChooser.setDialogType(JFileChooser.SAVE_DIALOG); + fileChooser.setFileFilter(new FileNameExtensionFilter("PROPERTIES FILE", "properties")); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + return fileChooser; + } public MultipleJDialog getNewMultipleJDialog() { this.multipleJDialog = new MultipleJDialog(WindowManager.getDefault().getMainWindow(), false); diff --git a/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/vista/csv/LoadCsvInstancesMainFrame.java b/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/vista/csv/LoadCsvInstancesMainFrame.java index bfd55e9..dd47382 100755 --- a/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/vista/csv/LoadCsvInstancesMainFrame.java +++ b/MIPMapGUI/mipmapgui/src/it/unibas/spicygui/vista/csv/LoadCsvInstancesMainFrame.java @@ -55,7 +55,7 @@ public LoadCsvInstancesMainFrame(IDataSourceProxy dataSource){ LoadCsvInstancesPanel instancePanel = new LoadCsvInstancesPanel(tableName.getLabel()); add(instancePanel); instanceArray.add(instancePanel); - } + } JPanel instanceMain=new LoadCsvInstancesBottomPanel(this); add(instanceMain); pack(); diff --git a/mipmapGUICommons/nbproject/private/private.xml b/mipmapGUICommons/nbproject/private/private.xml new file mode 100644 index 0000000..6807a2b --- /dev/null +++ b/mipmapGUICommons/nbproject/private/private.xml @@ -0,0 +1,7 @@ + + + + + + +