/*
 * OpenProdoc
 * 
 * See the help doc files distributed with
 * this work for additional information regarding copyright ownership.
 * Joaquin Hierro licenses this file to You under:
 * 
 * License GNU Affero GPL v3 http://www.gnu.org/licenses/agpl.html
 * 
 * you may not use this file except in compliance with the License.  
 * Unless agreed to in writing, software is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * author: Joaquin Hierro      2011
 * 
 */

/*
 * MantUsers.java
 *
 * Created on 17-feb-2010, 21:16:33
 */

package prodocswing.forms;

import java.util.Date;
import java.util.Vector;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import prodoc.Attribute;
import prodoc.Cursor;
import prodoc.DriverGeneric;
import prodoc.PDException;
import prodoc.PDExceptionFunc;
import prodoc.PDLog;
import prodoc.PDObjDefs;
import prodoc.PDTasksCron;
import prodoc.PDTasksDef;
import prodoc.PDTasksExec;
import prodoc.Record;

/**
 *
 * @author jhierrot
 */
public class MantTaskCron extends javax.swing.JDialog
{
private Record CronTask;
private boolean Cancel;

/** Creates new form MantUsers
 * @param parent 
 * @param modal
 */
public MantTaskCron(java.awt.Frame parent, boolean modal)
{
super(parent, modal);
initComponents();
}

/** 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()
    {

        LabelOperation = new javax.swing.JLabel();
        TaskNameLabel = new javax.swing.JLabel();
        TaskNameTextField = new javax.swing.JTextField();
        DescriptionLabel = new javax.swing.JLabel();
        DescriptionTextField = new javax.swing.JTextField();
        CategoryLabel = new javax.swing.JLabel();
        CategoryTextField = new javax.swing.JTextField();
        TypeLabel = new javax.swing.JLabel();
        TypeComboBox = new javax.swing.JComboBox();
        ObjTypeLabel = new javax.swing.JLabel();
        ObjTypeComboBox = new javax.swing.JComboBox();
        FilterLabel = new javax.swing.JLabel();
        FilterTextField = new javax.swing.JTextField();
        ParamLabel = new javax.swing.JLabel();
        ParamTextField = new javax.swing.JTextField();
        ParamLabel2 = new javax.swing.JLabel();
        ParamTextField2 = new javax.swing.JTextField();
        ParamLabel3 = new javax.swing.JLabel();
        ParamTextField3 = new javax.swing.JTextField();
        ParamLabel4 = new javax.swing.JLabel();
        ParamTextField4 = new javax.swing.JTextField();
        EndDateLabel = new javax.swing.JLabel();
        EndDateTextField = new javax.swing.JFormattedTextField();
        AddMonthLabel = new javax.swing.JLabel();
        AddMonthTextField = new javax.swing.JFormattedTextField();
        AddDayLabel = new javax.swing.JLabel();
        AddDayTextField = new javax.swing.JFormattedTextField();
        AddHourLabel = new javax.swing.JLabel();
        AddHourTextField = new javax.swing.JFormattedTextField();
        AddMinLabel = new javax.swing.JLabel();
        AddMinTextField = new javax.swing.JFormattedTextField();
        ActiveLabel = new javax.swing.JLabel();
        ActiveCB = new javax.swing.JCheckBox();
        TransactLabel = new javax.swing.JLabel();
        TransactCB = new javax.swing.JCheckBox();
        ButtonEdit = new javax.swing.JButton();
        ButtonTest = new javax.swing.JButton();
        ButtonRun = new javax.swing.JButton();
        ButtonAcept = new javax.swing.JButton();
        ButtonCancel = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle(MainWin.TT("Programed_Task_Maintenance"));
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter()
        {
            public void windowClosing(java.awt.event.WindowEvent evt)
            {
                formWindowClosing(evt);
            }
        });

        LabelOperation.setFont(new java.awt.Font("DejaVu Sans", 1, 14)); // NOI18N
        LabelOperation.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        LabelOperation.setText("jLabel1");

        TaskNameLabel.setFont(MainWin.getFontDialog());
        TaskNameLabel.setText("jLabel1");

        TaskNameTextField.setFont(MainWin.getFontDialog());

        DescriptionLabel.setFont(MainWin.getFontDialog());
        DescriptionLabel.setText("jLabel1");

        DescriptionTextField.setFont(MainWin.getFontDialog());

        CategoryLabel.setFont(MainWin.getFontDialog());
        CategoryLabel.setText("jLabel1");

        CategoryTextField.setFont(MainWin.getFontDialog());

        TypeLabel.setFont(MainWin.getFontDialog());
        TypeLabel.setText("jLabel1");

        TypeComboBox.setFont(MainWin.getFontDialog());
        TypeComboBox.setModel(getListTypeTask());
        TypeComboBox.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                TypeComboBoxActionPerformed(evt);
            }
        });

        ObjTypeLabel.setFont(MainWin.getFontDialog());
        ObjTypeLabel.setText("jLabel1");

        ObjTypeComboBox.setFont(MainWin.getFontDialog());
        ObjTypeComboBox.setModel(getListObjFold());
        ObjTypeComboBox.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ObjTypeComboBoxActionPerformed(evt);
            }
        });

        FilterLabel.setFont(MainWin.getFontDialog());
        FilterLabel.setText("jLabel1");

        FilterTextField.setFont(MainWin.getFontDialog());

        ParamLabel.setFont(MainWin.getFontDialog());
        ParamLabel.setText("jLabel1");

        ParamTextField.setFont(MainWin.getFontDialog());

        ParamLabel2.setFont(MainWin.getFontDialog());
        ParamLabel2.setText("jLabel1");

        ParamTextField2.setFont(MainWin.getFontDialog());

        ParamLabel3.setFont(MainWin.getFontDialog());
        ParamLabel3.setText("jLabel1");

        ParamTextField3.setFont(MainWin.getFontDialog());

        ParamLabel4.setFont(MainWin.getFontDialog());
        ParamLabel4.setText("jLabel1");

        ParamTextField4.setFont(MainWin.getFontDialog());

        EndDateLabel.setFont(MainWin.getFontDialog());
        EndDateLabel.setText("jLabel1");

        EndDateTextField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("d/MM/yyyy"))));
        EndDateTextField.setFont(MainWin.getFontDialog());

        AddMonthLabel.setFont(MainWin.getFontDialog());
        AddMonthLabel.setText("jLabel1");

        AddMonthTextField.setFont(MainWin.getFontDialog());

        AddDayLabel.setFont(MainWin.getFontDialog());
        AddDayLabel.setText("jLabel1");

        AddDayTextField.setFont(MainWin.getFontDialog());

        AddHourLabel.setFont(MainWin.getFontDialog());
        AddHourLabel.setText("jLabel1");

        AddHourTextField.setFont(MainWin.getFontDialog());

        AddMinLabel.setFont(MainWin.getFontDialog());
        AddMinLabel.setText("jLabel1");

        AddMinTextField.setFont(MainWin.getFontDialog());

        ActiveLabel.setFont(MainWin.getFontDialog());
        ActiveLabel.setText("jLabel1");

        ActiveCB.setBorder(null);

        TransactLabel.setFont(MainWin.getFontDialog());
        TransactLabel.setText("jLabel1");

        TransactCB.setBorder(null);

        ButtonEdit.setFont(MainWin.getFontDialog());
        ButtonEdit.setText("Edit");
        ButtonEdit.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ButtonEditActionPerformed(evt);
            }
        });

        ButtonTest.setFont(MainWin.getFontDialog());
        ButtonTest.setText("Test");
        ButtonTest.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ButtonTestActionPerformed(evt);
            }
        });

        ButtonRun.setFont(MainWin.getFontDialog());
        ButtonRun.setText("Run");
        ButtonRun.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ButtonRunActionPerformed(evt);
            }
        });

        ButtonAcept.setFont(MainWin.getFontDialog());
        ButtonAcept.setText(MainWin.TT("Ok"));
        ButtonAcept.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ButtonAceptActionPerformed(evt);
            }
        });

        ButtonCancel.setFont(MainWin.getFontDialog());
        ButtonCancel.setText(MainWin.TT("Cancel"));
        ButtonCancel.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ButtonCancelActionPerformed(evt);
            }
        });

        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(12, 12, 12)
                .addComponent(LabelOperation, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(12, 12, 12))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(ParamLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(TransactLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(ActiveLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(AddMinLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addComponent(AddHourLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(AddDayLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(EndDateLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(CategoryLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
                        .addComponent(TaskNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
                        .addComponent(TypeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
                        .addComponent(DescriptionLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
                        .addComponent(FilterLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
                        .addComponent(ObjTypeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
                        .addComponent(ParamLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(ParamLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(ParamLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(AddMonthLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(ParamTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 326, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ParamTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 326, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(EndDateTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 318, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(TaskNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(AddMonthTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(DescriptionTextField)
                    .addComponent(AddDayTextField)
                    .addComponent(CategoryTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(TypeComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(ObjTypeComboBox, 0, 326, Short.MAX_VALUE)
                    .addComponent(FilterTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 326, Short.MAX_VALUE)
                    .addComponent(ParamTextField)
                    .addComponent(ParamTextField2)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(AddHourTextField)
                            .addComponent(AddMinTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 62, Short.MAX_VALUE)
                            .addComponent(ActiveCB)
                            .addComponent(TransactCB))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(ButtonAcept)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(ButtonCancel))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(ButtonEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(ButtonTest, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(ButtonRun, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(25, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {DescriptionTextField, EndDateTextField, FilterTextField, ObjTypeComboBox, ParamTextField, ParamTextField2, ParamTextField3, ParamTextField4, TypeComboBox});

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {ActiveLabel, AddDayLabel, AddHourLabel, AddMinLabel, AddMonthLabel, CategoryLabel, DescriptionLabel, EndDateLabel, FilterLabel, ObjTypeLabel, ParamLabel, TaskNameLabel, TransactLabel, TypeLabel});

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {AddDayTextField, AddHourTextField, AddMinTextField, AddMonthTextField});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(LabelOperation)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(TaskNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(TaskNameLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(DescriptionTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(DescriptionLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(CategoryTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(CategoryLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(TypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(TypeLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ObjTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ObjTypeLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(FilterTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(FilterLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ParamTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ParamLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ParamLabel2)
                    .addComponent(ParamTextField2, 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(ParamLabel3)
                    .addComponent(ParamTextField3, 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(ParamLabel4)
                    .addComponent(ParamTextField4, 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(EndDateLabel)
                    .addComponent(EndDateTextField, 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(AddMonthLabel)
                    .addComponent(AddMonthTextField, 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(AddDayLabel)
                    .addComponent(AddDayTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(7, 7, 7)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(AddHourTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(AddHourLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(AddMinLabel)
                            .addComponent(AddMinTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(8, 8, 8)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(ActiveLabel)
                            .addComponent(ActiveCB))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(TransactLabel)
                            .addComponent(TransactCB)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(ButtonTest)
                            .addComponent(ButtonEdit)
                            .addComponent(ButtonRun))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(ButtonCancel)
                            .addComponent(ButtonAcept))))
                .addContainerGap(22, Short.MAX_VALUE))
        );

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

    private void ButtonCancelActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ButtonCancelActionPerformed
    {//GEN-HEADEREND:event_ButtonCancelActionPerformed
Cancel=true;
this.dispose();
    }//GEN-LAST:event_ButtonCancelActionPerformed

    private void ButtonAceptActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ButtonAceptActionPerformed
    {//GEN-HEADEREND:event_ButtonAceptActionPerformed
try {
Attribute Attr = CronTask.getAttr(PDTasksCron.fNAME);
Attr.setValue(TaskNameTextField.getText());
Attr = CronTask.getAttr(PDTasksCron.fCATEGORY);
Attr.setValue(CategoryTextField.getText());
Attr = CronTask.getAttr(PDTasksCron.fDESCRIPTION);
Attr.setValue(DescriptionTextField.getText());
Attr = CronTask.getAttr(PDTasksCron.fTYPE);
Attr.setValue(TypeComboBox.getSelectedIndex());
Attr = CronTask.getAttr(PDTasksCron.fOBJTYPE);
Attr.setValue(ObjTypeComboBox.getSelectedItem());
Attr = CronTask.getAttr(PDTasksCron.fFILTER);
Attr.setValue(FilterTextField.getText());
Attr = CronTask.getAttr(PDTasksCron.fPARAM);
Attr.setValue(ParamTextField.getText());
Attr = CronTask.getAttr(PDTasksCron.fPARAM2);
Attr.setValue(ParamTextField2.getText());
Attr = CronTask.getAttr(PDTasksCron.fPARAM3);
Attr.setValue(ParamTextField3.getText());
Attr = CronTask.getAttr(PDTasksCron.fPARAM4);
Attr.setValue(ParamTextField4.getText());
Attr = CronTask.getAttr(PDTasksCron.fNEXTDATE);
Attr.setValue(EndDateTextField.getValue());
Attr = CronTask.getAttr(PDTasksCron.fADDMONTH);
Attr.setValue(AddMonthTextField.getValue());
Attr = CronTask.getAttr(PDTasksCron.fADDDAYS);
Attr.setValue(AddDayTextField.getValue());
Attr = CronTask.getAttr(PDTasksCron.fADDHOURS);
Attr.setValue(AddHourTextField.getValue());
Attr = CronTask.getAttr(PDTasksCron.fADDMINS);
Attr.setValue(AddMinTextField.getValue());
Attr = CronTask.getAttr(PDTasksCron.fACTIVE);
Attr.setValue(ActiveCB.isSelected());
Attr = CronTask.getAttr(PDTasksCron.fTRANSACT);
Attr.setValue(TransactCB.isSelected());
Cancel = false;
this.dispose();
} catch (PDException ex)
    {
    MainWin.Message(MainWin.DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_ButtonAceptActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt)//GEN-FIRST:event_formWindowClosing
    {//GEN-HEADEREND:event_formWindowClosing
Cancel=true;
    }//GEN-LAST:event_formWindowClosing

    private void ObjTypeComboBoxActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ObjTypeComboBoxActionPerformed
    {//GEN-HEADEREND:event_ObjTypeComboBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ObjTypeComboBoxActionPerformed

    private void ButtonTestActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ButtonTestActionPerformed
    {//GEN-HEADEREND:event_ButtonTestActionPerformed
try {
setCursor(MainWin.WaitCur);    
ListTaskRes LMT = new ListTaskRes(this, true);
LMT.setLocationRelativeTo(null);
if (TypeComboBox.getSelectedIndex()==PDTasksDef.fTASK_DELETE_OLD_FOLD 
   || TypeComboBox.getSelectedIndex()==PDTasksDef.fTASK_IMPORT
   || TypeComboBox.getSelectedIndex()==PDTasksDef.fTASK_EXPORT
   || TypeComboBox.getSelectedIndex()==PDTasksDef.fTASK_FOLDSREPORT)
    LMT.setFoldType((String) ObjTypeComboBox.getSelectedItem());
else
    LMT.setDocType((String) ObjTypeComboBox.getSelectedItem());
PDTasksExec TC=new PDTasksExec(MainWin.getSession());
TC.setObjType((String) ObjTypeComboBox.getSelectedItem());
TC.setObjFilter(FilterTextField.getText());
TC.setParam(ParamTextField.getText());
TC.setParam2(ParamTextField2.getText());
TC.setParam3(ParamTextField3.getText());
TC.setParam4(ParamTextField4.getText());
TC.setNextDate((Date)EndDateTextField.getValue());
TC.setType(TypeComboBox.getSelectedIndex());
Cursor CursorId=TC.GenCur();
LMT.SetCursor(CursorId);
setCursor(MainWin.DefCur); 
MainWin.getSession().CloseCursor(CursorId);
LMT.setVisible(true);
} catch (Exception ex)
    {
    setCursor(MainWin.DefCur);    
    MainWin.Message(MainWin.DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_ButtonTestActionPerformed

    private void ButtonEditActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ButtonEditActionPerformed
    {//GEN-HEADEREND:event_ButtonEditActionPerformed
try {
TCBase LU=null;    
switch (TypeComboBox.getSelectedIndex())
{
    case PDTasksDef.fTASK_DELETE_OLD_FOLD: LU = new TCDelOldFold(this, true);  
        break;
    case PDTasksDef.fTASK_DELETE_OLD_DOC: LU = new TCDelOldDoc(this, true);
        break;
    case PDTasksDef.fTASK_PURGEDOC: LU = new TCPurgeOldDoc(this, true);;
        break;
    case PDTasksDef.fTASK_EXPORT: LU = new TCExportNewFold(this, true);
        break;  
    case PDTasksDef.fTASK_IMPORT: LU = new TCImportFold(this, true);
        break;
    case PDTasksDef.fTASK_DOCSREPORT: LU = new TCDocsReport(this, true);
        break;
    case PDTasksDef.fTASK_FOLDSREPORT: LU = new TCFoldsReport(this, true);
        break;
    case PDTasksDef.fTASK_LOCALSYNC: LU = new TCFoldsLocalSync(this, true);
        break;
    default: PDExceptionFunc.GenPDException("Unexpected_Task", "");
        break;
}
LU.setParam(ParamTextField.getText());
LU.setParam2(ParamTextField2.getText());
LU.setParam3(ParamTextField3.getText());
LU.setParam4(ParamTextField4.getText());
LU.setLocationRelativeTo(null);
LU.setVisible(true);
if (!LU.isCancel())
    {
    ParamTextField.setText(LU.getParam());
    ParamTextField2.setText(LU.getParam2());
    ParamTextField3.setText(LU.getParam3());
    ParamTextField4.setText(LU.getParam4());
    }
LU.dispose();
} catch (Exception ex)
    {
    MainWin.Message(MainWin.DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_ButtonEditActionPerformed

    private void ButtonRunActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ButtonRunActionPerformed
    {//GEN-HEADEREND:event_ButtonRunActionPerformed
try {
if (!MainWin.MessageQuestion(MainWin.DrvTT("Do_you_really_want_to_execute_the_task")+"? ("
            +MainWin.DrvTT("Beware_that_several_elements_can_be_altered_or_deleted")+")"))
    return;
setCursor(MainWin.WaitCur);    
PDTasksExec TC=new PDTasksExec(MainWin.getSession());
TC.setName(TaskNameTextField.getText());
TC.setDescription(this.DescriptionTextField.getText());
TC.setObjType((String) ObjTypeComboBox.getSelectedItem());
TC.setObjFilter(FilterTextField.getText());
TC.setParam(ParamTextField.getText());
TC.setParam2(ParamTextField2.getText());
TC.setParam3(ParamTextField3.getText());
TC.setParam4(ParamTextField4.getText());
TC.setNextDate((Date)EndDateTextField.getValue());
TC.setType(TypeComboBox.getSelectedIndex());
TC.Execute();
setCursor(MainWin.DefCur);    
MainWin.Message(MainWin.DrvTT("Task_ended"));
} catch (Exception ex)
    {
    setCursor(MainWin.DefCur);    
    MainWin.Message(MainWin.DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_ButtonRunActionPerformed

    private void TypeComboBoxActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_TypeComboBoxActionPerformed
    {//GEN-HEADEREND:event_TypeComboBoxActionPerformed
ButtonTest.setEnabled(true);
switch (TypeComboBox.getSelectedIndex())
    {
    case PDTasksDef.fTASK_DELETE_OLD_FOLD: ObjTypeComboBox.setModel(getListObjFold());  
        break;
    case PDTasksDef.fTASK_DELETE_OLD_DOC: ObjTypeComboBox.setModel(getListObjDoc());
        break;
    case PDTasksDef.fTASK_PURGEDOC: ObjTypeComboBox.setModel(getListObjDoc());
        break;
    case PDTasksDef.fTASK_EXPORT: ObjTypeComboBox.setModel(getListObjFold());  
        break;
    case PDTasksDef.fTASK_IMPORT: ObjTypeComboBox.setModel(getListObjFold());  
        ButtonTest.setEnabled(false);
        break;
    case PDTasksDef.fTASK_LOCALSYNC: ObjTypeComboBox.setModel(getListObjFold());  
        ButtonTest.setEnabled(false);
        break;
    case PDTasksDef.fTASK_DOCSREPORT: ObjTypeComboBox.setModel(getListObjDoc());
        break;
    case PDTasksDef.fTASK_FOLDSREPORT: ObjTypeComboBox.setModel(getListObjFold());
        break;
    default: ObjTypeComboBox.setModel(getListObjEmpty());    
    }
    }//GEN-LAST:event_TypeComboBoxActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox ActiveCB;
    private javax.swing.JLabel ActiveLabel;
    private javax.swing.JLabel AddDayLabel;
    private javax.swing.JFormattedTextField AddDayTextField;
    private javax.swing.JLabel AddHourLabel;
    private javax.swing.JFormattedTextField AddHourTextField;
    private javax.swing.JLabel AddMinLabel;
    private javax.swing.JFormattedTextField AddMinTextField;
    private javax.swing.JLabel AddMonthLabel;
    private javax.swing.JFormattedTextField AddMonthTextField;
    private javax.swing.JButton ButtonAcept;
    private javax.swing.JButton ButtonCancel;
    private javax.swing.JButton ButtonEdit;
    private javax.swing.JButton ButtonRun;
    private javax.swing.JButton ButtonTest;
    private javax.swing.JLabel CategoryLabel;
    private javax.swing.JTextField CategoryTextField;
    private javax.swing.JLabel DescriptionLabel;
    private javax.swing.JTextField DescriptionTextField;
    private javax.swing.JLabel EndDateLabel;
    private javax.swing.JFormattedTextField EndDateTextField;
    private javax.swing.JLabel FilterLabel;
    private javax.swing.JTextField FilterTextField;
    private javax.swing.JLabel LabelOperation;
    private javax.swing.JComboBox ObjTypeComboBox;
    private javax.swing.JLabel ObjTypeLabel;
    private javax.swing.JLabel ParamLabel;
    private javax.swing.JLabel ParamLabel2;
    private javax.swing.JLabel ParamLabel3;
    private javax.swing.JLabel ParamLabel4;
    private javax.swing.JTextField ParamTextField;
    private javax.swing.JTextField ParamTextField2;
    private javax.swing.JTextField ParamTextField3;
    private javax.swing.JTextField ParamTextField4;
    private javax.swing.JLabel TaskNameLabel;
    private javax.swing.JTextField TaskNameTextField;
    private javax.swing.JCheckBox TransactCB;
    private javax.swing.JLabel TransactLabel;
    private javax.swing.JComboBox TypeComboBox;
    private javax.swing.JLabel TypeLabel;
    // End of variables declaration//GEN-END:variables

/**
*
*/
public void AddMode()
{
LabelOperation.setText(MainWin.TT("Add_Task"));
EndDateTextField.setValue(new Date());
}
//----------------------------------------------------------------
/**
*
*/
public void DelMode()
{
LabelOperation.setText(MainWin.TT("Delete_Task"));
TaskNameTextField.setEditable(false);
CategoryTextField.setEditable(false);
DescriptionTextField.setEditable(false);
FilterTextField.setEditable(false);
ParamTextField.setEditable(false);
ParamTextField2.setEditable(false);
ParamTextField3.setEditable(false);
ParamTextField4.setEditable(false);
TypeComboBox.setEditable(false);
ObjTypeComboBox.setEditable(false);
EndDateTextField.setEditable(false);
AddMonthTextField.setEditable(false);
AddDayTextField.setEditable(false);
AddHourTextField.setEditable(false);
AddMinTextField.setEditable(false);
ActiveCB.setEnabled(false);
TransactCB.setEnabled(false);

}
//----------------------------------------------------------------
/**
*
*/
public void EditMode()
{
LabelOperation.setText(MainWin.TT("Update_Task"));
TaskNameTextField.setEditable(false);
}
//----------------------------------------------------------------
/**
*
*/
public void CopyMode()
{
LabelOperation.setText(MainWin.TT("Copy_Task"));
TaskNameTextField.setText(TaskNameTextField.getText()+"1");
}
//----------------------------------------------------------------
/**
* @return the User
*/
public Record getRecord()
{
return CronTask;
}
//----------------------------------------------------------------
/**
 * @param pReposit
*/
public void setRecord(Record pReposit)
{
CronTask = pReposit;
Attribute Attr=CronTask.getAttr(PDTasksCron.fNAME); //-------------------------
TaskNameLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    TaskNameTextField.setText((String)Attr.getValue());
TaskNameTextField.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=CronTask.getAttr(PDTasksCron.fCATEGORY);//--------------------------
CategoryLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    CategoryTextField.setText((String)Attr.getValue());
CategoryTextField.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=CronTask.getAttr(PDTasksCron.fDESCRIPTION);//--------------------------
DescriptionLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    DescriptionTextField.setText((String)Attr.getValue());
DescriptionTextField.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=CronTask.getAttr(PDTasksCron.fFILTER); //--------------------------
FilterLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    FilterTextField.setText((String)Attr.getValue());
FilterTextField.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=CronTask.getAttr(PDTasksCron.fPARAM); //--------------------------
ParamLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    ParamTextField.setText((String)Attr.getValue());
ParamTextField.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=CronTask.getAttr(PDTasksCron.fPARAM2); //--------------------------
ParamLabel2.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    ParamTextField2.setText((String)Attr.getValue());
ParamTextField2.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=CronTask.getAttr(PDTasksCron.fPARAM3); //--------------------------
ParamLabel3.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    ParamTextField3.setText((String)Attr.getValue());
ParamTextField3.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=CronTask.getAttr(PDTasksCron.fPARAM4); //--------------------------
ParamLabel4.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    ParamTextField4.setText((String)Attr.getValue());
ParamTextField4.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=CronTask.getAttr(PDTasksCron.fTYPE); //--------------------------
TypeLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    TypeComboBox.setSelectedIndex((Integer)Attr.getValue());
TypeComboBox.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=CronTask.getAttr(PDTasksCron.fOBJTYPE); //--------------------------
ObjTypeLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    ObjTypeComboBox.setSelectedItem((String)Attr.getValue());
ObjTypeComboBox.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=CronTask.getAttr(PDTasksCron.fNEXTDATE); //--------------------------
EndDateLabel.setText(MainWin.DrvTT(Attr.getUserName()));
try {
EndDateTextField.setFormatterFactory(MainWin.getFormFacTS());
} catch(Exception e)
    {
    PDLog.Error(e.getLocalizedMessage());
    }
if (Attr.getValue()!=null)
    EndDateTextField.setValue(Attr.getValue());
else
    EndDateTextField.setValue(new Date());
EndDateTextField.setToolTipText(MainWin.DrvTT(Attr.getDescription())  +"("+MainWin.getFormatTS()+")");
Attr=CronTask.getAttr(PDTasksCron.fADDMONTH); //--------------------------
AddMonthLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    AddMonthTextField.setValue((Integer)Attr.getValue());
else
    AddMonthTextField.setValue((Integer)0);
AddMonthTextField.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=CronTask.getAttr(PDTasksCron.fADDDAYS); //--------------------------
AddDayLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    AddDayTextField.setValue((Integer)Attr.getValue());
else
    AddDayTextField.setValue((Integer)0);
AddDayTextField.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=CronTask.getAttr(PDTasksCron.fADDHOURS); //--------------------------
AddHourLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    AddHourTextField.setValue((Integer)Attr.getValue());
else
    AddHourTextField.setValue((Integer)0);    
AddHourTextField.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=CronTask.getAttr(PDTasksCron.fADDMINS); //--------------------------
AddMinLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    AddMinTextField.setValue((Integer)Attr.getValue());
else
    AddMinTextField.setValue((Integer)0);
AddMinTextField.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=CronTask.getAttr(PDTasksCron.fACTIVE); //--------------------------
ActiveLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    ActiveCB.setSelected((Boolean)Attr.getValue());
ActiveCB.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=CronTask.getAttr(PDTasksCron.fTRANSACT); //--------------------------
TransactLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    TransactCB.setSelected((Boolean)Attr.getValue());
TransactCB.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
}
//----------------------------------------------------------------
/**
* @return the Cancel
*/
public boolean isCancel()
{
return Cancel;
}
//----------------------------------------------------------------

private ComboBoxModel getListTypeTask()
{
return(new DefaultComboBoxModel(PDTasksDef.getListTypeTask()));
}
//----------------------------------------------------------------
private ComboBoxModel getListObjDoc()
{
Vector VObjects=new Vector();
try {
DriverGeneric Session=MainWin.getSession();
PDObjDefs Obj = new PDObjDefs(Session);
Cursor CursorId = Obj.getListDocs();
Record Res=Session.NextRec(CursorId);
while (Res!=null)
    {
    Attribute Attr=Res.getAttr(PDObjDefs.fNAME);
    VObjects.add(Attr.getValue());
    Res=Session.NextRec(CursorId);
    }
Session.CloseCursor(CursorId);
} catch (PDException ex)
    {
    MainWin.Message("Error"+ex.getLocalizedMessage());
    }
return(new DefaultComboBoxModel(VObjects));
}
//----------------------------------------------------------------
private ComboBoxModel getListObjFold()
{
Vector VObjects=new Vector();
try {
DriverGeneric Session=MainWin.getSession();
PDObjDefs Obj = new PDObjDefs(Session);
Cursor CursorId = Obj.getListFold();
Record Res=Session.NextRec(CursorId);
while (Res!=null)
    {
    Attribute Attr=Res.getAttr(PDObjDefs.fNAME);
    VObjects.add(Attr.getValue());
    Res=Session.NextRec(CursorId);
    }
Session.CloseCursor(CursorId);
} catch (PDException ex)
    {
    MainWin.Message("Error"+ex.getLocalizedMessage());
    }
return(new DefaultComboBoxModel(VObjects));
}
//----------------------------------------------------------------
private ComboBoxModel getListObjEmpty()
{
Vector VObjects=new Vector();
return(new DefaultComboBoxModel(VObjects));
}
//----------------------------------------------------------------
}