diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index 8d75fea..096f3b3 100755 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -79,43 +79,6 @@ is divided into following sections: - - - - - - - - - - - - - - - - - - - - - - - - - - Must set platform.home - Must set platform.bootcp - Must set platform.java - Must set platform.javac - - The J2SE Platform is not correctly set up. - Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files. - Either open the project in the IDE and setup the Platform with the same name or add it manually. - For example like this: - ant -Duser.properties.file=<path_to_property_file> jar (where you put the property "platforms.${platform.active}.home" in a .properties file) - or ant -Dplatforms.${platform.active}.home=<path_to_JDK_home> jar (where no properties file is used) - @@ -217,6 +180,7 @@ is divided into following sections: + @@ -257,7 +221,7 @@ is divided into following sections: - + @@ -306,7 +270,7 @@ is divided into following sections: - + @@ -337,9 +301,6 @@ is divided into following sections: - - - @@ -355,9 +316,7 @@ is divided into following sections: - - - + @@ -382,7 +341,7 @@ is divided into following sections: - + @@ -407,7 +366,7 @@ is divided into following sections: - + @@ -532,7 +491,7 @@ is divided into following sections: - ${platform.java} -cp "${run.classpath.with.dist.jar}" ${main.class} + java -cp "${run.classpath.with.dist.jar}" ${main.class} @@ -557,7 +516,7 @@ is divided into following sections: To run this application from the command line without Ant, try: - ${platform.java} -jar "${dist.jar.resolved}" + java -jar "${dist.jar.resolved}" @@ -677,7 +636,7 @@ is divided into following sections: --> - + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index 5fca1bc..71e849f 100755 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -3,8 +3,8 @@ build.xml.script.CRC32=fecf65ff build.xml.stylesheet.CRC32=958a1d3e@1.26.1.45 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=56b42000 -nbproject/build-impl.xml.script.CRC32=727f9f53 +nbproject/build-impl.xml.data.CRC32=78461136 +nbproject/build-impl.xml.script.CRC32=c0c3402b nbproject/build-impl.xml.stylesheet.CRC32=576378a2@1.32.1.45 nbproject/management-build-impl.xml.data.CRC32=add1b344 nbproject/management-build-impl.xml.script.CRC32=253f0558 diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties index a753feb..879b2a2 100644 --- a/nbproject/private/private.properties +++ b/nbproject/private/private.properties @@ -5,4 +5,4 @@ file.reference.mysql-connector-java-5.0.5-bin.jar=/Users/Stefano/Desktop/Freimap javac.debug=true javadoc.preview=true jaxbwiz.endorsed.dirs=/Applications/NetBeans/NetBeans 6.8.app/Contents/Resources/NetBeans/ide12/modules/ext/jaxb/api -user.properties.file=/Users/Stefano/.netbeans/6.8/build.properties +user.properties.file=/Users/stefano/.netbeans/6.8/build.properties diff --git a/nbproject/project.properties b/nbproject/project.properties index e693b08..ac29ec7 100755 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -82,7 +82,7 @@ jnlp.signed=false main.class=freimapgsoc.Start manifest.file=manifest.mf meta.inf.dir=${src.dir}/META-INF -platform.active=JDK_1.6 +platform.active=default_platform run.classpath=\ ${javac.classpath}:\ ${build.classes.dir} diff --git a/nbproject/project.xml b/nbproject/project.xml index 492e957..d63d45e 100755 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -5,7 +5,6 @@ FreimapGSoC 1.6.5 - diff --git a/src/freimapgsoc/CredentialRequired.java b/src/freimapgsoc/CredentialRequired.java index e6959ea..11743fd 100644 --- a/src/freimapgsoc/CredentialRequired.java +++ b/src/freimapgsoc/CredentialRequired.java @@ -261,6 +261,8 @@ public void findDatabase(String host, String port, String username, String passw } catch (Exception ex) { logLabel.setForeground(Color.red); logLabel.setText(ex.getMessage()); + System.out.println(ex.getMessage()); + System.out.println(ex.getCause()); Logger.getLogger(CredentialRequired.class.getName()).log(Level.SEVERE, null, ex); } } @@ -319,6 +321,7 @@ private void loadDbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST: } } } catch (Exception ex) { + System.out.println(ex.getMessage()); logLabel.setForeground(Color.red); logLabel.setText(ex.getMessage()); } @@ -343,7 +346,7 @@ public void run() { } }); } - Connection c = null; + Connection c = null; Statement stmt = null; ResultSet rss = null; String host; diff --git a/src/freimapgsoc/LatLonJsToMySQL.form b/src/freimapgsoc/LatLonJsToMySQL.form index e60b372..b99435c 100644 --- a/src/freimapgsoc/LatLonJsToMySQL.form +++ b/src/freimapgsoc/LatLonJsToMySQL.form @@ -78,7 +78,7 @@ - + diff --git a/src/freimapgsoc/LatLonJsToMySQL.java b/src/freimapgsoc/LatLonJsToMySQL.java index 0b4888f..ce8bbbd 100644 --- a/src/freimapgsoc/LatLonJsToMySQL.java +++ b/src/freimapgsoc/LatLonJsToMySQL.java @@ -91,7 +91,7 @@ private void initComponents() { newDbText = new javax.swing.JTextField(); confirmPane.setMessage("If you continue your current data in the Database will be destroyed. \n Are you sure that you want to continue?.\n"); - confirmPane.setFont(new java.awt.Font("Lucida Grande", 1, 10)); // NOI18N + confirmPane.setFont(new java.awt.Font("Lucida Grande", 1, 10)); confirmPane.setName("confirmPane"); // NOI18N confirmPane.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent evt) { @@ -104,7 +104,7 @@ public void propertyChange(java.beans.PropertyChangeEvent evt) { errorsLog.setColumns(20); errorsLog.setEditable(false); - errorsLog.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N + errorsLog.setFont(new java.awt.Font("Lucida Grande", 0, 10)); errorsLog.setRows(8); errorsLog.setTabSize(10); errorsLog.setName("errorsLog"); // NOI18N @@ -119,7 +119,7 @@ public void propertyChange(java.beans.PropertyChangeEvent evt) { jLabel1.setText("Source File:"); jLabel1.setName("jLabel1"); // NOI18N - jLabel2.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N + jLabel2.setFont(new java.awt.Font("Lucida Grande", 0, 10)); jLabel2.setText("Password:"); jLabel2.setName("jLabel2"); // NOI18N @@ -129,22 +129,22 @@ public void propertyChange(java.beans.PropertyChangeEvent evt) { userText.setFont(new java.awt.Font("Lucida Grande", 0, 12)); userText.setName("userText"); // NOI18N - jLabel3.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N + jLabel3.setFont(new java.awt.Font("Lucida Grande", 0, 10)); jLabel3.setText("UserName:"); jLabel3.setName("jLabel3"); // NOI18N - jLabel5.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N + jLabel5.setFont(new java.awt.Font("Lucida Grande", 0, 10)); jLabel5.setText("Host:"); jLabel5.setName("jLabel5"); // NOI18N - hostText.setFont(new java.awt.Font("Lucida Grande", 0, 12)); + hostText.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N hostText.setName("hostText"); // NOI18N - jLabel4.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N + jLabel4.setFont(new java.awt.Font("Lucida Grande", 0, 10)); jLabel4.setText("Avaible Database:"); jLabel4.setName("jLabel4"); // NOI18N - cancelButton.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N + cancelButton.setFont(new java.awt.Font("Lucida Grande", 0, 12)); cancelButton.setText("Cancel"); cancelButton.setName("cancelButton"); // NOI18N cancelButton.addActionListener(new java.awt.event.ActionListener() { @@ -162,7 +162,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { } }); - logLabel.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N + logLabel.setFont(new java.awt.Font("Lucida Grande", 0, 10)); logLabel.setText(" "); logLabel.setName("logLabel"); // NOI18N @@ -180,7 +180,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { pathText.setToolTipText("Js File Path"); pathText.setName("pathText"); // NOI18N - chooseButton.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N + chooseButton.setFont(new java.awt.Font("Lucida Grande", 0, 12)); chooseButton.setText("Choose File"); chooseButton.setName("chooseButton"); // NOI18N chooseButton.addActionListener(new java.awt.event.ActionListener() { @@ -192,7 +192,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jLabel7.setText("With this utility you can add your LatLon.js data into a mysql Database."); jLabel7.setName("jLabel7"); // NOI18N - showLog.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N + showLog.setFont(new java.awt.Font("Lucida Grande", 0, 12)); showLog.setText("Show Log"); showLog.setName("showLog"); // NOI18N showLog.addActionListener(new java.awt.event.ActionListener() { @@ -208,7 +208,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { portText.setText("3306"); portText.setName("portText"); // NOI18N - jButton1.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N + jButton1.setFont(new java.awt.Font("Lucida Grande", 0, 12)); jButton1.setText("Example"); jButton1.setName("jButton1"); // NOI18N jButton1.addActionListener(new java.awt.event.ActionListener() { @@ -220,7 +220,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { dbText.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N dbText.setName("dbText"); // NOI18N - newDb.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N + newDb.setFont(new java.awt.Font("Lucida Grande", 0, 10)); newDb.setText("I want to create a new Database:"); newDb.setName("newDb"); // NOI18N newDb.addItemListener(new java.awt.event.ItemListener() { @@ -229,7 +229,7 @@ public void itemStateChanged(java.awt.event.ItemEvent evt) { } }); - newDbText.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N + newDbText.setFont(new java.awt.Font("Lucida Grande", 0, 12)); newDbText.setEnabled(false); newDbText.setName("newDbText"); // NOI18N @@ -242,7 +242,7 @@ public void itemStateChanged(java.awt.event.ItemEvent evt) { .add(jLabel7) .addContainerGap(54, Short.MAX_VALUE)) .add(layout.createSequentialGroup() - .add(99, 99, 99) + .add(106, 106, 106) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) @@ -348,7 +348,6 @@ private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN- }//GEN-LAST:event_cancelButtonActionPerformed private void copyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copyButtonActionPerformed - path = "file://" + pathText.getText(); host = hostText.getText(); port = portText.getText(); username = userText.getText(); @@ -363,7 +362,6 @@ private void copyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI if (i == 0) { try { createTables(); - parseFile(path); } catch (ClassNotFoundException ex) { logLabel.setText(ex.getMessage()); Logger.getLogger(LatLonJsToMySQL.class.getName()).log(Level.SEVERE, null, ex); @@ -553,7 +551,111 @@ private void createTables() throws ClassNotFoundException, SQLException { } - public void parseFile(String path) throws SQLException, InterruptedException { + + private void showLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showLogActionPerformed + scrollPane.setSize(398, 298); + errorsLog.append(errors.values().toString()); + frame = new Frame("Activity Log"); + frame.add(scrollPane); + frame.setLayout(new FlowLayout()); + frame.setSize(400, 300); + frame.setVisible(true); + frame.addWindowListener(new WindowAdapter() { + + public void windowClosing(WindowEvent e) { + frame.setVisible(false); + + + } + }); + }//GEN-LAST:event_showLogActionPerformed + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + pathText.setEditable(true); + pathText.setText("/Users/Stefano/Desktop/FreimapSte/Freimap/hg/src/data/latlon.js"); + userText.setText("root"); + passwordText.setText("CiscoSte5785"); + hostText.setText("127.0.0.1"); + }//GEN-LAST:event_jButton1ActionPerformed + + private void confirmPanePropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_confirmPanePropertyChange + System.out.println("PopUp3"); + String prop = evt.getPropertyName(); + + + if (evt.getSource().equals(confirmPane) && prop.equals(JOptionPane.YES_OPTION)) { + try { + logLabel.setText("Getting connection..."); + Thread.sleep(1000); + Class.forName("com.mysql.jdbc.Driver"); + c = (Connection) DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password); + + + if (!c.isClosed()) { + logLabel.setForeground(Color.green); + logLabel.setText("Connected!"); + createTables(); + parseFile( + pathText.getText()); + Thread.sleep(3000); + + + } + } catch (Exception ex) { + logLabel.setText(ex.getMessage()); + Logger.getLogger(LatLonJsToMySQL.class.getName()).log(Level.SEVERE, null, ex); + } + + + } else { + optionPane.setEnabled(false); + + + } + +// TODO add your handling code here: + }//GEN-LAST:event_confirmPanePropertyChange + + private void newDbItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_newDbItemStateChanged + if (newDb.isSelected()) { + newDbText.setEnabled(true); + dbText.setEnabled(false); + + + } else if (!newDb.isSelected()) { + newDbText.setEnabled(false); + dbText.setEnabled(true); + + + } + }//GEN-LAST:event_newDbItemStateChanged + + private void chooseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseButtonActionPerformed + JFileChooser fcjs = new JFileChooser(); + fcjs.addChoosableFileFilter(new jsFileFilter()); + fcjs.setAcceptAllFileFilterUsed(false); + fcjs.setFileFilter(new jsFileFilter()); + + + int returnVal = fcjs.showOpenDialog(fcjs); + + + if (returnVal == JFileChooser.APPROVE_OPTION) { + File file = fcjs.getSelectedFile(); + System.out.println("FILE JS OPENED"); + System.out.println("Opening: " + file.getName() + ".\n"); + pathText.setText(file.getPath()); + path = "file://" + pathText.getText(); + + + } else if (returnVal == JFileChooser.CANCEL_OPTION) { + System.out.println("Open command cancelled by user." + "\n"); + + + } +}//GEN-LAST:event_chooseButtonActionPerformed + + public void parseFile(String path) throws SQLException, InterruptedException { System.out.println("Now Parse Node and Links"); errors.put("PARSE FILE:", "Now Parse Node and Links...\n"); parseNode(path); @@ -743,109 +845,6 @@ public String addSlashes(String str) { } - private void chooseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseButtonActionPerformed - JFileChooser fcjs = new JFileChooser(); - fcjs.addChoosableFileFilter(new jsFileFilter()); - fcjs.setAcceptAllFileFilterUsed(false); - fcjs.setFileFilter(new jsFileFilter()); - - - int returnVal = fcjs.showOpenDialog(fcjs); - - - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fcjs.getSelectedFile(); - System.out.println("FILE JS OPENED"); - System.out.println("Opening: " + file.getName() + ".\n"); - pathText.setText(file.getPath()); - path = "file://" + pathText.getText(); - - - } else if (returnVal == JFileChooser.CANCEL_OPTION) { - System.out.println("Open command cancelled by user." + "\n"); - - - } - }//GEN-LAST:event_chooseButtonActionPerformed - - private void showLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showLogActionPerformed - scrollPane.setSize(398, 298); - errorsLog.append(errors.values().toString()); - frame = new Frame("Activity Log"); - frame.add(scrollPane); - frame.setLayout(new FlowLayout()); - frame.setSize(400, 300); - frame.setVisible(true); - frame.addWindowListener(new WindowAdapter() { - - public void windowClosing(WindowEvent e) { - frame.setVisible(false); - - - } - }); - }//GEN-LAST:event_showLogActionPerformed - - private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed - pathText.setEditable(true); - pathText.setText("/Users/Stefano/Desktop/FreimapSte/Freimap/hg/src/data/latlon.js"); - userText.setText("root"); - passwordText.setText("CiscoSte5785"); - hostText.setText("127.0.0.1"); - }//GEN-LAST:event_jButton1ActionPerformed - - private void confirmPanePropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_confirmPanePropertyChange - System.out.println("PopUp3"); - String prop = evt.getPropertyName(); - - - if (evt.getSource().equals(confirmPane) && prop.equals(JOptionPane.YES_OPTION)) { - try { - logLabel.setText("Getting connection..."); - Thread.sleep(1000); - Class.forName("com.mysql.jdbc.Driver"); - c = (Connection) DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password); - - - if (!c.isClosed()) { - logLabel.setForeground(Color.green); - logLabel.setText("Connected!"); - createTables(); - parseFile( - pathText.getText()); - Thread.sleep(3000); - - - } - } catch (Exception ex) { - logLabel.setText(ex.getMessage()); - Logger.getLogger(LatLonJsToMySQL.class.getName()).log(Level.SEVERE, null, ex); - } - - - } else { - optionPane.setEnabled(false); - - - } - -// TODO add your handling code here: - }//GEN-LAST:event_confirmPanePropertyChange - - private void newDbItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_newDbItemStateChanged - if (newDb.isSelected()) { - newDbText.setEnabled(true); - dbText.setEnabled(false); - - - } else if (!newDb.isSelected()) { - newDbText.setEnabled(false); - dbText.setEnabled(true); - - - } - }//GEN-LAST:event_newDbItemStateChanged - private String stripQuotes(String str) { if (str.length() <= 2) { return null; diff --git a/src/freimapgsoc/Layer.java b/src/freimapgsoc/Layer.java index b18f4c0..76aac43 100644 --- a/src/freimapgsoc/Layer.java +++ b/src/freimapgsoc/Layer.java @@ -45,7 +45,8 @@ public boolean setCurrentTime(long crtTime) { public void createLayer(HashMap, Vector> data, int id) { try { - //query al mysql per inserire i dati + //Query to the MySql Server to store the data + initLayout(); } catch (Exception ex) { diff --git a/src/freimapgsoc/MainLayer.form b/src/freimapgsoc/MainLayer.form index efe69ef..12fc7b3 100644 --- a/src/freimapgsoc/MainLayer.form +++ b/src/freimapgsoc/MainLayer.form @@ -1300,7 +1300,7 @@ - + diff --git a/src/freimapgsoc/MainLayer.java b/src/freimapgsoc/MainLayer.java index bb328ac..6a8a875 100644 --- a/src/freimapgsoc/MainLayer.java +++ b/src/freimapgsoc/MainLayer.java @@ -1632,7 +1632,7 @@ private void serviceDActionPerformed(java.awt.event.ActionEvent evt) { Logger.getLogger(MainLayer.class.getName()).log(Level.SEVERE, null, ex); } } catch (UnknownHostException ex) { - Logger.getLogger(SDMain.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(MainLayer.class.getName()).log(Level.SEVERE, null, ex); } // TODO add your handling code here: } diff --git a/src/freimapgsoc/MySQLCredential.form b/src/freimapgsoc/MySQLCredential.form new file mode 100644 index 0000000..e6e8aac --- /dev/null +++ b/src/freimapgsoc/MySQLCredential.form @@ -0,0 +1,391 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/freimapgsoc/MySQLCredential.java b/src/freimapgsoc/MySQLCredential.java new file mode 100644 index 0000000..6c093af --- /dev/null +++ b/src/freimapgsoc/MySQLCredential.java @@ -0,0 +1,680 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +/* + * LatLonJsToMySQL.java + * + * Created on 18-mar-2010, 0.49.47 + */ +package freimapgsoc; + +import com.mysql.jdbc.Connection; +import com.mysql.jdbc.Statement; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStreamReader; +import java.net.URL; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.StringTokenizer; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JOptionPane; + +/** + * + * @author Stefano + */ +public class MySQLCredential extends javax.swing.JFrame { + + /** Creates new form LatLonJsToMySQL */ + public MySQLCredential() { + initComponents(); + } + + /** + * 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. + * @return + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + confirmPane = new JOptionPane("If you continue your current data in the Database will be destroyed. \n Are you sure that you want to continue?.\n", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); + ; + scrollPane = new javax.swing.JScrollPane(); + errorsLog = new javax.swing.JTextArea(); + jLabel2 = new javax.swing.JLabel(); + passwordText = new javax.swing.JPasswordField(); + userText = new javax.swing.JTextField(); + jLabel3 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + hostText = new javax.swing.JTextField(); + jLabel4 = new javax.swing.JLabel(); + cancelButton = new javax.swing.JButton(); + startButton = new javax.swing.JButton(); + logLabel = new javax.swing.JLabel(); + checkconnButton = new javax.swing.JButton(); + jLabel7 = new javax.swing.JLabel(); + showLog = new javax.swing.JButton(); + jLabel6 = new javax.swing.JLabel(); + portText = new javax.swing.JTextField(); + exampleButton = new javax.swing.JButton(); + dbText = new javax.swing.JComboBox(); + newDb = new javax.swing.JCheckBox(); + newDbText = new javax.swing.JTextField(); + continueButton = new javax.swing.JButton(); + + confirmPane.setMessage("If you continue your current data in the Database will be destroyed. \n Are you sure that you want to continue?.\n"); + confirmPane.setFont(new java.awt.Font("Lucida Grande", 1, 10)); + confirmPane.setName("confirmPane"); // NOI18N + confirmPane.addPropertyChangeListener(new java.beans.PropertyChangeListener() { + public void propertyChange(java.beans.PropertyChangeEvent evt) { + confirmPanePropertyChange(evt); + } + }); + + scrollPane.setName("scrollPane"); // NOI18N + scrollPane.setSize(new java.awt.Dimension(400, 300)); + + errorsLog.setColumns(20); + errorsLog.setEditable(false); + errorsLog.setFont(new java.awt.Font("Lucida Grande", 0, 10)); + errorsLog.setRows(8); + errorsLog.setTabSize(10); + errorsLog.setName("errorsLog"); // NOI18N + errorsLog.setPreferredSize(new java.awt.Dimension(400, 300)); + errorsLog.setSize(new java.awt.Dimension(300, 400)); + scrollPane.setViewportView(errorsLog); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("MySQL Credentials"); + + jLabel2.setFont(new java.awt.Font("Lucida Grande", 0, 10)); + jLabel2.setText("Password:"); + jLabel2.setName("jLabel2"); // NOI18N + + passwordText.setFont(new java.awt.Font("Lucida Grande", 0, 12)); + passwordText.setName("passwordText"); // NOI18N + + userText.setFont(new java.awt.Font("Lucida Grande", 0, 12)); + userText.setName("userText"); // NOI18N + + jLabel3.setFont(new java.awt.Font("Lucida Grande", 0, 10)); + jLabel3.setText("UserName:"); + jLabel3.setName("jLabel3"); // NOI18N + + jLabel5.setFont(new java.awt.Font("Lucida Grande", 0, 10)); + jLabel5.setText("Host:"); + jLabel5.setName("jLabel5"); // NOI18N + + hostText.setFont(new java.awt.Font("Lucida Grande", 0, 12)); + hostText.setName("hostText"); // NOI18N + + jLabel4.setFont(new java.awt.Font("Lucida Grande", 0, 10)); + jLabel4.setText("Avaible Database:"); + jLabel4.setName("jLabel4"); // NOI18N + + cancelButton.setFont(new java.awt.Font("Lucida Grande", 0, 12)); + cancelButton.setText("Cancel"); + cancelButton.setName("cancelButton"); // NOI18N + cancelButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cancelButtonActionPerformed(evt); + } + }); + + startButton.setFont(new java.awt.Font("Lucida Grande", 0, 12)); + startButton.setText("Copy All"); + startButton.setName("startButton"); // NOI18N + startButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + startButtonActionPerformed(evt); + } + }); + + logLabel.setFont(new java.awt.Font("Lucida Grande", 0, 10)); + logLabel.setText(" "); + logLabel.setName("logLabel"); // NOI18N + + checkconnButton.setFont(new java.awt.Font("Lucida Grande", 0, 12)); + checkconnButton.setText("Load Avaible Database"); + checkconnButton.setName("checkconnButton"); // NOI18N + checkconnButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + checkconnButtonActionPerformed(evt); + } + }); + + jLabel7.setText("Insert MySQL credential to store the data of the Mesh Network:"); + jLabel7.setName("jLabel7"); // NOI18N + + showLog.setFont(new java.awt.Font("Lucida Grande", 0, 12)); + showLog.setText("Show Log"); + showLog.setName("showLog"); // NOI18N + showLog.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + showLogActionPerformed(evt); + } + }); + + jLabel6.setText(":"); + jLabel6.setName("jLabel6"); // NOI18N + + portText.setFont(new java.awt.Font("Lucida Grande", 0, 12)); + portText.setText("3306"); + portText.setName("portText"); // NOI18N + + exampleButton.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N + exampleButton.setText("Example"); + exampleButton.setName("exampleButton"); // NOI18N + exampleButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + exampleButtonActionPerformed(evt); + } + }); + + dbText.setFont(new java.awt.Font("Lucida Grande", 0, 12)); + dbText.setName("dbText"); // NOI18N + + newDb.setFont(new java.awt.Font("Lucida Grande", 0, 10)); + newDb.setText("I want to create a new Database:"); + newDb.setName("newDb"); // NOI18N + newDb.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + newDbItemStateChanged(evt); + } + }); + + newDbText.setFont(new java.awt.Font("Lucida Grande", 0, 12)); + newDbText.setEnabled(false); + newDbText.setName("newDbText"); // NOI18N + + continueButton.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N + continueButton.setText("Continue without store data"); + continueButton.setName("continueButton"); // NOI18N + continueButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + continueButtonActionPerformed(evt); + } + }); + + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() + .add(78, 78, 78) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .add(16, 16, 16) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) + .add(layout.createSequentialGroup() + .add(81, 81, 81) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false) + .add(org.jdesktop.layout.GroupLayout.LEADING, exampleButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.LEADING, checkconnButton) + .add(continueButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 177, Short.MAX_VALUE))) + .add(logLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 315, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(layout.createSequentialGroup() + .add(newDb) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(newDbText))) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 53, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) + .add(dbText, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.TRAILING, userText, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.TRAILING, passwordText) + .add(hostText)) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .add(5, 5, 5) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) + .add(startButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(showLog, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE) + .add(cancelButton))) + .add(layout.createSequentialGroup() + .add(jLabel6) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(portText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 53, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) + .add(11, 11, 11)))) + .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel7)) + .add(71, 71, 71)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .add(24, 24, 24) + .add(jLabel7) + .add(26, 26, 26) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) + .add(layout.createSequentialGroup() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(hostText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(jLabel5) + .add(jLabel6) + .add(portText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(jLabel3) + .add(userText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(jLabel2) + .add(passwordText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(jLabel4) + .add(dbText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) + .add(layout.createSequentialGroup() + .add(startButton) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(showLog) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(cancelButton))) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(newDb) + .add(newDbText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(24, 24, 24) + .add(logLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(checkconnButton) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(exampleButton) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(continueButton) + .add(13, 13, 13)) + ); + + pack(); + }// //GEN-END:initComponents + + private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed + new Start().setVisible(true); + this.dispose(); +}//GEN-LAST:event_cancelButtonActionPerformed + + private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startButtonActionPerformed + host = hostText.getText(); + port = portText.getText(); + username = userText.getText(); + password = passwordText.getText(); + if (newDb.isSelected()) { + database = newDbText.getText(); + } else { + database = dbText.getSelectedItem().toString(); + } + Component source = (Component) evt.getSource(); + int i = confirmPane.showConfirmDialog(source, "Are you sure?", "Database Replace", JOptionPane.YES_NO_OPTION); + if (i == 0) { + try { + createTables(); + Thread.sleep(3000); + new OlsrdDataSource(host,port,username,password).init(); + } catch (ClassNotFoundException ex) { + logLabel.setText(ex.getMessage()); + Logger.getLogger(LatLonJsToMySQL.class.getName()).log(Level.SEVERE, null, ex); + } catch (SQLException ex) { + logLabel.setText(ex.getMessage()); + Logger.getLogger(LatLonJsToMySQL.class.getName()).log(Level.SEVERE, null, ex); + } catch (Exception ex) { + ex.getMessage(); + } + } else { + confirmPane.setVisible(false); + } +}//GEN-LAST:event_startButtonActionPerformed + + private void checkconnButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkconnButtonActionPerformed + try { + host = hostText.getText(); + port = portText.getText(); + username = userText.getText(); + password = passwordText.getText(); + if (host.length() < 2) { + if (port.length() == 0) { + port = "3306"; + } + logLabel.setForeground(Color.red); + logLabel.setText("Add host address and port number!"); + } else { + logLabel.setText("Getting connection..."); + Thread.sleep(1000); + Class.forName("com.mysql.jdbc.Driver"); + c = (Connection) DriverManager.getConnection("jdbc:mysql://" + host + ":" + port, username, password); + if (!c.isClosed()) { + stmt = (Statement) c.createStatement(); + rss = stmt.executeQuery("SHOW DATABASES"); + int i = 0; + while (rss.next()) { + dbText.insertItemAt(rss.getString("Database"), i); + i++; + logLabel.setForeground(Color.green); + logLabel.setText("Connected!"); + dbText.setSelectedIndex(0); + } + } + } + } catch (Exception ex) { + logLabel.setForeground(Color.red); + logLabel.setText(ex.getMessage()); + } + + }//GEN-LAST:event_checkconnButtonActionPerformed + + private void createTables() throws ClassNotFoundException, SQLException { + try { + logLabel.setForeground(Color.black); + logLabel.setText("Creating Table in " + database + " database..."); + Class.forName("com.mysql.jdbc.Driver"); + errors.put("DATABASE:", "Getting Connection for CreateTables...\n"); + logLabel.setText("Getting Connection for CreateTables..."); + + String queryDel = "DROP SCHEMA IF EXISTS " + database + ";"; + + String queryCreate = "CREATE SCHEMA IF NOT EXISTS " + database + ";"; + + String queryUse = "use " + database + "; "; + + String query = "CREATE TABLE nodes (lon float DEFAULT '12.5535', " + + "lat float DEFAULT '41.8638', " + + "ip varchar(32) NOT NULL, " + + "name varchar(32) NOT NULL, " + + "isGateway binary(1) NOT NULL, " + + "gatewayIp varchar(32) NOT NULL, " + + "uptime varchar(10) DEFAULT NULL," + + "interfaces varchar(50) DEFAULT NULL, " + + "PRIMARY KEY (name),KEY ip (ip)" + + ") ENGINE=InnoDB DEFAULT CHARSET=latin1; "; + + String query2 = "CREATE TABLE flows (RECNUM bigint(20) unsigned zerofill NOT NULL AUTO_INCREMENT, " + + "PROBE varchar(16) NOT NULL DEFAULT '',TIME_RECEIVED datetime NOT NULL DEFAULT '0000-00-00 00:00:00'," + + "FLOW_VERSION tinyint(4) NOT NULL DEFAULT '0'," + + "SEQUENCE bigint(20) unsigned zerofill NOT NULL DEFAULT '00000000000000000000'," + + "SOURCE_IP varchar(16) NOT NULL DEFAULT ''," + + "SOURCE_PORT int(11) NOT NULL DEFAULT '0'," + + "DEST_IP varchar(16) NOT NULL DEFAULT ''," + + "DEST_PORT int(11) NOT NULL DEFAULT '0'," + + "NEXT_HOP varchar(16) NOT NULL DEFAULT ''," + + "PROTOCOL int(11) NOT NULL DEFAULT '0'," + + "TCP_FLAGS int(11) NOT NULL DEFAULT '0'," + + "TOS int(11) NOT NULL DEFAULT '0'," + + "BYTES bigint(20) unsigned NOT NULL DEFAULT '0'," + + "PACKETS bigint(20) unsigned NOT NULL DEFAULT '0'," + + "FLOW_BEGIN datetime NOT NULL DEFAULT '0000-00-00 00:00:00'," + + "FLOW_END datetime NOT NULL DEFAULT '0000-00-00 00:00:00'," + + "SOURCE_AS int(11) NOT NULL DEFAULT '0'," + + "DEST_AS int(11) NOT NULL DEFAULT '0'," + + "SOURCE_MASK smallint(6) NOT NULL DEFAULT '0'," + + "DEST_MASK smallint(6) NOT NULL DEFAULT '0'," + + "PRIMARY KEY (RECNUM),KEY k_begin (FLOW_BEGIN)," + + "KEY k_end (FLOW_END),KEY k_time (TIME_RECEIVED)," + + "KEY k_src (SOURCE_IP),KEY k_dst (DEST_IP)" + + ") ENGINE=MyISAM DEFAULT CHARSET=latin1;"; + + String query3 = "CREATE TABLE links (clock timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'," + + "src varchar(32) NOT NULL DEFAULT ''," + + "dest varchar(32) NOT NULL DEFAULT ''," + + "lq float DEFAULT NULL," + + "nlq float DEFAULT NULL," + + "etx float DEFAULT NULL," + + "PRIMARY KEY (clock,src,dest)," + + "KEY src (src)," + + "KEY dest (dest)," + + "CONSTRAINT links_ibfk_2 FOREIGN KEY (dest) REFERENCES nodes (ip)," + + "CONSTRAINT links_ibfk_1 FOREIGN KEY (src) REFERENCES nodes (ip)" + + ") ENGINE=InnoDB DEFAULT CHARSET=latin1; "; + + String query4 = "CREATE TABLE layer (" + + "id int(11) NOT NULL AUTO_INCREMENT," + + "srcnode varchar(32) DEFAULT NULL," + + "clock varchar(10) NULL DEFAULT NULL," + + "destnode varchar(32) DEFAULT NULL," + + "PRIMARY KEY (id)," + + "KEY srcnode (srcnode)," + + "KEY destnode (destnode)," + + "CONSTRAINT layer_ibfk_2 FOREIGN KEY (destnode) REFERENCES links (dest)," + + "CONSTRAINT layer_ibfk_1 FOREIGN KEY (srcnode) REFERENCES links (src)" + + ") ENGINE=InnoDB DEFAULT CHARSET=latin1;"; + + String query5 = "CREATE TABLE interfaces (mainIp varchar(32) NOT NULL DEFAULT ''," + + "IntIp varchar(32) DEFAULT NULL," + + "KEY mainIp (mainIp)" + + ") ENGINE=InnoDB DEFAULT CHARSET=latin1"; + + Connection c2 = (Connection) DriverManager.getConnection("jdbc:mysql://" + host + ":" + port, username, password); + Statement stmt2 = (Statement) c2.createStatement(); + errors.put("DATABASE:", "Connected to the database...\n"); + logLabel.setText("Execute Queries..."); + + Thread.sleep(3000); + System.out.println(queryDel); + + System.out.println(queryCreate); + System.out.println(queryUse); + System.out.println(query); + System.out.println(query2); + System.out.println(query3); + System.out.println(query4); + System.out.println(query5); + + + stmt2.executeUpdate(queryDel); + errors.put("DATABASE_QUERY:", queryDel + "\n"); + + stmt2.executeUpdate(queryCreate); + errors.put("DATABASE_QUERY:", queryCreate + "\n"); + + stmt2.executeQuery(queryUse); + errors.put("DATABASE_QUERY:", queryUse + "\n"); + + Thread.sleep(1000); + stmt2.executeUpdate(query); + errors.put("DATABASE_QUERY:", query + "\n"); + Thread.sleep(1000); + + stmt2.executeUpdate(query2); + errors.put("DATABASE_QUERY:", query2 + "\n"); + Thread.sleep(1000); + + stmt2.executeUpdate(query3); + errors.put("DATABASE_QUERY:", query3 + "\n"); + Thread.sleep(1000); + + stmt2.executeUpdate(query4); + errors.put("DATABASE:", query4 + "\n"); + Thread.sleep(1000); + + stmt2.executeUpdate(query5); + errors.put("DATABASE:", query5 + "\n"); + Thread.sleep(1000); + + errors.put("DATABASE:", "Now Adding nodes and Links....! This will take a while...\n"); + logLabel.setText("Now Adding nodes and Links....! This will take a while.."); + Thread.sleep(1500); + + } catch (Exception e) { + System.out.println(e.getMessage()); + } + + } + + + + private void showLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showLogActionPerformed + scrollPane.setSize(398, 298); + errorsLog.append(errors.values().toString()); + frame = new Frame("Activity Log"); + frame.add(scrollPane); + frame.setLayout(new FlowLayout()); + frame.setSize(400, 300); + frame.setVisible(true); + frame.addWindowListener(new WindowAdapter() { + + public void windowClosing(WindowEvent e) { + frame.setVisible(false); + + + } + }); + }//GEN-LAST:event_showLogActionPerformed + + private void exampleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exampleButtonActionPerformed + userText.setText("root"); + passwordText.setText("CiscoSte5785"); + hostText.setText("127.0.0.1"); + }//GEN-LAST:event_exampleButtonActionPerformed + + private void confirmPanePropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_confirmPanePropertyChange + System.out.println("PopUp3"); + String prop = evt.getPropertyName(); + + + if (evt.getSource().equals(confirmPane) && prop.equals(JOptionPane.YES_OPTION)) { + try { + logLabel.setText("Getting connection..."); + Thread.sleep(1000); + Class.forName("com.mysql.jdbc.Driver"); + c = (Connection) DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password); + + + if (!c.isClosed()) { + logLabel.setForeground(Color.green); + logLabel.setText("Connected!"); + createTables(); + Thread.sleep(3000); + } + } catch (Exception ex) { + logLabel.setText(ex.getMessage()); + Logger.getLogger(LatLonJsToMySQL.class.getName()).log(Level.SEVERE, null, ex); + } + + + } else { + optionPane.setEnabled(false); + + + } + +// TODO add your handling code here: + }//GEN-LAST:event_confirmPanePropertyChange + + private void newDbItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_newDbItemStateChanged + if (newDb.isSelected()) { + newDbText.setEnabled(true); + dbText.setEnabled(false); + + + } else if (!newDb.isSelected()) { + newDbText.setEnabled(false); + dbText.setEnabled(true); + + + } + }//GEN-LAST:event_newDbItemStateChanged + + private void continueButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_continueButtonActionPerformed + OlsrdDataSource noStore=new OlsrdDataSource(); + noStore.init(); + }//GEN-LAST:event_continueButtonActionPerformed + + private String stripQuotes(String str) { + if (str.length() <= 2) { + return null; + + } + return str.substring(1, str.length() - 1); + + } + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + + public void run() { + new LatLonJsToMySQL().setVisible(true); + + + + } + }); + + + + + + } + Frame frame = null; + Connection c = null; + ResultSet rss = null; + Statement stmt = null; + String line = null; + HashMap errors = new HashMap(); + String host; + String username; + String password; + String database; + String port; + JOptionPane optionPane = null; + String path; + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton cancelButton; + private javax.swing.JButton checkconnButton; + private javax.swing.JOptionPane confirmPane; + private javax.swing.JButton continueButton; + private javax.swing.JComboBox dbText; + private javax.swing.JTextArea errorsLog; + private javax.swing.JButton exampleButton; + private javax.swing.JTextField hostText; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel logLabel; + private javax.swing.JCheckBox newDb; + private javax.swing.JTextField newDbText; + private javax.swing.JPasswordField passwordText; + private javax.swing.JTextField portText; + private javax.swing.JScrollPane scrollPane; + private javax.swing.JButton showLog; + private javax.swing.JButton startButton; + private javax.swing.JTextField userText; + // End of variables declaration//GEN-END:variables +} diff --git a/src/freimapgsoc/OlsrdDataSource.java b/src/freimapgsoc/OlsrdDataSource.java index 48f5759..ce68239 100755 --- a/src/freimapgsoc/OlsrdDataSource.java +++ b/src/freimapgsoc/OlsrdDataSource.java @@ -1,218 +1,275 @@ /* net.relet.freimap.OlsrdDataSource.java - This file is part of the freimap software available at freimap.berlios.de +This file is part of the freimap software available at freimap.berlios.de - This software is copyright (c)2007 Thomas Hirsch +This software is copyright (c)2007 Thomas Hirsch - 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 2 of the License, or - (at your option) any later version. +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 2 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 with - the Debian GNU/Linux distribution in file /doc/gpl.txt - if not, write to the Free Software Foundation, Inc., 59 Temple Place, - Suite 330, Boston, MA 02111-1307 USA -*/ +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 with +the Debian GNU/Linux distribution in file /doc/gpl.txt +if not, write to the Free Software Foundation, Inc., 59 Temple Place, +Suite 330, Boston, MA 02111-1307 USA + */ package freimapgsoc; +import com.mysql.jdbc.Connection; +import com.mysql.jdbc.Statement; import java.io.*; import java.net.*; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; public class OlsrdDataSource implements DataSource { - DotPluginListener dot; - DataSourceListener listener; - TreeMap> data = new TreeMap>(); - Hashtable knownNodes=new Hashtable(); - Hashtable generatedNodes=new Hashtable(); - - long lastUpdateTime = 1, - firstUpdateTime = 1; - String nodefile; - - MysqlDataSource mysqlSource; - xmlDataSource ffmdSource; - - DataSource nodeSource; - String sNodeSource; - - public OlsrdDataSource() { - } - - - public void init(HashMap conf) { - String host = "localhost"; - int port = 2004; - - // nodefile = Configurator.getS("nodefile", conf); - //System.out.println("nodefile = "+nodefile); - - //sNodeSource = Configurator.getS("nodesource", conf); - - if (port==-1) { - System.err.println("invalid port parameter "+port); - System.exit(1); + + DotPluginListener dot; + DataSourceListener listener; + TreeMap> data = new TreeMap>(); + Hashtable knownNodes = new Hashtable(); + Hashtable generatedNodes = new Hashtable(); + long lastUpdateTime = 1, + firstUpdateTime = 1; + String nodefile; + MysqlDataSource mysqlSource; + xmlDataSource ffmdSource; + DataSource nodeSource; + String sNodeSource; + String username, password, host, port; + Connection c = null; + ResultSet rss; + Statement stmt; + + public OlsrdDataSource() { } - dot = new DotPluginListener(host, port, this); - } - /** - * public void init(HashMap conf) { - * String host = Configurator.getS("host", conf); - * int port = Configurator.getI("port", conf); - * - * nodefile = Configurator.getS("nodefile", conf); - * //System.out.println("nodefile = "+nodefile); - * - * sNodeSource = Configurator.getS("nodesource", conf); - * - * if (port==-1) { - * System.err.println("invalid port parameter "+port); - * System.exit(1); - * } - * dot = new DotPluginListener(host, port, this); - * } - * @return - */ - - @SuppressWarnings("unchecked") - public Vector getNodeList() { - if ((nodeSource == null) && (sNodeSource != null)) { - System.out.println("nodeSource in OlsrdDataSource.java:"+ nodeSource); - //nodeSource=.get(sNodeSource); - sNodeSource = null; + + public OlsrdDataSource(String host, String port, String username, String password) { + this.host = host; + this.port = port; + this.username = username; + this.password = password; } - if (nodeSource!=null) { - Vector nodes = nodeSource.getNodeList(); - for (Enumeration enu = generatedNodes.keys(); enu.hasMoreElements();) { - nodes.add(generatedNodes.get(enu.nextElement())); - } - - for (int i=0;i nodes = (Vector)ois.readObject(); - ois.close(); - for (int i=0;i conf) { + String host = "localhost"; + int port = 2004; + + // nodefile = Configurator.getS("nodefile", conf); + //System.out.println("nodefile = "+nodefile); + + //sNodeSource = Configurator.getS("nodesource", conf); + + if (port == -1) { + System.err.println("invalid port parameter " + port); + System.exit(1); + } + dot = new DotPluginListener(host, port, this); } - MapNode node= knownNodes.get(id); - if (node!=null) return node; - else return generatedNodes.get(id); - } - - public HashMap getNodeAvailability(long time) { - if (nodeSource!=null) { - return nodeSource.getNodeAvailability(time); - } else { - return new HashMap(); //empty + + /** + * public void init(HashMap conf) { + * String host = Configurator.getS("host", conf); + * int port = Configurator.getI("port", conf); + * + * nodefile = Configurator.getS("nodefile", conf); + * //System.out.println("nodefile = "+nodefile); + * + * sNodeSource = Configurator.getS("nodesource", conf); + * + * if (port==-1) { + * System.err.println("invalid port parameter "+port); + * System.exit(1); + * } + * dot = new DotPluginListener(host, port, this); + * } + * @return + */ + @SuppressWarnings("unchecked") + public Vector getNodeList() { + if (setConnection()) { + if ((nodeSource == null) && (sNodeSource != null)) { + System.out.println("nodeSource in OlsrdDataSource.java:" + nodeSource); + //nodeSource=.get(sNodeSource); + sNodeSource = null; + } + + if (nodeSource != null) { + Vector nodes = nodeSource.getNodeList(); + for (Enumeration enu = generatedNodes.keys(); enu.hasMoreElements();) { + nodes.add(generatedNodes.get(enu.nextElement())); + } + + for (int i = 0; i < nodes.size(); i++) { + knownNodes.put(nodes.elementAt(i).ip, nodes.elementAt(i)); + } + return nodes; + } else { + try { + ObjectInputStream ois = new ObjectInputStream(ClassLoader.getSystemResourceAsStream(nodefile)); + Vector nodes = (Vector) ois.readObject(); + ois.close(); + for (int i = 0; i < nodes.size(); i++) { + knownNodes.put(nodes.elementAt(i).ip, nodes.elementAt(i)); + } + return nodes; + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + return null; } - } - public long getLastUpdateTime() { - return lastUpdateTime; - } - public long getFirstUpdateTime() { - return firstUpdateTime; - } - public long getLastAvailableTime() { - return lastUpdateTime; - } - public long getFirstAvailableTime() { - return firstUpdateTime; - } - - - public long getClosestUpdateTime(long time) { - long cur=-1, closest = Long.MAX_VALUE; - Set keys = data.keySet(); - Iterator ki = keys.iterator(); - while (ki.hasNext()) { - cur = ki.next().longValue(); - long d=Math.abs(time-cur); - if (d getLinks(long time) { - Vector linkdata = data.get(new Long(time)); - return linkdata; - } - //threaded information fetching - public void addDataSourceListener(DataSourceListener dsl) { - listener = dsl; - if (!dot.isAlive()) dot.start(); - } - //some optional methods - public void getLinkCountProfile(MapNode node, NodeInfo info) { - LinkedList lcp=new LinkedList(); - //select HIGH_PRIORITY unix_timestamp(clock) as time, count(*) as num_links from "+TABLE_LINKS+" where dest='"+node.id+"' group by clock" - Iterator times=data.keySet().iterator(); - while(times.hasNext()) { - Long time=times.next(); - Vector links=data.get(time); - int lc=0; - for (int i=0; i getNodeAvailability(long time) { + if (nodeSource != null) { + return nodeSource.getNodeAvailability(time); + } else { + return new HashMap(); //empty } - } - lcp.add(new LinkCount(time.longValue(), lc)); } - info.setLinkCountProfile(lcp); - } - public void getLinkProfile(Link mylink, LinkInfo info) { - LinkedList lp=new LinkedList(); - //select HIGH_PRIORITY unix_timestamp(clock) as time, quality from "+TABLE_LINKS+" where src='"+link.from.id+"' and dest='"+link.to.id+"'"); - Iterator times=data.keySet().iterator(); - while (times.hasNext()) { - Long time=times.next(); - Vector links=data.get(time); - float quality=0; - for (int i=0; i keys = data.keySet(); + Iterator ki = keys.iterator(); + while (ki.hasNext()) { + cur = ki.next().longValue(); + long d = Math.abs(time - cur); + if (d < closest) { + closest = d; + } else { + break; + } + } + return cur; + } + + public Vector getLinks(long time) { + Vector linkdata = data.get(new Long(time)); + return linkdata; + } + //threaded information fetching + + public void addDataSourceListener(DataSourceListener dsl) { + listener = dsl; + if (!dot.isAlive()) { + dot.start(); + } + } + //some optional methods + + public void getLinkCountProfile(MapNode node, NodeInfo info) { + LinkedList lcp = new LinkedList(); + //select HIGH_PRIORITY unix_timestamp(clock) as time, count(*) as num_links from "+TABLE_LINKS+" where dest='"+node.id+"' group by clock" + Iterator times = data.keySet().iterator(); + while (times.hasNext()) { + Long time = times.next(); + Vector links = data.get(time); + int lc = 0; + for (int i = 0; i < links.size(); i++) { + Link link = links.elementAt(i); + if (link.dest.equals(node)) { + lc++; + } + } + lcp.add(new LinkCount(time.longValue(), lc)); } - } - lp.add(new LinkData(time.longValue(), quality)); + info.setLinkCountProfile(lcp); } - info.setLinkProfile(lp); - } - //private methods - private void addLinkData(long time, Vector linkData) { - data.put(new Long(time), linkData); - if (firstUpdateTime==1) firstUpdateTime=time; - lastUpdateTime=time; - if (listener != null) listener.timeRangeAvailable(firstUpdateTime, lastUpdateTime); - } + public void getLinkProfile(Link mylink, LinkInfo info) { + LinkedList lp = new LinkedList(); + //select HIGH_PRIORITY unix_timestamp(clock) as time, quality from "+TABLE_LINKS+" where src='"+link.from.id+"' and dest='"+link.to.id+"'"); + Iterator times = data.keySet().iterator(); + while (times.hasNext()) { + Long time = times.next(); + Vector links = data.get(time); + float quality = 0; + for (int i = 0; i < links.size(); i++) { + Link link = links.elementAt(i); + if (link.equals(mylink)) { + quality = link.etx; + } + } + lp.add(new LinkData(time.longValue(), quality)); + } + info.setLinkProfile(lp); + } + + //private methods + private void addLinkData(long time, Vector linkData) { + data.put(new Long(time), linkData); + if (firstUpdateTime == 1) { + firstUpdateTime = time; + } + lastUpdateTime = time; + if (listener != null) { + listener.timeRangeAvailable(firstUpdateTime, lastUpdateTime); + } + } public void init(String path) { throw new UnsupportedOperationException("Not supported yet."); @@ -239,120 +296,127 @@ public Vector getLinksFromDest(String id) { } /** - * - * @param ip - * @return - */ - @Override + * + * @param ip + * @return + */ + @Override public MapNode getNodeByIp(String ip) { throw new UnsupportedOperationException("Not supported yet."); } /** - * - * @return - */ - @Override + * + * @return + */ + @Override public void init() { throw new UnsupportedOperationException("Not supported yet."); } /** - * - * @param configuration - * @return - */ - @Override + * + * @param configuration + * @return + */ + @Override public HashMap read_conf(HashMap configuration) { throw new UnsupportedOperationException("Not supported yet."); } /** - * - * @return - */ - @Override + * + * @return + */ + @Override public Vector getLinks() { throw new UnsupportedOperationException("Not supported yet."); } + //Listener Of DotDraw Plugin + class DotPluginListener extends Thread { + BufferedReader in; + String host; + int port; + OlsrdDataSource parent; - //Listener Of DotDraw Plugin - class DotPluginListener extends Thread { - BufferedReader in; - String host; - int port; - OlsrdDataSource parent; - - //DotDraw Constructor - public DotPluginListener(String host, int port, OlsrdDataSource parent) { - this.parent=parent; - this.host=host; - this.port=port; - System.setProperty("java.net.IPv4Stack", "true"); //not necessary, but works around a bug in older java versions. - } + //DotDraw Constructor + public DotPluginListener(String host, int port, OlsrdDataSource parent) { + this.parent = parent; + this.host = host; + this.port = port; + System.setProperty("java.net.IPv4Stack", "true"); //not necessary, but works around a bug in older java versions. + } - //DotDraw Methods that open a Socket on the port 2004 and listen the traffic - public void run() { - Vector linkData = null; - try { - InetSocketAddress destination = new InetSocketAddress(host, port); - while (true) { //reconnect upon disconnection - Socket s = new Socket(); - //s.setSoTimeout(10000); - s.connect(destination, 25000); - in = new BufferedReader(new InputStreamReader(s.getInputStream())); - while (in!=null) { - String line=in.readLine(); - { //this used to be a try-catch statement - if (line==null) break; - if (line.equals("digraph topology")) { - if (linkData!=null) parent.addLinkData(System.currentTimeMillis()/1000, linkData); - linkData = new Vector(); - } else if ((linkData != null) && (line.length()>0) && (line.charAt(0)=='"')) { - StringTokenizer st=new StringTokenizer(line, "\"", false); - String from = st.nextToken(); - //if (from.indexOf("/")>-1) { from = from.substring(0, from.indexOf("/")); } - st.nextToken(); - if (st.hasMoreTokens()) { //otherwise it's a gateway node! - String to = st.nextToken(); - //if (to.indexOf("/")>-1) { to = to.substring(0, to.indexOf("/")); } - st.nextToken(); - String setx = st.nextToken(); - if(setx.equals("INFINITE")){ - setx = "0"; - } - boolean hna = setx.equals("HNA"); - float etx = hna?0:Float.parseFloat(setx); - MapNode nfrom = getNodeByName(from), - nto = getNodeByName(to); - if (nfrom == null) { - nfrom = new MapNode(from); - generatedNodes.put(from, nfrom); - if (listener!=null) listener.nodeListUpdate(nfrom); - } - if (nto == null) { - nto = new MapNode(to); - generatedNodes.put(to, nto); - if (listener!=null) listener.nodeListUpdate(nto); - } - linkData.add(new Link(nfrom, nto, etx, hna)); + //DotDraw Methods that open a Socket on the port 2004 and listen the traffic + public void run() { + Vector linkData = null; + try { + InetSocketAddress destination = new InetSocketAddress(host, port); + while (true) { //reconnect upon disconnection + Socket s = new Socket(); + //s.setSoTimeout(10000); + s.connect(destination, 25000); + in = new BufferedReader(new InputStreamReader(s.getInputStream())); + while (in != null) { + String line = in.readLine(); + { //this used to be a try-catch statement + if (line == null) { + break; + } + if (line.equals("digraph topology")) { + if (linkData != null) { + parent.addLinkData(System.currentTimeMillis() / 1000, linkData); + } + linkData = new Vector(); + } else if ((linkData != null) && (line.length() > 0) && (line.charAt(0) == '"')) { + StringTokenizer st = new StringTokenizer(line, "\"", false); + String from = st.nextToken(); + //if (from.indexOf("/")>-1) { from = from.substring(0, from.indexOf("/")); } + st.nextToken(); + if (st.hasMoreTokens()) { //otherwise it's a gateway node! + String to = st.nextToken(); + //if (to.indexOf("/")>-1) { to = to.substring(0, to.indexOf("/")); } + st.nextToken(); + String setx = st.nextToken(); + if (setx.equals("INFINITE")) { + setx = "0"; + } + boolean hna = setx.equals("HNA"); + float etx = hna ? 0 : Float.parseFloat(setx); + MapNode nfrom = getNodeByName(from), + nto = getNodeByName(to); + if (nfrom == null) { + nfrom = new MapNode(from); + generatedNodes.put(from, nfrom); + if (listener != null) { + listener.nodeListUpdate(nfrom); + } + } + if (nto == null) { + nto = new MapNode(to); + generatedNodes.put(to, nto); + if (listener != null) { + listener.nodeListUpdate(nto); + } + } + linkData.add(new Link(nfrom, nto, etx, hna)); + } + } + } + } + Thread.sleep(1000); } - } + } catch (SocketTimeoutException ex) { + System.err.println("[OlsrdDataSource] timeout while trying to connect. " + ex.getMessage()); + return; + } catch (ConnectException ex) { + System.err.println("connection to " + host + ":" + port + " failed. Detailed node data won't be available."); + return; + } catch (Exception ex) { + ex.printStackTrace(); } - } - Thread.sleep(1000); } - } catch (SocketTimeoutException ex) { - System.err.println("[OlsrdDataSource] timeout while trying to connect. "+ex.getMessage()); - return; - } catch (ConnectException ex) { - System.err.println("connection to " + host + ":" + port + " failed. Detailed node data won't be available."); - return; - } catch (Exception ex) { - ex.printStackTrace(); - } } - } } diff --git a/src/freimapgsoc/ServiceDiscovery.java b/src/freimapgsoc/ServiceDiscovery.java index 192aa7b..41495b0 100755 --- a/src/freimapgsoc/ServiceDiscovery.java +++ b/src/freimapgsoc/ServiceDiscovery.java @@ -103,8 +103,7 @@ public ServiceDiscovery(JmDNS jmdns) throws IOException { initComponents(); this.jmdns = jmdns; // jmdns.addServiceTypeListener(this); - for (int i = 0; i - < list.length; i++) { + for (int i = 0; i< list.length; i++) { jmdns.registerServiceType(list[i]); } } diff --git a/src/freimapgsoc/ServiceDiscoveryUnicast.form b/src/freimapgsoc/ServiceDiscoveryUnicast.form index 76a7b2d..9d08596 100644 --- a/src/freimapgsoc/ServiceDiscoveryUnicast.form +++ b/src/freimapgsoc/ServiceDiscoveryUnicast.form @@ -34,10 +34,10 @@ - - - - + + + + @@ -49,7 +49,7 @@ - + @@ -145,12 +145,9 @@ - - - - - - + + + @@ -175,14 +172,14 @@ - + - + @@ -191,11 +188,8 @@ - - - - - + + @@ -210,42 +204,37 @@ - + - + - + - - - - - - + - + - + @@ -309,9 +298,9 @@ - + - + @@ -402,7 +391,9 @@ + +
@@ -449,26 +440,27 @@ - - + + - + - + - + + - + diff --git a/src/freimapgsoc/ServiceDiscoveryUnicast.java b/src/freimapgsoc/ServiceDiscoveryUnicast.java index 16cb6df..e031c68 100644 --- a/src/freimapgsoc/ServiceDiscoveryUnicast.java +++ b/src/freimapgsoc/ServiceDiscoveryUnicast.java @@ -307,39 +307,38 @@ private void initComponents() { jPanel1.setName("jPanel1"); // NOI18N jPanel1.setPreferredSize(new java.awt.Dimension(500, 162)); - jLabel7.setFont(resourceMap.getFont("jLabel12.font")); // NOI18N + jLabel7.setFont(resourceMap.getFont("jLabel7.font")); // NOI18N jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N jLabel7.setName("jLabel7"); // NOI18N - jLabel8.setFont(resourceMap.getFont("jLabel12.font")); // NOI18N + jLabel8.setFont(resourceMap.getFont("jLabel7.font")); // NOI18N jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N jLabel8.setName("jLabel8"); // NOI18N nodeIPs.setFont(resourceMap.getFont("nodeIPs.font")); // NOI18N - nodeIPs.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + nodeIPs.setModel(new javax.swing.DefaultComboBoxModel(new String[] { " " })); nodeIPs.setName("nodeIPs"); // NOI18N nodeName.setFont(resourceMap.getFont("nodeName.font")); // NOI18N nodeName.setText(resourceMap.getString("nodeName.text")); // NOI18N nodeName.setName("nodeName"); // NOI18N - jLabel11.setFont(resourceMap.getFont("jLabel12.font")); // NOI18N + jLabel11.setFont(resourceMap.getFont("jLabel7.font")); // NOI18N jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N jLabel11.setName("jLabel11"); // NOI18N - nodeLatLon.setFont(resourceMap.getFont("jLabel12.font")); // NOI18N + nodeLatLon.setFont(resourceMap.getFont("jLabel7.font")); // NOI18N nodeLatLon.setText(resourceMap.getString("nodeLatLon.text")); // NOI18N nodeLatLon.setName("nodeLatLon"); // NOI18N - jComboBox2.setFont(resourceMap.getFont("jComboBox1.font")); // NOI18N - jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + jComboBox2.setFont(resourceMap.getFont("jComboBox2.font")); // NOI18N jComboBox2.setName("jComboBox2"); // NOI18N - jLabel16.setFont(resourceMap.getFont("jLabel12.font")); // NOI18N + jLabel16.setFont(resourceMap.getFont("jLabel7.font")); // NOI18N jLabel16.setText(resourceMap.getString("jLabel16.text")); // NOI18N jLabel16.setName("jLabel16"); // NOI18N - nodegw.setFont(resourceMap.getFont("jLabel12.font")); // NOI18N + nodegw.setFont(resourceMap.getFont("jLabel7.font")); // NOI18N nodegw.setText(resourceMap.getString("nodegw.text")); // NOI18N nodegw.setName("nodegw"); // NOI18N @@ -415,11 +414,9 @@ private void initComponents() { .addComponent(upTimeLab) .addComponent(nodegw))) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel8) - .addComponent(nodeIPs, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(35, 35, 35)) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel8) + .addComponent(nodeIPs, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(35, 35, 35) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) @@ -454,7 +451,9 @@ private void initComponents() { info.setColumns(20); info.setEditable(false); + info.setFont(resourceMap.getFont("info.font")); // NOI18N info.setRows(5); + info.setText(resourceMap.getString("info.text")); // NOI18N info.setName("info"); // NOI18N jScrollPane3.setViewportView(info); @@ -486,8 +485,8 @@ private void initComponents() { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 252, Short.MAX_VALUE)) + .addContainerGap()) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -519,23 +518,24 @@ private void initComponents() { jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel3Layout.createSequentialGroup() - .addContainerGap(49, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(94, 94, 94) .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(119, 119, 119) + .addGap(285, 285, 285) .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(149, 149, 149)) + .addContainerGap()) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel3Layout.createSequentialGroup() + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() + .addContainerGap(20, Short.MAX_VALUE) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(135, Short.MAX_VALUE)) + .addGap(194, 194, 194)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); @@ -544,10 +544,10 @@ private void initComponents() { layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 671, Short.MAX_VALUE) - .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 671, Short.MAX_VALUE) - .addComponent(jPanel1, 0, 671, Short.MAX_VALUE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, 0, 679, Short.MAX_VALUE) + .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 679, Short.MAX_VALUE) + .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 679, Short.MAX_VALUE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup( @@ -556,7 +556,7 @@ private void initComponents() { .addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE) .addContainerGap()) diff --git a/src/freimapgsoc/Start.form b/src/freimapgsoc/Start.form index 8d9a6e5..f6e5388 100644 --- a/src/freimapgsoc/Start.form +++ b/src/freimapgsoc/Start.form @@ -23,27 +23,35 @@ - + + - - - - - + - + - + + + + + + + + + + + + @@ -62,7 +70,11 @@ - + + + + +
@@ -122,5 +134,19 @@ + + + + + + + + + + + + + + diff --git a/src/freimapgsoc/Start.java b/src/freimapgsoc/Start.java index fc93d60..b510fd9 100644 --- a/src/freimapgsoc/Start.java +++ b/src/freimapgsoc/Start.java @@ -41,6 +41,8 @@ private void initComponents() { secondLabel = new javax.swing.JLabel(); openExampleFile = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setName("Form"); // NOI18N @@ -90,26 +92,41 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N jLabel1.setName("jLabel1"); // NOI18N + jLabel2.setFont(resourceMap.getFont("jLabel2.font")); // NOI18N + jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N + jLabel2.setName("jLabel2"); // NOI18N + + jButton1.setFont(resourceMap.getFont("jButton1.font")); // NOI18N + jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N + jButton1.setName("jButton1"); // NOI18N + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(jLabel1)) - .addGroup(layout.createSequentialGroup() - .addGap(48, 48, 48) + .addGap(34, 34, 34) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(olsrdButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(mySQLButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(openExampleFile, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(openFileButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE))) + .addComponent(openFileButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(layout.createSequentialGroup() - .addGap(95, 95, 95) - .addComponent(secondLabel))) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGap(81, 81, 81) + .addComponent(secondLabel)) + .addComponent(jLabel2)) + .addGap(8, 8, 8)) + .addGroup(layout.createSequentialGroup() + .addGap(116, 116, 116) + .addComponent(jButton1) + .addContainerGap(134, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel1) + .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -126,7 +143,11 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(openFileButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(openExampleFile) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel2) + .addGap(18, 18, 18) + .addComponent(jButton1) + .addContainerGap(10, Short.MAX_VALUE)) ); pack(); @@ -135,11 +156,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { private void olsrdButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_olsrdButtonActionPerformed //new Layer(new OlsrdDataSource().init()); CheckActiveDataSource check = new CheckActiveDataSource(); - if(check.mySql){ - MysqlDataSource ds=new MysqlDataSource(); - ds.init(); - } - + MySQLCredential mysqlcr=new MySQLCredential(); + mysqlcr.setVisible(true); }//GEN-LAST:event_olsrdButtonActionPerformed private void openFileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openFileButtonActionPerformed @@ -189,7 +207,9 @@ public void run() { }); } // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; private javax.swing.JButton mySQLButton; private javax.swing.JButton olsrdButton; private javax.swing.JButton openExampleFile; diff --git a/src/freimapgsoc/resources/ServiceDiscoveryUnicast.properties b/src/freimapgsoc/resources/ServiceDiscoveryUnicast.properties index 6e36356..314e862 100644 --- a/src/freimapgsoc/resources/ServiceDiscoveryUnicast.properties +++ b/src/freimapgsoc/resources/ServiceDiscoveryUnicast.properties @@ -9,8 +9,8 @@ jLabel2.text=Services: jLabel3.text=Detail: #NOI18N jLabel2.font=Lucida Grande-Plain-10 -nodeLatLon.text=jLabel13 -nodeName.text=jLabel9 +nodeLatLon.text=41.8637595/12.5535823 +nodeName.text=StefanoP #NOI18N nodeName.font=Lucida Grande-Plain-10 #NOI18N @@ -18,11 +18,18 @@ nodeIPs.font=Lucida Grande-Plain-10 upTimeLab.text=UpTime: #NOI18N upTimeLab.font=Lucida Grande 10-Plain-10 -nodegw.text=jLabel13 -jLabel9.text=Attributes: +nodegw.text=\ +4 days 3h 2m #NOI18N jLabel9.font=Lucida Grande 10-Plain-10 -attributeArea.text=jLabel9 +attributeArea.text=Gateway - 192.168.1.1 #NOI18N attributeArea.font=Lucida Grande 10-Plain-10 jButton1.text=See Fresnel Zone +#NOI18N +jComboBox2.font=Lucida Grande-Plain-10 +#NOI18N +jLabel7.font=Lucida Grande-Plain-10 +info.text= +#NOI18N +info.font=Lucida Grande-Plain-10 diff --git a/src/freimapgsoc/resources/Start.properties b/src/freimapgsoc/resources/Start.properties index f1ed088..dd8bd89 100644 --- a/src/freimapgsoc/resources/Start.properties +++ b/src/freimapgsoc/resources/Start.properties @@ -12,3 +12,9 @@ jLabel1.text= jLabel1.icon=aboutfreimap.png #NOI18N nameServiceButton.font=Lucida Grande-Plain-10 +jLabel2.text=If you want to store Mesh Network Data set the mysql credential +#NOI18N +jLabel2.font=Lucida Grande-Plain-10 +jButton1.text=Set MySql +#NOI18N +jButton1.font=Lucida Grande-Plain-10 diff --git a/src/freimapgsoc/resources/eth1Stefa b/src/freimapgsoc/resources/eth1Stefa new file mode 100644 index 0000000..18a08ab Binary files /dev/null and b/src/freimapgsoc/resources/eth1Stefa differ diff --git a/src/freimapgsoc/resources/eth2Stefa.png b/src/freimapgsoc/resources/eth2Stefa.png new file mode 100644 index 0000000..db00e9a Binary files /dev/null and b/src/freimapgsoc/resources/eth2Stefa.png differ diff --git a/src/freimapgsoc/resources/tap0Stefa.png b/src/freimapgsoc/resources/tap0Stefa.png new file mode 100644 index 0000000..925ec61 Binary files /dev/null and b/src/freimapgsoc/resources/tap0Stefa.png differ diff --git a/src/freimapgsoc/SDListener.java b/test/freimapgsoc/SDListener.java similarity index 100% rename from src/freimapgsoc/SDListener.java rename to test/freimapgsoc/SDListener.java diff --git a/src/freimapgsoc/SDMain.java b/test/freimapgsoc/SDMain.java similarity index 99% rename from src/freimapgsoc/SDMain.java rename to test/freimapgsoc/SDMain.java index f7d0d11..dcb4bad 100755 --- a/src/freimapgsoc/SDMain.java +++ b/test/freimapgsoc/SDMain.java @@ -5,6 +5,7 @@ package freimapgsoc; +import freimapgsoc.ServiceDiscovery; import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; diff --git a/src/freimapgsoc/SDResponder.java b/test/freimapgsoc/SDResponder.java similarity index 100% rename from src/freimapgsoc/SDResponder.java rename to test/freimapgsoc/SDResponder.java