コード例 #1
0
 /**
  * Returns a list of the allowed siblings with their occurrence for a given {@link OverlayWidget}
  * <tt>overlayWidget</tt>. This implementation returns all allowed siblings according to this
  * overlay widget's parent's {@link
  * org.nsesa.editor.gwt.core.client.ui.overlay.document.OverlayWidget#getStructureIndicator()}.
  *
  * @param documentController the document controller
  * @param overlayWidget the overlay widget to get the allowed siblings for
  * @return the allowed siblings
  */
 @Override
 public List<OverlayWidget> getAllowedSiblings(
     final DocumentController documentController, final OverlayWidget overlayWidget) {
   if (overlayWidget.getParentOverlayWidget() != null) {
     return getAllowedChildren(documentController, overlayWidget.getParentOverlayWidget());
   } else {
     // probably dealing with a root node
     return new ArrayList<OverlayWidget>();
   }
 }
コード例 #2
0
 /**
  * Returns the list of the allowed child types as they are coming from {@link StructureIndicator}
  * structure
  *
  * @return the list of the allowed child types
  */
 private List<OverlayWidget> getAllowedChildTypes(OverlayWidget overlayWidget) {
   List<OverlayWidget> allowedChildren = new ArrayList<OverlayWidget>();
   List<StructureIndicator> stack = new ArrayList<StructureIndicator>();
   stack.add(overlayWidget.getStructureIndicator());
   while (!stack.isEmpty()) {
     StructureIndicator structureIndicator = stack.remove(0);
     if (structureIndicator instanceof StructureIndicator.Element) {
       StructureIndicator.Element elemIndicator = (StructureIndicator.Element) structureIndicator;
       OverlayWidget candidate = elemIndicator.asWidget();
       allowedChildren.add(candidate);
     } else {
       if (structureIndicator.getIndicators() != null) {
         stack.addAll(structureIndicator.getIndicators());
       }
     }
   }
   return allowedChildren;
 }