####### new diagram definition

model.diagramType.ejbassembler=EJBAssemblyDiagram
resource.element.EJBAssemblyDiagram.name = "EJBAssembler Diagram"
resource.element.EJBAssemblyDiagram.diagramName = "EJBAssembler"
resource.element.EJBAssemblyDiagram.icon.small = "com/togethersoft/modules/ejb/assemblerdiagram/application.gif"
resource.element.EJBAssemblyDiagram.icon.large = "com/togethersoft/modules/ejb/assemblerdiagram/diagram.gif"

resource.element.SecurityRole.icon.small = "com/togethersoft/modules/ejb/assemblerdiagram/tv_security_role.gif"
resource.element.MethodPermission.icon.small = "com/togethersoft/modules/ejb/assemblerdiagram/tv_method_permission.gif"
resource.element.ContainerTransaction.icon.small = "com/togethersoft/modules/ejb/assemblerdiagram/tv_container_transaction.gif"

###### navigator
navigator.node.item.element.EJBAssemblyDiagram.icon = "com/togethersoft/modules/ejb/assemblerdiagram/application.gif"

###### toolbar

diagram.toolbar.button.EJBAssemblyDiagram.SecurityRole = createNode("SecurityRole")
diagram.toolbar.button.EJBAssemblyDiagram.SecurityRole.icon = "com/togethersoft/modules/ejb/assemblerdiagram/security_role.gif"

# Create method permission with default role "UnknownRole"
diagram.toolbar.button.EJBAssemblyDiagram.MethodPermission = node = createNode("MethodPermission");
\                                                             node->setProperty ("Role", "UnknownRole")
diagram.toolbar.button.EJBAssemblyDiagram.MethodPermission.icon = "com/togethersoft/modules/ejb/assemblerdiagram/method_permission.gif"

diagram.toolbar.button.EJBAssemblyDiagram.AssemblyLink = createLink("AssemblyLink")
diagram.toolbar.button.EJBAssemblyDiagram.AssemblyLink.icon = "DiagramElementsToolbar/CommunicatesLink.gif"

diagram.toolbar.button.EJBAssemblyDiagram.ContainerTransaction = node = createNode("ContainerTransaction");
\                                                                 node->setProperty( "ejbTransactionAttribute", "Required" )
diagram.toolbar.button.EJBAssemblyDiagram.ContainerTransaction.icon = "com/togethersoft/modules/ejb/assemblerdiagram/container_transaction.gif"

; set for all diagrams--need to change order

diagram.toolbar.button.EJBAssemblyDiagram.Note = createNode("Note")
diagram.toolbar.button.EJBAssemblyDiagram.Note.icon = "DiagramElementsToolbar/Note.gif"
diagram.toolbar.button.EJBAssemblyDiagram.Note link =
\  if (%src%->hasPropertyValue("$shapeType", "Note"),
\      createLink("NoteLink", %dst%, %src%),
\      createLink("NoteLink")
\  )
diagram.toolbar.button.EJBAssemblyDiagram.Note link.icon = "DiagramElementsToolbar/NoteLink.gif"

###### view map

view.map.EJBAssemblyDiagram.Class.isTopLevel() && hasProperty("$ejbRole") =
\ setCanContainChilds()

view.map.*.Attribute.(hasProperty ("ENV-REF") || hasProperty ("EJB-REF") || hasProperty ("SEC-ROLE-REF") || hasProperty ("RESOURCE-REF")).NEAddition =
\  setCompartment("EJBReferences")

view.map.EJBAssemblyDiagram.Attribute.(hasProperty ("ENV-REF") || hasProperty ("EJB-REF") || hasProperty ("SEC-ROLE-REF") || hasProperty ("RESOURCE-REF")).NEAddition =
\  %parent%->setCanContainChilds();
\  setGraphicObject("$RoundRectangle");
\  setCanHaveLinks();
\  if( hasProperty( "alias" ),
\      label = label( getProperty( "alias" ) ),
\      label = label( getProperty( "$name" ) )
\    );
\  names = addCompartment("RectangleInvisible", "Names" );
\  names->setLayoutConstraints( minHeight(22), preferredWidth(170), fixedHeight(true) );
\  nameLabel = addToCompartment(label, "Names");
\  setInplaceEditor({});
\  nameLabel->setInplaceEditor({inProperty:="$name", outProperty:="$defaultInplaceEditing", default:=true});
\  nameLabel->setAlignment("Center");
\  nameLabel->setLayoutConstraints(preferredHeight(16),fixedHeight(true))

view.map.EJBAssemblyDiagram.Operation.true =
\  %parent%->setCanContainChilds();
\  setGraphicObject("$RoundRectangle");
\  setCanHaveLinks();
\  compartments = addCompartment("RectangleInvisible","Compartments");
\  compartments->setLayoutConstraints(horizontalAlign("left"),verticalAlign("top"),
\                                     widthAlign("parentDefined"),heightAlign("parentDefined"));
\
\  names = addCompartment(compartments, "RectangleInvisible", "Names" );
\  names->setLayoutConstraints( minHeight(22), preferredWidth(170), fixedHeight(true) );
\
\  if(hasProperty("stereotype"),
\    stereoLabel = %parent%->addToCompartment(label("<<"+getProperty("stereotype")+">>"), "Operations");
\    stereoLabel->setInplaceEditor({ property:="stereotype", element:=%element% });
\    stereoLabel->setFont(%defaultFontName%, "Plain", 12);
\    stereoLabel->setLayoutConstraints(preferredHeight(16),fixedHeight(true))
\  );
\  if( hasProperty( "alias" ),
\      label = label( getProperty( "alias" ) ),
\      label = label( getProperty( "$name" ) )
\    );
\  nameLabel = addToCompartment(label,"Names");
\  setInplaceEditor({});
\  nameLabel->setInplaceEditor({inProperty:="$name", outProperty:="$defaultInplaceEditing", default:=true});
\  nameLabel->setAlignment("Center");
\  nameLabel->setLayoutConstraints(preferredHeight(16),fixedHeight(true));
\  if(hasProperty("$static"), label->setUnderlined());
\  if(hasProperty("$abstract"),
\    setFont(%defaultFontName%, "Italic", 12),
\    setFont(%defaultFontName%, "Plain", 12)
\  );
\  nameLabel->setInplaceEditor({property:="$name", default:=true});
\  setLayoutConstraints(preferredHeight(16),fixedHeight(true));
\  if(hasProperty("$hyperLink") || hasProperty("url"), setForeground(RGB(0,0,255)));
\  if(!hasOptionValue("option.detail", "Analysis") && hasOptionValue("option.formatting", "Java"),
\    prepend(getProperty("$returnType") + " ")
\  );
\  if(hasOptionValue("option.detail", "Implementation"),
\    if(hasOptionValue("option.formatting", "Java"),
\       append("(" + getProperty("$parametersText") + ")"),
\       append("(" + getProperty("$umlParametersText") + ")")
\    )
\  );
\  if(!hasOptionValue("option.detail", "Analysis") && hasOptionValue("option.formatting", "UML"),
\    if(hasProperty("$returnType"), append(":" + getProperty("$returnType")))
\  );
\  if(!hasOptionValue("option.detail", "Analysis"),
\    if(hasProperty("$public"),prepend("+"));
\    if(hasProperty("$private"),prepend("-"));
\    if(hasProperty("$protected"),prepend("#"));
\    if(hasProperty("$package"),prepend(" "))
\  )

view.map.*.SecurityRole.isOnTopLevelDiagram() =
\  setGraphicObject( "RectangleInvisible" );
\  setCanHaveLinks();
\  inset = addCompartment( "RectangleInvisible", "inset" );
\  inset->setLayoutConstraints( minHeight(5), fixedHeight(true) );
\  shapeCompartment = addCompartment( "RectangleInvisible", "shapeCompartment" );
\  shapeCompartment->setLayoutConstraints( minWidth(30), minHeight(30), preferredWidth(52), preferredHeight(52) );
\  shape = shapeCompartment->addCompartment( "ActorBold", "shape" );
\  shape->setLayoutConstraints( widthAlign("parentDefined"), heightAlign("parentDefined") );
\  if (!hasViewProperty("2DLook"), shape->setShadow(3, RGB(0,0,128)));
\
\  if( hasViewProperty("$imported"),
\      markersCompartment = addCompartment( "RectangleInvisibleMarked", "MarkersCompartment" );
\      markersCompartment->setLayoutConstraints( minHeight(10), fixedHeight(true))
\    );
\
\  names = addCompartment( "RectangleInvisible", "Names" );
\  names->setLayoutConstraints( minHeight(20), preferredWidth(30), fixedHeight(true) );
\  if( hasProperty("stereotype"),
\    stereoLabel = addToCompartment( label("<<"+getProperty("stereotype")+">>"), "Names" );
\    stereoLabel->setInplaceEditor( {property:="stereotype"} );
\    stereoLabel->setFont( %defaultFontName%, "Plain", 12 );
\    stereoLabel->setAlignment( "Center" );
\    stereoLabel->setLayoutConstraints( preferredHeight(16), fixedHeight(true) )
\  );
\  nameLabel = addToCompartment( label( getProperty( "$name" ) ), "Names" );
\  nameLabel->setInplaceEditor( { outProperty:="$defaultInplaceEditing", default:=true } );
\  nameLabel->setLayoutConstraints( preferredHeight(16), fixedHeight(true) );
\  nameLabel->setAlignment("Center");
\  if(hasProperty("$hyperLink") || hasProperty("url"), nameLabel->setForeground(RGB(0,0,255)))

view.map.*.MethodPermission.isOnTopLevelDiagram() =
\  setGraphicObject( "RectangleInvisible" );
\  setCanHaveLinks();
\  inset = addCompartment( "RectangleInvisible", "inset" );
\  inset->setLayoutConstraints( minHeight(5), fixedHeight(true) );
\  shapeCompartment = addCompartment( "RectangleInvisible", "shapeCompartment" );
\  shapeCompartment->setLayoutConstraints( minWidth(30), minHeight(30), preferredWidth(52), preferredHeight(52) );
\  shape = shapeCompartment->addCompartment( "ActorBold", "shape" );
\  shape->setLayoutConstraints( widthAlign("parentDefined"), heightAlign("parentDefined") );
\  if (!hasViewProperty("2DLook"), shape->setShadow(3, RGB(0,0,128)));
\  if( hasViewProperty("$imported"),
\      markersCompartment = addCompartment( "RectangleInvisibleMarked", "MarkersCompartment" );
\      markersCompartment->setLayoutConstraints( minHeight(10), fixedHeight(true))
\    );
\
\  names = addCompartment( "RectangleInvisible", "Names" );
\  names->setLayoutConstraints( minHeight(20), preferredWidth(30), fixedHeight(true) );
\  nameLabel = addToCompartment( label( "MethodPermission" ), "Names" );
\  nameLabel->setAlignment("Center");
\  if(hasProperty("$hyperLink") || hasProperty("url"), nameLabel->setForeground(RGB(0,0,255)))

view.map.*.EJBResource.isOnTopLevelDiagram() =
\  setGraphicObject( "Resource" );
\  setLayoutConstraints( minWidth(32), minHeight(25), preferredWidth(50), preferredHeight(140),
\                        canShiftX(true), canShiftY(true) );
\  setCanHaveLinks();
\  setLayout("Move");
\  if (!hasViewProperty("2DLook"), shape->setShadow(3, RGB(0,0,128)));
\  names = addCompartment("RectangleInvisible","Names");
\  names->setLayout("Move");
\  names->setLayoutConstraints(horizontalAlign("left"),verticalAlign("top"),
\                       widthAlign("parentDefined"),heightAlign("parentDefined"));
\  nameLabel = addToCompartment(label(getProperty("$name")),"Names");
\  nameLabel->setInplaceEditor({inProperty:="$name", outProperty:="$defaultInplaceEditing", default:=true});
\  nameLabel->setLayoutConstraints( preferredHeight(16), fixedHeight(true) );
\  nameLabel->setAlignment("Center");
\
\  if( hasViewProperty("$imported"),
\      importedMark=addCompartment( "ShortcutMark", "shortcutMark" );
\      importedMark->setLayoutConstraints( minWidth(12), minHeight(10), horizontalAlign("left"), verticalAlign("bottom") )
\    )

view.map.*.ContainerTransaction.isOnTopLevelDiagram() =
\  setGraphicObject( "RectangleInvisible" );
\  setLayoutConstraints( canShiftX(true), canShiftY(true) );
\  setCanHaveLinks();
\  setResizable( false );
\  setBackground( black );
\  shape = addCompartment( "CircleDouble", "shape" );
\  shape->setLayoutConstraints( minWidth(15), maxWidth(15), minHeight(15), maxHeight(15) );
\
\  names = addCompartment("RectangleInvisible","Names");
\  nameLabel = addToCompartment(label(getProperty("ejbTransactionAttribute")),"Names");
\  nameLabel->setLayoutConstraints( preferredHeight(16), fixedHeight(true) );
\  nameLabel->setAlignment("Center");
\  if( hasViewProperty("$imported"),
\      importedMark = addCompartment( "RectangleInvisibleMarked", "shortcutMark" );
\      importedMark->setLayoutConstraints( minHeight(10), fixedHeight(true) )
\    )

view.map.*.AssemblingEJB.isOnTopLevelDiagram() =
\  setGraphicObject("BeanComponent");
\  if (!hasViewProperty("2DLook"), shape->setShadow(3, RGB(0,0,128)));
\  setCanHaveLinks();
\  setCanContainChilds();
\  setLayoutConstraints(minWidth(16),minHeight(16),
\                       preferredWidth(50),preferredHeight(40),
\                       canShiftX(true),canShiftY(true));
\  setLayout("Move");
\  compartments = addCompartment("RectangleInvisible","Compartments");
\  compartments->setLayoutConstraints(horizontalAlign("left"),verticalAlign("top"),
\                                     widthAlign("parentDefined"),heightAlign("parentDefined"));
\  names = addCompartment(compartments, "RectangleInvisible","Names");
\  names->setLayoutConstraints(minHeight(20),maxHeight(40),fixedHeight(true));
\  internalTransitions  = addCompartment(compartments,"$ScrolledRectangle","EJBAssemblingMethods");
\  internalTransitions->setLayoutConstraints(minHeight(20));
\  internalTransitions->setHorizontalMargin(10);
\  nameLabel = addToCompartment(label(getProperty("$name")),"Names");
\  nameLabel->setInplaceEditor({inProperty:="$name", outProperty:="$defaultInplaceEditing", default:=true});
\  nameLabel->setAlignment("Center");
\  nameLabel->setLayoutConstraints(preferredHeight(16),fixedHeight(true));
\  if(hasProperty("$hyperLink") || hasProperty("url"), nameLabel->setForeground(RGB(0,0,255)));
\
\  if( hasViewProperty("$imported"),
\      importedMark=addCompartment( "ShortcutMark", "shortcutMark" );
\      importedMark->setLayoutConstraints( minWidth(12), minHeight(10), horizontalAlign("left"), verticalAlign("bottom") )
\    )

view.map.*.EJBAssemblingMethod.isOnTopLevelDiagram() =
\  setGraphicObject("$RoundRectangle");
\  if (!hasViewProperty("2DLook"), shape->setShadow(3, RGB(0,0,128)));
\  setCanHaveLinks();
\  setCanContainChilds();
\  setLayoutConstraints(minWidth(16),minHeight(16),
\                       preferredWidth(50),preferredHeight(40),
\                       canShiftX(true),canShiftY(true));
\  setLayout("Move");
\  compartments = addCompartment("RectangleInvisible","Compartments");
\  compartments->setLayoutConstraints(horizontalAlign("left"),verticalAlign("top"),
\                                     widthAlign("parentDefined"),heightAlign("parentDefined"));
\  names = addCompartment(compartments, "RectangleInvisible","Names");
\  names->setLayoutConstraints(minHeight(20),maxHeight(40),fixedHeight(true));
\  nameLabel = addToCompartment(label(getProperty("$name")),"Names");
\  nameLabel->setInplaceEditor({inProperty:="$name", outProperty:="$defaultInplaceEditing", default:=true});
\  nameLabel->setAlignment("Center");
\  nameLabel->setLayoutConstraints(preferredHeight(16),fixedHeight(true));
\  if(hasProperty("$hyperLink") || hasProperty("url"), nameLabel->setForeground(RGB(0,0,255)))
#\  setCompartment ("EJBAssemblingMethods")

#-------------------------------------------------------

view.map.*.AssemblyLink.true =
\   setForeground(RGB(0,128,128))

view.map.*.Attribute.hasProperty ("ENV-REF") =
\ setForeground (RGB (0, 100, 200))

view.map.*.Attribute.hasProperty ("EJB-REF") =
\ setForeground (RGB (0, 150, 200))

view.map.*.Attribute.hasProperty ("SEC-ROLE-REF") =
\ setForeground (RGB (100, 150, 255))

view.map.*.Attribute.hasProperty ("RESOURCE-REF") =
\ setForeground (RGB (200, 150, 255))

#-------------------------------------------------------

view.map.*.*.true.assembler_background =
\ backgroundColor = RGB(getViewProperty("backgroundColor"));
\ if(backgroundColor != null, setBackground(backgroundColor))

view.map.*.*.true.assembler_foreground =
\ foregroundColor = RGB(getViewProperty("foregroundColor"));
\ if(foregroundColor != null, setForeground(foregroundColor))

#-------------------------------------
# Link constraints
#-------------------------------------

model.constraint.link.AssemblyLink.source.1 =
\	 hasPropertyValue("$shapeType", "SecurityRole") ||
\	 hasPropertyValue("$shapeType", "MethodPermission") ||
\	 hasPropertyValue("$shapeType", "ContainerTransaction") ||
\	 hasProperty("EJB-REF") ||
\	 hasProperty("SEC-ROLE-REF") ||
\	 hasProperty("$ejbBean") ||
\	 hasProperty("$ejbBusinessMethod")

model.constraint.link.AssemblyLink.both.1 =
\	 (hasPropertyValue(%src%, "$shapeType", "SecurityRole") &&
\	    (hasProperty(%dst%, "SEC-ROLE-REF") ||
\	     hasPropertyValue(%dst%, "$shapeType", "MethodPermission"))) ||
\	 (hasPropertyValue(%src%, "$shapeType", "MethodPermission") &&
\	    (hasProperty(%dst%, "$ejbBusinessMethod") ||
\	     hasProperty(%dst%, "$ejbBean") ||
\	     hasPropertyValue(%dst%, "$shapeType", "SecurityRole"))) ||
\	 (hasPropertyValue(%src%, "$shapeType", "ContainerTransaction") &&
\	    (hasProperty(%dst%, "$ejbBusinessMethod") ||
\	     hasProperty(%dst%, "$ejbBean"))) ||
\	 (hasProperty(%src%, "$ejbBean") &&
\	    (hasProperty(%dst%, "EJB-REF") ||
\	     hasPropertyValue(%dst%, "$shapeType", "MethodPermission") ||
\	     hasPropertyValue(%dst%, "$shapeType", "ContainerTransaction"))) ||
\	 (hasProperty(%src%, "$ejbBusinessMethod") &&
\	    (hasPropertyValue(%dst%, "$shapeType", "MethodPermission") ||
\	     hasPropertyValue(%dst%, "$shapeType", "ContainerTransaction"))) ||
\	 (hasProperty(%src%, "SEC-ROLE-REF") &&
\	    hasPropertyValue(%dst%, "$shapeType", "SecurityRole")) ||
\	 (hasProperty(%src%, "EJB-REF") &&
\	    hasProperty(%dst%, "$ejbBean"))

model.constraint.node.*.container.ejbassembly =
\	(!hasPropertyValue("$shapeType", "MethodPermission")) &&
\	(!hasPropertyValue("$shapeType", "SecurityRole")) &&
\	(!hasPropertyValue("$shapeType", "ContainerTransaction"))
model.constraint.node.*.container.ejbassembly.message =
\	"This element can't contain subelements"
