Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » How to programmatically interact with the model explorer
How to programmatically interact with the model explorer [message #660913] Tue, 22 March 2011 10:30
nicolas h is currently offline nicolas hFriend
Messages: 60
Registered: February 2011
Location: Grenoble, France
I developped a plugin to automatically create a new empty model uml and a class diagram into this model. I reused code from org.eclipse.papyrus.wizards.CreateModelWizard to create and open Papyrus Model :

protected boolean createAndOpenPapyrusModel(DiResourceSet diResourceSet, IFile newFile, String diagramCategoryId) {
	if(newFile == null) {
		return false;
	createPapyrusModels(diResourceSet, newFile);
	initDomainModel(diResourceSet, newFile, diagramCategoryId);
	initDiagramModel(diResourceSet, diagramCategoryId);
	return true;

it's working.

Now, I wish I improved this plugin to automatically add a new package into my model and into my .di diagram, and I don't know how to do this.

I'm looking the EcoreFactory to create a new EPackage :

EPackage myPackage = EcoreFactory.eINSTANCE.createEPackage();

but I don't know how add this package to my model.

Here is my code to lookup into my model :

ModelExplorerPageBookView modelExplorerPageBookView = (ModelExplorerPageBookView) PlatformUI
EObject model = UmlUtils.getUmlModel().lookupRoot();
EClass metaClass = model.eClass();
if (model != null) {
	for (Iterator<EObject> i = metaClass.eContents().iterator(); i.hasNext();)
		Object obj =;	            	


org.eclipse.emf.ecore.impl.EOperationImpl@a4b72c (name: isMetamodel) (ordered: false, unique: true, lowerBound: 1, upperBound: 1)
org.eclipse.emf.ecore.impl.EAttributeImpl@1f5ad1c (name: viewpoint) (ordered: false, unique: true, lowerBound: 0, upperBound: 1) (changeable: true, volatile: false, transient: false, defaultValueLiteral: null, unsettable: true, derived: false) (iD: false)
org.eclipse.emf.ecore.impl.EGenericTypeImpl@381dc2 (expression: Package)

Does anyone have an idea to use this ?

Best regards,


Previous Topic:Create new SysML diagrams
Next Topic:CreateView question
Goto Forum:

Current Time: Thu May 06 01:54:46 GMT 2021

Powered by FUDForum. Page generated in 0.01845 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top