/*
 * Copyright (C) 2001-2006 University Bayreuth, BayCEER, Dept. of Mycology 
 * 
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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 library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package net.metadiversity.diversity.navikey.ui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.io.BufferedReader;
import java.net.URL;

import net.metadiversity.diversity.navikey.bo.DeltaInterface;
import net.metadiversity.diversity.navikey.bo.Resource;
import net.metadiversity.diversity.navikey.delta.DeltaConnector;
import net.metadiversity.diversity.navikey.delta.LocalDeltaConnector;
import net.metadiversity.diversity.navikey.delta.DnDatabaseConnector;
import net.metadiversity.diversity.navikey.servlet.HttpDeltaConnector;
//import net.metadiversity.diversity.navikey.resource.IconPanel;

/**
 *
 * NaviKey.java
 *
 * @author Michael Bartley
 * 3/25/98
 * @author Dieter Neubacher
 */

public class NaviKey extends javax.swing.JPanel
{
    /**
     * Comment for <code>serialVersionUID</code>
     */
    private static final long serialVersionUID = 3762532317360829234L;

    //public static String imageLocation;
        
    private boolean useTabSheets = false;    
    javax.swing.JTabbedPane tabbedPane;

    SuperPanel          superPanel;
    ConfigurationPanel  cp;
    javax.swing.JLabel  navikeyIcon = null;    
    DeltaInterface      delta;
    
    //These will be adjusted by user, and used by all subpanels as selections
    static Color naviKeyBackgroundColor = Color.black;
    static Color itemCharacterColor     = Color.cyan;
    static Color itemStateColor         = Color.magenta;
    static Color itemSelectionsColor    = Color.green;
    static Color itemListColor          = Color.yellow;
    static Color buttonColor            = Color.pink;
    static Color boxBGColor             = Color.white;
    static Color boxFGColor             = Color.black;
    static Color itemDisplayColor       = Color.cyan;
    static Color itemDisplayTextColor   = Color.white;
    static Color itemDisplayBGColor     = Color.darkGray;
    static Color itemDisplayFGColor     = Color.green;
    static Color imageBGColor           = Color.black;
    static Color imageFGColor           = Color.white;
    
    private boolean standAlone = true;
    // DiversityNavigator
    private boolean useDnDatabaseConnector = false;
    private String specsString = null;
    private String charsString = null;
    private String itemsString = null;
    
    private String specsfile = null;
    private String charsfile = null;
    private String itemsfile = null;
    private String imageDirectory=null;
    //
    // Options
    //
    private boolean useBestAlgorithm        = false; // to be implemented       
    private boolean useCharacterDependencies= false; // to be implemented

    //
    private boolean intelligence          = true;
    private boolean excludeUndefined      = true;
    private boolean multipleSelectionOR   = true;
    private boolean extremeInterval       = true;
    private boolean overlappingInterval   = true;
    // Remove Comments wenn readin data files.
    public  boolean removeCharsCommentFlag = false;
    public  boolean removeItemsCommentFlag = false;
    public  boolean removeSpecsCommentFlag = false;
    //
    // Remove StatesComments wenn readin data files.
    public  boolean removeCharsStatesCommentFlag = false;
    public  boolean removeItemsStatesCommentFlag = false;
    public  boolean removeSpecsStatesCommentFlag = false;
    // Show LIAS units with []
    public  boolean showLiasUnitsFlag   = false;
    // Dependencies
    public  boolean dependenciesFlag    = true; // Default
    //
    // Display all and found ItemCount
    // Will be displayed on the configurationPanel
    //
    private long allItemCount;
    private long foundItemCount;
    //
    //
    private String servletURL=null;
    
    private java.lang.String        propertyFileName = null;
    private java.net.URL            codebase         = null;
    private java.awt.Container      contentPane      = null;
    
    
    private Resource resource;
            
    private void initializeParameters()
    {
        BufferedReader bufferdReader = null;
        String props = null;
        try
        {
//            if( ! useDnDatabaseConnector )
            {
                props = getParameter( "propsfile" );
                URL url = new URL( getCodeBase().toString() + props ); 
                
                // JAVA 1.4: can't load the file "file://..." 
                // ERROR sun.net.ftp.FtpLoginException: Not logged in                
            
            
                System.out.println( "URL: " + url );
                System.out.println( "Protocol: " + url.getProtocol() );
                
                boolean useUrlFlag = ! url.getProtocol().equalsIgnoreCase( "FILE" );
                
                if( useUrlFlag )
                {                                    
                    bufferdReader = new BufferedReader( new java.io.InputStreamReader( url.openStream() ) );
                }
                else
                {
                    String filename = getCodeBase().toString() + props;
                    filename = filename.substring( filename.indexOf( ":/") + 2 );
                    bufferdReader = new BufferedReader( new java.io.InputStreamReader( new java.io.FileInputStream( filename ) ) );
                }
            }
        }
        catch( Exception e )
        {            
            System.out.println( "Can't read propsfile: " + getCodeBase().toString() + props );
            System.out.println( "NaviKey: No color scheme specified, using defaults" );
            standAlone = true;  // Run as Application
            return;
        }
        
        String line     = "";
        String value    = "";
        Color colorSelect = null;
        String field    = "";
        
        while( line != null )
        {
            try
            {
                line = bufferdReader.readLine();
                while( line != null )
                {
                    colorSelect = null;
                    if( line.indexOf( '=' ) > 0 )
                    {
                        field = line.substring( 0,line.indexOf( '=' ) );
                        value = line.substring( line.indexOf( '=' ) + 1 );
                        
                        if( field.equals( "standalone" ) )
                        {
                            if( value.equals( "false" ) )
                            {
                                System.out.println( "Good luck, servlet" );
                                standAlone = false;
                            }
                            else
                            {
                                System.out.println( "Using da files" + field + value );
                                standAlone = true;
                            }
                        }
                        // DEEMY: 2005-10-15 Remove comments                        
                        else if( field.equals( "removeCharsComments" ) )
                        {
                            if( value.equals( "false" ) )
                            {
                                removeCharsCommentFlag = false;
                            }
                            else
                            {
                                removeCharsCommentFlag = true;
                            }
                        }
                        else if( field.equals( "removeCharsStatesComments" ) )
                        {
                            if( value.equals( "false" ) )
                            {
                                removeCharsStatesCommentFlag = false;
                            }
                            else
                            {
                                removeCharsStatesCommentFlag = true;
                            }
                        }
                        else if( field.equals( "removeItemsComments" ) )
                        {
                            if( value.equals( "false" ) )
                            {
                                removeItemsCommentFlag = false;
                            }
                            else
                            {
                                removeItemsCommentFlag = true;
                            }
                        }
                        else if( field.equals( "removeItemsStatesComments" ) )
                        {
                            if( value.equals( "false" ) )
                            {
                                removeItemsStatesCommentFlag = false;
                            }
                            else
                            {
                                removeItemsStatesCommentFlag = true;
                            }
                        }
                        else if( field.equals( "removeSpecsComments" ) )
                        {
                            if( value.equals( "false" ) )
                            {
                                removeSpecsCommentFlag = false;
                            }
                            else
                            {
                                removeSpecsCommentFlag = true;
                            }
                        }
                        else if( field.equals( "removeSpecsStatesComments" ) )
                        {
                            if( value.equals( "false" ) )
                            {
                                removeSpecsStatesCommentFlag = false;
                            }
                            else
                            {
                                removeSpecsStatesCommentFlag = true;
                            }
                        }
                        //
                        else if( field.equals( "servletURL" ) )
                        {
                            servletURL = value;
                        }
                        //
                        // GUI Options
                        //
/*
    private boolean intelligence          = true;
    private boolean excludeUndefined      = true;
    private boolean multipleSelectionOR   = true;
    private boolean extremeInterval       = true;
    private boolean overlappingInterval   = true;
*/                      
                        
                        else if( field.equals( "useBestAlgorithm" ) )
                        {
                            if( value.equals( "false" ) )
                            {
                                useBestAlgorithm = false;
                            }
                            else
                            {
                                useBestAlgorithm = true;
                            }
                        }
                        else if( field.equals( "useCharacterDependencies" ) )
                        {
                            if( value.equals( "false" ) )
                            {
                                useCharacterDependencies = false;
                            }
                            else
                            {
                                useCharacterDependencies = true;
                            }
                        }
                        
                        else if( field.equals( "intelligence" ) )
                        {
                            if( value.equals( "false" ) )
                            {
                                intelligence = false;
                            }
                            else
                            {
                                intelligence = true;
                            }
                        }
                        
                        else if( field.equals( "excludeUndefined" ) )
                        {
                            // Text in GUI is invert to this option
                            
                            if( value.equals( "false" ) )
                            {
                                excludeUndefined = true;
                            }
                            else
                            {
                                excludeUndefined = false;
                            }
                        }
                        else if( field.equals( "multipleSelectionOR" ) )
                        {
                            if( value.equals( "false" ) )
                            {
                                multipleSelectionOR = false;
                            }
                            else
                            {
                                multipleSelectionOR = true;
                            }
                        }
                        else if( field.equals( "evaluateExtremeInterval" ) )
                        {
                            if( value.equals( "false" ) )
                            {
                                extremeInterval = false;
                            }
                            else
                            {
                                extremeInterval = true;
                            }
                        }
                        else if( field.equals( "evaluateOverlappingInterval" ) )
                        {
                            if( value.equals( "false" ) )
                            {
                                overlappingInterval = false;
                            }
                            else
                            {
                                overlappingInterval = true;
                            }
                        }
                        else if( field.equals( "showLiasUnits" ) )
                        {
                            // Default value is "false"
                            if( value.equals( "true" ) )
                            {
                                showLiasUnitsFlag = true;
                            }
                            else
                            {
                                showLiasUnitsFlag = false;
                            }
                        }
                        // dependenciesFlag
                        else if( field.equals( "dependencies" ) )
                        {
                            // Default value is "true"
                            if( value.equals( "true" ) )
                            {
                                dependenciesFlag = true;
                            }
                            else
                            {
                                dependenciesFlag = false;
                            }
                        }
                        else if( field.equals( "useGuiTabs" ) )
                        {    
                            // Default value is "false"
                            if( value.equals( "true" ) )
                            {
                                useTabSheets = true;
                            }
                            else
                            {
                                useTabSheets  = false;
                            }
                        }
                        else if( field.equals( "specsfile" ) )
                            specsfile = value;
                        else if( field.equals( "charsfile" ) )
                            charsfile = value;
                        else if( field.equals( "itemsfile" ) )
                            itemsfile = value;
                        else if( field.equals( "imageDirectory" ) )
                            imageDirectory = value;
                        
                        else
                        {
                            if ( value.equals( "black" ) )
                                colorSelect = Color.black;
                            else if ( value.equals( "blue" ) )
                                colorSelect = Color.blue;
                            else if ( value.equals( "cyan" ) )
                                colorSelect = Color.cyan;
                            else if ( value.equals( "darkGray" ) )
                                colorSelect = Color.darkGray;
                            else if ( value.equals( "gray" ) )
                                colorSelect = Color.gray;
                            else if ( value.equals( "green" ) )
                                colorSelect = Color.green;
                            else if ( value.equals( "lightGray" ) )
                                colorSelect = Color.lightGray;
                            else if ( value.equals( "magenta" ) )
                                colorSelect = Color.magenta;
                            else if ( value.equals( "orange" ) )
                                colorSelect = Color.orange;
                            else if ( value.equals( "pink" ) )
                                colorSelect = Color.pink;
                            else if ( value.equals( "red" ) )
                                colorSelect = Color.red;
                            else if ( value.equals( "white" ) )
                                colorSelect = Color.white;
                            else if ( value.equals( "yellow" ) )
                                colorSelect = Color.yellow;
                            
                            if( colorSelect != null )
                            {
                                if( field.equals( "naviKeyBackgroundColor" ) )
                                    naviKeyBackgroundColor = colorSelect;
                                else if ( field.equals( "itemCharacterColor" ) )
                                    itemCharacterColor = colorSelect;
                                else if ( field.equals( "itemSelectionsColor" ) )
                                    itemSelectionsColor = colorSelect;
                                else if ( field.equals( "itemListColor" ) )
                                    itemListColor = colorSelect;
                                else if ( field.equals( "buttonColor" ) )
                                    buttonColor = colorSelect;
                                else if ( field.equals( "boxBGColor" ) )
                                    boxBGColor = colorSelect;
                                else if ( field.equals( "boxFGColor" ) )
                                    boxFGColor = colorSelect;
                                else if ( field.equals( "itemDisplayColor" ) )
                                    itemDisplayColor = colorSelect;
                                else if ( field.equals( "itemDisplayTextColor" ) )
                                    itemDisplayTextColor = colorSelect;
                                else if ( field.equals( "itemDisplayBGColor" ) )
                                    itemDisplayBGColor = colorSelect;
                                else if ( field.equals( "itemDisplayFGColor" ) )
                                    itemDisplayFGColor = colorSelect;
                                else if ( field.equals( "imageBGColor" ) )
                                    imageBGColor = colorSelect;
                                else if ( field.equals( "imageFGColor" ) )
                                    imageFGColor = colorSelect;
                            }
                        }
                    }
                    line = bufferdReader.readLine();
                }
                bufferdReader.close();
            }
            catch( Exception e )
            {
                System.out.println( "Some error in reading file, using defaults" );
                return;
            }
            System.out.println( line );
        }
    }
    //--------------------------------------------------------------------------
    //--------------------------------------------------------------------------
    /**
     * NaviKey ( Plugin for DiversityNavigator )
     */
    public NaviKey( java.awt.Container contentPane, String specsString, String charsString, String itemsString )
    {   
        this.specsString = specsString;
        this.charsString = charsString;
        this.itemsString = itemsString;
        useDnDatabaseConnector = true;
        propertyFileName = "NaviKey.props";
        this.contentPane = contentPane;
               
        try
        {
                String path = System.getProperty( "user.home" );                                        	
        	path = "FILE:///" + path + "/.diversity_navigator/";	// Windows: working directory        	
        	this.codebase = new URL( path );
        }
        catch( java.net.MalformedURLException ex )
        {
        	System.out.println( "NavikeyApplication: ERROR can't get CodeBase" );
                ex.printStackTrace();
                
                this.codebase = null;
        }          
    }
    
    //--------------------------------------------------------------------------
    //--------------------------------------------------------------------------
    public NaviKey( java.awt.Container contentPane, String propsfile, URL codebase )
    {
        propertyFileName = propsfile;
        this.codebase    = codebase;
        this.contentPane = contentPane;
        
        // ??? resource = new Resource();
    }            
    //--------------------------------------------------------------------------
    //--------------------------------------------------------------------------
    private URL getCodeBase()
    {
        System.out.println( "getCodeBase() : " + codebase );
        return codebase;
    }
    //--------------------------------------------------------------------------
    //--------------------------------------------------------------------------
    String getParameter( String str )
    {
        System.out.println( "getParam( " + str +" )" );
        if( str.equals( "propsfile" ) )
        {
            return propertyFileName;
        }
        else
        {
            return null;
        }
    }
    //--------------------------------------------------------------------------
    //--------------------------------------------------------------------------
    java.awt.Container getContentPane()
    {
        // System.out.println( "getContentPane() : " + contentPane );
        return contentPane;
    }
    //--------------------------------------------------------------------------
    //--------------------------------------------------------------------------    
    public void init()
    {
        getContentPane().setLayout( new BorderLayout() );
        setBorder( javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10) );
        
        initializeParameters();
        DeltaConnector dc;
        
        System.out.println( "init()" );
        
        if( imageDirectory != null )
        {
            try
            {
                resource.defaultLocation = getCodeBase().toString() + imageDirectory +"/";
            }
            catch( Exception e )
            {
                System.out.println( "NaviKey: Unable to get code base. " + e );
            }
        }
        if( useDnDatabaseConnector )
        {
            dc = runDnDatabaseConnector();
        }
        else if( standAlone )
        {
            dc = runStandAlone();
        }
        else
        {
            dc = runHttpConnector();
        }
        delta = dc.getObject();
        superPanel = new SuperPanel( this, delta );
        // Item Character Panel
        System.out.println( "Setting panels" );
        superPanel.itemCharacterPanel.setItemCharacters( delta.getItemCharacterList( null, dependenciesFlag, dependenciesFlag ) );
        superPanel.itemCharacterPanel.updateList();
        /*        
        // Item Panel
        superPanel.itemsPanel.setItems( delta.getItemList( null ) );
        superPanel.itemsPanel.updateList();
        System.out.println( "Composing all" );
        superPanel.build();
        // State Panel
        (( java.awt.CardLayout )superPanel.statePanel.getLayout()).first( superPanel.statePanel );        
        superPanel.setSize( new java.awt.Dimension( 400, 640 ) );
*/        
        System.out.println( "setting layouts" );
        // Configuration Panel
        cp = new ConfigurationPanel( this, useTabSheets );
        cp.addNavikeyGuiListener( superPanel.getNavikeyGuiListener( "Options" ) );

        // Item Panel
        superPanel.itemsPanel.setItems( delta.getItemList( null ) );
        superPanel.itemsPanel.updateList();
        System.out.println( "Composing all" );
        superPanel.build();
        // State Panel
        (( java.awt.CardLayout )superPanel.statePanel.getLayout()).first( superPanel.statePanel );        
        superPanel.setSize( new java.awt.Dimension( 400, 640 ) );

        if( useTabSheets )
        {
            tabbedPane = new javax.swing.JTabbedPane();
            tabbedPane.setBorder( javax.swing.BorderFactory.createEmptyBorder( 3, 3, 3, 3 ) );

            tabbedPane.add( "Identification", superPanel  );
            tabbedPane.add( "Options", cp );
            tabbedPane.add( "About", new About() );
            
            getContentPane().add( java.awt.BorderLayout.CENTER, tabbedPane );
        }
        else
        {
            getContentPane().add( java.awt.BorderLayout.SOUTH, cp );
            // 
            getContentPane().add( java.awt.BorderLayout.CENTER, superPanel );
            // setup Navikey icon
            try
            {
                navikeyIcon = new javax.swing.JLabel( new javax.swing.ImageIcon( new java.net.URL( getCodeBase() + "images/nlogo.gif" ) ) );
                getContentPane().add( java.awt.BorderLayout.NORTH, navikeyIcon );
            }        
            catch( java.net.MalformedURLException ex )
            {
                System.out.println( "NaviKey: image file not available" + ex );
            }
        }
        this.setVisible( true );
        System.out.println( "NaviKey: Done with init" );
    }
    //--------------------------------------------------------------------------
    //--------------------------------------------------------------------------
    public void showResult( String title, javax.swing.JPanel p )
    {
        if( tabbedPane != null )
        {
            int tabCount = tabbedPane.getTabCount(); 
            if( tabCount > 3 )
            {
                tabbedPane.remove( 3 );
            }    
            tabbedPane.add( title, p );
            tabbedPane.setSelectedIndex( 3 );            
        }
    }
    //--------------------------------------------------------------------------
    //--------------------------------------------------------------------------
    private LocalDeltaConnector runStandAlone()
    {
        if( specsfile == null || charsfile == null || itemsfile == null )
        {
            System.out.println( "NaviKey: Required files not specified." );
            System.out.println( "NaviKey: use default filenames: chars, specs, items." );

            specsfile = "specs";
            charsfile = "chars";
            itemsfile = "items";
            // System.exit( 0 );
        }
        try
        {
            URL base = getCodeBase();
            String url = base.toString();
            System.out.println( "Printme " );
            return new LocalDeltaConnector( this, url, specsfile, charsfile, itemsfile );
        }
        catch( Exception e )
        {
            System.out.println( "NaviKey: Error reading delta files.\n" +e );
            System.exit( 0 );
            return new LocalDeltaConnector( this );
        }
    }    
    //--------------------------------------------------------------------------
    //--------------------------------------------------------------------------
    private HttpDeltaConnector runHttpConnector()
    {
        //return new HttpDeltaConnector( "url goes here" );
        return new HttpDeltaConnector( servletURL );
    }
    //--------------------------------------------------------------------------
    //--------------------------------------------------------------------------
    private DnDatabaseConnector runDnDatabaseConnector()
    {
        return new DnDatabaseConnector( this, specsString, charsString, itemsString );
    }
    //--------------------------------------------------------------------------
    //--------------------------------------------------------------------------
    /*
    public void unused_start()
    {
        System.out.println( superPanel.getBounds() );
        
        cp.reshape( cp.getBounds().x, superPanel.getBounds().height, getBounds().width, 35 );
        cp.setBackground( naviKeyBackgroundColor );
        if( naviKeyBackgroundColor.equals( Color.black ) )
        {
            cp.setForeground( Color.white );
        }
        else
        {
            cp.setForeground( Color.black );
        }
        System.out.println( superPanel.getBounds() );
        repaint();
    } 
     */       
    /**
     * @return Returns the excludeUndefined.
     */
    public boolean isExcludeUndefined()
    {
        return excludeUndefined;
    }
    /**
     * @param excludeUndefined The excludeUndefined to set.
     */
    public void setExcludeUndefined( boolean excludeUndefined )
    {
        this.excludeUndefined = excludeUndefined;
    }
    /**
     * @return Returns the extremeInterval.
     */
    public boolean isExtremeInterval()
    {
        return extremeInterval;
    }
    /**
     * @param extremeInterval The extremeInterval to set.
     */
    public void setExtremeInterval( boolean extremeInterval )
    {
        this.extremeInterval = extremeInterval;
    }
    /**
     * @return Returns the intelligence.
     */
    public boolean isIntelligence()
    {
        return intelligence;
    }
    /**
     * @param intelligence The intelligence to set.
     */
    public void setIntelligence( boolean intelligence )
    {
        this.intelligence = intelligence;
    }        
    /**
     * @return Returns the dependenciesFlag.
     */
    public boolean isDependencies()
    {
        return dependenciesFlag;
    }
    /**
     * @param dependenciesFlag The dependenciesFlag to set.
     */
    public void setDependencies( boolean dependenciesFlag )
    {
        this.dependenciesFlag = dependenciesFlag;
    }
    
    /**
     * @return Returns the multipleSelectionOR.
     */
    public boolean isMultipleSelectionOR()
    {
        return multipleSelectionOR;
    }
    /**
     * @param multipleSelectionOR The multipleSelectionOR to set.
     */
    public void setMultipleSelectionOR( boolean multipleSelectionOR )
    {
        this.multipleSelectionOR = multipleSelectionOR;
    }
    /**
     * @return Returns the overlappingInterval.
     */
    public boolean isOverlappingInterval()
    {
        return overlappingInterval;
    }
    /**
     * @param overlappingInterval The overlappingInterval to set.
     */
    public void setOverlappingInterval( boolean overlappingInterval )
    {
        this.overlappingInterval = overlappingInterval;
    }
    
    public boolean isRemoveCharsCommentFlag()
    {
        return removeCharsCommentFlag;        
    }
    public boolean isRemoveItemsCommentFlag()
    {
        return removeItemsCommentFlag;        
    }
    public boolean isRemoveSpecsCommentFlag()
    {
        return removeSpecsCommentFlag;        
    }
    
    public boolean isRemoveCharsStatesCommentFlag()
    {
        return removeCharsStatesCommentFlag;        
    }
    public boolean isRemoveItemsStatesCommentFlag()
    {
        return removeItemsStatesCommentFlag;        
    }
    public boolean isRemoveSpecsStatesCommentFlag()
    {
        return removeSpecsStatesCommentFlag;        
    }
    public boolean isShowLiasUnitsFlag()
    {
        return showLiasUnitsFlag;
    }
    public boolean isUseTabSheetsFlag()
    {
        return useTabSheets;
    }
    /**
     * @return Returns the allItemCount.
     */
    public long getAllItemCount()
    {
        return allItemCount;
    }
    /**
     * @param allItemCount The allItemCount to set.
     */
    public void setAllItemCount( long allItemCount )
    {
        this.allItemCount = allItemCount;
        
        // Update the GUI
        /*
        java.awt.event.ActionEvent ae = new java.awt.event.ActionEvent( this, 1, "OptionsChanged" );        
        superPanel.getNavikeyGuiListener( "Options" ).actionPerformed( ae );                        
        */
        cp.setTotalLabelText( Long.toString( allItemCount ) );
    }
    /**
     * @return Returns the foundItemCount.
     */
    public long getFoundItemCount()
    {
        return foundItemCount;
    }
    /**
     * @param foundItemCount The foundItemCount to set.
     */
    public void setFoundItemCount( long foundItemCount )
    {
        this.foundItemCount = foundItemCount;
        
        // update the GUI
        /*
        java.awt.event.ActionEvent ae = new java.awt.event.ActionEvent( this, 1, "OptionsChanged" );        
        superPanel.getNavikeyGuiListener( "Options" ).actionPerformed( ae );     
        */
        cp.setResultLabelText( Long.toString( foundItemCount ) );
    }

}
