######################################################################
##
## Copyright (c) LIFL 1999
## The GOODE team of the LIFL
## University of Lille, France
## All rights reserved
##
## The CorbaWeb script associated to the OMG IDL CORBA::Contained
## interface.
##
######################################################################

# Each action must have two arguments: the first one refers to the
# current CORBA object and the second one refers to a CorbaWeb
# ActionContext instance.

######################################################################
## obtains a label
######################################################################

proc get_label(contained)
{
  absolute_name = contained.absolute_name
  type_name = contained._type._toString()
  kind = type_name.substring(type_name.rindex(':')+1, type_name.index("Def"))
  return kind + ' ' + absolute_name
}

######################################################################
## Displays information about this CORBA::Contained object.
######################################################################

proc generate_contained_information(contained, ac)
{
  ac.h1("Browsing the " + get_label(contained))
  ac.anchorToInterfaceRepository()
  ac.p()

  ac.println("<ul>")
  ac.println("<li> <b>Absolute name</b>: " + contained.absolute_name)
  ac.println("<li> <b>Name</b>: " + contained.name)
  ac.println("<li> <b>Version</b>: " + contained.version)
  ac.println("<li> <b>Repository ID</b>: " + contained.id)
  ac.print("<li> <b>Defined in</b>: the ")
  defined_in = contained.defined_in
  try {
    label = get_label(defined_in)
  } catch (e) {
    label = "Interface Repository"
  }
  ac.anchorToObject(defined_in, label)
  ac.println("</ul>")

}

######################################################################
## This action displays the contain of a CORBA::Contained.
######################################################################

proc view(contained, ac)
{
  generate_contained_information(contained, ac)
}

######################################################################
## Declaration of these actions into the CorbaWeb ActionRepository.
######################################################################

declareAction("view", view, "Views the contain of a CORBA::Contained object")

######################################################################
# end of file 'CorbaWeb/actions/CORBA_Contained'
######################################################################

