Navázání DB spojení a kontrola databází SQL dotazem.
4 * Created on 30.12.2009, 2:22:41
6 package cz.frantovo.abcDrupal.gui;
8 import com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel;
9 import cz.frantovo.abcDrupal.Konvertor;
10 import cz.frantovo.abcDrupal.PosluchacLogu;
11 import cz.frantovo.abcDrupal.PromenneProstredi;
12 import java.util.logging.Level;
13 import java.util.logging.Logger;
14 import javax.swing.UIManager;
15 import javax.swing.UnsupportedLookAndFeelException;
21 public class HlavniOkno extends javax.swing.JFrame implements PosluchacLogu {
23 private static final Logger log = Logger.getLogger(HlavniOkno.class.getName());
25 /** Creates new form HlavniOkno */
28 setLocationRelativeTo(null);
29 nactiPromenneProstredi();
32 private void nactiPromenneProstredi() {
33 String zdroj = System.getenv(PromenneProstredi.MIGRACE_ZDROJ.toString());
35 jdbcZdroj.setText(zdroj);
37 String cil = System.getenv(PromenneProstredi.MIGRACE_CIL.toString());
43 /** This method is called from within the constructor to
44 * initialize the form.
45 * WARNING: Do NOT modify this code. The content of this method is
46 * always regenerated by the Form Editor.
48 @SuppressWarnings("unchecked")
49 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
50 private void initComponents() {
52 jLabel1 = new javax.swing.JLabel();
53 jLabel2 = new javax.swing.JLabel();
54 jdbcZdroj = new javax.swing.JTextField();
55 jdbcCil = new javax.swing.JTextField();
56 jScrollPane1 = new javax.swing.JScrollPane();
57 vystup = new javax.swing.JTextArea();
58 nahratData = new javax.swing.JButton();
60 setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
61 setTitle("ABC-Drupal");
63 jLabel1.setText("Zdroj");
65 jLabel2.setText("Cíl");
67 jdbcZdroj.setText("jdbc:mysql://127.0.0.1:3306/itbiz?user=itbiz&password=nbusr123");
69 jdbcCil.setText("jdbc:mysql://127.0.0.1:3306/abclinuxu?user=abclinuxu&password=nbusr123");
71 vystup.setColumns(20);
72 vystup.setEditable(false);
74 vystup.setEnabled(false);
75 jScrollPane1.setViewportView(vystup);
77 nahratData.setText("Nahrát data");
78 nahratData.addMouseWheelListener(new java.awt.event.MouseWheelListener() {
79 public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) {
80 nahratDataMouseWheelMoved(evt);
83 nahratData.addActionListener(new java.awt.event.ActionListener() {
84 public void actionPerformed(java.awt.event.ActionEvent evt) {
85 nahratDataActionPerformed(evt);
89 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
90 getContentPane().setLayout(layout);
91 layout.setHorizontalGroup(
92 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
93 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
95 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
96 .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 599, Short.MAX_VALUE)
97 .addGroup(layout.createSequentialGroup()
98 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
99 .addComponent(jLabel1)
100 .addComponent(jLabel2))
101 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
102 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
103 .addComponent(jdbcCil, javax.swing.GroupLayout.DEFAULT_SIZE, 560, Short.MAX_VALUE)
104 .addComponent(jdbcZdroj, javax.swing.GroupLayout.DEFAULT_SIZE, 560, Short.MAX_VALUE)))
105 .addComponent(nahratData))
108 layout.setVerticalGroup(
109 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
110 .addGroup(layout.createSequentialGroup()
112 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
113 .addComponent(jLabel1)
114 .addComponent(jdbcZdroj, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
115 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
116 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
117 .addComponent(jdbcCil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
118 .addComponent(jLabel2))
119 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
120 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
121 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
122 .addComponent(nahratData)
127 }// </editor-fold>//GEN-END:initComponents
129 private void nahratDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nahratDataActionPerformed
130 Konvertor k = new Konvertor(jdbcZdroj.getText(), jdbcCil.getText(), this);
131 nahratData.setEnabled(false);
132 nahratData.setToolTipText("Pokud chcete spustit migraci ještě jednou, pootočte kolečkem myši :-)");
134 }//GEN-LAST:event_nahratDataActionPerformed
136 private void nahratDataMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_nahratDataMouseWheelMoved
137 nahratData.setEnabled(true);
138 nahratData.setToolTipText(null);
139 }//GEN-LAST:event_nahratDataMouseWheelMoved
142 * @param args the command line arguments
144 public static void main(String args[]) {
147 java.awt.EventQueue.invokeLater(new Runnable() {
150 new HlavniOkno().setVisible(true);
155 private static void nastavLaF() {
157 UIManager.setLookAndFeel(new NimbusLookAndFeel());
158 } catch (UnsupportedLookAndFeelException e) {
159 log.log(Level.FINE, "Nepodařilo se načíst LaF. Nevadí.");
162 // Variables declaration - do not modify//GEN-BEGIN:variables
163 private javax.swing.JLabel jLabel1;
164 private javax.swing.JLabel jLabel2;
165 private javax.swing.JScrollPane jScrollPane1;
166 private javax.swing.JTextField jdbcCil;
167 private javax.swing.JTextField jdbcZdroj;
168 private javax.swing.JButton nahratData;
169 private javax.swing.JTextArea vystup;
170 // End of variables declaration//GEN-END:variables
172 public void vypis(String zprava) {
173 vystup.append(zprava + "\n");