1 26 package org.objectweb.openccm.explorer.Components; 27 28 import java.awt.Component ; 29 import java.awt.Dimension ; 30 import java.awt.GridLayout ; 31 import java.awt.event.ActionEvent ; 32 33 import javax.swing.JOptionPane ; 34 import javax.swing.JPanel ; 35 import javax.swing.JScrollPane ; 36 37 import org.objectweb.openccm.explorer.menu.TreeDialogSingleton; 38 import org.objectweb.util.explorer.api.Entry; 39 import org.objectweb.util.explorer.api.MenuItem; 40 import org.objectweb.util.explorer.api.MenuItemTreeView; 41 import org.objectweb.util.explorer.api.Tree; 42 import org.objectweb.util.explorer.api.TreeView; 43 import org.objectweb.util.explorer.swing.api.Explorer; 44 45 import org.omg.Components.CCMObject; 46 import org.omg.Components.ConsumerDescription; 47 import org.omg.Components.EmitterDescription; 48 49 57 public class ConnectConsumerAction 58 implements MenuItem 59 { 60 61 64 public int getStatus(TreeView arg0){ 65 return MenuItem.ENABLED_STATUS; 66 } 67 68 71 public void actionPerformed(MenuItemTreeView e) throws Exception { 72 EmitterContainer ec = (EmitterContainer) e.getSelectedObject(); 73 EmitterDescription emitter = ec.getEmitter(); 74 CCMObject component = ec.getComponent(); 75 76 org.objectweb.fractal.api.Component tree = TreeDialogSingleton.getInstance(); 77 Explorer explorerItf = (Explorer)tree.getFcInterface(Explorer.EXPLORER); 78 Tree treeItf = (Tree)tree.getFcInterface(Tree.TREE); 79 80 JPanel treePanel = new JPanel (); 81 treePanel.setLayout(new GridLayout (1, 0)); 82 treePanel.setPreferredSize(new Dimension (450, 350)); 83 treePanel.add(new JScrollPane (explorerItf.getTree())); 84 ActionEvent ae = (ActionEvent )e.getEvent(); 85 int result = JOptionPane.showOptionDialog((Component ) ae.getSource(), treePanel, "Select a consumer", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null); 86 if (result == 0) { 87 Entry entry = treeItf.getSelectedEntry(); 88 if (entry != null) { 89 Object object = entry.getValue(); 90 if (object != null) { 91 System.err.println(object); 92 ConsumerDescription consumer = (ConsumerDescription) object; 93 if (component != null && emitter != null && consumer != null) { 94 component.connect_consumer(emitter.name, consumer.consumer); 95 } 96 } 97 } 98 } 99 } 100 101 } 102 | Popular Tags |