1 26 package org.objectweb.openccm.explorer.CosNaming; 27 28 import org.objectweb.util.explorer.api.Entry; 29 import org.objectweb.util.explorer.api.MenuItem; 30 import org.objectweb.util.explorer.api.MenuItemTreeView; 31 import org.objectweb.util.explorer.api.Tree; 32 import org.objectweb.util.explorer.api.TreeView; 33 import org.objectweb.util.explorer.swing.gui.api.DialogAction; 34 import org.objectweb.util.explorer.swing.gui.api.DialogBox; 35 import org.objectweb.util.explorer.swing.gui.lib.DefaultDialogBox; 36 import org.objectweb.util.explorer.swing.gui.lib.LabelBox; 37 import org.omg.CosNaming.NamingContextExt ; 38 39 45 public class RenameBinding 46 implements MenuItem, DialogAction 47 { 48 49 55 protected LabelBox bindingName_ = null; 56 57 protected String currentBindingName_ = null; 58 59 protected org.omg.CORBA.Object bindingObject_ = null; 60 61 protected NamingContextExt naming_ = null; 62 63 protected Tree tree_ = null; 64 65 71 77 80 protected void bind(NamingContextExt naming, String id, org.omg.CORBA.Object o) { 81 try { 82 naming.rebind(naming.to_name(id), o); 83 } catch (org.omg.CosNaming.NamingContextPackage.NotFound e) { 84 System.out.println(getClass().getName() + " : Object Not Found Exception !"); 85 } catch (org.omg.CosNaming.NamingContextPackage.CannotProceed e) { 86 System.out.println(getClass().getName() + " : CannotProceed Exception"); 87 } catch (org.omg.CosNaming.NamingContextPackage.InvalidName e) { 88 System.out.println(getClass().getName() + " : InvalidName Exception"); 89 } 90 } 91 92 98 101 public int getStatus(TreeView arg0){ 102 return MenuItem.ENABLED_STATUS; 103 } 104 105 108 public void actionPerformed(MenuItemTreeView tv) throws Exception { 109 Entry entry = tv.getSelectedEntry(); 110 currentBindingName_ = entry.getName().toString(); 111 naming_ = (NamingContextExt ) tv.getParentObject(); 112 bindingObject_ = (org.omg.CORBA.Object )tv.getSelectedObject(); 113 tree_ = tv.getTree(); 114 115 DialogBox dialog = new DefaultDialogBox("Rename this binding"); 116 bindingName_ = new LabelBox("Binding name",currentBindingName_,true); 117 dialog.addElementBox(bindingName_); 118 dialog.setValidateAction(this); 119 dialog.show(); 120 } 121 122 128 131 public void executeAction() throws Exception { 132 String newName = bindingName_.getLabel(); 133 if(!newName.equals(currentBindingName_)){ 134 naming_.rebind(naming_.to_name(newName), bindingObject_); 135 naming_.unbind(naming_.to_name(currentBindingName_)); 136 tree_.renameSelectedNode(currentBindingName_, newName); 137 } 138 } 139 } 140 | Popular Tags |