示例#1
0
  /**
   * Attempt to find the breakpoint the user has clicked on, using as much information as is
   * available to this popup.
   *
   * @param bpman breakpoint manager to search through.
   * @return breakpoint if found, null if not.
   * @throws ViewException if the line does not contain code.
   */
  protected Breakpoint findBreakpoint(BreakpointManager bpman) throws ViewException {
    if (classLines == null) {
      // Fall back on the default behavior.
      return super.findBreakpoint(bpman);
    }

    // Get the class at this line.
    lastClickedClass = ClassDefinition.findClassForLine(classLines, lastClickedLine);
    if (lastClickedClass == null) {
      throw new NonCodeLineException();
    }

    // Query existing set of breakpoints for this class and line.
    return bpman.getBreakpoint(lastClickedClass, lastClickedLine);
  } // findBreakpoint
示例#2
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