Пример #1
0
  /**
   * Set the lists of class and method definitions.
   *
   * @param classes list of ClassDefinition objects.
   * @param methods list of MethodDefinition objects.
   */
  void setClassDefinitions(List classes, List methods) {
    classLines = classes;
    if (classLines == null || methods == null) {
      methodsMenu = null;
      return;
    }

    // Add the class names to the method definitions. Granted, this
    // is slow, but hopefully there are few classes and few methods
    // in those classes.
    Iterator iter = methods.iterator();
    while (iter.hasNext()) {
      MethodDefinition def = (MethodDefinition) iter.next();
      if (def.getClassName() == null) {
        // Set the class name if not already set.
        String cname = ClassDefinition.findClassForLine(classLines, def.getLine());
        def.setClassName(cname);
      }
    }

    // Build a submenu of the sorted method definitions.
    JMenu menu = new JMenu(Bundle.getString("SourceViewPopup.methodsMenuLabel"), true);
    Collections.sort(methods, new MDComparator());
    iter = methods.iterator();
    Preferences prefs = Preferences.userRoot().node("com/bluemarsh/jswat/view");
    boolean shortDesc =
        prefs.getBoolean("shortMethodDescInPopup", Defaults.VIEW_POPUP_SHORT_METHOD_DESC);
    while (iter.hasNext()) {
      MethodDefinition def = (MethodDefinition) iter.next();
      // Keep the description short, if so desired.
      String desc = shortDesc ? def.getMethodDescShort() : def.getMethodDesc();
      if (desc.length() > 80) {
        desc = desc.substring(0, 78) + "...";
      }
      JMenuItem item = new JMenuItem(desc);
      menu.add(item);
      item.setActionCommand(String.valueOf(def.getLine()));
      item.addActionListener(this);
    }
    if (menu.getMenuComponentCount() > 0) {
      methodsMenu = menu;
    }
  } // setClassDefinitions
Пример #2
0
  /**
   * Try to add a breakpoint at the last clicked class and line. Displays an appropriate error
   * message if needed.
   *
   * @param session Session.
   * @param bpman breakpoint manager.
   * @return new breakpoint if successful, null if error.
   */
  protected Breakpoint addBreakpoint(Session session, BreakpointManager bpman) {
    if (lastClickedClass == null) {
      // Fall back on default behavior.
      return super.addBreakpoint(session, bpman);
    }

    try {
      String fname = sourceSrc.getName();
      Breakpoint bp = new LineBreakpoint(lastClickedClass, fname, lastClickedLine);
      bpman.addNewBreakpoint(bp);
      return bp;
    } catch (ClassNotFoundException cnfe) {
      session
          .getUIAdapter()
          .showMessage(
              UIAdapter.MESSAGE_ERROR,
              Bundle.getString("AddBreak.invalidClassMsg") + ' ' + lastClickedClass);
      return null;
    } catch (ResolveException re) {
      session.getUIAdapter().showMessage(UIAdapter.MESSAGE_ERROR, re.errorMessage());
      return null;
    }
  } // addBreakpoint
Пример #3
0
 /**
  * Creates a JavaSourceViewPopup object.
  *
  * @param src source object.
  */
 public JavaSourceViewPopup(SourceSource src) {
   super(src);
   menuItemTable.put(
       PARSER_ERROR_STRING, new JMenuItem(Bundle.getString("SourceViewPopup.parserErrorMsg")));
 } // JavaSourceViewPopup