1 26 27 package org.objectweb.openccm.explorer.CosTrading.gui; 28 29 import java.awt.Color ; 30 31 import javax.swing.Box ; 32 import javax.swing.BoxLayout ; 33 import javax.swing.JPanel ; 34 import javax.swing.border.TitledBorder ; 35 36 import org.objectweb.openccm.explorer.menu.LabelBox; 37 import org.omg.CosTrading.Admin; 38 import org.omg.CosTrading.FollowOption; 39 40 46 public class AdminPanel 47 extends DefaultNodeViewPanel 48 { 49 50 56 57 protected Admin admin_; 58 59 65 67 public AdminPanel() { 68 setBackground(Color.white); 69 setLayout(new BoxLayout (this, BoxLayout.Y_AXIS)); 70 } 71 72 78 85 protected JPanel addSupportAttributes() { 86 JPanel supportPanel = new JPanel (); 87 supportPanel.setBackground(Color.white); 88 supportPanel.setBorder(new TitledBorder (null," Support attributes ",TitledBorder.CENTER,TitledBorder.TOP)); 89 90 Box box = Box.createVerticalBox(); 91 92 BooleanBox supports_modifiable_properties = new BooleanBox("Supports of modifiable properties: ", 94 admin_.supports_modifiable_properties()); 95 supports_modifiable_properties.addItemListener(new AbstractItemListener(admin_) 96 { 97 protected void doAdminAction(Object modified_item) { 98 adm_.set_supports_modifiable_properties(new Boolean ((String )modified_item).booleanValue()); 99 } 100 }); 101 supports_modifiable_properties.setToolTipText("Whether the trader supports property modification."); 102 103 BooleanBox supports_dynamic_properties = new BooleanBox("Supports of dynamic properties: ", 105 admin_.supports_dynamic_properties()); 106 supports_dynamic_properties.addItemListener(new AbstractItemListener(admin_) 107 { 108 protected void doAdminAction(Object modified_item) { 109 adm_.set_supports_dynamic_properties(new Boolean ((String )modified_item).booleanValue()); 110 } 111 }); 112 supports_dynamic_properties.setToolTipText("Whether the trader supports dynamic properties."); 113 114 BooleanBox supports_proxy_offers = new BooleanBox("Supports of proxy offers: ", 116 admin_.supports_proxy_offers()); 117 supports_proxy_offers.addItemListener(new AbstractItemListener(admin_) 118 { 119 protected void doAdminAction(Object modified_item) { 120 adm_.set_supports_proxy_offers(new Boolean ((String )modified_item).booleanValue()); 121 } 122 }); 123 supports_proxy_offers.setToolTipText("Whether the trader supports proxy offers."); 124 125 box.add(supports_modifiable_properties); 126 box.add(Box.createVerticalStrut(10)); 127 box.add(supports_dynamic_properties); 128 box.add(Box.createVerticalStrut(10)); 129 box.add(supports_proxy_offers); 130 131 supportPanel.add(box); 132 133 return supportPanel; 134 } 135 136 143 protected JPanel addLinkAttributes() { 144 JPanel linkAttrPanel = new JPanel (); 145 linkAttrPanel.setBackground(Color.white); 146 linkAttrPanel.setBorder(new TitledBorder (null," Link attributes ",TitledBorder.CENTER,TitledBorder.TOP)); 147 148 FollowOptionBox max_link_follow_policy = new FollowOptionBox("Maximum link follow policy allowed: ", 150 admin_.max_link_follow_policy()); 151 max_link_follow_policy.addItemListener(new AbstractItemListener(admin_) 152 { 153 protected void doAdminAction(Object modified_item) { 154 FollowOption opt; 155 String value = (String )modified_item; 156 if (value.equals("local_only")) opt = FollowOption.local_only; 157 else if (value.equals("if_no_local")) opt = FollowOption.if_no_local; 158 else opt = FollowOption.always; 159 adm_.set_max_link_follow_policy(opt); 160 } 161 }); 162 max_link_follow_policy.setToolTipText("Most permissive follow policy " + 163 "allowed when creating new links."); 164 165 Box box = Box.createVerticalBox(); 166 box.add(max_link_follow_policy); 167 168 linkAttrPanel.add(box); 169 170 return linkAttrPanel; 171 } 172 173 180 protected JPanel addImportAttributes() { 181 JPanel importAttrPanel = new JPanel (); 182 importAttrPanel.setBackground(Color.white); 183 importAttrPanel.setBorder(new TitledBorder (null," Import attributes ",TitledBorder.CENTER,TitledBorder.TOP)); 184 185 LabelBox def_search_card = new LabelBox("Default search cardinality: ", String.valueOf(admin_.def_search_card())); 187 def_search_card.addActionListener(new AbstractTextActionListener(admin_) 188 { 189 protected void doAdminAction(java.awt.event.ActionEvent e) { 190 adm_.set_def_search_card(Integer.parseInt(e.getActionCommand())); 191 } 192 }); 193 def_search_card.setToolTipText("Default upper bound of offers to be searched for a query operation."); 194 195 LabelBox max_search_card = new LabelBox("Maximum search cardinality: ", String.valueOf(admin_.max_search_card())); 197 max_search_card.addActionListener(new AbstractTextActionListener(admin_) 198 { 199 protected void doAdminAction(java.awt.event.ActionEvent e) { 200 adm_.set_max_search_card(Integer.parseInt(e.getActionCommand())); 201 } 202 }); 203 max_search_card.setToolTipText("Maximum upper bound of offers to be searched for a query operation."); 204 205 LabelBox def_match_card = new LabelBox("Default match cardinality: ", String.valueOf(admin_.def_match_card())); 207 def_match_card.addActionListener(new AbstractTextActionListener(admin_) 208 { 209 protected void doAdminAction(java.awt.event.ActionEvent e) { 210 adm_.set_def_match_card(Integer.parseInt(e.getActionCommand())); 211 } 212 }); 213 def_match_card.setToolTipText("Default upper bound of matched offers to be ordered in applying a preference criteria."); 214 215 LabelBox max_match_card = new LabelBox("Maximum match cardinality: ", String.valueOf(admin_.max_match_card())); 217 max_match_card.addActionListener(new AbstractTextActionListener(admin_) 218 { 219 protected void doAdminAction(java.awt.event.ActionEvent e) { 220 adm_.set_max_match_card(Integer.parseInt(e.getActionCommand())); 221 } 222 }); 223 max_match_card.setToolTipText("Maximum upper bound of matched offers to be ordered in applying a preference criteria."); 224 225 LabelBox def_return_card = new LabelBox("Default return cardinality: ", String.valueOf(admin_.def_return_card())); 227 def_return_card.addActionListener(new AbstractTextActionListener(admin_) 228 { 229 protected void doAdminAction(java.awt.event.ActionEvent e) { 230 adm_.set_def_return_card(Integer.parseInt(e.getActionCommand())); 231 } 232 }); 233 def_return_card.setToolTipText("Default upper bound of ordered offers to be returned to an importer."); 234 235 LabelBox max_return_card = new LabelBox("Maximum return cardinality: ", String.valueOf(admin_.max_return_card())); 237 max_return_card.addActionListener(new AbstractTextActionListener(admin_) 238 { 239 protected void doAdminAction(java.awt.event.ActionEvent e) { 240 adm_.set_max_return_card(Integer.parseInt(e.getActionCommand())); 241 } 242 }); 243 max_return_card.setToolTipText("Maximum upper bound of ordered offers to be returned to an importer."); 244 245 LabelBox max_list = new LabelBox("Maximum list size: ", String.valueOf(admin_.max_list())); 247 max_list.addActionListener(new AbstractTextActionListener(admin_) 248 { 249 protected void doAdminAction(java.awt.event.ActionEvent e) { 250 adm_.set_max_list(Integer.parseInt(e.getActionCommand())); 251 } 252 }); 253 max_list.setToolTipText("The upper bound on the size of any list returned by the trader."); 254 255 LabelBox def_hop_count = new LabelBox("Default hop count: ", String.valueOf(admin_.def_hop_count())); 257 def_hop_count.addActionListener(new AbstractTextActionListener(admin_) 258 { 259 protected void doAdminAction(java.awt.event.ActionEvent e) { 260 adm_.set_def_hop_count(Integer.parseInt(e.getActionCommand())); 261 } 262 }); 263 def_hop_count.setToolTipText("Default upper bound of depth of links to be traversed."); 264 265 LabelBox max_hop_count = new LabelBox("Maximum hop count: ", String.valueOf(admin_.max_hop_count())); 267 def_hop_count.addActionListener(new AbstractTextActionListener(admin_) 268 { 269 protected void doAdminAction(java.awt.event.ActionEvent e) { 270 adm_.set_def_hop_count(Integer.parseInt(e.getActionCommand())); 271 } 272 }); 273 max_hop_count.setToolTipText("Maximum upper bound of depth of links to be traversed."); 274 275 FollowOptionBox def_follow_policy = new FollowOptionBox("Default follow policy: ", 277 admin_.def_follow_policy()); 278 def_follow_policy.addItemListener(new AbstractItemListener(admin_) 279 { 280 protected void doAdminAction(Object modified_item) { 281 FollowOption opt; 282 String value = (String )modified_item; 283 if (value.equals("local_only")) opt = FollowOption.local_only; 284 else if (value.equals("if_no_local")) opt = FollowOption.if_no_local; 285 else opt = FollowOption.always; 286 adm_.set_def_follow_policy(opt); 287 } 288 }); 289 def_follow_policy.setToolTipText("Default link follow behavior for a particular trader."); 290 291 FollowOptionBox max_follow_policy = new FollowOptionBox("Maximum follow policy: ", 293 admin_.max_follow_policy()); 294 max_follow_policy.addItemListener(new AbstractItemListener(admin_) 295 { 296 protected void doAdminAction(Object modified_item) { 297 FollowOption opt; 298 String value = (String )modified_item; 299 if (value.equals("local_only")) opt = FollowOption.local_only; 300 else if (value.equals("if_no_local")) opt = FollowOption.if_no_local; 301 else opt = FollowOption.always; 302 adm_.set_max_follow_policy(opt); 303 } 304 }); 305 max_follow_policy.setToolTipText("Limiting link follow policy for all links of the trader - overrides both link and importer policies."); 306 307 308 Box box = Box.createVerticalBox(); 310 box.add(def_search_card); 311 box.add(Box.createVerticalStrut(10)); 312 box.add(max_search_card); 313 box.add(Box.createVerticalStrut(10)); 314 box.add(def_match_card); 315 box.add(Box.createVerticalStrut(10)); 316 box.add(max_match_card); 317 box.add(Box.createVerticalStrut(10)); 318 box.add(def_return_card); 319 box.add(Box.createVerticalStrut(10)); 320 box.add(max_return_card); 321 box.add(Box.createVerticalStrut(10)); 322 box.add(max_list); 323 box.add(Box.createVerticalStrut(10)); 324 box.add(def_hop_count); 325 box.add(Box.createVerticalStrut(10)); 326 box.add(max_hop_count); 327 box.add(Box.createVerticalStrut(10)); 328 box.add(def_follow_policy); 329 box.add(Box.createVerticalStrut(10)); 330 box.add(max_follow_policy); 331 importAttrPanel.add(box); 332 333 return importAttrPanel; 334 } 335 336 343 protected JPanel addOtherAttributes() { 344 JPanel otherAttrPanel = new JPanel (); 345 otherAttrPanel.setBackground(Color.white); 346 otherAttrPanel.setBorder(new TitledBorder (null," Other attributes ",TitledBorder.CENTER,TitledBorder.TOP)); 347 348 LabelBox request_id_stem = new LabelBox("request_id_stem: ", new String (admin_.request_id_stem())); 350 request_id_stem.addActionListener(new AbstractTextActionListener(admin_) 351 { 352 protected void doAdminAction(java.awt.event.ActionEvent e) { 353 adm_.set_request_id_stem(e.getActionCommand().getBytes()); 354 } 355 }); 356 request_id_stem.setToolTipText("Identification of the trader, to be \n" + 357 "used as the stem for the production of \n" + 358 "an id for a query request from one trader \n" + 359 "to another."); 360 361 Box box = Box.createVerticalBox(); 362 box.add(request_id_stem); 363 otherAttrPanel.add(box); 364 365 return otherAttrPanel; 366 } 367 368 374 377 public void onSetTreeView() { 378 if (getTreeView() == null) return; 379 admin_ = (Admin)getTreeView().getSelectedObject(); 380 if (admin_ != null) { 381 add(addSupportAttributes()); 382 add(addLinkAttributes()); 383 add(addImportAttributes()); 384 add(addOtherAttributes()); 385 } 386 } 387 } 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | Popular Tags |