/*
 * XMLClassBuilder.java
 *
 * Created on 25.09.2009, 10:07:30
 */

package csa.util;
import java.util.*;
import java.io.*;
import javax.swing.*;
import java.awt.*;


/**
 *
 * @author Malban
 */
public class XMLClassBuilder extends javax.swing.JFrame {
    private int yPos=55;
    private XMLClassBuilderData mConfig = new XMLClassBuilderData();
    private XMLClassBuilderDataPool mConfigPool;
    private int mClassSetting=0;

    class Field
    {
        String name="";
        String xmlName="";
        String type;
    }

    Vector <Field> mFields = new Vector<Field>();

    /** Creates new form XMLClassBuilder */
    public XMLClassBuilder() {
        initComponents();
        mConfigPool = new XMLClassBuilderDataPool();
        resetConfigPool(false, "");
    }

    private void resetConfigPool(boolean select, String klasseToSet) /* allneeded*/
    {
        mClassSetting++;
        Collection<String> collectionKlasse = mConfigPool.getKlassenHashMap().values();
        Iterator<String> iterKlasse = collectionKlasse.iterator();
        int i = 0;
        String klasse = "";

        jComboBoxKlasse.removeAllItems();
        while (iterKlasse.hasNext())
        {
            String item = iterKlasse.next();
            jComboBoxKlasse.addItem(item);
            if (select)
            {
                if (klasseToSet.length()==0)
                {
                    if (i==0)
                    {
                        jComboBoxKlasse.setSelectedIndex(i);
                        jTextFieldKlasse.setText(item);
                        klasse = item;
                    }
                }
                else
                {
                    if (klasseToSet.equalsIgnoreCase(item))
                    {
                        jComboBoxKlasse.setSelectedIndex(i);
                        jTextFieldKlasse.setText(item);
                        klasse = item;
                    }
                }
            }
            i++;
        }
        if ((select) && (klasse.length()==0))
        {
            if (jComboBoxKlasse.getItemCount()>0)
            {
                jComboBoxKlasse.setSelectedIndex(0);
                jTextFieldKlasse.setText(jComboBoxKlasse.getSelectedItem().toString());
                klasse = jComboBoxKlasse.getSelectedItem().toString();
            }
        }
        if (!select)  jComboBoxKlasse.setSelectedIndex(-1);

        Collection<XMLClassBuilderData> colC = mConfigPool.getMapForKlasse(klasse).values();
        Iterator<XMLClassBuilderData> iterC = colC.iterator();

        jComboBoxName.removeAllItems();
        i = 0;
        while (iterC.hasNext())
        {
            XMLClassBuilderData item = iterC.next();
            jComboBoxName.addItem(item.mName);
            if ((i==0) && (select))
            {
                jComboBoxName.setSelectedIndex(0);
                mConfig = mConfigPool.get(item.mName);
                setAllFromCurrent();
            }
            i++;
        }
        if (!select)  jComboBoxName.setSelectedIndex(-1);
        // resetStatementPool(null,null);
        mClassSetting--;
    }
    private void clearAll() /* allneeded*/
    {
        mClassSetting++;
        mConfig = new XMLClassBuilderData();
        setAllFromCurrent();
        mClassSetting--;
    }

    private void setAllFromCurrent() /* allneeded*/
    {
        mClassSetting++;
        jComboBoxKlasse.setSelectedItem(mConfig.mClass);
        jTextFieldKlasse.setText(mConfig.mClass);
        jComboBoxName.setSelectedItem(mConfig.mName);
        jTextFieldName.setText(mConfig.mName);

        jTextFieldPackage.setText(mConfig.mPackageName);
        jTextFieldClass.setText(mConfig.mClassName);


        // reset:
        jPanel2.removeAll();
        yPos=0;

        for (int i=0;i<mConfig.mFieldname.size(); i++)
        {
            addPanelWithData(i);
        }
        pack();
        invalidate();
        repaint();
        mClassSetting--;
    }

    private void readAllToCurrent()
    {
        mConfig.mClass = jTextFieldKlasse.getText();
        mConfig.mName = jTextFieldName.getText();

        mConfig.mFieldname.clear();
        mConfig.mXMLName.clear();
        mConfig.mType.clear();

        collectFields();
        for (int i=0;i<mFields.size();i++)
        {
            Field f = mFields.elementAt(i);
            mConfig.mFieldname.addElement(f.name);
            mConfig.mXMLName.addElement(f.xmlName);
            mConfig.mType.addElement(f.type);
        }
        mConfig.mPackageName = jTextFieldPackage.getText();
        mConfig.mClassName = jTextFieldClass.getText();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jTextFieldPackage = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jTextFieldClass = new javax.swing.JTextField();
        jCheckBoxIsProtected = new javax.swing.JCheckBox();
        jButtonAdField = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel2 = new javax.swing.JPanel();
        jPanelField = new javax.swing.JPanel();
        jComboBoxType = new javax.swing.JComboBox();
        jLabelType = new javax.swing.JLabel();
        jTextFieldXMLName = new javax.swing.JTextField();
        jLabelXMLName = new javax.swing.JLabel();
        jTextFieldFieldName = new javax.swing.JTextField();
        jLabelFieldName = new javax.swing.JLabel();
        JButtonGenerate = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jTextFieldKlasse = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTextFieldName = new javax.swing.JTextField();
        jComboBoxKlasse = new javax.swing.JComboBox();
        jComboBoxName = new javax.swing.JComboBox();
        jButtonNew = new javax.swing.JButton();
        jButtonSave = new javax.swing.JButton();
        jButtonSaveAsNew = new javax.swing.JButton();
        jButtonDelete = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel1.setText("Package");

        jLabel2.setText("Class");

        jCheckBoxIsProtected.setSelected(true);
        jCheckBoxIsProtected.setText("use Protected");
        jCheckBoxIsProtected.setEnabled(false);

        jButtonAdField.setText("Add Field");
        jButtonAdField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAdFieldActionPerformed(evt);
            }
        });

        jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanelField.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jComboBoxType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "String", "int", "float", "boolean", "Vector<String>", "Vector<int>", "Vector<float>", "Vector<boolean>", " " }));
        jComboBoxType.setName("Type"); // NOI18N

        jLabelType.setText("Type");

        jTextFieldXMLName.setName("XMLName"); // NOI18N

        jLabelXMLName.setText("XMLName");

        jTextFieldFieldName.setName("Name"); // NOI18N

        jLabelFieldName.setText("Fieldname");

        javax.swing.GroupLayout jPanelFieldLayout = new javax.swing.GroupLayout(jPanelField);
        jPanelField.setLayout(jPanelFieldLayout);
        jPanelFieldLayout.setHorizontalGroup(
            jPanelFieldLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelFieldLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelFieldName)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextFieldFieldName, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabelXMLName)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextFieldXMLName, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(34, 34, 34)
                .addComponent(jLabelType)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBoxType, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(135, Short.MAX_VALUE))
        );
        jPanelFieldLayout.setVerticalGroup(
            jPanelFieldLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelFieldLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelFieldLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelFieldName)
                    .addComponent(jTextFieldFieldName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelXMLName)
                    .addComponent(jTextFieldXMLName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelType)
                    .addComponent(jComboBoxType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(16, Short.MAX_VALUE))
        );

        jPanel2.add(jPanelField, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, 50));

        jScrollPane1.setViewportView(jPanel2);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 766, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 345, Short.MAX_VALUE)
        );

        JButtonGenerate.setText("Generate");
        JButtonGenerate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JButtonGenerateActionPerformed(evt);
            }
        });

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel4.setText("Name");

        jLabel3.setText("Class");

        jComboBoxKlasse.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBoxKlasse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxKlasseActionPerformed(evt);
            }
        });

        jComboBoxName.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBoxName.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxNameActionPerformed(evt);
            }
        });

        jButtonNew.setText("New");
        jButtonNew.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonNewActionPerformed(evt);
            }
        });

        jButtonSave.setText("Save");
        jButtonSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSaveActionPerformed(evt);
            }
        });

        jButtonSaveAsNew.setText("Save as new");
        jButtonSaveAsNew.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSaveAsNewActionPerformed(evt);
            }
        });

        jButtonDelete.setText("Delete");
        jButtonDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDeleteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel3))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTextFieldKlasse, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextFieldName))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jComboBoxKlasse, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jComboBoxName, 0, 98, Short.MAX_VALUE)))
                    .addComponent(jButtonDelete))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonSaveAsNew)
                    .addComponent(jButtonNew)
                    .addComponent(jButtonSave))
                .addContainerGap(14, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTextFieldKlasse, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBoxKlasse, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonNew))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTextFieldName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBoxName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonSave))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonSaveAsNew)
                    .addComponent(jButtonDelete)))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButtonAdField)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(JButtonGenerate))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(18, 18, 18)
                        .addComponent(jTextFieldPackage, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jTextFieldClass, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(55, 55, 55)
                .addComponent(jCheckBoxIsProtected)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(4, 4, 4))
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(jTextFieldPackage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(jTextFieldClass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jCheckBoxIsProtected))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButtonAdField)
                            .addComponent(JButtonGenerate)))
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    Field getField(Container c)
    {
        Field ret = null;
        String name="";
        String xmlName="";
        String type = "";

        for (int i = 0; i < c.getComponentCount(); i++)
        {
            Component field = (Component) c.getComponent(i);
            if (field==null) continue;
            if (field.getName()==null) continue;
            if (field.getName().equals("Name"))
            {
                name = ((JTextField)field).getText();
            }
            if (field.getName().equals("XMLName"))
            {
                xmlName = ((JTextField)field).getText();
            }
            if (field.getName().equals("Type"))
            {
                type = (String) ((JComboBox)field).getSelectedItem();
            }
        }
        if ((name.length() != 0) && (xmlName.length()!=0) && (type.length()!=0))
        {
            ret = new Field();
            ret.name = name;
            ret.xmlName = xmlName;
            ret.type = type;
        }
        return ret;
    }

    private void collectFields()
    {
        Container c = jPanel2;
        mFields.clear();
        for (int i = 0; i < c.getComponentCount(); i++)
        {
            Container fieldPanel = (Container) c.getComponent(i);
            Field f = getField(fieldPanel);
            if (f==null) continue;
            mFields.addElement(f);

            System.out.println("Field: " + f.name+" added!");
        }
    }

    private void JButtonGenerateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JButtonGenerateActionPerformed

        collectFields();
        Vector<String> bClass = generateClass();
        Vector<String> bHandler = generateHandler();
        Vector<String> bPool = generatePool();
        Vector<String> bgui = generateTemplateGUI();
        Vector<String> bform = generateTemplateGUIForm();

        String bPackage = jTextFieldPackage.getText();
        String bClassName = jTextFieldClass.getText();

        {try
        {
            PrintWriter pw = new PrintWriter(bClassName+".java");
            for (int i=0; i<bClass.size();i++ )
            {
                pw.print(bClass.elementAt(i)+"\n");
            }
            pw.close();
        }
        catch (IOException e)
        {
            System.err.println(e.toString());
        }}
        {try
        {
            PrintWriter pw = new PrintWriter(bClassName+"XMLHandler.java");
            for (int i=0; i<bHandler.size();i++ )
            {
                pw.print(bHandler.elementAt(i)+"\n");
            }
            pw.close();
        }
        catch (IOException e)
        {
            System.err.println(e.toString());
        }}
        {try
        {
            PrintWriter pw = new PrintWriter(bClassName+"Pool.java");
            for (int i=0; i<bPool.size();i++ )
            {
                pw.print(bPool.elementAt(i)+"\n");
            }
            pw.close();
        }
        catch (IOException e)
        {
            System.err.println(e.toString());
        }}
        {try
        {
            PrintWriter pw = new PrintWriter(bClassName+"Panel.java");
            for (int i=0; i<bgui.size();i++ )
            {
                pw.print(bgui.elementAt(i)+"\n");
            }
            pw.close();
        }
        catch (IOException e)
        {
            System.err.println(e.toString());
        }}
        {try
        {
            PrintWriter pw = new PrintWriter(bClassName+"Panel.form");
            for (int i=0; i<bform.size();i++ )
            {
                pw.print(bform.elementAt(i)+"\n");
            }
            pw.close();
        }
        catch (IOException e)
        {
            System.err.println(e.toString());
        }}

    }//GEN-LAST:event_JButtonGenerateActionPerformed

    private void addPanelWithData(int i)
    {


        JPanel PanelField = new javax.swing.JPanel();
        JComboBox ComboBoxType = new javax.swing.JComboBox();
        JLabel LabelType = new javax.swing.JLabel();
        JTextField TextFieldXMLName = new javax.swing.JTextField();
        JLabel LabelXMLName = new javax.swing.JLabel();
        JTextField TextFieldFieldName = new javax.swing.JTextField();
        JLabel LabelFieldName = new javax.swing.JLabel();
        PanelField.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        ComboBoxType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "String", "int", "float", "boolean", "Vector<String>", "Vector<int>", "Vector<float>", "Vector<boolean>", " " }));
        LabelType.setText("Type");
        LabelXMLName.setText("XMLName");
        LabelFieldName.setText("Fieldname");
        ComboBoxType.setName("Type"); // NOI18N
        TextFieldXMLName.setName("XMLName"); // NOI18N
        TextFieldFieldName.setName("Name"); // NOI18N

        javax.swing.GroupLayout PanelFieldLayout = new javax.swing.GroupLayout(PanelField);
        PanelField.setLayout(PanelFieldLayout);
        PanelFieldLayout.setHorizontalGroup(
            PanelFieldLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelFieldLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(LabelFieldName)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(TextFieldFieldName, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(LabelXMLName)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(TextFieldXMLName, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(34, 34, 34)
                .addComponent(LabelType)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ComboBoxType, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(83, Short.MAX_VALUE))
        );
        PanelFieldLayout.setVerticalGroup(
            PanelFieldLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelFieldLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PanelFieldLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(LabelFieldName)
                    .addComponent(TextFieldFieldName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(LabelXMLName)
                    .addComponent(TextFieldXMLName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(LabelType)
                    .addComponent(ComboBoxType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

         TextFieldFieldName.setText(mConfig.mFieldname.elementAt(i));
         TextFieldXMLName.setText(mConfig.mXMLName.elementAt(i));
         ComboBoxType.setSelectedItem(mConfig.mType.elementAt(i));

        jPanel2.add(PanelField, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, yPos, -1, 50));
        yPos+=55;

        pack();
        invalidate();
    }

    private void jButtonAdFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAdFieldActionPerformed


        JPanel PanelField = new javax.swing.JPanel();
        JComboBox ComboBoxType = new javax.swing.JComboBox();
        JLabel LabelType = new javax.swing.JLabel();
        JTextField TextFieldXMLName = new javax.swing.JTextField();
        JLabel LabelXMLName = new javax.swing.JLabel();
        JTextField TextFieldFieldName = new javax.swing.JTextField();
        JLabel LabelFieldName = new javax.swing.JLabel();
        PanelField.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        ComboBoxType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "String", "int", "float", "boolean", "Vector<String>", "Vector<int>", "Vector<float>", "Vector<boolean>", " " }));
        LabelType.setText("Type");
        LabelXMLName.setText("XMLName");
        LabelFieldName.setText("Fieldname");
        ComboBoxType.setName("Type"); // NOI18N
        TextFieldXMLName.setName("XMLName"); // NOI18N
        TextFieldFieldName.setName("Name"); // NOI18N

        javax.swing.GroupLayout PanelFieldLayout = new javax.swing.GroupLayout(PanelField);
        PanelField.setLayout(PanelFieldLayout);
        PanelFieldLayout.setHorizontalGroup(
            PanelFieldLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelFieldLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(LabelFieldName)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(TextFieldFieldName, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(LabelXMLName)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(TextFieldXMLName, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(34, 34, 34)
                .addComponent(LabelType)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ComboBoxType, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(83, Short.MAX_VALUE))
        );
        PanelFieldLayout.setVerticalGroup(
            PanelFieldLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelFieldLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PanelFieldLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(LabelFieldName)
                    .addComponent(TextFieldFieldName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(LabelXMLName)
                    .addComponent(TextFieldXMLName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(LabelType)
                    .addComponent(ComboBoxType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.add(PanelField, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, yPos, -1, 50));
        yPos+=55;

        pack();
        invalidate();
    }//GEN-LAST:event_jButtonAdFieldActionPerformed

    private void jButtonSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSaveActionPerformed

        readAllToCurrent();
        mConfigPool.put(mConfig);
        mConfigPool.save();
        mClassSetting++;
        String klasse = jTextFieldKlasse.getText();
        resetConfigPool(true, klasse);
        jComboBoxName.setSelectedItem(mConfig.mName);
        mClassSetting--;

    }//GEN-LAST:event_jButtonSaveActionPerformed

    private void jButtonSaveAsNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSaveAsNewActionPerformed
        mConfig = new XMLClassBuilderData();
        readAllToCurrent();
        mConfigPool.putAsNew(mConfig);
        mConfigPool.save();
        mClassSetting++;
        String klasse = jTextFieldKlasse.getText();
        resetConfigPool(true,klasse);
        jComboBoxName.setSelectedItem(mConfig.mName);
        mClassSetting--;

    }//GEN-LAST:event_jButtonSaveAsNewActionPerformed

    private void jButtonDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeleteActionPerformed
        readAllToCurrent();
        mConfigPool.remove(mConfig);
        mConfigPool.save();
        mClassSetting++;
        String klasse = jTextFieldKlasse.getText();
        resetConfigPool(true,klasse);

        if (jComboBoxName.getSelectedIndex() == -1)
        {
            clearAll();
        }

        String key = jComboBoxName.getSelectedItem().toString();
        mConfig = mConfigPool.get(key);
        setAllFromCurrent();

        mClassSetting--;
    }//GEN-LAST:event_jButtonDeleteActionPerformed

    private void jButtonNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNewActionPerformed
        mClassSetting++;
        mConfig = new XMLClassBuilderData();
        clearAll();
        resetConfigPool(false, "");
        mClassSetting--;
    }//GEN-LAST:event_jButtonNewActionPerformed

    private void jComboBoxKlasseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxKlasseActionPerformed
        if (mClassSetting >0 ) return;
        mClassSetting++;;

        String selected = jComboBoxKlasse.getSelectedItem().toString();
        clearAll();
        resetConfigPool(true, selected);
        jTextFieldKlasse.setText(jComboBoxKlasse.getSelectedItem().toString());
        String key = jComboBoxName.getSelectedItem().toString();
        mConfig = mConfigPool.get(key);
        setAllFromCurrent();
        mClassSetting--;

    }//GEN-LAST:event_jComboBoxKlasseActionPerformed

    private void jComboBoxNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxNameActionPerformed

        if (mClassSetting > 0 ) return;
        String key = jComboBoxName.getSelectedItem().toString();
        mConfig = mConfigPool.get(key);
        setAllFromCurrent();
    }//GEN-LAST:event_jComboBoxNameActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton JButtonGenerate;
    private javax.swing.JButton jButtonAdField;
    private javax.swing.JButton jButtonDelete;
    private javax.swing.JButton jButtonNew;
    private javax.swing.JButton jButtonSave;
    private javax.swing.JButton jButtonSaveAsNew;
    private javax.swing.JCheckBox jCheckBoxIsProtected;
    private javax.swing.JComboBox jComboBoxKlasse;
    private javax.swing.JComboBox jComboBoxName;
    private javax.swing.JComboBox jComboBoxType;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabelFieldName;
    private javax.swing.JLabel jLabelType;
    private javax.swing.JLabel jLabelXMLName;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanelField;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTextFieldClass;
    private javax.swing.JTextField jTextFieldFieldName;
    private javax.swing.JTextField jTextFieldKlasse;
    private javax.swing.JTextField jTextFieldName;
    private javax.swing.JTextField jTextFieldPackage;
    private javax.swing.JTextField jTextFieldXMLName;
    // End of variables declaration//GEN-END:variables

    private Vector<String> generateClass()
    {
        Vector<String> r = new Vector<String>();
        String bPackage = jTextFieldPackage.getText();
        String bClass = jTextFieldClass.getText();

        r.addElement("package "+bPackage+";\n");
        r.addElement("import csa.util.*;");
        r.addElement("import java.util.*;");
        r.addElement("import java.io.*;");
        r.addElement("import javax.swing.*;");
        r.addElement("import javax.xml.parsers.SAXParserFactory;");
        r.addElement("import javax.xml.parsers.SAXParser;\n");
        r.addElement("public class  "+bClass+"\n{");

        if (jCheckBoxIsProtected.isSelected())
        {
            r.addElement("\tprotected String mClass=\"\";");
            r.addElement("\tpublic String mName=\"\";");

            for (int i =0; i<mFields.size();i++)
            {
                Field f = mFields.elementAt(i);
                if (f.type.equals("String"))
                    r.addElement("\tprotected String m"+f.name+"=\"\";");
                if (f.type.equals("int"))
                    r.addElement("\tprotected int m"+f.name+"=0;");
                if (f.type.equals("float"))
                    r.addElement("\tprotected float m"+f.name+"=0f;");
                if (f.type.equals("boolean"))
                    r.addElement("\tprotected boolean m"+f.name+"=false;");
                if (f.type.equals("Vector<String>"))
                    r.addElement("\tprotected Vector<String> m"+f.name+"=new Vector<String>();");
                if (f.type.equals("Vector<int>"))
                    r.addElement("\tprotected Vector<Integer> m"+f.name+"=new Vector<Integer>();");
                if (f.type.equals("Vector<float>"))
                    r.addElement("\tprotected Vector<Float> m"+f.name+"=new Vector<Float>();");
                if (f.type.equals("Vector<boolean>"))
                    r.addElement("\tprotected Vector<Boolean> m"+f.name+"=new Vector<Boolean>();");
            }

            r.addElement("\tpublic String getName()");
            r.addElement("\t{");
            r.addElement("\t\treturn mName;");
            r.addElement("\t}");
            r.addElement("\tpublic void setName(String n)");
            r.addElement("\t{");
            r.addElement("\t\tmName=n;");
            r.addElement("\t}");

            r.addElement("\tpublic String getCClass()");
            r.addElement("\t{");
            r.addElement("\t\treturn mClass;");
            r.addElement("\t}");
            r.addElement("\tpublic void setCClass(String c)");
            r.addElement("\t{");
            r.addElement("\t\tmClass=c;");
            r.addElement("\t}");

            for (int i =0; i<mFields.size();i++)
            {
                Field f = mFields.elementAt(i);
                if (f.type.equals("String"))
                {
                    r.addElement("\tpublic String get"+f.name+"()");
                    r.addElement("\t{");
                    r.addElement("\t\treturn m"+f.name+";");
                    r.addElement("\t}");
                    r.addElement("\tpublic void set"+f.name+"(String "+f.name+")");
                    r.addElement("\t{");
                    r.addElement("\t\tm"+f.name+"="+f.name+";");
                    r.addElement("\t}");
                }
                if (f.type.equals("int"))
                {
                    r.addElement("\tpublic int get"+f.name+"()");
                    r.addElement("\t{");
                    r.addElement("\t\treturn m"+f.name+";");
                    r.addElement("\t}");
                    r.addElement("\tpublic void set"+f.name+"(int "+f.name+")");
                    r.addElement("\t{");
                    r.addElement("\t\tm"+f.name+"="+f.name+";");
                    r.addElement("\t}");
                }
                if (f.type.equals("float"))
                {
                    r.addElement("\tpublic float get"+f.name+"()");
                    r.addElement("\t{");
                    r.addElement("\t\treturn m"+f.name+";");
                    r.addElement("\t}");
                    r.addElement("\tpublic void set"+f.name+"(float "+f.name+")");
                    r.addElement("\t{");
                    r.addElement("\t\tm"+f.name+"="+f.name+";");
                    r.addElement("\t}");
                }
                if (f.type.equals("boolean"))
                {
                    r.addElement("\tpublic boolean get"+f.name+"()");
                    r.addElement("\t{");
                    r.addElement("\t\treturn m"+f.name+";");
                    r.addElement("\t}");
                    r.addElement("\tpublic void set"+f.name+"(boolean "+f.name+")");
                    r.addElement("\t{");
                    r.addElement("\t\tm"+f.name+"="+f.name+";");
                    r.addElement("\t}");
                }
                if (f.type.equals("Vector<String>"))
                {
                    r.addElement("\tpublic Vector<String> get"+f.name+"()");
                    r.addElement("\t{");
                    r.addElement("\t\treturn m"+f.name+";");
                    r.addElement("\t}");
                    r.addElement("\tpublic void set"+f.name+"(Vector<String> "+f.name+")");
                    r.addElement("\t{");
                    r.addElement("\t\tm"+f.name+"="+f.name+";");
                    r.addElement("\t}");
                }
                if (f.type.equals("Vector<int>"))
                {
                    r.addElement("\tpublic Vector<Integer> get"+f.name+"()");
                    r.addElement("\t{");
                    r.addElement("\t\treturn m"+f.name+";");
                    r.addElement("\t}");
                    r.addElement("\tpublic void set"+f.name+"(Vector<Integer> "+f.name+")");
                    r.addElement("\t{");
                    r.addElement("\t\tm"+f.name+"="+f.name+";");
                    r.addElement("\t}");
                }
                if (f.type.equals("Vector<float>"))
                {
                    r.addElement("\tpublic Vector<Float> get"+f.name+"()");
                    r.addElement("\t{");
                    r.addElement("\t\treturn m"+f.name+";");
                    r.addElement("\t}");
                    r.addElement("\tpublic void set"+f.name+"(Vector<Float> "+f.name+")");
                    r.addElement("\t{");
                    r.addElement("\t\tm"+f.name+"="+f.name+";");
                    r.addElement("\t}");
                }
                if (f.type.equals("Vector<boolean>"))
                {
                    r.addElement("\tpublic Vector<Boolean> get"+f.name+"()");
                    r.addElement("\t{");
                    r.addElement("\t\treturn m"+f.name+";");
                    r.addElement("\t}");
                    r.addElement("\tpublic void set"+f.name+"(Vector<Boolean> "+f.name+")");
                    r.addElement("\t{");
                    r.addElement("\t\tm"+f.name+"="+f.name+";");
                    r.addElement("\t}");
                }
            }

        }

        r.addElement("\tprivate String exportXML()");
        r.addElement("\t{");
        r.addElement("\t\tStringBuffer s = new StringBuffer();");
        r.addElement("\t\ts.append( \"\\t<"+bClass+">\\n\");");


        r.addElement("\t\ts.append( \"\\t\\t<Class>\"+UtilityString.toXML(mClass)+\"</Class>\\n\");");
        r.addElement("\t\ts.append( \"\\t\\t<Name>\"+UtilityString.toXML(mName)+\"</Name>\\n\");");


        for (int i =0; i<mFields.size();i++)
        {
            Field f = mFields.elementAt(i);
            if (f.type.equals("String"))
                r.addElement("\t\ts.append( \"\\t\\t<"+f.xmlName+">\"+UtilityString.toXML(m"+f.name+")+\"</"+f.xmlName+">\\n\");");

            if (f.type.equals("int"))
                r.addElement("\t\ts.append( \"\\t\\t<"+f.xmlName+">\"+m"+f.name+"+\"</"+f.xmlName+">\\n\");");

            if (f.type.equals("float"))
                r.addElement("\t\ts.append( \"\\t\\t<"+f.xmlName+">\"+m"+f.name+"+\"</"+f.xmlName+">\\n\");");

            if (f.type.equals("boolean"))
                r.addElement("\t\ts.append( \"\\t\\t<"+f.xmlName+">\"+m"+f.name+"+\"</"+f.xmlName+">\\n\");");

            if (f.type.equals("Vector<String>"))
            {
                r.addElement("\t\ts.append( \"\\t\\t<"+f.xmlName+"s>\\n\");");
                r.addElement("\t\tfor (int i=0;i<m"+f.name+".size(); i++)");
                r.addElement("\t\t{");
                r.addElement("\t\t\ts.append( \"\\t\\t\\t<"+f.xmlName+">\"+UtilityString.toXML(m"+f.name+".elementAt(i))+\"</"+f.xmlName+">\\n\");");
                r.addElement("\t\t}");
                r.addElement("\t\ts.append( \"\\t\\t</"+f.xmlName+"s>\\n\");");
            }

            if (f.type.equals("Vector<int>"))
            {
                r.addElement("\t\ts.append( \"\\t\\t<"+f.xmlName+"s>\\n\");");
                r.addElement("\t\tfor (int i=0;i<m"+f.name+".size(); i++)");
                r.addElement("\t\t{");
                r.addElement("\t\t\ts.append( \"\\t\\t\\t<"+f.xmlName+">\"+m"+f.name+".elementAt(i)+\"</"+f.xmlName+">\\n\");");
                r.addElement("\t\t}");
                r.addElement("\t\ts.append( \"\\t\\t</"+f.xmlName+"s>\\n\");");
            }

            if (f.type.equals("Vector<float>"))
            {
                r.addElement("\t\ts.append( \"\\t\\t<"+f.xmlName+"s>\\n\");");
                r.addElement("\t\tfor (int i=0;i<m"+f.name+".size(); i++)");
                r.addElement("\t\t{");
                r.addElement("\t\t\ts.append( \"\\t\\t\\t<"+f.xmlName+">\"+m"+f.name+".elementAt(i)+\"</"+f.xmlName+">\\n\");");
                r.addElement("\t\t}");
                r.addElement("\t\ts.append( \"\\t\\t</"+f.xmlName+"s>\\n\");");
            }

            if (f.type.equals("Vector<boolean>"))
            {
                r.addElement("\t\ts.append( \"\\t\\t<"+f.xmlName+"s>\\n\");");
                r.addElement("\t\tfor (int i=0;i<m"+f.name+".size(); i++)");
                r.addElement("\t\t{");
                r.addElement("\t\t\ts.append( \"\\t\\t\\t<"+f.xmlName+">\"+m"+f.name+".elementAt(i)+\"</"+f.xmlName+">\\n\");");
                r.addElement("\t\t}");
                r.addElement("\t\ts.append( \"\\t\\t</"+f.xmlName+"s>\\n\");");
            }
        }
        r.addElement("\t\ts.append( \"\\t</"+bClass+">\\n\");");
        r.addElement("\t\treturn s.toString();");

        r.addElement("\t}");

        r.addElement("\t@Override public String toString()\n\t{\n\t\treturn mName;\n\t}");
        r.addElement("\tprivate static "+bClass+"XMLHandler XMLHANDLER = new "+bClass+"XMLHandler();");
        r.addElement("\tpublic static "+bClass+"XMLHandler getXMLParseHandler()\n\t{\n\t\treturn XMLHANDLER;\n\t}");
        r.addElement("\tpublic static boolean saveCollectionAsXML(String filename, Collection<"+bClass+"> col)");
        r.addElement("\t{\n\t\ttry\n\t\t{");
        r.addElement("\t\t\tPrintWriter pw = new PrintWriter(csa.Global.mBaseDir+filename, \"UTF-8\");");
        r.addElement("\t\t\tpw.print(\"<?xml version=\\\"1.0\\\"?>\\n\");");
        r.addElement("\t\t\tpw.print(\"<All"+bClass+">\\n\");");
        r.addElement("\t\t\tIterator<"+bClass+"> iter = col.iterator();");
        r.addElement("\t\t\twhile (iter.hasNext())");
        r.addElement("\t\t\t{");
        r.addElement("\t\t\t\t"+bClass+" item = iter.next();");
        r.addElement("\t\t\t\tpw.print(item.exportXML());");
        r.addElement("\t\t\t}");
        r.addElement("\t\t\tpw.print(\"</All"+bClass+">\\n\");");
        r.addElement("\t\t\tpw.close();");
        r.addElement("\t\t}");
        r.addElement("\t\tcatch (IOException e)");
        r.addElement("\t\t{");
        r.addElement("\t\t\tSystem.err.println(e.toString());");
        r.addElement("\t\t\treturn false;");
        r.addElement("\t\t}");
        r.addElement("\t\treturn true;");
        r.addElement("\t}");

        r.addElement("\tpublic static HashMap<String, "+bClass+"> getHashMapFromXML(String filename)");
        r.addElement("\t{");
        r.addElement("\t\tHashMap<String, "+bClass+"> filters = new HashMap<String, "+bClass+">();");
        r.addElement("\t\ttry");
        r.addElement("\t\t{");
        r.addElement("\t\t\tSAXParserFactory factory = SAXParserFactory.newInstance();");
        r.addElement("\t\t\tSAXParser saxParser = factory.newSAXParser();");
        r.addElement("\t\t\t"+bClass+"XMLHandler h = "+bClass+".getXMLParseHandler();");
        r.addElement("\t\t\tsaxParser.parse(csa.Global.mBaseDir+filename, h);");
        r.addElement("\t\t\tfilters = h.getLastHashMap();");
        r.addElement("\t\t}");
        r.addElement("\t\tcatch (Throwable e)");
        r.addElement("\t\t{");
        r.addElement("\t\t\te.printStackTrace();");
        r.addElement("\t\t\tJOptionPane.showMessageDialog(null, e.toString() ,\""+bClass+" Load Error...\",  JOptionPane.INFORMATION_MESSAGE);");
        r.addElement("\t\t}");
        r.addElement("\t\treturn filters;");
        r.addElement("\t}");
        r.addElement("}");
        return r;
    }

    private Vector<String> generateHandler()
    {
        Vector<String> r = new Vector<String>();
        String bPackage = jTextFieldPackage.getText();
        String bClass = jTextFieldClass.getText();

        r.addElement("package "+bPackage+";\n");
        r.addElement("import org.xml.sax.helpers.DefaultHandler;");
        r.addElement("import org.xml.sax.*;");
        r.addElement("import java.util.*;");

        r.addElement("public class  "+bClass+"XMLHandler extends DefaultHandler\n{");

        r.addElement("\tprivate HashMap<String, "+bClass+"> m"+bClass+";");
        r.addElement("\tprivate "+bClass+" mCurrentData = null;");
        r.addElement("\tprivate String mCurrentElement = null;");

        for (int i =0; i<mFields.size();i++)
        {
            Field f = mFields.elementAt(i);
            r.addElement("\tprivate String m"+f.name+" = \"\";");
            if (f.type.equals("Vector<String>"))
            {
                r.addElement("\tprivate Vector<String> m"+f.name+"s = null;");
            }
            if (f.type.equals("Vector<int>"))
            {
                r.addElement("\tprivate Vector<Integer> m"+f.name+"s = null;");
            }
            if (f.type.equals("Vector<float>"))
            {
                r.addElement("\tprivate Vector<Float> m"+f.name+"s = null;");
            }
            if (f.type.equals("Vector<boolean>"))
            {
                r.addElement("\tprivate Vector<Boolean> m"+f.name+"s = null;");
            }
        }

        r.addElement("\tpublic HashMap<String, "+bClass+"> getLastHashMap()");
        r.addElement("\t{");
        r.addElement("\t\treturn m"+bClass+";");
        r.addElement("\t}");

        r.addElement("\t@Override public void startDocument() throws SAXException");
        r.addElement("\t{");
        r.addElement("\t\tmCurrentData = new "+bClass+"();");
        r.addElement("\t\tm"+bClass+" = new HashMap<String, "+bClass+">();");
        r.addElement("\t}");

        r.addElement("\t@Override public void endDocument () throws SAXException");
        r.addElement("\t{");
        r.addElement("\t}");

        r.addElement("\t@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException");
        r.addElement("\t{");
        r.addElement("\t\tmCurrentElement = qName;");
        r.addElement("\t\tif (qName.equalsIgnoreCase(\""+bClass+"\"))");
        r.addElement("\t\t{");
        r.addElement("\t\t\tmCurrentData = new "+bClass+"();");
        for (int i =0; i<mFields.size();i++)
        {
            Field f = mFields.elementAt(i);
            r.addElement("\t\t\tm"+f.name+" = \"\";");

            if (f.type.equals("Vector<String>"))
            {
                r.addElement("\t\t\tm"+f.name+"s = new Vector<String>();");
            }
            if (f.type.equals("Vector<int>"))
            {
                r.addElement("\t\t\tm"+f.name+"s = new Vector<Integer>();");
            }
            if (f.type.equals("Vector<float>"))
            {
                r.addElement("\t\t\tm"+f.name+"s = new Vector<Float>();");
            }
            if (f.type.equals("Vector<boolean>"))
            {
                r.addElement("\t\t\tm"+f.name+"s = new Vector<Boolean>();");
            }
        }
        r.addElement("\t\t}");
        r.addElement("\t}");

        r.addElement("\t@Override public void characters(char[] ch, int start, int length)");
        r.addElement("\t{");
        r.addElement("\t\tString s = new String( ch, start, length );");
        r.addElement("\t\tif (mCurrentElement == null) return;");
        if (jCheckBoxIsProtected.isSelected())
        {
            r.addElement("\t\tif (mCurrentElement.equalsIgnoreCase(\"Class\")) mCurrentData.mClass += s;");
            r.addElement("\t\tif (mCurrentElement.equalsIgnoreCase(\"Name\")) mCurrentData.mName += s;");

            for (int i =0; i<mFields.size();i++)
            {
                Field f = mFields.elementAt(i);
                r.addElement("\t\tif (mCurrentElement.equalsIgnoreCase(\""+f.xmlName+"\")) m"+f.name+" += s;");
            }
        }
        r.addElement("\t}");

        r.addElement("\t@Override public void endElement(String uri, String localName, String qName) throws SAXException");
        r.addElement("\t{");


        for (int i =0; i<mFields.size();i++)
        {
            Field f = mFields.elementAt(i);

            if (f.type.equals("Vector<String>"))
            {
                r.addElement("\t\tif (\""+f.xmlName+"\".equalsIgnoreCase(qName))");
                r.addElement("\t\t{");
                r.addElement("\t\t\tm"+f.name+"s.addElement(m"+f.name+");");
                r.addElement("\t\t\tm"+f.name+"=\"\";");
                r.addElement("\t\t}");
            }
            if (f.type.equals("Vector<int>"))
            {
                r.addElement("\t\tif (\""+f.xmlName+"\".equalsIgnoreCase(qName))");
                r.addElement("\t\t{");
                r.addElement("\t\t\ttry{");
                r.addElement("\t\t\tm"+f.name+"s.addElement(Integer.parseInt(m"+f.name+"));");
                r.addElement("\t\t\t}catch (Throwable e){}");
                r.addElement("\t\t\tm"+f.name+"=\"\";");
                r.addElement("\t\t}");
            }
            if (f.type.equals("Vector<float>"))
            {
                r.addElement("\t\tif (\""+f.xmlName+"\".equalsIgnoreCase(qName))");
                r.addElement("\t\t{");
                r.addElement("\t\t\ttry{");
                r.addElement("\t\t\tm"+f.name+"s.addElement(Float.parseFloat(m"+f.name+"));");
                r.addElement("\t\t\t}catch (Throwable e){}");
                r.addElement("\t\t\tm"+f.name+"=\"\";");
                r.addElement("\t\t}");
            }
            if (f.type.equals("Vector<boolean>"))
            {
                r.addElement("\t\tif (\""+f.xmlName+"\".equalsIgnoreCase(qName))");
                r.addElement("\t\t{");
                r.addElement("\t\t\ttry{");
                r.addElement("\t\t\tm"+f.name+"s.addElement(Boolean.parseBoolean(m"+f.name+"));");
                r.addElement("\t\t\t}catch (Throwable e){}");
                r.addElement("\t\t\tm"+f.name+"=\"\";");
                r.addElement("\t\t}");
            }
        }

        r.addElement("\t\tif (\""+bClass+"\".equalsIgnoreCase(qName))");
        r.addElement("\t\t{");

        r.addElement("\t\t\tif (mCurrentData != null)");
        r.addElement("\t\t\t{");

        for (int i =0; i<mFields.size();i++)
        {
            Field f = mFields.elementAt(i);
            if (f.type.equals("String"))
            {
                r.addElement("\t\t\t\tmCurrentData.m"+f.name+" = m"+f.name+";");
            }
            if (f.type.equals("int"))
            {
                r.addElement("\t\t\t\ttry{");
                r.addElement("\t\t\t\tmCurrentData.m"+f.name+" = Integer.parseInt(m"+f.name+");");
                r.addElement("\t\t\t\t}catch (Throwable e){}");
            }
            if (f.type.equals("float"))
            {
                r.addElement("\t\t\t\ttry{");
                r.addElement("\t\t\t\tmCurrentData.m"+f.name+" = Float.parseFloat(m"+f.name+");");
                r.addElement("\t\t\t\t}catch (Throwable e){}");
            }

            if (f.type.equals("boolean"))
            {
                r.addElement("\t\t\t\ttry{");
                r.addElement("\t\t\t\tmCurrentData.m"+f.name+" = Boolean.parseBoolean(m"+f.name+");");
                r.addElement("\t\t\t\t}catch (Throwable e){}");
            }
            r.addElement("\t\t\t\tm"+f.name+" = \"\";");


            if (f.type.equals("Vector<String>"))
            {
                r.addElement("\t\t\t\tmCurrentData.m"+f.name+" = m"+f.name+"s;");
            }
            if (f.type.equals("Vector<int>"))
            {
                r.addElement("\t\t\t\tmCurrentData.m"+f.name+" = m"+f.name+"s;");
            }
            if (f.type.equals("Vector<float>"))
            {
                r.addElement("\t\t\t\tmCurrentData.m"+f.name+" = m"+f.name+"s;");
            }
            if (f.type.equals("Vector<boolean>"))
            {
                r.addElement("\t\t\t\tmCurrentData.m"+f.name+" = m"+f.name+"s;");
            }
        }

        r.addElement("\t\t\t\tm"+bClass+".put(mCurrentData.mName, mCurrentData);");
        r.addElement("\t\t\t\tmCurrentData = null;");
        r.addElement("\t\t\t}");

        r.addElement("\t\t}");
        r.addElement("\t\tmCurrentElement = null;");
        r.addElement("\t}");
        r.addElement("}");
        return r;
    }

    private Vector<String> generatePool()
    {
        Vector<String> r = new Vector<String>();
        String bPackage = jTextFieldPackage.getText();
        String bClass = jTextFieldClass.getText();

        r.addElement("package "+bPackage+";\n");
        r.addElement("import javax.swing.JOptionPane;");
        r.addElement("import java.util.*;");

        r.addElement("public class  "+bClass+"Pool\n{");

        r.addElement("\tpublic static final String DEFAULT_XML_NAME = new String(\""+bClass+".xml\");");
        r.addElement("\tprivate String mFileName = DEFAULT_XML_NAME;");
        r.addElement("\tprivate HashMap<String, "+bClass+"> m"+bClass+" = new HashMap<String, "+bClass+">();");
        r.addElement("\tprivate HashMap<String, String> mKlassenMap = new HashMap<String, String>();");

        r.addElement("\tpublic "+bClass+"Pool(String name)");
        r.addElement("\t{");
        r.addElement("\t\tmFileName = name;");
        r.addElement("\t\tinit();");
        r.addElement("\t}");

        r.addElement("\tpublic "+bClass+"Pool()");
        r.addElement("\t{");
        r.addElement("\t\tinit();");
        r.addElement("\t}");

        r.addElement("\tpublic void setFilename(String n)");
        r.addElement("\t{");
        r.addElement("\t\tmFileName=n;");
        r.addElement("\t}");

        r.addElement("\tprivate boolean init()");
        r.addElement("\t{");
        r.addElement("\t\ttry");
        r.addElement("\t\t{");
        r.addElement("\t\t\treturn load();");
        r.addElement("\t\t}");
        r.addElement("\t\tcatch (Throwable e)");
        r.addElement("\t\t{");
        r.addElement("\t\t\tJOptionPane.showMessageDialog(null, e.toString() ,\"Load Error "+bClass+"...\",  JOptionPane.INFORMATION_MESSAGE);");
        r.addElement("\t\t\treturn false;");
        r.addElement("\t\t}");
        r.addElement("\t}");

        r.addElement("\tpublic boolean load()");
        r.addElement("\t{");
        r.addElement("\t\tjava.io.File f = new java.io.File(csa.Global.mBaseDir+mFileName);");
        r.addElement("\t\tif (!f.exists()) return false;");
        r.addElement("\t\tm"+bClass+" = "+bClass+".getHashMapFromXML(mFileName);");
        r.addElement("\t\treturn true;");
        r.addElement("\t}");

        r.addElement("\tpublic void save()");
        r.addElement("\t{");
        r.addElement("\t\t"+bClass+".saveCollectionAsXML(mFileName, m"+bClass+".values());");
        r.addElement("\t\tbuildKlassenMap();");
        r.addElement("\t}");

        r.addElement("\tpublic void remove("+bClass+" st)");
        r.addElement("\t{");
        r.addElement("\t\tm"+bClass+".remove(st.mName);");
        r.addElement("\t}");

        r.addElement("\tpublic void put("+bClass+" st)");
        r.addElement("\t{");
        r.addElement("\t\tm"+bClass+".remove(st.mName);");
        r.addElement("\t\tm"+bClass+".put(st.mName, st);");
        r.addElement("\t}");

        r.addElement("\tpublic void putAsNew("+bClass+" st)");
        r.addElement("\t{");
        r.addElement("\t\tm"+bClass+".put(st.mName, st);");
        r.addElement("\t}");

        r.addElement("\tpublic "+bClass+" get(String key)");
        r.addElement("\t{");
        r.addElement("\t\treturn m"+bClass+".get(key);");
        r.addElement("\t}");

        r.addElement("\tpublic HashMap<String, "+bClass+"> getHashMap()");
        r.addElement("\t{");
        r.addElement("\t\treturn m"+bClass+";");
        r.addElement("\t}");

        r.addElement("\tprivate void buildKlassenMap()");
        r.addElement("\t{");
        r.addElement("\t\tmKlassenMap = new HashMap<String, String>();");
        r.addElement("\t\tSet entries = m"+bClass+".entrySet();");
        r.addElement("\t\tIterator it = entries.iterator();");
        r.addElement("\t\twhile (it.hasNext())");
        r.addElement("\t\t{");
        r.addElement("\t\t\tMap.Entry entry = (Map.Entry) it.next();");
        r.addElement("\t\t\t"+bClass+" value = ("+bClass+") entry.getValue();");
        r.addElement("\t\t\tmKlassenMap.put(value.mClass, value.mClass);");
        r.addElement("\t\t}");
        r.addElement("\t}");

        r.addElement("\tpublic HashMap<String, String> getKlassenHashMap()");
        r.addElement("\t{");
        r.addElement("\t\tbuildKlassenMap();");
        r.addElement("\t\treturn mKlassenMap;");
        r.addElement("\t}");


        r.addElement("\tpublic HashMap<String, "+bClass+"> getMapForKlasse(String klasse)");
        r.addElement("\t{");
        r.addElement("\t\tHashMap<String, "+bClass+"> ret = new HashMap<String, "+bClass+">();");
        r.addElement("\t\tSet entries = m"+bClass+".entrySet();");
        r.addElement("\t\tIterator it = entries.iterator();");
        r.addElement("\t\twhile (it.hasNext())");
        r.addElement("\t\t{");
        r.addElement("\t\t\tMap.Entry entry = (Map.Entry) it.next();");
        r.addElement("\t\t\t"+bClass+" value = ("+bClass+") entry.getValue();");
        r.addElement("\t\t\tif (value.mClass.equalsIgnoreCase(klasse))");
        r.addElement("\t\t\t{");
        r.addElement("\t\t\t\tret.put(value.mName, value);");
        r.addElement("\t\t\t}");
        r.addElement("\t\t}");
        r.addElement("\t\t return ret;");
        r.addElement("\t}");
        r.addElement("}");
        return r;
    }


    private Vector<String> generateTemplateGUI()
    {
        Vector<String> r = new Vector<String>();
        String bPackage = jTextFieldPackage.getText();
        String bClass = jTextFieldClass.getText();

        r.addElement("package "+bPackage+";\n");
	r.addElement("");
	r.addElement("import java.util.*;");
	r.addElement("");
	r.addElement("public class TemplateGui extends javax.swing.JPanel {");
	r.addElement("    private XMLClassBuilderData mConfig = new XMLClassBuilderData();");
	r.addElement("    private XMLClassBuilderDataPool mConfigPool;");
	r.addElement("    private int mClassSetting=0;");
	r.addElement("");
	r.addElement("    /** Creates new form TemplateGui */");
	r.addElement("    public TemplateGui() {");
	r.addElement("        initComponents();");
	r.addElement("        mConfigPool = new XMLClassBuilderDataPool();");
	r.addElement("        resetConfigPool(false, \"\");");
	r.addElement("    }");
	r.addElement("");
	r.addElement("    private void resetConfigPool(boolean select, String klasseToSet) /* allneeded*/");
	r.addElement("    {");
	r.addElement("        mClassSetting++;");
	r.addElement("        Collection<String> collectionKlasse = mConfigPool.getKlassenHashMap().values();");
	r.addElement("        Iterator<String> iterKlasse = collectionKlasse.iterator();");
	r.addElement("        int i = 0;");
	r.addElement("        String klasse = \"\";");
	r.addElement("");
	r.addElement("        jComboBoxKlasse.removeAllItems();");
	r.addElement("        while (iterKlasse.hasNext())");
	r.addElement("        {");
	r.addElement("            String item = iterKlasse.next();");
	r.addElement("            jComboBoxKlasse.addItem(item);");
	r.addElement("            if (select)");
	r.addElement("            {");
	r.addElement("                if (klasseToSet.length()==0)");
	r.addElement("                {");
	r.addElement("                    if (i==0)");
	r.addElement("                    {");
	r.addElement("                        jComboBoxKlasse.setSelectedIndex(i);");
	r.addElement("                        jTextFieldKlasse.setText(item);");
	r.addElement("                        klasse = item;");
	r.addElement("                    }");
	r.addElement("                }");
	r.addElement("                else");
	r.addElement("                {");
	r.addElement("                    if (klasseToSet.equalsIgnoreCase(item))");
	r.addElement("                    {");
	r.addElement("                        jComboBoxKlasse.setSelectedIndex(i);");
	r.addElement("                        jTextFieldKlasse.setText(item);");
	r.addElement("                        klasse = item;");
	r.addElement("                    }");
	r.addElement("                }");
	r.addElement("            }");
	r.addElement("            i++;");
	r.addElement("        }");
	r.addElement("        if ((select) && (klasse.length()==0))");
	r.addElement("        {");
	r.addElement("            if (jComboBoxKlasse.getItemCount()>0)");
	r.addElement("            {");
	r.addElement("                jComboBoxKlasse.setSelectedIndex(0);");
	r.addElement("                jTextFieldKlasse.setText(jComboBoxKlasse.getSelectedItem().toString());");
	r.addElement("                klasse = jComboBoxKlasse.getSelectedItem().toString();");
	r.addElement("            }");
	r.addElement("        }");
	r.addElement("        if (!select)  jComboBoxKlasse.setSelectedIndex(-1);");
	r.addElement("");
	r.addElement("        Collection<XMLClassBuilderData> colC = mConfigPool.getMapForKlasse(klasse).values();");
	r.addElement("        Iterator<XMLClassBuilderData> iterC = colC.iterator();");
	r.addElement("");
	r.addElement("        jComboBoxName.removeAllItems();");
	r.addElement("        i = 0;");
	r.addElement("        while (iterC.hasNext())");
	r.addElement("        {");
	r.addElement("            XMLClassBuilderData item = iterC.next();");
	r.addElement("            jComboBoxName.addItem(item.mName);");
	r.addElement("            if ((i==0) && (select))");
	r.addElement("            {");
	r.addElement("                jComboBoxName.setSelectedIndex(0);");
	r.addElement("                mConfig = mConfigPool.get(item.mName);");
	r.addElement("                setAllFromCurrent();");
	r.addElement("            }");
	r.addElement("            i++;");
	r.addElement("        }");
	r.addElement("        if (!select)  jComboBoxName.setSelectedIndex(-1);");
	r.addElement("        mClassSetting--;");
	r.addElement("    }");
	r.addElement("");
	r.addElement("    private void clearAll() /* allneeded*/");
	r.addElement("    {");
	r.addElement("        mClassSetting++;");
	r.addElement("        mConfig = new XMLClassBuilderData();");
	r.addElement("        setAllFromCurrent();");
	r.addElement("        mClassSetting--;");
	r.addElement("    }");
	r.addElement("");
	r.addElement("    private void setAllFromCurrent() /* allneeded*/");
	r.addElement("    {");
	r.addElement("        mClassSetting++;");
	r.addElement("        jComboBoxKlasse.setSelectedItem(mConfig.mClass);");
	r.addElement("        jTextFieldKlasse.setText(mConfig.mClass);");
	r.addElement("        jComboBoxName.setSelectedItem(mConfig.mName);");
	r.addElement("        jTextFieldName.setText(mConfig.mName);");
	r.addElement("");
	r.addElement("        /* TO DO: Fill in needed Fields!");
	r.addElement("         *");
	r.addElement("         */");
	r.addElement("        mClassSetting--;");
	r.addElement("    }");
	r.addElement("");
	r.addElement("    private void readAllToCurrent() /* allneeded*/");
	r.addElement("    {");
	r.addElement("        mConfig.mClass = jTextFieldKlasse.getText();");
	r.addElement("        mConfig.mName = jTextFieldName.getText();");
	r.addElement("");
	r.addElement("        /* TO DO: Fill in needed Fields!");
	r.addElement("         *");
	r.addElement("         */");
	r.addElement("    }");
	r.addElement("    /** This method is called from within the constructor to");
	r.addElement("     * initialize the form.");
	r.addElement("     * WARNING: Do NOT modify this code. The content of this method is");
	r.addElement("     * always regenerated by the Form Editor.");
	r.addElement("     */");
	r.addElement("    @SuppressWarnings(\"unchecked\")");
	r.addElement("    // <editor-"+"fold defaultstate=\"collapsed\" desc=\"Generated Code\">/"+"/GEN"+"-BEGI"+"N:initComponents");
	r.addElement("    private void initComponents() {");
	r.addElement("");
	r.addElement("        jPanel1 = new javax.swing.JPanel();");
	r.addElement("        jComboBoxKlasse = new javax.swing.JComboBox();");
	r.addElement("        jComboBoxName = new javax.swing.JComboBox();");
	r.addElement("        jLabel3 = new javax.swing.JLabel();");
	r.addElement("        jLabel4 = new javax.swing.JLabel();");
	r.addElement("        jTextFieldName = new javax.swing.JTextField();");
	r.addElement("        jTextFieldKlasse = new javax.swing.JTextField();");
	r.addElement("        jButtonNew = new javax.swing.JButton();");
	r.addElement("        jButtonSave = new javax.swing.JButton();");
	r.addElement("        jButtonSaveAsNew = new javax.swing.JButton();");
	r.addElement("        jButtonDelete = new javax.swing.JButton();");
	r.addElement("        jPanel2 = new javax.swing.JPanel();");
	r.addElement("");
	r.addElement("        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());");
	r.addElement("");
	r.addElement("        jComboBoxKlasse.addActionListener(new java.awt.event.ActionListener() {");
	r.addElement("            public void actionPerformed(java.awt.event.ActionEvent evt) {");
	r.addElement("                jComboBoxKlasseActionPerformed(evt);");
	r.addElement("            }");
	r.addElement("        });");
	r.addElement("");
	r.addElement("        jComboBoxName.addActionListener(new java.awt.event.ActionListener() {");
	r.addElement("            public void actionPerformed(java.awt.event.ActionEvent evt) {");
	r.addElement("                jComboBoxNameActionPerformed(evt);");
	r.addElement("            }");
	r.addElement("        });");
	r.addElement("");
	r.addElement("        jLabel3.setText(\"Name\");");
	r.addElement("");
	r.addElement("        jLabel4.setText(\"Class\");");
	r.addElement("");
	r.addElement("        jButtonNew.setText(\"New\");");
	r.addElement("        jButtonNew.addActionListener(new java.awt.event.ActionListener() {");
	r.addElement("            public void actionPerformed(java.awt.event.ActionEvent evt) {");
	r.addElement("                jButtonNewActionPerformed(evt);");
	r.addElement("            }");
	r.addElement("        });");
	r.addElement("");
	r.addElement("        jButtonSave.setText(\"Save\");");
	r.addElement("        jButtonSave.addActionListener(new java.awt.event.ActionListener() {");
	r.addElement("            public void actionPerformed(java.awt.event.ActionEvent evt) {");
	r.addElement("                jButtonSaveActionPerformed(evt);");
	r.addElement("            }");
	r.addElement("        });");
	r.addElement("");
	r.addElement("        jButtonSaveAsNew.setText(\"Save as new\");");
	r.addElement("        jButtonSaveAsNew.addActionListener(new java.awt.event.ActionListener() {");
	r.addElement("            public void actionPerformed(java.awt.event.ActionEvent evt) {");
	r.addElement("                jButtonSaveAsNewActionPerformed(evt);");
	r.addElement("            }");
	r.addElement("        });");
	r.addElement("");
	r.addElement("        jButtonDelete.setText(\"Delete\");");
	r.addElement("        jButtonDelete.addActionListener(new java.awt.event.ActionListener() {");
	r.addElement("            public void actionPerformed(java.awt.event.ActionEvent evt) {");
	r.addElement("                jButtonDeleteActionPerformed(evt);");
	r.addElement("            }");
	r.addElement("        });");
	r.addElement("");
	r.addElement("        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);");
	r.addElement("        jPanel1.setLayout(jPanel1Layout);");
	r.addElement("        jPanel1Layout.setHorizontalGroup(");
	r.addElement("            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)");
	r.addElement("            .addGroup(jPanel1Layout.createSequentialGroup()");
	r.addElement("                .addContainerGap()");
	r.addElement("                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)");
	r.addElement("                    .addComponent(jLabel4)");
	r.addElement("                    .addComponent(jLabel3))");
	r.addElement("                .addGap(16, 16, 16)");
	r.addElement("                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)");
	r.addElement("                    .addComponent(jTextFieldName, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)");
	r.addElement("                    .addComponent(jTextFieldKlasse, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE))");
	r.addElement("                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)");
	r.addElement("                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)");
	r.addElement("                    .addComponent(jComboBoxKlasse, 0, 146, Short.MAX_VALUE)");
	r.addElement("                    .addComponent(jComboBoxName, 0, 146, Short.MAX_VALUE))");
	r.addElement("                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)");
	r.addElement("                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)");
	r.addElement("                    .addComponent(jButtonSave)");
	r.addElement("                    .addComponent(jButtonNew))");
	r.addElement("                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)");
	r.addElement("                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)");
	r.addElement("                    .addComponent(jButtonSaveAsNew)");
	r.addElement("                    .addComponent(jButtonDelete))");
	r.addElement("                .addContainerGap())");
	r.addElement("        );");
	r.addElement("        jPanel1Layout.setVerticalGroup(");
	r.addElement("            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)");
	r.addElement("            .addGroup(jPanel1Layout.createSequentialGroup()");
	r.addElement("                .addContainerGap()");
	r.addElement("                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)");
	r.addElement("                    .addGroup(jPanel1Layout.createSequentialGroup()");
	r.addElement("                        .addComponent(jButtonDelete)");
	r.addElement("                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)");
	r.addElement("                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)");
	r.addElement("                            .addComponent(jButtonSave)");
	r.addElement("                            .addComponent(jButtonSaveAsNew)))");
	r.addElement("                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)");
	r.addElement("                        .addGroup(jPanel1Layout.createSequentialGroup()");
	r.addElement("                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)");
	r.addElement("                                .addComponent(jComboBoxKlasse, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)");
	r.addElement("                                .addComponent(jButtonNew))");
	r.addElement("                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)");
	r.addElement("                            .addComponent(jComboBoxName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))");
	r.addElement("                        .addGroup(jPanel1Layout.createSequentialGroup()");
	r.addElement("                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)");
	r.addElement("                                .addComponent(jLabel4)");
	r.addElement("                                .addComponent(jTextFieldKlasse, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))");
	r.addElement("                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)");
	r.addElement("                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)");
	r.addElement("                                .addComponent(jLabel3)");
	r.addElement("                                .addComponent(jTextFieldName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))");
	r.addElement("                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))");
	r.addElement("        );");
	r.addElement("");
	r.addElement("        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);");
	r.addElement("        jPanel2.setLayout(jPanel2Layout);");
	r.addElement("        jPanel2Layout.setHorizontalGroup(");
	r.addElement("            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)");
	r.addElement("            .addGap(0, 531, Short.MAX_VALUE)");
	r.addElement("        );");
	r.addElement("        jPanel2Layout.setVerticalGroup(");
	r.addElement("            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)");
	r.addElement("            .addGap(0, 215, Short.MAX_VALUE)");
	r.addElement("        );");
	r.addElement("");
	r.addElement("        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);");
	r.addElement("        this.setLayout(layout);");
	r.addElement("        layout.setHorizontalGroup(");
	r.addElement("            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)");
	r.addElement("            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)");
	r.addElement("            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)");
	r.addElement("        );");
	r.addElement("        layout.setVerticalGroup(");
	r.addElement("            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)");
	r.addElement("            .addGroup(layout.createSequentialGroup()");
	r.addElement("                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)");
	r.addElement("                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)");
	r.addElement("                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))");
	r.addElement("        );");
	r.addElement("    }// </editor"+"-fold>/"+"/GEN"+"-EN"+"D:initComponents");
	r.addElement("");
	r.addElement("    private void jButtonNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN"+"-FIRST:event_jButtonNewActionPerformed");
	r.addElement("        mClassSetting++;");
	r.addElement("        mConfig = new XMLClassBuilderData();");
	r.addElement("        clearAll();");
	r.addElement("        resetConfigPool(false, \"\");");
	r.addElement("        mClassSetting--;");
	r.addElement("}//GEN"+"-"+"LAST:event_jButtonNewActionPerformed");
	r.addElement("");
	r.addElement("    private void jButtonSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN"+"-"+"FIRST:event_jButtonSaveActionPerformed");
	r.addElement("");
	r.addElement("        readAllToCurrent();");
	r.addElement("        mConfigPool.put(mConfig);");
	r.addElement("        mConfigPool.save();");
	r.addElement("        mClassSetting++;");
	r.addElement("        String klasse = jTextFieldKlasse.getText();");
	r.addElement("        resetConfigPool(true, klasse);");
	r.addElement("        jComboBoxName.setSelectedItem(mConfig.mName);");
	r.addElement("        mClassSetting--;");
	r.addElement("    }//GEN"+"-"+"LAST:event_jButtonSaveActionPerformed");
	r.addElement("");
	r.addElement("    private void jButtonSaveAsNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN"+"-"+"FIRST:event_jButtonSaveAsNewActionPerformed");
	r.addElement("        mConfig = new XMLClassBuilderData();");
	r.addElement("        readAllToCurrent();");
	r.addElement("        mConfigPool.putAsNew(mConfig);");
	r.addElement("        mConfigPool.save();");
	r.addElement("        mClassSetting++;");
	r.addElement("        String klasse = jTextFieldKlasse.getText();");
	r.addElement("        resetConfigPool(true,klasse);");
	r.addElement("        jComboBoxName.setSelectedItem(mConfig.mName);");
	r.addElement("        mClassSetting--;");
	r.addElement("    }//GEN"+"-"+"LAST:event_jButtonSaveAsNewActionPerformed");
	r.addElement("");
	r.addElement("    private void jButtonDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN"+"-"+"FIRST:event_jButtonDeleteActionPerformed");
	r.addElement("        readAllToCurrent();");
	r.addElement("        mConfigPool.remove(mConfig);");
	r.addElement("        mConfigPool.save();");
	r.addElement("        mClassSetting++;");
	r.addElement("        String klasse = jTextFieldKlasse.getText();");
	r.addElement("        resetConfigPool(true,klasse);");
	r.addElement("");
	r.addElement("        if (jComboBoxName.getSelectedIndex() == -1)");
	r.addElement("        {");
	r.addElement("            clearAll();");
	r.addElement("        }");
	r.addElement("");
	r.addElement("        String key = jComboBoxName.getSelectedItem().toString();");
	r.addElement("        mConfig = mConfigPool.get(key);");
	r.addElement("        setAllFromCurrent();");
	r.addElement("");
	r.addElement("        mClassSetting--;");
	r.addElement("}//GEN"+"-"+"LAST:event_jButtonDeleteActionPerformed");
	r.addElement("");
	r.addElement("    private void jComboBoxKlasseActionPerformed(java.awt.event.ActionEvent evt) {//GEN"+"-"+"FIRST:event_jComboBoxKlasseActionPerformed");
	r.addElement("        if (mClassSetting >0 ) return;");
	r.addElement("        mClassSetting++;;");
	r.addElement("");
	r.addElement("        String selected = jComboBoxKlasse.getSelectedItem().toString();");
	r.addElement("        clearAll();");
	r.addElement("        resetConfigPool(true, selected);");
	r.addElement("        jTextFieldKlasse.setText(jComboBoxKlasse.getSelectedItem().toString());");
	r.addElement("        String key = jComboBoxName.getSelectedItem().toString();");
	r.addElement("        mConfig = mConfigPool.get(key);");
	r.addElement("        setAllFromCurrent();");
	r.addElement("        mClassSetting--;");
	r.addElement("    }//GEN"+"-"+"LAST:event_jComboBoxKlasseActionPerformed");
	r.addElement("");
	r.addElement("    private void jComboBoxNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN"+"-"+"FIRST:event_jComboBoxNameActionPerformed");
	r.addElement("        if (mClassSetting > 0 ) return;");
	r.addElement("        String key = jComboBoxName.getSelectedItem().toString();");
	r.addElement("        mConfig = mConfigPool.get(key);");
	r.addElement("        setAllFromCurrent();");
	r.addElement("    }//GEN"+"-"+"LAST:event_jComboBoxNameActionPerformed");
	r.addElement("");
	r.addElement("");
	r.addElement("    // Variables declaration - do not modify//GEN"+"-"+"BEGIN:variables");
	r.addElement("    private javax.swing.JButton jButtonDelete;");
	r.addElement("    private javax.swing.JButton jButtonNew;");
	r.addElement("    private javax.swing.JButton jButtonSave;");
	r.addElement("    private javax.swing.JButton jButtonSaveAsNew;");
	r.addElement("    private javax.swing.JComboBox jComboBoxKlasse;");
	r.addElement("    private javax.swing.JComboBox jComboBoxName;");
	r.addElement("    private javax.swing.JLabel jLabel3;");
	r.addElement("    private javax.swing.JLabel jLabel4;");
	r.addElement("    private javax.swing.JPanel jPanel1;");
	r.addElement("    private javax.swing.JPanel jPanel2;");
	r.addElement("    private javax.swing.JTextField jTextFieldKlasse;");
	r.addElement("    private javax.swing.JTextField jTextFieldName;");
	r.addElement("    // End of variables declaration//GEN"+"-"+"END:variables");
	r.addElement("");
	r.addElement("}");

        r=csa.util.UtilityString.vectorReplace(r,"XMLClassBuilderDataPool", bClass+"Pool" );
        r=csa.util.UtilityString.vectorReplace(r,"mConfigPool", "m"+bClass+"Pool" );
        r=csa.util.UtilityString.vectorReplace(r,"XMLClassBuilderData", bClass );
        r=csa.util.UtilityString.vectorReplace(r,"mConfig", "m"+bClass);
        r=csa.util.UtilityString.vectorReplace(r,"TemplateGui", bClass+"Panel" );
	return r;
    }

    private Vector<String> generateTemplateGUIForm()
    {
        Vector<String> r = new Vector<String>();

	r.addElement("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
	r.addElement("");
	r.addElement("<Form version=\"1.3\" maxVersion=\"1.7\" type=\"org.netbeans.modules.form.forminfo.JPanelFormInfo\">");
	r.addElement("  <AuxValues>");
	r.addElement("    <AuxValue name=\"FormSettings_autoResourcing\" type=\"java.lang.Integer\" value=\"0\"/>");
	r.addElement("    <AuxValue name=\"FormSettings_autoSetComponentName\" type=\"java.lang.Boolean\" value=\"false\"/>");
	r.addElement("    <AuxValue name=\"FormSettings_generateFQN\" type=\"java.lang.Boolean\" value=\"true\"/>");
	r.addElement("    <AuxValue name=\"FormSettings_generateMnemonicsCode\" type=\"java.lang.Boolean\" value=\"false\"/>");
	r.addElement("    <AuxValue name=\"FormSettings_i18nAutoMode\" type=\"java.lang.Boolean\" value=\"false\"/>");
	r.addElement("    <AuxValue name=\"FormSettings_layoutCodeTarget\" type=\"java.lang.Integer\" value=\"1\"/>");
	r.addElement("    <AuxValue name=\"FormSettings_listenerGenerationStyle\" type=\"java.lang.Integer\" value=\"0\"/>");
	r.addElement("    <AuxValue name=\"FormSettings_variablesLocal\" type=\"java.lang.Boolean\" value=\"false\"/>");
	r.addElement("    <AuxValue name=\"FormSettings_variablesModifier\" type=\"java.lang.Integer\" value=\"2\"/>");
	r.addElement("  </AuxValues>");
	r.addElement("");
	r.addElement("  <Layout>");
	r.addElement("    <DimensionLayout dim=\"0\">");
	r.addElement("      <Group type=\"103\" groupAlignment=\"0\" attributes=\"0\">");
	r.addElement("          <Component id=\"jPanel1\" alignment=\"0\" max=\"32767\" attributes=\"0\"/>");
	r.addElement("          <Component id=\"jPanel2\" alignment=\"0\" max=\"32767\" attributes=\"0\"/>");
	r.addElement("      </Group>");
	r.addElement("    </DimensionLayout>");
	r.addElement("    <DimensionLayout dim=\"1\">");
	r.addElement("      <Group type=\"103\" groupAlignment=\"0\" attributes=\"0\">");
	r.addElement("          <Group type=\"102\" alignment=\"0\" attributes=\"0\">");
	r.addElement("              <Component id=\"jPanel1\" min=\"-2\" max=\"-2\" attributes=\"0\"/>");
	r.addElement("              <EmptySpace max=\"-2\" attributes=\"0\"/>");
	r.addElement("              <Component id=\"jPanel2\" max=\"32767\" attributes=\"0\"/>");
	r.addElement("          </Group>");
	r.addElement("      </Group>");
	r.addElement("    </DimensionLayout>");
	r.addElement("  </Layout>");
	r.addElement("  <SubComponents>");
	r.addElement("    <Container class=\"javax.swing.JPanel\" name=\"jPanel1\">");
	r.addElement("      <Properties>");
	r.addElement("        <Property name=\"border\" type=\"javax.swing.border.Border\" editor=\"org.netbeans.modules.form.editors2.BorderEditor\">");
	r.addElement("          <Border info=\"org.netbeans.modules.form.compat2.border.EtchedBorderInfo\">");
	r.addElement("            <EtchetBorder/>");
	r.addElement("          </Border>");
	r.addElement("        </Property>");
	r.addElement("      </Properties>");
	r.addElement("");
	r.addElement("      <Layout>");
	r.addElement("        <DimensionLayout dim=\"0\">");
	r.addElement("          <Group type=\"103\" groupAlignment=\"0\" attributes=\"0\">");
	r.addElement("              <Group type=\"102\" alignment=\"0\" attributes=\"0\">");
	r.addElement("                  <EmptySpace max=\"-2\" attributes=\"0\"/>");
	r.addElement("                  <Group type=\"103\" groupAlignment=\"0\" attributes=\"0\">");
	r.addElement("                      <Component id=\"jLabel4\" alignment=\"0\" min=\"-2\" max=\"-2\" attributes=\"0\"/>");
	r.addElement("                      <Component id=\"jLabel3\" alignment=\"0\" min=\"-2\" max=\"-2\" attributes=\"0\"/>");
	r.addElement("                  </Group>");
	r.addElement("                  <EmptySpace min=\"-2\" pref=\"16\" max=\"-2\" attributes=\"0\"/>");
	r.addElement("                  <Group type=\"103\" groupAlignment=\"1\" attributes=\"0\">");
	r.addElement("                      <Component id=\"jTextFieldName\" alignment=\"0\" pref=\"146\" max=\"32767\" attributes=\"0\"/>");
	r.addElement("                      <Component id=\"jTextFieldKlasse\" alignment=\"0\" pref=\"146\" max=\"32767\" attributes=\"1\"/>");
	r.addElement("                  </Group>");
	r.addElement("                  <EmptySpace type=\"unrelated\" max=\"-2\" attributes=\"0\"/>");
	r.addElement("                  <Group type=\"103\" groupAlignment=\"0\" attributes=\"0\">");
	r.addElement("                      <Component id=\"jComboBoxKlasse\" pref=\"146\" max=\"32767\" attributes=\"0\"/>");
	r.addElement("                      <Component id=\"jComboBoxName\" alignment=\"0\" pref=\"146\" max=\"32767\" attributes=\"1\"/>");
	r.addElement("                  </Group>");
	r.addElement("                  <EmptySpace max=\"-2\" attributes=\"0\"/>");
	r.addElement("                  <Group type=\"103\" groupAlignment=\"0\" attributes=\"0\">");
	r.addElement("                      <Component id=\"jButtonSave\" min=\"-2\" max=\"-2\" attributes=\"0\"/>");
	r.addElement("                      <Component id=\"jButtonNew\" min=\"-2\" max=\"-2\" attributes=\"0\"/>");
	r.addElement("                  </Group>");
	r.addElement("                  <EmptySpace max=\"-2\" attributes=\"0\"/>");
	r.addElement("                  <Group type=\"103\" groupAlignment=\"0\" attributes=\"0\">");
	r.addElement("                      <Component id=\"jButtonSaveAsNew\" alignment=\"0\" min=\"-2\" max=\"-2\" attributes=\"0\"/>");
	r.addElement("                      <Component id=\"jButtonDelete\" alignment=\"0\" min=\"-2\" max=\"-2\" attributes=\"0\"/>");
	r.addElement("                  </Group>");
	r.addElement("                  <EmptySpace min=\"-2\" max=\"-2\" attributes=\"0\"/>");
	r.addElement("              </Group>");
	r.addElement("          </Group>");
	r.addElement("        </DimensionLayout>");
	r.addElement("        <DimensionLayout dim=\"1\">");
	r.addElement("          <Group type=\"103\" groupAlignment=\"0\" attributes=\"0\">");
	r.addElement("              <Group type=\"102\" alignment=\"0\" attributes=\"0\">");
	r.addElement("                  <EmptySpace max=\"-2\" attributes=\"0\"/>");
	r.addElement("                  <Group type=\"103\" groupAlignment=\"0\" attributes=\"0\">");
	r.addElement("                      <Group type=\"102\" alignment=\"0\" attributes=\"0\">");
	r.addElement("                          <Component id=\"jButtonDelete\" min=\"-2\" max=\"-2\" attributes=\"0\"/>");
	r.addElement("                          <EmptySpace max=\"-2\" attributes=\"0\"/>");
	r.addElement("                          <Group type=\"103\" groupAlignment=\"3\" attributes=\"0\">");
	r.addElement("                              <Component id=\"jButtonSave\" alignment=\"3\" min=\"-2\" max=\"-2\" attributes=\"0\"/>");
	r.addElement("                              <Component id=\"jButtonSaveAsNew\" alignment=\"3\" min=\"-2\" max=\"-2\" attributes=\"0\"/>");
	r.addElement("                          </Group>");
	r.addElement("                      </Group>");
	r.addElement("                      <Group type=\"103\" alignment=\"0\" groupAlignment=\"1\" attributes=\"0\">");
	r.addElement("                          <Group type=\"102\" alignment=\"1\" attributes=\"0\">");
	r.addElement("                              <Group type=\"103\" groupAlignment=\"3\" attributes=\"0\">");
	r.addElement("                                  <Component id=\"jComboBoxKlasse\" alignment=\"3\" min=\"-2\" max=\"-2\" attributes=\"0\"/>");
	r.addElement("                                  <Component id=\"jButtonNew\" alignment=\"3\" min=\"-2\" max=\"-2\" attributes=\"0\"/>");
	r.addElement("                              </Group>");
	r.addElement("                              <EmptySpace max=\"-2\" attributes=\"0\"/>");
	r.addElement("                              <Component id=\"jComboBoxName\" min=\"-2\" max=\"-2\" attributes=\"0\"/>");
	r.addElement("                          </Group>");
	r.addElement("                          <Group type=\"102\" alignment=\"1\" attributes=\"0\">");
	r.addElement("                              <Group type=\"103\" groupAlignment=\"3\" attributes=\"0\">");
	r.addElement("                                  <Component id=\"jLabel4\" alignment=\"3\" min=\"-2\" max=\"-2\" attributes=\"0\"/>");
	r.addElement("                                  <Component id=\"jTextFieldKlasse\" alignment=\"3\" min=\"-2\" max=\"-2\" attributes=\"0\"/>");
	r.addElement("                              </Group>");
	r.addElement("                              <EmptySpace max=\"-2\" attributes=\"0\"/>");
	r.addElement("                              <Group type=\"103\" groupAlignment=\"3\" attributes=\"0\">");
	r.addElement("                                  <Component id=\"jLabel3\" alignment=\"3\" min=\"-2\" max=\"-2\" attributes=\"0\"/>");
	r.addElement("                                  <Component id=\"jTextFieldName\" alignment=\"3\" min=\"-2\" max=\"-2\" attributes=\"0\"/>");
	r.addElement("                              </Group>");
	r.addElement("                          </Group>");
	r.addElement("                      </Group>");
	r.addElement("                  </Group>");
	r.addElement("                  <EmptySpace max=\"32767\" attributes=\"0\"/>");
	r.addElement("              </Group>");
	r.addElement("          </Group>");
	r.addElement("        </DimensionLayout>");
	r.addElement("      </Layout>");
	r.addElement("      <SubComponents>");
	r.addElement("        <Component class=\"javax.swing.JComboBox\" name=\"jComboBoxKlasse\">");
	r.addElement("          <Properties>");
	r.addElement("            <Property name=\"model\" type=\"javax.swing.ComboBoxModel\" editor=\"org.netbeans.modules.form.editors2.ComboBoxModelEditor\">");
	r.addElement("              <StringArray count=\"0\"/>");
	r.addElement("            </Property>");
	r.addElement("          </Properties>");
	r.addElement("          <Events>");
	r.addElement("            <EventHandler event=\"actionPerformed\" listener=\"java.awt.event.ActionListener\" parameters=\"java.awt.event.ActionEvent\" handler=\"jComboBoxKlasseActionPerformed\"/>");
	r.addElement("          </Events>");
	r.addElement("        </Component>");
	r.addElement("        <Component class=\"javax.swing.JComboBox\" name=\"jComboBoxName\">");
	r.addElement("          <Properties>");
	r.addElement("            <Property name=\"model\" type=\"javax.swing.ComboBoxModel\" editor=\"org.netbeans.modules.form.editors2.ComboBoxModelEditor\">");
	r.addElement("              <StringArray count=\"0\"/>");
	r.addElement("            </Property>");
	r.addElement("          </Properties>");
	r.addElement("          <Events>");
	r.addElement("            <EventHandler event=\"actionPerformed\" listener=\"java.awt.event.ActionListener\" parameters=\"java.awt.event.ActionEvent\" handler=\"jComboBoxNameActionPerformed\"/>");
	r.addElement("          </Events>");
	r.addElement("        </Component>");
	r.addElement("        <Component class=\"javax.swing.JLabel\" name=\"jLabel3\">");
	r.addElement("          <Properties>");
	r.addElement("            <Property name=\"text\" type=\"java.lang.String\" value=\"Name\"/>");
	r.addElement("          </Properties>");
	r.addElement("        </Component>");
	r.addElement("        <Component class=\"javax.swing.JLabel\" name=\"jLabel4\">");
	r.addElement("          <Properties>");
	r.addElement("            <Property name=\"text\" type=\"java.lang.String\" value=\"Class\"/>");
	r.addElement("          </Properties>");
	r.addElement("        </Component>");
	r.addElement("        <Component class=\"javax.swing.JTextField\" name=\"jTextFieldName\">");
	r.addElement("        </Component>");
	r.addElement("        <Component class=\"javax.swing.JTextField\" name=\"jTextFieldKlasse\">");
	r.addElement("        </Component>");
	r.addElement("        <Component class=\"javax.swing.JButton\" name=\"jButtonNew\">");
	r.addElement("          <Properties>");
	r.addElement("            <Property name=\"text\" type=\"java.lang.String\" value=\"New\"/>");
	r.addElement("          </Properties>");
	r.addElement("          <Events>");
	r.addElement("            <EventHandler event=\"actionPerformed\" listener=\"java.awt.event.ActionListener\" parameters=\"java.awt.event.ActionEvent\" handler=\"jButtonNewActionPerformed\"/>");
	r.addElement("          </Events>");
	r.addElement("        </Component>");
	r.addElement("        <Component class=\"javax.swing.JButton\" name=\"jButtonSave\">");
	r.addElement("          <Properties>");
	r.addElement("            <Property name=\"text\" type=\"java.lang.String\" value=\"Save\"/>");
	r.addElement("          </Properties>");
	r.addElement("          <Events>");
	r.addElement("            <EventHandler event=\"actionPerformed\" listener=\"java.awt.event.ActionListener\" parameters=\"java.awt.event.ActionEvent\" handler=\"jButtonSaveActionPerformed\"/>");
	r.addElement("          </Events>");
	r.addElement("        </Component>");
	r.addElement("        <Component class=\"javax.swing.JButton\" name=\"jButtonSaveAsNew\">");
	r.addElement("          <Properties>");
	r.addElement("            <Property name=\"text\" type=\"java.lang.String\" value=\"Save as new\"/>");
	r.addElement("          </Properties>");
	r.addElement("          <Events>");
	r.addElement("            <EventHandler event=\"actionPerformed\" listener=\"java.awt.event.ActionListener\" parameters=\"java.awt.event.ActionEvent\" handler=\"jButtonSaveAsNewActionPerformed\"/>");
	r.addElement("          </Events>");
	r.addElement("        </Component>");
	r.addElement("        <Component class=\"javax.swing.JButton\" name=\"jButtonDelete\">");
	r.addElement("          <Properties>");
	r.addElement("            <Property name=\"text\" type=\"java.lang.String\" value=\"Delete\"/>");
	r.addElement("          </Properties>");
	r.addElement("          <Events>");
	r.addElement("            <EventHandler event=\"actionPerformed\" listener=\"java.awt.event.ActionListener\" parameters=\"java.awt.event.ActionEvent\" handler=\"jButtonDeleteActionPerformed\"/>");
	r.addElement("          </Events>");
	r.addElement("        </Component>");
	r.addElement("      </SubComponents>");
	r.addElement("    </Container>");
	r.addElement("    <Container class=\"javax.swing.JPanel\" name=\"jPanel2\">");
	r.addElement("");
	r.addElement("      <Layout>");
	r.addElement("        <DimensionLayout dim=\"0\">");
	r.addElement("          <Group type=\"103\" groupAlignment=\"0\" attributes=\"0\">");
	r.addElement("              <EmptySpace min=\"0\" pref=\"531\" max=\"32767\" attributes=\"0\"/>");
	r.addElement("          </Group>");
	r.addElement("        </DimensionLayout>");
	r.addElement("        <DimensionLayout dim=\"1\">");
	r.addElement("          <Group type=\"103\" groupAlignment=\"0\" attributes=\"0\">");
	r.addElement("              <EmptySpace min=\"0\" pref=\"215\" max=\"32767\" attributes=\"0\"/>");
	r.addElement("          </Group>");
	r.addElement("        </DimensionLayout>");
	r.addElement("      </Layout>");
	r.addElement("    </Container>");
	r.addElement("  </SubComponents>");
	r.addElement("</Form>");
	return r;
    }

}
