1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 package org.coach.actor.componentBrowser; 26 27 import java.awt.*; 28 import javax.swing.*; 29 import org.coach.idltree.*; 30 import org.coach.util.IorPrinter; 31 import org.omg.Components.*; 32 33 public class MethodPanel extends JPanel implements ObjectListener { 34 MethodFrame methodFrame; 35 JPanel treePanel; 36 JPanel emptyReply = new JPanel(); 37 IdlTreePanel operationTree; 38 JScrollPane operationScrollPane; 39 IdlTreePanel replyTree; 40 JScrollPane replyScrollPane; 41 InvokePanel invokePanel; 42 org.omg.CORBA.ORB orb; 43 44 public MethodPanel() { 45 try { 46 this.setLayout(new BorderLayout()); 47 } 48 catch(Exception ex) { 49 ex.printStackTrace(); 50 } 51 } 52 53 public MethodPanel(MethodFrame mf, String id, String facetName, org.omg.CORBA.Object target, org.omg.CORBA.ORB orb) { 54 this(); 55 this.orb = orb; 56 this.methodFrame = mf; 57 invokePanel = new InvokePanel(this, orb); 58 invokePanel.setOperation(id, facetName, target); 59 treePanel = new JPanel(); 60 treePanel.setLayout(new GridLayout(1,2)); 61 setOperation(invokePanel.getModel()); 62 this.add(treePanel, BorderLayout.CENTER); 63 this.add(invokePanel, BorderLayout.SOUTH); 64 } 65 66 public void setReply(IdlModel replyModel) { 67 replyTree = new IdlTreePanel(replyModel); 68 replyTree.addObjectListener(this); 69 replyScrollPane = new JScrollPane(replyTree); 70 treePanel.remove(emptyReply); 71 treePanel.add(replyScrollPane); 72 treePanel.repaint(); 73 repaint(); 74 methodFrame.pack(); 75 } 76 77 public void setOperation(IdlModel operationModel) { 78 treePanel.removeAll(); 79 operationTree = new IdlTreePanel(operationModel); 80 operationTree.addModelListener(invokePanel); 81 operationScrollPane = new JScrollPane(operationTree); 82 treePanel.add(operationScrollPane); 83 clearReply(); 84 methodFrame.pack(); 85 } 86 87 public void clearReply() { 88 replyTree = null; 89 replyScrollPane = null; 90 treePanel.add(emptyReply); 91 treePanel.repaint(); 92 repaint(); 93 } 94 95 98 public void objectAction(String ior) { 99 try { 100 IorPrinter iorPrinter = new IorPrinter(ior); 101 String id = iorPrinter.getTypeId(); 102 org.omg.CORBA.Object obj = orb.string_to_object(ior); 103 try { 104 CCMObject c = CCMObjectHelper.narrow(obj); 106 invokePanel.setOperation(id, "", obj); 109 setOperation(invokePanel.getModel()); 110 } catch (Exception ex) { 112 invokePanel.setOperation(id, "", obj); 115 setOperation(invokePanel.getModel()); 116 } 117 } catch (Exception e) { 118 e.printStackTrace(); 119 } 120 } 121 } | Popular Tags |