1 31 package org.objectweb.proactive.ic2d.gui.data; 32 33 import java.awt.Color ; 34 35 import org.objectweb.proactive.ic2d.data.AbstractDataObject; 36 import org.objectweb.proactive.ic2d.data.NodeObject; 37 import org.objectweb.proactive.ic2d.data.SpyListenerImpl; 38 import org.objectweb.proactive.ic2d.data.VMObject; 39 import org.objectweb.proactive.ic2d.event.VMObjectListener; 40 41 public class VMPanel extends AbstractDataObjectPanel implements VMObjectListener { 42 43 private VMObject vmObject; 44 45 49 public VMPanel(AbstractDataObjectPanel parentDataObjectPanel, VMObject targetVMObject) { 50 super(parentDataObjectPanel, "VM id="+targetVMObject.getID().toString(), "VMObject"); 51 activeObjectFilter.addClass(SpyListenerImpl.class.getName()); 52 this.vmObject = targetVMObject; 53 this.setLayout(new java.awt.GridLayout (1, 0, 4, 4)); 54 if (targetVMObject.getProtocolId().indexOf("globus")>=0){ 55 this.setBackground(new Color (0xff, 0xd0, 0xd0)); 56 } 57 createBorder(name); 58 59 PanelPopupMenu popup = new PanelPopupMenu(name); 61 popup.add(new javax.swing.AbstractAction ("Look for new Active Objects", null) { 62 public void actionPerformed(java.awt.event.ActionEvent e) { 63 vmObject.sendEventsForAllActiveObjects(); 64 } 65 }); 66 popup.add(new javax.swing.AbstractAction ("Set update frequence", null) { 67 public void actionPerformed(java.awt.event.ActionEvent e) { 68 changeUpdateFrequence(); 69 } 70 }); 71 popup.addSeparator(); 72 popup.add(new javax.swing.AbstractAction ("Stop monitoring this VM", null) { 73 public void actionPerformed(java.awt.event.ActionEvent e) { 74 vmObject.destroyObject(); 75 } 76 }); 77 78 addMouseListener(popup.getMenuMouseListener()); 79 } 80 81 82 83 87 91 public void nodeObjectAdded(NodeObject nodeObject) { 92 NodePanel panel = new NodePanel(this, nodeObject); 93 addChild(nodeObject, panel); 94 nodeObject.registerListener(panel); 95 } 96 97 98 public void nodeObjectRemoved(NodeObject nodeObject) { 99 removeChild(nodeObject); 100 } 101 102 103 104 108 protected AbstractDataObject getAbstractDataObject() { 109 return vmObject; 110 } 111 112 113 protected NodePanel getNodePanel(NodeObject nodeObject) { 114 return (NodePanel) getChild(nodeObject); 115 } 116 117 118 protected Object [][] getDataObjectInfo() { 119 return new Object [][] { 120 {"ID",vmObject.getID()}, 121 {"Active objects",new Integer (vmObject.getActiveObjectsCount())}, 122 {"Protocol identifier",vmObject.getProtocolId()} 123 }; 124 } 125 126 127 protected void setFontSize(java.awt.Font font) { 128 super.setFontSize(font); 129 createBorder(name); 130 } 131 132 133 137 private void changeUpdateFrequence() { 138 Object result = javax.swing.JOptionPane.showInputDialog( 139 parentFrame, "Please enter the new value for the frequence of the update for vm id="+vmObject.getID(), "Spy updates frequence", javax.swing.JOptionPane.PLAIN_MESSAGE, null, null, new Long (vmObject.getUpdateFrequence()) ); 147 if (result == null || (! (result instanceof String ))) return; 148 try { 149 long f = Long.parseLong((String ) result); 150 controller.log("Setting spy update frequence for VM " + vmObject.getID() + " to " + f + " ms"); 151 vmObject.setUpdateFrequence(f); 152 } catch (NumberFormatException e) { 153 } 154 } 155 156 157 private void createBorder(String name) { 158 setBorder(javax.swing.BorderFactory.createTitledBorder(null, name, 159 javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, defaultFont)); 160 } 161 162 } 163 | Popular Tags |