Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

UML Import Model Trimmer

< To: Tigerstripe Extension Points

  • Full name : org.eclipse.tigerstripe.workbench.ui.UML2Import.umlImportModelTrimmer

Purpose : During a UML2 import, the Model that is being imported can be "trimmed" to prevent unncessary imports. This can be useful in the following situations: If there are "private" parts of the model that you do not wish to import into Tigerstripe. If you have previously imported the Model and wish to only se "deltas", you can keep a record of what is imported and then only present deltas for re-import.

  • Usage :

The extension point only has 2 attributes: "name" - This is only used for logging and has no functional purpose. "trimmer_class" - This is the name of a class that must implement the IModelTrimmer interface.

The IModelTrimmer interface has only one method : public Model trimModel(Model modelToTrim);

The UML2 Model that is loaded form the specified files is passed in and a UML2 Model is to be returned. There are no constraints as to the relationship between the two models.

  • Example :

This example would allow for removal of any element with the stereotype "Private" to be removed. The removal should take care to maintain the integrity of the model.

   public Model trimModel(Model modelToTrim) {
       List<EObject> itemsToRemove = new ArrayList<EObject>();
       TreeIterator t = modelToTrim.eAllContents();
       t = modelToTrim.eAllContents();
       while (t.hasNext()) {
           EObject eObject = (EObject) t.next();
           if (eObject instanceof Classifier) {
               Classifier classifier = (Classifier) eObject;
               if (classifier.getAppliedStereotype("Private") != null){
                   // Add to list of items to remove from Model
                   itemsToRemove.add(classifier);			
               }
           } 
       }		
       // Do the removal here	
       return modelToTrim;
   }

Back to the top