Hi Klass and others!
Here is a simple example of DI scripting. It is included in SAM/UML/SysML
standard TOPCASED scripts.
Note that due to bug
http://gforge.enseeiht.fr/tracker/index.php?func=detail&aid=3898&group_id=52&atid=109
you may experience problem in Topcased 5.
# Menu: Topcased > Update fonts
#
from org.topcased.modeler.di.model import GraphNode
from org.topcased.modeler.di.model import EMFSemanticModelBridge
from org.topcased.modeler.di.model.util import DIUtils
from org.topcased.scripting.di import DiDOM
from org.topcased.sam import Port
from org.eclipse.swt.graphics import FontData
from org.topcased.modeler import ModelerPropertyConstants
from org.eclipse.jface.resource import StringConverter
from org.eclipse.swt.SWT import NORMAL
def main():
di = DiDOM()
print "[INFO] Update Fonts"
selection = di.getSelection("GraphNode")
if selection == None:
print "[ERROR] Please select a graphical node."
return
DIresource = selection.eResource()
root = DIresource.getContents().get(0)
font = FontData("Tahoma", 8, NORMAL)
for elt in root.eAllContents():
if isinstance(elt, GraphNode):
modelElt = elt.getSemanticModel()
if isinstance(modelElt, EMFSemanticModelBridge):
samObject = modelElt.getElement()
if isinstance(samObject, Port):
print "[INFO] " + samObject.eContainer().getName() + "::" +
samObject.getName() + " has been updated."
DIUtils.setProperty(elt, ModelerPropertyConstants.FONT,
StringConverter.asString(font))
DIresource.save(None)
print "[INFO] file " + DIresource.getURI().toString() + " has been saved."
main()
---
Pierre
-----Message d'origine-----
De : [email protected]
[mailto:[email protected]] De la part de Topcased user
list where issues are discussed
Envoyé : lundi 19 septembre 2011 14:06
À : [email protected]
Objet : [Topcased-users] example of .di scripting
Hi,
It seems like DI scripting was introduced as of Topcased 4.0.
<http://gforge.enseeiht.fr/tracker/?group_id=52&atid=133&func=detail&aid=3228>
Does anyone (Pierre?) have a non-confidential example lying around?
TIA,
Klaas
The information in this e-mail is confidential. The contents may not be
disclosed or used by anyone other than the addressee. Access to this e-mail by
anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and
delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of
this e-mail as it has been sent over public networks. If you have any concerns
over the content of this message or its Accuracy or Integrity, please contact
Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus
scanning software but you should take whatever measures you deem to be
appropriate to ensure that this message and any attachments are virus free.
_______________________________________________
Topcased-users mailing list
[email protected]
http://lists.gforge.enseeiht.fr/cgi-bin/mailman/listinfo/topcased-users