/*
 * 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
 * 
 */

/*
 * MainWin.java
 *
 * Created on 29-ene-2010, 0:52:22
 */

package prodocswing.forms;

import java.awt.Font;
import java.awt.Image;
import java.io.File;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.TreeSet;
import java.util.Vector;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.text.DefaultFormatterFactory;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import prodoc.*;
import prodocswing.PDTableModel;
import prodocswing.TreeFolder;

/**
 *
 * @author jhierrot
 */
public class MainWin extends javax.swing.JFrame
{
static private Font MenuFont=null;
static private Font TreeFont=null;
static private Font ListFont=null;
static private Font DialogFont=null;
private static DriverGeneric Session=null;
static private DefaultTreeModel FoldTreeModel=null;
private static SimpleDateFormat formatterTS = null;
private static SimpleDateFormat formatterDate = null;
private static DefaultFormatterFactory formFacTS = null;
private static DefaultFormatterFactory formFacDate = null;
static private String ActFolderId=PDFolders.ROOTFOLDER;
static private PDTableModel DocsContained;
static private int ExpFolds=0;
static private int ExpDocs=0;

    /**
     * @return the ActFolderId
     */
    public static String getActFolderId()
    {
        return ActFolderId;
    }
private PDFolders FoldAct=null;
private static final String List=PDFolders.fACL+"/"+PDFolders.fFOLDTYPE+"/"+PDFolders.fPARENTID+"/"+PDFolders.fPDID+"/"+PDFolders.fTITLE+"/"+PDFolders.fPDAUTOR+"/"+PDFolders.fPDDATE;
private static final HashSet ExecFiles=new HashSet();
static protected java.awt.Cursor DefCur=new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR);
static protected final java.awt.Cursor WaitCur=new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR);
private static String IO_OSFolder=System.getProperty("java.io.tmpdir");

/**
* @return the Session
*/
public static DriverGeneric getSession()
{
return Session;
}

/** Creates new form MainWin */
public MainWin()
{
initComponents();
TreeFolder.setPreferredSize(null);
DocsTable.setAutoCreateRowSorter(true);
DocsTable.setAutoCreateColumnsFromModel(true);
SetMenu();
TreeFolder.setSelectionRow(0);
try {
setTitle(getTitle()+" @"+getSession().getUser().getName()+" ( "+getSession().getUser().getDescription()+" )");
} catch (Exception ex)
    {}
}

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

        jSplitPane1 = new javax.swing.JSplitPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        TreeFolder = new javax.swing.JTree();
        jSplitPane2 = new javax.swing.JSplitPane();
        jScrollPane2 = new javax.swing.JScrollPane();
        SelFolderDesc = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        DocsTable = new javax.swing.JTable();
        menuBar = new javax.swing.JMenuBar();
        FolderMenu = new javax.swing.JMenu();
        AddFold = new javax.swing.JMenuItem();
        DelFold = new javax.swing.JMenuItem();
        ModFold = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JPopupMenu.Separator();
        AddFoldAdvanced = new javax.swing.JMenuItem();
        ModFoldAdvanced = new javax.swing.JMenuItem();
        RefreshFold = new javax.swing.JMenuItem();
        SearchFold = new javax.swing.JMenuItem();
        jSeparator6 = new javax.swing.JPopupMenu.Separator();
        ExportFold = new javax.swing.JMenuItem();
        ImportFold = new javax.swing.JMenuItem();
        ImportExtFold = new javax.swing.JMenuItem();
        ReportsFold = new javax.swing.JMenuItem();
        jSeparator5 = new javax.swing.JPopupMenu.Separator();
        exitMenuItem = new javax.swing.JMenuItem();
        DocMenu = new javax.swing.JMenu();
        AddDoc = new javax.swing.JMenuItem();
        DelDoc = new javax.swing.JMenuItem();
        jSeparator3 = new javax.swing.JPopupMenu.Separator();
        AddDocAdvanced = new javax.swing.JMenuItem();
        ModDocAdvanced = new javax.swing.JMenuItem();
        ViewMetadata = new javax.swing.JMenuItem();
        RefreshDocs = new javax.swing.JMenuItem();
        jSeparator4 = new javax.swing.JPopupMenu.Separator();
        CheckOut = new javax.swing.JMenuItem();
        CheckIn = new javax.swing.JMenuItem();
        CancelCheckout = new javax.swing.JMenuItem();
        ListVersions = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        SearchDocs = new javax.swing.JMenuItem();
        ExportDoc = new javax.swing.JMenuItem();
        ImportDoc = new javax.swing.JMenuItem();
        jSeparator7 = new javax.swing.JPopupMenu.Separator();
        ImportExtRIS = new javax.swing.JMenuItem();
        jSeparator8 = new javax.swing.JPopupMenu.Separator();
        ReportsDoc = new javax.swing.JMenuItem();
        OtherMenu = new javax.swing.JMenu();
        PaperBin = new javax.swing.JMenuItem();
        ChangePass = new javax.swing.JMenuItem();
        Thesaur = new javax.swing.JMenuItem();
        AdminMenu = new javax.swing.JMenu();
        ACLMenuItem = new javax.swing.JMenuItem();
        GroupMenuItem = new javax.swing.JMenuItem();
        UserMenuItem = new javax.swing.JMenuItem();
        RolMenuItem = new javax.swing.JMenuItem();
        MimeTypeMenuItem = new javax.swing.JMenuItem();
        ReposMenuItem = new javax.swing.JMenuItem();
        ObjDefMenuItem = new javax.swing.JMenuItem();
        AuthentMenuItem = new javax.swing.JMenuItem();
        CustomMenuItem = new javax.swing.JMenuItem();
        TaskCronMenuItem = new javax.swing.JMenuItem();
        TaskEvenMenuItem = new javax.swing.JMenuItem();
        TaskExecMenuItem = new javax.swing.JMenuItem();
        TaskEndedMenuItem = new javax.swing.JMenuItem();
        TraceMenuItem = new javax.swing.JMenuItem();
        ImportPackage = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        contentsMenuItem1 = new javax.swing.JMenuItem();
        aboutMenuItem1 = new javax.swing.JMenuItem();
        ReportBugs = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("OpenProdoc "+getVersion());
        setIconImage(getIcon());
        addWindowListener(new java.awt.event.WindowAdapter()
        {
            public void windowClosing(java.awt.event.WindowEvent evt)
            {
                formWindowClosing(evt);
            }
        });

        jSplitPane1.setDividerLocation(180);
        jSplitPane1.setDividerSize(4);

        TreeFolder.setFont(getFontTree());
        TreeFolder.setModel(getTreeModel());
        TreeFolder.setAlignmentX(0.3F);
        TreeFolder.setAutoscrolls(true);
        TreeFolder.setComponentPopupMenu(FolderMenu.getComponentPopupMenu());
        TreeFolder.setMaximumSize(new java.awt.Dimension(400, 76));
        TreeFolder.setMinimumSize(new java.awt.Dimension(200, 60));
        TreeFolder.setPreferredSize(new java.awt.Dimension(200, 76));
        TreeFolder.addTreeExpansionListener(new javax.swing.event.TreeExpansionListener()
        {
            public void treeCollapsed(javax.swing.event.TreeExpansionEvent evt)
            {
            }
            public void treeExpanded(javax.swing.event.TreeExpansionEvent evt)
            {
                TreeFolderTreeExpanded(evt);
            }
        });
        TreeFolder.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener()
        {
            public void valueChanged(javax.swing.event.TreeSelectionEvent evt)
            {
                TreeFolderValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(TreeFolder);

        jSplitPane1.setLeftComponent(jScrollPane1);

        jSplitPane2.setDividerLocation(160);
        jSplitPane2.setDividerSize(4);
        jSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jScrollPane2.setMinimumSize(new java.awt.Dimension(24, 48));

        SelFolderDesc.setFont(getFontMenu());
        SelFolderDesc.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        jScrollPane2.setViewportView(SelFolderDesc);

        jSplitPane2.setTopComponent(jScrollPane2);

        DocsTable.setFont(getFontList());
        DocsTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][]
            {

            },
            new String []
            {

            }
        ));
        DocsTable.addMouseListener(new java.awt.event.MouseAdapter()
        {
            public void mouseClicked(java.awt.event.MouseEvent evt)
            {
                DocsTableMouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(DocsTable);

        jSplitPane2.setRightComponent(jScrollPane3);

        jSplitPane1.setRightComponent(jSplitPane2);

        menuBar.setFont(getFontMenu());

        FolderMenu.setText(TT("Folders"));
        FolderMenu.setFont(getFontMenu());

        AddFold.setFont(getFontMenu());
        AddFold.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/add.png"))); // NOI18N
        AddFold.setText(TT("Add"));
        AddFold.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                AddFoldActionPerformed(evt);
            }
        });
        FolderMenu.add(AddFold);

        DelFold.setFont(getFontMenu());
        DelFold.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/del.png"))); // NOI18N
        DelFold.setText(TT("Delete"));
        DelFold.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                DelFoldActionPerformed(evt);
            }
        });
        FolderMenu.add(DelFold);

        ModFold.setFont(getFontMenu());
        ModFold.setText(TT("Update"));
        ModFold.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ModFoldActionPerformed(evt);
            }
        });
        FolderMenu.add(ModFold);
        FolderMenu.add(jSeparator2);

        AddFoldAdvanced.setFont(getFontMenu());
        AddFoldAdvanced.setText(TT("Extended_Add"));
        AddFoldAdvanced.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                AddFoldAdvancedActionPerformed(evt);
            }
        });
        FolderMenu.add(AddFoldAdvanced);

        ModFoldAdvanced.setFont(getFontMenu());
        ModFoldAdvanced.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/edit.png"))); // NOI18N
        ModFoldAdvanced.setText(TT("Update_Extended"));
        ModFoldAdvanced.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ModFoldAdvancedActionPerformed(evt);
            }
        });
        FolderMenu.add(ModFoldAdvanced);

        RefreshFold.setFont(getFontMenu());
        RefreshFold.setText(TT("Refresh"));
        RefreshFold.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                RefreshFoldActionPerformed(evt);
            }
        });
        FolderMenu.add(RefreshFold);

        SearchFold.setFont(getFontMenu());
        SearchFold.setText(TT("Search_Folders"));
        SearchFold.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                SearchFoldActionPerformed(evt);
            }
        });
        FolderMenu.add(SearchFold);
        FolderMenu.add(jSeparator6);

        ExportFold.setFont(getFontMenu());
        ExportFold.setText(TT("Export_Folders"));
        ExportFold.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ExportFoldActionPerformed(evt);
            }
        });
        FolderMenu.add(ExportFold);

        ImportFold.setFont(getFontMenu());
        ImportFold.setText(TT("Import_Folders"));
        ImportFold.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ImportFoldActionPerformed(evt);
            }
        });
        FolderMenu.add(ImportFold);

        ImportExtFold.setFont(getFontMenu());
        ImportExtFold.setText(TT("Import_Ext_Systems"));
        ImportExtFold.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ImportExtFoldActionPerformed(evt);
            }
        });
        FolderMenu.add(ImportExtFold);

        ReportsFold.setFont(getFontMenu());
        ReportsFold.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/Report.png"))); // NOI18N
        ReportsFold.setText("Reports");
        ReportsFold.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ReportsFoldActionPerformed(evt);
            }
        });
        FolderMenu.add(ReportsFold);
        FolderMenu.add(jSeparator5);

        exitMenuItem.setFont(getFontMenu());
        exitMenuItem.setText(TT("Exit"));
        exitMenuItem.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                exitMenuItemActionPerformed(evt);
            }
        });
        FolderMenu.add(exitMenuItem);

        menuBar.add(FolderMenu);

        DocMenu.setText(TT("Documents"));
        DocMenu.setFont(getFontMenu());

        AddDoc.setFont(getFontMenu());
        AddDoc.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/add.png"))); // NOI18N
        AddDoc.setText(TT("Add"));
        AddDoc.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                AddDocActionPerformed(evt);
            }
        });
        DocMenu.add(AddDoc);

        DelDoc.setFont(getFontMenu());
        DelDoc.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/del.png"))); // NOI18N
        DelDoc.setText(TT("Delete"));
        DelDoc.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                DelDocActionPerformed(evt);
            }
        });
        DocMenu.add(DelDoc);
        DocMenu.add(jSeparator3);

        AddDocAdvanced.setFont(getFontMenu());
        AddDocAdvanced.setText(TT("Extended_Add"));
        AddDocAdvanced.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                AddDocAdvancedActionPerformed(evt);
            }
        });
        DocMenu.add(AddDocAdvanced);

        ModDocAdvanced.setFont(getFontMenu());
        ModDocAdvanced.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/edit.png"))); // NOI18N
        ModDocAdvanced.setText(TT("Update_Extended"));
        ModDocAdvanced.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ModDocAdvancedActionPerformed(evt);
            }
        });
        DocMenu.add(ModDocAdvanced);

        ViewMetadata.setFont(getFontMenu());
        ViewMetadata.setText(TT("Document_Attributes"));
        ViewMetadata.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ViewMetadataActionPerformed(evt);
            }
        });
        DocMenu.add(ViewMetadata);

        RefreshDocs.setFont(getFontMenu());
        RefreshDocs.setText(TT("Refresh"));
        RefreshDocs.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                RefreshDocsActionPerformed(evt);
            }
        });
        DocMenu.add(RefreshDocs);
        DocMenu.add(jSeparator4);

        CheckOut.setFont(getFontMenu());
        CheckOut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/checkout.png"))); // NOI18N
        CheckOut.setText("CheckOut");
        CheckOut.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                CheckOutActionPerformed(evt);
            }
        });
        DocMenu.add(CheckOut);

        CheckIn.setFont(getFontMenu());
        CheckIn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/checkin.png"))); // NOI18N
        CheckIn.setText("CheckIn");
        CheckIn.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                CheckInActionPerformed(evt);
            }
        });
        DocMenu.add(CheckIn);

        CancelCheckout.setFont(getFontMenu());
        CancelCheckout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/cancelcheckout.png"))); // NOI18N
        CancelCheckout.setText("CancelCheckout");
        CancelCheckout.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                CancelCheckoutActionPerformed(evt);
            }
        });
        DocMenu.add(CancelCheckout);

        ListVersions.setFont(getFontMenu());
        ListVersions.setText(TT("List_of_Versions"));
        ListVersions.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ListVersionsActionPerformed(evt);
            }
        });
        DocMenu.add(ListVersions);
        DocMenu.add(jSeparator1);

        SearchDocs.setFont(getFontMenu());
        SearchDocs.setText(TT("Search_Documents"));
        SearchDocs.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                SearchDocsActionPerformed(evt);
            }
        });
        DocMenu.add(SearchDocs);

        ExportDoc.setFont(getFontMenu());
        ExportDoc.setText(TT("Export_Doc"));
        ExportDoc.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ExportDocActionPerformed(evt);
            }
        });
        DocMenu.add(ExportDoc);

        ImportDoc.setFont(getFontMenu());
        ImportDoc.setText(TT("Import_Doc"));
        ImportDoc.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ImportDocActionPerformed(evt);
            }
        });
        DocMenu.add(ImportDoc);
        DocMenu.add(jSeparator7);

        ImportExtRIS.setFont(getFontMenu());
        ImportExtRIS.setText(TT("Import_RIS"));
        ImportExtRIS.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ImportExtRISActionPerformed(evt);
            }
        });
        DocMenu.add(ImportExtRIS);
        DocMenu.add(jSeparator8);

        ReportsDoc.setFont(getFontMenu());
        ReportsDoc.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/Report.png"))); // NOI18N
        ReportsDoc.setText("Reports");
        ReportsDoc.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ReportsDocActionPerformed(evt);
            }
        });
        DocMenu.add(ReportsDoc);

        menuBar.add(DocMenu);

        OtherMenu.setText(TT("Other_Tasks"));
        OtherMenu.setFont(getFontMenu());

        PaperBin.setFont(getFontMenu());
        PaperBin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/undel.png"))); // NOI18N
        PaperBin.setText(MainWin.TT("Trash_bin"));
        PaperBin.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                PaperBinActionPerformed(evt);
            }
        });
        OtherMenu.add(PaperBin);

        ChangePass.setFont(getFontMenu());
        ChangePass.setText(MainWin.TT("Password_change"));
        ChangePass.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ChangePassActionPerformed(evt);
            }
        });
        OtherMenu.add(ChangePass);

        Thesaur.setFont(getFontMenu());
        Thesaur.setLabel("Thesaurus");
        Thesaur.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ThesaurActionPerformed(evt);
            }
        });
        OtherMenu.add(Thesaur);

        menuBar.add(OtherMenu);

        AdminMenu.setText(TT("Administration"));
        AdminMenu.setFont(getFontMenu());

        ACLMenuItem.setFont(getFontMenu());
        ACLMenuItem.setText("ACL");
        ACLMenuItem.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ACLMenuItemActionPerformed(evt);
            }
        });
        AdminMenu.add(ACLMenuItem);

        GroupMenuItem.setFont(getFontMenu());
        GroupMenuItem.setText(TT("Groups"));
        GroupMenuItem.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                GroupMenuItemActionPerformed(evt);
            }
        });
        AdminMenu.add(GroupMenuItem);

        UserMenuItem.setFont(getFontMenu());
        UserMenuItem.setText(TT("Users"));
        UserMenuItem.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                UserMenuItemActionPerformed(evt);
            }
        });
        AdminMenu.add(UserMenuItem);

        RolMenuItem.setFont(getFontMenu());
        RolMenuItem.setText(TT("Roles"));
        RolMenuItem.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                RolMenuItemActionPerformed(evt);
            }
        });
        AdminMenu.add(RolMenuItem);

        MimeTypeMenuItem.setFont(getFontMenu());
        MimeTypeMenuItem.setText(TT("Mime_Types"));
        MimeTypeMenuItem.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                MimeTypeMenuItemActionPerformed(evt);
            }
        });
        AdminMenu.add(MimeTypeMenuItem);

        ReposMenuItem.setFont(getFontMenu());
        ReposMenuItem.setText(TT("Repositories"));
        ReposMenuItem.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ReposMenuItemActionPerformed(evt);
            }
        });
        AdminMenu.add(ReposMenuItem);

        ObjDefMenuItem.setFont(getFontMenu());
        ObjDefMenuItem.setText(TT("Object_definitions"));
        ObjDefMenuItem.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ObjDefMenuItemActionPerformed(evt);
            }
        });
        AdminMenu.add(ObjDefMenuItem);

        AuthentMenuItem.setFont(getFontMenu());
        AuthentMenuItem.setText(TT("Authenticators"));
        AuthentMenuItem.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                AuthentMenuItemActionPerformed(evt);
            }
        });
        AdminMenu.add(AuthentMenuItem);

        CustomMenuItem.setFont(getFontMenu());
        CustomMenuItem.setText(TT("Customizations"));
        CustomMenuItem.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                CustomMenuItemActionPerformed(evt);
            }
        });
        AdminMenu.add(CustomMenuItem);

        TaskCronMenuItem.setFont(getFontMenu());
        TaskCronMenuItem.setText(TT("Task_Cron"));
        TaskCronMenuItem.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                TaskCronMenuItemActionPerformed(evt);
            }
        });
        AdminMenu.add(TaskCronMenuItem);

        TaskEvenMenuItem.setFont(getFontMenu());
        TaskEvenMenuItem.setText(TT("Task_Events"));
        TaskEvenMenuItem.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                TaskEvenMenuItemActionPerformed(evt);
            }
        });
        AdminMenu.add(TaskEvenMenuItem);

        TaskExecMenuItem.setFont(getFontMenu());
        TaskExecMenuItem.setText(TT("Pending_Task_log"));
        TaskExecMenuItem.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                TaskExecMenuItemActionPerformed(evt);
            }
        });
        AdminMenu.add(TaskExecMenuItem);

        TaskEndedMenuItem.setFont(getFontMenu());
        TaskEndedMenuItem.setText(TT("Ended_Tasks_Logs"));
        TaskEndedMenuItem.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                TaskEndedMenuItemActionPerformed(evt);
            }
        });
        AdminMenu.add(TaskEndedMenuItem);

        TraceMenuItem.setFont(getFontMenu());
        TraceMenuItem.setText(TT("Trace_Logs"));
        TraceMenuItem.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                TraceMenuItemActionPerformed(evt);
            }
        });
        AdminMenu.add(TraceMenuItem);

        ImportPackage.setFont(getFontMenu());
        ImportPackage.setText(TT("Import_Package"));
        ImportPackage.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ImportPackageActionPerformed(evt);
            }
        });
        AdminMenu.add(ImportPackage);

        menuBar.add(AdminMenu);

        helpMenu.setText(TT("Help"));
        helpMenu.setFont(getFontMenu());

        contentsMenuItem1.setFont(getFontMenu());
        contentsMenuItem1.setText(TT("Contents"));
        contentsMenuItem1.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                contentsMenuItem1ActionPerformed(evt);
            }
        });
        helpMenu.add(contentsMenuItem1);

        aboutMenuItem1.setFont(getFontMenu());
        aboutMenuItem1.setText(TT("About"));
        aboutMenuItem1.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                aboutMenuItem1ActionPerformed(evt);
            }
        });
        helpMenu.add(aboutMenuItem1);

        ReportBugs.setFont(getFontMenu());
        ReportBugs.setText(TT("Reporting_Bugs"));
        ReportBugs.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                ReportBugsActionPerformed(evt);
            }
        });
        helpMenu.add(ReportBugs);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 732, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 572, Short.MAX_VALUE)
        );

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

    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
    Disconnect();
    }//GEN-LAST:event_exitMenuItemActionPerformed

    private void UserMenuItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_UserMenuItemActionPerformed
    {//GEN-HEADEREND:event_UserMenuItemActionPerformed
try {
ListUsers LU = new ListUsers(this, true, new PDUser(getSession()));
LU.setLocationRelativeTo(null);
LU.setVisible(true);
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_UserMenuItemActionPerformed

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

    private void MimeTypeMenuItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_MimeTypeMenuItemActionPerformed
    {//GEN-HEADEREND:event_MimeTypeMenuItemActionPerformed
try {
ListMimeTypes LMT = new ListMimeTypes(this, true, new PDMimeType(getSession()));
LMT.setLocationRelativeTo(null);
LMT.setVisible(true);
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_MimeTypeMenuItemActionPerformed

    private void ACLMenuItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ACLMenuItemActionPerformed
    {//GEN-HEADEREND:event_ACLMenuItemActionPerformed
try {
ListAcl LA = new ListAcl(this, true, new PDACL(getSession()));
LA.setLocationRelativeTo(null);
LA.setVisible(true);
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_ACLMenuItemActionPerformed

    private void GroupMenuItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_GroupMenuItemActionPerformed
    {//GEN-HEADEREND:event_GroupMenuItemActionPerformed
try {
ListGroups LG = new ListGroups(this, true, new PDGroups(getSession()));
LG.setLocationRelativeTo(null);
LG.setVisible(true);
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_GroupMenuItemActionPerformed

    private void RolMenuItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_RolMenuItemActionPerformed
    {//GEN-HEADEREND:event_RolMenuItemActionPerformed
try {
ListRoles LR = new ListRoles(this, true, new PDRoles(getSession()));
LR.setLocationRelativeTo(null);
LR.setVisible(true);
} catch (Exception ex)  
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_RolMenuItemActionPerformed

    private void ReposMenuItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ReposMenuItemActionPerformed
    {//GEN-HEADEREND:event_ReposMenuItemActionPerformed
try {
ListRepositories LR = new ListRepositories(this, true, new PDRepository(getSession()));
LR.setLocationRelativeTo(null);
LR.setVisible(true);
} catch (Exception ex)  
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_ReposMenuItemActionPerformed

    private void TreeFolderTreeExpanded(javax.swing.event.TreeExpansionEvent evt)//GEN-FIRST:event_TreeFolderTreeExpanded
    {//GEN-HEADEREND:event_TreeFolderTreeExpanded
DefaultMutableTreeNode TreeFold = (DefaultMutableTreeNode) evt.getPath().getLastPathComponent();
if ( ((TreeFolder) TreeFold.getUserObject()).isExpanded())
    return;
setCursor(WaitCur);
ExpandFold(TreeFold);
setCursor(DefCur);
    }//GEN-LAST:event_TreeFolderTreeExpanded

    private void TreeFolderValueChanged(javax.swing.event.TreeSelectionEvent evt)//GEN-FIRST:event_TreeFolderValueChanged
    {//GEN-HEADEREND:event_TreeFolderValueChanged
try {
setCursor(WaitCur);
DefaultMutableTreeNode TreeFold = (DefaultMutableTreeNode) evt.getPath().getLastPathComponent();
FoldAct= ((TreeFolder) TreeFold.getUserObject()).getFold();
SelFolderDesc.setText(HtmlDesc(FoldAct));
ActFolderId=FoldAct.getPDId();
RefreshDocs();
setCursor(DefCur);
} catch (Exception ex)
    {
    setCursor(DefCur);
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_TreeFolderValueChanged

    private void AddFoldActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_AddFoldActionPerformed
    {//GEN-HEADEREND:event_AddFoldActionPerformed
String NewFoldChild=DialogReadString(TT("Add_Folder"),TT("Folder_name"), TT("Write_Folder_name"), null);
if (NewFoldChild==null || NewFoldChild.length()==0)
    return;
try {
PDFolders Fold=new PDFolders(Session);
Fold.setPDId(getActFolderId());
Fold.CreateChild(NewFoldChild);
TreePath ActualPath = TreeFolder.getSelectionPath();
DefaultMutableTreeNode TreeFold = (DefaultMutableTreeNode) ActualPath.getLastPathComponent();
ExpandFold(TreeFold);
TreeFolder.setSelectionPath(ActualPath);
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_AddFoldActionPerformed

    private void DelFoldActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_DelFoldActionPerformed
    {//GEN-HEADEREND:event_DelFoldActionPerformed
try {
TreePath selectionPath = TreeFolder.getSelectionPath();
DefaultMutableTreeNode TreeFold = (DefaultMutableTreeNode) selectionPath.getLastPathComponent();
PDFolders Fold= ((TreeFolder) TreeFold.getUserObject()).getFold();
DialogEditFold DEF = new DialogEditFold(this, true);
DEF.setLocationRelativeTo(null);
DEF.DelMode();
Fold.LoadFull(getActFolderId());
DEF.setRecord(Fold.getRecord());
DEF.setVisible(true);
if (DEF.isCancel())
    return;
ActFolderId=Fold.getParentId();
Fold.delete();
TreePath ParentFold = (TreePath) TreeFolder.getSelectionPath().getParentPath();
ExpandFold((DefaultMutableTreeNode)ParentFold.getLastPathComponent());
TreeFolder.setSelectionPath(selectionPath.getParentPath());
TreeFold = (DefaultMutableTreeNode) selectionPath.getParentPath().getLastPathComponent();
FoldAct= ((TreeFolder) TreeFold.getUserObject()).getFold();
SelFolderDesc.setText(HtmlDesc(FoldAct));
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_DelFoldActionPerformed

    private void AddFoldAdvancedActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_AddFoldAdvancedActionPerformed
    {//GEN-HEADEREND:event_AddFoldAdvancedActionPerformed
DialogEditFold DEF;
PDFolders Fold;
try {
DEF = new DialogEditFold(this, true);
DEF.setLocationRelativeTo(null);
DEF.AddMode();
DEF.setAcl(FoldAct.getACL());
Fold=new PDFolders(Session);
DEF.setParentPath(Fold.getPathId(FoldAct.getPDId()));
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    return;
    }
while (true)
    {
    try {
    DEF.setVisible(true);
    if (DEF.isCancel())
        return;
    Fold=new PDFolders(Session);
    Fold.assignValues(DEF.getRecord());
    Fold.setParentId(getActFolderId());
    Fold.insert();
    TreePath ActualPath = TreeFolder.getSelectionPath();
    ExpandFold((DefaultMutableTreeNode)ActualPath.getLastPathComponent());
    TreeFolder.setSelectionPath(ActualPath);
    return;
    } catch (Exception ex)
        {
        Message(DrvTT(ex.getLocalizedMessage()));
        }
    }
    }//GEN-LAST:event_AddFoldAdvancedActionPerformed

    private void ModFoldActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ModFoldActionPerformed
    {//GEN-HEADEREND:event_ModFoldActionPerformed
try {
TreePath selectionPath = TreeFolder.getSelectionPath();
DefaultMutableTreeNode TreeFold = (DefaultMutableTreeNode) selectionPath.getLastPathComponent();
PDFolders Fold= ((TreeFolder) TreeFold.getUserObject()).getFold();
String NewTitle=DialogReadString(TT("Update_Folder"),TT("Folder_name"), TT("Write_Folder_name"), Fold.getTitle());
if (NewTitle==null || NewTitle.length()==0)
    return;
Fold.setTitle(NewTitle);
Fold.update();
TreePath ParentFold = (TreePath) TreeFolder.getSelectionPath().getParentPath();
ExpandFold((DefaultMutableTreeNode)ParentFold.getLastPathComponent());
TreeFolder.setSelectionPath(selectionPath);
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_ModFoldActionPerformed

    private void ModFoldAdvancedActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ModFoldAdvancedActionPerformed
    {//GEN-HEADEREND:event_ModFoldAdvancedActionPerformed
DialogEditFold DEF;
PDFolders Fold;
TreePath selectionPath = TreeFolder.getSelectionPath();
try {
DefaultMutableTreeNode TreeFold = (DefaultMutableTreeNode) selectionPath.getLastPathComponent();
Fold= ((TreeFolder) TreeFold.getUserObject()).getFold();
DEF = new DialogEditFold(this, true);
DEF.setLocationRelativeTo(null);
DEF.EditMode();
Fold.LoadFull(Fold.getPDId());
DEF.setRecord(Fold.getRecord());
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    return;
    }
while (true)
    {
    try {
    DEF.setVisible(true);
    if (DEF.isCancel())
        return;
    DEF.getRecord().CheckDef();
    Fold.assignValues(DEF.getRecord());
    Fold.update();
    TreePath ParentFold = (TreePath) TreeFolder.getSelectionPath().getParentPath();
    ExpandFold((DefaultMutableTreeNode)ParentFold.getLastPathComponent());
    TreeFolder.setSelectionPath(selectionPath);
    return;
    } catch (Exception ex)
        {
        Message(DrvTT(ex.getLocalizedMessage()));
        }
    }
    }//GEN-LAST:event_ModFoldAdvancedActionPerformed

    private void RefreshFoldActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_RefreshFoldActionPerformed
    {//GEN-HEADEREND:event_RefreshFoldActionPerformed
DefaultMutableTreeNode TreeFold = (DefaultMutableTreeNode) TreeFolder.getSelectionPath().getLastPathComponent();
ExpandFold(TreeFold);
    }//GEN-LAST:event_RefreshFoldActionPerformed

    private void ObjDefMenuItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ObjDefMenuItemActionPerformed
    {//GEN-HEADEREND:event_ObjDefMenuItemActionPerformed
ListObjDef LOD = new ListObjDef(this, true, new PDObjDefs(getSession()));
LOD.setLocationRelativeTo(null);
LOD.setVisible(true);
    }//GEN-LAST:event_ObjDefMenuItemActionPerformed

    private void AddDocActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddDocActionPerformed
DialogEditDocReduced MD = new DialogEditDocReduced(this,true);
PDDocs Doc;
try {
Doc = new PDDocs(getSession());
MD.setRecord(Doc.getRecSum());
MD.AddMode();
PDFolders Fold=new PDFolders(Session);
MD.setParentPath(Fold.getPathId(FoldAct.getPDId()));
MD.setLocationRelativeTo(null);
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    return;
    }
while (true)
    {
    try {
    MD.setVisible(true);
    if (MD.isCancel())
        return;
    Doc.assignValues(MD.getRecord());
    if (MD.getPath()!=null)
        Doc.setFile(MD.getPath());
    else
        throw new PDException("Error_retrieving_file");
    Doc.setParentId(getActFolderId());
    Doc.insert();
    RefreshDocs();
    return;
    } catch (Exception ex)
        {
        Message(DrvTT(ex.getLocalizedMessage()));
        }
    }
    }//GEN-LAST:event_AddDocActionPerformed

    private void DelDocActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DelDocActionPerformed
if (DocsTable.getSelectedRow()==-1)
    return;
try {
PDDocs Doc = new PDDocs(getSession());
DialogEditDoc MD = new DialogEditDoc(this,true);
Doc.assignValues(DocsContained.getElement(DocsTable.convertRowIndexToModel(DocsTable.getSelectedRow())));
Doc.LoadFull(Doc.getPDId());
MD.DelMode();
MD.setRecord(Doc.getRecSum());
MD.setLocationRelativeTo(null);
MD.setVisible(true);
if (MD.isCancel())
    return;
Doc.assignValues(MD.getRecord());
Doc.delete();
RefreshDocs();
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_DelDocActionPerformed

    private void AddDocAdvancedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddDocAdvancedActionPerformed
PDDocs Doc;
DialogEditDoc MD = new DialogEditDoc(this,true);
try {
Doc = new PDDocs(getSession());
TreePath selectionPath = TreeFolder.getSelectionPath();
DefaultMutableTreeNode TreeFold = (DefaultMutableTreeNode) selectionPath.getLastPathComponent();
PDFolders Fold= ((TreeFolder) TreeFold.getUserObject()).getFold();
Doc.setACL(Fold.getACL());
MD.setRecord(Doc.getRecSum());
MD.AddMode();
MD.setParentPath(Fold.getPathId(FoldAct.getPDId()));
MD.setLocationRelativeTo(null);
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    return;
    }
while (true)
    {
    try {
    MD.setVisible(true);
    if (MD.isCancel())
        return;
    String SelectedType=(String)MD.getRecord().getAttr(PDDocs.fDOCTYPE).getValue();
    if (!SelectedType.equalsIgnoreCase(Doc.getDocType()))
        Doc = new PDDocs(getSession(), SelectedType);
    Doc.assignValues(MD.getRecord());
    if (MD.GetSelectPath()!=null && MD.GetSelectPath().length()>0)
        Doc.setFile(MD.GetSelectPath());
    else
        throw new PDException("Error_retrieving_file");
    Doc.setParentId(getActFolderId());
    Doc.insert();
    RefreshDocs();
    return;
    } catch (Exception ex)
        {
        Message(DrvTT(ex.getLocalizedMessage()));
        RefreshDocs();
        }
    }
    }//GEN-LAST:event_AddDocAdvancedActionPerformed

    private void ModDocAdvancedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ModDocAdvancedActionPerformed
if (DocsTable.getSelectedRow()==-1)
    return;
DialogEditDoc MD = new DialogEditDoc(this,true);
PDDocs Doc;
try {
Doc = new PDDocs(getSession());
Doc.assignValues(DocsContained.getElement(DocsTable.convertRowIndexToModel(DocsTable.getSelectedRow())));
Doc.LoadFull(Doc.getPDId());
MD.setRecord(Doc.getRecSum().Copy()); // we need a copy to avoid edition on the same referenced values
MD.EditMode();
MD.setLocationRelativeTo(null);
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    return;
    }
while (true)
    {   
    try {
    MD.setVisible(true);
    if (MD.isCancel())
        return;
    MD.getRecord().CheckDef();
    Doc.assignValues(MD.getRecord());
    if (MD.GetSelectPath()!=null && MD.GetSelectPath().length()>0)
        Doc.setFile(MD.GetSelectPath());
    Doc.update();
    RefreshDocs();
    return;
    } catch (Exception ex)
        {
        Message(DrvTT(ex.getLocalizedMessage()));
        }
    }
    }//GEN-LAST:event_ModDocAdvancedActionPerformed

    private void RefreshDocsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RefreshDocsActionPerformed
RefreshDocs();
    }//GEN-LAST:event_RefreshDocsActionPerformed

    private void CheckOutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CheckOutActionPerformed
if (DocsTable.getSelectedRow()==-1)
    return;
try {
PDDocs Doc = new PDDocs(getSession());
Doc.assignValues(DocsContained.getElement(DocsTable.convertRowIndexToModel(DocsTable.getSelectedRow())));
Doc.Checkout();
RefreshDocs();
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_CheckOutActionPerformed

    private void CheckInActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CheckInActionPerformed
if (DocsTable.getSelectedRow()==-1)
    return;
try {
PDDocs Doc = new PDDocs(getSession());
Doc.assignValues(DocsContained.getElement(DocsTable.convertRowIndexToModel(DocsTable.getSelectedRow())));
String VersionLabel=DialogReadString(TT("Creating_a_new_version_of_document"), TT("Version_identifier"),  TT("Type_a_version_name_or_identifier"), "");
if (VersionLabel==null)
    return;
if (VersionLabel.length()==0)
    {
    Message(TT("Version_identifier_required"));
    return;
    }
Doc.Checkin(VersionLabel);
RefreshDocs();
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_CheckInActionPerformed

    private void CancelCheckoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelCheckoutActionPerformed
if (DocsTable.getSelectedRow()==-1)
    return;
try {
if (!MessageQuestion(TT("Do_you_want_to_cancel_edition_and_lost_changes")))
    return;
PDDocs Doc = new PDDocs(getSession());
Doc.assignValues(DocsContained.getElement(DocsTable.convertRowIndexToModel(DocsTable.getSelectedRow())));
Doc.CancelCheckout();
RefreshDocs();
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_CancelCheckoutActionPerformed

    private void PaperBinActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PaperBinActionPerformed
ListDeleted LD = new ListDeleted(this, true);
LD.setLocationRelativeTo(null);
LD.setVisible(true);
    }//GEN-LAST:event_PaperBinActionPerformed

    private void ListVersionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ListVersionsActionPerformed
if (DocsTable.getSelectedRow()==-1)
    return;
ListVersions LV = new ListVersions(this, true, DocsContained.getElement(DocsTable.convertRowIndexToModel(DocsTable.getSelectedRow())));
LV.setLocationRelativeTo(null);
LV.setVisible(true);
    }//GEN-LAST:event_ListVersionsActionPerformed

    private void SearchFoldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SearchFoldActionPerformed
SearchFold SF = new SearchFold(this, true);
SF.setLocationRelativeTo(null);
SF.setFoldAct(getActFolderId());
SF.setVisible(true);     
    }//GEN-LAST:event_SearchFoldActionPerformed

    private void SearchDocsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SearchDocsActionPerformed
SearchDocs SD = new SearchDocs(this, true);
SD.setLocationRelativeTo(null);
SD.setFoldAct(getActFolderId());
SD.setVisible(true);
    }//GEN-LAST:event_SearchDocsActionPerformed

    private void AuthentMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AuthentMenuItemActionPerformed
try {
ListAuthenticators LA = new ListAuthenticators(this, true, new PDAuthenticators(getSession()));
LA.setLocationRelativeTo(null);
LA.setVisible(true);
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_AuthentMenuItemActionPerformed

    private void ChangePassActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ChangePassActionPerformed
    {//GEN-HEADEREND:event_ChangePassActionPerformed
try {
ChangePassword CP = new ChangePassword(this, true);
CP.setLocationRelativeTo(null);
CP.setVisible(true);
if (CP.isCancel())
    return;
getSession().ChangePassword(getSession().getUser().getName(), CP.getOldPasswordField(), CP.getNewPasswordField1());
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_ChangePassActionPerformed

    private void CustomMenuItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_CustomMenuItemActionPerformed
    {//GEN-HEADEREND:event_CustomMenuItemActionPerformed
try {
ListCustom LC = new ListCustom(this, true, new PDCustomization(getSession()));
LC.setLocationRelativeTo(null);
LC.setVisible(true);
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_CustomMenuItemActionPerformed

    private void aboutMenuItem1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_aboutMenuItem1ActionPerformed
    {//GEN-HEADEREND:event_aboutMenuItem1ActionPerformed
AboutOPD Ab=new AboutOPD(this, rootPaneCheckingEnabled);
Ab.setLocationRelativeTo(null);
Ab.setVisible(true);
Ab.dispose();
    }//GEN-LAST:event_aboutMenuItem1ActionPerformed

    private void contentsMenuItem1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_contentsMenuItem1ActionPerformed
    {//GEN-HEADEREND:event_contentsMenuItem1ActionPerformed
File f=new File ("doc"+OSSep()+DriverGeneric.getHelpLang(getLang())+OSSep()+"MainWin.html");
if (f.exists())
   Execute(f.getAbsolutePath());  
else
    {
    f=new File ("webapps"+OSSep()+"ProdocWeb2"+OSSep()+"help"+OSSep()+DriverGeneric.getHelpLang(getLang())+OSSep()+"MainWin.html");
    Execute(f.getAbsolutePath());  
    }
    }//GEN-LAST:event_contentsMenuItem1ActionPerformed

    private void DocsTableMouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST:event_DocsTableMouseClicked
    {//GEN-HEADEREND:event_DocsTableMouseClicked
if (evt.getClickCount()<2)
    return;
if (DocsTable.getSelectedRow()==-1)
    return;
try {
PDDocs Doc = new PDDocs(getSession());
Doc.assignValues(DocsContained.getElement(DocsTable.convertRowIndexToModel(DocsTable.getSelectedRow())));
Doc.LoadCurrent(Doc.getPDId());
String FileName;
if (Doc.IsUrl())
    FileName=Doc.getUrl();
else
    {
    FileName=Doc.getFileOpt(getTmp(), false);
    AddExec(FileName);
    }
Execute(FileName);
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }

    }//GEN-LAST:event_DocsTableMouseClicked

    private void ExportDocActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ExportDocActionPerformed
    {//GEN-HEADEREND:event_ExportDocActionPerformed
if (DocsTable.getSelectedRow()==-1)
    return;
try {
String FileName=MainWin.SelectFolderDestination("");
if (FileName.length()==0)
    return;
PDDocs Doc = new PDDocs(getSession());
Doc.assignValues(DocsContained.getElement(DocsTable.convertRowIndexToModel(DocsTable.getSelectedRow())));
Doc.ExportXML(FileName, false);
} catch (Exception ex)
    {
     MainWin.Message(MainWin.DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_ExportDocActionPerformed

    private void ImportDocActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ImportDocActionPerformed
    {//GEN-HEADEREND:event_ImportDocActionPerformed
String FileName=MainWin.SelectDestination(null, "opd", false);
if (FileName.length()==0)
    return;
try {
PDDocs Doc = new PDDocs(getSession());
File FileImp=new File(FileName);  
getSession().ProcessXML(FileImp, getActFolderId()); 
RefreshDocs();
} catch (Exception ex)
    {
    MainWin.Message(MainWin.DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_ImportDocActionPerformed

    private void ExportFoldActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ExportFoldActionPerformed
    {//GEN-HEADEREND:event_ExportFoldActionPerformed
try {
if (FoldAct.getPDId().equals(PDFolders.ROOTFOLDER))    
    PDExceptionFunc.GenPDException("Exporting_RootFolder_not_allowed", "");
ExpFolds=0;
ExpDocs=0;    
DialogExportFolders ExpFold = new DialogExportFolders(this,true);
ExpFold.setLocationRelativeTo(null);
ExpFold.setVisible(true);
if (ExpFold.isCancel())
    return;
setCursor(WaitCur);    
Export(FoldAct, getIO_OSFolder(), ExpFold.IsOneLevel(), ExpFold.IncludeMetadata(), ExpFold.IncludeDocs());
setCursor(DefCur);
Message(DrvTT("Exported")+" "+ExpFolds+" "+DrvTT("Folders")+" / "+ExpDocs +" "+DrvTT("Documents"));
} catch (Exception ex)
    {
    setCursor(DefCur);    
    MainWin.Message(MainWin.DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_ExportFoldActionPerformed

    private void ImportFoldActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ImportFoldActionPerformed
    {//GEN-HEADEREND:event_ImportFoldActionPerformed
try {
DialogImportFolders ImpFold = new DialogImportFolders(this,true);
ImpFold.setLocationRelativeTo(null);
ImpFold.setVisible(true);
if (ImpFold.isCancel())
    return;
setCursor(WaitCur);
if (ImpFold.IsJavaDoc())
    getSession().ConvertJavaDocImport(FoldAct, getIO_OSFolder(), ImpFold.FoldType(), ImpFold.DocType(), ImpFold.IsStrict());
else    
    getSession().ImportFolder(FoldAct, getIO_OSFolder(), ImpFold.IsOneLevel(), ImpFold.IncludeMetadata(), ImpFold.IncludeDocs(), ImpFold.FoldType(), ImpFold.DocType(), ImpFold.IsStrict());
ExpFolds=getSession().getImpFolds();
ExpDocs=getSession().getImpDocs();    
//Import(FoldAct, getIO_OSFolder(), ImpFold.IsOneLevel(), ImpFold.IncludeMetadata(), ImpFold.IncludeDocs(), ImpFold.FoldType(), ImpFold.DocType(), ImpFold.IsStrict());
TreePath ActualPath = TreeFolder.getSelectionPath();
DefaultMutableTreeNode TreeFold = (DefaultMutableTreeNode) ActualPath.getLastPathComponent();
ExpandFold(TreeFold);
TreeFolder.setSelectionPath(ActualPath);
setCursor(DefCur);
Message(DrvTT("Imported")+" "+ExpFolds+" "+DrvTT("Folders")+" / "+ExpDocs +" "+DrvTT("Documents"));
} catch (Exception ex)
    {
    setCursor(DefCur);
    MainWin.Message(MainWin.DrvTT(ex.getLocalizedMessage()));
    }

    }//GEN-LAST:event_ImportFoldActionPerformed

    private void ReportBugsActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ReportBugsActionPerformed
    {//GEN-HEADEREND:event_ReportBugsActionPerformed
// Execute("https://docs.google.com/spreadsheet/viewform?formkey%3DdFF6ZndKWXFUQnJ0MWtVZWdUWk10X2c6MQ");   
Execute("https://docs.google.com/spreadsheet/viewform?usp=drive_web&formkey=dEpsRzZzSmlaQVZET0g2NDdsM0ZRaEE6MA#gid=0");   
    }//GEN-LAST:event_ReportBugsActionPerformed

    private void ViewMetadataActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ViewMetadataActionPerformed
    {//GEN-HEADEREND:event_ViewMetadataActionPerformed
if (DocsTable.getSelectedRow()==-1)
    return;
try {
PDDocs Doc = new PDDocs(getSession());
DialogEditDoc MD = new DialogEditDoc(this,true);
Doc.assignValues(DocsContained.getElement(DocsTable.convertRowIndexToModel(DocsTable.getSelectedRow())));
Doc.LoadFull(Doc.getPDId());
MD.ViewMode();
MD.setRecord(Doc.getRecSum());
MD.setLocationRelativeTo(null);
MD.setVisible(true);
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_ViewMetadataActionPerformed

    private void ImportExtFoldActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ImportExtFoldActionPerformed
    {//GEN-HEADEREND:event_ImportExtFoldActionPerformed
try {
ExpFolds=0;
ExpDocs=0;    
DialogImportExtFolders ImpFold = new DialogImportExtFolders(this,true);
ImpFold.setLocationRelativeTo(null);
ImpFold.setVisible(true);
if (ImpFold.isCancel())
    return;
setCursor(WaitCur);
ImportExt(FoldAct, getIO_OSFolder(), ImpFold.DeleteAfterImport(), ImpFold.ImpFormat(), ImpFold.DefaultFoldType(), ImpFold.DateFormat(), ImpFold.TimeStampFormat());
TreePath ActualPath = TreeFolder.getSelectionPath();
DefaultMutableTreeNode TreeFold = (DefaultMutableTreeNode) ActualPath.getLastPathComponent();
ExpandFold(TreeFold);
TreeFolder.setSelectionPath(ActualPath);
setCursor(DefCur);
Message(DrvTT("Imported")+" "+ExpFolds+" "+DrvTT("Folders")+" / "+ExpDocs +" "+DrvTT("Documents"));
} catch (Exception ex)
    {
    setCursor(DefCur);
    MainWin.Message(MainWin.DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_ImportExtFoldActionPerformed

    private void ThesaurActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ThesaurActionPerformed
    {//GEN-HEADEREND:event_ThesaurActionPerformed
MainThes MTW=new MainThes(this, false, Session);
MTW.setLocationRelativeTo(null);
MTW.setVisible(true);
    }//GEN-LAST:event_ThesaurActionPerformed

    private void TaskCronMenuItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_TaskCronMenuItemActionPerformed
    {//GEN-HEADEREND:event_TaskCronMenuItemActionPerformed
try {
ListTaskCron LC = new ListTaskCron(this, true, new PDTasksCron(getSession()));
LC.setLocationRelativeTo(null);
LC.setVisible(true);
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_TaskCronMenuItemActionPerformed

    private void TaskEvenMenuItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_TaskEvenMenuItemActionPerformed
    {//GEN-HEADEREND:event_TaskEvenMenuItemActionPerformed
try {
ListTaskEvents LC = new ListTaskEvents(this, true, new PDTasksDefEvent(getSession()));
LC.setLocationRelativeTo(null);
LC.setVisible(true);
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_TaskEvenMenuItemActionPerformed

    private void TaskExecMenuItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_TaskExecMenuItemActionPerformed
    {//GEN-HEADEREND:event_TaskExecMenuItemActionPerformed
try {
ListTask LC = new ListTask(this, true, new PDTasksExec(getSession()));
LC.setLocationRelativeTo(null);
LC.setVisible(true);
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_TaskExecMenuItemActionPerformed

    private void TaskEndedMenuItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_TaskEndedMenuItemActionPerformed
    {//GEN-HEADEREND:event_TaskEndedMenuItemActionPerformed
try {
ListTaskEnded LC = new ListTaskEnded(this, true, new PDTasksExecEnded(getSession()));
LC.setLocationRelativeTo(null);
LC.setVisible(true);
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_TaskEndedMenuItemActionPerformed

    private void TraceMenuItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_TraceMenuItemActionPerformed
    {//GEN-HEADEREND:event_TraceMenuItemActionPerformed
try {
ListTrace LT = new ListTrace(this, true, new PDTrace(getSession()));
LT.setLocationRelativeTo(null);
LT.setVisible(true);
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_TraceMenuItemActionPerformed

    private void ReportsFoldActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ReportsFoldActionPerformed
    {//GEN-HEADEREND:event_ReportsFoldActionPerformed
try {
SelectReport SR = new SelectReport(this, true);
SR.setLocationRelativeTo(null);
SR.setVisible(true);
if (SR.isCancel())
    return;
setCursor(WaitCur);
PDFolders Fold=new PDFolders(Session);
Conditions Conds=new Conditions();
Condition Cond=new Condition(PDFolders.fPARENTID, Condition.cEQUAL, getActFolderId());
Conds.addCondition(Cond);
// Cursor Cur=Fold.Search(PDFolders.getTableName(), Conds,  true, false, null, null);
Vector<Record> Res = Fold.SearchV(PDFolders.getTableName(), Conds,  true, false, null, null);
PDReport Rep=new PDReport(Session);
Rep.setPDId(SR.getSelectedRep());
ArrayList<String> GeneratedRep = Rep.GenerateRep(getActFolderId(), null, Res, SR.getDocsPerPage(), SR.getPagesPerFile(), getIO_OSFolder());
setCursor(DefCur);
ListReports LR = new ListReports(this, true);
LR.setLocationRelativeTo(null);
LR.setRepList(GeneratedRep);
LR.setVisible(true);
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_ReportsFoldActionPerformed

    private void ReportsDocActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ReportsDocActionPerformed
    {//GEN-HEADEREND:event_ReportsDocActionPerformed
Cursor CursorId =null;
        try {
SelectReport SR = new SelectReport(this, true);
SR.setLocationRelativeTo(null);
SR.setVisible(true);
if (SR.isCancel())
    return;
setCursor(WaitCur);
PDDocs Doc=new PDDocs(Session);
PDReport Rep=new PDReport(Session);
Rep.setPDId(SR.getSelectedRep());
Vector<Record> ListRec=new Vector();
CursorId = Doc.getListContainedDocs(getActFolderId());
Record Res=Session.NextRec(CursorId);
while (Res!=null)
    {
    ListRec.add(Res);
    Res=Session.NextRec(CursorId);
    }
Session.CloseCursor(CursorId);
CursorId =null;
ArrayList<String> GeneratedRep = Rep.GenerateRep(getActFolderId(), null, ListRec, SR.getDocsPerPage(), SR.getPagesPerFile(), getIO_OSFolder());
setCursor(DefCur);
ListReports LR = new ListReports(this, true);
LR.setLocationRelativeTo(null);
LR.setRepList(GeneratedRep);
LR.setVisible(true);
} catch (Exception ex)
    {
    if (CursorId!=null)
        {try {
        Session.CloseCursor(CursorId); 
        } catch (Exception e){}
        }
    Message(DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_ReportsDocActionPerformed

    private void ImportExtRISActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ImportExtRISActionPerformed
    {//GEN-HEADEREND:event_ImportExtRISActionPerformed
try {
DialogImportRIS ImpRIS = new DialogImportRIS(this,true);
ImpRIS.setLocationRelativeTo(null);
ImpRIS.setVisible(true);
if (ImpRIS.isCancel())
    return;
PDDocsRIS D=new PDDocsRIS(getSession(), ImpRIS.DefaultRISDocType());
D.ImportFileRIS(getActFolderId(), ImpRIS.GetFilePath());
RefreshDocs();
} catch (Exception ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }        
    }//GEN-LAST:event_ImportExtRISActionPerformed

    private void ImportPackageActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ImportPackageActionPerformed
    {//GEN-HEADEREND:event_ImportPackageActionPerformed
try {
DialogImportPackage ImpFold = new DialogImportPackage(this,true);
ImpFold.setLocationRelativeTo(null);
ImpFold.setVisible(true);
if (ImpFold.isCancel())
    return;
setCursor(WaitCur);
getSession().ImportPack(getIO_OSFolder());
ExpFolds=getSession().getImpFolds();
ExpDocs=getSession().getImpDocs();    
TreePath ActualPath = TreeFolder.getSelectionPath();
DefaultMutableTreeNode TreeFold = (DefaultMutableTreeNode) ActualPath.getLastPathComponent();
ExpandFold(TreeFold);
TreeFolder.setSelectionPath(ActualPath);
setCursor(DefCur);
Message(DrvTT("Imported")+" "+ExpFolds+" "+DrvTT("Folders")+" / "+ExpDocs +" "+DrvTT("Documents"));
} catch (Exception ex)
    {
    setCursor(DefCur);
    MainWin.Message(MainWin.DrvTT(ex.getLocalizedMessage()));
    }
    }//GEN-LAST:event_ImportPackageActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[])
{
String PropertiesFile;    
if (args.length==0)    
    PropertiesFile="Prodoc.properties";
else
    PropertiesFile=args[0];
if (!Connect(PropertiesFile))
    System.exit(0);
java.awt.EventQueue.invokeLater(new Runnable()
    {
    public void run()
        {
        MainWin MW=new MainWin();
        MW.setLocationRelativeTo(null);
        MW.setVisible(true);
        }
    });
}

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem ACLMenuItem;
    private javax.swing.JMenuItem AddDoc;
    private javax.swing.JMenuItem AddDocAdvanced;
    private javax.swing.JMenuItem AddFold;
    private javax.swing.JMenuItem AddFoldAdvanced;
    private javax.swing.JMenu AdminMenu;
    private javax.swing.JMenuItem AuthentMenuItem;
    private javax.swing.JMenuItem CancelCheckout;
    private javax.swing.JMenuItem ChangePass;
    private javax.swing.JMenuItem CheckIn;
    private javax.swing.JMenuItem CheckOut;
    private javax.swing.JMenuItem CustomMenuItem;
    private javax.swing.JMenuItem DelDoc;
    private javax.swing.JMenuItem DelFold;
    private javax.swing.JMenu DocMenu;
    private javax.swing.JTable DocsTable;
    private javax.swing.JMenuItem ExportDoc;
    private javax.swing.JMenuItem ExportFold;
    private javax.swing.JMenu FolderMenu;
    private javax.swing.JMenuItem GroupMenuItem;
    private javax.swing.JMenuItem ImportDoc;
    private javax.swing.JMenuItem ImportExtFold;
    private javax.swing.JMenuItem ImportExtRIS;
    private javax.swing.JMenuItem ImportFold;
    private javax.swing.JMenuItem ImportPackage;
    private javax.swing.JMenuItem ListVersions;
    private javax.swing.JMenuItem MimeTypeMenuItem;
    private javax.swing.JMenuItem ModDocAdvanced;
    private javax.swing.JMenuItem ModFold;
    private javax.swing.JMenuItem ModFoldAdvanced;
    private javax.swing.JMenuItem ObjDefMenuItem;
    private javax.swing.JMenu OtherMenu;
    private javax.swing.JMenuItem PaperBin;
    private javax.swing.JMenuItem RefreshDocs;
    private javax.swing.JMenuItem RefreshFold;
    private javax.swing.JMenuItem ReportBugs;
    private javax.swing.JMenuItem ReportsDoc;
    private javax.swing.JMenuItem ReportsFold;
    private javax.swing.JMenuItem ReposMenuItem;
    private javax.swing.JMenuItem RolMenuItem;
    private javax.swing.JMenuItem SearchDocs;
    private javax.swing.JMenuItem SearchFold;
    private javax.swing.JLabel SelFolderDesc;
    private javax.swing.JMenuItem TaskCronMenuItem;
    private javax.swing.JMenuItem TaskEndedMenuItem;
    private javax.swing.JMenuItem TaskEvenMenuItem;
    private javax.swing.JMenuItem TaskExecMenuItem;
    private javax.swing.JMenuItem Thesaur;
    private javax.swing.JMenuItem TraceMenuItem;
    private javax.swing.JTree TreeFolder;
    private javax.swing.JMenuItem UserMenuItem;
    private javax.swing.JMenuItem ViewMetadata;
    private javax.swing.JMenuItem aboutMenuItem1;
    private javax.swing.JMenuItem contentsMenuItem1;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JPopupMenu.Separator jSeparator3;
    private javax.swing.JPopupMenu.Separator jSeparator4;
    private javax.swing.JPopupMenu.Separator jSeparator5;
    private javax.swing.JPopupMenu.Separator jSeparator6;
    private javax.swing.JPopupMenu.Separator jSeparator7;
    private javax.swing.JPopupMenu.Separator jSeparator8;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JSplitPane jSplitPane2;
    private javax.swing.JMenuBar menuBar;
    // End of variables declaration//GEN-END:variables

//---------------------------------------------------------------------
private static void EvaluateDef()
{
try {
String FontDef=getSession().getUser().getCustomData().getSwingStyle();
String ListF[]=FontDef.split(",");
MenuFont  =new java.awt.Font(ListF[0], Integer.parseInt(ListF[1]), Integer.parseInt(ListF[2]));
TreeFont  =new java.awt.Font(ListF[3], Integer.parseInt(ListF[4]), Integer.parseInt(ListF[5]));
ListFont  =new java.awt.Font(ListF[6], Integer.parseInt(ListF[7]), Integer.parseInt(ListF[8]));
DialogFont=new java.awt.Font(ListF[9], Integer.parseInt(ListF[10]), Integer.parseInt(ListF[11]));
} catch (Exception ex)
    {
    MenuFont=new java.awt.Font("Arial", 0, 12);
    TreeFont=new java.awt.Font("Arial", 0, 12);
    ListFont=new java.awt.Font("Arial", 0, 12);
    DialogFont=new java.awt.Font("Arial", 0, 12);
    }
}
//---------------------------------------------------------------------
/**
 * 
 * @return
 */
static public Font getFontMenu()
{
if (MenuFont==null)
    EvaluateDef();
return (MenuFont);
}
//---------------------------------------------------------------------
/**
 * 
 * @return
 */
static public Font getFontTree()
{
if (TreeFont==null)
    EvaluateDef();
return (TreeFont);
}
//---------------------------------------------------------------------
/**
 * 
 * @return
 */
static public Font getFontList()
{
if (ListFont==null)
    EvaluateDef();
return (ListFont);
}
//---------------------------------------------------------------------
/**
 * 
 * @return
 */
static public Font getFontDialog()
{
if (DialogFont==null)
    EvaluateDef();
return (DialogFont);
}
//---------------------------------------------------------------------
private PDTableModel getTableModel()
{
return new PDTableModel();
}
//---------------------------------------------------------------------

static private boolean Connect(String PropertiesFile)
{
LoginForm dialog = new LoginForm(new javax.swing.JFrame(), true);
dialog.setLocationRelativeTo(null);
for (int NumRetry = 0; NumRetry < 3; NumRetry++)
    {
    dialog.setVisible(true);
    if (dialog.getReturnStatus() == LoginForm.RET_CANCEL)
        return false;
    try {
        ProdocFW.InitProdoc("PD", PropertiesFile);
        Session = ProdocFW.getSession("PD", dialog.getLogin(), dialog.getPass());
        return(true);
    } catch (PDException ex)
        {
        Message(DrvTT(ex.getLocalizedMessage()));
        }
    }
return false;
}
//---------------------------------------------------------------------
static private void Disconnect()
{
try {
if (getSession()!=null)
    {
    ProdocFW.freeSesion("PD", getSession());
    }
ProdocFW.ShutdownProdoc("PD");
} catch (PDException ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
DestroyExec();
System.exit(0);
}
//---------------------------------------------------------------------
/**
 * 
 * @param pMessage
 */
static public void Message(String pMessage)
{
DialogInfo DI=new DialogInfo(null, true);
DI.SetMessage(DrvTT(pMessage));
DI.setLocationRelativeTo(null);
DI.setVisible(true);
}
//---------------------------------------------------------------------
/**
 * 
 * @param pMessage
 */
static public void Report(String pMessage)
{
DialogReport DR=new DialogReport(null, true);
DR.SetMessage(DrvTT(pMessage));
DR.setLocationRelativeTo(null);
DR.setVisible(true);
}
//---------------------------------------------------------------------
/**
 * 
 * @param pMessage to show to the user
 * @return if the user selects OK
 */
static public boolean MessageQuestion(String pMessage)
{
DialogInfoQuestion DI=new DialogInfoQuestion(null, true);
DI.SetMessage(DrvTT(pMessage));
DI.setLocationRelativeTo(null);
DI.setVisible( true);
return (DI.getReturnStatus()==DialogInfoQuestion.RET_OK);
}
//---------------------------------------------------------------------
/**
 * Returns the path of a selected file.
 * @param RecomFileName default name
 * @param Ext Default extension for the type
 * @param Save indicates if selecting an existing file or destination for saving a new one.
 * @return
 */
static public String SelectDestination(String RecomFileName, String Ext, boolean Save)
{
JFileChooser fc = new JFileChooser(getIO_OSFolder());
if (Ext!=null)
    fc.setFileFilter(new FileNameExtensionFilter("file "+Ext, Ext));
if (RecomFileName!=null)
    fc.setSelectedFile(new File(RecomFileName));
if (!Save)
    {
    if (fc.showOpenDialog(null)!=JFileChooser.APPROVE_OPTION)
        return("");
    }
else
    {
    if (fc.showSaveDialog(null)!=JFileChooser.APPROVE_OPTION)
        return("");
    }
setIO_OSFolder(fc.getSelectedFile().getParent());
return(fc.getSelectedFile().getAbsolutePath());
}
//---------------------------------------------------------------------
/**
 * 
 * @param RecomFileName
 * @return
 */
static public String SelectFolderDestination(String RecomFileName)
{
    //gfgfgf
JFileChooser fc = new JFileChooser();
if (RecomFileName!=null)
    fc.setSelectedFile(new File(RecomFileName));
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if (fc.showSaveDialog(null)!=JFileChooser.APPROVE_OPTION)
    return("");
setIO_OSFolder(fc.getSelectedFile().getAbsolutePath());
return(fc.getSelectedFile().getAbsolutePath());
}
//---------------------------------------------------------------------

private TreeModel getTreeModel()
{
if (FoldTreeModel==null)
    {
    PDFolders RootFolder=null;
    try {
    RootFolder = new PDFolders(Session);
    RootFolder.Load(PDFolders.ROOTFOLDER);
    TreeFolder TF=new TreeFolder(RootFolder);
    DefaultMutableTreeNode RootTreeFolder = new DefaultMutableTreeNode(TF);
    FoldTreeModel=new DefaultTreeModel(RootTreeFolder);
    ExpandFold(RootTreeFolder);
    } catch (PDException ex)
        {
        Message(DrvTT(ex.getLocalizedMessage()));
        return(null);
        }
    }
return(FoldTreeModel);
}
//---------------------------------------------------------------------
private void ExpandFold(DefaultMutableTreeNode ChildTreeFolder)
{
try {
setCursor(WaitCur);
ChildTreeFolder.removeAllChildren();
PDFolders Fold= ((TreeFolder) ChildTreeFolder.getUserObject()).getFold();
HashSet Child =Fold.getListDirectDescendList(Fold.getPDId());
for (Iterator it = Child.iterator(); it.hasNext();)
    {
    String ChildId=(String)it.next();
    if (ChildId.compareTo(Fold.getPDId())==0)
        continue;
    PDFolders ChildFolder=new PDFolders(Session);
    ChildFolder.LoadFull(ChildId);
    TreeFolder TFc=new TreeFolder(ChildFolder);
    DefaultMutableTreeNode ChildTreeFolder2=new DefaultMutableTreeNode(TFc);
    DefaultMutableTreeNode ChildTreeFolder3=new DefaultMutableTreeNode(null);
    ChildTreeFolder2.add(ChildTreeFolder3);
    ChildTreeFolder.add(ChildTreeFolder2);
    }
(((TreeFolder) ChildTreeFolder.getUserObject())).setExpanded(true);
FoldTreeModel.reload(ChildTreeFolder);
TreeFolder.setPreferredSize(null);
setCursor(DefCur);
} catch (PDException ex)
    {
    setCursor(DefCur);
    Message(DrvTT(ex.getLocalizedMessage()));
    }
}
//---------------------------------------------------------------------
static private String FormatDate(Date d)
{
return( getFormatterTS().format(d));
}
//---------------------------------------------------------------------
/**
 * 
 * @param Title
 * @param FieldName
 * @param ToolTip
 * @param FieldText
 * @return
 */
static public String DialogReadString(String Title, String FieldName, String ToolTip, String FieldText)
{
DialogReadString dialog = new DialogReadString(new javax.swing.JFrame(), true);
dialog.setLocationRelativeTo(null);
dialog.SetVals(Title, FieldName, ToolTip, FieldText);
dialog.setVisible(true);
if (dialog.getReturnStatus() == DialogReadString.RET_CANCEL)
    return null;
else
    return(dialog.getField());
}
//---------------------------------------------------------------------
static private Image getIcon()
{
//ImageIcon Ic=new ImageIcon( );    
//ImageIcon PDIcon=new ImageIcon(Ic.getClass().getResource("/resources/LogoProdoc.jpg"));
ImageIcon PDIcon=new ImageIcon("/resources/LogoProdoc.jpg");
return PDIcon.getImage();
}
//---------------------------------------------------------------------
/**
 * Refresh the list of documents
 * called after changing folder or adding, modifying or deleting a document
 */
private void RefreshDocs()
{
try {
    DocsContained = new PDTableModel();
    DocsContained.setDrv(MainWin.getSession());
    FoldAct.getListDirectDescendList(getActFolderId());
    PDDocs Doc = new PDDocs(getSession());
    Record R1=Doc.getRecordStruct();
    DocsContained.setListFields(Doc.getRecordStruct());
    DocsContained.setCursor(Doc.getListContainedDocs(FoldAct.getPDId()));
    DocsTable.setModel(DocsContained);
    DocsTable.getColumnModel().removeColumn(DocsTable.getColumnModel().getColumn(13));
    DocsTable.getColumnModel().removeColumn(DocsTable.getColumnModel().getColumn(12));
    DocsTable.getColumnModel().removeColumn(DocsTable.getColumnModel().getColumn(11));
    DocsTable.getColumnModel().removeColumn(DocsTable.getColumnModel().getColumn(10));
    DocsTable.getColumnModel().removeColumn(DocsTable.getColumnModel().getColumn(9));
    DocsTable.getColumnModel().removeColumn(DocsTable.getColumnModel().getColumn(8));
    DocsTable.getColumnModel().removeColumn(DocsTable.getColumnModel().getColumn(7));
    DocsTable.getColumnModel().removeColumn(DocsTable.getColumnModel().getColumn(6));
    DocsTable.getColumnModel().removeColumn(DocsTable.getColumnModel().getColumn(5));
    DocsTable.getColumnModel().removeColumn(DocsTable.getColumnModel().getColumn(0));
//   0 4 5 7 8 9 10 11 12
} catch (PDException ex)
    {
    Message(DrvTT(ex.getLocalizedMessage()));
    }
}
//---------------------------------------------------------------------
static protected int Execute(String Doc)
{
try {
String Orders[]= {"xdg-open", Doc};
String OS=System.getProperty("os.name");
if (OS.contains("Win"))
    {
    Orders[0]="explorer";
    Orders[1]="\""+Doc+"\"";
    }
else if (OS.contains("OS X") || OS.contains("Mac"))
    Orders[0]="open";
Runtime.getRuntime().exec(Orders);
} catch (Exception ex)
    {
    Message(ex.getLocalizedMessage());
    }
return(0);
}
//---------------------------------------------------------------------
private String HtmlDesc(PDFolders FoldAct) throws PDException
{
StringBuilder Html=new StringBuilder("<html><b>"+FoldAct.getTitle()+"</b> ("+FoldAct.getFolderType() +") : "+FormatDate(FoldAct.getPDDate())+ "<hr> ACL="+FoldAct.getACL());
Record Rec=FoldAct.getRecSum();
Rec.initList();
Attribute Attr=Rec.nextAttr();
while (Attr!=null)
    {
    if (!List.contains(Attr.getName()))
        {
        Html.append("<br><b>").append(DrvTT(Attr.getUserName())).append("= </b>");
        if (Attr.getType()==Attribute.tTHES)
            {
            if (Attr.isMultivalued())   
                {
                TreeSet ListTerms = Attr.getValuesList();
                PDThesaur Term=new PDThesaur(Session);
                for (Iterator iterator = ListTerms.iterator(); iterator.hasNext();)
                    {
                    Term.Load((String)iterator.next());
                    Html.append(Term.getName());
                    if (iterator.hasNext())
                        Html.append(Attribute.StringListSeparator);    
                    }
                }
            else
                {
                PDThesaur Term=new PDThesaur(Session);
                if (Attr.getValue()!=null)
                    {
                    Term.Load((String)Attr.getValue());
                    Html.append(Term.getName());
                    }
                }
            }
        else
            Html.append(Attr.Export());
        }
    Attr=Rec.nextAttr();
    }
Html.append("</html>");
return(Html.toString());
}
//---------------------------------------------------------------------
/**
 * 
 * @param Text
 * @return
 */
static public String DrvTT(String Text)
{
if (getSession()==null)
    return( DriverGeneric.DefTT(Text) );
else
    return( getSession().TT(Text) );
}
//----------------------------------------------------------
/**
 * 
 * @param Text
 * @return
 */
static public String TT(String Text)
{
if (getSession()==null)
    return( DriverGeneric.DefTT(Text) );
else
    return( getSession().TT(Text) );
}
//---------------------------------------------------------------------
/**
 * @return the formatterTS
 */
public static SimpleDateFormat getFormatterTS()
{
if (formatterTS==null)
    {
    try {
        formatterTS = new SimpleDateFormat(getSession().getPDCust().getTimeFormat());
    } catch (PDException ex)
        {
        formatterTS = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        }
    }
return formatterTS;
}
//---------------------------------------------------------------------

/**
 * @return the formatterDate
 */
public static SimpleDateFormat getFormatterDate()
{
if (formatterDate==null)
    {
    try {
        formatterDate = new SimpleDateFormat(getSession().getPDCust().getDateFormat());
    } catch (PDException ex)
        {
        formatterDate = new SimpleDateFormat("yyyy-MM-dd");
        }
    }
return formatterDate;
}
//---------------------------------------------------------------------
/**
 * @return the formatTS
 */
public static String getFormatTS()
{
try {
return (getSession().getPDCust().getTimeFormat() );
}  catch (PDException ex)
    {
    return("yyyy-MM-dd HH:mm:ss");
    }
}
//---------------------------------------------------------------------
/**
 * @return the formatDate
 */
public static String getFormatDate()
{
try {
return(getSession().getPDCust().getDateFormat());
} catch (PDException ex)
    {
    return("yyyy-MM-dd");
    }
}
//---------------------------------------------------------------------
/**
 * @return the formFacTS
 * @throws Exception 
 */
public static DefaultFormatterFactory getFormFacTS() throws Exception
{
if (formFacTS==null)
    {
//    formFacTS = new DefaultFormatterFactory(new MaskFormatter(MainWin.getFormatTS()));
    formFacTS = new DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat((MainWin.getFormatTS()))));
    }
return formFacTS;
}
//---------------------------------------------------------------------
/**
 * @return the formFacDate
 * @throws Exception
 */
public static DefaultFormatterFactory getFormFacDate() throws Exception
{
if (formFacDate==null)
    {
//    formFacDate = new DefaultFormatterFactory(new MaskFormatter(MainWin.getFormatDate()));
    formFacDate = new DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat((MainWin.getFormatDate()))));
    }
return formFacDate;
}
//---------------------------------------------------------------------
static protected String getLang()
{
try {
    return(getSession().getPDCust().getLanguage());
} catch (PDException ex)
    {
    return("EN");
    }
}
//---------------------------------------------------------------------
static protected String OSSep()
{
return(File.separator);
}
//---------------------------------------------------------------------
static public String getTmp()
{
String Tmp=System.getProperty("java.io.tmpdir");
return(Tmp);  
}
//---------------------------------------------------------------------
/**
 * Used in mainWin.title and About form
 * @return the actual ProdocSwing Version
 */
static public String getVersion()
{
return("3.0.2");  
}
//---------------------------------------------------------------------

/**
 * Exports a full tree recursively
 * @param FoldAct OPD Folder to start exporting
 * @param SelFile Destination Folder to export
 * @param IsOneLevel When tru, the OPD folder and contained Docs (if IncDocs), are exported 
 * @param IncMetadata when true, include metadata in the export
 * @param IncDocs  when true, include docs in the export
 */
private void Export(PDFolders FoldAct, String SelFolder, boolean IsOneLevel, boolean IncMetadata, boolean IncDocs) throws Exception
{
String Destpath=SelFolder+File.separatorChar;
File SOFolder=new File(Destpath+FoldAct.getTitle());
SOFolder.mkdir();
ExpFolds++;
if (IncMetadata)
    {
    PrintWriter PW = new PrintWriter(Destpath+FoldAct.getTitle()+".opd");
    PW.print(FoldAct.StartXML());    
    PW.print(FoldAct.toXML());
    PW.print(FoldAct.EndXML());    
    PW.flush();
    PW.close();
    }
if (IncDocs)    
    {
    PDDocs Doc = new PDDocs(FoldAct.getDrv());    
    Cursor ListDocs=Doc.getListContainedDocs(FoldAct.getPDId());
    Record Res=FoldAct.getDrv().NextRec(ListDocs);
    PDDocs ExpDoc=new PDDocs(FoldAct.getDrv());
    while (Res!=null)
        {
        ExpDoc.assignValues(Res);    
        ExpDoc.ExportXML(SOFolder.getAbsolutePath(), false);
        ExpDocs++;    
        Res=FoldAct.getDrv().NextRec(ListDocs);
        }
    FoldAct.getDrv().CloseCursor(ListDocs);
    }
if (!IsOneLevel)    
    {
    HashSet ListFolder = FoldAct.getListDirectDescendList(FoldAct.getPDId());
    PDFolders ChildFold=new PDFolders(FoldAct.getDrv());
    for (Iterator it = ListFolder.iterator(); it.hasNext();)
        {
        String ChildId=(String)it.next();
        ChildFold.LoadFull(ChildId);
        Export(ChildFold, SOFolder.getAbsolutePath(), IsOneLevel, IncMetadata, IncDocs);
        }
    }    
}
//---------------------------------------------------------------------
/**
private void Import(PDFolders FoldAct, String OriginPath, boolean IsOneLevel, boolean IncludeMetadata, boolean IncludeDocs, String FoldType, String DocType, boolean Strict) throws PDException
{
PDFolders NewFold=new PDFolders(FoldAct.getDrv(), FoldType); 
if (OriginPath.lastIndexOf(File.separatorChar)==OriginPath.length()-1) // ends with separtos
   OriginPath=OriginPath.substring(0, OriginPath.length()-1);
boolean FoldExist=false;
if (!Strict)
    {
    String Name=OriginPath.substring(OriginPath.lastIndexOf(File.separatorChar)+1);
    try {
    String IdFold=NewFold.GetIdChild(FoldAct.getPDId(), Name);
    NewFold.Load(IdFold);
    FoldExist=true;
    } catch( PDException ex)
        { // don't exits
        }
    }
if (Strict || (!Strict && !FoldExist))
    {
    if (IncludeMetadata)   
        {
        try{    
        NewFold=NewFold.ProcessXML(new File(OriginPath+".opd"), FoldAct.getPDId()); 
        } catch (PDException ex)
            {
            throw new PDException(ex.getLocalizedMessage()+"->"+OriginPath+".opd");    
            }
        }   
    else
        {
        String Name=OriginPath.substring(OriginPath.lastIndexOf(File.separatorChar)+1);
        NewFold.setTitle(Name);
        NewFold.setParentId(FoldAct.getPDId());   
        NewFold.insert();
        }
    }
ExpFolds++;
File ImpFold=new File(OriginPath);
File []ListOrigin=ImpFold.listFiles();
ArrayList DirList=new ArrayList(5);
for (File ListElement : ListOrigin)
    {
    if (ListElement.isDirectory())
        {
        if (!IsOneLevel)
            DirList.add(ListElement);
        continue;
        }
    if (IncludeDocs)
        {
        if (ListElement.getName().endsWith(".opd"))
            {
            if (IncludeMetadata)
                {
                try {
                    ExpDocs+=getSession().ProcessXML(ListElement, NewFold.getPDId());
                } catch (PDException ex)
                    {
                    throw new PDException(ex.getLocalizedMessage()+"->"+ListElement.getAbsolutePath());    
                    }
                }
            }
        else
            {
            if (!IncludeMetadata)
                {
                PDDocs NewDoc=new PDDocs(FoldAct.getDrv(), DocType);
                NewDoc.setTitle(ListElement.getName());
                NewDoc.setFile(ListElement.getAbsolutePath());
                NewDoc.setDocDate(new Date(ListElement.lastModified()));
                NewDoc.setParentId(NewFold.getPDId());
                NewDoc.insert();
                ExpDocs++;
                }
            }
        }
    }
ListOrigin=null; 
for (int i = 0; i < DirList.size(); i++)
    {
    File SubDir = (File) DirList.get(i);
    Import(NewFold, SubDir.getAbsolutePath(), IsOneLevel, IncludeMetadata, IncludeDocs, FoldType, DocType, Strict);    
    }
}
***/
//---------------------------------------------------------------------

private void ImportExt(PDFolders FoldAct, String OriginPath, boolean DeleteAfter, String Format, String DefFoldType, String DateFormat, String TimeStampFormat) throws PDException
{
PDFolders NewFold=new PDFolders(FoldAct.getDrv(), DefFoldType);   
//HashSet ChildF=NewFold.getListDirectDescendList(FoldAct.getPDId());
String Name=OriginPath.substring(OriginPath.lastIndexOf(File.separatorChar)+1);
try {
String IdFold=NewFold.GetIdChild(FoldAct.getPDId(), Name);
NewFold.Load(IdFold);
} catch( PDException ex)
    {
    NewFold.setTitle(Name);
    NewFold.setParentId(FoldAct.getPDId());   
    NewFold.insert();
    }
ExpFolds++;
File ImpFold=new File(OriginPath);
File []ListOrigin=ImpFold.listFiles();
ArrayList DirList=new ArrayList(5);
File ImageFile=null;
for (File ListElement : ListOrigin)
    {
    if (ListElement.isDirectory())
        {
        DirList.add(ListElement);
        continue;
        }
    if (ListElement.getName().toLowerCase().endsWith(".xml") && Format.equals("Abby"))
        {
        ExpDocs++;
        try {
            ImageFile=PDDocs.ProcessXMLAbby(getSession(), ListElement, NewFold.getPDId(), DateFormat, TimeStampFormat);
        } catch (PDException ex)
            {
            throw new PDException(ex.getLocalizedMessage()+"->"+ListElement.getAbsolutePath());
            }
        if (DeleteAfter)
            {
            if (ImageFile!=null)
                ImageFile.delete();
            ListElement.delete();
            }
        }
    else if (ListElement.getName().toLowerCase().endsWith(".txt") && Format.equals("Kofax"))
        {
        ExpDocs++;
        try {
            ImageFile=PDDocs.ProcessXMLKofax(getSession(), ListElement, NewFold.getPDId(), DateFormat, TimeStampFormat);
        } catch (PDException ex)
            {
            throw new PDException(ex.getLocalizedMessage()+"->"+ListElement.getAbsolutePath());
            }
        if (DeleteAfter)
            {
            if (ImageFile!=null)
                ImageFile.delete();
            ListElement.delete();
            }
        }
    }
ListOrigin=null; // to help gc and save memory during recursivity
for (Object DirList1 : DirList)
    {
    File SubDir = (File) DirList1;
    ImportExt(NewFold, SubDir.getAbsolutePath(), DeleteAfter, Format, DefFoldType, DateFormat, TimeStampFormat);
    if (DeleteAfter)
        SubDir.delete();
    }
}
//---------------------------------------------------------------------
static protected void AddExec(String FileName)
{
ExecFiles.add(FileName);  
File f=new File(FileName);
f.setReadOnly();
}
//---------------------------------------------------------------------
static private void DestroyExec()
{
for (Iterator it = ExecFiles.iterator(); it.hasNext();)
    {
    try {
    String FileName = (String)it.next();
    File f=new File(FileName);
    f.setWritable(true);
    f.delete();
    } catch (Exception ex)
        {   
        }
    } 
}
//---------------------------------------------------------------------
private void SetMenu()
{
try {    
PDRoles R=MainWin.getSession().getUser().getRol();
ACLMenuItem.setVisible(R.isAllowCreateAcl() || R.isAllowMaintainAcl());
AuthentMenuItem.setVisible(R.isAllowCreateAuth()  || R.isAllowMaintainAuth());
CustomMenuItem.setVisible(R.isAllowCreateCustom()  || R.isAllowMaintainCustom());
GroupMenuItem.setVisible(R.isAllowCreateGroup()  || R.isAllowMaintainGroup());
MimeTypeMenuItem.setVisible(R.isAllowCreateMime()  || R.isAllowMaintainMime());
ObjDefMenuItem.setVisible(R.isAllowCreateObject()  || R.isAllowMaintainObject());
ReposMenuItem.setVisible(R.isAllowCreateRepos()  || R.isAllowMaintainRepos());
RolMenuItem.setVisible(R.isAllowCreateRole()  || R.isAllowMaintainRole());
UserMenuItem.setVisible(R.isAllowCreateUser()  || R.isAllowMaintainUser());
TaskCronMenuItem.setVisible(R.isAllowCreateTask()  || R.isAllowMaintainTask());
TaskEvenMenuItem.setVisible(R.isAllowCreateTask()  || R.isAllowMaintainTask());
TaskExecMenuItem.setVisible(R.isAllowCreateTask()  || R.isAllowMaintainTask());
TaskEndedMenuItem.setVisible(R.isAllowCreateTask()  || R.isAllowMaintainTask());
TraceMenuItem.setVisible(R.isAllowCreateObject()  || R.isAllowMaintainObject());
ImportPackage.setVisible(R.isAllowCreateAcl()&&R.isAllowCreateAuth()&&R.isAllowCreateCustom()
                        &&R.isAllowCreateGroup()&&R.isAllowCreateMime()&& R.isAllowCreateObject()
                        && R.isAllowCreateRepos()&& R.isAllowCreateRole()&& R.isAllowCreateUser()
                        &&R.isAllowCreateTask()&& R.isAllowCreateFolder() &&R.isAllowCreateDoc()
                        && R.isAllowCreateThesaur());
AddFold.setVisible(R.isAllowCreateFolder());
AddFoldAdvanced.setVisible(R.isAllowCreateFolder());
ImportFold.setVisible(R.isAllowCreateFolder());
ModFold.setVisible(R.isAllowMaintainFolder());
ModFoldAdvanced.setVisible(R.isAllowMaintainFolder());
DelFold.setVisible(R.isAllowMaintainFolder());
AddDoc.setVisible(R.isAllowCreateDoc());
AddDocAdvanced.setVisible(R.isAllowCreateDoc());
ImportDoc.setVisible(R.isAllowCreateDoc());
PaperBin.setVisible(R.isAllowCreateDoc() && R.isAllowMaintainDoc());
ModDocAdvanced.setVisible(R.isAllowMaintainDoc());
CheckOut.setVisible(R.isAllowMaintainDoc());
CancelCheckout.setVisible(R.isAllowMaintainDoc());
CheckIn.setVisible(R.isAllowMaintainDoc());
CheckOut.setVisible(R.isAllowMaintainDoc());
DelDoc.setVisible(R.isAllowMaintainDoc());
ImportExtFold.setVisible(R.isAllowCreateFolder() && R.isAllowCreateDoc());
ImportExtRIS.setVisible(R.isAllowCreateDoc());
} catch (Exception ex)
    {
    Message(ex.getLocalizedMessage());
    }
}
//---------------------------------------------------------------------
/**
* @return the IO_OSFolder
*/
public static String getIO_OSFolder()
{
return IO_OSFolder;
}
//---------------------------------------------------------------------

/**
* @param aIO_OSFolder the IO_OSFolder to set
*/
public static void setIO_OSFolder(String aIO_OSFolder)
{
IO_OSFolder = aIO_OSFolder;
}
//---------------------------------------------------------------------


}