Hello,
I'm just about
developing an addin for rose and trying to implement the
following functionality:
In certain cases
the user is not allowed to create a new class (for example by clicking
the class icon in the toolbar and then in the
diagram).
So I registered
for the NewModelElementEvent and try to delete the class
afterwards:
Public
Sub OnNewModelElement(objRoseApp As RoseApplication, objItem As
RoseItem)
...
If aktuelleAnsicht
<> ANSICHT.MODELL Then
Dim res As VbMsgBoxResult
Dim
aktModell As RoseModel
res =
MsgBox("...Message...", vbOKOnly, "Error")
[Hsia,
John] You may have to typecast the roseitem back to a
class. In VB, that code would look
like
dim
myClass as RoseClass
set
myClass
= objItem
aktModell = objRoseApp.CurrentModel
[Hsia, John] missing the set - i.e. "set
aktModell = ..."
MsgBox "Name "
+ objItem.Name +
aktModell.GetAllClasses.GetWithUniqueID(objItem.GetUniqueID).Name ' for
debug purposes
aktModell.RootCategory.DeleteClass
(aktModell.GetAllClasses.GetWithUniqueID(objItem.GetUniqueID))
[Hsia,
John] Usually, I delete the class from the parent category for that
class not the root category. You're assuming that the class belongs to
the logical view - it may not.
End
If
End Sub
What happens is:
When I create a class (and the condition aktuelleAnsicht <>
ANSICHT.MODELL is true) the first msgbox appears but not the second one (the
one beginning with "Name").
So: If I have a
RoseItem that is a class, how can I delete it?
Thank you in
advance,
Alexander