/* ======================================================================
   Parts Copyright 2006 University of Leeds, Oxford University, University of the Highlands and Islands.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

====================================================================== */

package org.bodington.applet;

import org.bodington.applet.components.*;
import org.bodington.applet.data.*;
import org.bodington.applet.test.*;

import java.awt.datatransfer.*;
import java.awt.event.*;
import javax.swing.*;
import java.beans.*;
import java.awt.*;
import java.net.*;

public class BodingtonDesktopPane extends javax.swing.JDesktopPane
    {
    URL base;
    Clipboard clipboard;
    LocalFileFrame lframe = null;
    RemoteFileFrame rframe = null;
    MenuFrame mframe = null;
    
    public static BodingtonDesktopPane findInstance( Component comp )
	{
	Component parent=comp;
	while ( parent!=null && !BodingtonDesktopPane.class.isAssignableFrom( parent.getClass() ) )
	    parent = parent.getParent();
	return (BodingtonDesktopPane)parent;
	}
    
	public BodingtonDesktopPane()
    	{
    	super();
	    }
	
	public void setBodingtonResourceUrl( URL url )
	    {
	    base = url;
	    }
	
	public void init()
	    {
	    clipboard = new Clipboard( "Bodington Applet Clipboard" );
	        
    	lframe = new LocalFileFrame();
    	lframe.setClipboard( clipboard );
	    lframe.setLocation( 20, 20 );
	    lframe.setSize( 400, 200 );
    	add( lframe );
    	lframe.setVisible( true );
    	
    	
    	rframe = new RemoteFileFrame( base );
    	rframe.setClipboard( clipboard );
	    rframe.setLocation( 60, 100 );
	    rframe.setSize( 400, 200 );
    	add( rframe );
    	rframe.setVisible( true );
    	

    	mframe = new MenuFrame( base );
    	mframe.setClipboard( clipboard );
	    mframe.setLocation( 100, 180 );
	    mframe.setSize( 400, 200 );
    	add( mframe );
    	mframe.setVisible( true );
    	
	// make sure the remote file frame has reference to its
	// corresponding menu frame
	rframe.setMenuFrame( mframe );
	
    	/*
    	DNDFrame dndframe = new DNDFrame();
    	dndframe.setLocation( 20, 20 );
    	dndframe.setSize( 400, 200 );
    	dndframe.setVisible( true );
    	
    	DNDFrame dndframe2 = new DNDFrame();
    	dndframe2.setLocation( 20, 20 );
    	dndframe2.setSize( 400, 200 );
    	dndframe2.setVisible( true );
    	
    	DNDInternalFrame dndframe3 = new DNDInternalFrame();
    	dndframe3.setLocation( 20, 20 );
    	dndframe3.setSize( 400, 200 );
    	add( dndframe3 );
    	dndframe3.setVisible( true );
    	*/
    	
    	/*
    	PackageEditFrame pframe = new PackageEditFrame( base );
	    pframe.setLocation( 20, 20 );
	    pframe.setSize( 400, 200 );
    	add( pframe );
    	pframe.setVisible( true );
    	*/
	    }
	    
	public RemoteFileFrame getRemoteFileFrame()
	    {
	    return rframe;
	    }
	public LocalFileFrame getLocalFileFrame()
	    {
	    return lframe;
	    }
	public MenuFrame getMenuFrame()
	    {
	    return mframe;
	    }
    }
