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 06:30
nicolas h is currently offline nicolas h
Messages: 60
Registered: February 2011
Location: Grenoble, France
Member
Hi,
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);
	openDiagram(newFile);
	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
.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.showView(EXPLORER_ID);
					
EObject model = UmlUtils.getUmlModel().lookupRoot();
EClass metaClass = model.eClass();
					
if (model != null) {
	for (Iterator<EObject> i = metaClass.eContents().iterator(); i.hasNext();)
	 {
		Object obj = i.next();	            	
		System.out.println(obj.toString());
	 }


Quote:

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,

--
Nicolas

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


Current Time: Sat Aug 30 16:27:59 EDT 2014

Powered by FUDForum. Page generated in 0.01463 seconds