package org.objectweb.proactive.ic2d.gui.jobmonitor;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.JFrame;

import org.objectweb.proactive.ic2d.gui.IC2DGUIController;

public class JobMonitorFrame extends JFrame
{
	private static final int DEFAULT_WIDTH = 800;
	private static final int DEFAULT_HEIGHT = 600;

	private JobMonitorPanel panel;

	public JobMonitorFrame (IC2DGUIController controller)
	{
		super ("Job Monitoring");
		setSize (new Dimension (DEFAULT_WIDTH, DEFAULT_HEIGHT));
		
		panel = new JobMonitorPanel (controller);
		
		Container c = getContentPane();
		c.setLayout (new GridLayout (1, 1));
		c.add (panel);
		
		 setJMenuBar (createMenuBar());
	}

	private javax.swing.JMenuBar createMenuBar()
	{
	    javax.swing.JMenuBar menuBar = new javax.swing.JMenuBar();
	    	    
	    javax.swing.JMenu monitoringMenu = new javax.swing.JMenu("Monitoring");

	    javax.swing.JMenuItem b = new javax.swing.JMenuItem("Monitor a new RMI host");
	    b.addActionListener(new java.awt.event.ActionListener()
	    {
	        public void actionPerformed(java.awt.event.ActionEvent e)
	        {
				String initialHostValue = "localhost";
			    try {
			      initialHostValue = java.net.InetAddress.getLocalHost().getCanonicalHostName();
			    } catch (java.net.UnknownHostException exc) {
			    }
			    Object result = javax.swing.JOptionPane.showInputDialog(panel, // Component parentComponent,
			        "Please enter the name or the IP of the host to monitor :", // Object message,
			        "Adding a host to monitor", // String title,
			        javax.swing.JOptionPane.PLAIN_MESSAGE, // int messageType,
			        null, // Icon icon,
			        null, // Object[] selectionValues,
			        initialHostValue // Object initialSelectionValue)
			      );
			    if (result == null || (!(result instanceof String)))
			      return;
			    String host = (String) result;
			    
			    panel.addMonitoredHost (host);
			    panel.updateHosts ();
	        }
	    });
	    monitoringMenu.add(b);
	    
	    menuBar.add (monitoringMenu);

	    // control menu
	    javax.swing.JMenu controlMenu = new javax.swing.JMenu ("Control");

	    b = new javax.swing.JMenuItem ("Set Time-To-Refresh");
	    b.addActionListener(new java.awt.event.ActionListener()
	    {
	        public void actionPerformed (java.awt.event.ActionEvent e)
	        {
	        	String initialValue = "" + panel.getTtr();
			    Object result = javax.swing.JOptionPane.showInputDialog(panel, // Component parentComponent,
			        "Please enter the time to refresh, in seconds :", // Object message,
			        "Setting the time to refresh", // String title,
			        javax.swing.JOptionPane.PLAIN_MESSAGE, // int messageType,
			        null, // Icon icon,
			        null, // Object[] selectionValues,
			        initialValue // Object initialSelectionValue)
			      );
			    if (result == null || (!(result instanceof String)))
			      return;
			    
			    try
				{
					int ttr = Integer.parseInt ((String) result);
					panel.setTtr (ttr);
				}
				catch (NumberFormatException exc)
				{
//					System.out.println ("The ttr number is invalid !");
					return;
				}
	        }
	    });
	    controlMenu.add(b);
	    
	    b = new javax.swing.JMenuItem ("Set Depth Control");
	    b.addActionListener(new java.awt.event.ActionListener()
	    {
	        public void actionPerformed(java.awt.event.ActionEvent e)
	        {
//	        	System.out.println ("Set depth control asked");
	        }
	    });
	    controlMenu.add(b);
	    
	    menuBar.add (controlMenu);
	    
	    return menuBar;
	}
	
	public void hide()
	{
		super.hide();
		
		panel.hideOwnedFrames();
	}
	
	public void show()
	{
		super.show();
	
		panel.showOwnedFrames();
	}
}
@@ -149,22 +149,17 @@
 x.swing.
-JFrame
+*
 ;%0A%0Aimpor
@@ -723,28 +723,16 @@
 private 
-javax.swing.
 JMenuBar
@@ -752,36 +752,24 @@
 r()%0A%09%7B%0A%09    
-javax.swing.
 JMenuBar men
@@ -775,36 +775,24 @@
 nuBar = new 
-javax.swing.
 JMenuBar();%0A
@@ -803,36 +803,24 @@
  %09    %0A%09    
-javax.swing.
 JMenu monito
@@ -830,36 +830,24 @@
 gMenu = new 
-javax.swing.
 JMenu(%22Monit
@@ -857,36 +857,24 @@
 ng%22);%0A%0A%09    
-javax.swing.
 JMenuItem b 
@@ -875,36 +875,24 @@
 tem b = new 
-javax.swing.
 JMenuItem(%22M
@@ -1287,36 +1287,24 @@
 ct result = 
-javax.swing.
 JOptionPane.
@@ -1509,36 +1509,24 @@
 %0A%09%09%09        
-javax.swing.
 JOptionPane.
@@ -2016,28 +2016,16 @@
 nu%0A%09    
-javax.swing.
 JMenu co
@@ -2036,36 +2036,24 @@
 lMenu = new 
-javax.swing.
 JMenu (%22Cont
@@ -2069,36 +2069,24 @@
     b = new 
-javax.swing.
 JMenuItem (%22
@@ -2331,28 +2331,16 @@
 esult = 
-javax.swing.
 JOptionP
@@ -2546,28 +2546,16 @@
         
-javax.swing.
 JOptionP
@@ -3109,28 +3109,16 @@
 b = new 
-javax.swing.
 JMenuIte

Package names are useless here