1 26 27 package org.objectweb.openccm.explorer.CosTrading.gui; 28 29 import java.io.BufferedReader ; 30 import java.io.FileReader ; 31 32 import javax.swing.Box ; 33 import javax.swing.JPanel ; 34 35 import org.objectweb.openccm.explorer.menu.BrowserPanel; 36 import org.objectweb.openccm.explorer.menu.OpenCCMBrowserConstants; 37 import org.omg.CORBA.ORB ; 38 import org.omg.CosTrading.FollowOption; 39 import org.omg.CosTrading.Lookup; 40 import org.omg.CosTrading.LookupHelper; 41 42 46 public class AddLinkPanel 47 extends JPanel 48 { 49 50 56 57 protected BrowserPanel lbp_; 58 59 60 protected FollowOptionBox def_; 61 62 63 protected FollowOptionBox limit_; 64 65 71 74 public AddLinkPanel() { 75 Box b = Box.createVerticalBox(); 76 b.add(Box.createVerticalGlue()); 77 78 lbp_ = new BrowserPanel("Link Name: ", "Choose an IOR File: ", OpenCCMBrowserConstants.IOR_FILE_CHOOSER); 80 b.add(lbp_); 81 82 b.add(Box.createVerticalStrut(10)); 83 84 def_ = new FollowOptionBox("Default Follow Link Rule: "); 86 b.add(def_); 87 88 b.add(Box.createVerticalStrut(10)); 89 90 limit_ = new FollowOptionBox("Limiting Follow Link Rule: "); 92 b.add(limit_); 93 94 b.add(Box.createVerticalGlue()); 95 96 add(b); 97 } 98 99 105 111 116 public String getName() { 117 return lbp_.getLabel(); 118 } 119 120 125 public Lookup getLookupRef() { 126 Lookup ref = null; 127 if (lbp_.getFile() != null) { 128 java.io.File file = lbp_.getFile(); 129 String ior = null; 130 try { 131 BufferedReader in = new BufferedReader (new FileReader (file)); 132 ior = in.readLine(); 133 } catch (java.io.FileNotFoundException err) { 134 System.err.println(file + ": File not found !"); 135 } catch (java.io.IOException err) { 136 System.err.println(file + ": Error while reading !"); 137 } 138 if (ior != null && ior.startsWith("IOR:")) { 139 ORB orb = org.objectweb.openccm.corba.TheORB.getORB(); 140 ref = LookupHelper.narrow(orb.string_to_object(ior)); 141 } 142 } else if (lbp_.getSelectedObject() != null) { 143 ref = (Lookup)lbp_.getSelectedObject(); 144 } 145 return ref; 146 } 147 148 153 public FollowOption getDefPassOn() { 154 return def_.getOption(); 155 } 156 157 162 public FollowOption getLimiting() { 163 return limit_.getOption(); 164 } 165 } 166 167 | Popular Tags |