1 31 package org.objectweb.proactive.ic2d.gui.util; 32 33 import java.awt.Component ; 34 35 import org.objectweb.proactive.ic2d.data.WorldObject; 36 import org.objectweb.proactive.ic2d.gui.data.IC2DPanel; 37 import org.objectweb.proactive.ic2d.gui.dialog.FilteredClassesPanel; 38 import org.objectweb.proactive.ic2d.util.ActiveObjectFilter; 39 import org.objectweb.proactive.ic2d.util.IC2DMessageLogger; 40 41 public class DialogUtils { 42 43 private DialogUtils() { 44 } 45 46 public static void openNewRMIHostDialog( 47 java.awt.Component parentComponent, 48 WorldObject worldObject, 49 IC2DMessageLogger logger) { 50 String initialHostValue = "localhost"; 51 try { 52 initialHostValue = java.net.InetAddress.getLocalHost().getCanonicalHostName(); 53 } catch (java.net.UnknownHostException e) { 54 } 55 Object result = javax.swing.JOptionPane.showInputDialog(parentComponent, "Please enter the name or the IP of the host to monitor :", "Adding a host to monitor", javax.swing.JOptionPane.PLAIN_MESSAGE, null, null, initialHostValue ); 63 if (result == null || (!(result instanceof String ))) 64 return; 65 String host = (String ) result; 66 try { 67 worldObject.addHostObject(host, "rmi"); 68 } catch (java.rmi.RemoteException e) { 69 logger.log("Cannot create the RMI Host " + host, e); 70 } 71 } 72 73 74 public static void openNewIbisHostDialog( 75 java.awt.Component parentComponent, 76 WorldObject worldObject, 77 IC2DMessageLogger logger) { 78 String initialHostValue = "localhost"; 79 try { 80 initialHostValue = java.net.InetAddress.getLocalHost().getCanonicalHostName(); 81 } catch (java.net.UnknownHostException e) { 82 } 83 Object result = javax.swing.JOptionPane.showInputDialog(parentComponent, "Please enter the name or the IP of the host to monitor :", "Adding a host to monitor", javax.swing.JOptionPane.PLAIN_MESSAGE, null, null, initialHostValue ); 91 if (result == null || (!(result instanceof String ))) 92 return; 93 String host = (String ) result; 94 try { 95 worldObject.addHostObject(host, "ibis"); 96 } catch (java.rmi.RemoteException e) { 97 logger.log("Cannot create the Ibis Host " + host, e); 98 } 99 } 100 101 110 111 public static void openNewJINIHostDialog( 112 java.awt.Component parentComponent, 113 WorldObject worldObject, 114 IC2DMessageLogger logger) { 115 String initialHostValue = "localhost"; 116 try { 117 initialHostValue = java.net.InetAddress.getLocalHost().getCanonicalHostName(); 118 } catch (java.net.UnknownHostException e) { 119 } 120 Object result = javax.swing.JOptionPane.showInputDialog(parentComponent, "Please enter the name or the IP of the host to monitor :", "Adding a host to monitor", javax.swing.JOptionPane.PLAIN_MESSAGE, null, null, initialHostValue ); 128 if (result == null || (!(result instanceof String ))) 129 return; 130 String host = (String ) result; 131 System.out.println("host "+host); 132 worldObject.addHosts(host); 133 134 } 135 136 public static void openNewNodeDialog( 137 java.awt.Component parentComponent, 138 WorldObject worldObject, 139 IC2DMessageLogger logger) { 140 Object result = javax.swing.JOptionPane.showInputDialog(parentComponent, "Please enter the URL of the node in the form //hostname/nodename :", "Adding a JVM to monitor", javax.swing.JOptionPane.PLAIN_MESSAGE, null, null, "//hostname/nodename" ); 148 if (result == null || (!(result instanceof String ))) 149 return; 150 String url = (String ) result; 151 int n1 = url.indexOf("//"); 152 int n2 = url.lastIndexOf("/"); 153 if (n1 == -1 || n2 == -1 || n2 <= n1 + 1) { 154 logger.warn(url + " isn't an proper node url !"); 155 return; 156 } 157 String host = url.substring(n1 + 2, n2); 158 String nodeName = url.substring(n2 + 1); 159 try { 160 worldObject.addHostObject(host, nodeName); 161 } catch (java.rmi.RemoteException e) { 162 logger.log("Cannot create the RMI Host " + host, e); 163 } 164 } 165 166 public static void displayMessageDialog(java.awt.Component parentComponent, Object message) { 167 javax.swing.JOptionPane.showMessageDialog(parentComponent, message, "IC2D Message", javax.swing.JOptionPane.INFORMATION_MESSAGE ); 172 } 173 174 public static void displayWarningDialog(java.awt.Component parentComponent, Object message) { 175 javax.swing.JOptionPane.showMessageDialog(parentComponent, message, "IC2D Message", javax.swing.JOptionPane.WARNING_MESSAGE ); 180 } 181 182 183 public static void openFilteredClassesDialog(java.awt.Component parentComponent, IC2DPanel ic2dPanel, ActiveObjectFilter filter) { 184 FilteredClassesPanel panel = new FilteredClassesPanel(filter); 185 int result = javax.swing.JOptionPane.showOptionDialog(parentComponent, panel, "Filtered classes dialog", javax.swing.JOptionPane.OK_CANCEL_OPTION, javax.swing.JOptionPane.PLAIN_MESSAGE, null, null, null 193 ); 194 if (result != javax.swing.JOptionPane.OK_OPTION) return; 195 if (panel.updateFilter(filter)) { 196 ic2dPanel.updateFilteredClasses(); 197 } 198 } 199 200 203 209 public static void openNewGlobusHostDialog( 210 Component parentComponent, 211 WorldObject worldObject, 212 IC2DMessageLogger logger) 213 { 214 String initialHostValue = "localhost"; 215 try { 216 initialHostValue = java.net.InetAddress.getLocalHost().getCanonicalHostName(); 217 } catch (java.net.UnknownHostException e) { 218 e.printStackTrace(); 219 } 220 Object result = javax.swing.JOptionPane.showInputDialog(parentComponent, "Please enter the name or the IP of the Globus host to monitor :", "Adding a host to monitor", javax.swing.JOptionPane.PLAIN_MESSAGE, null, null, initialHostValue ); 228 if (result == null || (!(result instanceof String ))) 229 return; 230 String host = (String ) result; 231 try { 232 worldObject.addHostObject(host, "rmi"); 233 worldObject.addHosts(host); 234 } catch (java.rmi.RemoteException e) { 235 logger.log("Cannot create the Globus Host " + host, e); 236 } 237 } 238 239 } 240 | Popular Tags |