/jEdit/tags/jedit-4-2-pre13/bsh/commands/browseClass.bsh

# · Unknown · 42 lines · 35 code · 7 blank · 0 comment · 0 complexity · 1cc7398f833a36ecbbb061463e71f5a3 MD5 · raw file

  1. /**
  2. Open the class browser to view the specified class.
  3. If the argument is a string it is considered to be a class name.
  4. If the argument is an object, the class of the object is used.
  5. If the arg is a class, the class is used.
  6. <p>
  7. Note: To browse the String class you can't supply a String.
  8. You'd have to do: browseClass( String.class );
  9. <p>
  10. @method void browseClass( String | Object | Class )
  11. */
  12. import bsh.ClassIdentifier;
  13. browseClass( Object o )
  14. {
  15. String classname;
  16. if ( o instanceof String)
  17. classname = o;
  18. else if ( o instanceof ClassIdentifier )
  19. classname = this.namespace.identifierToClass(o).getName();
  20. else if ( o instanceof Class )
  21. classname = o.getName();
  22. else
  23. classname = o.getClass().getName();
  24. // really need a way to unset and more poweful testing...
  25. if ( bsh.system.desktop == void
  26. || bsh.system.desktop.classbrowser == void
  27. || bsh.system.desktop.classbrowser == null )
  28. {
  29. this.browser = classBrowser();
  30. } else {
  31. this.browser = bsh.system.desktop.classbrowser;
  32. bsh.system.desktop.classbrowser.toFront();
  33. }
  34. browser.driveToClass( classname );
  35. }