private boolean showXmlView(
      ImDocument doc, ImAnnotation annot, int xmlWrapperFlags, ImDocumentMarkupPanel idmp) {

    //	collect current display settings, including colors ...
    Set taggedAnnotTypes = new HashSet();
    Set highlightedAnnotTypes = new HashSet();
    Map annotTypeColors = new HashMap();

    //	... for both regions ...
    String[] regTypes = idmp.getLayoutObjectTypes();
    for (int t = 0; t < regTypes.length; t++) {
      String regAnnotType = ImDocumentRoot.getRegionAnnotationType(regTypes[t]);
      if (regAnnotType == null) continue;
      Color typeColor = idmp.getLayoutObjectColor(regTypes[t]);
      if (typeColor != null) annotTypeColors.put(regAnnotType, typeColor);
      if (!idmp.areRegionsPainted(regTypes[t])) continue;
      if (ImWord.WORD_ANNOTATION_TYPE.equals(regTypes[t])) continue;
      if (TableConstants.TABLE_CELL_ANNOTATION_TYPE.equals(regAnnotType))
        highlightedAnnotTypes.add(regAnnotType);
      else taggedAnnotTypes.add(regAnnotType);
    }

    //	... and annotations ...
    String[] annotTypes = idmp.getAnnotationTypes();
    for (int t = 0; t < annotTypes.length; t++) {
      Color typeColor = idmp.getAnnotationColor(annotTypes[t]);
      if (typeColor != null) annotTypeColors.put(annotTypes[t], typeColor);
      if (!idmp.areAnnotationsPainted(annotTypes[t])) continue;
      if (this.isStructureAnnotationType(annotTypes[t])) taggedAnnotTypes.add(annotTypes[t]);
      else highlightedAnnotTypes.add(annotTypes[t]);
    }

    //	..., and add paragraphs, which are implicit in text streams
    taggedAnnotTypes.add(ImRegion.PARAGRAPH_TYPE);

    //	we need to go through this rigmarole because color settings only show up from the second
    // original dialog opened onward
    new ImDocumentEditorDialog(
        this.parent,
        "Color Initializer",
        Gamta.newDocument(Gamta.newTokenSequence("COLOR INITIALIZER", null)),
        xmlWrapperFlags,
        taggedAnnotTypes,
        highlightedAnnotTypes,
        annotTypeColors);

    //	finally ...
    return this.showXmlView(
        doc,
        annot,
        xmlWrapperFlags,
        taggedAnnotTypes,
        highlightedAnnotTypes,
        annotTypeColors,
        idmp);
  }
  /* (non-Javadoc)
   * @see de.uka.ipd.idaho.im.imagine.plugins.SelectionActionProvider#getActions(de.uka.ipd.idaho.im.ImWord, de.uka.ipd.idaho.im.ImWord, de.uka.ipd.idaho.im.util.ImDocumentMarkupPanel)
   */
  public SelectionAction[] getActions(ImWord start, ImWord end, final ImDocumentMarkupPanel idmp) {

    //	we only work on individual text streams
    if (!start.getTextStreamId().equals(end.getTextStreamId())) return null;

    //	collect painted annotations spanning or overlapping whole selection
    ImAnnotation[] allOverlappingAnnots = idmp.document.getAnnotationsOverlapping(start, end);
    LinkedList spanningAnnotList = new LinkedList();
    for (int a = 0; a < allOverlappingAnnots.length; a++) {
      if (!idmp.areAnnotationsPainted(allOverlappingAnnots[a].getType())) continue;
      if (ImUtils.textStreamOrder.compare(start, allOverlappingAnnots[a].getFirstWord()) < 0)
        continue;
      if (ImUtils.textStreamOrder.compare(allOverlappingAnnots[a].getLastWord(), end) < 0) continue;
      spanningAnnotList.add(allOverlappingAnnots[a]);
    }

    //	anything to work with?
    if (spanningAnnotList.isEmpty()) return null;
    final ImAnnotation[] spanningAnnots =
        ((ImAnnotation[]) spanningAnnotList.toArray(new ImAnnotation[spanningAnnotList.size()]));

    //	collect available actions
    LinkedList actions = new LinkedList();

    //	show XML view of existing annotations
    if (spanningAnnots.length == 1)
      actions.add(
          new SelectionAction(
              "showXmlView",
              ("Show XML View of " + spanningAnnots[0].getType()),
              ("Show XML view of '" + spanningAnnots[0].getType() + "' annotation.")) {
            public boolean performAction(ImDocumentMarkupPanel invoker) {
              return showXmlView(idmp.document, spanningAnnots[0], idmp);
            }
          });

    //	show XML view of existing annotations
    else
      actions.add(
          new SelectionAction(
              "showXmlView", "Show XML View ...", "Show XML view of selected annotations.") {
            public boolean performAction(ImDocumentMarkupPanel invoker) {
              return false;
            }

            public JMenuItem getMenuItem(final ImDocumentMarkupPanel invoker) {
              JMenu pm = new JMenu("Show XML View ...");
              JMenuItem mi;
              for (int a = 0; a < spanningAnnots.length; a++) {
                final ImAnnotation spanningAnnot = spanningAnnots[a];
                mi =
                    new JMenuItem(
                        "- "
                            + spanningAnnot.getType()
                            + " '"
                            + getAnnotationShortValue(
                                spanningAnnot.getFirstWord(), spanningAnnot.getLastWord())
                            + "'");
                mi.addActionListener(
                    new ActionListener() {
                      public void actionPerformed(ActionEvent ae) {
                        if (showXmlView(idmp.document, spanningAnnot, idmp)) {
                          invoker.validate();
                          invoker.repaint();
                        }
                      }
                    });
                pm.add(mi);
              }
              return pm;
            }
          });

    //	finally ...
    return ((SelectionAction[]) actions.toArray(new SelectionAction[actions.size()]));
  }