Program: 74945
Project: 74945
Buggy source:
/** 
 * Construct a documentation viewer for the specified target, class name, or URL. Normally, one of these three arguments will be non-null.
 * @param target The object to get documentation for, or nullto base this on the specified class name.
 * @param configuration The configuration in charge of this viewer.
 * @param className The class name of the target, or null if a targetis given.
 * @param url The URL from which to read the doc file, or null toinfer it from the target or className.
 */
private void _init(final NamedObj target,Configuration configuration,String className,URL url) throws ClassNotFoundException {
  _configuration=configuration;
  _target=target;
  final DocManager manager;
  if (target != null) {
    manager=new DocManager(target);
  }
 else   if (className != null) {
    manager=new DocManager(Class.forName(className));
  }
 else   if (url != null) {
    manager=new DocManager(url);
  }
 else {
    throw new InternalErrorException("String_Node_Str");
  }
  className=manager.getClassName();
  final String rootName;
  int lastPeriod=className.lastIndexOf("String_Node_Str");
  if (lastPeriod >= 0) {
    rootName=className.substring(lastPeriod + 1);
  }
 else {
    rootName=className;
  }
  if (url != null) {
    setBase(url);
  }
 else {
    String javaDocDirectory="String_Node_Str" + className;
    int lastDot=javaDocDirectory.lastIndexOf("String_Node_Str");
    javaDocDirectory=javaDocDirectory.substring(0,lastDot);
    URL base=getClass().getClassLoader().getResource(javaDocDirectory.replace('.','/') + "String_Node_Str");
    setBase(base);
  }
  Container contentPane=getContentPane();
  Dimension horizontalSpace=new Dimension(_SPACING,0);
  Dimension verticalSpace=new Dimension(0,_SPACING);
  contentPane.add(Box.createRigidArea(verticalSpace));
  JPanel titlePanel=new JPanel();
  titlePanel.setLayout(new BoxLayout(titlePanel,BoxLayout.X_AXIS));
  contentPane.add(titlePanel);
  String title=className;
  if (target instanceof InstantiableNamedObj && ((InstantiableNamedObj)target).isClassDefinition()) {
    title=target.getName() + "String_Node_Str" + target.getFullName()+ "String_Node_Str";
  }
 else {
    if (manager.isInstanceDoc()) {
      title=target.getName() + "String_Node_Str" + className+ "String_Node_Str";
    }
 else {
      title=rootName + "String_Node_Str" + className+ "String_Node_Str";
    }
  }
  JEditorPane titlePane=new JEditorPane();
  titlePane.setContentType("String_Node_Str");
  titlePane.setEditable(false);
  titlePane.setText(_HTML_HEADER + "String_Node_Str" + title+ "String_Node_Str"+ _HTML_TAIL);
  titlePane.getCaret().setDot(0);
  Dimension titleSize=new Dimension(_DESCRIPTION_WIDTH + _ICON_WINDOW_WIDTH + _SPACING,40);
  titlePane.setPreferredSize(titleSize);
  titlePane.setSize(titleSize);
  titlePane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
  titlePanel.add(Box.createRigidArea(horizontalSpace));
  titlePanel.add(titlePane);
  titlePanel.add(Box.createRigidArea(horizontalSpace));
  JPanel descriptionPanel=new JPanel();
  descriptionPanel.setLayout(new BoxLayout(descriptionPanel,BoxLayout.X_AXIS));
  contentPane.add(Box.createRigidArea(verticalSpace));
  contentPane.add(descriptionPanel);
  descriptionPanel.add(Box.createRigidArea(horizontalSpace));
  final CompositeEntity container=new CompositeEntity();
  ActorEditorGraphController controller=new ActorEditorGraphController();
  controller.setConfiguration(getConfiguration());
  ActorGraphModel graphModel=new ActorGraphModel(container);
  final GraphPane graphPane=new GraphPane(controller,graphModel);
  final JGraph jgraph=new JGraph(graphPane);
  jgraph.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
  jgraph.setMinimumSize(new Dimension(_ICON_WINDOW_WIDTH,_ICON_WINDOW_HEIGHT));
  jgraph.setMaximumSize(new Dimension(_ICON_WINDOW_WIDTH,_ICON_WINDOW_HEIGHT));
  jgraph.setPreferredSize(new Dimension(_ICON_WINDOW_WIDTH,_ICON_WINDOW_HEIGHT));
  jgraph.setSize(_ICON_WINDOW_WIDTH,_ICON_WINDOW_HEIGHT);
  jgraph.setBackground(BasicGraphFrame.BACKGROUND_COLOR);
  descriptionPanel.add(jgraph);
  descriptionPanel.add(Box.createRigidArea(horizontalSpace));
  final JEditorPane descriptionPane=new JEditorPane();
  descriptionPane.addHyperlinkListener(this);
  descriptionPane.setContentType("String_Node_Str");
  descriptionPane.setEditable(false);
  JScrollPane scroller=new JScrollPane(descriptionPane);
  scroller.setPreferredSize(new Dimension(_DESCRIPTION_WIDTH,_ICON_WINDOW_HEIGHT));
  scroller.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
  descriptionPanel.add(scroller);
  descriptionPanel.add(Box.createRigidArea(horizontalSpace));
  JPanel middle=new JPanel();
  middle.setLayout(new BoxLayout(middle,BoxLayout.X_AXIS));
  contentPane.add(Box.createRigidArea(verticalSpace));
  contentPane.add(middle);
  _scroller=new JScrollPane(pane);
  _scroller.setPreferredSize(new Dimension(_MAIN_WINDOW_WIDTH,_MAIN_WINDOW_HEIGHT));
  _scroller.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
  middle.add(Box.createRigidArea(horizontalSpace));
  middle.add(_scroller);
  middle.add(Box.createRigidArea(horizontalSpace));
  JPanel bottom=new JPanel();
  bottom.setLayout(new BoxLayout(bottom,BoxLayout.X_AXIS));
  contentPane.add(Box.createRigidArea(verticalSpace));
  contentPane.add(bottom);
  contentPane.add(Box.createRigidArea(verticalSpace));
  bottom.add(Box.createRigidArea(horizontalSpace));
  JEditorPane authorPane=new JEditorPane();
  authorPane.addHyperlinkListener(this);
  authorPane.setContentType("String_Node_Str");
  authorPane.setEditable(false);
  JScrollPane authorScroller=new JScrollPane(authorPane);
  Dimension authorSize=new Dimension(_AUTHOR_WINDOW_WIDTH,_BOTTOM_HEIGHT);
  authorScroller.setPreferredSize(authorSize);
  authorScroller.setSize(authorSize);
  authorScroller.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
  bottom.add(authorScroller);
  bottom.add(Box.createRigidArea(horizontalSpace));
  JEditorPane seeAlsoPane=new JEditorPane();
  seeAlsoPane.addHyperlinkListener(this);
  seeAlsoPane.setContentType("String_Node_Str");
  seeAlsoPane.setEditable(false);
  JScrollPane seeAlsoScroller=new JScrollPane(seeAlsoPane);
  Dimension seeAlsoSize=new Dimension(_SEE_ALSO_WIDTH,_BOTTOM_HEIGHT);
  seeAlsoScroller.setPreferredSize(seeAlsoSize);
  seeAlsoScroller.setSize(seeAlsoSize);
  seeAlsoScroller.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
  bottom.add(seeAlsoScroller);
  bottom.add(Box.createRigidArea(horizontalSpace));
  StringBuffer html=new StringBuffer();
  html.append(_HTML_HEADER);
  String description=manager.getDescription();
  html.append(description);
  html.append(_HTML_TAIL);
  descriptionPane.setText(html.toString());
  descriptionPane.getCaret().setDot(0);
  String moml=null;
  if (target != null) {
    StringBuffer buffer=new StringBuffer("String_Node_Str");
    _includeClassDefinitions(target,buffer);
    buffer.append(target.exportMoML());
    buffer.append("String_Node_Str");
    buffer.append(target.getElementName());
    buffer.append("String_Node_Str");
    buffer.append(target.getName());
    buffer.append("String_Node_Str");
    buffer.append(target.getElementName());
    buffer.append("String_Node_Str");
    buffer.append("String_Node_Str");
    moml=buffer.toString();
  }
 else   if (!manager.hadException()) {
    if (manager.isTargetInstantiableAttribute()) {
      moml="String_Node_Str" + rootName + "String_Node_Str"+ className+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
    }
 else     if (manager.isTargetInstantiableEntity()) {
      moml="String_Node_Str" + rootName + "String_Node_Str"+ className+ "String_Node_Str";
    }
 else     if (manager.isTargetInstantiablePort()) {
      moml="String_Node_Str" + rootName + "String_Node_Str"+ className+ "String_Node_Str";
    }
  }
  if (moml != null) {
    MoMLChangeRequest request=new MoMLChangeRequest(this,container,moml){
      protected void _execute() throws Exception {
        super._execute();
        NamedObj sample=null;
        String name=rootName;
        if (target != null) {
          name=target.getName();
        }
        if (manager.isTargetInstantiableAttribute()) {
          sample=container.getAttribute(name);
        }
 else         if (manager.isTargetInstantiableEntity()) {
          sample=container.getEntity(name);
        }
 else         if (manager.isTargetInstantiablePort()) {
          sample=container.getPort(name);
        }
        if (sample != null) {
          _populatePortsAndParametersTable(sample,manager);
          _adjustIconDisplay(sample,container,graphPane,jgraph);
        }
      }
    }
;
    container.requestChange(request);
  }
  if (target != null) {
    _populatePortsAndParametersTable(target,manager);
  }
  StringBuffer info=new StringBuffer();
  info.append(_HTML_HEADER);
  info.append(_tableOpening);
  info.append(_tr);
  info.append(_td20);
  info.append("String_Node_Str");
  info.append(_tde);
  info.append(_td);
  info.append(manager.getAuthor());
  if (manager.isInstanceDoc()) {
    DocManager nextTier=manager.getNextTier();
    if (nextTier != null) {
      String nextTierAuthor=nextTier.getAuthor();
      if (!nextTierAuthor.equals("String_Node_Str")) {
        info.append("String_Node_Str");
        info.append(nextTierAuthor);
      }
    }
  }
  info.append(_tde);
  info.append(_tre);
  String version=manager.getVersion();
  if (version != null) {
    info.append(_tr);
    info.append(_td20);
    info.append("String_Node_Str");
    info.append(_tde);
    info.append(_td);
    info.append(version);
    info.append(_tde);
    info.append(_tre);
  }
  String since=manager.getSince();
  if (since != null) {
    info.append(_tr);
    info.append(_td20);
    info.append("String_Node_Str");
    info.append(_tde);
    info.append(_td);
    info.append(since);
    info.append(_tde);
    info.append(_tre);
  }
  String rating=manager.getAcceptedRating();
  if (rating != null) {
    info.append(_tr);
    info.append(_td20);
    info.append("String_Node_Str");
    info.append(_tde);
    info.append(_colorizeRating(rating));
    info.append(_tre);
  }
  info.append(_tableClosing);
  info.append(_HTML_TAIL);
  authorPane.setText(info.toString());
  authorPane.getCaret().setDot(0);
  seeAlsoPane.setText(_HTML_HEADER + manager.getSeeAlso() + _HTML_TAIL);
  seeAlsoPane.getCaret().setDot(0);
}

Fixed version (ground truth):
/** 
 * Construct a documentation viewer for the specified target, class name, or URL. Normally, one of these three arguments will be non-null.
 * @param target The object to get documentation for, or nullto base this on the specified class name.
 * @param configuration The configuration in charge of this viewer.
 * @param className The class name of the target, or null if a targetis given.
 * @param url The URL from which to read the doc file, or null toinfer it from the target or className.
 */
private void _init(final NamedObj target,Configuration configuration,String className,URL url) throws ClassNotFoundException {
  _configuration=configuration;
  _target=target;
  final DocManager manager;
  if (target != null) {
    manager=new DocManager(target);
  }
 else   if (className != null) {
    manager=new DocManager(Class.forName(className));
  }
 else   if (url != null) {
    manager=new DocManager(url);
  }
 else {
    throw new InternalErrorException("String_Node_Str");
  }
  className=manager.getClassName();
  final String rootName;
  int lastPeriod=className.lastIndexOf("String_Node_Str");
  if (lastPeriod >= 0) {
    rootName=className.substring(lastPeriod + 1);
  }
 else {
    rootName=className;
  }
  if (url != null) {
    setBase(url);
  }
 else {
    String javaDocDirectory="String_Node_Str" + className;
    int lastDot=javaDocDirectory.lastIndexOf("String_Node_Str");
    javaDocDirectory=javaDocDirectory.substring(0,lastDot);
    URL base=getClass().getClassLoader().getResource(javaDocDirectory.replace('.','/') + "String_Node_Str");
    setBase(base);
  }
  Container contentPane=getContentPane();
  Dimension horizontalSpace=new Dimension(_SPACING,0);
  Dimension verticalSpace=new Dimension(0,_SPACING);
  contentPane.add(Box.createRigidArea(verticalSpace));
  JPanel titlePanel=new JPanel();
  titlePanel.setLayout(new BoxLayout(titlePanel,BoxLayout.X_AXIS));
  contentPane.add(titlePanel);
  String title=className;
  if (target instanceof InstantiableNamedObj && ((InstantiableNamedObj)target).isClassDefinition()) {
    title=target.getName() + "String_Node_Str" + target.getFullName()+ "String_Node_Str";
  }
 else {
    if (manager.isInstanceDoc()) {
      title=target.getName() + "String_Node_Str" + className+ "String_Node_Str";
    }
 else {
      title=rootName + "String_Node_Str" + className+ "String_Node_Str";
    }
  }
  JEditorPane titlePane=new JEditorPane();
  titlePane.setContentType("String_Node_Str");
  titlePane.setEditable(false);
  titlePane.setText(_HTML_HEADER + "String_Node_Str" + title+ "String_Node_Str"+ _HTML_TAIL);
  titlePane.getCaret().setDot(0);
  Dimension titleSize=new Dimension(_DESCRIPTION_WIDTH + _ICON_WINDOW_WIDTH + _SPACING,40);
  titlePane.setPreferredSize(titleSize);
  titlePane.setSize(titleSize);
  titlePane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
  titlePanel.add(Box.createRigidArea(horizontalSpace));
  titlePanel.add(titlePane);
  titlePanel.add(Box.createRigidArea(horizontalSpace));
  JPanel descriptionPanel=new JPanel();
  descriptionPanel.setLayout(new BoxLayout(descriptionPanel,BoxLayout.X_AXIS));
  contentPane.add(Box.createRigidArea(verticalSpace));
  contentPane.add(descriptionPanel);
  descriptionPanel.add(Box.createRigidArea(horizontalSpace));
  _iconContainer=new CompositeEntity();
  final ActorEditorGraphController controller=new ActorEditorGraphController();
  controller.setConfiguration(getConfiguration());
  ActorGraphModel graphModel=new ActorGraphModel(_iconContainer){
    /** 
 * Override the base class to give a useful message.
 * @param change The change that has failed.
 * @param exception The exception that was thrown.
 */
    public void changeFailed(    ChangeRequest change,    Exception exception){
      if (_graphPane == null) {
        super.changeFailed(change,exception);
        return;
      }
      LabelFigure newFigure=new LabelFigure("String_Node_Str",_font);
      _graphPane.getForegroundLayer().add(newFigure);
      CanvasUtilities.translateTo(newFigure,100.0,100.0);
      controller.dispatch(new GraphViewEvent(this,GraphViewEvent.NODE_DRAWN,newFigure));
    }
  }
;
  _graphPane=new GraphPane(controller,graphModel);
  _jgraph=new JGraph(_graphPane);
  _jgraph.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
  _jgraph.setMinimumSize(new Dimension(_ICON_WINDOW_WIDTH,_ICON_WINDOW_HEIGHT));
  _jgraph.setMaximumSize(new Dimension(_ICON_WINDOW_WIDTH,_ICON_WINDOW_HEIGHT));
  _jgraph.setPreferredSize(new Dimension(_ICON_WINDOW_WIDTH,_ICON_WINDOW_HEIGHT));
  _jgraph.setSize(_ICON_WINDOW_WIDTH,_ICON_WINDOW_HEIGHT);
  _jgraph.setBackground(BasicGraphFrame.BACKGROUND_COLOR);
  descriptionPanel.add(_jgraph);
  descriptionPanel.add(Box.createRigidArea(horizontalSpace));
  final JEditorPane descriptionPane=new JEditorPane();
  descriptionPane.addHyperlinkListener(this);
  descriptionPane.setContentType("String_Node_Str");
  descriptionPane.setEditable(false);
  JScrollPane scroller=new JScrollPane(descriptionPane);
  scroller.setPreferredSize(new Dimension(_DESCRIPTION_WIDTH,_ICON_WINDOW_HEIGHT));
  scroller.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
  descriptionPanel.add(scroller);
  descriptionPanel.add(Box.createRigidArea(horizontalSpace));
  JPanel middle=new JPanel();
  middle.setLayout(new BoxLayout(middle,BoxLayout.X_AXIS));
  contentPane.add(Box.createRigidArea(verticalSpace));
  contentPane.add(middle);
  _scroller=new JScrollPane(pane);
  _scroller.setPreferredSize(new Dimension(_MAIN_WINDOW_WIDTH,_MAIN_WINDOW_HEIGHT));
  _scroller.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
  middle.add(Box.createRigidArea(horizontalSpace));
  middle.add(_scroller);
  middle.add(Box.createRigidArea(horizontalSpace));
  JPanel bottom=new JPanel();
  bottom.setLayout(new BoxLayout(bottom,BoxLayout.X_AXIS));
  contentPane.add(Box.createRigidArea(verticalSpace));
  contentPane.add(bottom);
  contentPane.add(Box.createRigidArea(verticalSpace));
  bottom.add(Box.createRigidArea(horizontalSpace));
  JEditorPane authorPane=new JEditorPane();
  authorPane.addHyperlinkListener(this);
  authorPane.setContentType("String_Node_Str");
  authorPane.setEditable(false);
  JScrollPane authorScroller=new JScrollPane(authorPane);
  Dimension authorSize=new Dimension(_AUTHOR_WINDOW_WIDTH,_BOTTOM_HEIGHT);
  authorScroller.setPreferredSize(authorSize);
  authorScroller.setSize(authorSize);
  authorScroller.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
  bottom.add(authorScroller);
  bottom.add(Box.createRigidArea(horizontalSpace));
  JEditorPane seeAlsoPane=new JEditorPane();
  seeAlsoPane.addHyperlinkListener(this);
  seeAlsoPane.setContentType("String_Node_Str");
  seeAlsoPane.setEditable(false);
  JScrollPane seeAlsoScroller=new JScrollPane(seeAlsoPane);
  Dimension seeAlsoSize=new Dimension(_SEE_ALSO_WIDTH,_BOTTOM_HEIGHT);
  seeAlsoScroller.setPreferredSize(seeAlsoSize);
  seeAlsoScroller.setSize(seeAlsoSize);
  seeAlsoScroller.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
  bottom.add(seeAlsoScroller);
  bottom.add(Box.createRigidArea(horizontalSpace));
  StringBuffer html=new StringBuffer();
  html.append(_HTML_HEADER);
  String description=manager.getDescription();
  html.append(description);
  html.append(_HTML_TAIL);
  descriptionPane.setText(html.toString());
  descriptionPane.getCaret().setDot(0);
  String moml=null;
  if (target != null) {
    StringBuffer buffer=new StringBuffer("String_Node_Str");
    _includeClassDefinitions(target,buffer);
    buffer.append(target.exportMoMLPlain());
    buffer.append("String_Node_Str");
    buffer.append(target.getElementName());
    buffer.append("String_Node_Str");
    buffer.append(target.getName());
    buffer.append("String_Node_Str");
    buffer.append(target.getElementName());
    buffer.append("String_Node_Str");
    buffer.append("String_Node_Str");
    moml=buffer.toString();
  }
 else   if (!manager.hadException()) {
    if (manager.isTargetInstantiableAttribute()) {
      moml="String_Node_Str" + rootName + "String_Node_Str"+ className+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
    }
 else     if (manager.isTargetInstantiableEntity()) {
      moml="String_Node_Str" + rootName + "String_Node_Str"+ className+ "String_Node_Str";
    }
 else     if (manager.isTargetInstantiablePort()) {
      moml="String_Node_Str" + rootName + "String_Node_Str"+ className+ "String_Node_Str"+ "String_Node_Str";
    }
  }
  if (moml != null) {
    MoMLChangeRequest request=new MoMLChangeRequest(this,_iconContainer,moml){
      protected void _execute() throws Exception {
        super._execute();
        NamedObj sample=null;
        String name=rootName;
        if (target != null) {
          name=target.getName();
        }
        if (manager.isTargetInstantiableAttribute()) {
          sample=_iconContainer.getAttribute(name);
        }
 else         if (manager.isTargetInstantiableEntity()) {
          sample=_iconContainer.getEntity(name);
        }
 else         if (manager.isTargetInstantiablePort()) {
          sample=_iconContainer.getPort(name);
        }
        if (sample != null) {
          _populatePortsAndParametersTable(sample,manager);
          _adjustIconDisplay(sample,_iconContainer,_graphPane,_jgraph);
        }
      }
    }
;
    _iconContainer.requestChange(request);
  }
  if (target != null) {
    _populatePortsAndParametersTable(target,manager);
  }
  StringBuffer info=new StringBuffer();
  info.append(_HTML_HEADER);
  info.append(_tableOpening);
  info.append(_tr);
  info.append(_td20);
  info.append("String_Node_Str");
  info.append(_tde);
  info.append(_td);
  info.append(manager.getAuthor());
  if (manager.isInstanceDoc()) {
    DocManager nextTier=manager.getNextTier();
    if (nextTier != null) {
      String nextTierAuthor=nextTier.getAuthor();
      if (!nextTierAuthor.equals("String_Node_Str")) {
        info.append("String_Node_Str");
        info.append(nextTierAuthor);
      }
    }
  }
  info.append(_tde);
  info.append(_tre);
  String version=manager.getVersion();
  if (version != null) {
    info.append(_tr);
    info.append(_td20);
    info.append("String_Node_Str");
    info.append(_tde);
    info.append(_td);
    info.append(version);
    info.append(_tde);
    info.append(_tre);
  }
  String since=manager.getSince();
  if (since != null) {
    info.append(_tr);
    info.append(_td20);
    info.append("String_Node_Str");
    info.append(_tde);
    info.append(_td);
    info.append(since);
    info.append(_tde);
    info.append(_tre);
  }
  String rating=manager.getAcceptedRating();
  if (rating != null) {
    info.append(_tr);
    info.append(_td20);
    info.append("String_Node_Str");
    info.append(_tde);
    info.append(_colorizeRating(rating));
    info.append(_tre);
  }
  info.append(_tableClosing);
  info.append(_HTML_TAIL);
  authorPane.setText(info.toString());
  authorPane.getCaret().setDot(0);
  seeAlsoPane.setText(_HTML_HEADER + manager.getSeeAlso() + _HTML_TAIL);
  seeAlsoPane.getCaret().setDot(0);
}