Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » How to import uml models programmatically in the mode "User Model"
How to import uml models programmatically in the mode "User Model" [message #1697893] Tue, 09 June 2015 12:08 Go to next message
Thanh Liem Phan is currently offline Thanh Liem PhanFriend
Messages: 28
Registered: January 2015
Junior Member
Hi all,

I have a library, called "spiderLib.uml". I want to import this lib programmatically in the mode "User Model". I've digged out the source code of Papyrus, then it seems that, in the plugin oep.uml.import, the class "oep.uml.importt.ui.handlers.AbstractImportHandler.java" is appropriate for this task.

I create a new class which extends AbstractImportHandler, however, this class is prohibited to access from the library by the restriction rules.

My question is : how could I import (in user model) programmatically a lib.uml into my model. Do you have any example code?

Thanks for your help.
PTL.
Re: How to import uml models programmatically in the mode "User Model" [message #1698219 is a reply to message #1697893] Fri, 12 June 2015 09:50 Go to previous messageGo to next message
Gabriel Pascual is currently offline Gabriel PascualFriend
Messages: 31
Registered: April 2013
Location: Laval, France
Member
Hi,

The interesting code to create an imported package is in AbstractImportHandler#handleImportPackage(Package) method:
// Create the new Imported Package element 
PackageImport packageImport = UMLFactory.eINSTANCE.createPackageImport();

// Load library to import
Package importedPackage = EMFHelper.reloadIntoContext(libraryToImport, targetElement);

// Add to target model 
targetElement.getPackageImports().add(packageImport);
packageImport .setImportedPackage(importedPackage);


This code must be executed in a command Wink.

Regards

Gabriel


Software Development Engineer
Re: How to import uml models programmatically in the mode "User Model" [message #1698403 is a reply to message #1698219] Mon, 15 June 2015 11:05 Go to previous message
Thanh Liem Phan is currently offline Thanh Liem PhanFriend
Messages: 28
Registered: January 2015
Junior Member
Thanks Gabriel,
I've got it. It works perfectly.
Have a nice day & Regards.
Liem.
Previous Topic:"Refine" stereotype [SysML]
Next Topic:How to embed a table into a property view
Goto Forum:
  


Current Time: Thu Apr 18 00:58:16 GMT 2024

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

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

Back to the top