/*
 * MainFrame.java
 *
 *  iReport  --  Visual designer for generating JasperReports Documents
 *  Copyright (C) 2002-2003  Giulio Toffoli gt@businesslogic.it
 *
 *  This program is free software; you can redistribute  and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  Giulio Toffoli
 *  Via T.Aspetti, 233
 *  35100 Padova ITALY
 *  gt@businesslogic.it
 *
 * Created on 5 febbraio 2003, 12.45
 *
 * Modified on 5 May 2005: rl
 * Added Synchronizing Report Name To Filename when saving the file
 *
 */

package it.businesslogic.ireport.gui;

import it.businesslogic.ireport.gui.event.*;
import it.businesslogic.ireport.gui.library.*;
import it.businesslogic.ireport.gui.locale.*;
import it.businesslogic.ireport.undo.*;
import it.businesslogic.ireport.*;
import it.businesslogic.ireport.gui.command.FormatCommand;
import it.businesslogic.ireport.util.*;
import javax.swing.tree.*;
import java.util.*;
import java.io.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.Point;

import jcmdline.*;

import org.apache.xerces.parsers.DOMParser;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.NamedNodeMap;

import org.xml.sax.SAXException;
/**
 * This class is the core of the GUI of iReport. From this class we control all
 * events related to the open and close files, handling of properties files,
 * handling JMDIDestopPane, Menus....
 *
 * @author  Administrator
 */
public class MainFrame extends javax.swing.JFrame implements ReportListener, Runnable, LanguageChangedListener {
    
    public int docCounter=0;
    
    private Thread checkModifiedFielsThread = null;
    public static String constTitle = "iReport 0.5.0 ";
    private String homeDirectory = ".";
    private java.util.Vector toolBarControls;
    private java.util.HashMap pluginEntries;
    private ElementPropertiesDialog elementPropertiesDialog;
    private EventsForm eventsForm;
    private ValuesDialog valuesDialog;
    private GroupsDialog groupsDialog;
    private BandsDialog bandsDialog;
    private FontsDialog fontsDialog;
    private LocaleResourceFilesDialog localeFilesDialog;
    private ReportQueryDialog reportQueryDialog;
    private PluginConfigurationDialog pluginConfigurationDialog = null;
    private ToolbarFormatPanel jToolbarFormatPanel = null;
    private ToolbarConnectionPanel jToolbarConnectionPanel = null;   
    
    private Vector ttfFonts;
    private Vector connections;
    private Properties properties;
    private Vector recentFilesList;
    private Vector favoriteFilesList;
    private Vector recentProjectsList;
    private Vector clipboards[];
    private Vector classpath;
    private it.businesslogic.ireport.ReportElement styleClipboards[];
    private int activeClipboard = 0;
    private int activeStyleClipboard = 0;
    private boolean catchFormActivated = true;
    private boolean embeddedIreport = false;
    
    private LibraryPanel libraryPanel = null;
    
    public static ReportClassLoader reportClassLoader = null;
    
    private static MainFrame mainInstance =  null;
    
    private boolean dontHandleEvent;
    
    private StringBuffer outputBuffer;
    
    private javax.swing.event.EventListenerList listenerList =  null;
    
    /**
     * Variable currentZoomFactor is used to remember the zoomFactor
     * while reloading a file after changing it from outside or
     * via the option Edit XML source.
     */
    private double currentZoomFactor = 1.0;
    
    public static String IREPORT_HOME_DIR;
    
    public static String IREPORT_USER_HOME_DIR;
    
    public static String IREPORT_TMP_DIR;
    
    public static String IREPORT_RECENT_FILES_FILE;
    
    public static String IREPORT_FAVORITE_FILES_FILE;
    
    public static String IREPORT_RECENT_PROJECTS_FILE;
    
    public static String IREPORT_CONFIG_FILE;
    
    public static String IREPORT_DEFAULT_HOME_DIR;
    
    public static final int IREPORT_JAVA_VIEWER = 1;
    
    public static final int IREPORT_PDF_VIEWER = 2;
    
    public static final int IREPORT_HTML_VIEWER = 4;
    
    public static final int IREPORT_XLS_VIEWER = 8;
    
    public static final int IREPORT_CSV_VIEWER = 16;
    
    public static final int IREPORT_JASPER_VIEWER = 32;
    
    public static final int IREPORT_TXT_VIEWER = 64;
    
    /**
     * Return the main instance of the MainFrame. This method assume that there is only
     * one iReport instanced per JVM, so the first istance of MainFrame is the only possible.
     */
    public static MainFrame getMainInstance() {
        return mainInstance;
    }
    
    static {
        
        reportClassLoader = new ReportClassLoader();
        
    } //end static section for simple init
        /*
         *  You can override ireport home setting ireport.home variable or using line command options.
         *
         */
    public void setiReportPaths(String ireport_home, String ireport_user_home, String ireport_tmp_dir) {
        
        // Setting User home directory
        if ( ireport_user_home == null) {
            ireport_user_home =  System.getProperty("user.home") + File.separator + ".ireport";
            IREPORT_USER_HOME_DIR = ireport_user_home;
            
            //setHomeDirectory(Misc.nvl(System.getProperty("ireport.home"), IREPORT_DEFAULT_HOME_DIR));
        }
        else {
            if (ireport_user_home.endsWith(File.separator)) {
                ireport_user_home = ireport_user_home.substring(0, ireport_user_home.length()-1);
            }
            IREPORT_USER_HOME_DIR = ireport_user_home;
        }
        
        // Setting iReport directory
        if ( ireport_home == null) {
            ireport_home =  System.getProperty("ireport.home",".");
            IREPORT_HOME_DIR = ireport_home;
            setHomeDirectory(IREPORT_HOME_DIR);
        }
        else {
            if (ireport_home.endsWith(File.separator)) {
                ireport_home = ireport_home.substring(0, ireport_home.length()-1);
            }
            IREPORT_HOME_DIR = ireport_home;
        }
        
        // Setting temp dir...
        if (IREPORT_TMP_DIR == null || IREPORT_TMP_DIR.trim().length() == 0) {
            if ( ireport_tmp_dir == null) {
                ireport_user_home =  System.getProperty("user.home") + File.separator + ".ireport";
                IREPORT_TMP_DIR = ireport_home;
                
                //setHomeDirectory(Misc.nvl(System.getProperty("ireport.home"), IREPORT_DEFAULT_HOME_DIR));
            }
            else {
                if (ireport_tmp_dir.endsWith(File.separator)) {
                    ireport_tmp_dir = ireport_tmp_dir.substring(0, ireport_tmp_dir.length()-1);
                }
                IREPORT_TMP_DIR = ireport_tmp_dir;
            }
        }
        
        IREPORT_DEFAULT_HOME_DIR = IREPORT_HOME_DIR;
        setHomeDirectory(IREPORT_HOME_DIR);
        
        IREPORT_RECENT_FILES_FILE = IREPORT_USER_HOME_DIR + File.separator + "recentFiles.xml";
        IREPORT_RECENT_PROJECTS_FILE = IREPORT_USER_HOME_DIR + File.separator + "recentProjects.xml";
        IREPORT_FAVORITE_FILES_FILE = IREPORT_USER_HOME_DIR + File.separator + "favoriteFiles.xml";
        IREPORT_CONFIG_FILE = IREPORT_USER_HOME_DIR + File.separator + "config.xml";
        
        //System.out.println(IREPORT_DEFAULT_HOME_DIR);
        //System.out.println(IREPORT_HOME_DIR);
        try {
            //nothing in here yet.
        }
        catch(Throwable e) {
            e.printStackTrace(System.err);
        }
    }
    
    public MainFrame() {
        this(new HashMap());
    }
    /** Creates new form MainFrame */
    public MainFrame(Map args) {
        
        if (mainInstance==null) {
            mainInstance = this;
        }
        
        SplashDialog sp = null;
        
        if (args.get("splash") != null)
        {
         sp = (SplashDialog)args.get("splash"); 
        }
        
        
        properties = new Properties();
        outputBuffer = new StringBuffer();
        connections = new Vector();
        recentFilesList = new Vector();
        favoriteFilesList = new Vector();
        recentProjectsList = new Vector();
        pluginEntries = new java.util.HashMap();
        
        setiReportPaths((String)args.get("ireport-home"),
        (String)args.get("user-home"),
        (String)args.get("tmp-dir"));
        
        // Set the classloader...
        
       
        //Thread.currentThread().setContextClassLoader( reportClassLoader );
        if (sp!=null) sp.updateLoadingStatus(10,"Loading iReport configuration");
        if (args.containsKey("config-file")) {
            loadiReportConfiguration((String)args.get("config-file"));
        }
        else {
            loadiReportConfiguration();
        }
        
        if (args.get("beanClass") != null)
        {
            getProperties().put("beanClass",(String)args.get("beanClass"));
        }
        
        Misc.setPLAF( properties.getProperty("LookAndFeel") );
        
        if (sp!=null) sp.updateLoadingStatus(20,"Setting locale");
        it.businesslogic.ireport.util.I18n.setCurrentLocale( properties.getProperty("Language"), properties.getProperty("Country") );
        
        if (sp!=null) sp.updateLoadingStatus(30,"Init main frame components");
        jToolbarFormatPanel = new ToolbarFormatPanel(this);
        jToolbarConnectionPanel = new ToolbarConnectionPanel(this);
        
        initComponents();
        
        this.jCheckBoxMenuItemGrid.setSelected( properties.getProperty("showGrid","false").equals("true") );
        this.jCheckBoxMenuItemSnapToGrid.setSelected( properties.getProperty("snapToGrid","false").equals("true") );
        this.jCheckBoxMenuItemEMM.setSelected( properties.getProperty("EMM","false").equals("true") );
        
        this.jListThreads.setModel(new javax.swing.DefaultListModel());
        I18n.addOnLanguageChangedListener( this );
        
        if (sp!=null) sp.updateLoadingStatus(60,"Loading fonts");
        this.ttfFonts = FontListLoader.loadTTFFonts();
        
        
        
        if (ttfFonts == null) ttfFonts = new Vector();
        
        System.setProperty("org.xml.sax.driver","org.apache.xerces.parsers.SAXParser");
        
        if (sp!=null) sp.updateLoadingStatus(75,"Configuring GUI components");
        //jMDIDesktopPane.addInternalFrameActivatedListener(this);
       
        this.setTitle( constTitle+ " - (c) 2002-2005 by Giulio Toffoli");

        toolBarControls = new java.util.Vector();
        
        elementPropertiesDialog = new ElementPropertiesDialog(this,false);
        elementPropertiesDialog.updateFonts(ttfFonts);
        valuesDialog = new ValuesDialog(this,false);
        groupsDialog = new GroupsDialog(this,false);
        bandsDialog = new BandsDialog(this,false);
        fontsDialog = new FontsDialog(this,false);
        reportQueryDialog = new ReportQueryDialog(this,false);
        localeFilesDialog = new LocaleResourceFilesDialog(this,false);
        eventsForm = new EventsForm();
        
        jNumberComboBoxZoom.addValueChangedListener(new ValueChangedListener() {
            public void valueChanged(ValueChangedEvent evt) {
                jNumberComboBoxZoomValueChanged(evt);
            }
        });
        
        //user pressed enter
        jNumberComboBoxZoom.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                //simulate focus lost to force zoom update
                jNumberComboBoxZoom.focusLost(new FocusEvent(MainFrame.this, FocusEvent.COMPONENT_SHOWN));
            }
        });
        
        jMDIDesktopPane.addInternalFrameActivatedListener(new InternalFrameActivatedListener() {
            public void internalFrameActivated( InternalFrameActivatedEvent evt) {
                jMDIDesktopPaneInternalFrameActivated(evt);
            }
        });
        
        toolBarControls.addElement( this.jButtonNew);
        toolBarControls.addElement( this.jButtonOpen);
        toolBarControls.addElement( this.jButtonSave);
        toolBarControls.addElement( null);
        toolBarControls.addElement( this.jButtonCut);
        toolBarControls.addElement( this.jButtonCopy);
        toolBarControls.addElement( this.jButtonPaste);
        toolBarControls.addElement( null);
        toolBarControls.addElement( this.jToggleButtonPointer);
        toolBarControls.addElement( this.jToggleButtonLineTool);
        toolBarControls.addElement( this.jToggleButtonRectTool);
        toolBarControls.addElement( this.jToggleButtonRectRoundTool);
        toolBarControls.addElement( this.jToggleButtonEllipseTool);
        toolBarControls.addElement( this.jToggleButtonImageTool);
        toolBarControls.addElement( this.jToggleButtonStaticTextTool);
        toolBarControls.addElement( this.jToggleButtonTextFieldTool);
        toolBarControls.addElement( this.jToggleButtonSubreportTool);
        toolBarControls.addElement( this.jToggleButtonChartTool);
        toolBarControls.addElement( this.jToggleButtonBarcodeTool);
        toolBarControls.addElement( null);
        toolBarControls.addElement( this.jButtonParameters);
        toolBarControls.addElement( this.jButtonGroups);
        toolBarControls.addElement( this.jButtonBands);
        toolBarControls.addElement( this.jButtonDatabase);
        toolBarControls.addElement( null);
        toolBarControls.addElement( this.jPanelZoom);
        toolBarControls.addElement( null);
        toolBarControls.addElement( this.jButtonCompiler);
        
        toolBarControls.addElement(this.jButtonRun1);
        toolBarControls.addElement(this.jButtonRun2);
        toolBarControls.addElement( null);
        //toolBarControls.addElement(this.jButtonAlignLeft);
        //toolBarControls.addElement(this.jButtonAlignCenter);
        //toolBarControls.addElement(this.jButtonAlignRight);
        //toolBarControls.addElement(this.jButtonAlignJustify);
        
        jNumberComboBoxZoom.addEntry("50%",50);
        jNumberComboBoxZoom.addEntry("75%",75);
        jNumberComboBoxZoom.addEntry("100%",100);
        jNumberComboBoxZoom.addEntry("150%",150);
        jNumberComboBoxZoom.addEntry("200%",200);
        jNumberComboBoxZoom.addEntry("400%",400);
        jNumberComboBoxZoom.addEntry("800%",800);
        jNumberComboBoxZoom.addEntry("Width",100);
        jNumberComboBoxZoom.addEntry("Height",100);
        jNumberComboBoxZoom.addEntry("Whole page",100);
        //jNumberComboBoxZoom.addEntry("Fit to page",100); // deactivate since July 16 2004
        
        //java.awt.Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        //this.setSize(dim);
        
        if (sp!=null) sp.updateLoadingStatus(80,"Loading available font family names");
        String[] fontFamilies = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
        for (int i=0; i<fontFamilies.length; ++i)
        {
            jComboBoxFont.addItem(fontFamilies[i]); 
            if (fontFamilies[i].equals("Arial"))
            {
                jComboBoxFont.setSelectedIndex(i);
            }
        }
        
        jNumberComboBoxSize.addEntry("3",3);
        jNumberComboBoxSize.addEntry("5",5);
        jNumberComboBoxSize.addEntry("8",8);
        jNumberComboBoxSize.addEntry("10",10);
        jNumberComboBoxSize.addEntry("12",12);
        jNumberComboBoxSize.addEntry("14",14);
        jNumberComboBoxSize.addEntry("18",18);
        jNumberComboBoxSize.addEntry("24",24);
        jNumberComboBoxSize.addEntry("36",36);
        jNumberComboBoxSize.addEntry("48",48);
        
        jNumberComboBoxSize.setSelectedIndex(5);
        
        DefaultTreeSelectionModel dtsm = (DefaultTreeSelectionModel)jTreeDocument.getSelectionModel();
        dtsm.setSelectionMode( DefaultTreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION );
        
        jPanelToolBarComponentResized(new java.awt.event.ComponentEvent(jPanelToolBar,0));
        
        // This try is of java <1.4 comatibility
        try {
            this.setExtendedState(MAXIMIZED_BOTH);
        } catch (java.lang.NoSuchMethodError ex){
            /* do nothing */
        }
        
        java.awt.Image def = Misc.loadImageFromResources("it/businesslogic/ireport/icons/layout/img.gif");
        try {
            java.awt.MediaTracker mt = new java.awt.MediaTracker( new javax.swing.JPanel() );
            mt.addImage(def,0);
            mt.waitForID(0);
        } catch (Exception ex) {
            /* Do nothing */
        }
        ImageReportElement.setImgDef(def);
        //jNumberComboBoxZoom.setPostfix("%");
        
        javax.swing.tree.DefaultMutableTreeNode root = new javax.swing.tree.DefaultMutableTreeNode("Opened files");
        javax.swing.tree.DefaultMutableTreeNode rootDoc = new javax.swing.tree.DefaultMutableTreeNode("Document");
        javax.swing.tree.DefaultTreeModel model = new javax.swing.tree.DefaultTreeModel(root);
        javax.swing.tree.DefaultTreeModel modelDoc = new javax.swing.tree.DefaultTreeModel(rootDoc);
        
        javax.swing.ToolTipManager.sharedInstance().registerComponent(jTreeFiles);
        jTreeFiles.setModel( model );
        jTreeFiles.setCellRenderer( new ProjectExplorerTreeCellRenderer());
        
        jTreeDocument.setModel( modelDoc );
        jTreeDocument.setCellRenderer( new DocumentStructureTreeCellRenderer());
        
        libraryPanel = new LibraryPanel();
        jTabbedPaneExplorer.addTab("Library",libraryPanel);
        
        if (sp!=null) sp.updateLoadingStatus(85,"Loading file lists");
        loadFileLists();
        
        updateRecentFileMenu(jMenuRecentFiles, getRecentFilesList() );
        updateRecentProjectMenu(jMenuRecentProjects, getRecentProjectsList());
        
        //IRCompilerDocument doc = new IRCompilerDocument();
        
        //this.jEditorPaneOutput.setDocument(doc );
        this.jEditorPaneOutput.setContentType("text/html");
        
        this.jEditorPaneOutput.addHyperlinkListener( new javax.swing.event.HyperlinkListener() {
            public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e) {
                if (e.getEventType() == javax.swing.event.HyperlinkEvent.EventType.ACTIVATED) {
                    if (!parseError(e.getURL()))
                        JOptionPane.showMessageDialog(MainFrame.this," HyperlinkEvent " + e.getURL() );
                    
                }
            }
        });
        
        jMenuItemUndo.setAccelerator( javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_Z, KeyEvent.CTRL_DOWN_MASK));
        jMenuItemRedo.setAccelerator( javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_Y, KeyEvent.CTRL_DOWN_MASK));
        jCheckBoxMenuItemEMM.setAccelerator( javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.CTRL_DOWN_MASK));
        jMenuItemCut.setAccelerator( javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.CTRL_DOWN_MASK));
        jMenuItemCopy.setAccelerator( javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK));
        jMenuItemPaste.setAccelerator( javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_DOWN_MASK));
        
        jToolbarConnectionPanel.updateConnections();
       
        clipboards = new Vector[5];
        for (int i=0; i<5; ++i) {
            clipboards[i] = new Vector();
        }
        
        styleClipboards = new it.businesslogic.ireport.ReportElement[5];
        for (int i=0; i<5; ++i) {
            styleClipboards[i] = null;
        }
        
        this.setReportViewer(this.getReportViewer());
        this.disableSaveAllSpecific();
        this.disableSaveSpecific();
        
        logOnConsole("iReport home ( " + ( (!args.containsKey("ireport-home")) ? "ireport.home system property" : "from command line") + "): "+this.IREPORT_HOME_DIR + "\n");
        logOnConsole("User home ( " + ( (!args.containsKey("user-home")) ? "user.home system property" : "from command line") + "): " + this.IREPORT_USER_HOME_DIR + "\n");
        
        logOnConsole("iReport default compile directory: " + this.getDefaultCompilationDirectory()+"\n");
        logOnConsole("iReport user home directory (iReport compiles here if there are no settings or " +
        "the user hasn't selected to compile to the report directory): " + IREPORT_DEFAULT_HOME_DIR + "\n");
        
        
        if (sp!=null) sp.updateLoadingStatus(90,"Loading plugins");
        loadPlugins(IREPORT_HOME_DIR + File.separator + "plugins"  );
        
        jToolBarText.setVisible( getProperties().getProperty("toolbarTextVisible","false").equalsIgnoreCase("true") );
        jToolBarFormat.setVisible( getProperties().getProperty("toolbarFormattingVisible","false").equalsIgnoreCase("true") );
        jToolBarConnections.setVisible( getProperties().getProperty("toolbarConnectionsVisible","true").equalsIgnoreCase("true") );
        
        jCheckBoxMenuItemElementsFormatting.setSelected( getProperties().getProperty("toolbarFormattingVisible","false").equalsIgnoreCase("true") );
        jCheckBoxMenuItemTextFormatting.setSelected( getProperties().getProperty("toolbarTextVisible","false").equalsIgnoreCase("true") );
        
        it.businesslogic.ireport.util.I18n.setCurrentLocale( properties.getProperty("Language"), properties.getProperty("Country") );
        
        if (sp!=null) sp.updateLoadingStatus(95,"Opening files");
        if (args.containsKey("files")) {
            Iterator iter = ((Collection)args.get("files")).iterator();
            while (iter.hasNext()) {
                try {
                    File f = (File)iter.next();
                    if (sp!=null) sp.updateLoadingStatus(98,"Opening " + f.getName());
                    Report report = new Report(f.getPath());
                    openNewReportWindow( report );
                } catch (Exception ex) { }
            }
        }
        
        if (sp!=null) sp.setVisible(false);
    }
    
    /**
     * Retrieve the first unused mane like untitled_report_XXX
     */
    public String getFirstNameFree() {
        JInternalFrame[] frames = jMDIDesktopPane.getAllFrames();
        
        for (int k=1; ; k++) {
            String name = "untitled_report_" + k;
            boolean found = false;
            for (int i=0; i<frames.length ; ++i) {
                if (frames[i] instanceof JReportFrame) {
                    JReportFrame jrf = (JReportFrame)frames[i];
                    if (jrf.getReport().getName().equalsIgnoreCase(name)) {
                        found = true;
                        break;
                    }
                }
            }
            if (!found) {
                return name;
            }
        }
    }
    
    
    public void setFileListActivatedFrame(JReportFrame jrf) {
        // remove the frame from the documnets list....
        DefaultTreeModel dtm = (DefaultTreeModel)jTreeFiles.getModel();
        Enumeration opened_entries = ((DefaultMutableTreeNode)dtm.getRoot()).children();
        while (opened_entries.hasMoreElements()) {
            DefaultMutableTreeNode documentEntryNode = (DefaultMutableTreeNode)opened_entries.nextElement();
            if (documentEntryNode.getUserObject() instanceof DocumentTreeEntry) {
                DocumentTreeEntry dte = (DocumentTreeEntry)documentEntryNode.getUserObject();
                if (dte.getJrf() == jrf) {
                    jTreeFiles.setSelectionPath(new TreePath(new Object[]
                    {dtm.getRoot(), documentEntryNode}));
                    jTreeFiles.updateUI();
                    break;
                }
            }
            
        }
    }
    
    public void updateMenuWindowList() {
        // Remove all menus...
        java.awt.Component[] menus = this.jMenuWindow.getMenuComponents();
        int i = 0;
        for (int k = 0;  k<menus.length ; ++k) {
            if ((menus[k] instanceof JRadioButtonMenuItemMDIFrame) &&
            ((JRadioButtonMenuItemMDIFrame)menus[k]).getFrame() != null &&
            ((JRadioButtonMenuItemMDIFrame)menus[k]).getFrame().isValid() &&
            ((JRadioButtonMenuItemMDIFrame)menus[k]).getFrame().isVisible()) {
                JRadioButtonMenuItemMDIFrame menuItem = (JRadioButtonMenuItemMDIFrame)menus[k];
                menuItem.setText( (i+1) + ". " + menuItem.getFrame().getTitle() );
                menuItem.setMnemonic((int)(((i+1)+"").charAt(0)) );
                menuItem.setFont(new java.awt.Font("Dialog", 0, 11));
                menuItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke((int)(((i+1)+"").charAt(0)),java.awt.Event.META_MASK));
                i++;
                //System.out.println("Menu "+menuItem.getText());
            }
        }
        
    }
    
    
    public void jMenuWindowListActionPerformed(java.awt.event.ActionEvent evt) {
        if (evt.getSource() != null &&
        evt.getSource() instanceof JRadioButtonMenuItemMDIFrame) {
            JRadioButtonMenuItemMDIFrame mdm = (JRadioButtonMenuItemMDIFrame)evt.getSource();
            try {
                
                mdm.getFrame().setSelected(true);
            } catch (Exception ex)
            {}
        }
        
    }
    
    public void jMDIDesktopPaneInternalFrameActivated(InternalFrameActivatedEvent evt) {
        if (evt.getJMDIFrame() != null && evt.getAction() == InternalFrameActivatedEvent.CLOSED) {
            // remove the frame from the documnets list....
            DefaultTreeModel dtm = (DefaultTreeModel)jTreeFiles.getModel();
            Enumeration opened_entries = ((DefaultMutableTreeNode)dtm.getRoot()).children();
            while (opened_entries.hasMoreElements()) {
                DefaultMutableTreeNode documentEntryNode = (DefaultMutableTreeNode)opened_entries.nextElement();
                if (documentEntryNode.getUserObject() instanceof DocumentTreeEntry) {
                    DocumentTreeEntry dte = (DocumentTreeEntry)documentEntryNode.getUserObject();
                    if (dte.getJrf() == evt.getJMDIFrame()) {
                        ((DefaultMutableTreeNode)dtm.getRoot()).remove(documentEntryNode);
                        jTreeFiles.updateUI();
                        
                        break;
                    }
                }
                
            }
            // Remove from window list...
            java.awt.Component[] menus = this.jMenuWindow.getMenuComponents();
            for (int k = menus.length-1;  k>=0 ; --k) {
                if (menus[k] instanceof JRadioButtonMenuItemMDIFrame &&
                ((JRadioButtonMenuItemMDIFrame)menus[k]).getFrame() == evt.getJMDIFrame()) {
                    this.jMenuWindow.remove(menus[k]);
                }
            }
            updateMenuWindowList();
            return;
        }
        
        if (evt.getJMDIFrame() == null) {
            this.setTitle(constTitle);
            setActiveReportForm( null );
            return;
        }
        
        
        this.setTitle(constTitle + " ["+ evt.getJMDIFrame().getTitle() + "]");
        jMDIMenuBar.restoreButtonsPosition();
        //System.out.println("Value setted!");
        if (evt.getJMDIFrame() instanceof JReportFrame) {
            
            JReportFrame jrf = (JReportFrame)evt.getJMDIFrame();
            this.jNumberComboBoxZoom.setValue(jrf.getZoomFactor()*100);
            
            // Set the fit to page value...
            setFileListActivatedFrame(jrf);
            //updateFitToPage(jrf);
            
            // Enable all buttons and menus...
            setActiveReportForm( jrf );
            
        }
        else {
            //System.out.println("Chiusetutte lengthfinestre!");
            setActiveReportForm( null );
        }
    }

    public void renewTitle(JReportFrame jrf)
    {
        this.setTitle(constTitle +
                " ["+ jrf.getReport().getName() + " "+
                jrf.getReport().getWidth()+"x"+jrf.getReport().getHeight()+" "+
                "(" + (jrf.getReport().isModified()?"Modified" : "Unchanged") + ") " +
                jrf.getReport().getFilename()+(jrf.getReport().isReadOnly()?" (READ ONLY) ":"")+
                "]");
    }
    
    public void setActiveReportForm(JReportFrame jrf)
    {
        boolean enabled = true;
        if (jrf == null)
        {
            enabled = false;
        }
        else
        {
            renewTitle(jrf);
        }
        if(jrf != null && jrf.getReport().isReadOnly())
        {
            enabled = false;
        }
        
        if (jrf != null)
        {
            java.awt.Component[] menus = this.jMenuWindow.getMenuComponents();
            for (int k = menus.length-1;  k>=0 ; --k)
            {
                if (menus[k] instanceof JRadioButtonMenuItemMDIFrame &&
                        ((JRadioButtonMenuItemMDIFrame)menus[k]).getFrame() == jrf)
                {
                    ((JRadioButtonMenuItemMDIFrame)menus[k]).setSelected(true);
                }
            }
            
        }
        
        this.elementPropertiesDialog.setJReportFrame(jrf);
        this.valuesDialog.setJReportFrame(jrf);
        this.groupsDialog.setJReportFrame(jrf);
        this.bandsDialog.setJReportFrame(jrf);
        this.fontsDialog.setJReportFrame(jrf);
        this.reportQueryDialog.setJReportFrame(jrf);
        this.libraryPanel.setJReportFrame(jrf);
        this.localeFilesDialog.setJReportFrame(jrf);
        
        updateDocumentStructureTree( jrf);
        updateUndoMenu(jrf);
        updateCutAndPasteMenu(jrf);
        // Toolbar...
        this.jButtonBands.setEnabled(enabled);
        this.jButtonDatabase.setEnabled(enabled);
        this.jButtonParameters.setEnabled(enabled);
        this.jButtonGroups.setEnabled(enabled);
        this.jButtonCompiler.setEnabled(enabled);
        this.jButtonRun1.setEnabled(enabled);
        this.jButtonRun2.setEnabled(enabled);
        
        // Enable or disable all element in toolbars...
        for (int cc = 0; cc < jToolBarText.getComponentCount(); ++cc)
        {
            java.awt.Component component = jToolBarText.getComponentAtIndex(cc);
            if (component instanceof javax.swing.JButton)
            {
                ((javax.swing.JButton)component).setEnabled( enabled );
            }
            else if (component instanceof javax.swing.JComboBox)
            {
                ((javax.swing.JComboBox)component).setEnabled( enabled );
            }
        }
        
        // Enable or disable all element in toolbars...
        for (int cc = 0; cc < jToolBarFormat.getComponentCount(); ++cc)
        {
            java.awt.Component component = jToolBarFormat.getComponentAtIndex(cc);
            if (component instanceof javax.swing.JButton)
            {
                ((javax.swing.JButton)component).setEnabled( enabled );
            }
            else if (component instanceof javax.swing.JComboBox)
            {
                ((javax.swing.JComboBox)component).setEnabled( enabled );
            }
        }
        /*
        this.jButtonAlignLeft.setEnabled(enabled);
        this.jButtonAlignCenter.setEnabled(enabled);
        this.jButtonAlignRight.setEnabled(enabled);
        this.jButtonAlignJustify.setEnabled(enabled);
         */
        
        this.jToggleButtonEllipseTool.setEnabled(enabled);
        this.jToggleButtonImageTool.setEnabled(enabled);
        this.jToggleButtonLineTool.setEnabled(enabled);
        
        this.jToggleButtonPointer.setEnabled(enabled);
        this.jToggleButtonRectRoundTool.setEnabled(enabled);
        this.jToggleButtonRectTool.setEnabled(enabled);
        this.jButtonSave.setEnabled(enabled);
        this.jToggleButtonStaticTextTool.setEnabled(enabled);
        this.jToggleButtonSubreportTool.setEnabled(enabled);
        this.jToggleButtonChartTool.setEnabled(enabled);
        this.jToggleButtonBarcodeTool.setEnabled(enabled);
        this.jToggleButtonTextFieldTool.setEnabled(enabled);
        this.jMenuItemXMLSource.setEnabled(enabled);
        this.jCheckBoxMenuItemEMM.setEnabled(enabled);
        this.jCheckBoxMenuItemGrid.setEnabled(enabled);
        this.jCheckBoxMenuItemSnapToGrid.setEnabled(enabled);
        this.jMenuAdd.setEnabled(true);
        
        this.jMenuItemBands.setEnabled(enabled);
        this.jMenuItemGroups.setEnabled(enabled);
        this.jMenuItemReportProperties.setEnabled(enabled);
        this.jMenuItemProperties.setEnabled(enabled);
        this.jMenuItemElementProperties.setEnabled(enabled);
        this.jMenuItemFields.setEnabled(enabled);
        this.jMenuItemVariables.setEnabled(enabled);
        this.jMenuItemParameters.setEnabled(enabled);
        this.jMenuItemReportQuery.setEnabled(enabled);
        this.jMenuItemReportQuery2.setEnabled(enabled);
        this.jMenuItemFonts.setEnabled(enabled);
        this.jMenuItemScriptletEditor.setEnabled(enabled);
        this.jMenuItemReportSeries.setEnabled(enabled);
        this.jMenuItemReportImports.setEnabled(enabled);
        this.jMenuInternationalization.setEnabled(enabled);
        this.jMenuItemRemoveMargins.setEnabled(enabled);
        
        jMDIDesktopPane.setPreferredSize(new java.awt.Dimension(100,10));
        jMDIDesktopPane.setMinimumSize(new java.awt.Dimension(100,10));
        //jMDIDesktopPane.setPreferredSize(new Dimension(100,100));
        setActiveTool(this.jToggleButtonPointer);
        if (!enabled)
        {
            this.jToggleButtonPointer.setSelected(false);
        }
        if (jrf != null)
        {
            Report r = jrf.getReport();
            if( r.isModified() )
            {
                this.enableSaveSpecific();
                this.enableSaveAllSpecific();
                //end if report modified
            }
            else
            {
                this.disableSaveSpecific();
                if ( this.isSaveAllRequired() )
                {
                    this.enableSaveAllSpecific();
                }
                else
                {
                    this.disableSaveAllSpecific();
                }
                //end else report modified
            }
        }//end if jrf is null
    }//end setActiveReportForm
    
    public void updateDocumentStructureTree(JReportFrame jrf)
    {
        // Update the document tree structure...
        ((DefaultMutableTreeNode)this.jTreeDocument.getModel().getRoot()).removeAllChildren();
        
        if (jrf != null)
        {
            this.setDontHandleEvent(true);
            
            Enumeration bands = jrf.getReport().getBands().elements();
            while (bands.hasMoreElements())
            {
                Band band = (Band)bands.nextElement();
                DefaultMutableTreeNode bandNode = new DefaultMutableTreeNode(band);
                Enumeration elements = jrf.getReport().getElements().elements();
                while (elements.hasMoreElements())
                {
                    ReportElement element = (ReportElement)elements.nextElement();
                    if (element.getBand() == band)
                        bandNode.add( new DefaultMutableTreeNode(element));
                }
                
                ((DefaultMutableTreeNode)this.jTreeDocument.getModel().getRoot()).add( bandNode);
            }
            
            this.setDontHandleEvent(false);
            reportElementsSelectionChanged(new ReportElementsSelectionEvent(jrf,  jrf.getSelectedElements()));
        }
        
        jTreeDocument.updateUI();
    }
    
    public boolean isEMMActive()
    {
        return this.jCheckBoxMenuItemEMM.isSelected();
    }
    
    public void setActiveTool( int tool )
    {
        if (tool == 0)
            setActiveTool(this.jToggleButtonPointer);
    }
    private void setActiveTool( java.awt.Component tool )
    {
        try
        {
            this.jToggleButtonEllipseTool.setSelected(  (tool ==this.jToggleButtonEllipseTool) );
            this.jToggleButtonImageTool.setSelected(  (tool ==this.jToggleButtonImageTool) );
            this.jToggleButtonLineTool.setSelected(  (tool ==this.jToggleButtonLineTool) );
            this.jToggleButtonPointer.setSelected(  (tool ==this.jToggleButtonPointer) );
            this.jToggleButtonRectRoundTool.setSelected(  (tool ==this.jToggleButtonRectRoundTool) );
            this.jToggleButtonRectTool.setSelected(  (tool ==this.jToggleButtonRectTool) );
            this.jToggleButtonStaticTextTool.setSelected(  (tool ==this.jToggleButtonStaticTextTool) );
            this.jToggleButtonSubreportTool.setSelected(  (tool ==this.jToggleButtonSubreportTool) );
            this.jToggleButtonChartTool.setSelected(  (tool ==this.jToggleButtonChartTool) );
            this.jToggleButtonBarcodeTool.setSelected(  (tool ==this.jToggleButtonBarcodeTool) );
            this.jToggleButtonTextFieldTool.setSelected(  (tool ==this.jToggleButtonTextFieldTool) );
        }
        catch (Exception ex)
        {
            /* Do nothing */
        }
    }
    
    // Robert says:
    // As Fit To Page is calculated every time is it called,
    // There is not need for this method
    // Giulio do you agree?
    
    public void updateFitToPage(JReportFrame jrf)
    {
        int w = jrf.getReport().getWidth();
        double s = (jrf.getReportPanel().getWidth()-20)/(double)w;
        jNumberComboBoxZoom.addEntry("Fit to page", s*100);
    }
    /** 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.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        buttonGroupExportType = new javax.swing.ButtonGroup();
        buttonGroupFramesList = new javax.swing.ButtonGroup();
        jPopupMenuDocumentStructure = new javax.swing.JPopupMenu();
        jMenuItemDS_properties = new javax.swing.JMenuItem();
        jSeparator22 = new javax.swing.JSeparator();
        jMenuItemMoveUp = new javax.swing.JMenuItem();
        jMenuItemMoveDown = new javax.swing.JMenuItem();
        jSeparator23 = new javax.swing.JSeparator();
        jMenuItemDS_cut = new javax.swing.JMenuItem();
        jMenuItemDS_copy = new javax.swing.JMenuItem();
        jMenuItemDS_paste = new javax.swing.JMenuItem();
        jMenuItemDS_delete = new javax.swing.JMenuItem();
        jPopupMenuDocumentStructureBand = new javax.swing.JPopupMenu();
        jMenuItemDSB_properties = new javax.swing.JMenuItem();
        jPopupMenuThreads = new javax.swing.JPopupMenu();
        jMenuItemKill = new javax.swing.JMenuItem();
        jPopupMenuFiles = new javax.swing.JPopupMenu();
        jMenuItemSaveFromList = new javax.swing.JMenuItem();
        jMenuItemSaveAsFromList = new javax.swing.JMenuItem();
        jMenuItemSaveAllFromList = new javax.swing.JMenuItem();
        jSeparator24 = new javax.swing.JSeparator();
        jMenuItemCloseFromList = new javax.swing.JMenuItem();
        jMenuItemCloseAllFromList = new javax.swing.JMenuItem();
        jMenuItemCloseAllExceptThisFromList = new javax.swing.JMenuItem();
        jSeparator27 = new javax.swing.JSeparator();
        jMenuItemRevertToSavedFromList = new javax.swing.JMenuItem();
        jPanelToolBar = new javax.swing.JPanel();
        jPanelZoom = new javax.swing.JPanel();
        jNumberComboBoxZoom = new it.businesslogic.ireport.gui.JNumberComboBox();
        jButtonNew = new javax.swing.JButton();
        jButtonOpen = new javax.swing.JButton();
        jButtonSave = new javax.swing.JButton();
        jButtonCut = new javax.swing.JButton();
        jButtonCopy = new javax.swing.JButton();
        jButtonPaste = new javax.swing.JButton();
        jToggleButtonPointer = new javax.swing.JToggleButton();
        jToggleButtonLineTool = new javax.swing.JToggleButton();
        jToggleButtonRectTool = new javax.swing.JToggleButton();
        jToggleButtonRectRoundTool = new javax.swing.JToggleButton();
        jToggleButtonEllipseTool = new javax.swing.JToggleButton();
        jToggleButtonImageTool = new javax.swing.JToggleButton();
        jToggleButtonStaticTextTool = new javax.swing.JToggleButton();
        jToggleButtonTextFieldTool = new javax.swing.JToggleButton();
        jToggleButtonSubreportTool = new javax.swing.JToggleButton();
        jButtonBands = new javax.swing.JButton();
        jButtonGroups = new javax.swing.JButton();
        jButtonParameters = new javax.swing.JButton();
        jButtonDatabase = new javax.swing.JButton();
        jButtonCompiler = new javax.swing.JButton();
        jButtonRun1 = new javax.swing.JButton();
        jButtonRun2 = new javax.swing.JButton();
        jToggleButtonChartTool = new javax.swing.JToggleButton();
        jToggleButtonBarcodeTool = new javax.swing.JToggleButton();
        jPanel1 = new javax.swing.JPanel();
        jToolBarText = new javax.swing.JToolBar();
        jComboBoxFont = new javax.swing.JComboBox();
        jNumberComboBoxSize = new it.businesslogic.ireport.gui.JNumberComboBox();
        jButtonIncreaseSize = new javax.swing.JButton();
        jButtonDecreaseSize = new javax.swing.JButton();
        jButtonBold = new javax.swing.JButton();
        jButtonItalic = new javax.swing.JButton();
        jButtonUnderline = new javax.swing.JButton();
        jButtonStrikethrought = new javax.swing.JButton();
        jButtonAlignLeft = new javax.swing.JButton();
        jButtonAlignJustify = new javax.swing.JButton();
        jButtonAlignCenter = new javax.swing.JButton();
        jButtonAlignRight = new javax.swing.JButton();
        jButtonAlignTop = new javax.swing.JButton();
        jButtonAlignMiddle = new javax.swing.JButton();
        jButtonAlignBottom = new javax.swing.JButton();
        jToolBarConnections = jToolbarConnectionPanel.getToolBar();
        Filler1 = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jToolBarFormat = jToolbarFormatPanel.getToolBar();
        Filler = new javax.swing.JButton();
        jSplitPaneV = new javax.swing.JSplitPane();
        jPanelMaster = new javax.swing.JPanel();
        jSplitPaneHorizontal = new javax.swing.JSplitPane();
        jMDIDesktopPane = new it.businesslogic.ireport.gui.JMDIDesktopPane();
        jTabbedPaneExplorer = new javax.swing.JTabbedPane();
        jPanelFiles = new javax.swing.JPanel();
        jScrollPaneFiles = new javax.swing.JScrollPane();
        jTreeFiles = new javax.swing.JTree();
        jPanelDocumentStructure = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTreeDocument = new javax.swing.JTree();
        jPanelSouth = new javax.swing.JPanel();
        jScrollPaneOutput = new javax.swing.JScrollPane();
        jEditorPaneOutput = new javax.swing.JEditorPane();
        jPanelProcesses = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jScrollProcesses = new javax.swing.JScrollPane();
        jListThreads = new javax.swing.JList();
        jMDIMenuBar = new it.businesslogic.ireport.gui.JMDIMenuBar();
        jMenuFile = new javax.swing.JMenu();
        jMenuItemNewDocument = new javax.swing.JMenuItem();
        jMenuItemWizard = new javax.swing.JMenuItem();
        jMenuItemOpen = new javax.swing.JMenuItem();
        jMenuItemQOpen = new javax.swing.JMenuItem();
        jMenuItemSave = new javax.swing.JMenuItem();
        jMenuItemSaveAs = new javax.swing.JMenuItem();
        jMenuItemSaveAll = new javax.swing.JMenuItem();
        jMenuItemClose = new javax.swing.JMenuItem();
        jMenuItemCloseAll = new javax.swing.JMenuItem();
        jMenuItemCloseAllExceptThis = new javax.swing.JMenuItem();
        jSeparator3 = new javax.swing.JSeparator();
        jMenuItemRevertToSaved = new javax.swing.JMenuItem();
        jSeparator16 = new javax.swing.JSeparator();
        jMenuRecentFiles = new javax.swing.JMenu();
        jMenuRecentProjects = new javax.swing.JMenu();
        jMenuItemFavorites = new javax.swing.JMenuItem();
        jSeparator15 = new javax.swing.JSeparator();
        jMenuItemQuit = new javax.swing.JMenuItem();
        jSeparator25 = new javax.swing.JSeparator();
        jSeparator26 = new javax.swing.JSeparator();
        jMenuEdit = new javax.swing.JMenu();
        jMenuItemUndo = new javax.swing.JMenuItem();
        jMenuItemRedo = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JSeparator();
        jMenuItemCut = new javax.swing.JMenuItem();
        jMenuItemCopy = new javax.swing.JMenuItem();
        jMenuItemPaste = new javax.swing.JMenuItem();
        jMenuItemDelete = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JSeparator();
        jCheckBoxMenuItemEMM = new javax.swing.JCheckBoxMenuItem();
        jCheckBoxMenuItemSnapToGrid = new javax.swing.JCheckBoxMenuItem();
        jMenuAdd = new javax.swing.JMenu();
        jMenuItemNullElement = new javax.swing.JMenuItem();
        jMenuItemLine = new javax.swing.JMenuItem();
        jMenuItemRectangle = new javax.swing.JMenuItem();
        jMenuItemRoundRectangle = new javax.swing.JMenuItem();
        jMenuItemEllipse = new javax.swing.JMenuItem();
        jMenuItemImage = new javax.swing.JMenuItem();
        jMenuItemStaticText = new javax.swing.JMenuItem();
        jMenuItemTextField = new javax.swing.JMenuItem();
        jMenuItemChart = new javax.swing.JMenuItem();
        jMenuItemSubreport = new javax.swing.JMenuItem();
        jMenuItemXMLSource = new javax.swing.JMenuItem();
        jMenuItemRemoveMargins = new javax.swing.JMenuItem();
        jMenuView = new javax.swing.JMenu();
        jCheckBoxMenuItemGrid = new javax.swing.JCheckBoxMenuItem();
        jSeparator4 = new javax.swing.JSeparator();
        jCheckBoxMenuItemOutput = new javax.swing.JCheckBoxMenuItem();
        jCheckBoxMenuItemExplorer = new javax.swing.JCheckBoxMenuItem();
        jMenuToolBars = new javax.swing.JMenu();
        jCheckBoxMenuItemTextFormatting = new javax.swing.JCheckBoxMenuItem();
        jCheckBoxMenuItemElementsFormatting = new javax.swing.JCheckBoxMenuItem();
        jSeparator12 = new javax.swing.JSeparator();
        jMenuItemReportProperties = new javax.swing.JMenuItem();
        jMenuItemProperties = new javax.swing.JMenuItem();
        jMenuItemReportQuery = new javax.swing.JMenuItem();
        jMenuItemFields = new javax.swing.JMenuItem();
        jMenuItemVariables = new javax.swing.JMenuItem();
        jMenuItemParameters = new javax.swing.JMenuItem();
        jMenuItemFonts = new javax.swing.JMenuItem();
        jSeparator6 = new javax.swing.JSeparator();
        jMenuItemBands = new javax.swing.JMenuItem();
        jMenuItemGroups = new javax.swing.JMenuItem();
        jSeparator7 = new javax.swing.JSeparator();
        jMenuItemElementProperties = new javax.swing.JMenuItem();
        jMenuItemElementsBrowser = new javax.swing.JMenuItem();
        jMenuItemScriptletEditor = new javax.swing.JMenuItem();
        jMenuItemReportSeries = new javax.swing.JMenuItem();
        jMenuItemReportImports = new javax.swing.JMenuItem();
        jMenuInternationalization = new javax.swing.JMenu();
        jMenuInternationalizationWizard = new javax.swing.JMenuItem();
        jMenuLocaleFiles = new javax.swing.JMenuItem();
        jMenuSearch = new javax.swing.JMenu();
        jMenuItemFind = new javax.swing.JMenuItem();
        jMenuItemFindNext = new javax.swing.JMenuItem();
        jMenuItemFindPrev = new javax.swing.JMenuItem();
        jMenuItemReplace = new javax.swing.JMenuItem();
        jMenuProjects = new javax.swing.JMenu();
        jMenuItemNewProject = new javax.swing.JMenuItem();
        jMenuItemOpenProject = new javax.swing.JMenuItem();
        jMenuItemCloseProject = new javax.swing.JMenuItem();
        jSeparator13 = new javax.swing.JSeparator();
        jMenuItemAddFileToProject = new javax.swing.JMenuItem();
        jMenuItemProjectOptions = new javax.swing.JMenuItem();
        jMenuBuild = new javax.swing.JMenu();
        jMenuItemCompile = new javax.swing.JMenuItem();
        jMenuItemCompileAll = new javax.swing.JMenuItem();
        jSeparator10 = new javax.swing.JSeparator();
        jMenuItemExecute = new javax.swing.JMenuItem();
        jMenuItemExecuteDB = new javax.swing.JMenuItem();
        jSeparator11 = new javax.swing.JSeparator();
        jRadioButtonMenuItemPreviewPDF = new javax.swing.JRadioButtonMenuItem();
        jRadioButtonMenuItemPreviewHTML = new javax.swing.JRadioButtonMenuItem();
        jRadioButtonMenuItemPreviewJAVA = new javax.swing.JRadioButtonMenuItem();
        jRadioButtonMenuItemPreviewXLS = new javax.swing.JRadioButtonMenuItem();
        jRadioButtonMenuItemPreviewCSV = new javax.swing.JRadioButtonMenuItem();
        jRadioButtonMenuItemPreviewTXT = new javax.swing.JRadioButtonMenuItem();
        jRadioButtonMenuItemPreviewInternalViewer = new javax.swing.JRadioButtonMenuItem();
        jSeparator14 = new javax.swing.JSeparator();
        jMenuItemActiveConnection = new javax.swing.JMenuItem();
        jMenuItemReportLocale = new javax.swing.JMenuItem();
        jMenuFormat = new javax.swing.JMenu();
        jMenuAlign = new javax.swing.JMenu();
        jMenuItemAlignLeft = new javax.swing.JMenuItem();
        jMenuItemAlignRight = new javax.swing.JMenuItem();
        jMenuItemAlignTop = new javax.swing.JMenuItem();
        jMenuItemAlignBottom = new javax.swing.JMenuItem();
        jSeparator19 = new javax.swing.JSeparator();
        jMenuItemAlignVerticalAxis = new javax.swing.JMenuItem();
        jMenuItemAlignHorizontalAxis = new javax.swing.JMenuItem();
        jSeparator20 = new javax.swing.JSeparator();
        jMenuItemAlignToBandTop = new javax.swing.JMenuItem();
        jMenuItemAlignToBandBottom = new javax.swing.JMenuItem();
        jMenuSize = new javax.swing.JMenu();
        jMenuItemSameWidth = new javax.swing.JMenuItem();
        jMenuItemSameWidthMax = new javax.swing.JMenuItem();
        jMenuItemSameWidthMin = new javax.swing.JMenuItem();
        jSeparator17 = new javax.swing.JSeparator();
        jMenuItemSameHeight = new javax.swing.JMenuItem();
        jMenuItemSameHeightMin = new javax.swing.JMenuItem();
        jMenuItemSameHeightMax = new javax.swing.JMenuItem();
        jSeparator18 = new javax.swing.JSeparator();
        jMenuItemSameSize = new javax.swing.JMenuItem();
        jMenuPosition = new javax.swing.JMenu();
        jMenuItemCenterH = new javax.swing.JMenuItem();
        jMenuItemCenterV = new javax.swing.JMenuItem();
        jMenuItemCenterInBand = new javax.swing.JMenuItem();
        jMenuItemCenterBackground = new javax.swing.JMenuItem();
        jMenuItemJoinLeft = new javax.swing.JMenuItem();
        jMenuItemJoinRight = new javax.swing.JMenuItem();
        jMenuItemLeftMargin = new javax.swing.JMenuItem();
        jMenuItemRightMargin = new javax.swing.JMenuItem();
        jSeparator5 = new javax.swing.JSeparator();
        jMenuHSpacing = new javax.swing.JMenu();
        jMenuItemHSMakeEqual = new javax.swing.JMenuItem();
        jMenuItemHSIncrease = new javax.swing.JMenuItem();
        jMenuItemHSDecrease = new javax.swing.JMenuItem();
        jMenuItemHSRemove = new javax.swing.JMenuItem();
        jMenuVSpacing = new javax.swing.JMenu();
        jMenuItemVSMakeEqual = new javax.swing.JMenuItem();
        jMenuItemVSIncrease = new javax.swing.JMenuItem();
        jMenuItemVSDecrease = new javax.swing.JMenuItem();
        jMenuItemVSRemove = new javax.swing.JMenuItem();
        jSeparator8 = new javax.swing.JSeparator();
        jMenuItemOrganize = new javax.swing.JMenuItem();
        jMenuItemBringToFront = new javax.swing.JMenuItem();
        jMenuItemSendToBack = new javax.swing.JMenuItem();
        jMenuDatabase = new javax.swing.JMenu();
        jMenuItemConnections = new javax.swing.JMenuItem();
        jSeparator9 = new javax.swing.JSeparator();
        jMenuItemReportQuery2 = new javax.swing.JMenuItem();
        jMenuTools = new javax.swing.JMenu();
        jMenuItemOptions = new javax.swing.JMenuItem();
        jMenuItemCompatibility = new javax.swing.JMenuItem();
        jMenuItemPluginConfig = new javax.swing.JMenuItem();
        jMenuItemClasspath = new javax.swing.JMenuItem();
        jMenuItemExportOptions = new javax.swing.JMenuItem();
        jMenuPlugins = new javax.swing.JMenu();
        jMenuWindow = new javax.swing.JMenu();
        jMenuItemCascade = new javax.swing.JMenuItem();
        jMenuItemTileHorizontal = new javax.swing.JMenuItem();
        jMenuItemTileVertical = new javax.swing.JMenuItem();
        jMenuItemtileAnodine = new javax.swing.JMenuItem();
        jMenuItemNextWin = new javax.swing.JMenuItem();
        jMenuItemPrevWin = new javax.swing.JMenuItem();
        jSeparator21 = new javax.swing.JSeparator();
        jMenuHelp = new javax.swing.JMenu();
        jMenuItemHelp = new javax.swing.JMenuItem();
        jMenuItemAbout = new javax.swing.JMenuItem();
        
        jMenuItemDS_properties.setText("Properties");
        jMenuItemDS_properties.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemDS_propertiesActionPerformed(evt);
            }
        });
        
        jPopupMenuDocumentStructure.add(jMenuItemDS_properties);
        
        jPopupMenuDocumentStructure.add(jSeparator22);
        
        jMenuItemMoveUp.setText("Move up");
        jMenuItemMoveUp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemMoveUpActionPerformed(evt);
            }
        });
        
        jPopupMenuDocumentStructure.add(jMenuItemMoveUp);
        
        jMenuItemMoveDown.setText("Move down");
        jMenuItemMoveDown.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemMoveDownActionPerformed(evt);
            }
        });
        
        jPopupMenuDocumentStructure.add(jMenuItemMoveDown);
        
        jPopupMenuDocumentStructure.add(jSeparator23);
        
        jMenuItemDS_cut.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemDS_cut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/cut.gif")));
        jMenuItemDS_cut.setText("Cut");
        jMenuItemDS_cut.setEnabled(false);
        jMenuItemDS_cut.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemDS_cutActionPerformed(evt);
            }
        });
        
        jPopupMenuDocumentStructure.add(jMenuItemDS_cut);
        
        jMenuItemDS_copy.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemDS_copy.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/copy.gif")));
        jMenuItemDS_copy.setText("Copy");
        jMenuItemDS_copy.setEnabled(false);
        jMenuItemDS_copy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemDS_copyActionPerformed(evt);
            }
        });
        
        jPopupMenuDocumentStructure.add(jMenuItemDS_copy);
        
        jMenuItemDS_paste.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemDS_paste.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/paste.gif")));
        jMenuItemDS_paste.setText("Paste");
        jMenuItemDS_paste.setEnabled(false);
        jMenuItemDS_paste.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemDS_pasteActionPerformed(evt);
            }
        });
        
        jPopupMenuDocumentStructure.add(jMenuItemDS_paste);
        
        jMenuItemDS_delete.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemDS_delete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/delete.gif")));
        jMenuItemDS_delete.setText("Delete");
        jMenuItemDS_delete.setEnabled(false);
        jMenuItemDS_delete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemDS_deleteActionPerformed(evt);
            }
        });
        
        jPopupMenuDocumentStructure.add(jMenuItemDS_delete);
        
        jMenuItemDSB_properties.setText("Band properties");
        jMenuItemDSB_properties.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemDSB_propertiesActionPerformed(evt);
            }
        });
        
        jPopupMenuDocumentStructureBand.add(jMenuItemDSB_properties);
        
        jMenuItemKill.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemKill.setText("Kill this thread");
        jMenuItemKill.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemKillActionPerformed(evt);
            }
        });
        
        jPopupMenuThreads.add(jMenuItemKill);
        
        jMenuItemSaveFromList.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemSaveFromList.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/save.gif")));
        jMenuItemSaveFromList.setMnemonic('s');
        jMenuItemSaveFromList.setText("Save");
        jMenuItemSaveFromList.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSaveFromListActionPerformed(evt);
            }
        });
        
        jPopupMenuFiles.add(jMenuItemSaveFromList);
        
        jMenuItemSaveAsFromList.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemSaveAsFromList.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/save.gif")));
        jMenuItemSaveAsFromList.setText("Save as...");
        jMenuItemSaveAsFromList.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSaveAsFromListActionPerformed(evt);
            }
        });
        
        jPopupMenuFiles.add(jMenuItemSaveAsFromList);
        
        jMenuItemSaveAllFromList.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemSaveAllFromList.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/saveall.gif")));
        jMenuItemSaveAllFromList.setText("Save all");
        jMenuItemSaveAllFromList.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSaveAllFromListActionPerformed(evt);
            }
        });
        
        jPopupMenuFiles.add(jMenuItemSaveAllFromList);
        
        jPopupMenuFiles.add(jSeparator24);
        
        jMenuItemCloseFromList.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemCloseFromList.setText("Close");
        jMenuItemCloseFromList.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCloseFromListActionPerformed(evt);
            }
        });
        
        jPopupMenuFiles.add(jMenuItemCloseFromList);
        
        jMenuItemCloseAllFromList.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemCloseAllFromList.setText("Close all");
        jMenuItemCloseAllFromList.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCloseAllFromListActionPerformed(evt);
            }
        });
        
        jPopupMenuFiles.add(jMenuItemCloseAllFromList);
        
        jMenuItemCloseAllExceptThisFromList.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemCloseAllExceptThisFromList.setText("Close all except this");
        jMenuItemCloseAllExceptThisFromList.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCloseAllExceptThisFromListActionPerformed(evt);
            }
        });
        
        jPopupMenuFiles.add(jMenuItemCloseAllExceptThisFromList);
        
        jPopupMenuFiles.add(jSeparator27);
        
        jMenuItemRevertToSavedFromList.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemRevertToSavedFromList.setText("Revert to saved");
        jMenuItemRevertToSavedFromList.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemRevertToSavedFromListActionPerformed(evt);
            }
        });
        
        jPopupMenuFiles.add(jMenuItemRevertToSavedFromList);
        
        
        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("iReport 0.0.9");
        setIconImage(getIconImage());
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });
        
        jPanelToolBar.setLayout(null);
        
        jPanelToolBar.setMaximumSize(new java.awt.Dimension(32000, 32000));
        jPanelToolBar.setMinimumSize(new java.awt.Dimension(36, 500));
        jPanelToolBar.setPreferredSize(new java.awt.Dimension(200, 36));
        jPanelToolBar.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                jPanelToolBarComponentResized(evt);
            }
        });
        
        jPanelZoom.setLayout(null);
        
        jPanelZoom.setBorder(new javax.swing.border.EtchedBorder());
        jNumberComboBoxZoom.setMaximumRowCount(12);
        jNumberComboBoxZoom.setPostfix("%");
        jNumberComboBoxZoom.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jNumberComboBoxZoomActionPerformed(evt);
            }
        });
        
        jPanelZoom.add(jNumberComboBoxZoom);
        jNumberComboBoxZoom.setBounds(4, 4, 90, 24);
        
        jPanelToolBar.add(jPanelZoom);
        jPanelZoom.setBounds(400, 0, 100, 32);
        
        jButtonNew.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/new1.jpg")));
        jButtonNew.setToolTipText("New report");
        jButtonNew.setBorder(null);
        jButtonNew.setBorderPainted(false);
        jButtonNew.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/new2.jpg")));
        jButtonNew.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/new3.jpg")));
        jButtonNew.setSelectedIcon(new javax.swing.ImageIcon(""));
        jButtonNew.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonNewActionPerformed(evt);
            }
        });
        
        jPanelToolBar.add(jButtonNew);
        jButtonNew.setBounds(0, 0, 32, 32);
        
        jButtonOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/open1.jpg")));
        jButtonOpen.setToolTipText("Open report");
        jButtonOpen.setBorder(null);
        jButtonOpen.setBorderPainted(false);
        jButtonOpen.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/open2.jpg")));
        jButtonOpen.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/open3.jpg")));
        jButtonOpen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonOpenActionPerformed(evt);
            }
        });
        
        jPanelToolBar.add(jButtonOpen);
        jButtonOpen.setBounds(50, 0, 32, 32);
        
        jButtonSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/save1.jpg")));
        jButtonSave.setToolTipText("Save report");
        jButtonSave.setBorder(null);
        jButtonSave.setBorderPainted(false);
        jButtonSave.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/save2.jpg")));
        jButtonSave.setEnabled(false);
        jButtonSave.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/save3.jpg")));
        jButtonSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSaveActionPerformed(evt);
            }
        });
        
        jPanelToolBar.add(jButtonSave);
        jButtonSave.setBounds(40, 0, 32, 32);
        
        jButtonCut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/cut1.jpg")));
        jButtonCut.setToolTipText("Cut");
        jButtonCut.setBorder(null);
        jButtonCut.setBorderPainted(false);
        jButtonCut.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/cut2.jpg")));
        jButtonCut.setEnabled(false);
        jButtonCut.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/cut3.jpg")));
        jButtonCut.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCutActionPerformed(evt);
            }
        });
        
        jPanelToolBar.add(jButtonCut);
        jButtonCut.setBounds(60, 0, 32, 32);
        
        jButtonCopy.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/copy1.jpg")));
        jButtonCopy.setToolTipText("Copy");
        jButtonCopy.setBorder(null);
        jButtonCopy.setBorderPainted(false);
        jButtonCopy.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/copy2.jpg")));
        jButtonCopy.setEnabled(false);
        jButtonCopy.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/copy3.jpg")));
        jButtonCopy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCopyActionPerformed(evt);
            }
        });
        
        jPanelToolBar.add(jButtonCopy);
        jButtonCopy.setBounds(0, 0, 32, 32);
        
        jButtonPaste.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/paste1.jpg")));
        jButtonPaste.setToolTipText("Paste");
        jButtonPaste.setBorder(null);
        jButtonPaste.setBorderPainted(false);
        jButtonPaste.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/paste2.jpg")));
        jButtonPaste.setEnabled(false);
        jButtonPaste.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/paste3.jpg")));
        jButtonPaste.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPasteActionPerformed(evt);
            }
        });
        
        jPanelToolBar.add(jButtonPaste);
        jButtonPaste.setBounds(80, 0, 32, 32);
        
        jToggleButtonPointer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/pointer1.jpg")));
        jToggleButtonPointer.setToolTipText("Pointer");
        jToggleButtonPointer.setBorder(null);
        jToggleButtonPointer.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/pointer2.jpg")));
        jToggleButtonPointer.setEnabled(false);
        jToggleButtonPointer.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/pointer3.jpg")));
        jToggleButtonPointer.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/pointer3.jpg")));
        jToggleButtonPointer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButtonPointerActionPerformed(evt);
            }
        });
        jToggleButtonPointer.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jToggleButtonPointerItemStateChanged(evt);
            }
        });
        
        jPanelToolBar.add(jToggleButtonPointer);
        jToggleButtonPointer.setBounds(100, 0, 32, 32);
        
        jToggleButtonLineTool.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/lineTool1.jpg")));
        jToggleButtonLineTool.setToolTipText("Line tool");
        jToggleButtonLineTool.setBorder(null);
        jToggleButtonLineTool.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/lineTool2.jpg")));
        jToggleButtonLineTool.setEnabled(false);
        jToggleButtonLineTool.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/lineTool3.jpg")));
        jToggleButtonLineTool.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/lineTool3.jpg")));
        jToggleButtonLineTool.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButtonLineToolActionPerformed(evt);
            }
        });
        jToggleButtonLineTool.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jToggleButtonLineToolItemStateChanged(evt);
            }
        });
        
        jPanelToolBar.add(jToggleButtonLineTool);
        jToggleButtonLineTool.setBounds(100, 0, 32, 32);
        
        jToggleButtonRectTool.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/rectTool1.jpg")));
        jToggleButtonRectTool.setToolTipText("Rectangle tool");
        jToggleButtonRectTool.setBorder(null);
        jToggleButtonRectTool.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/rectTool2.jpg")));
        jToggleButtonRectTool.setEnabled(false);
        jToggleButtonRectTool.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/rectTool3.jpg")));
        jToggleButtonRectTool.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/rectTool3.jpg")));
        jToggleButtonRectTool.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButtonRectToolActionPerformed(evt);
            }
        });
        jToggleButtonRectTool.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jToggleButtonRectToolItemStateChanged(evt);
            }
        });
        
        jPanelToolBar.add(jToggleButtonRectTool);
        jToggleButtonRectTool.setBounds(110, 0, 32, 32);
        
        jToggleButtonRectRoundTool.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/roundRectTool1.jpg")));
        jToggleButtonRectRoundTool.setToolTipText("Round rectangle tool");
        jToggleButtonRectRoundTool.setBorder(null);
        jToggleButtonRectRoundTool.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/roundRectTool2.jpg")));
        jToggleButtonRectRoundTool.setEnabled(false);
        jToggleButtonRectRoundTool.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/roundRectTool3.jpg")));
        jToggleButtonRectRoundTool.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/roundRectTool3.jpg")));
        jToggleButtonRectRoundTool.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButtonRectRoundToolActionPerformed(evt);
            }
        });
        jToggleButtonRectRoundTool.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jToggleButtonRectRoundToolItemStateChanged(evt);
            }
        });
        
        jPanelToolBar.add(jToggleButtonRectRoundTool);
        jToggleButtonRectRoundTool.setBounds(110, 0, 32, 32);
        
        jToggleButtonEllipseTool.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/ellipseTool1.jpg")));
        jToggleButtonEllipseTool.setToolTipText("Ellipse tool");
        jToggleButtonEllipseTool.setBorder(null);
        jToggleButtonEllipseTool.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/ellipseTool2.jpg")));
        jToggleButtonEllipseTool.setEnabled(false);
        jToggleButtonEllipseTool.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/ellipseTool3.jpg")));
        jToggleButtonEllipseTool.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/ellipseTool3.jpg")));
        jToggleButtonEllipseTool.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButtonEllipseToolActionPerformed(evt);
            }
        });
        jToggleButtonEllipseTool.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jToggleButtonEllipseToolItemStateChanged(evt);
            }
        });
        
        jPanelToolBar.add(jToggleButtonEllipseTool);
        jToggleButtonEllipseTool.setBounds(110, 0, 32, 32);
        
        jToggleButtonImageTool.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/imageTool1.jpg")));
        jToggleButtonImageTool.setToolTipText("Image tool");
        jToggleButtonImageTool.setBorder(null);
        jToggleButtonImageTool.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/imageTool2.jpg")));
        jToggleButtonImageTool.setEnabled(false);
        jToggleButtonImageTool.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/imageTool3.jpg")));
        jToggleButtonImageTool.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/imageTool3.jpg")));
        jToggleButtonImageTool.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButtonImageToolActionPerformed(evt);
            }
        });
        jToggleButtonImageTool.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jToggleButtonImageToolItemStateChanged(evt);
            }
        });
        
        jPanelToolBar.add(jToggleButtonImageTool);
        jToggleButtonImageTool.setBounds(110, 0, 32, 32);
        
        jToggleButtonStaticTextTool.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/textTool1.jpg")));
        jToggleButtonStaticTextTool.setToolTipText("Static text tool");
        jToggleButtonStaticTextTool.setBorder(null);
        jToggleButtonStaticTextTool.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/textTool2.jpg")));
        jToggleButtonStaticTextTool.setEnabled(false);
        jToggleButtonStaticTextTool.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/textTool3.jpg")));
        jToggleButtonStaticTextTool.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/textTool3.jpg")));
        jToggleButtonStaticTextTool.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButtonStaticTextToolActionPerformed(evt);
            }
        });
        jToggleButtonStaticTextTool.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jToggleButtonStaticTextToolItemStateChanged(evt);
            }
        });
        
        jPanelToolBar.add(jToggleButtonStaticTextTool);
        jToggleButtonStaticTextTool.setBounds(110, 0, 32, 32);
        
        jToggleButtonTextFieldTool.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/fieldTool1.jpg")));
        jToggleButtonTextFieldTool.setToolTipText("Textfield tool");
        jToggleButtonTextFieldTool.setBorder(null);
        jToggleButtonTextFieldTool.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/fieldTool2.jpg")));
        jToggleButtonTextFieldTool.setEnabled(false);
        jToggleButtonTextFieldTool.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/fieldTool3.jpg")));
        jToggleButtonTextFieldTool.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/fieldTool3.jpg")));
        jToggleButtonTextFieldTool.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButtonTextFieldToolActionPerformed(evt);
            }
        });
        jToggleButtonTextFieldTool.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jToggleButtonTextFieldToolItemStateChanged(evt);
            }
        });
        
        jPanelToolBar.add(jToggleButtonTextFieldTool);
        jToggleButtonTextFieldTool.setBounds(110, 0, 32, 32);
        
        jToggleButtonSubreportTool.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/subreportTool1.jpg")));
        jToggleButtonSubreportTool.setToolTipText("Subreport tool");
        jToggleButtonSubreportTool.setBorder(null);
        jToggleButtonSubreportTool.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/subreportTool2.jpg")));
        jToggleButtonSubreportTool.setEnabled(false);
        jToggleButtonSubreportTool.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/subreportTool3.jpg")));
        jToggleButtonSubreportTool.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/subreportTool3.jpg")));
        jToggleButtonSubreportTool.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButtonSubreportToolActionPerformed(evt);
            }
        });
        jToggleButtonSubreportTool.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jToggleButtonSubreportToolItemStateChanged(evt);
            }
        });
        
        jPanelToolBar.add(jToggleButtonSubreportTool);
        jToggleButtonSubreportTool.setBounds(110, 0, 32, 32);
        
        jButtonBands.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/bands1.jpg")));
        jButtonBands.setToolTipText("Bands");
        jButtonBands.setBorder(null);
        jButtonBands.setBorderPainted(false);
        jButtonBands.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/bands2.jpg")));
        jButtonBands.setEnabled(false);
        jButtonBands.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/bands3.jpg")));
        jButtonBands.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBandsActionPerformed(evt);
            }
        });
        
        jPanelToolBar.add(jButtonBands);
        jButtonBands.setBounds(0, 0, 32, 32);
        
        jButtonGroups.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/groups1.jpg")));
        jButtonGroups.setToolTipText("Groups");
        jButtonGroups.setBorder(null);
        jButtonGroups.setBorderPainted(false);
        jButtonGroups.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/groups2.jpg")));
        jButtonGroups.setEnabled(false);
        jButtonGroups.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/groups3.jpg")));
        jButtonGroups.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGroupsActionPerformed(evt);
            }
        });
        
        jPanelToolBar.add(jButtonGroups);
        jButtonGroups.setBounds(0, 0, 32, 32);
        
        jButtonParameters.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/parameters1.jpg")));
        jButtonParameters.setToolTipText("Parameters");
        jButtonParameters.setBorder(null);
        jButtonParameters.setBorderPainted(false);
        jButtonParameters.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/parameters2.jpg")));
        jButtonParameters.setEnabled(false);
        jButtonParameters.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/parameters3.jpg")));
        jButtonParameters.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonParametersActionPerformed(evt);
            }
        });
        
        jPanelToolBar.add(jButtonParameters);
        jButtonParameters.setBounds(0, 0, 32, 32);
        
        jButtonDatabase.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/database1.jpg")));
        jButtonDatabase.setToolTipText("Database");
        jButtonDatabase.setBorder(null);
        jButtonDatabase.setBorderPainted(false);
        jButtonDatabase.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/database2.jpg")));
        jButtonDatabase.setEnabled(false);
        jButtonDatabase.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/database3.jpg")));
        jButtonDatabase.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDatabaseActionPerformed(evt);
            }
        });
        
        jPanelToolBar.add(jButtonDatabase);
        jButtonDatabase.setBounds(0, 0, 32, 32);
        
        jButtonCompiler.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/comp1.jpg")));
        jButtonCompiler.setToolTipText("Compile the report");
        jButtonCompiler.setBorder(null);
        jButtonCompiler.setBorderPainted(false);
        jButtonCompiler.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/comp2.jpg")));
        jButtonCompiler.setEnabled(false);
        jButtonCompiler.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/comp3.jpg")));
        jButtonCompiler.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCompilerActionPerformed(evt);
            }
        });
        
        jPanelToolBar.add(jButtonCompiler);
        jButtonCompiler.setBounds(0, 0, 32, 32);
        
        jButtonRun1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/run1.jpg")));
        jButtonRun1.setToolTipText("Run report using an empty datasource");
        jButtonRun1.setBorder(null);
        jButtonRun1.setBorderPainted(false);
        jButtonRun1.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/run2.jpg")));
        jButtonRun1.setEnabled(false);
        jButtonRun1.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/run3.jpg")));
        jButtonRun1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRun1ActionPerformed(evt);
            }
        });
        
        jPanelToolBar.add(jButtonRun1);
        jButtonRun1.setBounds(0, 0, 32, 32);
        
        jButtonRun2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/rundb1.jpg")));
        jButtonRun2.setToolTipText("Run report using a connection");
        jButtonRun2.setBorder(null);
        jButtonRun2.setBorderPainted(false);
        jButtonRun2.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/rundb2.jpg")));
        jButtonRun2.setEnabled(false);
        jButtonRun2.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/rundb3.jpg")));
        jButtonRun2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRun2ActionPerformed(evt);
            }
        });
        
        jPanelToolBar.add(jButtonRun2);
        jButtonRun2.setBounds(0, 0, 32, 32);
        
        jToggleButtonChartTool.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/chart1.jpg")));
        jToggleButtonChartTool.setToolTipText("Chart tool");
        jToggleButtonChartTool.setBorder(null);
        jToggleButtonChartTool.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/chart2.jpg")));
        jToggleButtonChartTool.setEnabled(false);
        jToggleButtonChartTool.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/chart3.jpg")));
        jToggleButtonChartTool.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/chart3.jpg")));
        jToggleButtonChartTool.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButtonChartToolActionPerformed(evt);
            }
        });
        jToggleButtonChartTool.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jToggleButtonChartToolItemStateChanged(evt);
            }
        });
        
        jPanelToolBar.add(jToggleButtonChartTool);
        jToggleButtonChartTool.setBounds(110, 0, 32, 32);
        
        jToggleButtonBarcodeTool.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/barcodeTool1.jpg")));
        jToggleButtonBarcodeTool.setToolTipText("Barcode tool");
        jToggleButtonBarcodeTool.setBorder(null);
        jToggleButtonBarcodeTool.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/barcodeTool2.jpg")));
        jToggleButtonBarcodeTool.setEnabled(false);
        jToggleButtonBarcodeTool.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/barcodeTool3.jpg")));
        jToggleButtonBarcodeTool.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/barcodeTool3.jpg")));
        jToggleButtonBarcodeTool.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jToggleButtonBarcodeToolItemStateChanged(evt);
            }
        });
        jToggleButtonBarcodeTool.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButtonBarcodeToolActionPerformed(evt);
            }
        });
        
        jPanelToolBar.add(jToggleButtonBarcodeTool);
        jToggleButtonBarcodeTool.setBounds(110, 0, 32, 32);
        
        getContentPane().add(jPanelToolBar, java.awt.BorderLayout.NORTH);
        
        jPanel1.setLayout(new java.awt.BorderLayout());
        
        jComboBoxFont.setFont(new java.awt.Font("Arial", 0, 11));
        jComboBoxFont.setEnabled(false);
        jComboBoxFont.setMaximumSize(new java.awt.Dimension(200, 32767));
        jComboBoxFont.setPreferredSize(new java.awt.Dimension(200, 20));
        jComboBoxFont.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jComboBoxFontItemStateChanged(evt);
            }
        });
        
        jToolBarText.add(jComboBoxFont);
        
        jNumberComboBoxSize.setEnabled(false);
        jNumberComboBoxSize.setFont(new java.awt.Font("Dialog", 0, 12));
        jNumberComboBoxSize.setMaximumSize(new java.awt.Dimension(60, 32767));
        jNumberComboBoxSize.setMinimumSize(new java.awt.Dimension(40, 22));
        jNumberComboBoxSize.setPreferredSize(new java.awt.Dimension(40, 22));
        jNumberComboBoxSize.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jNumberComboBoxSizeItemStateChanged(evt);
            }
        });
        jNumberComboBoxSize.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jNumberComboBoxSizeActionPerformed(evt);
            }
        });
        
        jToolBarText.add(jNumberComboBoxSize);
        
        jButtonIncreaseSize.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/toolbars/text/increase_font_size.png")));
        jButtonIncreaseSize.setEnabled(false);
        jButtonIncreaseSize.setFocusPainted(false);
        jButtonIncreaseSize.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButtonIncreaseSize.setMinimumSize(new java.awt.Dimension(22, 22));
        jButtonIncreaseSize.setPreferredSize(new java.awt.Dimension(22, 22));
        jButtonIncreaseSize.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonIncreaseSizeActionPerformed(evt);
            }
        });
        
        jToolBarText.add(jButtonIncreaseSize);
        
        jButtonDecreaseSize.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/toolbars/text/decrease_font_size.png")));
        jButtonDecreaseSize.setEnabled(false);
        jButtonDecreaseSize.setFocusPainted(false);
        jButtonDecreaseSize.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButtonDecreaseSize.setMinimumSize(new java.awt.Dimension(22, 22));
        jButtonDecreaseSize.setPreferredSize(new java.awt.Dimension(22, 22));
        jButtonDecreaseSize.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDecreaseSizeActionPerformed(evt);
            }
        });
        
        jToolBarText.add(jButtonDecreaseSize);
        
        jToolBarText.addSeparator();
        
        jButtonBold.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/toolbars/text/bold.png")));
        jButtonBold.setEnabled(false);
        jButtonBold.setFocusPainted(false);
        jButtonBold.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButtonBold.setMinimumSize(new java.awt.Dimension(22, 22));
        jButtonBold.setPreferredSize(new java.awt.Dimension(22, 22));
        jButtonBold.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBoldActionPerformed(evt);
            }
        });
        
        jToolBarText.add(jButtonBold);
        
        jButtonItalic.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/toolbars/text/italic.png")));
        jButtonItalic.setEnabled(false);
        jButtonItalic.setFocusPainted(false);
        jButtonItalic.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButtonItalic.setMinimumSize(new java.awt.Dimension(22, 22));
        jButtonItalic.setPreferredSize(new java.awt.Dimension(22, 22));
        jButtonItalic.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonItalicActionPerformed(evt);
            }
        });
        
        jToolBarText.add(jButtonItalic);
        
        jButtonUnderline.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/toolbars/text/underline.png")));
        jButtonUnderline.setEnabled(false);
        jButtonUnderline.setFocusPainted(false);
        jButtonUnderline.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButtonUnderline.setMinimumSize(new java.awt.Dimension(22, 22));
        jButtonUnderline.setPreferredSize(new java.awt.Dimension(22, 22));
        jButtonUnderline.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonUnderlineActionPerformed(evt);
            }
        });
        
        jToolBarText.add(jButtonUnderline);
        
        jButtonStrikethrought.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/toolbars/text/strikethrought.png")));
        jButtonStrikethrought.setEnabled(false);
        jButtonStrikethrought.setFocusPainted(false);
        jButtonStrikethrought.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButtonStrikethrought.setMinimumSize(new java.awt.Dimension(22, 22));
        jButtonStrikethrought.setPreferredSize(new java.awt.Dimension(22, 22));
        jButtonStrikethrought.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonStrikethroughtActionPerformed(evt);
            }
        });
        
        jToolBarText.add(jButtonStrikethrought);
        
        jButtonAlignLeft.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/toolbars/text/align_left.png")));
        jButtonAlignLeft.setEnabled(false);
        jButtonAlignLeft.setFocusPainted(false);
        jButtonAlignLeft.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButtonAlignLeft.setMinimumSize(new java.awt.Dimension(22, 22));
        jButtonAlignLeft.setPreferredSize(new java.awt.Dimension(22, 22));
        jButtonAlignLeft.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAlignLeftActionPerformed(evt);
            }
        });
        
        jToolBarText.add(jButtonAlignLeft);
        
        jButtonAlignJustify.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/toolbars/text/align_justified.png")));
        jButtonAlignJustify.setEnabled(false);
        jButtonAlignJustify.setFocusPainted(false);
        jButtonAlignJustify.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButtonAlignJustify.setMinimumSize(new java.awt.Dimension(22, 22));
        jButtonAlignJustify.setPreferredSize(new java.awt.Dimension(22, 22));
        jButtonAlignJustify.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAlignJustifyActionPerformed(evt);
            }
        });
        
        jToolBarText.add(jButtonAlignJustify);
        
        jButtonAlignCenter.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/toolbars/text/align_center.png")));
        jButtonAlignCenter.setEnabled(false);
        jButtonAlignCenter.setFocusPainted(false);
        jButtonAlignCenter.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButtonAlignCenter.setMinimumSize(new java.awt.Dimension(22, 22));
        jButtonAlignCenter.setPreferredSize(new java.awt.Dimension(22, 22));
        jButtonAlignCenter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAlignCenterActionPerformed(evt);
            }
        });
        
        jToolBarText.add(jButtonAlignCenter);
        
        jButtonAlignRight.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/toolbars/text/align_right.png")));
        jButtonAlignRight.setEnabled(false);
        jButtonAlignRight.setFocusPainted(false);
        jButtonAlignRight.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButtonAlignRight.setMinimumSize(new java.awt.Dimension(22, 22));
        jButtonAlignRight.setPreferredSize(new java.awt.Dimension(22, 22));
        jButtonAlignRight.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAlignRightActionPerformed(evt);
            }
        });
        
        jToolBarText.add(jButtonAlignRight);
        
        jToolBarText.addSeparator();
        jButtonAlignTop.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/toolbars/text/align_top.png")));
        jButtonAlignTop.setEnabled(false);
        jButtonAlignTop.setFocusPainted(false);
        jButtonAlignTop.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButtonAlignTop.setMinimumSize(new java.awt.Dimension(22, 22));
        jButtonAlignTop.setPreferredSize(new java.awt.Dimension(22, 22));
        jButtonAlignTop.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAlignTopActionPerformed(evt);
            }
        });
        
        jToolBarText.add(jButtonAlignTop);
        
        jButtonAlignMiddle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/toolbars/text/align_middle.png")));
        jButtonAlignMiddle.setEnabled(false);
        jButtonAlignMiddle.setFocusPainted(false);
        jButtonAlignMiddle.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButtonAlignMiddle.setMinimumSize(new java.awt.Dimension(22, 22));
        jButtonAlignMiddle.setPreferredSize(new java.awt.Dimension(22, 22));
        jButtonAlignMiddle.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAlignMiddleActionPerformed(evt);
            }
        });
        
        jToolBarText.add(jButtonAlignMiddle);
        
        jButtonAlignBottom.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/toolbars/text/align_bottom.png")));
        jButtonAlignBottom.setEnabled(false);
        jButtonAlignBottom.setFocusPainted(false);
        jButtonAlignBottom.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButtonAlignBottom.setMinimumSize(new java.awt.Dimension(22, 22));
        jButtonAlignBottom.setPreferredSize(new java.awt.Dimension(22, 22));
        jButtonAlignBottom.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAlignBottomActionPerformed(evt);
            }
        });
        
        jToolBarText.add(jButtonAlignBottom);
        
        Filler1.setBackground(new java.awt.Color(255, 255, 255));
        Filler1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/null.gif")));
        Filler1.setBorderPainted(false);
        Filler1.setContentAreaFilled(false);
        Filler1.setEnabled(false);
        Filler1.setFocusPainted(false);
        Filler1.setFocusable(false);
        Filler1.setMargin(new java.awt.Insets(0, 0, 0, 0));
        Filler1.setMaximumSize(new java.awt.Dimension(0, 22));
        Filler1.setMinimumSize(new java.awt.Dimension(0, 22));
        Filler1.setPreferredSize(new java.awt.Dimension(0, 22));
        jToolBarConnections.add(Filler1);
        
        jToolBarText.add(jToolBarConnections);
        
        jPanel1.add(jToolBarText, java.awt.BorderLayout.NORTH);
        
        jPanel2.setLayout(new java.awt.BorderLayout());
        
        Filler.setBackground(new java.awt.Color(255, 255, 255));
        Filler.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/null.gif")));
        Filler.setBorderPainted(false);
        Filler.setContentAreaFilled(false);
        Filler.setEnabled(false);
        Filler.setFocusPainted(false);
        Filler.setFocusable(false);
        Filler.setMargin(new java.awt.Insets(0, 0, 0, 0));
        Filler.setMaximumSize(new java.awt.Dimension(0, 22));
        Filler.setMinimumSize(new java.awt.Dimension(0, 22));
        Filler.setPreferredSize(new java.awt.Dimension(0, 22));
        jToolBarFormat.add(Filler);
        
        jPanel2.add(jToolBarFormat, java.awt.BorderLayout.NORTH);
        
        jSplitPaneV.setDividerSize(8);
        jSplitPaneV.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
        jSplitPaneV.setResizeWeight(1.0);
        jSplitPaneV.setOneTouchExpandable(true);
        jPanelMaster.setLayout(new java.awt.BorderLayout());
        
        jPanelMaster.setMinimumSize(new java.awt.Dimension(750, 100));
        jPanelMaster.setPreferredSize(new java.awt.Dimension(750, 550));
        jSplitPaneHorizontal.setDividerSize(8);
        jSplitPaneHorizontal.setOneTouchExpandable(true);
        jSplitPaneHorizontal.setRightComponent(jMDIDesktopPane);
        
        jTabbedPaneExplorer.setTabPlacement(javax.swing.JTabbedPane.BOTTOM);
        jTabbedPaneExplorer.setPreferredSize(new java.awt.Dimension(150, 10));
        jTabbedPaneExplorer.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jTabbedPaneExplorerStateChanged(evt);
            }
        });
        
        jPanelFiles.setLayout(new java.awt.BorderLayout());
        
        jPanelFiles.setBackground(new java.awt.Color(255, 255, 255));
        jScrollPaneFiles.setBackground(new java.awt.Color(255, 255, 255));
        jScrollPaneFiles.setMinimumSize(new java.awt.Dimension(0, 0));
        jScrollPaneFiles.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jScrollPaneFilesMousePressed(evt);
            }
        });
        
        jTreeFiles.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
            public void valueChanged(javax.swing.event.TreeSelectionEvent evt) {
                jTreeFilesValueChanged(evt);
            }
        });
        jTreeFiles.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTreeFilesMouseClicked(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jTreeFilesMousePressed(evt);
            }
        });
        
        jScrollPaneFiles.setViewportView(jTreeFiles);
        
        jPanelFiles.add(jScrollPaneFiles, java.awt.BorderLayout.CENTER);
        
        jTabbedPaneExplorer.addTab("Files", jPanelFiles);
        
        jPanelDocumentStructure.setLayout(new java.awt.BorderLayout());
        
        jPanelDocumentStructure.setBackground(new java.awt.Color(255, 255, 255));
        jScrollPane1.setBackground(new java.awt.Color(255, 255, 255));
        jTreeDocument.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
            public void valueChanged(javax.swing.event.TreeSelectionEvent evt) {
                jTreeDocumentValueChanged(evt);
            }
        });
        jTreeDocument.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jTreeDocumentMousePressed(evt);
            }
        });
        
        jScrollPane1.setViewportView(jTreeDocument);
        
        jPanelDocumentStructure.add(jScrollPane1, java.awt.BorderLayout.CENTER);
        
        jTabbedPaneExplorer.addTab("Document structure", jPanelDocumentStructure);
        
        jSplitPaneHorizontal.setLeftComponent(jTabbedPaneExplorer);
        
        jPanelMaster.add(jSplitPaneHorizontal, java.awt.BorderLayout.CENTER);
        
        jSplitPaneV.setTopComponent(jPanelMaster);
        
        jPanelSouth.setLayout(new java.awt.BorderLayout());
        
        jScrollPaneOutput.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        jScrollPaneOutput.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        jScrollPaneOutput.setMinimumSize(new java.awt.Dimension(22, 75));
        jScrollPaneOutput.setPreferredSize(new java.awt.Dimension(3, 100));
        jEditorPaneOutput.setBackground(new java.awt.Color(204, 204, 204));
        jEditorPaneOutput.setEditable(false);
        jEditorPaneOutput.setFont(new java.awt.Font("Courier New", 0, 12));
        jScrollPaneOutput.setViewportView(jEditorPaneOutput);
        
        jPanelSouth.add(jScrollPaneOutput, java.awt.BorderLayout.CENTER);
        
        jPanelProcesses.setLayout(new java.awt.BorderLayout());
        
        jPanelProcesses.setMinimumSize(new java.awt.Dimension(10, 1));
        jPanelProcesses.setPreferredSize(new java.awt.Dimension(120, 1));
        jTabbedPane1.setTabPlacement(javax.swing.JTabbedPane.BOTTOM);
        jListThreads.setFont(new java.awt.Font("Dialog", 0, 11));
        jListThreads.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jListThreads.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jListThreadsMouseClicked(evt);
            }
        });
        
        jScrollProcesses.setViewportView(jListThreads);
        
        jTabbedPane1.addTab("Active Threads", jScrollProcesses);
        
        jPanelProcesses.add(jTabbedPane1, java.awt.BorderLayout.CENTER);
        
        jPanelSouth.add(jPanelProcesses, java.awt.BorderLayout.EAST);
        
        jSplitPaneV.setBottomComponent(jPanelSouth);
        
        jPanel2.add(jSplitPaneV, java.awt.BorderLayout.CENTER);
        
        jPanel1.add(jPanel2, java.awt.BorderLayout.CENTER);
        
        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
        
        jMenuFile.setMnemonic('f');
        jMenuFile.setText("File");
        jMenuFile.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuFileActionPerformed(evt);
            }
        });
        
        jMenuItemNewDocument.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemNewDocument.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/new.gif")));
        jMenuItemNewDocument.setText("New document");
        jMenuItemNewDocument.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemNewDocumentActionPerformed(evt);
            }
        });
        
        jMenuFile.add(jMenuItemNewDocument);
        
        jMenuItemWizard.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemWizard.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/wizard.gif")));
        jMenuItemWizard.setText("Report wizard...");
        jMenuItemWizard.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/wizard.gif")));
        jMenuItemWizard.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemWizardActionPerformed(evt);
            }
        });
        
        jMenuFile.add(jMenuItemWizard);
        
        jMenuItemOpen.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/open.gif")));
        jMenuItemOpen.setText("Open");
        jMenuItemOpen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemOpenActionPerformed(evt);
            }
        });
        
        jMenuFile.add(jMenuItemOpen);
        
        jMenuItemQOpen.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemQOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/open.gif")));
        jMenuItemQOpen.setText("Quick open...");
        jMenuFile.add(jMenuItemQOpen);
        
        jMenuItemSave.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/save.gif")));
        jMenuItemSave.setMnemonic('s');
        jMenuItemSave.setText("Save");
        jMenuItemSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSaveActionPerformed(evt);
            }
        });
        
        jMenuFile.add(jMenuItemSave);
        
        jMenuItemSaveAs.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemSaveAs.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/save.gif")));
        jMenuItemSaveAs.setText("Save as...");
        jMenuItemSaveAs.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSaveAsActionPerformed(evt);
            }
        });
        
        jMenuFile.add(jMenuItemSaveAs);
        
        jMenuItemSaveAll.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemSaveAll.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/saveall.gif")));
        jMenuItemSaveAll.setText("Save all");
        jMenuItemSaveAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSaveAllActionPerformed(evt);
            }
        });
        
        jMenuFile.add(jMenuItemSaveAll);
        
        jMenuItemClose.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemClose.setText("Close");
        jMenuItemClose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCloseActionPerformed(evt);
            }
        });
        
        jMenuFile.add(jMenuItemClose);
        
        jMenuItemCloseAll.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemCloseAll.setText("Close all");
        jMenuItemCloseAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCloseAllActionPerformed(evt);
            }
        });
        
        jMenuFile.add(jMenuItemCloseAll);
        
        jMenuItemCloseAllExceptThis.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemCloseAllExceptThis.setText("Close all except this");
        jMenuItemCloseAllExceptThis.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCloseAllExceptThisActionPerformed(evt);
            }
        });
        
        jMenuFile.add(jMenuItemCloseAllExceptThis);
        
        jMenuFile.add(jSeparator3);
        
        jMenuItemRevertToSaved.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemRevertToSaved.setText("Revert to saved");
        jMenuItemRevertToSaved.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemRevertToSavedActionPerformed(evt);
            }
        });
        
        jMenuFile.add(jMenuItemRevertToSaved);
        
        jMenuFile.add(jSeparator16);
        
        jMenuRecentFiles.setText("Recent Files");
        jMenuRecentFiles.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuFile.add(jMenuRecentFiles);
        
        jMenuRecentProjects.setText("Recent Projects");
        jMenuRecentProjects.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuFile.add(jMenuRecentProjects);
        
        jMenuItemFavorites.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemFavorites.setText("Favorite Files...");
        jMenuFile.add(jMenuItemFavorites);
        
        jMenuFile.add(jSeparator15);
        
        jMenuItemQuit.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemQuit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/null.gif")));
        jMenuItemQuit.setMnemonic('q');
        jMenuItemQuit.setText("Quit");
        jMenuItemQuit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemQuitActionPerformed(evt);
            }
        });
        
        jMenuFile.add(jMenuItemQuit);
        
        jMenuFile.add(jSeparator25);
        
        jMenuFile.add(jSeparator26);
        
        jMDIMenuBar.add(jMenuFile);
        
        jMenuEdit.setMnemonic('e');
        jMenuEdit.setText("Edit");
        jMenuEdit.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuEditActionPerformed(evt);
            }
        });
        
        jMenuItemUndo.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemUndo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/undo.gif")));
        jMenuItemUndo.setText("Undo");
        jMenuItemUndo.setEnabled(false);
        jMenuItemUndo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemUndoActionPerformed(evt);
            }
        });
        
        jMenuEdit.add(jMenuItemUndo);
        
        jMenuItemRedo.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemRedo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/redo.gif")));
        jMenuItemRedo.setText("Redo");
        jMenuItemRedo.setEnabled(false);
        jMenuItemRedo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemRedoActionPerformed(evt);
            }
        });
        
        jMenuEdit.add(jMenuItemRedo);
        
        jMenuEdit.add(jSeparator1);
        
        jMenuItemCut.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemCut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/cut.gif")));
        jMenuItemCut.setText("Cut");
        jMenuItemCut.setEnabled(false);
        jMenuItemCut.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCutActionPerformed(evt);
            }
        });
        
        jMenuEdit.add(jMenuItemCut);
        
        jMenuItemCopy.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemCopy.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/copy.gif")));
        jMenuItemCopy.setText("Copy");
        jMenuItemCopy.setEnabled(false);
        jMenuItemCopy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCopyActionPerformed(evt);
            }
        });
        
        jMenuEdit.add(jMenuItemCopy);
        
        jMenuItemPaste.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemPaste.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/paste.gif")));
        jMenuItemPaste.setText("Paste");
        jMenuItemPaste.setEnabled(false);
        jMenuItemPaste.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemPasteActionPerformed(evt);
            }
        });
        
        jMenuEdit.add(jMenuItemPaste);
        
        jMenuItemDelete.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/delete.gif")));
        jMenuItemDelete.setText("Delete");
        jMenuItemDelete.setEnabled(false);
        jMenuItemDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemDeleteActionPerformed(evt);
            }
        });
        
        jMenuEdit.add(jMenuItemDelete);
        
        jMenuEdit.add(jSeparator2);
        
        jCheckBoxMenuItemEMM.setFont(new java.awt.Font("Dialog", 0, 11));
        jCheckBoxMenuItemEMM.setText("Disable elements mouse move");
        jCheckBoxMenuItemEMM.setEnabled(false);
        jCheckBoxMenuItemEMM.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxMenuItemEMMActionPerformed(evt);
            }
        });
        
        jMenuEdit.add(jCheckBoxMenuItemEMM);
        
        jCheckBoxMenuItemSnapToGrid.setFont(new java.awt.Font("Dialog", 0, 11));
        jCheckBoxMenuItemSnapToGrid.setText("Snap To Grid");
        jCheckBoxMenuItemSnapToGrid.setEnabled(false);
        jCheckBoxMenuItemSnapToGrid.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxMenuItemSnapToGridActionPerformed(evt);
            }
        });
        
        jMenuEdit.add(jCheckBoxMenuItemSnapToGrid);
        
        jMenuAdd.setText("Insert element...");
        jMenuAdd.setEnabled(false);
        jMenuAdd.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemNullElement.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemNullElement.setText("Null element (debug only)");
        jMenuItemNullElement.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemNullElementActionPerformed(evt);
            }
        });
        
        jMenuAdd.add(jMenuItemNullElement);
        
        jMenuItemLine.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemLine.setText("Line");
        jMenuItemLine.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemLineActionPerformed(evt);
            }
        });
        
        jMenuAdd.add(jMenuItemLine);
        
        jMenuItemRectangle.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemRectangle.setText("Rectangle");
        jMenuItemRectangle.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemRectangleActionPerformed(evt);
            }
        });
        
        jMenuAdd.add(jMenuItemRectangle);
        
        jMenuItemRoundRectangle.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemRoundRectangle.setText("Rounded rectangle");
        jMenuItemRoundRectangle.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemRoundRectangleActionPerformed(evt);
            }
        });
        
        jMenuAdd.add(jMenuItemRoundRectangle);
        
        jMenuItemEllipse.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemEllipse.setText("Ellipse");
        jMenuItemEllipse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemEllipseActionPerformed(evt);
            }
        });
        
        jMenuAdd.add(jMenuItemEllipse);
        
        jMenuItemImage.setText("Image");
        jMenuItemImage.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemImageActionPerformed(evt);
            }
        });
        
        jMenuAdd.add(jMenuItemImage);
        
        jMenuItemStaticText.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemStaticText.setText("Static text");
        jMenuItemStaticText.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemStaticTextActionPerformed(evt);
            }
        });
        
        jMenuAdd.add(jMenuItemStaticText);
        
        jMenuItemTextField.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemTextField.setText("Text field");
        jMenuItemTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemTextFieldActionPerformed(evt);
            }
        });
        
        jMenuAdd.add(jMenuItemTextField);
        
        jMenuItemChart.setText("Chart");
        jMenuItemChart.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemChartActionPerformed(evt);
            }
        });
        
        jMenuAdd.add(jMenuItemChart);
        
        jMenuItemSubreport.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemSubreport.setText("Subreport");
        jMenuItemSubreport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSubreportActionPerformed(evt);
            }
        });
        
        jMenuAdd.add(jMenuItemSubreport);
        
        jMenuEdit.add(jMenuAdd);
        
        jMenuItemXMLSource.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemXMLSource.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/null.gif")));
        jMenuItemXMLSource.setText("Edit XML source...");
        jMenuItemXMLSource.setEnabled(false);
        jMenuItemXMLSource.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemXMLSourceActionPerformed(evt);
            }
        });
        
        jMenuEdit.add(jMenuItemXMLSource);
        
        jMenuItemRemoveMargins.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemRemoveMargins.setText("Item");
        jMenuItemRemoveMargins.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemRemoveMarginsActionPerformed(evt);
            }
        });
        
        jMenuEdit.add(jMenuItemRemoveMargins);
        
        jMDIMenuBar.add(jMenuEdit);
        
        jMenuView.setMnemonic('v');
        jMenuView.setText("View");
        jMenuView.setFont(new java.awt.Font("Dialog", 0, 11));
        jCheckBoxMenuItemGrid.setFont(new java.awt.Font("Dialog", 0, 11));
        jCheckBoxMenuItemGrid.setText("Show grid");
        jCheckBoxMenuItemGrid.setEnabled(false);
        jCheckBoxMenuItemGrid.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxMenuItemGridActionPerformed(evt);
            }
        });
        
        jMenuView.add(jCheckBoxMenuItemGrid);
        
        jMenuView.add(jSeparator4);
        
        jCheckBoxMenuItemOutput.setFont(new java.awt.Font("Dialog", 0, 11));
        jCheckBoxMenuItemOutput.setSelected(true);
        jCheckBoxMenuItemOutput.setText("Show output window");
        jCheckBoxMenuItemOutput.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxMenuItemOutputActionPerformed(evt);
            }
        });
        
        jMenuView.add(jCheckBoxMenuItemOutput);
        
        jCheckBoxMenuItemExplorer.setFont(new java.awt.Font("Dialog", 0, 11));
        jCheckBoxMenuItemExplorer.setSelected(true);
        jCheckBoxMenuItemExplorer.setText("Show project browser");
        jCheckBoxMenuItemExplorer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxMenuItemExplorerActionPerformed(evt);
            }
        });
        
        jMenuView.add(jCheckBoxMenuItemExplorer);
        
        jMenuToolBars.setText("Toolbars");
        jMenuToolBars.setFont(new java.awt.Font("Dialog", 0, 11));
        jCheckBoxMenuItemTextFormatting.setFont(new java.awt.Font("Dialog", 0, 11));
        jCheckBoxMenuItemTextFormatting.setSelected(true);
        jCheckBoxMenuItemTextFormatting.setText("Text formatting");
        jCheckBoxMenuItemTextFormatting.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxMenuItemTextFormattingActionPerformed(evt);
            }
        });
        
        jMenuToolBars.add(jCheckBoxMenuItemTextFormatting);
        
        jCheckBoxMenuItemElementsFormatting.setFont(new java.awt.Font("Dialog", 0, 11));
        jCheckBoxMenuItemElementsFormatting.setSelected(true);
        jCheckBoxMenuItemElementsFormatting.setText("Elements formatting");
        jCheckBoxMenuItemElementsFormatting.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxMenuItemElementsFormattingActionPerformed(evt);
            }
        });
        
        jMenuToolBars.add(jCheckBoxMenuItemElementsFormatting);
        
        jMenuView.add(jMenuToolBars);
        
        jMenuView.add(jSeparator12);
        
        jMenuItemReportProperties.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemReportProperties.setText("Report properties");
        jMenuItemReportProperties.setEnabled(false);
        jMenuItemReportProperties.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemReportPropertiesActionPerformed(evt);
            }
        });
        
        jMenuView.add(jMenuItemReportProperties);
        
        jMenuItemProperties.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemProperties.setText("Custom properties");
        jMenuItemProperties.setEnabled(false);
        jMenuItemProperties.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemPropertiesActionPerformed(evt);
            }
        });
        
        jMenuView.add(jMenuItemProperties);
        
        jMenuItemReportQuery.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemReportQuery.setText("Report query");
        jMenuItemReportQuery.setEnabled(false);
        jMenuItemReportQuery.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemReportQueryActionPerformed(evt);
            }
        });
        
        jMenuView.add(jMenuItemReportQuery);
        
        jMenuItemFields.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemFields.setText("Report fields");
        jMenuItemFields.setEnabled(false);
        jMenuItemFields.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemFieldsActionPerformed(evt);
            }
        });
        
        jMenuView.add(jMenuItemFields);
        
        jMenuItemVariables.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemVariables.setText("Report variables");
        jMenuItemVariables.setEnabled(false);
        jMenuItemVariables.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemVariablesActionPerformed(evt);
            }
        });
        
        jMenuView.add(jMenuItemVariables);
        
        jMenuItemParameters.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemParameters.setText("Report parameters");
        jMenuItemParameters.setEnabled(false);
        jMenuItemParameters.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemParametersActionPerformed(evt);
            }
        });
        
        jMenuView.add(jMenuItemParameters);
        
        jMenuItemFonts.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemFonts.setText("Report fonts");
        jMenuItemFonts.setEnabled(false);
        jMenuItemFonts.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemFontsActionPerformed(evt);
            }
        });
        
        jMenuView.add(jMenuItemFonts);
        
        jMenuView.add(jSeparator6);
        
        jMenuItemBands.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemBands.setText("Bands");
        jMenuItemBands.setEnabled(false);
        jMenuItemBands.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemBandsActionPerformed(evt);
            }
        });
        
        jMenuView.add(jMenuItemBands);
        
        jMenuItemGroups.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemGroups.setText("Report groups");
        jMenuItemGroups.setEnabled(false);
        jMenuItemGroups.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemGroupsActionPerformed(evt);
            }
        });
        
        jMenuView.add(jMenuItemGroups);
        
        jMenuView.add(jSeparator7);
        
        jMenuItemElementProperties.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemElementProperties.setText("Element properties");
        jMenuItemElementProperties.setEnabled(false);
        jMenuItemElementProperties.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemElementPropertiesActionPerformed(evt);
            }
        });
        
        jMenuView.add(jMenuItemElementProperties);
        
        jMenuItemElementsBrowser.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemElementsBrowser.setText("Elements browser");
        jMenuItemElementsBrowser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemElementsBrowserActionPerformed(evt);
            }
        });
        
        jMenuView.add(jMenuItemElementsBrowser);
        
        jMenuItemScriptletEditor.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemScriptletEditor.setText("ScriptletEditor (Experimental)");
        jMenuItemScriptletEditor.setEnabled(false);
        jMenuItemScriptletEditor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemScriptletEditorActionPerformed(evt);
            }
        });
        
        jMenuView.add(jMenuItemScriptletEditor);
        
        jMenuItemReportSeries.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemReportSeries.setText("Report series");
        jMenuItemReportSeries.setEnabled(false);
        jMenuItemReportSeries.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemReportSeriesActionPerformed(evt);
            }
        });
        
        jMenuView.add(jMenuItemReportSeries);
        
        jMenuItemReportImports.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemReportImports.setText("Report series");
        jMenuItemReportImports.setEnabled(false);
        jMenuItemReportImports.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemReportImportsActionPerformed(evt);
            }
        });
        
        jMenuView.add(jMenuItemReportImports);
        
        jMenuInternationalization.setText("Internationalization");
        jMenuInternationalization.setEnabled(false);
        jMenuInternationalization.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuInternationalizationWizard.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuInternationalizationWizard.setText("Internationalization Wizard");
        jMenuInternationalizationWizard.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuInternationalizationWizardActionPerformed(evt);
            }
        });
        
        jMenuInternationalization.add(jMenuInternationalizationWizard);
        
        jMenuLocaleFiles.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuLocaleFiles.setText("Locale resource files");
        jMenuLocaleFiles.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuLocaleFilesActionPerformed(evt);
            }
        });
        
        jMenuInternationalization.add(jMenuLocaleFiles);
        
        jMenuView.add(jMenuInternationalization);
        
        jMDIMenuBar.add(jMenuView);
        
        jMenuSearch.setMnemonic('s');
        jMenuSearch.setText("Search");
        jMenuSearch.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemFind.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemFind.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/find.gif")));
        jMenuItemFind.setText("Find");
        jMenuSearch.add(jMenuItemFind);
        
        jMenuItemFindNext.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemFindNext.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/findnext.gif")));
        jMenuItemFindNext.setText("Find next");
        jMenuSearch.add(jMenuItemFindNext);
        
        jMenuItemFindPrev.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemFindPrev.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/findprev.gif")));
        jMenuItemFindPrev.setText("Find Prev");
        jMenuSearch.add(jMenuItemFindPrev);
        
        jMenuItemReplace.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemReplace.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/findreplace.gif")));
        jMenuItemReplace.setText("Replace");
        jMenuSearch.add(jMenuItemReplace);
        
        jMDIMenuBar.add(jMenuSearch);
        
        jMenuProjects.setMnemonic('p');
        jMenuProjects.setText("Project");
        jMenuProjects.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuProjects.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuProjectsActionPerformed(evt);
            }
        });
        
        jMenuItemNewProject.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemNewProject.setText("New project");
        jMenuItemNewProject.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemNewProjectActionPerformed(evt);
            }
        });
        
        jMenuProjects.add(jMenuItemNewProject);
        
        jMenuItemOpenProject.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemOpenProject.setText("Open project");
        jMenuProjects.add(jMenuItemOpenProject);
        
        jMenuItemCloseProject.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemCloseProject.setText("Close project");
        jMenuItemCloseProject.setEnabled(false);
        jMenuItemCloseProject.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCloseProjectActionPerformed(evt);
            }
        });
        
        jMenuProjects.add(jMenuItemCloseProject);
        
        jMenuProjects.add(jSeparator13);
        
        jMenuItemAddFileToProject.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemAddFileToProject.setText("Add report to project...");
        jMenuProjects.add(jMenuItemAddFileToProject);
        
        jMenuItemProjectOptions.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemProjectOptions.setText("Project options...");
        jMenuItemProjectOptions.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemReportPropertiesActionPerformed(evt);
            }
        });
        
        jMenuProjects.add(jMenuItemProjectOptions);
        
        jMDIMenuBar.add(jMenuProjects);
        
        jMenuBuild.setMnemonic('b');
        jMenuBuild.setText("Build");
        jMenuBuild.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemCompile.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemCompile.setText("Compile");
        jMenuItemCompile.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jMenuItemCompileItemStateChanged(evt);
            }
        });
        jMenuItemCompile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCompileActionPerformed(evt);
            }
        });
        
        jMenuBuild.add(jMenuItemCompile);
        
        jMenuItemCompileAll.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemCompileAll.setText("Compile All");
        jMenuBuild.add(jMenuItemCompileAll);
        
        jMenuBuild.add(jSeparator10);
        
        jMenuItemExecute.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemExecute.setText("Execute report");
        jMenuItemExecute.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemExecuteActionPerformed(evt);
            }
        });
        
        jMenuBuild.add(jMenuItemExecute);
        
        jMenuItemExecuteDB.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemExecuteDB.setText("Execute report (using active conn.) ");
        jMenuItemExecuteDB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemExecuteDBActionPerformed(evt);
            }
        });
        
        jMenuBuild.add(jMenuItemExecuteDB);
        
        jMenuBuild.add(jSeparator11);
        
        buttonGroupExportType.add(jRadioButtonMenuItemPreviewPDF);
        jRadioButtonMenuItemPreviewPDF.setFont(new java.awt.Font("Dialog", 0, 11));
        jRadioButtonMenuItemPreviewPDF.setSelected(true);
        jRadioButtonMenuItemPreviewPDF.setText("PDF preview");
        jRadioButtonMenuItemPreviewPDF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButtonMenuItemPreviewPDFActionPerformed(evt);
            }
        });
        
        jMenuBuild.add(jRadioButtonMenuItemPreviewPDF);
        
        buttonGroupExportType.add(jRadioButtonMenuItemPreviewHTML);
        jRadioButtonMenuItemPreviewHTML.setFont(new java.awt.Font("Dialog", 0, 11));
        jRadioButtonMenuItemPreviewHTML.setText("HTML preview");
        jRadioButtonMenuItemPreviewHTML.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButtonMenuItemPreviewHTMLActionPerformed(evt);
            }
        });
        
        jMenuBuild.add(jRadioButtonMenuItemPreviewHTML);
        
        buttonGroupExportType.add(jRadioButtonMenuItemPreviewJAVA);
        jRadioButtonMenuItemPreviewJAVA.setFont(new java.awt.Font("Dialog", 0, 11));
        jRadioButtonMenuItemPreviewJAVA.setText("JAVA 2D preview");
        jRadioButtonMenuItemPreviewJAVA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButtonMenuItemPreviewJAVAActionPerformed(evt);
            }
        });
        
        jMenuBuild.add(jRadioButtonMenuItemPreviewJAVA);
        
        buttonGroupExportType.add(jRadioButtonMenuItemPreviewXLS);
        jRadioButtonMenuItemPreviewXLS.setFont(new java.awt.Font("Dialog", 0, 11));
        jRadioButtonMenuItemPreviewXLS.setText("Excel preview");
        jRadioButtonMenuItemPreviewXLS.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButtonMenuItemPreviewXLSActionPerformed(evt);
            }
        });
        
        jMenuBuild.add(jRadioButtonMenuItemPreviewXLS);
        
        buttonGroupExportType.add(jRadioButtonMenuItemPreviewCSV);
        jRadioButtonMenuItemPreviewCSV.setFont(new java.awt.Font("Dialog", 0, 11));
        jRadioButtonMenuItemPreviewCSV.setText("CSV preview");
        jRadioButtonMenuItemPreviewCSV.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButtonMenuItemPreviewCSVActionPerformed(evt);
            }
        });
        
        jMenuBuild.add(jRadioButtonMenuItemPreviewCSV);
        
        buttonGroupExportType.add(jRadioButtonMenuItemPreviewTXT);
        jRadioButtonMenuItemPreviewTXT.setFont(new java.awt.Font("Dialog", 0, 11));
        jRadioButtonMenuItemPreviewTXT.setText("Text preview (Experimental)");
        jRadioButtonMenuItemPreviewTXT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButtonMenuItemPreviewTXTActionPerformed(evt);
            }
        });
        
        jMenuBuild.add(jRadioButtonMenuItemPreviewTXT);
        
        buttonGroupExportType.add(jRadioButtonMenuItemPreviewInternalViewer);
        jRadioButtonMenuItemPreviewInternalViewer.setFont(new java.awt.Font("Dialog", 0, 11));
        jRadioButtonMenuItemPreviewInternalViewer.setText("JRViewer preview");
        jRadioButtonMenuItemPreviewInternalViewer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButtonMenuItemPreviewInternalViewerActionPerformed(evt);
            }
        });
        
        jMenuBuild.add(jRadioButtonMenuItemPreviewInternalViewer);
        
        jMenuBuild.add(jSeparator14);
        
        jMenuItemActiveConnection.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemActiveConnection.setText("Set active connection");
        jMenuItemActiveConnection.setToolTipText("Set the connection that must be used to fill this report");
        jMenuItemActiveConnection.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemActiveConnectionActionPerformed(evt);
            }
        });
        
        jMenuBuild.add(jMenuItemActiveConnection);
        
        jMenuItemReportLocale.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemReportLocale.setText("Item");
        jMenuItemReportLocale.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemReportLocaleActionPerformed(evt);
            }
        });
        
        jMenuBuild.add(jMenuItemReportLocale);
        
        jMDIMenuBar.add(jMenuBuild);
        
        jMenuFormat.setMnemonic('o');
        jMenuFormat.setText("Format");
        jMenuFormat.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuAlign.setText("Align...");
        jMenuAlign.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuAlign.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuAlignActionPerformed(evt);
            }
        });
        
        jMenuItemAlignLeft.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_LEFT, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemAlignLeft.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemAlignLeft.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/elem_align_left.gif")));
        jMenuItemAlignLeft.setText("Align left");
        jMenuItemAlignLeft.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAlignLeftActionPerformed(evt);
            }
        });
        
        jMenuAlign.add(jMenuItemAlignLeft);
        
        jMenuItemAlignRight.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_RIGHT, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemAlignRight.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemAlignRight.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/elem_align_right.gif")));
        jMenuItemAlignRight.setText("Align right");
        jMenuItemAlignRight.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAlignRightActionPerformed(evt);
            }
        });
        
        jMenuAlign.add(jMenuItemAlignRight);
        
        jMenuItemAlignTop.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_UP, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemAlignTop.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemAlignTop.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/elem_align_top.gif")));
        jMenuItemAlignTop.setText("Align top");
        jMenuItemAlignTop.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAlignTopActionPerformed(evt);
            }
        });
        
        jMenuAlign.add(jMenuItemAlignTop);
        
        jMenuItemAlignBottom.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_DOWN, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemAlignBottom.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemAlignBottom.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/elem_align_bottom.gif")));
        jMenuItemAlignBottom.setText("Align bottom");
        jMenuItemAlignBottom.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAlignBottomActionPerformed(evt);
            }
        });
        
        jMenuAlign.add(jMenuItemAlignBottom);
        
        jMenuAlign.add(jSeparator19);
        
        jMenuItemAlignVerticalAxis.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemAlignVerticalAxis.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/elem_center_axis.gif")));
        jMenuItemAlignVerticalAxis.setText("Align vertical axis");
        jMenuItemAlignVerticalAxis.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAlignVerticalAxisActionPerformed(evt);
            }
        });
        
        jMenuAlign.add(jMenuItemAlignVerticalAxis);
        
        jMenuItemAlignHorizontalAxis.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemAlignHorizontalAxis.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/elem_vcenter_axis.gif")));
        jMenuItemAlignHorizontalAxis.setText("Align horizontal axis");
        jMenuItemAlignHorizontalAxis.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAlignHorizontalAxisActionPerformed(evt);
            }
        });
        
        jMenuAlign.add(jMenuItemAlignHorizontalAxis);
        
        jMenuAlign.add(jSeparator20);
        
        jMenuItemAlignToBandTop.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_PAGE_UP, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemAlignToBandTop.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemAlignToBandTop.setText("Align to band top");
        jMenuItemAlignToBandTop.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAlignToBandTopActionPerformed(evt);
            }
        });
        
        jMenuAlign.add(jMenuItemAlignToBandTop);
        
        jMenuItemAlignToBandBottom.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_PAGE_DOWN, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemAlignToBandBottom.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemAlignToBandBottom.setText("Align to band bottom");
        jMenuItemAlignToBandBottom.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAlignToBandBottomActionPerformed(evt);
            }
        });
        
        jMenuAlign.add(jMenuItemAlignToBandBottom);
        
        jMenuFormat.add(jMenuAlign);
        
        jMenuSize.setText("Size...");
        jMenuSize.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemSameWidth.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemSameWidth.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/elem_same_hsize.gif")));
        jMenuItemSameWidth.setText("Same width");
        jMenuItemSameWidth.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSameWidthActionPerformed(evt);
            }
        });
        
        jMenuSize.add(jMenuItemSameWidth);
        
        jMenuItemSameWidthMax.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemSameWidthMax.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/elem_same_hsize_plus.gif")));
        jMenuItemSameWidthMax.setText("Same width (max)");
        jMenuItemSameWidthMax.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSameWidthMaxActionPerformed(evt);
            }
        });
        
        jMenuSize.add(jMenuItemSameWidthMax);
        
        jMenuItemSameWidthMin.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemSameWidthMin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/elem_same_hsize_min.gif")));
        jMenuItemSameWidthMin.setText("Same width (min)");
        jMenuItemSameWidthMin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSameWidthMinActionPerformed(evt);
            }
        });
        
        jMenuSize.add(jMenuItemSameWidthMin);
        
        jMenuSize.add(jSeparator17);
        
        jMenuItemSameHeight.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemSameHeight.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/elem_same_vsize.gif")));
        jMenuItemSameHeight.setText("Same height");
        jMenuItemSameHeight.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSameHeightActionPerformed(evt);
            }
        });
        
        jMenuSize.add(jMenuItemSameHeight);
        
        jMenuItemSameHeightMin.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemSameHeightMin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/elem_same_vsize_min.gif")));
        jMenuItemSameHeightMin.setText("Same height (min)");
        jMenuItemSameHeightMin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSameHeightMinActionPerformed(evt);
            }
        });
        
        jMenuSize.add(jMenuItemSameHeightMin);
        
        jMenuItemSameHeightMax.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemSameHeightMax.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/elem_same_vsize_plus.gif")));
        jMenuItemSameHeightMax.setText("Same height (max)");
        jMenuItemSameHeightMax.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSameHeightMaxActionPerformed(evt);
            }
        });
        
        jMenuSize.add(jMenuItemSameHeightMax);
        
        jMenuSize.add(jSeparator18);
        
        jMenuItemSameSize.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemSameSize.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/elem_same_size.gif")));
        jMenuItemSameSize.setText("Same size");
        jMenuItemSameSize.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSameSizeActionPerformed(evt);
            }
        });
        
        jMenuSize.add(jMenuItemSameSize);
        
        jMenuFormat.add(jMenuSize);
        
        jMenuPosition.setText("Position...");
        jMenuPosition.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemCenterH.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemCenterH.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/elem_hcenter.gif")));
        jMenuItemCenterH.setText("Center horizontally (band based)");
        jMenuItemCenterH.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCenterHActionPerformed(evt);
            }
        });
        
        jMenuPosition.add(jMenuItemCenterH);
        
        jMenuItemCenterV.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemCenterV.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/elem_vcenter.gif")));
        jMenuItemCenterV.setText("Center vertically (band based)");
        jMenuItemCenterV.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCenterVActionPerformed(evt);
            }
        });
        
        jMenuPosition.add(jMenuItemCenterV);
        
        jMenuItemCenterInBand.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemCenterInBand.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/elem_ccenter.gif")));
        jMenuItemCenterInBand.setText("Center in band");
        jMenuItemCenterInBand.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCenterInBandActionPerformed(evt);
            }
        });
        
        jMenuPosition.add(jMenuItemCenterInBand);
        
        jMenuItemCenterBackground.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemCenterBackground.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/elem_bcenter.gif")));
        jMenuItemCenterBackground.setText("Center in background");
        jMenuItemCenterBackground.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCenterBackgroundActionPerformed(evt);
            }
        });
        
        jMenuPosition.add(jMenuItemCenterBackground);
        
        jMenuItemJoinLeft.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemJoinLeft.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemJoinLeft.setText("Join sides left");
        jMenuItemJoinLeft.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemJoinLeftActionPerformed(evt);
            }
        });
        
        jMenuPosition.add(jMenuItemJoinLeft);
        
        jMenuItemJoinRight.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemJoinRight.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemJoinRight.setText("Join sides right");
        jMenuItemJoinRight.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemJoinRightActionPerformed(evt);
            }
        });
        
        jMenuPosition.add(jMenuItemJoinRight);
        
        jMenuItemLeftMargin.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_HOME, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemLeftMargin.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemLeftMargin.setText("Join left page margin");
        jMenuItemLeftMargin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemLeftMarginActionPerformed(evt);
            }
        });
        
        jMenuPosition.add(jMenuItemLeftMargin);
        
        jMenuItemRightMargin.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_END, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemRightMargin.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemRightMargin.setText("Join right page margin");
        jMenuItemRightMargin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemRightMarginActionPerformed(evt);
            }
        });
        
        jMenuPosition.add(jMenuItemRightMargin);
        
        jMenuFormat.add(jMenuPosition);
        
        jMenuFormat.add(jSeparator5);
        
        jMenuHSpacing.setText("Horizontal spacing...");
        jMenuHSpacing.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemHSMakeEqual.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemHSMakeEqual.setText("Make equal");
        jMenuItemHSMakeEqual.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemHSMakeEqualActionPerformed(evt);
            }
        });
        
        jMenuHSpacing.add(jMenuItemHSMakeEqual);
        
        jMenuItemHSIncrease.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemHSIncrease.setText("Increase");
        jMenuItemHSIncrease.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemHSIncreaseActionPerformed(evt);
            }
        });
        
        jMenuHSpacing.add(jMenuItemHSIncrease);
        
        jMenuItemHSDecrease.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemHSDecrease.setText("Decrease");
        jMenuItemHSDecrease.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemHSDecreaseActionPerformed(evt);
            }
        });
        
        jMenuHSpacing.add(jMenuItemHSDecrease);
        
        jMenuItemHSRemove.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemHSRemove.setText("Remove");
        jMenuItemHSRemove.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemHSRemoveActionPerformed(evt);
            }
        });
        
        jMenuHSpacing.add(jMenuItemHSRemove);
        
        jMenuFormat.add(jMenuHSpacing);
        
        jMenuVSpacing.setText("Vertical spacing");
        jMenuVSpacing.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemVSMakeEqual.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemVSMakeEqual.setText("Make equal");
        jMenuItemVSMakeEqual.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemVSMakeEqualActionPerformed(evt);
            }
        });
        
        jMenuVSpacing.add(jMenuItemVSMakeEqual);
        
        jMenuItemVSIncrease.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemVSIncrease.setText("Increase");
        jMenuItemVSIncrease.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemVSIncreaseActionPerformed(evt);
            }
        });
        
        jMenuVSpacing.add(jMenuItemVSIncrease);
        
        jMenuItemVSDecrease.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemVSDecrease.setText("Decrease");
        jMenuItemVSDecrease.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemVSDecreaseActionPerformed(evt);
            }
        });
        
        jMenuVSpacing.add(jMenuItemVSDecrease);
        
        jMenuItemVSRemove.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemVSRemove.setText("Remove");
        jMenuItemVSRemove.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemVSRemoveActionPerformed(evt);
            }
        });
        
        jMenuVSpacing.add(jMenuItemVSRemove);
        
        jMenuFormat.add(jMenuVSpacing);
        
        jMenuFormat.add(jSeparator8);
        
        jMenuItemOrganize.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemOrganize.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemOrganize.setIcon(new javax.swing.ImageIcon(""));
        jMenuItemOrganize.setText("Organize as a table");
        jMenuItemOrganize.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemOrganizeActionPerformed(evt);
            }
        });
        
        jMenuFormat.add(jMenuItemOrganize);
        
        jMenuItemBringToFront.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemBringToFront.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/sendtofront.gif")));
        jMenuItemBringToFront.setText("Bring to front");
        jMenuItemBringToFront.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemBringToFrontActionPerformed(evt);
            }
        });
        
        jMenuFormat.add(jMenuItemBringToFront);
        
        jMenuItemSendToBack.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemSendToBack.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/sendtoback.gif")));
        jMenuItemSendToBack.setText("Send to back");
        jMenuItemSendToBack.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSendToBackActionPerformed(evt);
            }
        });
        
        jMenuFormat.add(jMenuItemSendToBack);
        
        jMDIMenuBar.add(jMenuFormat);
        
        jMenuDatabase.setMnemonic('d');
        jMenuDatabase.setText("Datasource");
        jMenuDatabase.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemConnections.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemConnections.setText("Connections / Datasources");
        jMenuItemConnections.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemConnectionsActionPerformed(evt);
            }
        });
        
        jMenuDatabase.add(jMenuItemConnections);
        
        jMenuDatabase.add(jSeparator9);
        
        jMenuItemReportQuery2.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemReportQuery2.setText("Report query");
        jMenuItemReportQuery2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemReportQuery2ActionPerformed(evt);
            }
        });
        
        jMenuDatabase.add(jMenuItemReportQuery2);
        
        jMDIMenuBar.add(jMenuDatabase);
        
        jMenuTools.setMnemonic('t');
        jMenuTools.setText("Tools");
        jMenuTools.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemOptions.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemOptions.setText("Options...");
        jMenuItemOptions.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemOptionsActionPerformed(evt);
            }
        });
        
        jMenuTools.add(jMenuItemOptions);
        
        jMenuItemCompatibility.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemCompatibility.setText("Compatibility...");
        jMenuItemCompatibility.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCompatibilityActionPerformed(evt);
            }
        });
        
        jMenuTools.add(jMenuItemCompatibility);
        
        jMenuItemPluginConfig.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemPluginConfig.setText("Configure plugins");
        jMenuItemPluginConfig.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemPluginConfigActionPerformed(evt);
            }
        });
        
        jMenuTools.add(jMenuItemPluginConfig);
        
        jMenuItemClasspath.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemClasspath.setText("Classpath");
        jMenuItemClasspath.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemClasspathActionPerformed(evt);
            }
        });
        
        jMenuTools.add(jMenuItemClasspath);
        
        jMenuItemExportOptions.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemExportOptions.setText("Export options");
        jMenuItemExportOptions.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemExportOptionsActionPerformed(evt);
            }
        });
        
        jMenuTools.add(jMenuItemExportOptions);
        
        jMDIMenuBar.add(jMenuTools);
        
        jMenuPlugins.setText("Plugins");
        jMenuPlugins.setFont(new java.awt.Font("Dialog", 0, 11));
        jMDIMenuBar.add(jMenuPlugins);
        
        jMenuWindow.setMnemonic('w');
        jMenuWindow.setText("Window");
        jMenuWindow.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemCascade.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemCascade.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/win_cascade.gif")));
        jMenuItemCascade.setText("Cascade");
        jMenuItemCascade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCascadeActionPerformed(evt);
            }
        });
        
        jMenuWindow.add(jMenuItemCascade);
        
        jMenuItemTileHorizontal.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemTileHorizontal.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/win_htile.gif")));
        jMenuItemTileHorizontal.setText("Tile horizontal");
        jMenuItemTileHorizontal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemTileHorizontalActionPerformed(evt);
            }
        });
        
        jMenuWindow.add(jMenuItemTileHorizontal);
        
        jMenuItemTileVertical.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemTileVertical.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/win_vtile.gif")));
        jMenuItemTileVertical.setText("Tile vertical");
        jMenuItemTileVertical.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemTileVerticalActionPerformed(evt);
            }
        });
        
        jMenuWindow.add(jMenuItemTileVertical);
        
        jMenuItemtileAnodine.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemtileAnodine.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/win_atile.gif")));
        jMenuItemtileAnodine.setText("Tile anodine");
        jMenuItemtileAnodine.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemtileAnodineActionPerformed(evt);
            }
        });
        
        jMenuWindow.add(jMenuItemtileAnodine);
        
        jMenuItemNextWin.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemNextWin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/win_next.gif")));
        jMenuItemNextWin.setText("Next Window");
        jMenuItemNextWin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemNextWinActionPerformed(evt);
            }
        });
        
        jMenuWindow.add(jMenuItemNextWin);
        
        jMenuItemPrevWin.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemPrevWin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/businesslogic/ireport/icons/menu/win_prev.gif")));
        jMenuItemPrevWin.setText("Previous Window");
        jMenuItemPrevWin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemPrevWinActionPerformed(evt);
            }
        });
        
        jMenuWindow.add(jMenuItemPrevWin);
        
        jMenuWindow.add(jSeparator21);
        
        jMDIMenuBar.add(jMenuWindow);
        
        jMenuHelp.setMnemonic('h');
        jMenuHelp.setText("Help");
        jMenuHelp.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemHelp.setFont(new java.awt.Font("Dialog", 0, 11));
        jMenuItemHelp.setText("Help...");
        jMenuItemHelp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemHelpActionPerformed(evt);
            }
        });
        
        jMenuHelp.add(jMenuItemHelp);
        
        jMenuItemAbout.setFont(new java.awt.Font("Dialog", 1, 11));
        jMenuItemAbout.setText("About iReport...");
        jMenuItemAbout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAboutActionPerformed(evt);
            }
        });
        
        jMenuHelp.add(jMenuItemAbout);
        
        jMDIMenuBar.add(jMenuHelp);
        
        setJMenuBar(jMDIMenuBar);
        
        pack();
    }//GEN-END:initComponents

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

    private void jMenuItemSaveAllFromListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSaveAllFromListActionPerformed
        jMenuItemSaveAllActionPerformed( evt );
    }//GEN-LAST:event_jMenuItemSaveAllFromListActionPerformed

    private void jMenuItemSaveAsFromListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSaveAsFromListActionPerformed
        
        JReportFrame jrf = getSelectedJRFFromFilesTree();
        if (jrf != null) {
            saveAs( jrf );
        }
        
    }//GEN-LAST:event_jMenuItemSaveAsFromListActionPerformed

    private void jMenuItemSaveFromListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSaveFromListActionPerformed
        
        JReportFrame jrf = getSelectedJRFFromFilesTree();
        if (jrf != null) {
            save( jrf );
        }
    }//GEN-LAST:event_jMenuItemSaveFromListActionPerformed

    private void jMenuItemRevertToSavedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemRevertToSavedActionPerformed
        
        JReportFrame activeFrame = this.getActiveReportFrame();
        if (activeFrame != null) {
                        //
                        try {
                            if (activeFrame.getReport().getFilename() != null && new File(activeFrame.getReport().getFilename()).exists() )
                            {
                                String filename = activeFrame.getReport().getFilename();
                                jMDIMenuBar.closeFrame( activeFrame, true);
                                openFile(filename);
                            }
                        } catch (Exception ex)
                        {};
                        //dtn.getJrf().updateUI();
                        //jMDIDesktopPane.internalFrameActivated(dtn.getJrf());
                        //this.logOnConsole("Activated :"+dtn.getJrf().getReport().getFilename()+"\n");
                    }
    }//GEN-LAST:event_jMenuItemRevertToSavedActionPerformed

    private void jMenuItemRevertToSavedFromListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemRevertToSavedFromListActionPerformed
        
        JReportFrame jrf = getSelectedJRFFromFilesTree();
        if (jrf != null && jrf.getReport().getFilename() != null && new File(jrf.getReport().getFilename()).exists())
        {
            String filename = jrf.getReport().getFilename();
            jMDIMenuBar.closeFrame( jrf, true);
            openFile(filename);
        }

        
    }//GEN-LAST:event_jMenuItemRevertToSavedFromListActionPerformed

    private void jMenuItemCloseAllExceptThisFromListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCloseAllExceptThisFromListActionPerformed
        
        if (this.getActiveReportFrame() == null) return;
        JInternalFrame activeF = this.getActiveReportFrame();
        
        JReportFrame jrf = getSelectedJRFFromFilesTree();
        
        if (jrf != null) {
            //
            try {
                activeF = jrf;
            } catch (Exception ex)
            {};
            //dtn.getJrf().updateUI();
            //jMDIDesktopPane.internalFrameActivated(dtn.getJrf());
            //this.logOnConsole("Activated :"+dtn.getJrf().getReport().getFilename()+"\n");
        }

            
        JInternalFrame[] frames = this.jMDIDesktopPane.getAllFrames();
        for (int i=0; i<frames.length; ++i)
        {
            if (frames[i] != activeF)
            {
                jMDIMenuBar.closeFrame( frames[i] );
            }
        }
    }//GEN-LAST:event_jMenuItemCloseAllExceptThisFromListActionPerformed

    private void jMenuItemCloseAllFromListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCloseAllFromListActionPerformed
        jMenuItemCloseAllActionPerformed( evt );
    }//GEN-LAST:event_jMenuItemCloseAllFromListActionPerformed

    private void jMenuItemCloseFromListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCloseFromListActionPerformed
        
        JReportFrame jrf = getSelectedJRFFromFilesTree();

        if (jrf != null) {
            //
            try {
                jMDIMenuBar.closeFrame(jrf );
            } catch (Exception ex)
            {};
            //dtn.getJrf().updateUI();
            //jMDIDesktopPane.internalFrameActivated(dtn.getJrf());
            //this.logOnConsole("Activated :"+dtn.getJrf().getReport().getFilename()+"\n");
        }
        
    }//GEN-LAST:event_jMenuItemCloseFromListActionPerformed

    private void jMenuItemCloseAllExceptThisActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCloseAllExceptThisActionPerformed
        
        if (this.getActiveReportFrame() == null) return;
        JInternalFrame activeF = this.getActiveReportFrame();
        JInternalFrame[] frames = this.jMDIDesktopPane.getAllFrames();
        for (int i=0; i<frames.length; ++i)
        {
            if (frames[i] != activeF)
            {
                jMDIMenuBar.closeFrame( frames[i] );
            }
        }
    }//GEN-LAST:event_jMenuItemCloseAllExceptThisActionPerformed

    private void jMenuItemCloseAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCloseAllActionPerformed
        
        while (this.getActiveReportFrame() != null)
        {
            jMDIMenuBar.closeFrame( this.getActiveReportFrame() );
        }
        
    }//GEN-LAST:event_jMenuItemCloseAllActionPerformed

    private void jMenuItemCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCloseActionPerformed
        
        jMDIMenuBar.closeFrame( this.getActiveReportFrame() );
        
    }//GEN-LAST:event_jMenuItemCloseActionPerformed

    private void jMenuItemExportOptionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemExportOptionsActionPerformed
        it.businesslogic.ireport.gui.export.ExportPreferencesDialog epf = new it.businesslogic.ireport.gui.export.ExportPreferencesDialog(this, true);
        epf.setVisible(true);
        
    }//GEN-LAST:event_jMenuItemExportOptionsActionPerformed

    private void jMenuItemClasspathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemClasspathActionPerformed
        
        ClassPathDialog cpd = new ClassPathDialog(this, true);
        cpd.setClasspath( getClasspath() );
        cpd.setVisible(true);
        if (cpd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION )
        {
            setClasspath( cpd.getClasspath() );
        }
        
    }//GEN-LAST:event_jMenuItemClasspathActionPerformed

    private void jMenuItemCompileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCompileActionPerformed
      
        jButtonCompilerActionPerformed( evt );
        
    }//GEN-LAST:event_jMenuItemCompileActionPerformed

    private void jMenuItemCompileItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jMenuItemCompileItemStateChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemCompileItemStateChanged

    private void jMenuItemRemoveMarginsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemRemoveMarginsActionPerformed
       
        JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
        
        if (jrf == null) return;
        
        UndoOperation uo = new RemoveMarginsOperation(jrf,
                        jrf.getReport().getTopMargin(),
                        jrf.getReport().getBottomMargin(),
                        jrf.getReport().getLeftMargin(),
                        jrf.getReport().getRightMargin());
        uo.redo();

        jrf.addUndoOperation( uo );
    }//GEN-LAST:event_jMenuItemRemoveMarginsActionPerformed

    private void jMenuItemReportLocaleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemReportLocaleActionPerformed
      
        it.businesslogic.ireport.gui.locale.NewLocaleFileDialog fd = new it.businesslogic.ireport.gui.locale.NewLocaleFileDialog(this,true);
        fd.setVisible(true);
        
        if (fd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION)
        {
            String reportLocale = fd.getText();
            this.getProperties().setProperty("reportLocale", reportLocale);
            saveiReportConfiguration();
        	
            Locale loc = Misc.getLocaleFromString(reportLocale);
 	    updateJMenuItemReportLocaleText();
        }
        
        
    }//GEN-LAST:event_jMenuItemReportLocaleActionPerformed

    public void updateJMenuItemReportLocaleText()
    {
    	Locale loc = Misc.getLocaleFromString( this.getProperties().getProperty("reportLocale"));
    	jMenuItemReportLocale.setText(it.businesslogic.ireport.util.I18n.getString("setReportLocale", "Set report locale -" ) + " " + loc.getDisplayName() );	
    }
    
        
        
    private void jCheckBoxMenuItemEMMActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItemEMMActionPerformed
        
		getProperties().put("EMM",  ""+jCheckBoxMenuItemEMM.isSelected());
        	this.saveiReportConfiguration();        
        
    }//GEN-LAST:event_jCheckBoxMenuItemEMMActionPerformed

    private void jMenuItemHelpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemHelpActionPerformed
        
        String operatingSystem = System.getProperty("os.name");
        
       
            try {
                 if (operatingSystem.toLowerCase().indexOf("windows") > -1)
                 {
                        Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://ireport.sourceforge.net/docs.html");
                 }
                 else
                 {
                        // Try with htmlview...
                        Runtime.getRuntime().exec("htmlview http://ireport.sourceforge.net/docs.html &");
                 }
            } catch (Exception ex)
            {
                javax.swing.JOptionPane.showMessageDialog( this,"Unable to open http://ireport.sourceforge.net/docs.html", "", javax.swing.JOptionPane.ERROR_MESSAGE);
            }
        
    }//GEN-LAST:event_jMenuItemHelpActionPerformed

    private void jListThreadsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jListThreadsMouseClicked
        if (evt.getButton() == evt.BUTTON3) {
            this.jPopupMenuThreads.show(jListThreads, evt.getPoint().x, evt.getPoint().y);
        }
    }//GEN-LAST:event_jListThreadsMouseClicked

    private void jMenuItemKillActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemKillActionPerformed
        
        Object obj = this.jListThreads.getSelectedValue();
        if (obj != null)
        {
            IReportCompiler ic = (IReportCompiler)obj;
            ic.stopThread();
        }
        
    }//GEN-LAST:event_jMenuItemKillActionPerformed

    private void jMenuLocaleFilesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuLocaleFilesActionPerformed
        this.getLocaleFilesDialog().setVisible(true);
    }//GEN-LAST:event_jMenuLocaleFilesActionPerformed

    private void jMenuInternationalizationWizardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuInternationalizationWizardActionPerformed
        
        
        
    }//GEN-LAST:event_jMenuInternationalizationWizardActionPerformed

    private void jMenuItemReportImportsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemReportImportsActionPerformed
       JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
       
       ReportImportsDialog rsd = new ReportImportsDialog(this, true);
       rsd.setJReportFrame( jrf );
       rsd.setVisible(true);
       

    }//GEN-LAST:event_jMenuItemReportImportsActionPerformed

    private void jButtonAlignBottomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAlignBottomActionPerformed
        setElementsValue("setVerticalAlign", "Bottom");
    }//GEN-LAST:event_jButtonAlignBottomActionPerformed

    private void jButtonAlignMiddleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAlignMiddleActionPerformed
         setElementsValue("setVerticalAlign", "Middle");
    }//GEN-LAST:event_jButtonAlignMiddleActionPerformed

    private void jButtonAlignTopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAlignTopActionPerformed
        setElementsValue("setVerticalAlign", "Top");
    }//GEN-LAST:event_jButtonAlignTopActionPerformed

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

       JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
       if (jrf == null || jrf.getReport().getScriptletHandling() != Report.SCRIPTLET_IREPORT_INTERNAL_HANDLING ) {
                if (JOptionPane.showConfirmDialog(this,
                it.businesslogic.ireport.util.I18n.getString( "usingSeries",
                "To use the charts and series, you must leave iReport to handle the scriptlet class code internally.\n"+
                "You can set how handle scriptlet in report properties form.\n\nDo you want activate this option now?"),
                "Scriptlet editor", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE) != JOptionPane.OK_OPTION) {
                    return;
                }
                
                jrf.getReport().setScriptletHandling( Report.SCRIPTLET_IREPORT_INTERNAL_HANDLING );
            }
       
       it.businesslogic.ireport.chart.gui.ReportSeriesDialog rsd = new it.businesslogic.ireport.chart.gui.ReportSeriesDialog(this, true);
       rsd.setJReportFrame( jrf );
       rsd.setVisible(true);
       
       
    }//GEN-LAST:event_jMenuItemReportSeriesActionPerformed

    private void jButtonFormatCenterVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonFormatCenterVActionPerformed
        jMenuItemAlignVerticalAxisActionPerformed(evt);
    }//GEN-LAST:event_jButtonFormatCenterVActionPerformed

    private void jButtonFormatCenterHActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonFormatCenterHActionPerformed
        jMenuItemAlignHorizontalAxisActionPerformed(evt);
    }//GEN-LAST:event_jButtonFormatCenterHActionPerformed

    private void jButtonStrikethroughtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonStrikethroughtActionPerformed
        JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
        if (jrf == null) return;
        // Set the new value for all selected elements...
        boolean bool = false;
        Enumeration e = jrf.getSelectedElements().elements();
        while (e.hasMoreElements()) {
            ReportElement repele = (ReportElement)e.nextElement();
            if (repele instanceof TextReportElement)
            {
                TextReportElement element = (TextReportElement)repele;
                bool = ((TextReportElement)repele).isStrikeTrought();
                break;
            }
        }
        
        setElementsValue("setStrikeTrought", new Boolean(!bool), Boolean.TYPE);
        this.getElementPropertiesDialog().updateSelection();
    }//GEN-LAST:event_jButtonStrikethroughtActionPerformed

    private void jButtonUnderlineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonUnderlineActionPerformed
        
        JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
        if (jrf == null) return;
        // Set the new value for all selected elements...
        boolean bool = false;
        Enumeration e = jrf.getSelectedElements().elements();
        while (e.hasMoreElements()) {
            ReportElement repele = (ReportElement)e.nextElement();
            if (repele instanceof TextReportElement)
            {
                TextReportElement element = (TextReportElement)repele;
                bool = ((TextReportElement)repele).isUnderline();
                break;
            }
        }
        
        setElementsValue("setUnderline", new Boolean(!bool), Boolean.TYPE);
        this.getElementPropertiesDialog().updateSelection();
    }//GEN-LAST:event_jButtonUnderlineActionPerformed

    private void jButtonItalicActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonItalicActionPerformed
       JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
        if (jrf == null) return;
        // Set the new value for all selected elements...
        boolean bool = false;
        Enumeration e = jrf.getSelectedElements().elements();
        while (e.hasMoreElements()) {
            ReportElement repele = (ReportElement)e.nextElement();
            if (repele instanceof TextReportElement)
            {
                TextReportElement element = (TextReportElement)repele;
                bool = ((TextReportElement)repele).isItalic();
                break;
            }
        }
        
        setElementsValue("setItalic", new Boolean(!bool), Boolean.TYPE);
        this.getElementPropertiesDialog().updateSelection();
    }//GEN-LAST:event_jButtonItalicActionPerformed

    private void jButtonBoldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBoldActionPerformed
        
        JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
        if (jrf == null) return;
        // Set the new value for all selected elements...
        boolean bool = false;
        Enumeration e = jrf.getSelectedElements().elements();
        while (e.hasMoreElements()) {
            ReportElement repele = (ReportElement)e.nextElement();
            if (repele instanceof TextReportElement)
            {
                TextReportElement element = (TextReportElement)repele;
                bool = ((TextReportElement)repele).isBold();
                break;
            }
        }
        
        setElementsValue("setBold", new Boolean(!bool), Boolean.TYPE);
        this.getElementPropertiesDialog().updateSelection();
    }//GEN-LAST:event_jButtonBoldActionPerformed

    private void jButtonDecreaseSizeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDecreaseSizeActionPerformed
        setElementsValue("modifyFontSize", new Integer(-2), Integer.TYPE);
        this.getElementPropertiesDialog().updateSelection();
    }//GEN-LAST:event_jButtonDecreaseSizeActionPerformed

    private void jButtonIncreaseSizeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonIncreaseSizeActionPerformed
        setElementsValue("modifyFontSize", new Integer(2), Integer.TYPE);
        this.getElementPropertiesDialog().updateSelection();
    }//GEN-LAST:event_jButtonIncreaseSizeActionPerformed

    private void jComboBoxFontItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBoxFontItemStateChanged
        if (!this.isDontHandleEvent() && jComboBoxFont.getSelectedItem() != null)
        {
            setElementsValue("setFontName", ""+ jComboBoxFont.getSelectedItem());
            this.getElementPropertiesDialog().updateSelection();
        }
    }//GEN-LAST:event_jComboBoxFontItemStateChanged

    private void jNumberComboBoxSizeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jNumberComboBoxSizeItemStateChanged
        if (!this.isDontHandleEvent())
        {
            setElementsValue("setFontSize", new Integer((int)jNumberComboBoxSize.getValue()), Integer.TYPE);
            this.getElementPropertiesDialog().updateSelection();
        }
    }//GEN-LAST:event_jNumberComboBoxSizeItemStateChanged

    private void jNumberComboBoxSizeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNumberComboBoxSizeActionPerformed
        
        setElementsValue("setFontSize", new Integer((int)jNumberComboBoxSize.getValue()), Integer.TYPE);
    }//GEN-LAST:event_jNumberComboBoxSizeActionPerformed

    private void jCheckBoxMenuItemElementsFormattingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItemElementsFormattingActionPerformed
        jToolBarFormat.setVisible( jCheckBoxMenuItemElementsFormatting.isSelected());
        getProperties().put("toolbarFormattingVisible",  ""+jCheckBoxMenuItemElementsFormatting.isSelected());
        this.saveiReportConfiguration();
    }//GEN-LAST:event_jCheckBoxMenuItemElementsFormattingActionPerformed

    private void jCheckBoxMenuItemTextFormattingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItemTextFormattingActionPerformed
        jToolBarText.setVisible( jCheckBoxMenuItemTextFormatting.isSelected());
        getProperties().put("toolbarTextVisible",  ""+jCheckBoxMenuItemTextFormatting.isSelected());
        this.saveiReportConfiguration();
    }//GEN-LAST:event_jCheckBoxMenuItemTextFormattingActionPerformed

    private void jButtonAlignRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAlignRightActionPerformed
        setElementsValue("setAlign", "Right");
    }//GEN-LAST:event_jButtonAlignRightActionPerformed

    private void jButtonAlignCenterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAlignCenterActionPerformed
        setElementsValue("setAlign", "Center");
    }//GEN-LAST:event_jButtonAlignCenterActionPerformed

    private void jButtonAlignJustifyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAlignJustifyActionPerformed
        setElementsValue("setAlign", "Justified");
    }//GEN-LAST:event_jButtonAlignJustifyActionPerformed

    private void jButtonAlignLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAlignLeftActionPerformed
        setElementsValue("setAlign", "Left");
    }//GEN-LAST:event_jButtonAlignLeftActionPerformed
    
    public void jMenuItemOrganizeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemOrganizeActionPerformed
        formatMenuPerformed( OperationType.ORGANIZE_AS_A_TABLE);
    }//GEN-LAST:event_jMenuItemOrganizeActionPerformed
    
    public void jMenuItemLeftMarginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemLeftMarginActionPerformed
        formatMenuPerformed( OperationType.ALIGN_TO_LEFT_MARGIN);
    }//GEN-LAST:event_jMenuItemLeftMarginActionPerformed
    
    public void jMenuItemRightMarginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemRightMarginActionPerformed
        formatMenuPerformed( OperationType.ALIGN_TO_RIGHT_MARGIN);
    }//GEN-LAST:event_jMenuItemRightMarginActionPerformed
    
    private void jNumberComboBoxZoomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNumberComboBoxZoomActionPerformed
        //System.out.println( "Zoom: " + jNumberComboBoxZoom.getValue());
    }//GEN-LAST:event_jNumberComboBoxZoomActionPerformed
    
    private void jMenuItemPluginConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemPluginConfigActionPerformed
        
        
        getPluginConfigurationDialog().setVisible(true);
        
    }//GEN-LAST:event_jMenuItemPluginConfigActionPerformed
    
    private void jMenuItemDS_deleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDS_deleteActionPerformed
        this.jMenuItemDeleteActionPerformed(evt);
    }//GEN-LAST:event_jMenuItemDS_deleteActionPerformed
    
    private void jMenuItemDS_pasteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDS_pasteActionPerformed
        this.jMenuItemPasteActionPerformed(evt);
    }//GEN-LAST:event_jMenuItemDS_pasteActionPerformed
    
    private void jMenuItemDS_copyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDS_copyActionPerformed
        this.jMenuItemCopyActionPerformed(evt);
    }//GEN-LAST:event_jMenuItemDS_copyActionPerformed
    
    private void jMenuItemDSB_propertiesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDSB_propertiesActionPerformed
        
        if (jTreeDocument.getSelectionCount() > 0) {
            DefaultMutableTreeNode elementNode = (DefaultMutableTreeNode)jTreeDocument.getSelectionPath().getLastPathComponent();
            if (elementNode.getUserObject() instanceof Band) {
                String thisBand = ((Band)elementNode.getUserObject()).getName();
                this.jMenuItemBandsActionPerformed(evt);
                this.getBandsDialog().setSelectedBand( thisBand );
            }
        }
        
        
        
        
    }//GEN-LAST:event_jMenuItemDSB_propertiesActionPerformed
    
    private void jMenuItemDS_cutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDS_cutActionPerformed
        this.jMenuItemCutActionPerformed(evt);
    }//GEN-LAST:event_jMenuItemDS_cutActionPerformed
    
    private void jMenuItemDS_propertiesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDS_propertiesActionPerformed
        this.jMenuItemPropertiesActionPerformed(evt);
    }//GEN-LAST:event_jMenuItemDS_propertiesActionPerformed
    
    
    private void jMenuItemMoveDownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemMoveDownActionPerformed
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
            jrf.moveDown();
            if (jrf.getSelectedElements().size()>0)
                updateDocumentStructureTree(jrf);
            
        }
    }//GEN-LAST:event_jMenuItemMoveDownActionPerformed
    
    private void jMenuItemMoveUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemMoveUpActionPerformed
        
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame)
        {;
         JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
         jrf.moveUp();
         if (jrf.getSelectedElements().size()>0)
             updateDocumentStructureTree(jrf);
         
        }
        
    }//GEN-LAST:event_jMenuItemMoveUpActionPerformed
    
    private void jTreeDocumentMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTreeDocumentMousePressed
                
        if (evt.getButton() == evt.BUTTON3) {
            if (jMDIDesktopPane.getSelectedFrame() != null &&
            jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
                JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
                if (jTreeDocument.getSelectionCount() > 0) {
                    DefaultMutableTreeNode elementNode = (DefaultMutableTreeNode)jTreeDocument.getSelectionPath().getLastPathComponent();
                    if (elementNode.getUserObject() instanceof ReportElement) {
                        // (ReportElement)elementNode.getUserObject());
                        this.jPopupMenuDocumentStructure.show(jTreeDocument, evt.getPoint().x, evt.getPoint().y);
                        
                    } else if (elementNode.getUserObject() instanceof Band) {
                        // (ReportElement)elementNode.getUserObject());
                        this.jPopupMenuDocumentStructureBand.show(jTreeDocument, evt.getPoint().x, evt.getPoint().y);
                        
                    }
                }
            }
            
        }
        else if (evt.getButton() == evt.BUTTON1 && evt.getClickCount() == 2) {
            if (jMDIDesktopPane.getSelectedFrame() != null &&
            jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
                JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
                if (jrf.getSelectedElements().size() > 0) {
                    this.getElementPropertiesDialog().setVisible(true);
                    this.getElementPropertiesDialog().updateSelection();
                }
            }
        }
    }//GEN-LAST:event_jTreeDocumentMousePressed
    
    private void jScrollPaneFilesMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jScrollPaneFilesMousePressed
        
    }//GEN-LAST:event_jScrollPaneFilesMousePressed
    
    private void jTreeFilesMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTreeFilesMousePressed
        if (evt.getButton() == evt.BUTTON3) {
            if (jTreeFiles.getSelectionCount() > 0) {
                    this.jPopupMenuFiles.show(jTreeFiles, evt.getPoint().x, evt.getPoint().y);
                }
        }  
    }//GEN-LAST:event_jTreeFilesMousePressed
    
    private void jRadioButtonMenuItemPreviewTXTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonMenuItemPreviewTXTActionPerformed
        this.setReportViewer(IREPORT_TXT_VIEWER);
    }//GEN-LAST:event_jRadioButtonMenuItemPreviewTXTActionPerformed
    
	private void jToggleButtonBarcodeToolItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jToggleButtonBarcodeToolItemStateChanged
            if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
                if (jMDIDesktopPane.getSelectedFrame() != null &&
                jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
                    JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
                    jrf.setNewObjectType( ReportElementType.BARCODE_ELEMENT);
                    jrf.setLensMode(false);
                }
                setActiveTool(jToggleButtonBarcodeTool);
            }
	}//GEN-LAST:event_jToggleButtonBarcodeToolItemStateChanged
        
	private void jToggleButtonBarcodeToolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonBarcodeToolActionPerformed
            jToggleButtonBarcodeTool.setSelected(true);
	}//GEN-LAST:event_jToggleButtonBarcodeToolActionPerformed
        
    private void jMenuItemChartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemChartActionPerformed
        jToggleButtonChartToolItemStateChanged(new java.awt.event.ItemEvent(jToggleButtonChartTool,0,jToggleButtonChartTool, java.awt.event.ItemEvent.SELECTED));
    }//GEN-LAST:event_jMenuItemChartActionPerformed
    
    private void jMenuItemImageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemImageActionPerformed
        jToggleButtonImageToolItemStateChanged(new java.awt.event.ItemEvent(jToggleButtonImageTool,0,jToggleButtonImageTool, java.awt.event.ItemEvent.SELECTED));
    }//GEN-LAST:event_jMenuItemImageActionPerformed
    
    private void jToggleButtonChartToolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonChartToolActionPerformed
        jToggleButtonChartTool.setSelected(true);
    }//GEN-LAST:event_jToggleButtonChartToolActionPerformed
    
    private void jMenuProjectsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuProjectsActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuProjectsActionPerformed
    
    private void jMenuItemScriptletEditorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemScriptletEditorActionPerformed
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
            
            if (jrf == null || jrf.getReport().getScriptletHandling() != Report.SCRIPTLET_IREPORT_INTERNAL_HANDLING ) {
                if (JOptionPane.showConfirmDialog(this,
                "To use the scriptlet editor, you must leave iReport to handle the scriptlet class code internally.\n"+
                "You can set how handle scriptlet in report properties form.\n\nDo you want activate this option now?",
                "Scriptlet editor", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE) != JOptionPane.OK_OPTION) {
                    return;
                }
                
                jrf.getReport().setScriptletHandling( Report.SCRIPTLET_IREPORT_INTERNAL_HANDLING );
            }
            
            this.getEventsForm().setVisible(true);
            this.getEventsForm().setJReportFrame( jrf );
        }
    }//GEN-LAST:event_jMenuItemScriptletEditorActionPerformed
    
    private void jMenuItemPropertiesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemPropertiesActionPerformed
        
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
            PropertiesDialog pd = new PropertiesDialog(this, true);
            pd.setJReportFrame( jrf );
            pd.updateProperties();
            
            pd.show();
        }
    }//GEN-LAST:event_jMenuItemPropertiesActionPerformed
    
   private void jRadioButtonMenuItemPreviewCSVActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jRadioButtonMenuItemPreviewCSVActionPerformed
   {//GEN-HEADEREND:event_jRadioButtonMenuItemPreviewCSVActionPerformed
       this.setReportViewer(IREPORT_CSV_VIEWER);
   }//GEN-LAST:event_jRadioButtonMenuItemPreviewCSVActionPerformed
   
   private void jRadioButtonMenuItemPreviewXLSActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jRadioButtonMenuItemPreviewXLSActionPerformed
   {//GEN-HEADEREND:event_jRadioButtonMenuItemPreviewXLSActionPerformed
       this.setReportViewer(IREPORT_XLS_VIEWER);
   }//GEN-LAST:event_jRadioButtonMenuItemPreviewXLSActionPerformed
   
   private void jRadioButtonMenuItemPreviewJAVAActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jRadioButtonMenuItemPreviewJAVAActionPerformed
   {//GEN-HEADEREND:event_jRadioButtonMenuItemPreviewJAVAActionPerformed
       this.setReportViewer(IREPORT_JAVA_VIEWER);
   }//GEN-LAST:event_jRadioButtonMenuItemPreviewJAVAActionPerformed
   
   private void jRadioButtonMenuItemPreviewHTMLActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jRadioButtonMenuItemPreviewHTMLActionPerformed
   {//GEN-HEADEREND:event_jRadioButtonMenuItemPreviewHTMLActionPerformed
       this.setReportViewer(IREPORT_HTML_VIEWER);
   }//GEN-LAST:event_jRadioButtonMenuItemPreviewHTMLActionPerformed
   
   private void jMenuItemQuitActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jMenuItemQuitActionPerformed
   {//GEN-HEADEREND:event_jMenuItemQuitActionPerformed
       this.closeApplication();
   }//GEN-LAST:event_jMenuItemQuitActionPerformed
                   
    private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
        // Checking for documents update outside iReport...
        
        if (!catchFormActivated) return;
        catchFormActivated = false;
        if (checkModifiedFielsThread == null || !checkModifiedFielsThread.isAlive()) {
            checkModifiedFielsThread= new Thread( this );
            checkModifiedFielsThread.start();
        }
    }//GEN-LAST:event_formWindowActivated
    
    
    public JReportFrame openFile(String filename){
        
        return openFile(new File(filename));
    }
    
    public JReportFrame openFile(File file){
        
        JReportFrame reportFrame;
        reportFrame = findReportFrameByFile(file);

        
        if( reportFrame == null ){
            try {
                Report report = new Report(file.getPath());
                report.setUsingMultiLineExpressions( false ); //this.isUsingMultiLineExpressions());
                reportFrame = openNewReportWindow( report );
            } catch (Exception e ) {
                logOnConsole( e.getMessage() + "\n" );
            }
            
        } else {
            setActiveReportForm(reportFrame);
        }
        
        return reportFrame;
    }
    
    
    /**
     * Test if the passed string is empty.
     * @param str
     * @return Returns true if empty.
     */
    private boolean isEmptyString(String str){
        return (str == null || str.trim().length() == 0);
    }
    
    /**
     * Search for a opened file in the iReport Designer.
     *
     * @param file File to search.
     * @return The JReportFrame.
     */
    private JReportFrame findReportFrameByFile(File fileToSearch){
        
        if(fileToSearch != null){
            
            javax.swing.JInternalFrame[] frames = jMDIDesktopPane.getAllFrames();
            JReportFrame jrf;
            String  frameFilename;
            
            for (int i=0; i< frames.length; ++i) {
                if (frames[i]  instanceof JReportFrame) {
                    jrf = (JReportFrame)frames[i];
                    
                    frameFilename = jrf.getReport().getFilename();
                    if (!isEmptyString(frameFilename) && fileToSearch.equals(new File(frameFilename))) {
                        return jrf;
                    }
                }
            }
        }
        
        return null;
    }
    
    /**
     * Search for a opened file in the iReport Designer.
     *
     * @param filename Filename to find.
     * @return The JReportFrame.
     */
    private JReportFrame findReportFrameByFilename(String filename){
        
        if(!isEmptyString(filename)){
            return findReportFrameByFile(new File(filename));
        }
        
        return null;
    }
    
    
    public void checkForModifiedFiles() {
        //if (!catchFormActivated) return;
        catchFormActivated = false;
        
        javax.swing.JInternalFrame[] frames = jMDIDesktopPane.getAllFrames();
        String filename;
        JReportFrame jrf;
        long time;
        Report report;
        int res;
        
        for (int i=0; i< frames.length; ++i) {
            
            if (frames[i]  instanceof JReportFrame) {
                
                jrf = (JReportFrame)frames[i];
                filename = jrf.getReport().getFilename();
                
                if ( !isEmptyString(filename) ) {
                    
                    time = Misc.getLastWriteTime(filename);
                    
                    if (jrf.getReport().getLoadTime() < time ) {
                        
                        //System.out.println("Trovato: "+filename);
                        res = javax.swing.JOptionPane.showConfirmDialog(this, filename +"\n\nThis file has been modified outside iReport.Do you want reload it?","iReport",javax.swing.JOptionPane.INFORMATION_MESSAGE);
                        if (res == javax.swing.JOptionPane.OK_OPTION) {
                            setCurrentZoomFactor( jrf.getZoomFactor() );
                            jrf.doDefaultCloseAction();
                            openFile(filename);
                            setCurrentZoomFactor( 1.0 ); //reset
                            
                        } else {
                            jrf.getReport().setLoadTime(time);
                        }
                    }
                }
            }
        }
        catchFormActivated = true;
    }
    
    /**
     *Used to determine if a save all is required.
     */
    public boolean isSaveAllRequired() {
        boolean ret = false;
        javax.swing.JInternalFrame[] frames = jMDIDesktopPane.getAllFrames();
        for (int i=0; i< frames.length; ++i) {
            if (frames[i]  instanceof JReportFrame) {
                JReportFrame jrf = (JReportFrame)frames[i];
                Report checkMe = jrf.getReport();
                if( checkMe == null ) {
                    ret = ( ret || false );
                }
                else {
                    ret = ( ret || checkMe.isModified() );
                }
                
            }//end if instance of JReportFrame
        }//end for frames
        return ret;
    }//end isSaveAllRequired
    
    private void jMenuItemXMLSourceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemXMLSourceActionPerformed
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
            if (jrf.getReport().getFilename() == null ||
            jrf.getReport().getFilename().equals("")) {
                int res = javax.swing.JOptionPane.showConfirmDialog(this, "You must save your file before editing it with an external editor!\nSave it now ?","",javax.swing.JOptionPane.INFORMATION_MESSAGE);
                if (res == javax.swing.JOptionPane.OK_OPTION) {
                    jMenuItemSaveActionPerformed(evt);
                }
                else
                    return;
            }
            else {
                int res = javax.swing.JOptionPane.showConfirmDialog(this, "The document could have been modified!\nWould you like to save it before launching the external editor?","",javax.swing.JOptionPane.INFORMATION_MESSAGE);
                if (res == javax.swing.JOptionPane.OK_OPTION) {
                    jMenuItemSaveActionPerformed(evt);
                }
            }
            if (jrf.getReport().getFilename() == null ||
            jrf.getReport().getFilename().equals("")) return;
            
            Runtime rt = Runtime.getRuntime();
            String editor = "notepad.exe";
            try {
                if (this.getProperties().getProperty("ExternalEditor")!=null)
                    editor = (String)this.getProperties().getProperty("ExternalEditor");
                if (editor == null || editor.equals("")) {
                    this.logOnConsole("Using notepad.exe as default editor!\n",false);
                    editor = "notepad.exe";
                }
                
                // WRONG ON UNIX: rt.exec(editor+ " \"" +jrf.getReport().getFilename()+"\"");
                // String tokenizer wasn't parsing the command and arguments
		// properly, so pass them in as separate elements.
		rt.exec(new String[] { editor, jrf.getReport().getFilename() });
            } catch (Exception ex) {
                javax.swing.JOptionPane.showMessageDialog(this, "An exception is occured executing:\n"+ editor+ " \"" +jrf.getReport().getFilename()+"\"","",javax.swing.JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_jMenuItemXMLSourceActionPerformed
    
    public void jMenuItemVSRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemVSRemoveActionPerformed
        //formatMenuPerformed( OperationType.REMOVE_SPACE_V);
        FormatCommand.getCommand(OperationType.REMOVE_SPACE_V ).execute();
    }//GEN-LAST:event_jMenuItemVSRemoveActionPerformed
    
    public void jMenuItemVSDecreaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemVSDecreaseActionPerformed
        formatMenuPerformed( OperationType.DECREASE_SPACE_V);
    }//GEN-LAST:event_jMenuItemVSDecreaseActionPerformed
    
    public void jMenuItemVSMakeEqualActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemVSMakeEqualActionPerformed
        formatMenuPerformed( OperationType.EQUALS_SPACE_V);
    }//GEN-LAST:event_jMenuItemVSMakeEqualActionPerformed
    
    public void jMenuItemHSRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemHSRemoveActionPerformed
        formatMenuPerformed( OperationType.REMOVE_SPACE_H);
    }//GEN-LAST:event_jMenuItemHSRemoveActionPerformed
    
    public void jMenuItemHSIncreaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemHSIncreaseActionPerformed
        formatMenuPerformed( OperationType.INCREASE_SPACE_H);
    }//GEN-LAST:event_jMenuItemHSIncreaseActionPerformed
    
    public void jMenuItemHSMakeEqualActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemHSMakeEqualActionPerformed
        formatMenuPerformed( OperationType.EQUALS_SPACE_H);
    }//GEN-LAST:event_jMenuItemHSMakeEqualActionPerformed
    
    public void jMenuItemJoinRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemJoinRightActionPerformed
        formatMenuPerformed( OperationType.JOIN_RIGHT);
    }//GEN-LAST:event_jMenuItemJoinRightActionPerformed
    
    public void jMenuItemJoinLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemJoinLeftActionPerformed
        formatMenuPerformed( OperationType.JOIN_LEFT);
    }//GEN-LAST:event_jMenuItemJoinLeftActionPerformed
    
    public void jMenuItemCenterBackgroundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCenterBackgroundActionPerformed
        formatMenuPerformed( OperationType.CENTER_IN_BACKGROUND);
    }//GEN-LAST:event_jMenuItemCenterBackgroundActionPerformed
    
    public void jMenuItemCenterInBandActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCenterInBandActionPerformed
        formatMenuPerformed( OperationType.CENTER_IN_BAND);
    }//GEN-LAST:event_jMenuItemCenterInBandActionPerformed
    
    public void jMenuItemCenterVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCenterVActionPerformed
        formatMenuPerformed( OperationType.CENTER_IN_BAND_V);
    }//GEN-LAST:event_jMenuItemCenterVActionPerformed
    
    public void jMenuItemCenterHActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCenterHActionPerformed
        formatMenuPerformed( OperationType.CENTER_IN_BAND_H);
    }//GEN-LAST:event_jMenuItemCenterHActionPerformed
    
    public void jMenuItemSameSizeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSameSizeActionPerformed
        formatMenuPerformed( OperationType.SAME_SIZE);
    }//GEN-LAST:event_jMenuItemSameSizeActionPerformed
    
    public void jMenuItemSameHeightMaxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSameHeightMaxActionPerformed
        formatMenuPerformed( OperationType.SAME_HEIGHT_MAX);
    }//GEN-LAST:event_jMenuItemSameHeightMaxActionPerformed
    
    public void jMenuItemSameHeightMinActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSameHeightMinActionPerformed
        formatMenuPerformed( OperationType.SAME_HEIGHT_MIN);
    }//GEN-LAST:event_jMenuItemSameHeightMinActionPerformed
    
    public void jMenuItemSameHeightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSameHeightActionPerformed
        formatMenuPerformed( OperationType.SAME_HEIGHT);
    }//GEN-LAST:event_jMenuItemSameHeightActionPerformed
    
    public void jMenuItemSameWidthMinActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSameWidthMinActionPerformed
        formatMenuPerformed( OperationType.SAME_WIDTH_MIN);
    }//GEN-LAST:event_jMenuItemSameWidthMinActionPerformed
    
    public void jMenuItemSameWidthMaxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSameWidthMaxActionPerformed
        formatMenuPerformed( OperationType.SAME_WIDTH_MAX);
    }//GEN-LAST:event_jMenuItemSameWidthMaxActionPerformed
    
    public void jMenuItemSameWidthActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSameWidthActionPerformed
        formatMenuPerformed( OperationType.SAME_WIDTH);
    }//GEN-LAST:event_jMenuItemSameWidthActionPerformed
    
    public void jMenuItemAlignToBandBottomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAlignToBandBottomActionPerformed
        formatMenuPerformed( OperationType.ALIGN_BOTTOM_TO_BAND);
    }//GEN-LAST:event_jMenuItemAlignToBandBottomActionPerformed
    
    public void jMenuItemAlignToBandTopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAlignToBandTopActionPerformed
        formatMenuPerformed( OperationType.ALIGN_TOP_TO_BAND);
    }//GEN-LAST:event_jMenuItemAlignToBandTopActionPerformed
    
    public void jMenuItemAlignHorizontalAxisActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAlignHorizontalAxisActionPerformed
        formatMenuPerformed( OperationType.ALIGN_HORIZONTAL_AXIS);
    }//GEN-LAST:event_jMenuItemAlignHorizontalAxisActionPerformed
    
    public void jMenuItemAlignVerticalAxisActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAlignVerticalAxisActionPerformed
        formatMenuPerformed( OperationType.ALIGN_VERTICAL_AXIS);
    }//GEN-LAST:event_jMenuItemAlignVerticalAxisActionPerformed
    
    public void jMenuItemAlignBottomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAlignBottomActionPerformed
        formatMenuPerformed( OperationType.ALIGN_BOTTOM);
    }//GEN-LAST:event_jMenuItemAlignBottomActionPerformed
    
    public void jMenuItemAlignTopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAlignTopActionPerformed
        formatMenuPerformed( OperationType.ALIGN_TOP);
    }//GEN-LAST:event_jMenuItemAlignTopActionPerformed
    
    public void jMenuItemAlignRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAlignRightActionPerformed
        formatMenuPerformed( OperationType.ALIGN_RIGHT);
    }//GEN-LAST:event_jMenuItemAlignRightActionPerformed
    
    public void formatMenuPerformed(int operationType) {
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
            jrf.makeOperation( operationType );
            if (jrf.getSelectedElements().size()>0)
                updateDocumentStructureTree(jrf);
        }
    }
    
    public void jMenuItemAlignLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAlignLeftActionPerformed
        // Align all element to left....
        formatMenuPerformed( OperationType.ALIGN_LEFT);
    }//GEN-LAST:event_jMenuItemAlignLeftActionPerformed
    
    private void jRadioButtonMenuItemPreviewInternalViewerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonMenuItemPreviewInternalViewerActionPerformed
        this.setReportViewer(IREPORT_JASPER_VIEWER);
    }//GEN-LAST:event_jRadioButtonMenuItemPreviewInternalViewerActionPerformed
    
    public void jMenuItemSendToBackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSendToBackActionPerformed
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
            jrf.sendToBack();
            if (jrf.getSelectedElements().size()>0)
                updateDocumentStructureTree(jrf);
        }
    }//GEN-LAST:event_jMenuItemSendToBackActionPerformed
    
    public void jMenuItemBringToFrontActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemBringToFrontActionPerformed
        
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
            jrf.bringToFront();
            if (jrf.getSelectedElements().size()>0)
                updateDocumentStructureTree(jrf);
        }
    }//GEN-LAST:event_jMenuItemBringToFrontActionPerformed
    
    private void jMenuItemWizardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemWizardActionPerformed
        
        if (this.getProperties().get("DefaultConnection") == null ||
        !( this.getProperties().get("DefaultConnection") instanceof it.businesslogic.ireport.connection.JDBCConnection) ) {
            javax.swing.JOptionPane.showMessageDialog(this, "Before start the Wizard, you must configure a JDBC connection\nand set it the active connection.\n\nIf you have already created and tested a JDBC connection go to the menu\nbuild->set active connection and select your entry.\nIf you have not yet setup a JDBC connection go to\nDatasources->Connection/Datasources to create one.","",javax.swing.JOptionPane.ERROR_MESSAGE);
            return;
        }
        
        WizardDialog wd = new WizardDialog(this,true);
        wd.show();
        if (wd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
            Report report = wd.getReport();
            if (report != null) {
                // Name the report...
                
                openNewReportWindow(report);
            }
        }
        
    }//GEN-LAST:event_jMenuItemWizardActionPerformed
    
    private void jMenuItemReportPropertiesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemReportPropertiesActionPerformed
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
            ReportPropertiesFrame rpf = new ReportPropertiesFrame(this,true);
            rpf.setModal(true);
            
            rpf.setBottomMargin( jrf.getReport().getBottomMargin());
            rpf.setColumns( jrf.getReport().getColumnCount());
            rpf.setColumnsSpacing( jrf.getReport().getColumnSpacing());
            rpf.setColumnsWidth( jrf.getReport().getColumnWidth());
            //rpf.setGlobalUnit( jrf.getReport().getGlobalUnit());
            rpf.setLeftMargin(jrf.getReport().getLeftMargin());
            rpf.setOrientation( jrf.getReport().getOrientation());
            rpf.setPrintOrder( jrf.getReport().getPrintOrder());
            rpf.setReportFormat( jrf.getReport().getReportFormat());
            rpf.setReportHeight( jrf.getReport().getHeight());
            rpf.setReportName( jrf.getReport().getName());
            rpf.setReportWidth( jrf.getReport().getWidth());
            rpf.setRightMargin( jrf.getReport().getRightMargin());
            rpf.setScriptletClass( jrf.getReport().getScriptletClass());
            rpf.setScriptletHandling( jrf.getReport().getScriptletHandling() );
            rpf.setSummaryOnNewPage( jrf.getReport().isIsSummaryNewPage());
            rpf.setTitleOnNewPage(jrf.getReport().isIsTitleNewPage());
            rpf.setTopMargin( jrf.getReport().getTopMargin());
            rpf.setWhenNoDataType( jrf.getReport().getWhenNoDataType());
            rpf.setXmlEncoding( jrf.getReport().getEncoding());
            rpf.setFloatColumnFooter( jrf.getReport().isFloatColumnFooter());
            rpf.setResourceBundleBaseName( jrf.getReport().getResourceBundleBaseName() );
            rpf.setLanguage( jrf.getReport().getLanguage() );
            
            //System.out.println("Il nome :"+rpf.getReportName()+" (old)");
            rpf.show();
            if (rpf.getDialogResult() == JOptionPane.OK_OPTION) {
                // Change report...
                jrf.getReport().setDirty(true);
                //javax.swing.JOptionPane.showMessageDialog(null,""+rpf.getReportName());
                // First all fields that don't modify layout...
                jrf.getReport().setWidth(rpf.getReportWidth());
                jrf.getReport().setHeight(rpf.getReportHeight());
                jrf.getReport().setOrientation(rpf.getOrientation());
                jrf.getReport().setName(rpf.getReportName());
                int oldTop = jrf.getReport().getTopMargin();
                jrf.getReport().setTopMargin(rpf.getTopMargin());
                int differenceY = jrf.getReport().getTopMargin() - oldTop;
                
                int oldLeft = jrf.getReport().getLeftMargin();
                jrf.getReport().setLeftMargin(rpf.getLeftMargin());
                int differenceX = jrf.getReport().getLeftMargin() - oldLeft;
                if (differenceX != 0 || differenceY != 0) {
                    Enumeration e = jrf.getReport().getElements().elements();
                    while (e.hasMoreElements()) {
                        ReportElement re = (ReportElement)e.nextElement();
                        re.trasform(new java.awt.Point(differenceX,differenceY), TransformationType.TRANSFORMATION_MOVE);
                    }
                }
                
                jrf.getReport().setLanguage(rpf.getLanguage());
                jrf.getReport().setRightMargin(rpf.getRightMargin());
                jrf.getReport().setBottomMargin(rpf.getBottomMargin());
                jrf.getReport().setColumnCount(rpf.getColumns());
                jrf.getReport().setColumnWidth(rpf.getColumnsWidth());
                jrf.getReport().setColumnSpacing(rpf.getColumnsSpacing());
                jrf.getReport().setIsSummaryNewPage(rpf.isSummaryOnNewPage());
                jrf.getReport().setIsTitleNewPage(rpf.isTitleOnNewPage());
                jrf.getReport().setWhenNoDataType(rpf.getWhenNoDataType());
                jrf.getReport().setScriptletClass(rpf.getScriptletClass());
                jrf.getReport().setEncoding(rpf.getXmlEncoding());
                jrf.getReport().setPrintOrder(rpf.getPrintOrder());
                jrf.getReport().setReportFormat(rpf.getReportFormat());
                jrf.getReport().setFloatColumnFooter(rpf.isFloatColumnFooter());
                jrf.getReport().setScriptletHandling( rpf.getScriptletHandling() );
                jrf.getReport().setResourceBundleBaseName( rpf.getResourceBundleBaseName() );
                
                this.setTitle(constTitle + " ["+ jrf.getReport().getName() + " "+ jrf.getReport().getWidth()+"x"+jrf.getReport().getHeight()+" "+jrf.getReport().getFilename()+" "+(jrf.getReport().isReadOnly()?"(READ ONLY) ":"")+"]");
                jrf.updateTitle();
                // Aggiorniamo il menu attivo...
                java.awt.Component[] menus = this.jMenuWindow.getMenuComponents();
                int frame = 0;
                for (int k = 0;  k<menus.length ; ++k) {
                    //javax.swing.JOptionPane.showMessageDialog(this,"Menu: " + menus[k] );
                    
                    
                    if (menus[k] instanceof JRadioButtonMenuItemMDIFrame) {
                        frame++;
                        
                        JRadioButtonMenuItemMDIFrame mri = (JRadioButtonMenuItemMDIFrame)menus[k];
                        //((JRadioButtonMenuItemMDIFrame)menus[k]).getFrame() == jrf)
                        if ( mri.isSelected() ) {
                            //javax.swing.JOptionPane.showMessageDialog( this, "Selected" + frame +" "+text);
                            mri.setText(frame + ". " + jrf.getTitle());
                            break;
                        }
                    }
                }
                
                jrf.setIsDocDirty(true);
                jrf.getJPanelReport().repaint();
            }
        }
    }//GEN-LAST:event_jMenuItemReportPropertiesActionPerformed
    
    private void jMenuItemGroupsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemGroupsActionPerformed
        jButtonGroupsActionPerformed(evt);
    }//GEN-LAST:event_jMenuItemGroupsActionPerformed
    
    public void jMenuItemBandsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemBandsActionPerformed
        jButtonBandsActionPerformed(evt);
    }//GEN-LAST:event_jMenuItemBandsActionPerformed
    
    private void jMenuItemElementsBrowserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemElementsBrowserActionPerformed
        this.jTabbedPaneExplorer.setSelectedComponent(jPanelDocumentStructure );
    }//GEN-LAST:event_jMenuItemElementsBrowserActionPerformed
    
    private void jMenuItemElementPropertiesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemElementPropertiesActionPerformed
        this.getElementPropertiesDialog().setVisible(true);
        this.getElementPropertiesDialog().updateSelection();
    }//GEN-LAST:event_jMenuItemElementPropertiesActionPerformed
    
    private void jMenuItemParametersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemParametersActionPerformed
        jButtonParametersActionPerformed(evt);
        this.getValuesDialog().gotoTab("Parameters");
    }//GEN-LAST:event_jMenuItemParametersActionPerformed
    
    private void jMenuItemVariablesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemVariablesActionPerformed
        jButtonParametersActionPerformed(evt);
        this.getValuesDialog().gotoTab("Variables");
    }//GEN-LAST:event_jMenuItemVariablesActionPerformed
    
    private void jMenuItemFieldsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemFieldsActionPerformed
        jButtonParametersActionPerformed(evt);
        this.getValuesDialog().gotoTab("Fields");
    }//GEN-LAST:event_jMenuItemFieldsActionPerformed
    
    private void jMenuItemReportQueryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemReportQueryActionPerformed
        jButtonDatabaseActionPerformed(evt);
    }//GEN-LAST:event_jMenuItemReportQueryActionPerformed
    
    private void jMenuItemExecuteDBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemExecuteDBActionPerformed
        jButtonRun2ActionPerformed(evt);
    }//GEN-LAST:event_jMenuItemExecuteDBActionPerformed
    
    private void jMenuItemExecuteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemExecuteActionPerformed
        jButtonRun1ActionPerformed(evt);
    }//GEN-LAST:event_jMenuItemExecuteActionPerformed
    
    private void jButtonPasteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPasteActionPerformed
        jMenuItemPasteActionPerformed(evt);
    }//GEN-LAST:event_jButtonPasteActionPerformed
    
    private void jButtonCopyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCopyActionPerformed
        jMenuItemCopyActionPerformed(evt);
    }//GEN-LAST:event_jButtonCopyActionPerformed
    
    private void jButtonCutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCutActionPerformed
        jMenuItemCutActionPerformed(evt);
    }//GEN-LAST:event_jButtonCutActionPerformed
    
    private void jMenuItemPasteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemPasteActionPerformed
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
            jrf.paste();
        }
    }//GEN-LAST:event_jMenuItemPasteActionPerformed
    
    private void jMenuItemCopyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCopyActionPerformed
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
            jrf.copy();
            if (getClipBoard().size()>0) {
                this.jMenuItemPaste.setEnabled(true);
                this.jButtonPaste.setEnabled(true);
            }
            else {
                this.jMenuItemPaste.setEnabled(false);
                this.jButtonPaste.setEnabled(false);
            }
        }
    }//GEN-LAST:event_jMenuItemCopyActionPerformed
    
    private void jMenuItemCutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCutActionPerformed
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
            jrf.cut();
        }
    }//GEN-LAST:event_jMenuItemCutActionPerformed
    
    private void jButtonRun2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRun2ActionPerformed
        
        // 1. Get active report...
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
            if (Misc.nvl(this.getProperties().getProperty("SaveBeforeCompiling"), "true").equals("true"))
                jMenuItemSaveActionPerformed(new java.awt.event.ActionEvent(jMenuItemSave,0,"Save"));
            //1. Save the report if needed....
            if (jrf.getReport().isDirty() ||
            jrf.getReport().getFilename() == null ||
            jrf.getReport().getFilename().trim().equals("")) {
                this.logOnConsole("Action aborted by user.\n");
                return;
            }
            
            clearConsole();
            //1. Compile....
            IReportCompiler ic = new IReportCompiler();
            
            ic.setThreadList( jListThreads );
            ic.setCommand( IReportCompiler.CMD_COMPILE | IReportCompiler.CMD_EXPORT);
            
            if (jrf.getReport().getScriptletHandling() == jrf.getReport().SCRIPTLET_IREPORT_INTERNAL_HANDLING) {
                ic.setCommand( ic.getCommand()  | IReportCompiler.CMD_COMPILE_SCRIPTLET);
            }
            
            
            HashMap hm = new HashMap();
            hm.put( ic.USE_EMPTY_DATASOURCE, "false");
            
            if (this.getProperties().get("DefaultConnection") == null ) {
                    javax.swing.JOptionPane.showMessageDialog(this, "You must configure a JDBC connection\nand set it the active connection.\n\nIf you have already created and tested a JDBC connection go to the menu\nbuild->set active connection and select your entry.\nIf you have not yet setup a JDBC connection go to\nDatasources->Connection/Datasources to create one.","",javax.swing.JOptionPane.ERROR_MESSAGE);
                    return;
            }
            
            IReportConnection connection = (IReportConnection)this.getProperties().get("DefaultConnection");
            
            
            //if (connection instanceof  it.businesslogic.ireport.connection.JDBCConnection)
            //{
            //    javax.swing.JOptionPane.showMessageDialog(null, ((it.businesslogic.ireport.connection.JDBCConnection)connection).getJDBCDriver());
            //}
            
            hm.put( ic.USE_CONNECTION, "true");
            hm.put( ic.CONNECTION, connection);
            hm.put( ic.OUTPUT_DIRECTORY, getTranslatedCompileDirectory());
            
            if (jrf.getReport().getLanguage().equals("groovy"))
            {
                hm.put( ic.COMPILER, "net.sf.jasperreports.compilers.JRGroovyCompiler");
            } 
            
            if (jrf.getReport().getLanguage().equals("groovy"))
            {
                hm.put( ic.COMPILER, "net.sf.jasperreports.compilers.JRGroovyCompiler");
            } 
            
            ic.setProperties(hm);
            
            if (jRadioButtonMenuItemPreviewCSV.isSelected()) hm.put( ic.OUTPUT_FORMAT, "csv");
            else if (jRadioButtonMenuItemPreviewHTML.isSelected()) hm.put( ic.OUTPUT_FORMAT, "html");
            else if (jRadioButtonMenuItemPreviewXLS.isSelected()) hm.put( ic.OUTPUT_FORMAT, "xls");
            //else if (jRadioButtonMenuItemPreviewJAVA.isSelected()) hm.put( ic.OUTPUT_FORMAT, "java");
            else if (jRadioButtonMenuItemPreviewInternalViewer.isSelected()) hm.put( ic.OUTPUT_FORMAT, "jrviewer");
            else if (jRadioButtonMenuItemPreviewTXT.isSelected()) hm.put( ic.OUTPUT_FORMAT, "txt");
            else
                hm.put( ic.OUTPUT_FORMAT, "pdf");
            
            ic.setProperties(hm);
            ic.setJrf(jrf);
            ic.setMainFrame(this);
            
            ic.start();
        }
    }//GEN-LAST:event_jButtonRun2ActionPerformed
    
    private void jMenuItemDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDeleteActionPerformed
        
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
            
            jrf.deleteSelectedElements();
        }
        
    }//GEN-LAST:event_jMenuItemDeleteActionPerformed
    
    private void jMenuItemRedoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemRedoActionPerformed
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
            
            jrf.redo();
            this.updateUndoMenu(jrf);
            
            if (jrf.getSelectedElements().size()>0)
                updateDocumentStructureTree(jrf);
        }
    }//GEN-LAST:event_jMenuItemRedoActionPerformed
    
    private void jMenuItemUndoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemUndoActionPerformed
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
            
            jrf.undo();
            this.updateUndoMenu(jrf);
            
            if (jrf.getSelectedElements().size()>0)
                updateDocumentStructureTree(jrf);
        }
    }//GEN-LAST:event_jMenuItemUndoActionPerformed
    
    private void jTreeDocumentValueChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_jTreeDocumentValueChanged
        
        if (dontHandleEvent) return;
        
        // Get active jrf...
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            //dontHandleEvent = true;
            try {
                JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
                Vector elementsToSelect = new Vector();
                
                TreePath[] path = jTreeDocument.getSelectionPaths();
                
                
                for (int i=0; i<path.length; ++i) {
                    DefaultMutableTreeNode elementNode = (DefaultMutableTreeNode)path[i].getLastPathComponent();
                    if (elementNode.getUserObject() instanceof ReportElement) {
                        elementsToSelect.addElement( (ReportElement)elementNode.getUserObject());
                        
                    }
                    else if (path.length == 1) {
                        jrf.setSelectedElement(null);
                        return;
                    }
                }
                
                jrf.setSelectedElement(null);
                Enumeration e = elementsToSelect.elements();
                while (e.hasMoreElements()) {
                    jrf.addSelectedElement((ReportElement)e.nextElement(), false);
                }
                jrf.fireSelectionChangedEvent();
            } catch (Exception ex)
            {}
            //
        }
        
    }//GEN-LAST:event_jTreeDocumentValueChanged
    
    private void jTreeFilesValueChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_jTreeFilesValueChanged
        // Select all selected elements...
        
        
    }//GEN-LAST:event_jTreeFilesValueChanged
    
    private void jMenuItemAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAboutActionPerformed
        
        IReportAbout ra = new IReportAbout(this, true);
        ra.show();
    }//GEN-LAST:event_jMenuItemAboutActionPerformed
    
    private void jButtonRun1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRun1ActionPerformed
        
        // 1. Get active report...
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
            if (Misc.nvl(this.getProperties().getProperty("SaveBeforeCompiling"), "true").equals("true"))
                jMenuItemSaveActionPerformed(new java.awt.event.ActionEvent(jMenuItemSave,0,"Save"));
            //1. Save the report if needed....
            if (jrf.getReport().isDirty() ||
            jrf.getReport().getFilename() == null ||
            jrf.getReport().getFilename().trim().equals("")) {
                this.logOnConsole("Action aborted by user.\n");
                return;
            }
            
            clearConsole();
            //1. Compile....
            IReportCompiler ic = new IReportCompiler();
            
            ic.setThreadList( jListThreads );
            ic.setCommand( IReportCompiler.CMD_COMPILE | IReportCompiler.CMD_EXPORT);
            
            if (jrf.getReport().getScriptletHandling() == jrf.getReport().SCRIPTLET_IREPORT_INTERNAL_HANDLING) {
                ic.setCommand( ic.getCommand()  | IReportCompiler.CMD_COMPILE_SCRIPTLET);
            }
            
            HashMap hm = new HashMap();
            hm.put( ic.USE_EMPTY_DATASOURCE, "true");
            hm.put( ic.OUTPUT_DIRECTORY, getTranslatedCompileDirectory());
            
            if (jrf.getReport().getLanguage().equals("groovy"))
            {
                hm.put( ic.COMPILER, "net.sf.jasperreports.compilers.JRGroovyCompiler");
            } 
            
            ic.setProperties(hm);
            
            if (jRadioButtonMenuItemPreviewCSV.isSelected()) hm.put( ic.OUTPUT_FORMAT, "csv");
            else if (jRadioButtonMenuItemPreviewHTML.isSelected()) hm.put( ic.OUTPUT_FORMAT, "html");
            else if (jRadioButtonMenuItemPreviewXLS.isSelected()) hm.put( ic.OUTPUT_FORMAT, "xls");
            //else if (jRadioButtonMenuItemPreviewJAVA.isSelected()) hm.put( ic.OUTPUT_FORMAT, "java");
            else if (jRadioButtonMenuItemPreviewInternalViewer.isSelected()) hm.put( ic.OUTPUT_FORMAT, "jrviewer");
            else if (jRadioButtonMenuItemPreviewTXT.isSelected()) hm.put( ic.OUTPUT_FORMAT, "txt");
            else
                hm.put( ic.OUTPUT_FORMAT, "pdf");
            
            ic.setProperties(hm);
            ic.setJrf(jrf);
            ic.setMainFrame(this);
            
            ic.start();
        }
    }//GEN-LAST:event_jButtonRun1ActionPerformed
    
    private void jMenuItemPrevWinActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemPrevWinActionPerformed
        // Remove all menus...
        java.awt.Component[] menus = this.jMenuWindow.getMenuComponents();
        int firstFrame = -1;
        for (int k = 0;  k<menus.length ; ++k) {
            if (menus[k] instanceof JRadioButtonMenuItemMDIFrame) {
                if (firstFrame == -1) firstFrame = k;
                if ( ((JRadioButtonMenuItemMDIFrame)menus[k]).getFrame() == jMDIDesktopPane.getSelectedFrame()) {
                    // The next if exists, is the right menu..
                    k--;
                    if (k>=firstFrame && menus[k] instanceof JRadioButtonMenuItemMDIFrame) {
                        try {
                            ((JRadioButtonMenuItemMDIFrame)menus[k]).getFrame().setSelected(true);
                        } catch (Exception ex)
                        {}
                    }
                    else if (menus[menus.length-1] instanceof JRadioButtonMenuItemMDIFrame) {
                        try {
                            ((JRadioButtonMenuItemMDIFrame)menus[menus.length-1]).getFrame().setSelected(true);
                        } catch (Exception ex)
                        {}
                    }
                    return;
                }
            }
        }
    }//GEN-LAST:event_jMenuItemPrevWinActionPerformed
    
    private void jMenuItemNextWinActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemNextWinActionPerformed
        
        
        // Remove all menus...
        java.awt.Component[] menus = this.jMenuWindow.getMenuComponents();
        int firstFrame = -1;
        for (int k = 0;  k<menus.length ; ++k) {
            if (menus[k] instanceof JRadioButtonMenuItemMDIFrame) {
                if (firstFrame == -1) firstFrame = k;
                if ( ((JRadioButtonMenuItemMDIFrame)menus[k]).getFrame() == jMDIDesktopPane.getSelectedFrame()) {
                    // The next if exists, is the right menu..
                    k++;
                    if (k<menus.length && menus[k] instanceof JRadioButtonMenuItemMDIFrame) {
                        try {
                            ((JRadioButtonMenuItemMDIFrame)menus[k]).getFrame().setSelected(true);
                        } catch (Exception ex)
                        {}
                    }
                    else if (firstFrame != -1) {
                        try {
                            ((JRadioButtonMenuItemMDIFrame)menus[firstFrame]).getFrame().setSelected(true);
                        } catch (Exception ex)
                        {}
                    }
                    return;
                }
            }
        }
        
        /*
        JInternalFrame[] frames = jMDIDesktopPane.getAllFrames();
        if (frames.length < 2) return;
        for (int i=0; i<frames.length; ++i)
        {
            if (frames[i] == jMDIDesktopPane.getSelectedFrame())
            {
                i++;
                if (i == frames.length) i=0;
                try {
                frames[i].setSelected(true);
                } catch (Exception ex){}
                return;
            }
        }
         */
        
    }//GEN-LAST:event_jMenuItemNextWinActionPerformed
    
    private void jMenuItemtileAnodineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemtileAnodineActionPerformed
        jMDIDesktopPane.tileAnodine();
    }//GEN-LAST:event_jMenuItemtileAnodineActionPerformed
    
    private void jMenuItemTileVerticalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemTileVerticalActionPerformed
        jMDIDesktopPane.tileVertically();
    }//GEN-LAST:event_jMenuItemTileVerticalActionPerformed
    
    private void jMenuItemTileHorizontalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemTileHorizontalActionPerformed
        jMDIDesktopPane.tileHorizontally();
    }//GEN-LAST:event_jMenuItemTileHorizontalActionPerformed
    
    private void jMenuItemCascadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCascadeActionPerformed
        // Dispose all frames in cascade....
        // The active frame must be the last....
        jMDIDesktopPane.cascade();
    }//GEN-LAST:event_jMenuItemCascadeActionPerformed
    
    private void jRadioButtonMenuItemPreviewPDFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonMenuItemPreviewPDFActionPerformed
        this.setReportViewer(IREPORT_PDF_VIEWER);
    }//GEN-LAST:event_jRadioButtonMenuItemPreviewPDFActionPerformed
    
    private void jTreeFilesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTreeFilesMouseClicked
        if (evt.getClickCount() == 2 && evt.getButton() == java.awt.event.MouseEvent.BUTTON1) {
            TreePath path = jTreeFiles.getSelectionPath();
            if (path == null) return;
            TreeNode node = (TreeNode)path.getLastPathComponent();
            if (node instanceof DefaultMutableTreeNode) {
                DefaultMutableTreeNode nodem = (DefaultMutableTreeNode)node;
                Object obj = nodem.getUserObject();
                if (obj != null && obj instanceof DocumentTreeEntry) {
                    DocumentTreeEntry dtn = (DocumentTreeEntry)obj;
                    if (dtn.getJrf() != null) {
                        //
                        try {
                            dtn.getJrf().setSelected(true);
                        } catch (Exception ex)
                        {};
                        //dtn.getJrf().updateUI();
                        //jMDIDesktopPane.internalFrameActivated(dtn.getJrf());
                        //this.logOnConsole("Activated :"+dtn.getJrf().getReport().getFilename()+"\n");
                    }
                }
            }
        }
        //else System.out.println("Mouse clicked...");
        
        
    }//GEN-LAST:event_jTreeFilesMouseClicked
    
    private void jMenuItemFontsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemFontsActionPerformed
        this.fontsDialog.setVisible(true);
    }//GEN-LAST:event_jMenuItemFontsActionPerformed
    
    private void jMenuItemActiveConnectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemActiveConnectionActionPerformed
        ActiveConnectionDialog acd = new ActiveConnectionDialog(this, true);
        acd.show();
        if (acd.getDialogResult() == JOptionPane.OK_OPTION) {
            this.getProperties().put( "DefaultConnection",acd.getIReportConnection());
            
            this.saveiReportConfiguration();
            jToolbarConnectionPanel.updateConnections();

        }
    }//GEN-LAST:event_jMenuItemActiveConnectionActionPerformed
    
    private void jTabbedPaneExplorerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPaneExplorerStateChanged
        if (jTabbedPaneExplorer.getSelectedComponent() instanceof ProjectPane) {
            jMenuItemCloseProject.setEnabled(true);
        }
        else {
            jMenuItemCloseProject.setEnabled(false);
        }
    }//GEN-LAST:event_jTabbedPaneExplorerStateChanged
    
    private void jMenuItemCloseProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCloseProjectActionPerformed
        // Close the active project...
        if (jTabbedPaneExplorer.getSelectedComponent() instanceof ProjectPane) {
            // ProjectPane.close();
            jTabbedPaneExplorer.remove(jTabbedPaneExplorer.getSelectedComponent());
        }
        
        
    }//GEN-LAST:event_jMenuItemCloseProjectActionPerformed
    
    private void jMenuItemNewProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemNewProjectActionPerformed
        
        ProjectDialog pd = new ProjectDialog(this, true);
        pd.show();
        if (pd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
            /* Code to handle the new project... */
            ProjectInfo pi = new ProjectInfo();
            pi.setName( pd.getProjectName() );
            pi.setSourcesDir( pd.getSourcesDir() );
            pi.setOutputDir( pd.getOutputDir() );
            pi.setConnection( pd.getConnection() );
            ProjectPane pp = new ProjectPane(pi);
            this.jTabbedPaneExplorer.addTab("Project "+pi, pp);
            this.jTabbedPaneExplorer.setSelectedComponent(pp);
        }
    }//GEN-LAST:event_jMenuItemNewProjectActionPerformed
    
    private void jToggleButtonChartToolItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jToggleButtonChartToolItemStateChanged
        if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
            if (jMDIDesktopPane.getSelectedFrame() != null &&
            jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
                JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
                jrf.setNewObjectType( ReportElementType.CHART_ELEMENT);
                jrf.setLensMode(false);
            }
            setActiveTool(jToggleButtonChartTool);
        }
    }//GEN-LAST:event_jToggleButtonChartToolItemStateChanged
    
    private void jMenuItemConnectionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemConnectionsActionPerformed
        ConnectionsDialog cd = new ConnectionsDialog(this,true);
        cd.show();
        
        jToolbarConnectionPanel.updateConnections();

    }//GEN-LAST:event_jMenuItemConnectionsActionPerformed
    
    private void jMenuItemReportQuery2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemReportQuery2ActionPerformed
        this.jButtonDatabaseActionPerformed(evt);
    }//GEN-LAST:event_jMenuItemReportQuery2ActionPerformed
    
    private void jMenuItemCompatibilityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCompatibilityActionPerformed
        CompatibilityDialog cd = new CompatibilityDialog(this,true);
        cd.show();
    }//GEN-LAST:event_jMenuItemCompatibilityActionPerformed
    
    private void jMenuItemOptionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemOptionsActionPerformed
        OptionsDialog od = new OptionsDialog(this,true);
        od.loadConfiguration();
        od.show();
    }//GEN-LAST:event_jMenuItemOptionsActionPerformed
    
    private void jCheckBoxMenuItemOutputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItemOutputActionPerformed
        if (jCheckBoxMenuItemOutput.isSelected()) {
            jSplitPaneV.add("bottom", jPanelSouth );
            jSplitPaneV.setDividerSize(8);
        }
        else {
            jSplitPaneV.remove( jPanelSouth);
            jSplitPaneV.setDividerSize(0);
        }
        
    }//GEN-LAST:event_jCheckBoxMenuItemOutputActionPerformed
    
    private void jCheckBoxMenuItemExplorerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItemExplorerActionPerformed
        if (jCheckBoxMenuItemExplorer.isSelected()) {
            jSplitPaneHorizontal.add("left", jTabbedPaneExplorer);
            jSplitPaneHorizontal.setDividerSize(8);
        }
        else {
            jSplitPaneHorizontal.remove( jTabbedPaneExplorer);
            jSplitPaneHorizontal.setDividerSize(0);
        }
    }//GEN-LAST:event_jCheckBoxMenuItemExplorerActionPerformed
    
    public void jMenuItemHSDecreaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemHSDecreaseActionPerformed
        formatMenuPerformed( OperationType.DECREASE_SPACE_H);
    }//GEN-LAST:event_jMenuItemHSDecreaseActionPerformed
    
    public void jMenuItemVSIncreaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemVSIncreaseActionPerformed
        formatMenuPerformed( OperationType.INCREASE_SPACE_V);
    }//GEN-LAST:event_jMenuItemVSIncreaseActionPerformed
    
    private void jButtonDatabaseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDatabaseActionPerformed
        this.getReportQueryDialog().setJReportFrame( this.getActiveReportFrame() );
        this.getReportQueryDialog().setVisible(true);
    }//GEN-LAST:event_jButtonDatabaseActionPerformed
    
    private void jMenuItemSaveAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSaveAllActionPerformed
        javax.swing.JInternalFrame[] frames = jMDIDesktopPane.getAllFrames();
        for (int i=0; i< frames.length; ++i) {
            if (frames[i]  instanceof JReportFrame) {
                JReportFrame jrf = (JReportFrame)frames[i];
                if (jrf.getReport().getFilename() == null ||
                jrf.getReport().getFilename().trim().equals("")) {
                    // Choose a file name....
                    javax.swing.JFileChooser jfc = new javax.swing.JFileChooser(getCurrentDirectory());
                    
                    jfc.setDialogTitle("Save report as XML jasperreports file....");
                    jfc.setFileFilter( new javax.swing.filechooser.FileFilter() {
                        public boolean accept(java.io.File file) {
                            String filename = file.getName();
                            return (filename.toLowerCase().endsWith(".xml") || file.isDirectory() || filename.toLowerCase().endsWith(".jrxml")) ;
                        }
                        public String getDescription() {
                            return "JasperReports XML *.xml, *.jrxml";
                        }
                    });
                    
                    
                    jfc.setMultiSelectionEnabled(false);
                    
                    jfc.setDialogType( javax.swing.JFileChooser.SAVE_DIALOG);
                    if  (jfc.showSaveDialog(this) != javax.swing.JOptionPane.OK_OPTION) {
                        //if we saved or didn't save the current file
                        javax.swing.JInternalFrame current = jMDIDesktopPane.getSelectedFrame();
                        if( current instanceof JReportFrame ) {
                            JReportFrame crf = (JReportFrame)current;
                            if( crf.getReport().isModified() ) {
                                this.enableSaveSpecific();
                            }
                            else {
                                this.disableSaveSpecific();
                            }
                        }
                        return;
                    }
                    setCurrentDirectory( jfc.getSelectedFile(), true);
                    jrf.getReport().setFilename( jfc.getSelectedFile().getPath());
                }
                
                //saveBackup( jrf.getReport().getFilename());
                jrf.getReport().saveXMLFile();
                jrf.getReport().setModified(false);
                //this.addToRecentFileList(rp.filename);
                //saveProperties();
                //this.updateRecentFileList();
            }//end if instance of
        }//end for loop frames
        this.disableSaveAllSpecific();
        this.disableSaveSpecific();
    }//GEN-LAST:event_jMenuItemSaveAllActionPerformed
    
    private void jMenuItemSaveAsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSaveAsActionPerformed
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
            
            saveAs(jrf);
        }
    }//GEN-LAST:event_jMenuItemSaveAsActionPerformed
    
    
    public void saveAs(JReportFrame jrf)
    {
            String reportName = jrf.getReport().getName();
            
            // Choose a new file name....
            // -----------------------------------------------------------------
            
            javax.swing.JFileChooser jfc = new javax.swing.JFileChooser(getCurrentDirectory());
            jfc.setDialogTitle("Save report as XML jasperreports file as....");
            
            // Handling the new File, that gets saved for the first time
            // Propose a new file name based on the report name
            
            jfc.setSelectedFile( new java.io.File(jrf.getReport().getFilename())) ;
            
            if (jrf.getReport().getFilename() == null ||
                    jrf.getReport().getFilename().trim().equals(""))
            {
                if ( !( (reportName == null) || (reportName.trim().equals(""))) )
                {
                    File file = new java.io.File( reportName + ".jrxml");
                    jfc.setSelectedFile( file );
                }
            }
            
            jfc.setFileFilter( new javax.swing.filechooser.FileFilter()
            {
                public boolean accept(java.io.File file)
                {
                    String filename = file.getName();
                    return (filename.toLowerCase().endsWith(".xml") || file.isDirectory() || filename.toLowerCase().endsWith(".jrxml")) ;
                }
                public String getDescription()
                {
                    return "JasperReports XML *.xml, *.jrxml";
                }
            });
            jfc.setMultiSelectionEnabled(false);
            jfc.setDialogType( javax.swing.JFileChooser.SAVE_DIALOG);
            
            // Show the dialog:
            if  (jfc.showSaveDialog(this) != javax.swing.JOptionPane.OK_OPTION)
            {
                return;
            }
            
            setCurrentDirectory( jfc.getSelectedFile(), true);
            
            //file exists?
            if(jfc.getSelectedFile().exists())
            {
                //is the same file to save?
                if( new File(jrf.getReport().getFilename()).equals(jfc.getSelectedFile()))
                {
                    // Synchronize Report Name ?
                    boolean sync = false;
                    String filename = jfc.getSelectedFile().getName();
                    filename = filename.substring(0, filename.lastIndexOf(".")  );
                
                    if (! reportName.toLowerCase().equals (filename.toLowerCase() ) )
                    {
                        if ( isSynchronizeReportName() )
                        {
                            sync = true;
                        }
                        else
                        {
                            // Ask whether to synchronize
                            if ( isShowOptionDialogSynchronize( jrf.getReport().getName(), filename ) )
                            {
                                sync = true;
                            }
                        }
                    }
                    if (sync)
                    {
                        jrf.getReport().setName( filename );
                    }
                    //save only
                    jrf.getReport().saveXMLFile();
                    jrf.getReport().setModified(false);
                    return;
                    
                }
                else
                {
                    //is different file to save?
                    //confirm overwrite
                    int ret = I18nOptionPane.showOptionDialog(this,
                            "overwriteFile",
                            "saveAs",
                            JOptionPane.YES_NO_OPTION,
                            JOptionPane.WARNING_MESSAGE,
                            null, new String[]{"yes", "no"},
                            "no"
                                    );
                            
                            //if yes
                            if(ret == 0)
                            {
                                //is that file opened?
                                JReportFrame reportFrame = findReportFrameByFile(jfc.getSelectedFile());
                                if(reportFrame != null)
                                {
                                    //close file
                                    reportFrame.doDefaultCloseAction();
                                }
                            }
                            else
                            {
                                //canceled
                                return;
                            }
                            
                }
            }
            else
            {
                // File does not exist yet.
                
            }

            String f = jfc.getSelectedFile().getPath();
            if (!f.toLowerCase().endsWith(".jrxml" ) &&
                    !f.toLowerCase().endsWith(".xml" ))
            {
                f += ".jrxml";
            }
            
            //saveBackup( jrf.getReport().getFilename());
            jrf.getReport().checkReadOnlyFlag(f);
            if(jrf.getReport().isReadOnly())
            {
                javax.swing.JOptionPane.showMessageDialog(this,
                        it.businesslogic.ireport.util.I18n.getString("selectedFileReadOnly", "Selected File is read only and cannot be used."),
                        it.businesslogic.ireport.util.I18n.getString("save","Save"),javax.swing.JOptionPane.INFORMATION_MESSAGE);
                return;
            }
            
            // Begin Modification, Robert Lamping, May 3, 2005
            
            String filename = jfc.getSelectedFile().getName();
            filename = filename.substring(0, filename.lastIndexOf(".")  );
            
            if (reportName.trim().equals("") )
            {
                // if report name is empty, then use the filename without the last extension as
                // the new report name.
                jrf.getReport().setName(filename);
            }
            else
            {
                // If different file name was entered than the report name
                // and the report name is not null or empty. then:
                // Ask whether it should be brought in sync.
                
                // filename always includes a "."
                // so take everything until the last occurance of "."
                // and compare this to the reportname
                // if not equal, than ask to synchronize.
                
                
                if (! reportName.toLowerCase().equals(filename.toLowerCase() ) )
                {
                    // Ask to synchronize
                    // TODO: I18N hardcoded text
                    if ( isSynchronizeReportName() )
                    {
                        jrf.getReport().setName(filename);
                        logOnConsole("Report name synchronized with file name\n");
                    }
                    else
                    {
                        if ( isShowOptionDialogSynchronize( reportName, filename ) )
                        {
                            jrf.getReport().setName(filename);
                        }
                    }
                }
                
            }
            // End Modification, Robert Lamping, May 3, 2005
            
            jrf.getReport().setFilename(f);
            jrf.getReport().saveXMLFile();
            
            jrf.getReport().setModified(false);
            jrf.updateTitle();
            
            javax.swing.tree.DefaultTreeModel dtm = (javax.swing.tree.DefaultTreeModel) jTreeFiles.getModel();
            dtm.reload();
            
            updateMenuWindowList();
            setActiveReportForm(jrf);
            this.disableSaveSpecific();
            if(this.isSaveAllRequired())
            {
                this.enableSaveAllSpecific();
            }
            else
            {
                this.disableSaveAllSpecific();
            }
            recentFilesList.insertElementAt(jrf.getReport().getFilename(),0);
            this.updateRecentFileMenu(jMenuRecentFiles, recentFilesList );
            //saveFileList(recentFilesList, "recentFiles.xml");
            saveFileList(recentFilesList, IREPORT_RECENT_FILES_FILE);
            //          this.addToRecentFileList(rp.filename);
            //saveProperties();
            //this.updateRecentFileList();

    }
    
    
    private void jButtonOpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOpenActionPerformed
        this.jMenuItemOpenActionPerformed(evt);
    }//GEN-LAST:event_jButtonOpenActionPerformed
    
    private void jButtonCompilerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCompilerActionPerformed
        // 1. Get active report...
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
            if (Misc.nvl(this.getProperties().getProperty("SaveBeforeCompiling"), "true").equals("true"))
                jMenuItemSaveActionPerformed(new java.awt.event.ActionEvent(jMenuItemSave,0,"Save"));
            //1. Save the report if needed....
            if (jrf.getReport().isDirty() ||
            jrf.getReport().getFilename() == null ||
            jrf.getReport().getFilename().trim().equals("")) {
                this.logOnConsole("Action aborted by user.\n");
                return;
            }
            
            clearConsole();
            //1. Compile....
            IReportCompiler ic = new IReportCompiler();
            ic.setThreadList( jListThreads );
            
            
            HashMap hm = new HashMap();
            hm.put( ic.OUTPUT_DIRECTORY, getTranslatedCompileDirectory());
            
            if (jrf.getReport().getLanguage().equals("groovy"))
            {
                hm.put( ic.COMPILER, "net.sf.jasperreports.compilers.JRGroovyCompiler");
            } 
            
            ic.setProperties(hm);
            ic.setCommand( IReportCompiler.CMD_COMPILE);
            
            if (jrf.getReport().getScriptletHandling() == jrf.getReport().SCRIPTLET_IREPORT_INTERNAL_HANDLING) {
                ic.setCommand( ic.getCommand() | IReportCompiler.CMD_COMPILE_SCRIPTLET);
            }
            ic.setJrf(jrf);
            ic.setMainFrame(this);
            ic.start();
        }
        
        
    }//GEN-LAST:event_jButtonCompilerActionPerformed
    
    private void jButtonSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSaveActionPerformed
        jMenuItemSaveActionPerformed(evt);
    }//GEN-LAST:event_jButtonSaveActionPerformed
    
    public void jMenuItemSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSaveActionPerformed
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
            
            save( jrf );
        }
    }//GEN-LAST:event_jMenuItemSaveActionPerformed
    
    public void save(JReportFrame jrf)
    {
            String reportName = jrf.getReport().getName();
                
            if (jrf.getReport().getFilename() == null ||
            jrf.getReport().getFilename().trim().equals("")) {
                // Choose a file name....
                javax.swing.JFileChooser jfc = new javax.swing.JFileChooser(getCurrentDirectory());
                jfc.setDialogTitle("Save report as XML jasperreports file....");
                
                // Begin Modification, Robert Lamping, May 3, 2005
                // filename is empty, so default it to the report name
                // whether or not the (future) option to keep report name and file name equal
            
                File file = new java.io.File( reportName + ".jrxml");
                jfc.setSelectedFile( file );
                // End Modification, Robert Lamping, May 3, 2005        
                
                jfc.setFileFilter( new javax.swing.filechooser.FileFilter() {
                    public boolean accept(java.io.File file) {
                        String filename = file.getName();
                        return (filename.toLowerCase().endsWith(".xml") || file.isDirectory() || filename.toLowerCase().endsWith(".jrxml")) ;
                    }
                    public String getDescription() {
                        return "JasperReports XML *.xml, *.jrxml";
                    }
                });
                
                jfc.setMultiSelectionEnabled(false);
                
                jfc.setDialogType( javax.swing.JFileChooser.SAVE_DIALOG);
                if  (jfc.showSaveDialog( this) != javax.swing.JOptionPane.OK_OPTION) return;
                setCurrentDirectory( jfc.getSelectedFile(), true);
                String f = jfc.getSelectedFile().getPath();
                if (!f.toLowerCase().endsWith(".jrxml" ) &&
                !f.toLowerCase().endsWith(".xml" )) {
                    f += ".jrxml";
                }
                jrf.getReport().checkReadOnlyFlag(f);
                if(jrf.getReport().isReadOnly()){
                    javax.swing.JOptionPane.showMessageDialog(this,
                    it.businesslogic.ireport.util.I18n.getString("selectedFileReadOnly", "Selected File is read only and cannot be used."),
                    it.businesslogic.ireport.util.I18n.getString("save","Save"),javax.swing.JOptionPane.INFORMATION_MESSAGE);
                    return;
                }
                
                
                // Begin Modification, Robert Lamping, May 3, 2005
                // If a file with the same name exists as f
                // then the ask whether the file must be overwritten.
                               
                //file exists?
                if(jfc.getSelectedFile().exists()) {
                                      
                    //confirm overwrite
                    // TODO: Show Filename in OptionDialog
                    int ret = I18nOptionPane.showOptionDialog(this,
                            "overwriteFile",
                            "save",
                            JOptionPane.YES_NO_OPTION,
                            JOptionPane.WARNING_MESSAGE,
                            null, new String[]{"yes", "no"},
                            "no",
                            jfc.getSelectedFile().getPath()  );
                            
                            //if yes
                            if(ret == 0){

                                //is that file opened?
                                JReportFrame reportFrame = findReportFrameByFile(jfc.getSelectedFile());
                                if(reportFrame != null){
                                    //close file
                                    reportFrame.doDefaultCloseAction();
                                }
                            } else {

                                //canceled
                                return;
                            }
                }
                
               
                String filename = jfc.getSelectedFile().getName();
                filename = filename.substring(0, filename.lastIndexOf(".")  );
                
                if (reportName.trim().equals ("") )
                {
                    // if report name is empty, then use the filename without the last extension as
                    // the new report name.
                    jrf.getReport ().setName (filename);
                }
                else
                {
                    // If different file name was entered than the report name
                    // and the report name is not null or empty. then:
                    // Ask whether it should be brought in sync.
                                        
                    // filename always includes a "."
                    // so take everything until the last occurance of "."
                    // and compare this to the reportname
                    // if not equal, than ask to synchronize.
                    
                    
                    if (! reportName.toLowerCase().equals (filename.toLowerCase() ) )
                    {
                        // Ask to synchronize
                        // TODO: I18N hardcoded text
                        if ( isSynchronizeReportName() )
                        {
                            jrf.getReport().setName(filename);
                            logOnConsole("Report name synchronized with file name\n");
                        }
                        else
                        {
                            // ask user whether to synchronize or not
                            if ( isShowOptionDialogSynchronize( reportName, filename ) )
                            {
                                jrf.getReport().setName(filename);
                            }
                        }
                    }
                    
                }
                // End Modification, Robert Lamping, May 3, 2005
                
                jrf.getReport().setFilename( f );
                recentFilesList.insertElementAt(jrf.getReport().getFilename(),0);
                this.updateRecentFileMenu(jMenuRecentFiles, recentFilesList );
                //saveFileList(recentFilesList, "recentFiles.xml");
                saveFileList(recentFilesList, IREPORT_RECENT_FILES_FILE);
            }
            else
            {
                
                // Begin Modification, Robert Lamping, May 3, 2005
                File file = new java.io.File( jrf.getReport().getFilename() );
                // strip the path:
                String filename = file.getName();
                filename = filename.substring(0, filename.lastIndexOf(".")  );
                
                if (reportName.trim().equals("") )
                {
                    // if report name is empty, then use the filename without the last extension as
                    // the new report name.
                    jrf.getReport().setName(filename);
                }
                else
                {
                    // If different file name was entered than the report name
                    // and the report name is not null or empty. then:
                    // Ask whether it should be brought in sync.
                    
                    // filename always includes a "."
                    // so take everything until the last occurance of "."
                    // and compare this to the reportname
                    // if not equal, than ask to synchronize.
                    if (! reportName.toLowerCase().equals(filename.toLowerCase()) )
                    {
                        if ( isSynchronizeReportName() )
                        {
                            jrf.getReport().setName(filename);
                            logOnConsole("Report name synchronized with file name");
                        }
                        else
                        {
                             // ask user whether to synchronize or not
                            if ( isShowOptionDialogSynchronize( reportName, filename ) )
                            {
                                jrf.getReport().setName(filename);
                            }
                        }
                    }
                    
                }
                // End Modification, Robert Lamping, May 3, 2005
                
            }
            
            
            if(!jrf.getReport().isReadOnly() && !getProperties().getProperty("BackupPolicy","3").equals("1") )
            {
                saveBackup( jrf.getReport().getFilename());
            }
            jrf.getReport().saveXMLFile();
            jrf.getReport().setDirty(false);
            jrf.getReport().setModified(false);
            this.disableSaveSpecific();
            if(this.isSaveAllRequired())
            {
                this.enableSaveAllSpecific();
            }
            else
            {
                this.disableSaveAllSpecific();
            }
            //this.addToRecentFileList(rp.filename);
            //saveProperties();
            //this.updateRecentFileList();
            this.jTreeFiles.updateUI();
        
    }
    
    private void jCheckBoxMenuItemSnapToGridActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItemSnapToGridActionPerformed
        // Set SnapToGrid to all reports form..
        javax.swing.JInternalFrame[] frames = jMDIDesktopPane.getAllFrames();
        for (int i=0; i< frames.length; ++i) {
            if (frames[i]  instanceof JReportFrame) {
                JReportFrame jrf = (JReportFrame)frames[i];
                jrf.setSnapToGrid(jCheckBoxMenuItemSnapToGrid.isSelected() );
                this.getProperties().setProperty( "snapToGrid", jCheckBoxMenuItemSnapToGrid.isSelected() + "" );
                this.saveiReportConfiguration();
            }
        }
    }//GEN-LAST:event_jCheckBoxMenuItemSnapToGridActionPerformed
    
    private void jCheckBoxMenuItemGridActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItemGridActionPerformed
        
        javax.swing.JInternalFrame[] frames = jMDIDesktopPane.getAllFrames();
        for (int i=0; i< frames.length; ++i) {
            if (frames[i]  instanceof JReportFrame) {
                JReportFrame jrf = (JReportFrame)frames[i];
                jrf.setShowGrid(jCheckBoxMenuItemGrid.isSelected() );
                this.getProperties().setProperty( "showGrid", jCheckBoxMenuItemGrid.isSelected() + "" );
                this.saveiReportConfiguration();
            }
        }
    }//GEN-LAST:event_jCheckBoxMenuItemGridActionPerformed
    
    private void jButtonBandsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBandsActionPerformed
        getBandsDialog().setVisible(true);
    }//GEN-LAST:event_jButtonBandsActionPerformed
    
    private void jButtonGroupsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGroupsActionPerformed
        getGroupsDialog().setVisible(true);
    }//GEN-LAST:event_jButtonGroupsActionPerformed
    
    private void jButtonParametersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonParametersActionPerformed
        // Show values frame...
        getValuesDialog().setVisible(true);
        
    }//GEN-LAST:event_jButtonParametersActionPerformed
    
    private void jMenuItemOpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemOpenActionPerformed
        // Select an XMl file...
        String fileName = "";
        javax.swing.JFileChooser jfc = new javax.swing.JFileChooser(getCurrentDirectory());
        
        jfc.setDialogTitle("Load XML jasperreports file....");
        
        jfc.addChoosableFileFilter( new javax.swing.filechooser.FileFilter() {
            public boolean accept(java.io.File file) {
                String filename = file.getName();
                return (filename.toLowerCase().endsWith(".jasper") || file.isDirectory()) ;
            }
            public String getDescription() {
                return "JasperReports compiled *.jasper";
            }
        });
        
        jfc.setFileFilter( new javax.swing.filechooser.FileFilter() {
            public boolean accept(java.io.File file) {
                String filename = file.getName();
                return (filename.toLowerCase().endsWith(".xml") || file.isDirectory() || filename.toLowerCase().endsWith(".jrxml")) ;
            }
            public String getDescription() {
                return "JasperReports XML *.xml, *.jrxml";
            }
        });
        
        
        
        jfc.setMultiSelectionEnabled(true);
        jfc.setDialogType( javax.swing.JFileChooser.OPEN_DIALOG);
        if  (jfc.showOpenDialog( this) == javax.swing.JOptionPane.OK_OPTION) {
            java.io.File[] files = jfc.getSelectedFiles();
            Report report;
            
            for (int i=0; i<files.length; ++i) {
                openFile(files[i]);
            }
            setCurrentDirectory( jfc.getSelectedFile(), true);
        }
        
    }//GEN-LAST:event_jMenuItemOpenActionPerformed
    
    private void jToggleButtonSubreportToolItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jToggleButtonSubreportToolItemStateChanged
        if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
            if (jMDIDesktopPane.getSelectedFrame() != null &&
            jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
                JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
                jrf.setNewObjectType( ReportElementType.SUBREPORT_ELEMENT);
                jrf.setLensMode(false);
            }
            setActiveTool(jToggleButtonSubreportTool);
        }
    }//GEN-LAST:event_jToggleButtonSubreportToolItemStateChanged
    
    private void jToggleButtonSubreportToolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonSubreportToolActionPerformed
        jToggleButtonSubreportTool.setSelected(true);
    }//GEN-LAST:event_jToggleButtonSubreportToolActionPerformed
    
    private void jToggleButtonTextFieldToolItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jToggleButtonTextFieldToolItemStateChanged
        if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
            if (jMDIDesktopPane.getSelectedFrame() != null &&
            jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
                JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
                jrf.setNewObjectType( ReportElementType.TEXTFIELD_ELEMENT);
                jrf.setLensMode(false);
            }
            setActiveTool(jToggleButtonTextFieldTool);
        }
    }//GEN-LAST:event_jToggleButtonTextFieldToolItemStateChanged
    
    private void jToggleButtonTextFieldToolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonTextFieldToolActionPerformed
        jToggleButtonTextFieldTool.setSelected(true);
    }//GEN-LAST:event_jToggleButtonTextFieldToolActionPerformed
    
    private void jToggleButtonStaticTextToolItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jToggleButtonStaticTextToolItemStateChanged
        if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
            if (jMDIDesktopPane.getSelectedFrame() != null &&
            jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
                JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
                jrf.setNewObjectType( ReportElementType.STATICTEXT_ELEMENT);
                jrf.setLensMode(false);
            }
            setActiveTool(jToggleButtonStaticTextTool);
        }
    }//GEN-LAST:event_jToggleButtonStaticTextToolItemStateChanged
    
    private void jToggleButtonStaticTextToolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonStaticTextToolActionPerformed
        jToggleButtonStaticTextTool.setSelected(true);
    }//GEN-LAST:event_jToggleButtonStaticTextToolActionPerformed
    
    private void jToggleButtonImageToolItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jToggleButtonImageToolItemStateChanged
        if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
            if (jMDIDesktopPane.getSelectedFrame() != null &&
            jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
                JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
                jrf.setNewObjectType( ReportElementType.IMAGE_ELEMENT);
                jrf.setLensMode(false);
            }
            setActiveTool(jToggleButtonImageTool);
        }
    }//GEN-LAST:event_jToggleButtonImageToolItemStateChanged
    
    private void jToggleButtonImageToolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonImageToolActionPerformed
        jToggleButtonImageTool.setSelected(true);
    }//GEN-LAST:event_jToggleButtonImageToolActionPerformed
    
    private void jToggleButtonEllipseToolItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jToggleButtonEllipseToolItemStateChanged
        if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
            if (jMDIDesktopPane.getSelectedFrame() != null &&
            jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
                JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
                jrf.setNewObjectType( ReportElementType.ELLIPSE_ELEMENT);
                jrf.setLensMode(false);
            }
            setActiveTool(jToggleButtonEllipseTool);
        }
    }//GEN-LAST:event_jToggleButtonEllipseToolItemStateChanged
    
    private void jToggleButtonEllipseToolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonEllipseToolActionPerformed
        jToggleButtonEllipseTool.setSelected(true);
    }//GEN-LAST:event_jToggleButtonEllipseToolActionPerformed
    
    private void jToggleButtonRectRoundToolItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jToggleButtonRectRoundToolItemStateChanged
        if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
            if (jMDIDesktopPane.getSelectedFrame() != null &&
            jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
                JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
                jrf.setNewObjectType( ReportElementType.ROUND_RECTANGLE_ELEMENT);
                jrf.setLensMode(false);
            }
            setActiveTool(jToggleButtonRectRoundTool);
        }
    }//GEN-LAST:event_jToggleButtonRectRoundToolItemStateChanged
    
    private void jToggleButtonRectRoundToolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonRectRoundToolActionPerformed
        jToggleButtonRectRoundTool.setSelected(true);
    }//GEN-LAST:event_jToggleButtonRectRoundToolActionPerformed
    
    private void jToggleButtonRectToolItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jToggleButtonRectToolItemStateChanged
        if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
            if (jMDIDesktopPane.getSelectedFrame() != null &&
            jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
                JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
                jrf.setNewObjectType( ReportElementType.RECTANGLE_ELEMENT);
                jrf.setLensMode(false);
            }
            setActiveTool(jToggleButtonRectTool);
        }
    }//GEN-LAST:event_jToggleButtonRectToolItemStateChanged
    
    private void jToggleButtonRectToolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonRectToolActionPerformed
        jToggleButtonRectTool.setSelected(true);
    }//GEN-LAST:event_jToggleButtonRectToolActionPerformed
    
    private void jToggleButtonLineToolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonLineToolActionPerformed
        jToggleButtonLineTool.setSelected(true);
    }//GEN-LAST:event_jToggleButtonLineToolActionPerformed
    
    private void jToggleButtonLineToolItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jToggleButtonLineToolItemStateChanged
        if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
            if (jMDIDesktopPane.getSelectedFrame() != null &&
            jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
                JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
                jrf.setNewObjectType( ReportElementType.LINE_ELEMENT);
                jrf.setLensMode(false);
            }
            setActiveTool(jToggleButtonLineTool);
        }
    }//GEN-LAST:event_jToggleButtonLineToolItemStateChanged
    
    private void jToggleButtonPointerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonPointerActionPerformed
        jToggleButtonPointer.setSelected(true);
    }//GEN-LAST:event_jToggleButtonPointerActionPerformed
    
    private void jToggleButtonPointerItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jToggleButtonPointerItemStateChanged
        if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
            
            if (jMDIDesktopPane.getSelectedFrame() != null &&
            jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
                JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
                jrf.setNewObjectType( ReportElementType.NONE);
                jrf.setLensMode(false);
            }
            if (jToggleButtonPointer.isEnabled()) {
                setActiveTool( jToggleButtonPointer );
            }
        }
    }//GEN-LAST:event_jToggleButtonPointerItemStateChanged
    
    private void jButtonNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNewActionPerformed
        evt.setSource(jButtonNew);
        this.jMenuItemNewDocumentActionPerformed(evt);
    }//GEN-LAST:event_jButtonNewActionPerformed
    
    public void setCutCopyEnabled(boolean enabled) {
        this.jButtonCut.setEnabled(enabled);
        this.jMenuItemCut.setEnabled(enabled);
        this.jMenuItemDS_cut.setEnabled(enabled);
        
        this.jButtonCopy.setEnabled(enabled);
        this.jMenuItemCopy.setEnabled(enabled);
        this.jMenuItemDS_copy.setEnabled(enabled);
        
        this.jMenuItemDelete.setEnabled(enabled);
        this.jMenuItemDS_delete.setEnabled(enabled);
    }
    
    public void setPasteEnebled(boolean enabled) {
        this.jButtonPaste.setEnabled(enabled);
        this.jMenuItemPaste.setEnabled(enabled);
        this.jMenuItemDS_paste.setEnabled(enabled);
    }
    
    public void setUndoEnebled(boolean enabled) {
        this.jMenuItemUndo.setEnabled(enabled);
    }
    
    public void setRedoEnebled(boolean enabled) {
        this.jMenuItemRedo.setEnabled(enabled);
    }
    
    public void setSaveEnebled(boolean enabled) {
        this.jButtonSave.setEnabled( enabled);
        this.jMenuItemSave.setEnabled( enabled);
    }
    
    private void jMenuItemSubreportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSubreportActionPerformed
        jToggleButtonSubreportToolItemStateChanged(new java.awt.event.ItemEvent(jToggleButtonSubreportTool,0,jToggleButtonSubreportTool, java.awt.event.ItemEvent.SELECTED));
    }//GEN-LAST:event_jMenuItemSubreportActionPerformed
    
    private void jMenuItemTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemTextFieldActionPerformed
        jToggleButtonTextFieldToolItemStateChanged(new java.awt.event.ItemEvent(jToggleButtonTextFieldTool,0,jToggleButtonTextFieldTool, java.awt.event.ItemEvent.SELECTED));
    }//GEN-LAST:event_jMenuItemTextFieldActionPerformed
    
    private void jMenuItemStaticTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemStaticTextActionPerformed
        jToggleButtonStaticTextToolItemStateChanged(new java.awt.event.ItemEvent(jToggleButtonStaticTextTool,0,jToggleButtonStaticTextTool, java.awt.event.ItemEvent.SELECTED));
    }//GEN-LAST:event_jMenuItemStaticTextActionPerformed
    
    private void jMenuItemEllipseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemEllipseActionPerformed
        jToggleButtonEllipseToolItemStateChanged(new java.awt.event.ItemEvent(jToggleButtonEllipseTool,0,jToggleButtonEllipseTool, java.awt.event.ItemEvent.SELECTED));
    }//GEN-LAST:event_jMenuItemEllipseActionPerformed
    
    private void jMenuItemRoundRectangleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemRoundRectangleActionPerformed
        jToggleButtonRectRoundToolItemStateChanged(new java.awt.event.ItemEvent(jToggleButtonRectRoundTool,0,jToggleButtonRectRoundTool, java.awt.event.ItemEvent.SELECTED));
    }//GEN-LAST:event_jMenuItemRoundRectangleActionPerformed
    
    private void jMenuItemRectangleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemRectangleActionPerformed
        jToggleButtonRectToolItemStateChanged(new java.awt.event.ItemEvent(jToggleButtonRectTool,0,jToggleButtonRectTool, java.awt.event.ItemEvent.SELECTED));
    }//GEN-LAST:event_jMenuItemRectangleActionPerformed
    
    private void jMenuItemLineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemLineActionPerformed
        jToggleButtonLineToolItemStateChanged(new java.awt.event.ItemEvent(jToggleButtonLineTool,0,jToggleButtonLineTool, java.awt.event.ItemEvent.SELECTED));
    }//GEN-LAST:event_jMenuItemLineActionPerformed
    
    private void jMenuItemNullElementActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemNullElementActionPerformed
        
    }//GEN-LAST:event_jMenuItemNullElementActionPerformed
    
    private void jMenuEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuEditActionPerformed
        // Add your handling code here:
    }//GEN-LAST:event_jMenuEditActionPerformed
    
    private void jNumberComboBoxZoomValueChanged(ValueChangedEvent evt) {
        applyComboBoxZoomFactor();
    }
    
    private void applyComboBoxZoomFactor(){
        
        JInternalFrame jif = jMDIDesktopPane.getSelectedFrame();
        if (jif instanceof JReportFrame) {
            double new_factor = 0;
            String s = this.jNumberComboBoxZoom.getSelectedItem()+"";
            
            /* Code Begin Robert Lamping, 17 july 2004  
             * Add + modification
             * Fit to Page renamed to Width
             * Added:  Whole Page, Height
             */
            if (s.equalsIgnoreCase("Width")) {
                new_factor = (double)(((JReportFrame)jif).getJPanelReport().getWidth()-20) / (double)(((JReportFrame)jif).getReport().getWidth());
                ((JReportFrame)jif).setZoomFactor(new_factor);
                new_factor = (int)(100.0*new_factor);
                jNumberComboBoxZoom.setValue( new_factor );
                ((JReportFrame)jif).centerSelectedElements();
                
            } else if (s.equalsIgnoreCase("Whole page")) {
                int height = ((JReportFrame) jif).getReport().getDesignHeight();
                new_factor = Math.min( (double)(((JReportFrame)jif).getJPanelReport().getWidth()-20) / (double)(((JReportFrame)jif).getReport().getWidth()),
                (double)(((JReportFrame)jif).getJPanelReport().getHeight()-20) / (double) height );
                ((JReportFrame)jif).setZoomFactor(new_factor);
                new_factor = (int)(100.0*new_factor);
                jNumberComboBoxZoom.setValue( new_factor );

            } else if (s.equalsIgnoreCase("Height")) {
                int height = ((JReportFrame) jif).getReport().getDesignHeight();
                new_factor = (double)(((JReportFrame)jif).getJPanelReport().getHeight()-20) / (double) height ;
                ((JReportFrame)jif).setZoomFactor(new_factor);
                new_factor = (int)(100.0*new_factor);
                jNumberComboBoxZoom.setValue( new_factor );
                ((JReportFrame)jif).centerSelectedElements();

            /* Code End Robert Lamping, 17 july 2004  */                
            } else  {
                
                /* Code Begin Robert Lamping, 18 july 2004  */                
                Point defaultCenter = ((JReportFrame)jif).getCurrentCenter();
                
                ((JReportFrame)jif).setZoomFactor( (double)(this.jNumberComboBoxZoom.getValue()/100.0));

                // Move selected items in the middle if possible.
                ((JReportFrame)jif).centerSelectedElements( defaultCenter ) ;
                /* Code End Robert Lamping, 18 july 2004  */                
                
            }
            
        }
                 
    }
    
    /**
     *  This method adjust JImageButtons position in according with buttons array.
     *  A null entry is interpreted as a 8 pixel space.
     */
    private void jPanelToolBarComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jPanelToolBarComponentResized
        // Add your handling code here:
        if (toolBarControls == null ) return;
        int actualWidth=0;
        int actualHeight=0;
        int availWidth = this.jPanelToolBar.getWidth();
        
        java.util.Enumeration e = toolBarControls.elements();
        while (e.hasMoreElements()) {
            Object obj = e.nextElement();
            if (obj == null || ! (obj instanceof javax.swing.JComponent)) {
                if (actualWidth > 0) {
                    actualWidth += 8;
                }
            }
            else {
                javax.swing.JComponent ctl = (javax.swing.JComponent)obj;
                if ((actualWidth + ctl.getWidth()) > availWidth && (ctl.getWidth()+0 <= availWidth)) {
                    // Go to the next row...
                    actualHeight += 32;
                    actualWidth = 0;
                }
                ctl.setLocation(actualWidth,actualHeight);
                actualWidth += ctl.getWidth();
            }
        }
        jPanelToolBar.setSize( this.jPanelToolBar.getWidth(), (actualHeight+34));
        jPanelToolBar.setPreferredSize(new java.awt.Dimension( this.jPanelToolBar.getWidth(), (actualHeight)+34));
        jPanelToolBar.updateUI();
    }//GEN-LAST:event_jPanelToolBarComponentResized
    
    private void jMenuItemNewDocumentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemNewDocumentActionPerformed
        
        
        if (evt.getSource() == jButtonNew &&
            getProperties().getProperty( "DefaultTemplate") != null)
        {
            File f = new File( getProperties().getProperty( "DefaultTemplate"));
            if (f.exists())
            {
                try {
                    Report report = new Report(f.getPath());
                    report.setFilename( null );
                    report.setName( getFirstNameFree() );
                    report.setDirty( true );
                
                    openNewReportWindow( report );
                } catch (Exception ex) { 
                    ex.printStackTrace();
                }
                
                return;
            }
            
        }
        
        
        // Get info about the new report....
        // 1. Display the ReportProperties frame in dialog mode.
        //    Will be proposed default values...
        ReportPropertiesFrame rpf = new ReportPropertiesFrame(this,true);
        rpf.setModal(true);
        // find the first name free...
        String name = getFirstNameFree();
        rpf.setReportName( name);
        rpf.show();
        if (rpf.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) {
            // The user has clicked on OK...
            // Storing in a new report the report characteristics.
            Report newReport = new Report();
            newReport.setUsingMultiLineExpressions(false); //this.isUsingMultiLineExpressions());
            newReport.setWidth(rpf.getReportWidth());
            newReport.setHeight(rpf.getReportHeight());
            newReport.setOrientation(rpf.getOrientation());
            newReport.setName(rpf.getReportName());
            newReport.setTopMargin(rpf.getTopMargin());
            newReport.setLeftMargin(rpf.getLeftMargin());
            newReport.setRightMargin(rpf.getRightMargin());
            newReport.setBottomMargin(rpf.getBottomMargin());
            newReport.setColumnCount(rpf.getColumns());
            newReport.setColumnWidth(rpf.getColumnsWidth());
            newReport.setColumnSpacing(rpf.getColumnsSpacing());
            newReport.setIsSummaryNewPage(rpf.isSummaryOnNewPage());
            newReport.setIsTitleNewPage(rpf.isTitleOnNewPage());
            newReport.setWhenNoDataType(rpf.getWhenNoDataType());
            newReport.setScriptletClass(rpf.getScriptletClass());
            newReport.setEncoding(rpf.getXmlEncoding());
            newReport.setPrintOrder(rpf.getPrintOrder());
            newReport.setReportFormat(rpf.getReportFormat());
            newReport.setFloatColumnFooter(rpf.isFloatColumnFooter());
            newReport.setResourceBundleBaseName( rpf.getResourceBundleBaseName() );
            /* todo newReport.setPageName(rpf.getPageName());  */
            newReport.setLanguage( rpf.getLanguage() );
            
            
            openNewReportWindow( newReport );
            
        }
    }//GEN-LAST:event_jMenuItemNewDocumentActionPerformed
    
    public JReportFrame openNewReportWindow( Report newReport ) {
        // Create a new document frame....
        // ...that rappresent the report document created...
        JReportFrame jrf = new JReportFrame(newReport);
        
        jrf.addReportListener(this);
        newReport.addReportObjectChangedListener( this.getLibraryPanel());
        newReport.addReportObjectChangedListener( this.getValuesDialog());
        
        // this is for JMDIFrame design...
        // jMDIMenuBar could be retrived from the jrf parent, contained in the JFrame
        // that store the JDesktopPane parent...
        jrf.setMenu( this.jMDIMenuBar );
        // Set default, but we starting the frame maximized by default...
        jrf.setBounds(10,10,700,500);
        // We must set the frame visible before adding it to the jMDIDesktopPane...
        
        jrf.setShowGrid( this.getProperties().getProperty( "showGrid", "false" ).equals("true"));
        jrf.setSnapToGrid( this.getProperties().getProperty( "snapToGrid", "false" ).equals("true"));
        
        jrf.setVisible(true);
        
        if (!isEmptyString(jrf.getReport().getFilename()) ) {
            recentFilesList.remove( jrf.getReport().getFilename());
            recentFilesList.insertElementAt(jrf.getReport().getFilename(),0);
            this.updateRecentFileMenu(jMenuRecentFiles, recentFilesList );
            //saveFileList(recentFilesList, "recentFiles.xml");
            saveFileList(recentFilesList, IREPORT_RECENT_FILES_FILE);
        }
        
        jMDIDesktopPane.add(jrf, javax.swing.JLayeredPane.DEFAULT_LAYER);
        
        jMDIDesktopPane.getDesktopManager().activateFrame(jrf);

        // Count all frames...
        
        int f_num = jMDIDesktopPane.getAllFrames().length;
        JRadioButtonMenuItemMDIFrame menuItem = new JRadioButtonMenuItemMDIFrame((JMDIFrame)jrf, f_num + ". " + jrf.getTitle() );
        menuItem.setSelected(true);
        menuItem.setMnemonic((int)((f_num+"").charAt(0)) );
        menuItem.setFont(new java.awt.Font("Dialog", 0, 11));
        menuItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke((int)((f_num+"").charAt(0)),java.awt.Event.META_MASK));
        
        this.jMenuWindow.insert(menuItem, this.jMenuWindow.getMenuComponentCount());
        menuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuWindowListActionPerformed(evt);
            }
        });
        buttonGroupFramesList.add(menuItem);
        //updateMenuWindowList();
        
        // After activation, we try to maximize the window....
        try {
            jrf.setSelected(true);
            jrf.setZoomFactor( this.getCurrentZoomFactor() );
            //if (jMDIMenuBar.getMaximizedFrame()  != null)
            jrf.setMaximum(true);
            String report_name = jrf.getReport().getName();
            DocumentTreeEntry dte = new DocumentTreeEntry(jrf,jrf.getReport().getName());
            javax.swing.tree.DefaultTreeModel dtm = (javax.swing.tree.DefaultTreeModel) jTreeFiles.getModel();
            ((javax.swing.tree.DefaultMutableTreeNode)dtm.getRoot()).add(
            new javax.swing.tree.DefaultMutableTreeNode(dte));
            setFileListActivatedFrame(jrf);
            this.jTreeFiles.updateUI();
           
        } catch (java.beans.PropertyVetoException ex) {
            /* Nothing to do */
        } catch (Exception ex2) {
            /* Do nothing */
        }
        
        //set zoomfactor in toolbar
        this.jNumberComboBoxZoom.setValue( (int) (this.getCurrentZoomFactor()*100) );

        // This call fix a bug in the code to show control box buttons on menu panel...
        jMDIMenuBar.restoreButtonsPosition();
        if( !isEmptyString(newReport.getFilename())) {
            if(newReport.isModified()) {
                this.enableSaveSpecific();
                this.enableSaveAllSpecific();
            }
            else {
                this.disableSaveSpecific();
                if(this.isSaveAllRequired()) {
                    this.enableSaveAllSpecific();
                }
                else {
                    this.disableSaveAllSpecific();
                }
            }
        }
        else {
            this.enableSaveSpecific();
            this.enableSaveAllSpecific();
        }
        
        return jrf;
    }
    private void jMenuFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuFileActionPerformed
        // Add your handling code here:
        jMDIMenuBar.restoreButtonsPosition();
    }//GEN-LAST:event_jMenuFileActionPerformed
    
    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        
        // This try is of java <1.4 comatibility
        try {
            this.getExtendedState();
        } catch (java.lang.NoSuchMethodError ex) {
            java.awt.Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
            java.awt.Point p = new java.awt.Point();
            p.x = Math.max( 0, (dim.width -this.getWidth())/2 );
            p.y = Math.max( 0, (dim.height -this.getHeight())/2 );
            this.setLocation(p);
        }
        //this.setSize(dim);
        //this.getContentPane().repaint();
        //this.update(this.getGraphics());
        //this.setState(java.awt.Frame.MAXIMIZED_HORIZ);
    }//GEN-LAST:event_formWindowOpened
    
    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
        closeApplication();
    }//GEN-LAST:event_exitForm
    
    private void closeApplication() {
        try {
            this.saveiReportConfiguration();
        }
        catch(Throwable e) {
            e.printStackTrace(System.err);
        }
        if( this.isSaveAllRequired() ) {
            String message = "There are unsaved files.  Would you like to save them before exiting?";
            String caption = "Unsaved files";
            int ret = javax.swing.JOptionPane.showConfirmDialog(this, message, caption, javax.swing.JOptionPane.YES_NO_CANCEL_OPTION);
            switch(ret) {
                case javax.swing.JOptionPane.YES_OPTION:
                    java.awt.event.ActionEvent ae = new java.awt.event.ActionEvent(jMenuItemSaveAll,0, this.jMenuItemSaveAll.getActionCommand());
                    jMenuItemSaveAllActionPerformed(ae);
                    return;
                case javax.swing.JOptionPane.NO_OPTION:
                    break;
                case javax.swing.JOptionPane.CANCEL_OPTION:
                    return;
            }
        }
        this.dispose();
        if(!isEmbedded()) {
            System.exit(0);
        }
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        
        // command line arguments
        //StringParam patternArg =
        //    new StringParam("config-file", "",
        //                    StringParam.PUBLIC);
        
        FileParam configFileOpt =
        new FileParam("config-file",
        "the configuration file to use",
        FileParam.IS_FILE & FileParam.IS_READABLE & FileParam.IS_WRITEABLE,
        FileParam.OPTIONAL);
        
        FileParam ireportHomeDirOpt =
        new FileParam("ireport-home",
        "iReport home directory",
        FileParam.IS_DIR & FileParam.IS_READABLE & FileParam.IS_WRITEABLE,
        FileParam.OPTIONAL);
        
        FileParam userHomeDirOpt =
        new FileParam("user-home",
        "User home directory",
        FileParam.IS_DIR & FileParam.IS_READABLE & FileParam.IS_WRITEABLE,
        FileParam.OPTIONAL);
        
        FileParam tempDirOpt =
        new FileParam("temp-dir",
        "Dir where store temporary java sources",
        FileParam.IS_DIR & FileParam.IS_READABLE & FileParam.IS_WRITEABLE,
        FileParam.OPTIONAL);
        
        BooleanParam configSplashOpt =
        new BooleanParam("no-splash",
        "not show the spash window");
        
        StringParam configBeanClassOpt =
        new StringParam("beanClass",
        "show this class when open extended bean data source query editor");
        
        FileParam filesArg =
        new FileParam("files",
        "xml file(s) to edit, supports use of wildcards ",
        FileParam.IS_FILE & FileParam.IS_READABLE,
        FileParam.OPTIONAL, FileParam.MULTI_VALUED);
        
        
        
        // command line options
        //BooleanParam ignorecaseOpt =
        //    new BooleanParam("ignoreCase", "ignore case while matching");
        //BooleanParam listfilesOpt =
        //    new BooleanParam("listFiles", "list filenames containing pattern");
        
        // a help text because we will use a HelpCmdLineHandler so our
        // command will display verbose help with the -help option
        String helpText = "This command prints to stdout all lines within " +
        "the specified files that contain the specified " +
        "pattern.\n\n" +
        "Optionally, the matching may be done without " +
        "regard to case (using the -ignorecase option).\n\n" +
        "If the -listFiles option is specified, only the " +
        "names of the files containing the pattern will be " +
        "listed.  In this case, files to process must be " +
        "specified on the command line";
        CmdLineHandler cl =
        new VersionCmdLineHandler( MainFrame.constTitle,
        new HelpCmdLineHandler(helpText,
        "iReport",
        "Designer for JasperReports",
        new Parameter[] { configFileOpt, ireportHomeDirOpt, userHomeDirOpt, tempDirOpt, configSplashOpt, configBeanClassOpt},
        new Parameter[] { filesArg } ));
        
        cl.setParser(new PosixCmdLineParser());
        
        cl.setDieOnParseError(false);
        
        if (!cl.parse(args)) {
            // This prevent a call to exit from the parser.
            System.out.println(cl.getUsage(true));
            System.out.println(cl.getParseError());
            return;
        }
        
        Map map = new HashMap();
        if (configFileOpt.isSet()) {
            map.put("config-file", configFileOpt.getFile().getPath());
        }
        
        if (!configSplashOpt.isTrue()) {
            SplashDialog sp = new SplashDialog(null, false);
            sp.setVisible(true);
            map.put("splash", sp);
        }
        
        if (ireportHomeDirOpt.isSet()) {
            map.put("ireport-home", ireportHomeDirOpt.getFile().getPath());
        }
        
        if (userHomeDirOpt.isSet()) {
            map.put("user-home", userHomeDirOpt.getFile().getPath());
        }
        
        if (tempDirOpt.isSet()) {
            map.put("temp-dir", tempDirOpt.getFile().getPath());
        }
        
        if (filesArg.isSet()) {
            map.put("files", filesArg.getFiles());
        }
        
        if (configBeanClassOpt.isSet())
        {
            map.put("beanClass", configBeanClassOpt.getValue());
        }
        
        MainFrame _mainFrame = new MainFrame(map);
        _mainFrame.show();
    }
    
    
    
    private static byte[] getBytesFromInputStream(java.io.InputStream in, int length)  throws java.io.IOException {
        java.io.DataInputStream din = new java.io.DataInputStream(in);
        byte[] bytecodes = new byte[length];
        try {
            din.readFully(bytecodes);
        } finally {
            if (din != null) din.close();
        }
        return bytecodes;
    }
    
    /** Gets the image to be displayed in the minimized icon
     * for this frame.
     * @return    the icon image for this frame, or <code>null</code>
     *                    if this frame doesn't have an icon image.
     * @see       #setIconImage(Icon)
     *
     */
    public java.awt.Image getIconImage() {
        try {
            ClassLoader cl = this.getClass().getClassLoader();
            //java.io.InputStream in = new java.io.FileInputStream( cl.getResource("it/businesslogic/ireport/icons/iconsmall.jpg").getPath() );
            java.io.InputStream in = cl.getResourceAsStream("it/businesslogic/ireport/icons/iconsmall.jpg");
            byte[] data = getBytesFromInputStream(in, in.available());
            return java.awt.Toolkit.getDefaultToolkit().createImage(data);
        } catch (Exception ex)
        {ex.getMessage();
         ex.printStackTrace();
        }
        return null;
    }
    
    /** Getter for property elementPropertiesFrame.
     * @return Value of property elementPropertiesFrame.
     *
     */
    public ElementPropertiesDialog getElementPropertiesDialog() {
        return elementPropertiesDialog;
    }
    
    /** Setter for property elementPropertiesFrame.
     * @param elementPropertiesFrame New value of property elementPropertiesFrame.
     *
     */
    public void setElementPropertiesDialog(ElementPropertiesDialog elementPropertiesDialog) {
        this.elementPropertiesDialog = elementPropertiesDialog;
    }
    
    /** Getter for property valuesDialog.
     * @return Value of property valuesDialog.
     *
     */
    public it.businesslogic.ireport.gui.ValuesDialog getValuesDialog() {
        return valuesDialog;
    }
    
    /** Setter for property valuesDialog.
     * @param valuesDialog New value of property valuesDialog.
     *
     */
    public void setValuesDialog(it.businesslogic.ireport.gui.ValuesDialog valuesDialog) {
        this.valuesDialog = valuesDialog;
    }
    
    /** Getter for property groupsDialog.
     * @return Value of property groupsDialog.
     *
     */
    public it.businesslogic.ireport.gui.GroupsDialog getGroupsDialog() {
        return groupsDialog;
    }
    
    /** Setter for property groupsDialog.
     * @param groupsDialog New value of property groupsDialog.
     *
     */
    public void setGroupsDialog(it.businesslogic.ireport.gui.GroupsDialog groupsDialog) {
        this.groupsDialog = groupsDialog;
    }
    
    /** Getter for property bandsDialog.
     * @return Value of property bandsDialog.
     *
     */
    public BandsDialog getBandsDialog() {
        return bandsDialog;
    }
    
    /** Setter for property bandsDialog.
     * @param bandsDialog New value of property bandsDialog.
     *
     */
    public void setBandsDialog(BandsDialog bandsDialog) {
        this.bandsDialog = bandsDialog;
    }
    
    /** Getter for property reportQueryDialog.
     * @return Value of property reportQueryDialog.
     *
     */
    public it.businesslogic.ireport.gui.ReportQueryDialog getReportQueryDialog() {
        return reportQueryDialog;
    }
    
    /** Setter for property reportQueryDialog.
     * @param reportQueryDialog New value of property reportQueryDialog.
     *
     */
    public void setReportQueryDialog(it.businesslogic.ireport.gui.ReportQueryDialog reportQueryDialog) {
        this.reportQueryDialog = reportQueryDialog;
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Filler;
    private javax.swing.JButton Filler1;
    private javax.swing.ButtonGroup buttonGroupExportType;
    private javax.swing.ButtonGroup buttonGroupFramesList;
    private javax.swing.JButton jButtonAlignBottom;
    private javax.swing.JButton jButtonAlignCenter;
    private javax.swing.JButton jButtonAlignJustify;
    private javax.swing.JButton jButtonAlignLeft;
    private javax.swing.JButton jButtonAlignMiddle;
    private javax.swing.JButton jButtonAlignRight;
    private javax.swing.JButton jButtonAlignTop;
    private javax.swing.JButton jButtonBands;
    private javax.swing.JButton jButtonBold;
    private javax.swing.JButton jButtonCompiler;
    private javax.swing.JButton jButtonCopy;
    private javax.swing.JButton jButtonCut;
    private javax.swing.JButton jButtonDatabase;
    private javax.swing.JButton jButtonDecreaseSize;
    private javax.swing.JButton jButtonGroups;
    private javax.swing.JButton jButtonIncreaseSize;
    private javax.swing.JButton jButtonItalic;
    private javax.swing.JButton jButtonNew;
    private javax.swing.JButton jButtonOpen;
    private javax.swing.JButton jButtonParameters;
    private javax.swing.JButton jButtonPaste;
    private javax.swing.JButton jButtonRun1;
    private javax.swing.JButton jButtonRun2;
    private javax.swing.JButton jButtonSave;
    private javax.swing.JButton jButtonStrikethrought;
    private javax.swing.JButton jButtonUnderline;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItemEMM;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItemElementsFormatting;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItemExplorer;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItemGrid;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItemOutput;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItemSnapToGrid;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItemTextFormatting;
    private javax.swing.JComboBox jComboBoxFont;
    private javax.swing.JEditorPane jEditorPaneOutput;
    private javax.swing.JList jListThreads;
    private it.businesslogic.ireport.gui.JMDIDesktopPane jMDIDesktopPane;
    private it.businesslogic.ireport.gui.JMDIMenuBar jMDIMenuBar;
    private javax.swing.JMenu jMenuAdd;
    private javax.swing.JMenu jMenuAlign;
    private javax.swing.JMenu jMenuBuild;
    private javax.swing.JMenu jMenuDatabase;
    private javax.swing.JMenu jMenuEdit;
    private javax.swing.JMenu jMenuFile;
    private javax.swing.JMenu jMenuFormat;
    private javax.swing.JMenu jMenuHSpacing;
    private javax.swing.JMenu jMenuHelp;
    private javax.swing.JMenu jMenuInternationalization;
    private javax.swing.JMenuItem jMenuInternationalizationWizard;
    private javax.swing.JMenuItem jMenuItemAbout;
    private javax.swing.JMenuItem jMenuItemActiveConnection;
    private javax.swing.JMenuItem jMenuItemAddFileToProject;
    private javax.swing.JMenuItem jMenuItemAlignBottom;
    private javax.swing.JMenuItem jMenuItemAlignHorizontalAxis;
    private javax.swing.JMenuItem jMenuItemAlignLeft;
    private javax.swing.JMenuItem jMenuItemAlignRight;
    private javax.swing.JMenuItem jMenuItemAlignToBandBottom;
    private javax.swing.JMenuItem jMenuItemAlignToBandTop;
    private javax.swing.JMenuItem jMenuItemAlignTop;
    private javax.swing.JMenuItem jMenuItemAlignVerticalAxis;
    private javax.swing.JMenuItem jMenuItemBands;
    private javax.swing.JMenuItem jMenuItemBringToFront;
    private javax.swing.JMenuItem jMenuItemCascade;
    private javax.swing.JMenuItem jMenuItemCenterBackground;
    private javax.swing.JMenuItem jMenuItemCenterH;
    private javax.swing.JMenuItem jMenuItemCenterInBand;
    private javax.swing.JMenuItem jMenuItemCenterV;
    private javax.swing.JMenuItem jMenuItemChart;
    private javax.swing.JMenuItem jMenuItemClasspath;
    private javax.swing.JMenuItem jMenuItemClose;
    private javax.swing.JMenuItem jMenuItemCloseAll;
    private javax.swing.JMenuItem jMenuItemCloseAllExceptThis;
    private javax.swing.JMenuItem jMenuItemCloseAllExceptThisFromList;
    private javax.swing.JMenuItem jMenuItemCloseAllFromList;
    private javax.swing.JMenuItem jMenuItemCloseFromList;
    private javax.swing.JMenuItem jMenuItemCloseProject;
    private javax.swing.JMenuItem jMenuItemCompatibility;
    private javax.swing.JMenuItem jMenuItemCompile;
    private javax.swing.JMenuItem jMenuItemCompileAll;
    private javax.swing.JMenuItem jMenuItemConnections;
    private javax.swing.JMenuItem jMenuItemCopy;
    private javax.swing.JMenuItem jMenuItemCut;
    private javax.swing.JMenuItem jMenuItemDSB_properties;
    private javax.swing.JMenuItem jMenuItemDS_copy;
    private javax.swing.JMenuItem jMenuItemDS_cut;
    private javax.swing.JMenuItem jMenuItemDS_delete;
    private javax.swing.JMenuItem jMenuItemDS_paste;
    private javax.swing.JMenuItem jMenuItemDS_properties;
    private javax.swing.JMenuItem jMenuItemDelete;
    private javax.swing.JMenuItem jMenuItemElementProperties;
    private javax.swing.JMenuItem jMenuItemElementsBrowser;
    private javax.swing.JMenuItem jMenuItemEllipse;
    private javax.swing.JMenuItem jMenuItemExecute;
    private javax.swing.JMenuItem jMenuItemExecuteDB;
    private javax.swing.JMenuItem jMenuItemExportOptions;
    private javax.swing.JMenuItem jMenuItemFavorites;
    private javax.swing.JMenuItem jMenuItemFields;
    private javax.swing.JMenuItem jMenuItemFind;
    private javax.swing.JMenuItem jMenuItemFindNext;
    private javax.swing.JMenuItem jMenuItemFindPrev;
    private javax.swing.JMenuItem jMenuItemFonts;
    private javax.swing.JMenuItem jMenuItemGroups;
    private javax.swing.JMenuItem jMenuItemHSDecrease;
    private javax.swing.JMenuItem jMenuItemHSIncrease;
    private javax.swing.JMenuItem jMenuItemHSMakeEqual;
    private javax.swing.JMenuItem jMenuItemHSRemove;
    private javax.swing.JMenuItem jMenuItemHelp;
    private javax.swing.JMenuItem jMenuItemImage;
    private javax.swing.JMenuItem jMenuItemJoinLeft;
    private javax.swing.JMenuItem jMenuItemJoinRight;
    private javax.swing.JMenuItem jMenuItemKill;
    private javax.swing.JMenuItem jMenuItemLeftMargin;
    private javax.swing.JMenuItem jMenuItemLine;
    private javax.swing.JMenuItem jMenuItemMoveDown;
    private javax.swing.JMenuItem jMenuItemMoveUp;
    private javax.swing.JMenuItem jMenuItemNewDocument;
    private javax.swing.JMenuItem jMenuItemNewProject;
    private javax.swing.JMenuItem jMenuItemNextWin;
    private javax.swing.JMenuItem jMenuItemNullElement;
    private javax.swing.JMenuItem jMenuItemOpen;
    private javax.swing.JMenuItem jMenuItemOpenProject;
    private javax.swing.JMenuItem jMenuItemOptions;
    private javax.swing.JMenuItem jMenuItemOrganize;
    private javax.swing.JMenuItem jMenuItemParameters;
    private javax.swing.JMenuItem jMenuItemPaste;
    private javax.swing.JMenuItem jMenuItemPluginConfig;
    private javax.swing.JMenuItem jMenuItemPrevWin;
    private javax.swing.JMenuItem jMenuItemProjectOptions;
    private javax.swing.JMenuItem jMenuItemProperties;
    private javax.swing.JMenuItem jMenuItemQOpen;
    private javax.swing.JMenuItem jMenuItemQuit;
    private javax.swing.JMenuItem jMenuItemRectangle;
    private javax.swing.JMenuItem jMenuItemRedo;
    private javax.swing.JMenuItem jMenuItemRemoveMargins;
    private javax.swing.JMenuItem jMenuItemReplace;
    private javax.swing.JMenuItem jMenuItemReportImports;
    private javax.swing.JMenuItem jMenuItemReportLocale;
    private javax.swing.JMenuItem jMenuItemReportProperties;
    private javax.swing.JMenuItem jMenuItemReportQuery;
    private javax.swing.JMenuItem jMenuItemReportQuery2;
    private javax.swing.JMenuItem jMenuItemReportSeries;
    private javax.swing.JMenuItem jMenuItemRevertToSaved;
    private javax.swing.JMenuItem jMenuItemRevertToSavedFromList;
    private javax.swing.JMenuItem jMenuItemRightMargin;
    private javax.swing.JMenuItem jMenuItemRoundRectangle;
    private javax.swing.JMenuItem jMenuItemSameHeight;
    private javax.swing.JMenuItem jMenuItemSameHeightMax;
    private javax.swing.JMenuItem jMenuItemSameHeightMin;
    private javax.swing.JMenuItem jMenuItemSameSize;
    private javax.swing.JMenuItem jMenuItemSameWidth;
    private javax.swing.JMenuItem jMenuItemSameWidthMax;
    private javax.swing.JMenuItem jMenuItemSameWidthMin;
    private javax.swing.JMenuItem jMenuItemSave;
    private javax.swing.JMenuItem jMenuItemSaveAll;
    private javax.swing.JMenuItem jMenuItemSaveAllFromList;
    private javax.swing.JMenuItem jMenuItemSaveAs;
    private javax.swing.JMenuItem jMenuItemSaveAsFromList;
    private javax.swing.JMenuItem jMenuItemSaveFromList;
    private javax.swing.JMenuItem jMenuItemScriptletEditor;
    private javax.swing.JMenuItem jMenuItemSendToBack;
    private javax.swing.JMenuItem jMenuItemStaticText;
    private javax.swing.JMenuItem jMenuItemSubreport;
    private javax.swing.JMenuItem jMenuItemTextField;
    private javax.swing.JMenuItem jMenuItemTileHorizontal;
    private javax.swing.JMenuItem jMenuItemTileVertical;
    private javax.swing.JMenuItem jMenuItemUndo;
    private javax.swing.JMenuItem jMenuItemVSDecrease;
    private javax.swing.JMenuItem jMenuItemVSIncrease;
    private javax.swing.JMenuItem jMenuItemVSMakeEqual;
    private javax.swing.JMenuItem jMenuItemVSRemove;
    private javax.swing.JMenuItem jMenuItemVariables;
    private javax.swing.JMenuItem jMenuItemWizard;
    private javax.swing.JMenuItem jMenuItemXMLSource;
    private javax.swing.JMenuItem jMenuItemtileAnodine;
    private javax.swing.JMenuItem jMenuLocaleFiles;
    private javax.swing.JMenu jMenuPlugins;
    private javax.swing.JMenu jMenuPosition;
    private javax.swing.JMenu jMenuProjects;
    private javax.swing.JMenu jMenuRecentFiles;
    private javax.swing.JMenu jMenuRecentProjects;
    private javax.swing.JMenu jMenuSearch;
    private javax.swing.JMenu jMenuSize;
    private javax.swing.JMenu jMenuToolBars;
    private javax.swing.JMenu jMenuTools;
    private javax.swing.JMenu jMenuVSpacing;
    private javax.swing.JMenu jMenuView;
    private javax.swing.JMenu jMenuWindow;
    private it.businesslogic.ireport.gui.JNumberComboBox jNumberComboBoxSize;
    private it.businesslogic.ireport.gui.JNumberComboBox jNumberComboBoxZoom;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanelDocumentStructure;
    private javax.swing.JPanel jPanelFiles;
    private javax.swing.JPanel jPanelMaster;
    private javax.swing.JPanel jPanelProcesses;
    private javax.swing.JPanel jPanelSouth;
    private javax.swing.JPanel jPanelToolBar;
    private javax.swing.JPanel jPanelZoom;
    private javax.swing.JPopupMenu jPopupMenuDocumentStructure;
    private javax.swing.JPopupMenu jPopupMenuDocumentStructureBand;
    private javax.swing.JPopupMenu jPopupMenuFiles;
    private javax.swing.JPopupMenu jPopupMenuThreads;
    private javax.swing.JRadioButtonMenuItem jRadioButtonMenuItemPreviewCSV;
    private javax.swing.JRadioButtonMenuItem jRadioButtonMenuItemPreviewHTML;
    private javax.swing.JRadioButtonMenuItem jRadioButtonMenuItemPreviewInternalViewer;
    private javax.swing.JRadioButtonMenuItem jRadioButtonMenuItemPreviewJAVA;
    private javax.swing.JRadioButtonMenuItem jRadioButtonMenuItemPreviewPDF;
    private javax.swing.JRadioButtonMenuItem jRadioButtonMenuItemPreviewTXT;
    private javax.swing.JRadioButtonMenuItem jRadioButtonMenuItemPreviewXLS;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPaneFiles;
    private javax.swing.JScrollPane jScrollPaneOutput;
    private javax.swing.JScrollPane jScrollProcesses;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator10;
    private javax.swing.JSeparator jSeparator11;
    private javax.swing.JSeparator jSeparator12;
    private javax.swing.JSeparator jSeparator13;
    private javax.swing.JSeparator jSeparator14;
    private javax.swing.JSeparator jSeparator15;
    private javax.swing.JSeparator jSeparator16;
    private javax.swing.JSeparator jSeparator17;
    private javax.swing.JSeparator jSeparator18;
    private javax.swing.JSeparator jSeparator19;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator20;
    private javax.swing.JSeparator jSeparator21;
    private javax.swing.JSeparator jSeparator22;
    private javax.swing.JSeparator jSeparator23;
    private javax.swing.JSeparator jSeparator24;
    private javax.swing.JSeparator jSeparator25;
    private javax.swing.JSeparator jSeparator26;
    private javax.swing.JSeparator jSeparator27;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JSeparator jSeparator5;
    private javax.swing.JSeparator jSeparator6;
    private javax.swing.JSeparator jSeparator7;
    private javax.swing.JSeparator jSeparator8;
    private javax.swing.JSeparator jSeparator9;
    private javax.swing.JSplitPane jSplitPaneHorizontal;
    private javax.swing.JSplitPane jSplitPaneV;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTabbedPane jTabbedPaneExplorer;
    private javax.swing.JToggleButton jToggleButtonBarcodeTool;
    private javax.swing.JToggleButton jToggleButtonChartTool;
    private javax.swing.JToggleButton jToggleButtonEllipseTool;
    private javax.swing.JToggleButton jToggleButtonImageTool;
    private javax.swing.JToggleButton jToggleButtonLineTool;
    private javax.swing.JToggleButton jToggleButtonPointer;
    private javax.swing.JToggleButton jToggleButtonRectRoundTool;
    private javax.swing.JToggleButton jToggleButtonRectTool;
    private javax.swing.JToggleButton jToggleButtonStaticTextTool;
    private javax.swing.JToggleButton jToggleButtonSubreportTool;
    private javax.swing.JToggleButton jToggleButtonTextFieldTool;
    private javax.swing.JToolBar jToolBarConnections;
    private javax.swing.JToolBar jToolBarFormat;
    private javax.swing.JToolBar jToolBarText;
    private javax.swing.JTree jTreeDocument;
    private javax.swing.JTree jTreeFiles;
    // End of variables declaration//GEN-END:variables
    
    
    /* This method load:
     *  recent file list
     *  recent project list
     *  favorites files list
     */
    public void loadFileLists() {
        
        loadFileList(this.getRecentFilesList(), IREPORT_RECENT_FILES_FILE);
        //loadFileList(this.getRecentProjectsList(), IREPORT_RECENT_PROJECTS_FILE);
        // First we must implement it....
        //loadFileList(this.getFavoriteFilesList() , IREPORT_FAVORITE_FILES_FILE);
    }
    
    private void loadFileList(Vector v, String xmlFile) {
        File file = null;
        try {
            file = new File(xmlFile);
        } catch (Exception ex)
        {}
        if (file == null || !file.exists() || file.isDirectory()) {
            try {
                outputBuffer.setLength(0);
                logOnConsole("Error loading Configuration file: "+xmlFile+"\n");
            } catch (Exception exsx)
            {}
            return;
        }
        //  Create a Xerces DOM Parser
        DOMParser parser = new DOMParser();
        //  Parse the Document
        //  and traverse the DOM
        try {
            
            parser.setEntityResolver( new org.xml.sax.EntityResolver() {
                /* Code by Teodor Danciu */
                public org.xml.sax.InputSource resolveEntity(
                String publicId,
                String systemId
                ) throws SAXException//, java.io.IOException
                {
                    org.xml.sax.InputSource inputSource = null;
                    
                    if (systemId != null) {
                        String dtd = null;
                        
                        if (
                        systemId.equals("http://ireport.sourceforge.net/dtds/iReportFilesList.dtd")
                        ) {
                            dtd = "it/businesslogic/ireport/dtds/iReportFilesList.dtd";
                        }
                        else {
                            return new org.xml.sax.InputSource(systemId);
                        }
                        
                        ClassLoader classLoader = this.getClass().getClassLoader();
                        
                        java.net.URL url = null;
                        
                        
                        if (classLoader != null) {
                            url = classLoader.getResource(dtd);
                        }
                        if (url == null) {
                            classLoader = this.getClass().getClassLoader();
                        }
                        
                        java.io.InputStream is = classLoader.getResourceAsStream(dtd);
                        if (is != null) {
                            java.io.InputStreamReader isr = new java.io.InputStreamReader(is);
                            inputSource = new org.xml.sax.InputSource(isr);
                        }
                        
                    }
                    
                    return inputSource;
                }
            });
            /* End Code by Teodor Danciu */
            parser.parse( new java.io.File(xmlFile).toURI().toString() );
            Document document = parser.getDocument();
            
            // Traverse the tree until we don't find a iReportFilesList element...
            Node fileList = goToNodeElement("iReportFilesList",document.getDocumentElement());
            if (fileList == null) return;
            NodeList list = fileList.getChildNodes();
            for (int i=0; i < list.getLength(); ++i) {
                Node child = list.item(i);
                if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("iReportFile")) {
                    String fileName = Report.readPCDATA(child);
                    if (fileName != null && fileName.trim().length()>0) {
                        v.addElement( fileName );
                    }
                }
                
            }
            
        } catch (Exception ex) {
        }
    }
    
    static public Node goToNodeElement(String name, Node node ) {
        if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("iReportFilesList")) {
            return node;
        }
        
        NodeList list = node.getChildNodes();
        for (int i=0; i < list.getLength(); ++i) {
            Node child = goToNodeElement(name, list.item(i) );
            if (child != null) return child;
        }
        
        return null;
    }
    
    /* iReport configuration loader...
     */
    public void loadiReportConfiguration() {
        loadiReportConfiguration( IREPORT_CONFIG_FILE );
    }
    
     /* iReport configuration loader...
      */
    public void loadiReportConfiguration(String xmlFile) {
        // Adding default properties...
        properties.put("RecentFilesLength","10");
        properties.put("ViewRules","true");
        properties.put("GridSize","10");
        properties.put("ViewBorderForTextElements","true");
        properties.put("DefaultTemplate","");
        properties.put("DefaultCompilationDirectory",".");
        properties.put("BackupPolicy","2");
        properties.put("DefaultBackupDirectory","");
        properties.put("ExternalEditor","");
        properties.put("ExternalPDFViewer","");
        properties.put("ExternalHTMLViewer","");
        properties.put("ExternalXLSViewer","");
        properties.put("ExternalCSVViewer","");
        properties.put("ViewBorderForTextElements","true");
        properties.put("ViewBorderColor","1");
        properties.put("DefaultUnit","cm");
        properties.put("SaveBeforeCompiling","true");
        properties.put("ViewBorderColor","-6710887");
        properties.put("LookAndFeel", "Metal");
        properties.put("UseAutoRegiesterFields", "true");
        properties.put("UseAutoRegiesterFields", "true");
        properties.put("Language", java.util.Locale.getDefault().getLanguage());
        properties.put("Country", "");
        properties.put("Compatibility", "" + CompatibilitySupport.LAST_AVAILABLE_VERSION);
        properties.put("toolbarFormattingVisible","true");
        properties.put("toolbarTextVisible","true");
        properties.put("showGrid","false");
        properties.put("snapToGrid","false");
        
        File file = null;
        try {
            file = new File(xmlFile);
        } catch (Exception ex)
        {}
        if (file == null || !file.exists() || file.isDirectory()) {
            try {
                outputBuffer.setLength(0);
                logOnConsole("Error loading iReport Configuration file: "+xmlFile+"\nUsing default parameters.");
            } catch (Exception exsx)
            {}
            return;
        }
        //  Create a Xerces DOM Parser
        DOMParser parser = new DOMParser();
        //  Parse the Document
        //  and traverse the DOM
        try {
            
            parser.setEntityResolver( new org.xml.sax.EntityResolver() {
                /* Code by Teodor Danciu */
                public org.xml.sax.InputSource resolveEntity(
                String publicId,
                String systemId
                ) throws SAXException//, java.io.IOException
                {
                    org.xml.sax.InputSource inputSource = null;
                    
                    if (systemId != null) {
                        String dtd = null;
                        
                        if ( systemId.equals("http://ireport.sourceforge.net/dtds/iReportProperties.dtd") ) {
                            dtd = "it/businesslogic/ireport/dtds/iReportProperties.dtd";
                        } else {
                            return new org.xml.sax.InputSource(systemId);
                        }
                        
                        
                        ClassLoader classLoader = this.getClass().getClassLoader();
                        
                        java.net.URL url = null;
                        
                        
                        if (classLoader != null) {
                            url = classLoader.getResource(dtd);
                        }
                        if (url == null) {
                            classLoader = this.getClass().getClassLoader();
                        }
                        
                        java.io.InputStream is = classLoader.getResourceAsStream(dtd);
                        if (is != null) {
                            java.io.InputStreamReader isr = new java.io.InputStreamReader(is);
                            inputSource = new org.xml.sax.InputSource(isr);
                        }
                        
                    }
                    
                    return inputSource;
                }
            });
            /* End Code by Teodor Danciu */
            parser.parse( new java.io.File(xmlFile).toURI().toString() );
            Document document = parser.getDocument();
            
            traverse(document.getDocumentElement());
            
            String defaultConnection = Misc.nvl(properties.get("DefaultConnection"),"");
            
            //properties.put("DefaultConnection", null); // No default connection...
            if (!defaultConnection.equals("")) {
                // Looking for a connection width this name..,
                Enumeration e = getConnections().elements();
                while (e.hasMoreElements()) {
                    IReportConnection irc = (IReportConnection)e.nextElement();
                    if (Misc.nvl(irc.getName(),"").equals( defaultConnection )) {
                        properties.put("DefaultConnection", irc);
                        break;
                    }
                }
            }
            else if (getConnections().size() > 0)
            {
            	IReportConnection irc = (IReportConnection)getConnections().elementAt(0);
            	properties.put("DefaultConnection", irc);
            }
            
            
            String currentDirectory = Misc.nvl(properties.get("CurrentDirectory"),"");
            if (!currentDirectory.equals("")) {
                this.setCurrentDirectory(new java.io.File( currentDirectory ), false);
            }
            
            //I changed this from the working directory to the ireport IREPORT_DEFAULT_HOME_DIR
            // Now is set in setiReportPaths ... setHomeDirectory(Misc.nvl(System.getProperty("ireport.home"), IREPORT_DEFAULT_HOME_DIR));
            this.setDefaultCompilationDirectory(properties.getProperty("DefaultCompilationDirectory"));
            
            // We force to use classic expressions
            properties.put("usingMultiLineExpressions", "false");
            
            CompatibilitySupport.version = Integer.parseInt( properties.getProperty("Compatibility") );
            
        } catch (SAXException e) {
            System.err.println(e);
        } catch (java.io.IOException e) {
            System.err.println(e);
        }
    }
    
    /**
     *  Set the current directory.
     *  If save = true, the config file is updates...
     */
    public File setCurrentDirectory( File f, boolean save) {
        String currentDirectory = "";
        if( f == null ) return f;
        
        try {
            if( f.isDirectory() ) {
                currentDirectory = f.getAbsolutePath();
            } else {
                currentDirectory = f.getParentFile().getAbsolutePath();
            }
            
            if (save) {
                getProperties().put("CurrentDirectory", currentDirectory);
                this.saveiReportConfiguration();
            }
        } catch (Exception ex) {
            
        }
        return f;
    }
    
    private void traverse(Node node) {
        //System.out.println("traverse");
        if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("iReportProperties")) {
            //System.out.println("iReportProperties");
            // Get childs....
            NodeList children = node.getChildNodes();
            if (children != null) {
                for (int k=0; k< children.getLength(); k++) {
                    Node nodeChild = (Node)children.item(k);
                    if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("iReportProperty")) {
                        
                        // Take the CDATA...
                        String paramName = "";
                        NamedNodeMap nnm = nodeChild.getAttributes();
                        if ( nnm.getNamedItem("name") != null) paramName = nnm.getNamedItem("name").getNodeValue();
                        //System.out.println("     iReportProperty "+nnm.getNamedItem("name").getNodeValue());
                        properties.put(paramName,  readPCDATA(nodeChild) );
                        
                    }
                    else if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("iReportConnection")) {
                        // Take the CDATA...
                        String connectionName = "";
                        String connectionClass = "";
                        HashMap hm = new HashMap();
                        NamedNodeMap nnm = nodeChild.getAttributes();
                        if ( nnm.getNamedItem("name") != null) connectionName = nnm.getNamedItem("name").getNodeValue();
                        if ( nnm.getNamedItem("connectionClass") != null) connectionClass = nnm.getNamedItem("connectionClass").getNodeValue();
                        
                        // Get all connections parameters...
                        NodeList list_child = nodeChild.getChildNodes();
                        for (int ck=0; ck< list_child.getLength(); ck++) {
                            String parameterName = "";
                            Node child_child = (Node)list_child.item(ck);
                            if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("connectionParameter")) {
                                
                                NamedNodeMap nnm2 = child_child.getAttributes();
                                if ( nnm2.getNamedItem("name") != null)
                                    parameterName = nnm2.getNamedItem("name").getNodeValue();
                                hm.put( parameterName,readPCDATA(child_child));
                            }
                        }
                        try {
                            IReportConnection con = (IReportConnection) Class.forName(connectionClass).newInstance();
                            con.loadProperties(hm);
                            con.setName(connectionName);
                            connections.addElement( con );
                        } catch (Exception ex) {
                            try {
                                logOnConsole("Error loading " +connectionName+"\n"+ex.getMessage()+"\n");
                                
                            } catch (Exception exsx)
                            {}
                        }
                    }
                }
            }
        }
    }
    /** Getter for property connections.
     * @return Value of property connections.
     *
     */
    public java.util.Vector getConnections() {
        return connections;
    }
    
    /** Setter for property connections.
     * @param connections New value of property connections.
     *
     */
    public void setConnections(java.util.Vector connections) {
        this.connections = connections;
    }
    
    /** Getter for property properties.
     * @return Value of property properties.
     *
     */
    public String getI18nString(String s) {
        return it.businesslogic.ireport.util.I18n.getString(s, it.businesslogic.ireport.util.I18n.getCurrentLocale());
    }
    
    /** Getter for property properties.
     * @return Value of property properties.
     *
     */
    public Properties getProperties() {
        return properties;
    }
    
    /** Setter for property properties.
     * @param properties New value of property properties.
     *
     */
    public void setProperties(Properties properties) {
        this.properties = properties;
    }
    
    private String readPCDATA(Node textNode) {
        NodeList list_child = textNode.getChildNodes();
        for (int ck=0; ck< list_child.getLength(); ck++) {
            Node child_child = (Node)list_child.item(ck);
            if (child_child.getNodeType() == Node.CDATA_SECTION_NODE ||
            child_child.getNodeType() == Node.TEXT_NODE) {
                return (String)child_child.getNodeValue();
            }
        }
        return "";
    }
    
    public boolean saveiReportConfiguration() {
        // Get the path of this class...
        // this.getClass().getResource("MainFrame");
        File dir = new File(IREPORT_USER_HOME_DIR);
        try {
            if (dir.exists()) {
                if (!dir.isDirectory() ) {
                    javax.swing.JOptionPane.showMessageDialog( this, dir.getPath() +" is not a directory!\nPlease rename this file and retry to save config!","",JOptionPane.ERROR_MESSAGE);
                    return false;
                }
            }
            else {
                dir.mkdirs();
            }
        } catch (Exception ex) {
            javax.swing.JOptionPane.showMessageDialog( this, "An error is occurred saving iReport config:\n"+ex.getMessage()+"\nPlease try to save config again!","",JOptionPane.ERROR_MESSAGE);
            return false;
        }
        
        return saveiReportConfiguration( IREPORT_CONFIG_FILE );
    }
    public boolean saveiReportConfiguration(String xmlFile) {
        try {
            //PrintWriter pw = new PrintWriter( new FileWriter(xmlFile) );
            
            PrintWriter pw = new PrintWriter( new OutputStreamWriter(new
                        FileOutputStream(xmlFile),"UTF-8"));

            // Find iReport configuration in the home directory...
            // 1. Save all properties using am XML style...
            
            if (getConnections().size() > 0 && properties.get("DefaultConnection") == null)
            {
            	IReportConnection irc = (IReportConnection)getConnections().elementAt(0);
            	properties.put("DefaultConnection", irc);
            }
            
            pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            pw.println("<!-- iReport 2 Configuration file - " + new Date() + " -->");
            pw.println("<!DOCTYPE iReportProperties PUBLIC \"-//iReport/DTD iReport Configuration//EN\" \"http://ireport.sourceforge.net/dtds/iReportProperties.dtd\">");
            pw.println("<iReportProperties>");
            
            Enumeration e = this.getProperties().keys();
            while (e.hasMoreElements()) {
                String key = (String)e.nextElement();
                pw.println("\t<iReportProperty name=\""+ key +"\"><![CDATA["+ this.getProperties().get(key) +"]]></iReportProperty>");
            }
            
            e = this.getConnections().elements();
            while (e.hasMoreElements()) {
                IReportConnection con = (IReportConnection)e.nextElement();
                con.save(pw);
            }
            
            pw.println("</iReportProperties>");
            pw.close();
        } catch (Exception ex) {
            //ex.printStackTrace(s
            try {
                logOnConsole("Error saving iReport Configuration file: "+xmlFile+"\n"+ex.getMessage()+"\n");
                
            } catch (Exception exsx)
            {}
            return false;
        }
        try {
            logOnConsole("iReport configuration file "+ xmlFile + " successfully updated!\n");
        } catch (Exception ex)
        { }
        return true;
    }
    
    
    
    public boolean saveFileList( Vector v, String xmlFile) {
        // Get the path of this class...
        // this.getClass().getResource("MainFrame");
        
        File dir = new File( IREPORT_USER_HOME_DIR );
        try {
            if (dir.exists()) {
                if (!dir.isDirectory() ) {
                    javax.swing.JOptionPane.showMessageDialog( this, dir.getPath() +" is not a directory!\nPlease rename this file and retry to save config!","",JOptionPane.ERROR_MESSAGE);
                    return false;
                }
            }
            else {
                dir.mkdirs();
            }
        } catch (Exception ex) {
            javax.swing.JOptionPane.showMessageDialog( this, "An error is occurred saving iReport config:\n"+ex.getMessage()+"\nPlease try to save config again!","",JOptionPane.ERROR_MESSAGE);
            return false;
        }
        
        //xmlFile = dir.getPath()+ File.separatorChar + xmlFile;
        
        try {
            PrintWriter pw = new PrintWriter( new FileWriter(xmlFile) );
            // Find iReport configuration in the home directory...
            // 1. Save all properties using am XML style...
            pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            pw.println("<!-- iReport 2 file list - " + new Date() + " -->");
            pw.println("<!DOCTYPE iReportFilesList PUBLIC \"-//iReport/DTD iReport Configuration//EN\" \"http://ireport.sourceforge.net/dtds/iReportFilesList.dtd\">");
            pw.println("<iReportFilesList>");
            
            Enumeration e = v.elements();
            int i=0;
            int max_files = 10;
            try {
                max_files = Integer.parseInt(getProperties().getProperty("RecentFilesLength"));
            } catch (Exception ex) {
                getProperties().setProperty("RecentFilesLength","10");
            }
            
            while (i < max_files && e.hasMoreElements()) {
                String file = (String)e.nextElement();
                pw.println("\t<iReportFile><![CDATA["+ file +"]]></iReportFile>");
                i++;
            }
            pw.println("</iReportFilesList>");
            pw.close();
        } catch (Exception ex) {
            //ex.printStackTrace(s
            try {
                logOnConsole("Error saving iReport file: "+xmlFile+"\n"+ex.getMessage()+"\n");
                
            } catch (Exception exsx)
            {}
            return false;
        }
        try {
            logOnConsole("iReport file "+ xmlFile + " successfully updated!\n");
        } catch (Exception ex)
        { }
        return true;
    }
    
    
    
    public void logOnConsole(String noHTML) {
        logOnConsole(noHTML,false);
    }
    public void logOnConsole(String s, boolean isHTML) {
        try {
            
            //String text = Misc.string_replace("","</body></html>",this.jEditorPaneOutput.getText());
            
            //s =  + s+"</body></html>";
            if ( this.jEditorPaneOutput == null) {
                outputBuffer.append(s);
                //System.out.println(outputBuffer);
            }
            else {
                this.jEditorPaneOutput.setContentType("text/html");
                if (!isHTML) {
                    s = Misc.string_replace("&gt;",">",s);
                    s = Misc.string_replace("&lt;","<",s);
                    s = Misc.string_replace("&nbsp;"," ",s);
                    s = Misc.string_replace("&nbsp;&nbsp;&nbsp;&nbsp;","\t",s);
                    s = Misc.string_replace("<br>", "\n", s);
                }
                outputBuffer.append(s);
                this.jEditorPaneOutput.setText("<html><body><table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td nowrap><font face=\"Courier New\" size=\"3\">" + outputBuffer + "</font></td></tr></table></body></html>");
            }
            //this.jEditorPaneOutput.getDocument().insertString(this.jEditorPaneOutput.getDocument().getLength(), s ,  null);
            
        } catch (Exception exsx) {
            JOptionPane.showMessageDialog(this,""+exsx.getMessage());
        }
    }
    
    /** Getter for property ttfFonts.
     * @return Value of property ttfFonts.
     *
     */
    public java.util.Vector getTtfFonts() {
        return ttfFonts;
    }
    
    /** Setter for property ttfFonts.
     * @param ttfFonts New value of property ttfFonts.
     *
     */
    public void setTtfFonts(java.util.Vector ttfFonts) {
        this.ttfFonts = ttfFonts;
    }
    
    /** This method parse an error encoded using an url.
     *  The url must be in the form:
     *  http://{error|warinig}:{JReportFrame ID}/{expression}
     *
     *  error: referred to an expression field
     *  warning: referred to an element position warning
     *
     *  Possible expressions for error:
     *  variableInitialValue_<VARIABLE_NAME>
     *  textField_<TEXTFIELD NUMBER>
     *  printWhen_<PRINT WHEN EXPRESSION NUMBER>(*)
     *  parameterDefaultValue_<PARAMETER NAME>
     *  parameter_<PARAMETER NAME>
     *
     *  Possible expressions for warning:
     *  y=<Y>,height=<Height>,band-height=<Band-Height>
     *
     *  (*) The printWhen expression are considered only if not blank.
     *  The search order is this: bands, elements
     */
    public boolean  parseError(java.net.URL url) {
        if (url == null) return false;
        
        // First of all activate the right frame...
        JInternalFrame[] frames = jMDIDesktopPane.getAllFrames();
        JReportFrame jrf = null;
        for (int k=0; k< frames.length; k++) {
            if (frames[k] instanceof JReportFrame) {
                if ( ((JReportFrame)frames[k]).getWindowID() == url.getPort()) {
                    jrf = (JReportFrame)frames[k];
                    if ( !frames[k].isSelected() ) {
                        try {
                            frames[k].setSelected(true);
                        } catch (Exception ex)
                        {}
                    }
                }
            }
        }
        if (jrf == null) return false;
        
        try {
            if (url.getHost().equalsIgnoreCase("error")) {
                String expression = url.getFile();
                
                if (expression!=null && expression.length() > 0) {
                    // parse expression...
                    if (expression.startsWith("/textField_")) {
                        int index = 0;
                        int number = Integer.parseInt( expression.substring(("/textField_").length()).trim());
                        Enumeration e = jrf.getReport().getElements().elements();
                        while (e.hasMoreElements()) {
                            ReportElement re = (ReportElement)e.nextElement();
                            if (re instanceof TextFieldReportElement) {
                                index++;
                                if (index == number) {
                                    jrf.setSelectedElement(re);
                                    this.getElementPropertiesDialog().setVisible(true);
                                    this.getElementPropertiesDialog().gotoTab( this.getElementPropertiesDialog().TEXTFIELD_TAB );
                                    return true;
                                }
                            }
                        }
                    }
                    else if (expression.startsWith("/parameterDefaultValue_")) {
                        int index = 0;
                        String name = expression.substring(("/parameterDefaultValue_").length()).trim();
                        Enumeration e = jrf.getReport().getParameters().elements();
                        while (e.hasMoreElements()) {
                            it.businesslogic.ireport.JRParameter param = (it.businesslogic.ireport.JRParameter)e.nextElement();
                            if (param.getName().equals(name)) {
                                this.getValuesDialog().setVisible(true);
                                this.getValuesDialog().modifyErrorParameter(param );
                                return true;
                            }
                        }
                        
                    }
                }
            }
            else if (url.getHost().equals("warning")) {
            }
        } catch (Exception ex)
        {}
        return false;
    }
    
    public void reportBandChanged(ReportBandChangedEvent evt) {
        fireReportListenerReportBandChanged( evt );
        this.updateDocumentStructureTree( evt.getJReportFrame());
    }
    
    public void reportElementsChanged(ReportElementChangedEvent evt) {
        
        fireReportListenerReportElementsChanged( evt );
        if (evt.getType() == ReportElementChangedEvent.CHANGED) {
            for (int ir=0; ir<evt.getElements().size(); ++ir)
            {
                ReportElement re = (ReportElement)evt.getElements().elementAt(ir);
                DefaultMutableTreeNode node = findElementTreeNode(re, true);
                if (node == null) {
                    // This node has changed your band....
                    // Find the node based on objects availables....
                    node = findElementTreeNode(re, false);
                    if (node == null) return; // This should not happen....
                    // Remove from your parent....
                    node.removeFromParent();
                    // Add to the new parent...
                    DefaultMutableTreeNode root = (DefaultMutableTreeNode)jTreeDocument.getModel().getRoot();
                    for (int i=0; i<root.getChildCount(); ++i) {
                        DefaultMutableTreeNode bandNode = (DefaultMutableTreeNode)root.getChildAt(i);
                        if (bandNode.getUserObject() == re.band) {
                            bandNode.add( node );
                            this.setDontHandleEvent(true);
                            if (evt.getJReportFrame().getSelectedElements().contains( re )) {
                                jTreeDocument.getSelectionModel().addSelectionPath(new TreePath(new Object[]
                                {root, bandNode,node}));
                            }
                            this.setDontHandleEvent(false);
                            break;
                        }
                    }
                }
            }
            jTreeDocument.updateUI();
        }
        else if (evt.getType() == ReportElementChangedEvent.REMOVED) {
            for (int i=0; i<evt.getElements().size(); ++i)
            {
                ReportElement re = (ReportElement)evt.getElements().elementAt(i);
                // find this element....
                DefaultMutableTreeNode node = findElementTreeNode(re,true);
                if (node != null) {
                    node.removeFromParent();

                }
            }
            jTreeDocument.updateUI();
        }
        else if (evt.getType() == ReportElementChangedEvent.ADDED) {
            for (int ir=0; ir<evt.getElements().size(); ++ir)
            {
                ReportElement re = (ReportElement)evt.getElements().elementAt(ir);
                // add it to your band...
                DefaultMutableTreeNode node = new DefaultMutableTreeNode(re);
                // Find the band node...
                DefaultMutableTreeNode root = (DefaultMutableTreeNode)jTreeDocument.getModel().getRoot();
                for (int i=0; i<root.getChildCount(); ++i) {
                    DefaultMutableTreeNode bandNode = (DefaultMutableTreeNode)root.getChildAt(i);
                    if (bandNode.getUserObject() == re.band) {
                        bandNode.add( node );

                        break;
                    }
                }
            }
            jTreeDocument.updateUI();
        }
        //we need to set the report to show it has been modified.
        Report mod = evt.getJReportFrame().getReport();
        mod.setModified(true);
        this.enableSaveSpecific();
        this.enableSaveAllSpecific();
        
    }//end reportElementsChanged
    
    /**
     *Used to enable anything strictly save related.  Not save all.
     */
    public void enableSaveSpecific() {
        //TODO add events to update gui when changes occur in expressions.
        //this had to be commented out until that day arrives.
        //brainjava will be working on this
       /*
       this.jButtonSave.setEnabled(true);
       this.jMenuItemSave.setEnabled(true);
        **/
    }
    
    /**
     *Used to disable anything Save.  Not save all.
     */
    public void disableSaveSpecific() {
        
        //TODO add more events so code can be comented back in
        //this had to be removed until events can be added to
        //the expression updates so the gui will know changes have
        //occurred
       /*
       this.jButtonSave.setEnabled(false);
       this.jMenuItemSave.setEnabled(false);
        **/
    }//end disableSaveSpecific
    
    /**
     *Used to enable anything strictly save all related.  Not save.
     */
    public void enableSaveAllSpecific() {
        this.jMenuItemSaveAll.setEnabled(true);
    }//end enableSaveAllSpecific
    
    /**
     *Used to disable anything Save.  Not save all.
     */
    public void disableSaveAllSpecific() {
        this.jMenuItemSaveAll.setEnabled(false);
    }//end disableSaveAllSpecific
    
    /**
     *     If searchInYourBandOnly == true
     *     This method Look for the userObject re in elements contained in the same band
     *     of the element. This method MUST CHECK that the report IS in the band
     *     assigned. If not it must return null. The reason is that if the element
     *     is not found in your band, it has changed the band attribute and must be updated.
     */
    public DefaultMutableTreeNode findElementTreeNode( ReportElement re, boolean searchInYourBandOnly) {
        // looking for it in the tree...
        //1. Search the band...
        DefaultMutableTreeNode root = (DefaultMutableTreeNode)jTreeDocument.getModel().getRoot();
        for (int i=0; i<root.getChildCount(); ++i) {
            DefaultMutableTreeNode bandNode = (DefaultMutableTreeNode)root.getChildAt(i);
            if (!searchInYourBandOnly || bandNode.getUserObject() == re.band) {
                for (int k=0; k<bandNode.getChildCount(); ++k) {
                    DefaultMutableTreeNode child = (DefaultMutableTreeNode)bandNode.getChildAt(k);
                    if (child.getUserObject() == re) {
                        return child;
                    }
                }
            }
        }
        return null;
    }
    
    
    /**     This method is called when a new element is selected,
     *     or deselected.
     *
     */
    public void reportElementsSelectionChanged(ReportElementsSelectionEvent evt) {
        setDontHandleEvent(true);
        fireReportListenerReportElementsSelectionChanged( evt );
        TreePath[] path = jTreeDocument.getSelectionPaths();
        if (path != null && evt.getSelectedElements() != null && evt.getSelectedElements().size() == 0 && path.length == 1 &&
        ((DefaultMutableTreeNode) path[0].getLastPathComponent()).getUserObject() instanceof Band) {
            setDontHandleEvent(false);
            return;
        }
        
        jTreeDocument.getSelectionModel().clearSelection();
        setDontHandleEvent(false);
        Vector v = evt.getSelectedElements();
        Enumeration e = v.elements();
        while (e.hasMoreElements()) {
            ReportElement re = (ReportElement)e.nextElement();
            // looking for it in the tree...
            //1. Search the band...
            DefaultMutableTreeNode root = (DefaultMutableTreeNode)jTreeDocument.getModel().getRoot();
            for (int i=0; i<root.getChildCount(); ++i) {
                DefaultMutableTreeNode bandNode = (DefaultMutableTreeNode)root.getChildAt(i);
                if (bandNode.getUserObject() == re.band) {
                    for (int k=0; k<bandNode.getChildCount(); ++k) {
                        DefaultMutableTreeNode child = (DefaultMutableTreeNode)bandNode.getChildAt(k);
                        if (child.getUserObject() == re) {
                            setDontHandleEvent(true);
                            jTreeDocument.getSelectionModel().addSelectionPath(new TreePath(new Object[]
                            {root, bandNode,child}));
                            setDontHandleEvent(false);
                        }
                    }
                }
            }
            
        }
        
        
    }
    
    /** Getter for property dontHandleEvent.
     * @return Value of property dontHandleEvent.
     *
     */
    public boolean isDontHandleEvent() {
        return dontHandleEvent;
    }
    
    /** Setter for property dontHandleEvent.
     * @param dontHandleEvent New value of property dontHandleEvent.
     *
     */
    public void setDontHandleEvent(boolean dontHandleEvent) {
        this.dontHandleEvent = dontHandleEvent;
    }
    
    /** Getter for property jTreeDocument.
     * @return Value of property jTreeDocument.
     *
     */
    public javax.swing.JTree getJTreeDocument() {
        return jTreeDocument;
    }
    
    /** Setter for property jTreeDocument.
     * @param jTreeDocument New value of property jTreeDocument.
     *
     */
    public void setJTreeDocument(javax.swing.JTree jTreeDocument) {
        this.jTreeDocument = jTreeDocument;
    }
    
    /** Getter for property recentFilesList.
     * @return Value of property recentFilesList.
     *
     */
    public java.util.Vector getRecentFilesList() {
        return recentFilesList;
    }
    
    /** Setter for property recentFilesList.
     * @param recentFilesList New value of property recentFilesList.
     *
     */
    public void setRecentFilesList(java.util.Vector recentFilesList) {
        this.recentFilesList = recentFilesList;
    }
    
    /** Getter for property recentProjectsList.
     * @return Value of property recentProjectsList.
     *
     */
    public java.util.Vector getRecentProjectsList() {
        return recentProjectsList;
    }
    
    /** Setter for property recentProjectsList.
     * @param recentProjectsList New value of property recentProjectsList.
     *
     */
    public void setRecentProjectsList(java.util.Vector recentProjectsList) {
        this.recentProjectsList = recentProjectsList;
    }
    
    /** Getter for property favoriteFilesList.
     * @return Value of property favoriteFilesList.
     *
     */
    public java.util.Vector getFavoriteFilesList() {
        return favoriteFilesList;
    }
    
    /** Setter for property favoriteFilesList.
     * @param favoriteFilesList New value of property favoriteFilesList.
     *
     */
    public void setFavoriteFilesList(java.util.Vector favoriteFilesList) {
        this.favoriteFilesList = favoriteFilesList;
    }
    
    private void jMenuItemRecentFileActionPerformed(java.awt.event.ActionEvent evt ) {
        if (evt.getSource() instanceof JMenuItem) {
            JMenuItem menu = (JMenuItem)evt.getSource();
            
            // Is a recent file?!
            for (int i=0; i< jMenuRecentFiles.getMenuComponentCount(); ++ i) {
                if (jMenuRecentFiles.getMenuComponent(i) ==  menu) {
                    
                    // If not already Opened, open entry # i
                    JReportFrame frameReport = openFile( (String)recentFilesList.elementAt(i));
                    if(frameReport != null){
                        
                        Report report = frameReport.getReport();
                        
                        if( report.isModified() ) {
                            this.enableSaveSpecific();
                            this.enableSaveAllSpecific();
                        }
                        else {
                            this.disableSaveSpecific();
                            if( this.isSaveAllRequired() ) {
                                this.enableSaveAllSpecific();
                            }
                            else {
                                this.disableSaveAllSpecific();
                            }
                        }
                        break;
                    }
                }
            }
        }
    }
    
    public void updateRecentFileMenu(JMenu menu, Vector v) {
        menu.removeAll();
        Enumeration e = v.elements();
        int i=1;
        
        int k=0;
        int max_files = 10;
        try {
            max_files = Integer.parseInt(getProperties().getProperty("RecentFilesLength"));
        } catch (Exception ex) {
            getProperties().setProperty("RecentFilesLength","10");
        }
        
        while (k < max_files && e.hasMoreElements()) {
            
            JMenuItem subMenu = new JMenuItem( i+". "+Misc.getShortFileName((String)e.nextElement()));
            subMenu.setFont(new java.awt.Font("Dialog", 0, 11));
            subMenu.addActionListener( new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jMenuItemRecentFileActionPerformed(evt);
                }
                
            });
            menu.add(subMenu);
            i++;
            k++;
        }
    }
    
    public void updateRecentProjectMenu(JMenu menu, Vector v) {
    }
    public void updateUndoMenu(JReportFrame jrf) {
        
        if (jrf == null) {
            this.jMenuItemUndo.setEnabled(false);
            this.jMenuItemRedo.setEnabled(false);
            return;
        }
        if (jrf.getUndoOperation() != null) {
            this.jMenuItemUndo.setEnabled(true);
            this.jMenuItemUndo.setText("Undo " + jrf.getUndoOperation());
        }
        else {
            this.jMenuItemUndo.setEnabled(false);
            this.jMenuItemUndo.setText("Undo");
        }
        
        if (jrf.getRedoOperation() != null) {
            this.jMenuItemRedo.setEnabled(true);
            this.jMenuItemRedo.setText("Redo " + jrf.getRedoOperation());
        }
        else {
            this.jMenuItemRedo.setEnabled(false);
            this.jMenuItemRedo.setText("Redo");
        }
    }
    
    public void updateCutAndPasteMenu(JReportFrame jrf) {
        
        if (jrf == null) {
            setCutCopyEnabled(false);
            setPasteEnebled(false);
            return;
        }
        if (jrf.getSelectedElements().size() > 0) {
            setCutCopyEnabled(true);
            if (getClipBoard().size()>0)
                setPasteEnebled(true);
        }
        else {
            setCutCopyEnabled(false);
            if (getClipBoard().size()>0)
                setPasteEnebled(true);
        }
    }
    
    
    public void undo() {
        jMenuItemUndoActionPerformed(new java.awt.event.ActionEvent(jMenuItemUndo,0,""));
    }
    
    public void redo() {
        jMenuItemRedoActionPerformed(new java.awt.event.ActionEvent(jMenuItemUndo,0,""));
        
    }
    
    /**
     *     Update the jTreeDocumen (the tree with the opened files)
     */
    public void updateOpenedDocumentsList() {
        
        try {
        jTreeFiles.updateUI();
        } catch (Exception ex1) { 
            System.out.println( "* 1 * : "  + ex1 );
            ex1.printStackTrace ();
        }
    }
    
    /** Getter for property activeClipboard.
     * @return Value of property activeClipboard.
     *
     */
    public int getActiveClipboard() {
        return activeClipboard;
    }
    
    /** Setter for property activeClipboard.
     * @param activeClipboard New value of property activeClipboard.
     *
     */
    public void setActiveClipboard(int activeClipboard) {
        this.activeClipboard = activeClipboard;
    }
    
    public Vector getClipBoard() {
        return clipboards[getActiveClipboard()];
    }
    
    public void setClipBoardContent(Vector elements) {
        clipboards[getActiveClipboard()] = elements;
        
    }
    
    /** Getter for property homeDirectory.
     * @return Value of property homeDirectory.
     *
     */
    public java.lang.String getHomeDirectory() {
        return homeDirectory;
    }
    
    /** Setter for property homeDirectory.
     * @param homeDirectory New value of property homeDirectory.
     *
     */
    public void setHomeDirectory(java.lang.String homeDirectory) {
        this.homeDirectory = homeDirectory;
    }
    
    public String getCurrentDirectory() {
        return "" + Misc.nvl( getProperties().getProperty("CurrentDirectory"), ".");
    }
    
    public void run() {
        this.checkForModifiedFiles();
    }
    
    
    public void saveBackup(String filename) {
        java.io.File f = new java.io.File(filename);
        if ( f.exists()) {
            String path = f.getParent();
            String file = f.getName();
            
            if (getProperties().getProperty("DefaultBackupDirectory") != null &&
            (""+getProperties().getProperty("DefaultBackupDirectory")).length()>0)
                path = getProperties().getProperty("DefaultBackupDirectory");
            
            if (getProperties().getProperty("BackupPolicy") != null &&
            (""+getProperties().getProperty("BackupPolicy")).equalsIgnoreCase("1")) {
                return;
            } else if (getProperties().getProperty("BackupPolicy") != null &&
            (""+getProperties().getProperty("BackupPolicy")).equalsIgnoreCase("2")) {
                file = Misc.changeFileExtension(file, "bak");
            } else {
                file += ".bak";
            }
            try {
                //String back_path = getProperties().getProperty( "
                File f2 = new java.io.File( path, file); // + ((path.endsWith(java.io.File.separatorChar+"")) ? "" : ""+java.io.File.separatorChar) + file);
                if (f2.exists()) {
                    if (!f2.delete()) {
                        logOnConsole("Can not delete " + f2+"<br>",true);
                    }
                }
                
                f.renameTo( f2 );
                logOnConsole("Renamed " + f + " to " +  f2+"<br>",true);
                //com.ms.wfc.io.File.copyOver( filename, com.ms.wfc.io.File.combine(path,file));
            } catch (Exception ex) {
                javax.swing.JOptionPane.showMessageDialog(this, "An exception is occurred saving backup copy.\n"+ex.getMessage(),"",javax.swing.JOptionPane.ERROR_MESSAGE);
            }
        }
    }
    
    /* Thanks to James Fu */
    private void setElementValue(Object element, String method, String value) {
       setElementValue(element, method, value, String.class);
    }
    /* Thanks to James Fu */
    public void setElementsValue(String method,String value ) {
        setElementsValue( method, value, String.class);
    }
    
    
    private void setElementValue(Object element, String method, Object value, Class clazz) {
        try {
            java.lang.reflect.Method setMethod = element.getClass().getMethod(method, new Class[]
            {clazz});
            setMethod.invoke(element, new Object[]
            {value});
        }
        catch (Exception e) {
        //    e.printStackTrace();
        }
    }
    
    
    /* Thanks to James Fu */
    public void setElementsValue(String method, Object value, Class clazz ) {
        JReportFrame jrf = (JReportFrame)jMDIDesktopPane.getSelectedFrame();
        if (jrf == null) return;
        // Set the new value for all selected elements...
        Enumeration e = jrf.getSelectedElements().elements();
        while (e.hasMoreElements()) {
            ReportElement repele = (ReportElement)e.nextElement();
            if (repele instanceof TextReportElement)
            {
                TextReportElement element = (TextReportElement)repele;
                setElementValue(element, method, value, clazz);
            }
        }
        
        jrf.getJPanelReport().repaint();
    }
    
    //TODO         */
    ////////////////////////////////////////
    /*
     *
    The methods below which are being used for pref settings need to be moved
    to another location.  This is just a quick fix sort of thing.
       wade
     */
    ///////////////////////////////////////
    
    /**
     *Used to set the application preference/option/property UseMultiLineExpressions
     *@pram useMultiLineExpressions whether to use or not to use them.
     */
    public void setUsingMultiLineExpressions(boolean useMultiLineExpressions) {
        
        String boolVal = ""+false; //""+useMultiLineExpressions;
        
        this.properties.setProperty("usingMultiLineExpressions", boolVal);
    }//end setUseMultiLineExpressions
    
    /**
     *Used to tell whether or not to be using multi line expressions.
     *@return whether multiline expressions are being used or not.
     */
    public boolean isUsingMultiLineExpressions() {
        boolean ret = false;
                /*
                String prop = this.properties.getProperty("usingMultiLineExpressions");
                if(prop != null) {
                        ret = prop.trim().equalsIgnoreCase("true");
                }
                else {
                        ret = false;
                }
                 */
        return ret;
    }//end isUsingMultiLineExpressions
    
    /**
     *Method used to tell compiler to use the directory the file being compiled in
     *for the compile directory.  This is for simplicity of development.
     *@param useCurrentFilesDirectoryForCompiles speaks for itself
     */
    public void setUsingCurrentFilesDirectoryForCompiles(boolean usingCurrentFilesDirectoryForCompiles) {
        this.properties.setProperty("useCurrentFilesDirectoryForCompiles", ""+usingCurrentFilesDirectoryForCompiles);
    }
    
    /**
     *Used to tell if the compiler should use the current files directory for the compile.
     *@return whether or not to use the current files directory for the compile.
     */
    public boolean isUsingCurrentFilesDirectoryForCompiles() {
        boolean ret = false;
        ret = this.properties.getProperty("useCurrentFilesDirectoryForCompiles", "false").trim().equalsIgnoreCase("true");
        return ret;
    }
    
    /**
     *Used to set the default compilation directory
     *@param defaultCompilationDirectory
     */
    public void setDefaultCompilationDirectory(String defaultCompilationDirectory) {
        IREPORT_TMP_DIR = defaultCompilationDirectory;
    }
    
    /**
     *Method used to get the default compilation directory
     *@return the default compilation directory for ireport
     */
    public String getDefaultCompilationDirectory() {
        
        if (IREPORT_TMP_DIR != null) return IREPORT_TMP_DIR;
        return IREPORT_HOME_DIR;
                /*
                String ret = this.properties.getProperty("ireport.temp", IREPORT_TMP_DIR);
                if( ret.trim().length() > 0 ) {
                 
                }
                else {
                        ret = IREPORT_TMP_DIR;
                }
                return ret;
                 */
        
    }
    
    /**
     *Method used to translate properties that dictate where the compilation directory
     *should be so that the correct directory can be obtained and used.
     *@return the compilation directory to use for the reports.
     */
    public String getTranslatedCompileDirectory() {
        String ret = null;
        if( this.isUsingCurrentFilesDirectoryForCompiles() ) {
            javax.swing.JInternalFrame f = this.jMDIDesktopPane.getSelectedFrame();
            if( f != null && f instanceof JReportFrame ) {
                JReportFrame rf = (JReportFrame)f;
                String fileName = rf.getReport().getFilename();
                if( fileName != null ) {
                    java.io.File rfile = new java.io.File(fileName);
                    ret = rfile.getParent();
                }
                else {
                    ret = this.getDefaultCompilationDirectory();
                }
                
            }
            else {
                ret = this.getDefaultCompilationDirectory();
            }
        }
        else {
            ret = this.getDefaultCompilationDirectory();
        }
        return ret;
    }
    
    /**
     *Used to hold the viewer setting.
     *@param reportViewer the viewer to use
     */
    public void setReportViewer(int reportViewer) {
        switch( reportViewer ) {
            case IREPORT_JAVA_VIEWER:
                this.jRadioButtonMenuItemPreviewJAVA.setSelected(true);
                break;
            case IREPORT_PDF_VIEWER:
                this.jRadioButtonMenuItemPreviewPDF.setSelected(true);
                break;
            case IREPORT_HTML_VIEWER:
                this.jRadioButtonMenuItemPreviewHTML.setSelected(true);
                break;
            case IREPORT_XLS_VIEWER:
                this.jRadioButtonMenuItemPreviewXLS.setSelected(true);
                break;
            case IREPORT_CSV_VIEWER:
                this.jRadioButtonMenuItemPreviewCSV.setSelected(true);
                break;
            case IREPORT_TXT_VIEWER:
                this.jRadioButtonMenuItemPreviewTXT.setSelected(true);
                break;
            case IREPORT_JASPER_VIEWER:
            default:
                reportViewer = IREPORT_JASPER_VIEWER;
                this.jRadioButtonMenuItemPreviewInternalViewer.setSelected(true);
                break;
        }//end switch report viewer
        this.properties.setProperty("DefaultReportViewer", ""+reportViewer);
        
    }//end setReportViewer
    
    /**
     *Used to get which viewer is in use
     *@returns the in representing the viewer in use.
     */
    public int getReportViewer() {
        int ret = IREPORT_JASPER_VIEWER;
        try {
            ret = Integer.parseInt(this.properties.getProperty("DefaultReportViewer", ""+IREPORT_JASPER_VIEWER));
        }
        catch(Throwable e) {
            //hmm, don't guess we care...we'll correct it internally.
        }
        switch( ret ) {
            case IREPORT_JAVA_VIEWER:
                break;
            case IREPORT_PDF_VIEWER:
                break;
            case IREPORT_HTML_VIEWER:
                break;
            case IREPORT_XLS_VIEWER:
                break;
            case IREPORT_CSV_VIEWER:
                break;
            case IREPORT_TXT_VIEWER:
                break;
            case IREPORT_JASPER_VIEWER:
            default:
                ret = IREPORT_JASPER_VIEWER;
                break;
        }//end switch report viewer
        return ret;
    }//end getReportViewer
    public void setEmbeddedIreport(boolean status) {
        this.embeddedIreport = status;
    }//end setEmbeddedIreport
    public boolean isEmbedded() {
        return this.embeddedIreport;
    }//end isEmbedded
    public void applyI18n(){
        jMenuFile.setText(it.businesslogic.ireport.util.I18n.getString("file","File"));
        jMenuItemNewDocument.setText(it.businesslogic.ireport.util.I18n.getString("newDocument","New document"));
        jMenuItemWizard.setText(it.businesslogic.ireport.util.I18n.getString("reportWizard","Report Wizard"));
        jMenuItemOpen.setText(it.businesslogic.ireport.util.I18n.getString("open","Open"));
        jMenuItemQOpen.setText(it.businesslogic.ireport.util.I18n.getString("quickOpen","Quick open"));
        jMenuItemClose.setText(it.businesslogic.ireport.util.I18n.getString("close","Close"));
        jMenuItemCloseAll.setText(it.businesslogic.ireport.util.I18n.getString("closeAll","Close all"));
        jMenuItemCloseAllExceptThis.setText(it.businesslogic.ireport.util.I18n.getString("closeAllExceptThis","Close all except this"));
        jMenuItemRevertToSaved.setText(it.businesslogic.ireport.util.I18n.getString("revertToSaved","Revert to saved"));
        jMenuItemCloseFromList.setText(it.businesslogic.ireport.util.I18n.getString("close","Close"));
        jMenuItemCloseAllFromList.setText(it.businesslogic.ireport.util.I18n.getString("closeAll","Close all"));
        jMenuItemCloseAllExceptThisFromList.setText(it.businesslogic.ireport.util.I18n.getString("closeAllExceptThis","Close all except this"));
        jMenuItemRevertToSavedFromList.setText(it.businesslogic.ireport.util.I18n.getString("revertToSaved","Revert to saved"));
        jMenuItemSaveFromList.setText(it.businesslogic.ireport.util.I18n.getString("save","Save"));
        jMenuItemSaveAsFromList.setText(it.businesslogic.ireport.util.I18n.getString("saveAs","Save as..."));
        jMenuItemSaveAllFromList.setText(it.businesslogic.ireport.util.I18n.getString("saveAll","Save all"));
        jMenuItemSave.setText(it.businesslogic.ireport.util.I18n.getString("save","Save"));
        jMenuItemSaveAs.setText(it.businesslogic.ireport.util.I18n.getString("saveAs","Save as..."));
        jMenuItemSaveAll.setText(it.businesslogic.ireport.util.I18n.getString("saveAll","Save all"));
        jMenuRecentFiles.setText(it.businesslogic.ireport.util.I18n.getString("recentFiles","Recent files"));
        jMenuRecentProjects.setText(it.businesslogic.ireport.util.I18n.getString("recentProjects","Recent projects"));
        jMenuItemFavorites.setText(it.businesslogic.ireport.util.I18n.getString("favoriteFiles","Favorites files"));
        jMenuItemQuit.setText(it.businesslogic.ireport.util.I18n.getString("quit","Quit"));
        jMenuEdit.setText(it.businesslogic.ireport.util.I18n.getString("edit","Edit"));
        jMenuItemUndo.setText(it.businesslogic.ireport.util.I18n.getString("undo","Undo"));
        jMenuItemRedo.setText(it.businesslogic.ireport.util.I18n.getString("redo","Redo"));
        jMenuItemCut.setText(it.businesslogic.ireport.util.I18n.getString("cut","Cut"));
        jMenuItemDS_cut.setText(it.businesslogic.ireport.util.I18n.getString("cut","Cut"));
        jMenuItemCopy.setText(it.businesslogic.ireport.util.I18n.getString("copy","Copy"));
        jMenuItemDS_copy.setText(it.businesslogic.ireport.util.I18n.getString("copy","Copy"));
        jMenuItemPaste.setText(it.businesslogic.ireport.util.I18n.getString("paste","Paste"));
        jMenuItemDS_paste.setText(it.businesslogic.ireport.util.I18n.getString("paste","Paste"));
        jMenuItemDelete.setText(it.businesslogic.ireport.util.I18n.getString("delete","Delete"));
        jMenuItemDS_delete.setText(it.businesslogic.ireport.util.I18n.getString("delete","Delete"));
        jMenuItemMoveUp.setText(it.businesslogic.ireport.util.I18n.getString("moveUp","Move up"));
        jMenuItemMoveDown.setText(it.businesslogic.ireport.util.I18n.getString("moveDown","Move down"));
        jMenuItemDSB_properties.setText(it.businesslogic.ireport.util.I18n.getString("bandProperties","Band properties"));
        jCheckBoxMenuItemEMM.setText(it.businesslogic.ireport.util.I18n.getString("disableElementsMouseMove","Disable elements mouse move"));
        jCheckBoxMenuItemSnapToGrid.setText(it.businesslogic.ireport.util.I18n.getString("snapToGrid","Snap to grid"));
        jMenuAdd.setText(it.businesslogic.ireport.util.I18n.getString("insertElement","Insert element"));
        jMenuItemLine.setText(it.businesslogic.ireport.util.I18n.getString("line","Line"));
        jMenuItemRectangle.setText(it.businesslogic.ireport.util.I18n.getString("rectangle","Rectangle"));
        jMenuItemRoundRectangle.setText(it.businesslogic.ireport.util.I18n.getString("roundedRectangle","Rounded rectangle"));
        jMenuItemEllipse.setText(it.businesslogic.ireport.util.I18n.getString("ellipse","Ellipse"));
        jMenuItemStaticText.setText(it.businesslogic.ireport.util.I18n.getString("staticText","Static text"));
        jMenuItemTextField.setText(it.businesslogic.ireport.util.I18n.getString("textField","Textfield"));
        jMenuItemSubreport.setText(it.businesslogic.ireport.util.I18n.getString("subreport","Subreport"));
        jMenuItemXMLSource.setText(it.businesslogic.ireport.util.I18n.getString("editXmlSource","Edit XML source"));
        jMenuView.setText(it.businesslogic.ireport.util.I18n.getString("view","View"));
        jCheckBoxMenuItemGrid.setText(it.businesslogic.ireport.util.I18n.getString("showGrid","Show grid"));
        jCheckBoxMenuItemOutput.setText(it.businesslogic.ireport.util.I18n.getString("showOutputWindow","Show output window"));
        jCheckBoxMenuItemExplorer.setText(it.businesslogic.ireport.util.I18n.getString("showProjectBrowser","Show project browser"));
        jMenuItemReportProperties.setText(it.businesslogic.ireport.util.I18n.getString("reportProperties","Report properties"));
        jMenuItemProperties.setText(it.businesslogic.ireport.util.I18n.getString("customProperties","Custom properties"));
        jMenuItemDS_properties.setText(it.businesslogic.ireport.util.I18n.getString("properties","Properties"));
        jMenuItemReportQuery.setText(it.businesslogic.ireport.util.I18n.getString("reportQuery","Report query"));
        jMenuItemFields.setText(it.businesslogic.ireport.util.I18n.getString("reportFields","Report fields"));
        jMenuItemVariables.setText(it.businesslogic.ireport.util.I18n.getString("reportVariables","Report variables"));
        jMenuItemParameters.setText(it.businesslogic.ireport.util.I18n.getString("reportParameters","Report parameters"));
        jMenuItemFonts.setText(it.businesslogic.ireport.util.I18n.getString("reportFonts","Report fonts"));
        jMenuItemBands.setText(it.businesslogic.ireport.util.I18n.getString("bands","Bands"));
        jMenuItemGroups.setText(it.businesslogic.ireport.util.I18n.getString("reportGroups","Report groups"));
        jMenuItemElementProperties.setText(it.businesslogic.ireport.util.I18n.getString("elementProperties","Element properties"));
        jMenuItemElementsBrowser.setText(it.businesslogic.ireport.util.I18n.getString("elementsBrowser","Elements browser"));
        jMenuItemScriptletEditor.setText(it.businesslogic.ireport.util.I18n.getString("scriptletEditor","Scriptlet editor"));
        jMenuItemReportSeries.setText(it.businesslogic.ireport.util.I18n.getString("reportSeries","Report series"));
        jMenuItemReportImports.setText(it.businesslogic.ireport.util.I18n.getString("reportImports","Report imports"));
        jMenuSearch.setText(it.businesslogic.ireport.util.I18n.getString("search","Search"));
        jMenuItemFindNext.setText(it.businesslogic.ireport.util.I18n.getString("findNext","Find next"));
        jMenuItemFindPrev.setText(it.businesslogic.ireport.util.I18n.getString("findPrevious","Find Prev"));
        jMenuItemReplace.setText(it.businesslogic.ireport.util.I18n.getString("replace","Replace"));
        jMenuProjects.setText(it.businesslogic.ireport.util.I18n.getString("project","Project"));
        jMenuItemNewProject.setText(it.businesslogic.ireport.util.I18n.getString("newProject","New project"));
        jMenuItemOpenProject.setText(it.businesslogic.ireport.util.I18n.getString("openProject","Open project"));
        jMenuItemCloseProject.setText(it.businesslogic.ireport.util.I18n.getString("closeProject","Close project"));
        jMenuItemAddFileToProject.setText(it.businesslogic.ireport.util.I18n.getString("addReportToProject","Add report to project..."));
        jMenuItemProjectOptions.setText(it.businesslogic.ireport.util.I18n.getString("projectOptions","Project options..."));
        jMenuBuild.setText(it.businesslogic.ireport.util.I18n.getString("build","Build"));
        jMenuItemCompile.setText(it.businesslogic.ireport.util.I18n.getString("compile","Compile"));
        jMenuItemCompileAll.setText(it.businesslogic.ireport.util.I18n.getString("compileAll","Compile All"));
        jMenuItemExecute.setText(it.businesslogic.ireport.util.I18n.getString("executeReport","Execute report"));
        jMenuItemExecuteDB.setText(it.businesslogic.ireport.util.I18n.getString("executeReportUsingActiveConnection","Execute report (using active conn.) "));
        jRadioButtonMenuItemPreviewPDF.setText(it.businesslogic.ireport.util.I18n.getString("pdfPreview","PDF preview"));
        jRadioButtonMenuItemPreviewHTML.setText(it.businesslogic.ireport.util.I18n.getString("htmlPreview","HTML preview"));
        jRadioButtonMenuItemPreviewJAVA.setText(it.businesslogic.ireport.util.I18n.getString("java2DPreview","JAVA 2D preview"));
        jRadioButtonMenuItemPreviewXLS.setText(it.businesslogic.ireport.util.I18n.getString("excelPreview","Excel preview"));
        jRadioButtonMenuItemPreviewCSV.setText(it.businesslogic.ireport.util.I18n.getString("csvPreview","CSV preview"));
        jRadioButtonMenuItemPreviewTXT.setText(it.businesslogic.ireport.util.I18n.getString("textPreview","Text preview (Experimental)"));
        jRadioButtonMenuItemPreviewInternalViewer.setText(it.businesslogic.ireport.util.I18n.getString("jrViewerPreview","JRViewer preview"));
        jMenuItemActiveConnection.setText(it.businesslogic.ireport.util.I18n.getString("setActiveConnection","Set active connection"));
        updateJMenuItemReportLocaleText();
        jMenuItemActiveConnection.setToolTipText(it.businesslogic.ireport.util.I18n.getString("setTheConnection","Set the connection that must be used to fill this report"));
        jMenuFormat.setText(it.businesslogic.ireport.util.I18n.getString("format","Format"));
        jMenuAlign.setText(it.businesslogic.ireport.util.I18n.getString("align", "Align..."));
        jMenuItemAlignLeft.setText(it.businesslogic.ireport.util.I18n.getString("alignLeft", "Align left"));
        jMenuItemAlignRight.setText(it.businesslogic.ireport.util.I18n.getString("alignRight", "Align right"));
        jMenuItemAlignTop.setText(it.businesslogic.ireport.util.I18n.getString("alignTop", "Align top"));
        jMenuItemAlignBottom.setText(it.businesslogic.ireport.util.I18n.getString("alignBottom", "Align bottom"));
        jMenuItemAlignVerticalAxis.setText(it.businesslogic.ireport.util.I18n.getString("alignVerticalAxis", "Align vertical axis"));
        jMenuItemAlignHorizontalAxis.setText(it.businesslogic.ireport.util.I18n.getString("alignHorizontalAxis", "Align horizontal axis"));
        jMenuItemAlignToBandTop.setText(it.businesslogic.ireport.util.I18n.getString("alignToBandTop", "Align to band top"));
        jMenuItemAlignToBandBottom.setText(it.businesslogic.ireport.util.I18n.getString("alignToBandBottom", "Align to band bottom"));
        jMenuSize.setText(it.businesslogic.ireport.util.I18n.getString("size", "Size..."));
        jMenuItemSameWidth.setText(it.businesslogic.ireport.util.I18n.getString("sameWidth", "Same width"));
        jMenuItemSameWidthMax.setText(it.businesslogic.ireport.util.I18n.getString("sameWidthMax", "Same width (max)"));
        jMenuItemSameWidthMin.setText(it.businesslogic.ireport.util.I18n.getString("sameWidthMin", "Same width (min)"));
        jMenuItemSameHeight.setText(it.businesslogic.ireport.util.I18n.getString("sameHeight", "Same height"));
        jMenuItemSameHeightMin.setText(it.businesslogic.ireport.util.I18n.getString("sameHeightMin", "Same height (min)"));
        jMenuItemSameHeightMax.setText(it.businesslogic.ireport.util.I18n.getString("sameHeightMax", "Same height (max)"));
        jMenuItemSameSize.setText(it.businesslogic.ireport.util.I18n.getString("sameSize", "Same size"));
        jMenuPosition.setText(it.businesslogic.ireport.util.I18n.getString("position", "Position..."));
        jMenuItemCenterH.setText(it.businesslogic.ireport.util.I18n.getString("centerHorizontallyBandBased", "Center horizontally (band based)"));
        jMenuItemCenterV.setText(it.businesslogic.ireport.util.I18n.getString("centerVerticallyBandBased", "Center vertically (band based)"));
        jMenuItemCenterInBand.setText(it.businesslogic.ireport.util.I18n.getString("centerInBand", "Center in band"));
        jMenuItemCenterBackground.setText(it.businesslogic.ireport.util.I18n.getString("centerInBackground", "Center in background"));
        jMenuItemJoinLeft.setText(it.businesslogic.ireport.util.I18n.getString("joinSidesLeft", "Join sides left"));
        jMenuItemJoinRight.setText(it.businesslogic.ireport.util.I18n.getString("joinSidesRight", "Join sides right"));
        jMenuHSpacing.setText(it.businesslogic.ireport.util.I18n.getString("horizontalSpacing", "Horizontal spacing..."));
        jMenuItemHSMakeEqual.setText(it.businesslogic.ireport.util.I18n.getString("makeEqual", "Make equal"));
        jMenuItemHSIncrease.setText(it.businesslogic.ireport.util.I18n.getString("increase", "Increase"));
        jMenuItemHSDecrease.setText(it.businesslogic.ireport.util.I18n.getString("decrease", "Decrease"));
        jMenuItemHSRemove.setText(it.businesslogic.ireport.util.I18n.getString("remove", "Remove"));
        jMenuVSpacing.setText(it.businesslogic.ireport.util.I18n.getString("verticalSpacing", "Vertical spacing"));
        jMenuItemVSMakeEqual.setText(it.businesslogic.ireport.util.I18n.getString("makeEqual", "Make equal"));
        jMenuItemVSIncrease.setText(it.businesslogic.ireport.util.I18n.getString("increase", "Increase"));
        jMenuItemVSDecrease.setText(it.businesslogic.ireport.util.I18n.getString("decrease", "Decrease"));
        jMenuItemVSRemove.setText(it.businesslogic.ireport.util.I18n.getString("remove", "Remove"));
        jMenuItemBringToFront.setText(it.businesslogic.ireport.util.I18n.getString("bringToFront", "Bring to front"));
        jMenuItemSendToBack.setText(it.businesslogic.ireport.util.I18n.getString("sendToBack", "Send to back"));
        jMenuDatabase.setText(it.businesslogic.ireport.util.I18n.getString("datasource", "Datasource"));
        jMenuItemConnections.setText(it.businesslogic.ireport.util.I18n.getString("connectionsDatasources", "Connections / Datasources"));
        jMenuItemReportQuery2.setText(it.businesslogic.ireport.util.I18n.getString("reportQuery", "Report query"));
        jMenuTools.setText(it.businesslogic.ireport.util.I18n.getString("tools", "Tools"));
        jMenuItemOptions.setText(it.businesslogic.ireport.util.I18n.getString("options", "Options..."));
        jMenuItemCompatibility.setText(it.businesslogic.ireport.util.I18n.getString("compatibility", "Compatibility..."));
        jMenuWindow.setText(it.businesslogic.ireport.util.I18n.getString("window", "Window"));
        jMenuItemCascade.setText(it.businesslogic.ireport.util.I18n.getString("cascade", "Cascade"));
        jMenuItemTileHorizontal.setText(it.businesslogic.ireport.util.I18n.getString("tileHorizontal", "Tile horizontal"));
        jMenuItemTileVertical.setText(it.businesslogic.ireport.util.I18n.getString("tileVertical", "Tile vertical"));
        jMenuItemtileAnodine.setText(it.businesslogic.ireport.util.I18n.getString("tileAnodine", "Tile anodine"));
        jMenuItemNextWin.setText(it.businesslogic.ireport.util.I18n.getString("nextWindow", "Next Window"));
        jMenuItemPrevWin.setText(it.businesslogic.ireport.util.I18n.getString("previousWindow", "Previous Window"));
        jMenuHelp.setText(it.businesslogic.ireport.util.I18n.getString("help", "Help"));
        jMenuItemHelp.setText(it.businesslogic.ireport.util.I18n.getString("help", "Help"));
        jMenuItemAbout.setText(it.businesslogic.ireport.util.I18n.getString("aboutiReport", "About iReport..."));
        jMenuItemFind.setText(it.businesslogic.ireport.util.I18n.getString("find", "Find..."));
        jMenuItemPluginConfig.setText(it.businesslogic.ireport.util.I18n.getString("configurePlugins", "Configure plugins"));
        jMenuPlugins.setText(it.businesslogic.ireport.util.I18n.getString("plugins", "Plugins"));
        jMenuInternationalization.setText(it.businesslogic.ireport.util.I18n.getString("internationalization", "Internationalization"));
        jMenuInternationalizationWizard.setText(it.businesslogic.ireport.util.I18n.getString("internationalizationWizard", "Internationalization Wizard"));
        jMenuLocaleFiles.setText(it.businesslogic.ireport.util.I18n.getString("internationalizationFiles", "Locale files"));
        jMenuItemRemoveMargins.setText(it.businesslogic.ireport.util.I18n.getString("removeMargins", "Remove margins"));
        
        
        if (libraryPanel != null && jTabbedPaneExplorer.indexOfComponent(libraryPanel) >= 0)
                jTabbedPaneExplorer.setTitleAt(jTabbedPaneExplorer.indexOfComponent(libraryPanel), it.businesslogic.ireport.util.I18n.getString("gui.library", "Library"));
    }
    
    
    /** Getter for property eventsForm.
     * @return Value of property eventsForm.
     *
     */
    public it.businesslogic.ireport.gui.EventsForm getEventsForm() {
        return eventsForm;
    }
    
    /** Setter for property eventsForm.
     * @param eventsForm New value of property eventsForm.
     *
     */
    public void setEventsForm(it.businesslogic.ireport.gui.EventsForm eventsForm) {
        this.eventsForm = eventsForm;
    }
    
    
    
    public void loadPlugins(String plugins_dir) {
        // Adding default properties...
        
        java.util.Vector plugin_files_v = new java.util.Vector();
        File plugDir = null;
        try {
            plugDir = new File(plugins_dir);
        } catch (Exception ex)
        {}
        if (plugDir == null || !plugDir.exists() || plugDir.isFile()) {
            try {
                logOnConsole("Error scanning iReport plugin directory :"+plugins_dir+".\n");
            } catch (Exception exsx)
            {}
            
        } else
        {
        
        // Loading all xml files....
        
	        File plugins_files[] = plugDir.listFiles();
	        
	        for (int i=0; i<plugins_files.length; ++i)
	        {
	            if (!plugins_files[i].getName().endsWith(".xml")) continue;
	            plugin_files_v.add(plugins_files[i]);
	        }
	}

        try {
       	
        Enumeration enum_pl = this.getClass().getClassLoader().getResources("ireport/plugin.xml");
        while (enum_pl.hasMoreElements())
        {
            Object oobj = enum_pl.nextElement();
            System.out.println( oobj+"");
            plugin_files_v.add(oobj);
        }
        } catch (Exception ex) {
               	logOnConsole("Error searching ireport/plugin.xml resources\n"); 	
        }
        
        for (int i=0; i<plugin_files_v.size(); ++i) {
            
            Object source = plugin_files_v.elementAt(i);
            //  Create a Xerces DOM Parser
            DOMParser parser = new DOMParser();
            //  Parse the Document
            //  and traverse the DOM
            try {
                
                parser.setEntityResolver( new org.xml.sax.EntityResolver() {
                    /* Code by Teodor Danciu */
                    public org.xml.sax.InputSource resolveEntity(
                    String publicId,
                    String systemId
                    ) throws SAXException//, java.io.IOException
                    {
                        org.xml.sax.InputSource inputSource = null;
                        
                        if (systemId != null) {
                            String dtd = null;
                            
                            if ( systemId.equals("http://ireport.sourceforge.net/dtds/iReportPlugin.dtd") ) {
                                dtd = "it/businesslogic/ireport/dtds/iReportPlugin.dtd";
                            } else {
                                return new org.xml.sax.InputSource(systemId);
                            }
                            
                            
                            ClassLoader classLoader = this.getClass().getClassLoader();
                            
                            java.net.URL url = null;
                            
                            
                            if (classLoader != null) {
                                url = classLoader.getResource(dtd);
                            }
                            if (url == null) {
                                classLoader = this.getClass().getClassLoader();
                            }
                            
                            java.io.InputStream is = classLoader.getResourceAsStream(dtd);
                            if (is != null) {
                                java.io.InputStreamReader isr = new java.io.InputStreamReader(is);
                                inputSource = new org.xml.sax.InputSource(isr);
                            }
                            
                        }
                        
                        return inputSource;
                    }
                });
                /* End Code by Teodor Danciu */
                InputStream input_source = null;
                if ( source instanceof java.io.File )
                {
                    input_source = new FileInputStream((java.io.File)source);
                    
                } else if ( source instanceof java.net.URL){
                      
                    input_source = ((java.net.URL)source).openStream();
                
                }
                
                parser.parse(new org.xml.sax.InputSource( input_source ));
                Document document = parser.getDocument();
                
                //System.out.println("traverse");
                Node node = document.getDocumentElement();
                
                PluginEntry pe = new PluginEntry();
                pe.setMainFrame( this );
                
                if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("iReportPlugin")) {
                    //System.out.println("iReportProperties");
                    // Get childs....
                    NamedNodeMap nnm_plugin = node.getAttributes();
                    if ( nnm_plugin.getNamedItem("name") != null) pe.setName(nnm_plugin.getNamedItem("name").getNodeValue());
                    if ( nnm_plugin.getNamedItem("class") != null) pe.setClassName( nnm_plugin.getNamedItem("class").getNodeValue() );
                    if ( nnm_plugin.getNamedItem("loadOnStartup") != null) pe.setLoadOnStartup( Misc.nvl(nnm_plugin.getNamedItem("loadOnStartup").getNodeValue().trim(),"false").toLowerCase().equals("true") );
                    if ( nnm_plugin.getNamedItem("hide") != null) pe.setHide(  Misc.nvl(nnm_plugin.getNamedItem("hide").getNodeValue().trim(),"false").toLowerCase().equals("true") );
                    if ( nnm_plugin.getNamedItem("configurable") != null) pe.setConfigurable( Misc.nvl(nnm_plugin.getNamedItem("configurable").getNodeValue().trim(),"false").toLowerCase().equals("true") );
                    
                    NodeList children = node.getChildNodes();
                    if (children != null) {
                        for (int k=0; k< children.getLength(); k++) {
                            Node nodeChild = (Node)children.item(k);
                            if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("IconFile")) {
                                
                                // Take the CDATA...
                                // Load icon...
                                String iconName = readPCDATA(nodeChild).trim();
                                try {
                                    pe.setIcon( new javax.swing.ImageIcon(getClass().getResource(iconName) ));
                                } catch (Exception ex) { ex.printStackTrace(); }
                            }
                            else if (nodeChild.getNodeType() == Node.ELEMENT_NODE && nodeChild.getNodeName().equals("Description")) {
                                String description = readPCDATA(nodeChild).trim();
                                pe.setDescription( description );
                            }
                        }
                    }
                }
                
                
                if (!pe.isHide()) {
                    javax.swing.JMenuItem pluginItem = new javax.swing.JMenuItem();
                    pluginItem.setFont(new java.awt.Font("Dialog", 0, 11));
                    pluginItem.setText( pe.getName() );
                    if (pe.getIcon() != null) {
                        pluginItem.setIcon( pe.getIcon() );
                    }
                    
                    pluginEntries.put( pluginItem, pe );
                    
                    pluginItem.addActionListener( new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jMenuItemPluginActionPerformed(evt);
                        }
                        
                    });
                    
                    jMenuPlugins.add( pluginItem );
                }
                
                if (pe.isLoadOnStartup()) {
                    
                    pe.getPlugin().call();
                }
                
            } catch (SAXException e) {
                System.err.println(e);
            } catch (java.io.IOException e) {
                System.err.println(e);
            }
            
        } // End cycle on iReport plugin files...
    }
    
    
    private void jMenuItemPluginActionPerformed(java.awt.event.ActionEvent evt) {
        
        if (this.pluginEntries.containsKey( evt.getSource() ) ) {
            PluginEntry pe = (PluginEntry)this.pluginEntries.get( evt.getSource() );
            pe.getPlugin().call();
        }
        
    }
    
    /** Getter for property pluginConfigurationDialog.
     * @return Value of property pluginConfigurationDialog.
     *
     */
    public it.businesslogic.ireport.gui.PluginConfigurationDialog getPluginConfigurationDialog() {
        
        if (pluginConfigurationDialog == null) {
            pluginConfigurationDialog = new PluginConfigurationDialog(this);
            pluginConfigurationDialog.setPlugins( this.getPluginEntries().values() );
        }
        
        return pluginConfigurationDialog;
    }
    
    /** Setter for property pluginConfigurationDialog.
     * @param pluginConfigurationDialog New value of property pluginConfigurationDialog.
     *
     */
    public void setPluginConfigurationDialog(it.businesslogic.ireport.gui.PluginConfigurationDialog pluginConfigurationDialog) {
        this.pluginConfigurationDialog = pluginConfigurationDialog;
    }
    
    /** Getter for property pluginEntries.
     * @return Value of property pluginEntries.
     *
     */
    public java.util.HashMap getPluginEntries() {
        return pluginEntries;
    }
    
    /** Setter for property pluginEntries.
     * @param pluginEntries New value of property pluginEntries.
     *
     */
    public void setPluginEntries(java.util.HashMap pluginEntries) {
        this.pluginEntries = pluginEntries;
    }
    
    public void languageChanged(LanguageChangedEvent evt) {
        
        this.applyI18n();
    }
    
    /**
     * Return the active Report frame. return null if no report frame is actually activated.
     */
    public JReportFrame getActiveReportFrame() {
        if (jMDIDesktopPane.getSelectedFrame() != null &&
        jMDIDesktopPane.getSelectedFrame() instanceof JReportFrame) {
            return (JReportFrame)jMDIDesktopPane.getSelectedFrame();
        }
        return null;
    }
    
    /** Getter for property reportClassLoader.
     * @return Value of property reportClassLoader.
     *
     */
    public it.businesslogic.ireport.ReportClassLoader getReportClassLoader() {
        if (reportClassLoader == null)
        {
           reportClassLoader = new ReportClassLoader();
        }
        reportClassLoader.rescanLibDirectory();
        return reportClassLoader;
    }
    
    /** Setter for property reportClassLoader.
     * @param reportClassLoader New value of property reportClassLoader.
     *
     */
    public void setReportClassLoader(it.businesslogic.ireport.ReportClassLoader reportClassLoader) {
        this.reportClassLoader = reportClassLoader;
    }
    
    
    public javax.swing.text.Document getLogDocument() {
        return  jEditorPaneOutput.getDocument();
    }
    
    /**
     * Getter for property activeStyleClipboard.
     * @return Value of property activeStyleClipboard.
     */
    public int getActiveStyleClipboard() {
        return activeStyleClipboard;
    }
    
    /**
     * Setter for property activeStyleClipboard.
     * @param activeStyleClipboard New value of property activeStyleClipboard.
     */
    public void setActiveStyleClipboard(int activeStyleClipboard) {
        this.activeStyleClipboard = activeStyleClipboard;
    }
    
    
    public it.businesslogic.ireport.ReportElement getStyleClipboard() {
        return styleClipboards[getActiveStyleClipboard()];
    }
    
    public void setStyleClipbardContent(it.businesslogic.ireport.ReportElement element) {
        styleClipboards[getActiveStyleClipboard()] = element;
        
    }
    
    // Hack for MacOS X suggested by Gary Nunes
    public java.awt.Dimension getMinimumSize() {
        return new java.awt.Dimension(50, 50); // arbitrary minimum size value
    }
    
    /**
     * Getter for property currentZoomFactor.
     * @return Value of property currentZoomFactor.
     */
    public double getCurrentZoomFactor() {
        return currentZoomFactor;
    }
    
    /**
     * Setter for property currentZoomFactor.
     * @param currentZoomFactor New value of property currentZoomFactor.
     */
    public void setCurrentZoomFactor(double currentZoomFactor) {
        this.currentZoomFactor = currentZoomFactor;
    }

    public void setComboBoxZoomFactor(double zoomFactor) {
        this.jNumberComboBoxZoom.setValue(zoomFactor);
        //logOnConsole(this.jNumberComboBoxZoom.getValue() + "\n" ) ;
    }

    /**
     * Getter for property libraryPanel.
     * @return Value of property libraryPanel.
     */
    public LibraryPanel getLibraryPanel() {
        return this.libraryPanel;
    }

    /**
     * Setter for property libraryPanel.
     * @param libraryPanel New value of property libraryPanel.
     */
    public void setLibraryPanel(LibraryPanel libraryPanel) {
        this.libraryPanel = libraryPanel;
    }
    
    public void clearConsole()
    {
        this.jEditorPaneOutput.setContentType("text/html");
            outputBuffer.setLength(0);
            logOnConsole("");
    }

    public LocaleResourceFilesDialog getLocaleFilesDialog() {
        return localeFilesDialog;
    }

    public void setLocaleFilesDialog(LocaleResourceFilesDialog localeFilesDialog) {
        this.localeFilesDialog = localeFilesDialog;
    }

    /**
     * Registers ReportListener to receive events.
     * @param listener The listener to register.
     */
    public synchronized void addReportListener(it.businesslogic.ireport.gui.event.ReportListener listener) {

        if (listenerList == null ) {
            listenerList = new javax.swing.event.EventListenerList();
        }
        listenerList.add (it.businesslogic.ireport.gui.event.ReportListener.class, listener);
    }

    /**
     * Removes ReportListener from the list of listeners.
     * @param listener The listener to remove.
     */
    public synchronized void removeReportListener(it.businesslogic.ireport.gui.event.ReportListener listener) {

        listenerList.remove (it.businesslogic.ireport.gui.event.ReportListener.class, listener);
    }

    /**
     * Notifies all registered listeners about the event.
     * 
     * @param event The event to be fired
     */
    private void fireReportListenerReportElementsSelectionChanged(it.businesslogic.ireport.gui.event.ReportElementsSelectionEvent event) {

        if (listenerList == null) return;
        Object[] listeners = listenerList.getListenerList ();
        for (int i = listeners.length-2; i>=0; i-=2) {
            if (listeners[i]==it.businesslogic.ireport.gui.event.ReportListener.class) {
                ((it.businesslogic.ireport.gui.event.ReportListener)listeners[i+1]).reportElementsSelectionChanged (event);
            }
        }
    }

    /**
     * Notifies all registered listeners about the event.
     * 
     * @param event The event to be fired
     */
    private void fireReportListenerReportElementsChanged(it.businesslogic.ireport.gui.event.ReportElementChangedEvent event) {

        if (listenerList == null) return;
        Object[] listeners = listenerList.getListenerList ();
        for (int i = listeners.length-2; i>=0; i-=2) {
            if (listeners[i]==it.businesslogic.ireport.gui.event.ReportListener.class) {
                ((it.businesslogic.ireport.gui.event.ReportListener)listeners[i+1]).reportElementsChanged (event);
            }
        }
    }

    /**
     * Notifies all registered listeners about the event.
     * 
     * @param event The event to be fired
     */
    private void fireReportListenerReportBandChanged(it.businesslogic.ireport.gui.event.ReportBandChangedEvent event) {

        if (listenerList == null) return;
        Object[] listeners = listenerList.getListenerList ();
        for (int i = listeners.length-2; i>=0; i-=2) {
            if (listeners[i]==it.businesslogic.ireport.gui.event.ReportListener.class) {
                ((it.businesslogic.ireport.gui.event.ReportListener)listeners[i+1]).reportBandChanged (event);
            }
        }
    }

    public Vector getClasspath() {
        
        if (classpath == null)
        {
            classpath = new Vector();
            
            // Each line is a path/jar...
            StringTokenizer  st = new StringTokenizer( getProperties().getProperty("classpath",""),"\n");
            while (st.hasMoreTokens())
            {
                String token = st.nextToken();
                if (token != null && token.trim().length() > 0)
                {
                    classpath.addElement( token.trim() );
                }
            }
            
        }
        return classpath;
    }

    public void setClasspath(Vector classpath) {
        this.classpath = classpath;
        String cp_property = "";
        for (int i=0; i<classpath.size(); ++i)
        {
            cp_property += classpath.elementAt(i) +"\n";
        }
        getProperties().setProperty("classpath",cp_property);
    }
    
    // Indicate whether Report Name must be synchronized 
    public boolean isSynchronizeReportName()
    {
        return getProperties().getProperty("SynchronizeReportName", "").equals("true") ;
    }
    
    public boolean isShowOptionDialogSynchronize(  String reportName, String filename ) {

        int ret = I18nOptionPane.showOptionDialog(this,
                                    "gui.MainFrame.SynchronizeReportName",
                                    "",
                                    JOptionPane.YES_NO_OPTION,
                                    JOptionPane.WARNING_MESSAGE,
                                    null, new String[]{"yes", "no"},
                                    "no",
                                    "Report Name: " + reportName + "\n" + "File Name: " + filename  );
                                    
                                    return (ret==0);
    }
    
    public JReportFrame getSelectedJRFFromFilesTree()
    {
        TreePath path = jTreeFiles.getSelectionPath();
        if (path == null) return null;
        TreeNode node = (TreeNode)path.getLastPathComponent();
        if (node instanceof DefaultMutableTreeNode) {
                DefaultMutableTreeNode nodem = (DefaultMutableTreeNode)node;
                Object obj = nodem.getUserObject();
                if (obj != null && obj instanceof DocumentTreeEntry) {
                    DocumentTreeEntry dtn = (DocumentTreeEntry)obj;
                    return dtn.getJrf();
                }
        }
        
        return null;
    }

    public JMDIDesktopPane getJMDIDesktopPane() {
        return jMDIDesktopPane;
    }

}//end class MainFrame
