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