1 28 29 30 import javax.swing.Box ; 31 import javax.swing.JOptionPane ; 32 33 34 import org.objectweb.util.browser.api.MenuItem; 35 import org.objectweb.util.browser.api.MenuItemTreeView; 36 import org.objectweb.util.browser.api.TreeView; 37 import org.objectweb.util.browser.gui.lib.LabelBox; 38 39 45 public class InvokeServiceAction 46 implements MenuItem 47 { 48 49 protected LabelBox id_ = null; 50 51 54 protected Box createBox() { 55 Box box = Box.createVerticalBox(); 56 box.add(Box.createVerticalGlue()); 57 id_ = new LabelBox("Value"); 58 box.add(id_); 59 box.add(Box.createVerticalGlue()); 60 return box; 61 } 62 63 public void actionPerformed(MenuItemTreeView e) { 64 Service s = (Service)e.getSelectedObject(); 65 InvokeThread t = new InvokeThread(s); 66 t.start(); 67 } 68 69 72 public int getStatus(TreeView treeView) { 73 return MenuItem.ENABLED_STATUS; 74 } 75 76 public class InvokeThread extends Thread { 77 78 protected Service s_ = null; 79 80 public InvokeThread(Service s) { 81 s_ = s; 82 } 83 84 public void run() { 85 int result = JOptionPane.showOptionDialog(null, createBox(), "Invokes the print method", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null); 86 if (result == 0) { 87 if(id_!=null) { 88 String message = id_.getLabel(); 89 s_.print(message); 90 } 91 } 92 } 93 } 94 95 } | Popular Tags |