1 31 package org.objectweb.proactive.ic2d.gui.data; 32 33 import org.objectweb.proactive.ic2d.data.AbstractDataObject; 34 import org.objectweb.proactive.ic2d.data.HostObject; 35 import org.objectweb.proactive.ic2d.data.VMObject; 36 import org.objectweb.proactive.ic2d.event.HostObjectListener; 37 38 public class HostPanel extends AbstractDataObjectPanel implements HostObjectListener { 39 40 private HostObject hostObject; 41 protected java.awt.Dimension minimumSize = new java.awt.Dimension (150,80); 42 protected PanelPopupMenu popup; 43 44 48 public HostPanel(AbstractDataObjectPanel parentDataObjectPanel, HostObject targetHostObject) { 49 super(parentDataObjectPanel, targetHostObject.getHostName(), "HostObject"); 50 this.hostObject = targetHostObject; 51 setBackground(new java.awt.Color (0xd0, 0xd0, 0xd0)); 56 createBorder(hostObject.getOperatingSystem()); 57 setLayout(new java.awt.FlowLayout (java.awt.FlowLayout.CENTER, 9, 5)); 58 59 popup = new PanelPopupMenu("Host " + name+" OS "+hostObject.getOperatingSystem()); 61 popup.add(new javax.swing.AbstractAction ("Look for new nodes", null) { 62 public void actionPerformed(java.awt.event.ActionEvent e) { 63 hostObject.createAllNodes(); 64 } 65 }); 66 popup.addSeparator(); 67 popup.add(new javax.swing.AbstractAction ("Stop Monitoring this host", null) { 68 public void actionPerformed(java.awt.event.ActionEvent e) { 69 hostObject.destroyObject(); 70 } 71 }); 72 73 addMouseListener(popup.getMenuMouseListener()); 75 76 addMouseMotionListener(new java.awt.event.MouseMotionAdapter () { 77 public void mouseDragged(java.awt.event.MouseEvent e) { 78 if (controller.isLayoutAutomatic()) return; 79 e.translatePoint(getX(), getY()); 80 setLocation(e.getX(), e.getY()); 81 } 82 }); 83 addMouseListener(new java.awt.event.MouseAdapter () { 84 public void mouseReleased(java.awt.event.MouseEvent e) { 85 HostPanel.this.parentDataObjectPanel.revalidate(); 86 HostPanel.this.parentDataObjectPanel.repaint(); 87 } 88 }); 89 } 90 91 92 96 100 public void vmObjectAdded(VMObject vmObject) { 101 VMPanel panel = new VMPanel(this, vmObject); 102 addChild(vmObject, panel); 103 vmObject.registerListener(panel); 104 } 105 106 public void vmObjectRemoved(VMObject vmObject) { 107 removeChild(vmObject); 108 } 109 110 public void operatingSystemFound(String os) { 111 createBorder(os); 112 popup.setName("Host " + name+" OS "+os); 113 repaint(); 114 } 115 116 117 121 protected AbstractDataObject getAbstractDataObject() { 122 return hostObject; 123 } 124 125 126 protected VMPanel getVMPanel(VMObject vmObject) { 127 return (VMPanel) getChild(vmObject); 128 } 129 130 131 protected Object [][] getDataObjectInfo() { 132 return new Object [][] { 133 {"Hostname", name} 134 }; 135 } 136 137 138 protected java.awt.Dimension getMinimumSizeInternal() { 139 return minimumSize; 140 } 141 142 143 protected void setFontSize(java.awt.Font font) { 144 super.setFontSize(font); 145 createBorder(hostObject.getOperatingSystem()); 146 } 147 148 152 private String getNodeNameFromDialog() { 153 Object result = javax.swing.JOptionPane.showInputDialog( 154 parentFrame, "Enter the name of the node to create on host "+hostObject.getHostName(), "Creating a new remote JVM", javax.swing.JOptionPane.PLAIN_MESSAGE ); 159 if (result == null || (! (result instanceof String ))) return null; 160 return (String ) result; 161 } 162 163 164 private void createBorder(String os) { 165 if (os == null) os = "OS Undefined"; 166 setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createMatteBorder(1,1,1,1, new java.awt.Color (0, 0, 128)), name+":"+os, 167 javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, defaultFont)); 168 } 169 170 } 171 172 173 174 | Popular Tags |