/*
 * 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.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.PDObjDefs;
import prodoc.PDTasksDefEvent;
import prodoc.Record;

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

/** Creates new form MantUsers
 * @param parent 
 * @param modal
 */
public MantTaskEvents(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();
        EventTypeLabel = new javax.swing.JLabel();
        EventTypeComboBox = new javax.swing.JComboBox();
        EventOrderLabel = new javax.swing.JLabel();
        EventOrderTextField = new javax.swing.JFormattedTextField();
        ActiveLabel = new javax.swing.JLabel();
        ActiveCB = new javax.swing.JCheckBox();
        TransactLabel = new javax.swing.JLabel();
        TransactCB = new javax.swing.JCheckBox();
        ButtonAcept = new javax.swing.JButton();
        ButtonCancel = new javax.swing.JButton();
        ButtonEdit = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle(MainWin.TT("Event_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(getListTypeEventTask());
        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());

        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());

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

        EventTypeComboBox.setFont(MainWin.getFontDialog());
        EventTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "INS", "UPD", "DEL" }));

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

        EventOrderTextField.setFont(MainWin.getFontDialog());

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

        ActiveCB.setBorder(null);

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

        TransactCB.setBorder(null);

        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);
            }
        });

        ButtonEdit.setFont(MainWin.getFontDialog());
        ButtonEdit.setText("Edit");
        ButtonEdit.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ButtonEditActionPerformed(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, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(TransactLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(TransactCB))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(ParamLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ParamTextField))
                    .addGroup(layout.createSequentialGroup()
                        .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))
                        .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(ObjTypeComboBox, 0, 326, Short.MAX_VALUE)
                            .addComponent(DescriptionTextField)
                            .addComponent(TypeComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(FilterTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 326, Short.MAX_VALUE)
                            .addComponent(TaskNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(CategoryTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ParamTextField2)
                            .addComponent(ParamTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 326, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(EventTypeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(EventOrderLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ActiveLabel, 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)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(ActiveCB)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(ButtonEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(EventOrderTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addComponent(EventTypeComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(ButtonAcept)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ButtonCancel)))
                .addContainerGap(25, Short.MAX_VALUE))
        );

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

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

        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(EventTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(EventTypeLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(EventOrderTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(EventOrderLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(ActiveCB)
                            .addComponent(ActiveLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(TransactCB)
                            .addComponent(TransactLabel)))
                    .addComponent(ButtonEdit))
                .addGap(26, 26, 26)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ButtonCancel)
                    .addComponent(ButtonAcept))
                .addContainerGap(20, 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 = EventTask.getAttr(PDTasksDefEvent.fNAME);
Attr.setValue(TaskNameTextField.getText());
Attr = EventTask.getAttr(PDTasksDefEvent.fCATEGORY);
Attr.setValue(CategoryTextField.getText());
Attr = EventTask.getAttr(PDTasksDefEvent.fDESCRIPTION);
Attr.setValue(DescriptionTextField.getText());
Attr = EventTask.getAttr(PDTasksDefEvent.fTYPE);
Attr.setValue(TypeComboBox.getSelectedIndex()+PDTasksDefEvent.STARTNUM);
Attr = EventTask.getAttr(PDTasksDefEvent.fOBJTYPE);
Attr.setValue(ObjTypeComboBox.getSelectedItem());
Attr = EventTask.getAttr(PDTasksDefEvent.fFILTER);
Attr.setValue(FilterTextField.getText());
Attr = EventTask.getAttr(PDTasksDefEvent.fPARAM);
Attr.setValue(ParamTextField.getText());
Attr = EventTask.getAttr(PDTasksDefEvent.fPARAM2);
Attr.setValue(ParamTextField2.getText());
Attr = EventTask.getAttr(PDTasksDefEvent.fPARAM3);
Attr.setValue(ParamTextField3.getText());
Attr = EventTask.getAttr(PDTasksDefEvent.fPARAM4);
Attr.setValue(ParamTextField4.getText());
Attr = EventTask.getAttr(PDTasksDefEvent.fEVENTYPE);
Attr.setValue((String)EventTypeComboBox.getSelectedItem());
Attr = EventTask.getAttr(PDTasksDefEvent.fEVENORDER);
Attr.setValue(Integer.parseInt(EventOrderTextField.getText()));
Attr = EventTask.getAttr(PDTasksDefEvent.fACTIVE);
Attr.setValue(ActiveCB.isSelected());
Attr = EventTask.getAttr(PDTasksDefEvent.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 ButtonEditActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ButtonEditActionPerformed
    {//GEN-HEADEREND:event_ButtonEditActionPerformed
try {
TCBase LU=null;
switch (TypeComboBox.getSelectedIndex()+ PDTasksDefEvent.STARTNUM)
    {
    case PDTasksDefEvent.fTASKEVENT_UPDATE_DOC : LU = new TCEUpdate(this, true);
    break;
    case PDTasksDefEvent.fTASKEVENT_UPDATE_FOLD : LU = new TCEUpdate(this, true);
    break;
    case PDTasksDefEvent.fTASKEVENT_COPY_DOC: LU = new TCECopy(this, true);
    break;
    case PDTasksDefEvent.fTASKEVENT_COPY_FOLD: LU = new TCECopy(this, true);
    break;
    case PDTasksDefEvent.fTASKEVENT_EXPORT_DOC: LU = new TCExportEventFold(this, true);;
    break;
    case PDTasksDefEvent.fTASKEVENT_EXPORT_FOLD: LU = new TCExportEventFold(this, true);;
    break;
    case PDTasksDefEvent.fTASKEVENT_CONVERT_DOC: LU = new TCEConvert(this, true);
    break;
    case PDTasksDefEvent.fTASKEVENT_FTINDEX_DOC: 
    case PDTasksDefEvent.fTASKEVENT_FTUPDA_DOC:
    case PDTasksDefEvent.fTASKEVENT_FTDEL_DOC: LU = new TCEFT(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 (PDExceptionFunc ex)
    {
    MainWin.Message(MainWin.DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_ButtonEditActionPerformed

    private void TypeComboBoxActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_TypeComboBoxActionPerformed
    {//GEN-HEADEREND:event_TypeComboBoxActionPerformed
int T=TypeComboBox.getSelectedIndex()+PDTasksDefEvent.STARTNUM;
if (T==PDTasksDefEvent.fTASKEVENT_UPDATE_FOLD || T==PDTasksDefEvent.fTASKEVENT_COPY_FOLD 
    || T==PDTasksDefEvent.fTASKEVENT_EXPORT_FOLD)
    ObjTypeComboBox.setModel(getListObjFold());
else
    ObjTypeComboBox.setModel(getListObjDoc());
    }//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.JButton ButtonAcept;
    private javax.swing.JButton ButtonCancel;
    private javax.swing.JButton ButtonEdit;
    private javax.swing.JLabel CategoryLabel;
    private javax.swing.JTextField CategoryTextField;
    private javax.swing.JLabel DescriptionLabel;
    private javax.swing.JTextField DescriptionTextField;
    private javax.swing.JLabel EventOrderLabel;
    private javax.swing.JFormattedTextField EventOrderTextField;
    private javax.swing.JComboBox EventTypeComboBox;
    private javax.swing.JLabel EventTypeLabel;
    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"));
}
//----------------------------------------------------------------
/**
*
*/
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);
EventTypeComboBox.setEditable(false);
EventOrderTextField.setEditable(false);
ActiveCB.setEnabled(false);
TransactCB.setEnabled(false);
}
//----------------------------------------------------------------
/**
*
*/
public void EditMode()
{
TaskNameTextField.setEditable(false);
LabelOperation.setText(MainWin.TT("Update_Task"));
}
//----------------------------------------------------------------
/**
*
*/
public void CopyMode()
{
LabelOperation.setText(MainWin.TT("Copy_Task"));
TaskNameTextField.setText(TaskNameTextField.getText()+"1");
}
//----------------------------------------------------------------
/**
* @return the User
*/
public Record getRecord()
{
return EventTask;
}
//----------------------------------------------------------------
/**
 * @param pReposit
*/
public void setRecord(Record pReposit)
{
EventTask = pReposit;
Attribute Attr=EventTask.getAttr(PDTasksDefEvent.fNAME); //-------------------------
TaskNameLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    TaskNameTextField.setText((String)Attr.getValue());
TaskNameTextField.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=EventTask.getAttr(PDTasksDefEvent.fCATEGORY);//--------------------------
CategoryLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    CategoryTextField.setText((String)Attr.getValue());
CategoryTextField.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=EventTask.getAttr(PDTasksDefEvent.fDESCRIPTION);//--------------------------
DescriptionLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    DescriptionTextField.setText((String)Attr.getValue());
DescriptionTextField.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=EventTask.getAttr(PDTasksDefEvent.fFILTER); //--------------------------
FilterLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    FilterTextField.setText((String)Attr.getValue());
FilterTextField.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=EventTask.getAttr(PDTasksDefEvent.fPARAM); //--------------------------
ParamLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    ParamTextField.setText((String)Attr.getValue());
ParamTextField.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=EventTask.getAttr(PDTasksDefEvent.fPARAM2); //--------------------------
ParamLabel2.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    ParamTextField2.setText((String)Attr.getValue());
ParamTextField2.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=EventTask.getAttr(PDTasksDefEvent.fPARAM3); //--------------------------
ParamLabel3.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    ParamTextField3.setText((String)Attr.getValue());
ParamTextField3.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=EventTask.getAttr(PDTasksDefEvent.fPARAM4); //--------------------------
ParamLabel4.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    ParamTextField4.setText((String)Attr.getValue());
ParamTextField4.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=EventTask.getAttr(PDTasksDefEvent.fTYPE); //--------------------------
TypeLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null && (Integer)Attr.getValue()>=PDTasksDefEvent.STARTNUM)
    TypeComboBox.setSelectedIndex((Integer)Attr.getValue()-PDTasksDefEvent.STARTNUM);
TypeComboBox.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=EventTask.getAttr(PDTasksDefEvent.fOBJTYPE); //--------------------------
ObjTypeLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    ObjTypeComboBox.setSelectedItem((String)Attr.getValue());
ObjTypeComboBox.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=EventTask.getAttr(PDTasksDefEvent.fEVENTYPE); //--------------------------
EventTypeLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    EventTypeComboBox.setSelectedItem((String)Attr.getValue());
EventTypeComboBox.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=EventTask.getAttr(PDTasksDefEvent.fEVENORDER); //--------------------------
EventOrderLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    EventOrderTextField.setText(""+Attr.getValue());
EventOrderTextField.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=EventTask.getAttr(PDTasksDefEvent.fACTIVE); //--------------------------
ActiveLabel.setText(MainWin.DrvTT(Attr.getUserName()));
if (Attr.getValue()!=null)
    ActiveCB.setSelected((Boolean)Attr.getValue());
ActiveCB.setToolTipText(MainWin.DrvTT(Attr.getDescription()));
Attr=EventTask.getAttr(PDTasksDefEvent.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 getListTypeEventTask()
{
return(new DefaultComboBoxModel(PDTasksDefEvent.getListTypeEventTask()));
}
//----------------------------------------------------------------
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));
}
//----------------------------------------------------------------
}