1 26 package org.objectweb.openccm.explorer.CosNaming; 27 28 import org.objectweb.util.explorer.api.DropAction; 29 import org.objectweb.util.explorer.api.DropTreeView; 30 import org.objectweb.util.explorer.swing.gui.api.DialogAction; 31 import org.objectweb.util.explorer.swing.gui.api.DialogBox; 32 import org.objectweb.util.explorer.swing.gui.lib.DefaultDialogBox; 33 import org.objectweb.util.explorer.swing.gui.lib.LabelBox; 34 import org.omg.CosNaming.NamingContextExt ; 35 36 44 public class BindObjectOnDropAction 45 implements DropAction, DialogAction { 46 47 53 protected NamingContextExt namingContext_; 54 55 protected LabelBox name_; 56 57 protected org.omg.CORBA.Object object_ = null; 58 59 65 71 77 80 public void execute(DropTreeView dropTreeView) throws Exception { 81 namingContext_ = (NamingContextExt )dropTreeView.getSelectedObject(); 82 String name = dropTreeView.getDragSourceEntry().getName().toString(); 83 Object dragObject = dropTreeView.getDragSourceObject(); 84 85 if(org.omg.CORBA.Object .class.isAssignableFrom(dragObject.getClass())){ 86 object_ = (org.omg.CORBA.Object )dragObject; 87 } else { 88 throw new Exception ("You must select a org.omg.CORBA.Object \n Found : " + dragObject.getClass().getName()); 89 } 90 if(object_ != null) { 91 DialogBox dialog = new DefaultDialogBox("Binds a new object into the NameService"); 92 name_ = new LabelBox("Object name",name); 93 dialog.addElementBox(name_); 94 dialog.setValidateAction(this); 95 dialog.show(); 96 } 97 98 } 99 100 106 109 public void executeAction() throws Exception { 110 namingContext_.rebind(namingContext_.to_name(name_.getLabel()),object_); 111 } 112 113 } | Popular Tags |