franta-hg@0: /* franta-hg@0: * HlavniOkno.java franta-hg@0: * franta-hg@0: * Created on 30.12.2009, 2:22:41 franta-hg@0: */ franta-hg@0: package cz.frantovo.abcDrupal.gui; franta-hg@0: franta-hg@0: import com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel; franta-hg@2: import cz.frantovo.abcDrupal.Konvertor; franta-hg@2: import cz.frantovo.abcDrupal.PosluchacLogu; franta-hg@3: import cz.frantovo.abcDrupal.PromenneProstredi; franta-hg@0: import java.util.logging.Level; franta-hg@0: import java.util.logging.Logger; franta-hg@0: import javax.swing.UIManager; franta-hg@0: import javax.swing.UnsupportedLookAndFeelException; franta-hg@0: franta-hg@0: /** franta-hg@0: * franta-hg@0: * @author fiki franta-hg@0: */ franta-hg@2: public class HlavniOkno extends javax.swing.JFrame implements PosluchacLogu { franta-hg@0: franta-hg@0: private static final Logger log = Logger.getLogger(HlavniOkno.class.getName()); franta-hg@0: franta-hg@0: /** Creates new form HlavniOkno */ franta-hg@0: public HlavniOkno() { franta-hg@0: initComponents(); franta-hg@4: setLocationRelativeTo(null); franta-hg@3: nactiPromenneProstredi(); franta-hg@3: } franta-hg@3: franta-hg@3: private void nactiPromenneProstredi() { franta-hg@3: String zdroj = System.getenv(PromenneProstredi.MIGRACE_ZDROJ.toString()); franta-hg@3: if (zdroj != null) { franta-hg@3: jdbcZdroj.setText(zdroj); franta-hg@3: } franta-hg@3: String cil = System.getenv(PromenneProstredi.MIGRACE_CIL.toString()); franta-hg@3: if (cil != null) { franta-hg@3: jdbcCil.setText(cil); franta-hg@3: } franta-hg@0: } franta-hg@0: franta-hg@0: /** This method is called from within the constructor to franta-hg@0: * initialize the form. franta-hg@0: * WARNING: Do NOT modify this code. The content of this method is franta-hg@0: * always regenerated by the Form Editor. franta-hg@0: */ franta-hg@0: @SuppressWarnings("unchecked") franta-hg@0: // //GEN-BEGIN:initComponents franta-hg@0: private void initComponents() { franta-hg@0: franta-hg@2: jLabel1 = new javax.swing.JLabel(); franta-hg@2: jLabel2 = new javax.swing.JLabel(); franta-hg@2: jdbcZdroj = new javax.swing.JTextField(); franta-hg@2: jdbcCil = new javax.swing.JTextField(); franta-hg@2: jScrollPane1 = new javax.swing.JScrollPane(); franta-hg@2: vystup = new javax.swing.JTextArea(); franta-hg@4: nahratData = new javax.swing.JButton(); franta-hg@0: franta-hg@0: setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); franta-hg@2: setTitle("ABC-Drupal"); franta-hg@0: franta-hg@2: jLabel1.setText("Zdroj"); franta-hg@0: franta-hg@2: jLabel2.setText("Cíl"); franta-hg@2: franta-hg@4: jdbcZdroj.setText("jdbc:mysql://127.0.0.1:3306/itbiz?user=itbiz&password=nbusr123"); franta-hg@2: franta-hg@4: jdbcCil.setText("jdbc:mysql://127.0.0.1:3306/abclinuxu?user=abclinuxu&password=nbusr123"); franta-hg@2: franta-hg@2: vystup.setColumns(20); franta-hg@2: vystup.setEditable(false); franta-hg@2: vystup.setRows(5); franta-hg@2: vystup.setEnabled(false); franta-hg@2: jScrollPane1.setViewportView(vystup); franta-hg@2: franta-hg@4: nahratData.setText("Nahrát data"); franta-hg@5: nahratData.addMouseWheelListener(new java.awt.event.MouseWheelListener() { franta-hg@5: public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) { franta-hg@5: nahratDataMouseWheelMoved(evt); franta-hg@5: } franta-hg@5: }); franta-hg@4: nahratData.addActionListener(new java.awt.event.ActionListener() { franta-hg@2: public void actionPerformed(java.awt.event.ActionEvent evt) { franta-hg@4: nahratDataActionPerformed(evt); franta-hg@2: } franta-hg@2: }); franta-hg@0: franta-hg@0: javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); franta-hg@0: getContentPane().setLayout(layout); franta-hg@0: layout.setHorizontalGroup( franta-hg@0: layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) franta-hg@2: .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() franta-hg@0: .addContainerGap() franta-hg@2: .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) franta-hg@2: .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 599, Short.MAX_VALUE) franta-hg@2: .addGroup(layout.createSequentialGroup() franta-hg@2: .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) franta-hg@2: .addComponent(jLabel1) franta-hg@2: .addComponent(jLabel2)) franta-hg@2: .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) franta-hg@2: .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) franta-hg@2: .addComponent(jdbcCil, javax.swing.GroupLayout.DEFAULT_SIZE, 560, Short.MAX_VALUE) franta-hg@2: .addComponent(jdbcZdroj, javax.swing.GroupLayout.DEFAULT_SIZE, 560, Short.MAX_VALUE))) franta-hg@4: .addComponent(nahratData)) franta-hg@0: .addContainerGap()) franta-hg@0: ); franta-hg@0: layout.setVerticalGroup( franta-hg@0: layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) franta-hg@2: .addGroup(layout.createSequentialGroup() franta-hg@0: .addContainerGap() franta-hg@2: .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) franta-hg@2: .addComponent(jLabel1) franta-hg@2: .addComponent(jdbcZdroj, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) franta-hg@2: .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) franta-hg@2: .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) franta-hg@2: .addComponent(jdbcCil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) franta-hg@2: .addComponent(jLabel2)) franta-hg@2: .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) franta-hg@2: .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE) franta-hg@2: .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) franta-hg@4: .addComponent(nahratData) franta-hg@0: .addContainerGap()) franta-hg@0: ); franta-hg@0: franta-hg@0: pack(); franta-hg@0: }// //GEN-END:initComponents franta-hg@0: franta-hg@4: private void nahratDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nahratDataActionPerformed franta-hg@2: Konvertor k = new Konvertor(jdbcZdroj.getText(), jdbcCil.getText(), this); franta-hg@5: nahratData.setEnabled(false); franta-hg@5: nahratData.setToolTipText("Pokud chcete spustit migraci ještě jednou, pootočte kolečkem myši :-)"); franta-hg@2: k.konvertuj(); franta-hg@4: }//GEN-LAST:event_nahratDataActionPerformed franta-hg@2: franta-hg@5: private void nahratDataMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_nahratDataMouseWheelMoved franta-hg@5: nahratData.setEnabled(true); franta-hg@5: nahratData.setToolTipText(null); franta-hg@5: }//GEN-LAST:event_nahratDataMouseWheelMoved franta-hg@5: franta-hg@0: /** franta-hg@0: * @param args the command line arguments franta-hg@0: */ franta-hg@0: public static void main(String args[]) { franta-hg@0: nastavLaF(); franta-hg@0: franta-hg@0: java.awt.EventQueue.invokeLater(new Runnable() { franta-hg@0: franta-hg@0: public void run() { franta-hg@0: new HlavniOkno().setVisible(true); franta-hg@0: } franta-hg@0: }); franta-hg@0: } franta-hg@0: franta-hg@0: private static void nastavLaF() { franta-hg@0: try { franta-hg@0: UIManager.setLookAndFeel(new NimbusLookAndFeel()); franta-hg@0: } catch (UnsupportedLookAndFeelException e) { franta-hg@0: log.log(Level.FINE, "Nepodařilo se načíst LaF. Nevadí."); franta-hg@0: } franta-hg@0: } franta-hg@0: // Variables declaration - do not modify//GEN-BEGIN:variables franta-hg@2: private javax.swing.JLabel jLabel1; franta-hg@2: private javax.swing.JLabel jLabel2; franta-hg@2: private javax.swing.JScrollPane jScrollPane1; franta-hg@2: private javax.swing.JTextField jdbcCil; franta-hg@2: private javax.swing.JTextField jdbcZdroj; franta-hg@4: private javax.swing.JButton nahratData; franta-hg@2: private javax.swing.JTextArea vystup; franta-hg@0: // End of variables declaration//GEN-END:variables franta-hg@2: franta-hg@2: public void vypis(String zprava) { franta-hg@2: vystup.append(zprava + "\n"); franta-hg@2: } franta-hg@0: }