/* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) */
  public void selectionChanged(SelectionChangedEvent event) {

    RuleViolation violation = selectedViolationFrom(event);
    if (violation == null) return;

    String varName = violation.getVariableName();
    if (StringUtil.isEmpty(varName)) return;

    int beginLine = violation.getBeginLine();
    int endLine = violation.getEndLine();

    if (beginLine != 0 && endLine != 0) {
      try {
        int offset = getDocument().getLineOffset(violation.getBeginLine() - 1);
        int length = getDocument().getLineOffset(violation.getEndLine()) - offset;
        highlight(offset, length);
      } catch (BadLocationException ble) {
        logError(
            StringKeys.ERROR_RUNTIME_EXCEPTION + "Exception when selecting a line in the editor",
            ble);
      }

      // showMethodToMarker(marker);
      showMethodToViolation(violation);

      // then we calculate and color _a possible_ Path
      // for this Error in the Dataflow
      DataflowGraph graph = graphViewer.getGraph();
      if (!graphViewer.isDisposed() && graph != null) {
        graph.markPath(beginLine, endLine, varName);
      }
    }
  }
  /** Generates a html table with violation information. */
  private String displayRuleViolation(RuleViolation vio) {

    StringBuilder sb = new StringBuilder(200);
    sb.append("<table border=\"0\">");
    renderViolationRow(sb, "Rule:", vio.getRule().getName());
    renderViolationRow(sb, "Description:", vio.getDescription());

    if (StringUtil.isNotEmpty(vio.getVariableName())) {
      renderViolationRow(sb, "Variable:", vio.getVariableName());
    }

    if (vio.getEndLine() > 0) {
      renderViolationRow(sb, "Line:", vio.getEndLine() + " and " + vio.getBeginLine());
    } else {
      renderViolationRow(sb, "Line:", Integer.toString(vio.getBeginLine()));
    }

    sb.append("</table>");
    return sb.toString();
  }