/*------------------------------------------------------------------------------------
Copyright (c)2000 TogetherSoft Corporation. Patents pending. All rights reserved.
------------------------------------------------------------------------------------*/

package com.togethersoft.modules.xmleditor.xmltree;

import java.util.*;
import com.togethersoft.openapi.rwi.*;
import com.togethersoft.openapi.ide.*;
import com.togethersoft.openapi.ide.diagram.*;
import com.togethersoft.modules.xmleditor.api.*;


public class DefaultRwiElementProvider implements RwiElementProvider
{
  //--------------------------------------------------------------------
  public RwiElement getRwiElement (XmlElementNode elementNode, Properties providerParam)
  {
    XmlElementNode parentElement = elementNode.getParentElement();

    // if it's the root element return the active diagram
    if (parentElement == null)
    {
      // get active diagram
      IdeDiagram ideActiveDiagram = IdeAccess.getDiagramManager().getActiveDiagram();
      return (ideActiveDiagram != null) ? ideActiveDiagram.getRwiDiagram() : null;
    }

    // return parent's RWI-element
    return parentElement.getRwiElement();
  }

}
