java/abc-drupal-gui/src/cz/frantovo/abcDrupal/gui/HlavniOkno.java
author František Kučera <franta-hg@frantovo.cz>
Fri, 01 Jan 2010 16:44:46 +0100
changeset 4 5816c7f61a2a
parent 3 d40099dbbdd1
child 5 ed73b8912549
permissions -rw-r--r--
Skript pro spouštění a hesla k DB.
     1 /*
     2  * HlavniOkno.java
     3  *
     4  * Created on 30.12.2009, 2:22:41
     5  */
     6 package cz.frantovo.abcDrupal.gui;
     7 
     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;
    16 
    17 /**
    18  *
    19  * @author fiki
    20  */
    21 public class HlavniOkno extends javax.swing.JFrame implements PosluchacLogu {
    22 
    23     private static final Logger log = Logger.getLogger(HlavniOkno.class.getName());
    24 
    25     /** Creates new form HlavniOkno */
    26     public HlavniOkno() {
    27 	initComponents();
    28 	setLocationRelativeTo(null);
    29 	nactiPromenneProstredi();
    30     }
    31 
    32     private void nactiPromenneProstredi() {
    33 	String zdroj = System.getenv(PromenneProstredi.MIGRACE_ZDROJ.toString());
    34 	if (zdroj != null) {
    35 	    jdbcZdroj.setText(zdroj);
    36 	}
    37 	String cil = System.getenv(PromenneProstredi.MIGRACE_CIL.toString());
    38 	if (cil != null) {
    39 	    jdbcCil.setText(cil);
    40 	}
    41     }
    42 
    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.
    47      */
    48     @SuppressWarnings("unchecked")
    49     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    50     private void initComponents() {
    51 
    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();
    59 
    60         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    61         setTitle("ABC-Drupal");
    62 
    63         jLabel1.setText("Zdroj");
    64 
    65         jLabel2.setText("Cíl");
    66 
    67         jdbcZdroj.setText("jdbc:mysql://127.0.0.1:3306/itbiz?user=itbiz&password=nbusr123");
    68 
    69         jdbcCil.setText("jdbc:mysql://127.0.0.1:3306/abclinuxu?user=abclinuxu&password=nbusr123");
    70 
    71         vystup.setColumns(20);
    72         vystup.setEditable(false);
    73         vystup.setRows(5);
    74         vystup.setEnabled(false);
    75         jScrollPane1.setViewportView(vystup);
    76 
    77         nahratData.setText("Nahrát data");
    78         nahratData.addActionListener(new java.awt.event.ActionListener() {
    79             public void actionPerformed(java.awt.event.ActionEvent evt) {
    80                 nahratDataActionPerformed(evt);
    81             }
    82         });
    83 
    84         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    85         getContentPane().setLayout(layout);
    86         layout.setHorizontalGroup(
    87             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    88             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
    89                 .addContainerGap()
    90                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
    91                     .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 599, Short.MAX_VALUE)
    92                     .addGroup(layout.createSequentialGroup()
    93                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    94                             .addComponent(jLabel1)
    95                             .addComponent(jLabel2))
    96                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    97                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    98                             .addComponent(jdbcCil, javax.swing.GroupLayout.DEFAULT_SIZE, 560, Short.MAX_VALUE)
    99                             .addComponent(jdbcZdroj, javax.swing.GroupLayout.DEFAULT_SIZE, 560, Short.MAX_VALUE)))
   100                     .addComponent(nahratData))
   101                 .addContainerGap())
   102         );
   103         layout.setVerticalGroup(
   104             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
   105             .addGroup(layout.createSequentialGroup()
   106                 .addContainerGap()
   107                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
   108                     .addComponent(jLabel1)
   109                     .addComponent(jdbcZdroj, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
   110                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
   111                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
   112                     .addComponent(jdbcCil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
   113                     .addComponent(jLabel2))
   114                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
   115                 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
   116                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
   117                 .addComponent(nahratData)
   118                 .addContainerGap())
   119         );
   120 
   121         pack();
   122     }// </editor-fold>//GEN-END:initComponents
   123 
   124     private void nahratDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nahratDataActionPerformed
   125 	Konvertor k = new Konvertor(jdbcZdroj.getText(), jdbcCil.getText(), this);
   126 	k.konvertuj();
   127     }//GEN-LAST:event_nahratDataActionPerformed
   128 
   129     /**
   130      * @param args the command line arguments
   131      */
   132     public static void main(String args[]) {
   133 	nastavLaF();
   134 
   135 	java.awt.EventQueue.invokeLater(new Runnable() {
   136 
   137 	    public void run() {
   138 		new HlavniOkno().setVisible(true);
   139 	    }
   140 	});
   141     }
   142 
   143     private static void nastavLaF() {
   144 	try {
   145 	    UIManager.setLookAndFeel(new NimbusLookAndFeel());
   146 	} catch (UnsupportedLookAndFeelException e) {
   147 	    log.log(Level.FINE, "Nepodařilo se načíst LaF. Nevadí.");
   148 	}
   149     }
   150     // Variables declaration - do not modify//GEN-BEGIN:variables
   151     private javax.swing.JLabel jLabel1;
   152     private javax.swing.JLabel jLabel2;
   153     private javax.swing.JScrollPane jScrollPane1;
   154     private javax.swing.JTextField jdbcCil;
   155     private javax.swing.JTextField jdbcZdroj;
   156     private javax.swing.JButton nahratData;
   157     private javax.swing.JTextArea vystup;
   158     // End of variables declaration//GEN-END:variables
   159 
   160     public void vypis(String zprava) {
   161 	vystup.append(zprava + "\n");
   162     }
   163 }