1 18 19 package org.objectweb.jac.aspects.gui; 20 21 import java.util.Collection ; 22 import java.util.HashMap ; 23 import java.util.Hashtable ; 24 import java.util.List ; 25 import java.util.Map ; 26 import java.util.Vector ; 27 import org.apache.log4j.Logger; 28 import org.objectweb.jac.core.rtti.AbstractMethodItem; 29 import org.objectweb.jac.core.rtti.ClassItem; 30 import org.objectweb.jac.core.rtti.MemberItem; 31 import org.objectweb.jac.core.rtti.MethodItem; 32 33 51 52 public class CustomizedGUI { 53 static Logger logger = Logger.getLogger("gui"); 54 55 57 Hashtable paneContents = new Hashtable (); 59 Hashtable paneContainers = new Hashtable (); 61 Hashtable splitters = new Hashtable (); 63 Hashtable invalidPanes = new Hashtable (); 65 66 68 public static final int HORIZONTAL = 0; 69 70 public static final int HORIZONTAL_UP = 1; 71 72 public static final int HORIZONTAL_DOWN = 2; 73 74 public static final int VERTICAL = 3; 75 76 public static final int VERTICAL_LEFT = 4; 77 78 public static final int VERTICAL_RIGHT = 5; 79 80 public static final String BOTTOM = "BOTTOM"; 81 public static final String TOP = "TOP"; 82 83 public void setInvalidPane(String changedPane, String invalidPane) { 84 invalidPanes.put(changedPane,invalidPane); 85 } 86 87 public String getInvalidPane(String changedPane) { 88 return (String )invalidPanes.get(changedPane); 89 } 90 91 96 int subPanesCount= 1; 97 public int getSubPanesCount() { 98 return subPanesCount; 99 } 100 101 int geometry = 0; 102 public int getGeometry() { 103 return geometry; 104 } 105 106 boolean[] scrollings = new boolean[] {false}; 107 public boolean[] getScrollings() { 108 return scrollings; 109 } 110 111 String application; 112 113 117 public String getApplication() { 118 return application; 119 } 120 121 125 public void setApplication(String v) { 126 this.application = v; 127 } 128 129 130 214 public void setSubPanesGeometry(int subPanesCount, int geometry, 215 boolean[] scrollings) { 216 this.subPanesCount = subPanesCount; 217 this.geometry = geometry; 218 this.scrollings = scrollings; 219 } 220 221 231 public void setPaneContent(String paneId, 232 String viewType, String [] args) { 233 paneContents.put(paneId,new PanelContent(viewType,args)); 234 } 235 236 239 public String getPaneContentType(String paneID) { 240 return (String )((Object [])paneContents.get(paneID))[0]; 241 } 242 243 public String [] getPaneContentArgs(String paneID) { 244 return (String [])((Object [])paneContents.get(paneID))[1]; 245 } 246 247 public Map getPaneContents() { 248 return paneContents; 249 } 250 251 public void setPaneContainer(String paneId, String containerType) { 252 paneContainers.put(paneId,containerType); 253 } 254 255 public String getPaneContainer(String paneId) { 256 return (String )paneContainers.get(paneId); 257 } 258 259 public Map getPaneContainers() { 260 return paneContainers; 261 } 262 263 Hashtable subPaneContents = new Hashtable (); 264 265 public Map getSubPaneContents() { 266 return subPaneContents; 267 } 268 269 HashMap targetContainers = new HashMap (); 271 272 279 280 public void addReferenceToPane(MemberItem reference, 281 String viewType, String [] viewParams, 282 String paneId) { 283 Vector containers = (Vector )targetContainers.get(reference); 284 if (containers==null) { 285 containers = new Vector (); 286 targetContainers.put(reference,containers); 287 } 288 containers.add(new Target(paneId,viewType,viewParams)); 289 } 290 291 public Map getTargetContainers() { 292 return targetContainers; 293 } 294 295 public List getFieldTargets(MemberItem reference) { 296 List result = null; 297 while (result==null && reference!=null) { 298 result = (List )targetContainers.get(reference); 299 ClassItem superClass = reference.getClassItem().getSuperclass(); 300 if (superClass!=null) 301 reference = superClass.getFieldNoError(reference.getName()); 302 else 303 reference = null; 304 } 305 return result; 306 } 307 308 int left; 309 int up; 310 int width; 311 int height; 312 313 public int getLeft() { 314 return left; 315 } 316 317 public int getUp() { 318 return up; 319 } 320 321 public int getWidth() { 322 return width; 323 } 324 325 public int getHeight() { 326 return height; 327 } 328 329 boolean geometrySet = false; 330 331 337 public boolean isGeometrySet() { 338 return geometrySet; 339 } 340 341 351 352 public void setPosition(int left, int up, int width, int height) { 353 this.up = up; 354 this.left = left; 355 this.width = width; 356 this.height = height; 357 geometrySet = true; 358 } 359 360 373 374 public void setSplitterLocation(int splitterId, float location) { 375 splitters.put(new Integer (splitterId), new Float (location)); 376 } 377 378 public Map getSplitters() { 379 return splitters; 380 } 381 382 boolean hasStatusBar=false; 383 MethodItem statusBarMethod=null; 384 String statusPosition = BOTTOM; 385 386 public boolean hasStatusBar() { 387 return hasStatusBar; 388 } 389 390 public String getStatusPosition() { 391 return statusPosition; 392 } 393 394 public MethodItem getStatusBarMethod() { 395 return statusBarMethod; 396 } 397 398 401 402 public void addStatusBar(MethodItem method,String position) { 403 hasStatusBar=true; 404 statusBarMethod = method; 405 statusPosition=position; 406 } 407 408 417 418 436 public CustomizedGUI(String id) { 437 this.id = id; 438 } 439 440 String id; 441 public String getId() { 442 return id; 443 } 444 445 Hashtable menus = new Hashtable (); 446 447 public Hashtable getMenus() { 448 return menus; 449 } 450 451 public Menu getMenus(String name) { 452 Menu menu=(Menu)menus.get(name); 453 if(menu==null) { 454 menu=new Menu(); 455 menus.put(name,menu); 456 } 457 return menu; 458 } 459 460 public boolean hasMenuBar() { 461 return menus.size()>0; 462 } 463 464 472 public void addMenuItem(String menuName, 473 String [] menuPath, 474 Callback callback) { 475 String [] path = new String [menuPath.length-1]; 476 System.arraycopy(menuPath,0,path,0,menuPath.length-1); 477 getMenu(menuName,path).put( 478 menuPath[menuPath.length-1],callback); 479 } 480 481 489 public void addMenuSeparator(String menuName,String [] menuPath) { 490 getMenu(menuName,menuPath).addSeparator(); 491 } 492 493 Vector toolbar = new Vector (); 494 495 503 public void addToolbarAction(AbstractMethodItem method) { 504 toolbar.add(new Callback(null,method, new Object [0])); 505 } 506 507 516 public void addToolbarAction(String objectName, AbstractMethodItem method) { 517 addToolbarAction(objectName,method,new Object [0]); 518 } 519 520 public void addToolbarAction(String objectName, AbstractMethodItem method, Object [] params) { 521 toolbar.add(new Callback(objectName,method,params)); 522 } 523 524 529 public void addToolbarSeparator() { 530 toolbar.add(null); 531 } 532 533 540 public Collection getToolbar() { 541 return toolbar; 542 } 543 544 public boolean hasToolBar() { 545 return toolbar.size()>0; 546 } 547 548 551 protected Menu getMenu(String menuName,String [] menuPath) { 552 Menu menu = getMenus(menuName); 553 for (int i=0; i<menuPath.length; i++) { 554 if (menu.containsKey(menuPath[i])) { 555 Object current = menu.get(menuPath[i]); 556 if (current instanceof Menu) { 557 menu = (Menu)current; 558 } else { 559 logger.warn("overriding menu item "+current); 560 Menu old = menu; 561 menu = new Menu(); 562 old.put(menuPath[i],menu); 563 } 564 } else { 565 Menu old = menu; 566 menu = new Menu(); 567 old.put(menuPath[i],menu); 568 } 569 } 570 return menu; 571 } 572 573 public void setMenuIcon(String menuName, 574 String [] menuPath, String icon) { 575 getMenu(menuName,menuPath).setIcon(icon); 576 } 577 578 public void setMenuPosition(String menuName,String position) { 579 getMenus(menuName).setPosition(position); 580 } 581 582 String welcomeTitle = "Welcome"; 583 String welcomeMessage = null; 584 String welcomeIcon = null; 585 586 public void setWelcomeMessage(String title,String message,String icon) { 587 this.welcomeTitle = title; 588 this.welcomeMessage = message; 589 this.welcomeIcon = icon; 590 } 591 592 String title; 593 public void setTitle(String title) { 594 this.title=title; 595 } 596 public String getTitle() { 597 return title; 598 } 599 600 Vector cssURLs=new Vector (); 601 public void addStyleSheetURL(String url) { 602 cssURLs.add(url); 603 } 604 605 public Vector getStyleSheetURLs() { 606 return cssURLs; 607 } 608 609 AbstractMethodItem onCloseHandler; 610 public void setOnCloseHandler(AbstractMethodItem handler) { 611 onCloseHandler = handler; 612 } 613 public AbstractMethodItem getOnCloseHandler() { 614 return onCloseHandler; 615 } 616 617 String icon; 618 public String getIcon() { 619 return icon; 620 } 621 public void setIcon(String icon) { 622 this.icon = icon; 623 } 624 } 625 | Popular Tags |