Hlavní třída pro migraci, napojení na GUI.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/java/abc-drupal-gui/src/cz/frantovo/abcDrupal/Konvertor.java Thu Dec 31 18:12:03 2009 +0100
1.3 @@ -0,0 +1,31 @@
1.4 +package cz.frantovo.abcDrupal;
1.5 +
1.6 +import java.util.Date;
1.7 +
1.8 +/**
1.9 + * Řídící třída, stará se o konverzi z databáze Drupalu do databáze ABC.
1.10 + * @author fiki
1.11 + */
1.12 +public class Konvertor {
1.13 +
1.14 + private String jdbcZdroj;
1.15 + private String jdbcCil;
1.16 + private PosluchacLogu posluchacLogu;
1.17 +
1.18 + public Konvertor(String jdbcZdroj, String jdbcCil, PosluchacLogu posluchacLogu) {
1.19 + this.jdbcZdroj = jdbcZdroj;
1.20 + this.jdbcCil = jdbcCil;
1.21 + this.posluchacLogu = posluchacLogu;
1.22 + }
1.23 +
1.24 + public void konvertuj() {
1.25 + vypis("Začíná migrace");
1.26 + vypis("Migrace dokončena");
1.27 + }
1.28 +
1.29 + private void vypis(String zprava) {
1.30 + if (posluchacLogu != null) {
1.31 + posluchacLogu.vypis(new Date() + " " + zprava);
1.32 + }
1.33 + }
1.34 +}
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/java/abc-drupal-gui/src/cz/frantovo/abcDrupal/PosluchacLogu.java Thu Dec 31 18:12:03 2009 +0100
2.3 @@ -0,0 +1,10 @@
2.4 +package cz.frantovo.abcDrupal;
2.5 +
2.6 +/**
2.7 + * Slouží k vypisování (např. do GUI) zpráv z průběhu migrace
2.8 + * @author fiki
2.9 + */
2.10 +public interface PosluchacLogu {
2.11 +
2.12 + public void vypis(String zprava);
2.13 +}
3.1 --- a/java/abc-drupal-gui/src/cz/frantovo/abcDrupal/gui/HlavniOkno.form Thu Dec 31 18:00:23 2009 +0100
3.2 +++ b/java/abc-drupal-gui/src/cz/frantovo/abcDrupal/gui/HlavniOkno.form Thu Dec 31 18:12:03 2009 +0100
3.3 @@ -3,6 +3,7 @@
3.4 <Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
3.5 <Properties>
3.6 <Property name="defaultCloseOperation" type="int" value="3"/>
3.7 + <Property name="title" type="java.lang.String" value="ABC-Drupal"/>
3.8 </Properties>
3.9 <SyntheticProperties>
3.10 <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
3.11 @@ -22,11 +23,22 @@
3.12 <Layout>
3.13 <DimensionLayout dim="0">
3.14 <Group type="103" groupAlignment="0" attributes="0">
3.15 - <Group type="102" attributes="0">
3.16 + <Group type="102" alignment="1" attributes="0">
3.17 <EmptySpace max="-2" attributes="0"/>
3.18 - <Group type="103" groupAlignment="0" attributes="0">
3.19 + <Group type="103" groupAlignment="1" attributes="0">
3.20 + <Component id="jScrollPane1" alignment="0" pref="599" max="32767" attributes="0"/>
3.21 + <Group type="102" alignment="1" attributes="0">
3.22 + <Group type="103" groupAlignment="0" attributes="0">
3.23 + <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
3.24 + <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
3.25 + </Group>
3.26 + <EmptySpace max="-2" attributes="0"/>
3.27 + <Group type="103" groupAlignment="0" attributes="0">
3.28 + <Component id="jdbcCil" pref="560" max="32767" attributes="0"/>
3.29 + <Component id="jdbcZdroj" alignment="0" pref="560" max="32767" attributes="0"/>
3.30 + </Group>
3.31 + </Group>
3.32 <Component id="jButton1" alignment="1" min="-2" max="-2" attributes="0"/>
3.33 - <Component id="jTextField1" alignment="0" pref="388" max="32767" attributes="0"/>
3.34 </Group>
3.35 <EmptySpace max="-2" attributes="0"/>
3.36 </Group>
3.37 @@ -34,10 +46,20 @@
3.38 </DimensionLayout>
3.39 <DimensionLayout dim="1">
3.40 <Group type="103" groupAlignment="0" attributes="0">
3.41 - <Group type="102" alignment="1" attributes="0">
3.42 + <Group type="102" alignment="0" attributes="0">
3.43 <EmptySpace max="-2" attributes="0"/>
3.44 - <Component id="jTextField1" min="-2" max="-2" attributes="0"/>
3.45 - <EmptySpace pref="234" max="32767" attributes="0"/>
3.46 + <Group type="103" groupAlignment="3" attributes="0">
3.47 + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
3.48 + <Component id="jdbcZdroj" alignment="3" min="-2" max="-2" attributes="0"/>
3.49 + </Group>
3.50 + <EmptySpace max="-2" attributes="0"/>
3.51 + <Group type="103" groupAlignment="3" attributes="0">
3.52 + <Component id="jdbcCil" alignment="3" min="-2" max="-2" attributes="0"/>
3.53 + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
3.54 + </Group>
3.55 + <EmptySpace max="-2" attributes="0"/>
3.56 + <Component id="jScrollPane1" pref="152" max="32767" attributes="0"/>
3.57 + <EmptySpace max="-2" attributes="0"/>
3.58 <Component id="jButton1" min="-2" max="-2" attributes="0"/>
3.59 <EmptySpace max="-2" attributes="0"/>
3.60 </Group>
3.61 @@ -45,15 +67,50 @@
3.62 </DimensionLayout>
3.63 </Layout>
3.64 <SubComponents>
3.65 + <Component class="javax.swing.JLabel" name="jLabel1">
3.66 + <Properties>
3.67 + <Property name="text" type="java.lang.String" value="Zdroj"/>
3.68 + </Properties>
3.69 + </Component>
3.70 + <Component class="javax.swing.JLabel" name="jLabel2">
3.71 + <Properties>
3.72 + <Property name="text" type="java.lang.String" value="Cíl"/>
3.73 + </Properties>
3.74 + </Component>
3.75 + <Component class="javax.swing.JTextField" name="jdbcZdroj">
3.76 + <Properties>
3.77 + <Property name="text" type="java.lang.String" value="jdbcZdroj"/>
3.78 + </Properties>
3.79 + </Component>
3.80 + <Component class="javax.swing.JTextField" name="jdbcCil">
3.81 + <Properties>
3.82 + <Property name="text" type="java.lang.String" value="jdbcCil"/>
3.83 + </Properties>
3.84 + </Component>
3.85 + <Container class="javax.swing.JScrollPane" name="jScrollPane1">
3.86 + <AuxValues>
3.87 + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
3.88 + </AuxValues>
3.89 +
3.90 + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
3.91 + <SubComponents>
3.92 + <Component class="javax.swing.JTextArea" name="vystup">
3.93 + <Properties>
3.94 + <Property name="columns" type="int" value="20"/>
3.95 + <Property name="editable" type="boolean" value="false"/>
3.96 + <Property name="rows" type="int" value="5"/>
3.97 + <Property name="enabled" type="boolean" value="false"/>
3.98 + </Properties>
3.99 + </Component>
3.100 + </SubComponents>
3.101 + </Container>
3.102 <Component class="javax.swing.JButton" name="jButton1">
3.103 <Properties>
3.104 - <Property name="text" type="java.lang.String" value=":-)"/>
3.105 + <Property name="text" type="java.lang.String" value="Nahrát data"/>
3.106 </Properties>
3.107 - </Component>
3.108 - <Component class="javax.swing.JTextField" name="jTextField1">
3.109 - <Properties>
3.110 - <Property name="text" type="java.lang.String" value="jTextField1"/>
3.111 - </Properties>
3.112 + <Events>
3.113 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
3.114 + </Events>
3.115 </Component>
3.116 </SubComponents>
3.117 </Form>
4.1 --- a/java/abc-drupal-gui/src/cz/frantovo/abcDrupal/gui/HlavniOkno.java Thu Dec 31 18:00:23 2009 +0100
4.2 +++ b/java/abc-drupal-gui/src/cz/frantovo/abcDrupal/gui/HlavniOkno.java Thu Dec 31 18:12:03 2009 +0100
4.3 @@ -6,6 +6,8 @@
4.4 package cz.frantovo.abcDrupal.gui;
4.5
4.6 import com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel;
4.7 +import cz.frantovo.abcDrupal.Konvertor;
4.8 +import cz.frantovo.abcDrupal.PosluchacLogu;
4.9 import java.util.logging.Level;
4.10 import java.util.logging.Logger;
4.11 import javax.swing.UIManager;
4.12 @@ -15,7 +17,7 @@
4.13 *
4.14 * @author fiki
4.15 */
4.16 -public class HlavniOkno extends javax.swing.JFrame {
4.17 +public class HlavniOkno extends javax.swing.JFrame implements PosluchacLogu {
4.18
4.19 private static final Logger log = Logger.getLogger(HlavniOkno.class.getName());
4.20
4.21 @@ -33,32 +35,71 @@
4.22 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
4.23 private void initComponents() {
4.24
4.25 + jLabel1 = new javax.swing.JLabel();
4.26 + jLabel2 = new javax.swing.JLabel();
4.27 + jdbcZdroj = new javax.swing.JTextField();
4.28 + jdbcCil = new javax.swing.JTextField();
4.29 + jScrollPane1 = new javax.swing.JScrollPane();
4.30 + vystup = new javax.swing.JTextArea();
4.31 jButton1 = new javax.swing.JButton();
4.32 - jTextField1 = new javax.swing.JTextField();
4.33
4.34 setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
4.35 + setTitle("ABC-Drupal");
4.36
4.37 - jButton1.setText(":-)");
4.38 + jLabel1.setText("Zdroj");
4.39
4.40 - jTextField1.setText("jTextField1");
4.41 + jLabel2.setText("Cíl");
4.42 +
4.43 + jdbcZdroj.setText("jdbcZdroj");
4.44 +
4.45 + jdbcCil.setText("jdbcCil");
4.46 +
4.47 + vystup.setColumns(20);
4.48 + vystup.setEditable(false);
4.49 + vystup.setRows(5);
4.50 + vystup.setEnabled(false);
4.51 + jScrollPane1.setViewportView(vystup);
4.52 +
4.53 + jButton1.setText("Nahrát data");
4.54 + jButton1.addActionListener(new java.awt.event.ActionListener() {
4.55 + public void actionPerformed(java.awt.event.ActionEvent evt) {
4.56 + jButton1ActionPerformed(evt);
4.57 + }
4.58 + });
4.59
4.60 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
4.61 getContentPane().setLayout(layout);
4.62 layout.setHorizontalGroup(
4.63 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
4.64 - .addGroup(layout.createSequentialGroup()
4.65 + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
4.66 .addContainerGap()
4.67 - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
4.68 - .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING)
4.69 - .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE))
4.70 + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
4.71 + .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 599, Short.MAX_VALUE)
4.72 + .addGroup(layout.createSequentialGroup()
4.73 + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
4.74 + .addComponent(jLabel1)
4.75 + .addComponent(jLabel2))
4.76 + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
4.77 + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
4.78 + .addComponent(jdbcCil, javax.swing.GroupLayout.DEFAULT_SIZE, 560, Short.MAX_VALUE)
4.79 + .addComponent(jdbcZdroj, javax.swing.GroupLayout.DEFAULT_SIZE, 560, Short.MAX_VALUE)))
4.80 + .addComponent(jButton1))
4.81 .addContainerGap())
4.82 );
4.83 layout.setVerticalGroup(
4.84 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
4.85 - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
4.86 + .addGroup(layout.createSequentialGroup()
4.87 .addContainerGap()
4.88 - .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
4.89 - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 234, Short.MAX_VALUE)
4.90 + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
4.91 + .addComponent(jLabel1)
4.92 + .addComponent(jdbcZdroj, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
4.93 + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
4.94 + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
4.95 + .addComponent(jdbcCil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
4.96 + .addComponent(jLabel2))
4.97 + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
4.98 + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
4.99 + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
4.100 .addComponent(jButton1)
4.101 .addContainerGap())
4.102 );
4.103 @@ -66,6 +107,11 @@
4.104 pack();
4.105 }// </editor-fold>//GEN-END:initComponents
4.106
4.107 + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
4.108 + Konvertor k = new Konvertor(jdbcZdroj.getText(), jdbcCil.getText(), this);
4.109 + k.konvertuj();
4.110 + }//GEN-LAST:event_jButton1ActionPerformed
4.111 +
4.112 /**
4.113 * @param args the command line arguments
4.114 */
4.115 @@ -89,6 +135,15 @@
4.116 }
4.117 // Variables declaration - do not modify//GEN-BEGIN:variables
4.118 private javax.swing.JButton jButton1;
4.119 - private javax.swing.JTextField jTextField1;
4.120 + private javax.swing.JLabel jLabel1;
4.121 + private javax.swing.JLabel jLabel2;
4.122 + private javax.swing.JScrollPane jScrollPane1;
4.123 + private javax.swing.JTextField jdbcCil;
4.124 + private javax.swing.JTextField jdbcZdroj;
4.125 + private javax.swing.JTextArea vystup;
4.126 // End of variables declaration//GEN-END:variables
4.127 +
4.128 + public void vypis(String zprava) {
4.129 + vystup.append(zprava + "\n");
4.130 + }
4.131 }