Coverage Report - org.argouml.model.euml.EUMLModelImplementation
 
Classes in this File Line Coverage Branch Coverage Complexity
EUMLModelImplementation
0%
0/159
0%
0/70
1.884
EUMLModelImplementation$1
0%
0/3
N/A
1.884
 
 1  
 // $Id: EUMLModelImplementation.java 19102 2011-03-03 20:57:29Z thn $
 2  
 /*******************************************************************************
 3  
  * Copyright (c) 2007,2010 Tom Morris and other contributors
 4  
  * All rights reserved. This program and the accompanying materials
 5  
  * are made available under the terms of the Eclipse Public License v1.0
 6  
  * which accompanies this distribution, and is available at
 7  
  * http://www.eclipse.org/legal/epl-v10.html
 8  
  *
 9  
  * Contributors:
 10  
  *    Tom Morris - initial implementation
 11  
  *    Bogdan Pistol - undo support
 12  
  *    thn
 13  
  *    
 14  
  * This implementation uses ideas and code snippets from the 
 15  
  * "org.eclipse.uml2.uml.editor.presentation" package.
 16  
  * 
 17  
  * The package "org.eclipse.uml2.uml.editor.presentation" is part of the
 18  
  * Eclipse UML2 plugin and it is available under the terms of 
 19  
  * the Eclipse Public License v1.0.
 20  
  *****************************************************************************/
 21  
 
 22  
 package org.argouml.model.euml;
 23  
 
 24  
 import java.io.FileInputStream;
 25  
 import java.io.IOException;
 26  
 import java.io.OutputStream;
 27  
 import java.util.ArrayList;
 28  
 import java.util.HashMap;
 29  
 import java.util.List;
 30  
 import java.util.Map;
 31  
 
 32  
 import org.apache.log4j.Logger;
 33  
 import org.argouml.model.DiagramInterchangeModel;
 34  
 import org.argouml.model.ModelImplementation;
 35  
 import org.argouml.model.UmlException;
 36  
 import org.eclipse.emf.common.command.BasicCommandStack;
 37  
 import org.eclipse.emf.common.notify.AdapterFactory;
 38  
 import org.eclipse.emf.common.util.URI;
 39  
 import org.eclipse.emf.ecore.EPackage.Registry;
 40  
 import org.eclipse.emf.ecore.EcorePackage;
 41  
 import org.eclipse.emf.ecore.provider.EcoreItemProviderAdapterFactory;
 42  
 import org.eclipse.emf.ecore.resource.Resource;
 43  
 import org.eclipse.emf.ecore.resource.ResourceSet;
 44  
 import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
 45  
 import org.eclipse.emf.edit.domain.EditingDomain;
 46  
 import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
 47  
 import org.eclipse.uml2.common.edit.domain.UML2AdapterFactoryEditingDomain;
 48  
 import org.eclipse.uml2.uml.UMLPackage;
 49  
 import org.eclipse.uml2.uml.edit.providers.UMLItemProviderAdapterFactory;
 50  
 import org.eclipse.uml2.uml.edit.providers.UMLReflectiveItemProviderAdapterFactory;
 51  
 import org.eclipse.uml2.uml.edit.providers.UMLResourceItemProviderAdapterFactory;
 52  
 import org.eclipse.uml2.uml.resource.UML212UMLResource;
 53  
 import org.eclipse.uml2.uml.resource.UML22UMLExtendedMetaData;
 54  
 import org.eclipse.uml2.uml.resource.UML22UMLResource;
 55  
 import org.eclipse.uml2.uml.resource.UMLResource;
 56  
 import org.eclipse.uml2.uml.resource.XMI212UMLResource;
 57  
 import org.eclipse.uml2.uml.resource.XMI2UMLExtendedMetaData;
 58  
 import org.eclipse.uml2.uml.resource.XMI2UMLResource;
 59  
 
 60  
 /**
 61  
  * Eclipse UML2 implementation of the ArgoUML Model subsystem. Although built on
 62  
  * the Eclipse UML2 plugin which is, in turn, built on eCore and the Eclipse
 63  
  * Modeling Framework (EMF), the only things required from Eclipse are the five
 64  
  * Jars which implement UML2, eCore, and the subset of EMF needed for to support
 65  
  * them.
 66  
  * <p>
 67  
  * The implementation of this subsystem was generously sponsored by Google as
 68  
  * part of the Google Summer of Code 2007. A large part of the implementation was
 69  
  * built by the sponsored student, Bogdan Ciprian Pistol, who was mentored by
 70  
  * Tom Morris.
 71  
  * <p>
 72  
  * This implementation uses ideas and code snippets from the 
 73  
  * "org.eclipse.uml2.uml.editor.presentation" package which is part of the
 74  
  * Eclipse UML2 plugin.
 75  
  * 
 76  
  * @author Bogdan Ciprian Pistol
 77  
  * @author Tom Morris <tfmorris@gmail.com>
 78  
  * @since ArgoUML 0.25.4, May 2007
 79  
  */
 80  0
 public class EUMLModelImplementation implements ModelImplementation {
 81  
 
 82  0
     private static final Logger LOG =
 83  
         Logger.getLogger(EUMLModelImplementation.class);
 84  
 
 85  
     private ActivityGraphsFactoryEUMLlImpl theActivityGraphsFactory;
 86  
 
 87  
     private ActivityGraphsHelperEUMLImpl theActivityGraphsHelper;
 88  
 
 89  
     private AggregationKindEUMLImpl theAggregationKind;
 90  
 
 91  
     @SuppressWarnings("deprecation")
 92  
     private ChangeableKindEUMLImpl theChangeableKind;
 93  
 
 94  
     private CollaborationsFactoryEUMLImpl theCollaborationsFactory;
 95  
 
 96  
     private CollaborationsHelperEUMLImpl theCollaborationsHelper;
 97  
 
 98  
     private CommonBehaviorFactoryEUMLImpl theCommonBehaviorFactory;
 99  
 
 100  
     private CommonBehaviorHelperEUMLImpl theCommonBehaviorHelper;
 101  
 
 102  
     private ConcurrencyKindEUMLImpl theConcurrencyKind;
 103  
 
 104  
     private CopyHelperEUMLImpl theCopyHelper;
 105  
 
 106  
     private CoreFactoryEUMLImpl theCoreFactory;
 107  
 
 108  
     private CoreHelperEUMLImpl theCoreHelper;
 109  
 
 110  
     private DataTypesFactoryEUMLImpl theDataTypesFactory;
 111  
 
 112  
     private DataTypesHelperEUMLImpl theDataTypesHelper;
 113  
 
 114  
     private DirectionKindEUMLImpl theDirectionKind;
 115  
 
 116  
     private ExtensionMechanismsFactoryEUMLImpl theExtensionMechanismsFactory;
 117  
 
 118  
     private ExtensionMechanismsHelperEUMLImpl theExtensionMechanismsHelper;
 119  
 
 120  
     private FacadeEUMLImpl theFacade;
 121  
 
 122  
     private MetaTypesEUMLImpl theMetaTypes;
 123  
 
 124  
     private ModelEventPumpEUMLImpl theModelEventPump;
 125  
 
 126  
     private ModelManagementFactoryEUMLImpl theModelManagementFactory;
 127  
 
 128  
     private ModelManagementHelperEUMLImpl theModelManagementHelper;
 129  
 
 130  
     private OrderingKindEUMLImpl theOrderingKind;
 131  
 
 132  
     private PseudostateKindEUMLImpl thePseudostateKind;
 133  
 
 134  
     @SuppressWarnings("deprecation")
 135  
     private ScopeKindEUMLImpl theScopeKind;
 136  
 
 137  
     private StateMachinesFactoryEUMLImpl theStateMachinesFactory;
 138  
 
 139  
     private StateMachinesHelperEUMLImpl theStateMachinesHelper;
 140  
 
 141  
     private UmlFactoryEUMLImpl theUmlFactory;
 142  
 
 143  
     private UmlHelperEUMLImpl theUmlHelper;
 144  
 
 145  
     private UseCasesFactoryEUMLImpl theUseCasesFactory;
 146  
 
 147  
     private UseCasesHelperEUMLImpl theUseCasesHelper;
 148  
 
 149  
     private VisibilityKindEUMLImpl theVisibilityKind;
 150  
     
 151  
     private CommandStackImpl theCommandStack;
 152  
 
 153  
     /**
 154  
      * This keeps track of the editing domain that is used to track all changes
 155  
      * to the model.
 156  
      * <p>
 157  
      * TODO: This probably needs to be a set of EditingDomain so that we can
 158  
      * manage an EditingDomain per project.
 159  
      */
 160  
     private AdapterFactoryEditingDomain editingDomain;
 161  
     
 162  
     /**
 163  
      * Map of which resources are read-only.
 164  
      * <p>
 165  
      * TODO: This needs to be managed per EditingDomain.
 166  
      */
 167  0
     private Map<Resource,Boolean> readOnlyMap = 
 168  
         new HashMap<Resource, Boolean>();
 169  
 
 170  
     /**
 171  
      * Constructor.
 172  
      */
 173  0
     public EUMLModelImplementation() {
 174  0
         initializeEditingDomain();
 175  0
         LOG.debug("EUML Init - editing domain initialized"); //$NON-NLS-1$
 176  0
     }
 177  
 
 178  
     /**
 179  
      * This sets up the editing domain for the model editor.
 180  
      * 
 181  
      * TODO: We probably need an EditingDomain per Argo project so that we can 
 182  
      * keep the ResourceSets separate.
 183  
      */
 184  
     private void initializeEditingDomain() {
 185  
         // If the eUML.resources system property is defined then we are in a
 186  
         // stand alone application, else we're in an Eclipse plug in.
 187  
         // The eUML.resource should contain the path to the
 188  
         // org.eclipse.uml2.uml.resource jar plugin.
 189  0
         String path = System.getProperty("eUML.resources"); //$NON-NLS-1$
 190  
 
 191  0
         BasicCommandStack commandStack = new BasicCommandStack() {
 192  
 
 193  
             @Override
 194  
             protected void handleError(Exception exception) {
 195  0
                 super.handleError(exception);
 196  0
                 throw new RuntimeException(exception);
 197  
             }
 198  
 
 199  
         };
 200  
 
 201  0
         List<AdapterFactory> factories = new ArrayList<AdapterFactory>();
 202  0
         factories.add(new UMLResourceItemProviderAdapterFactory());
 203  0
         factories.add(new UMLItemProviderAdapterFactory());
 204  0
         factories.add(new EcoreItemProviderAdapterFactory());
 205  0
         factories.add(new UMLReflectiveItemProviderAdapterFactory());
 206  0
         ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(
 207  
                 factories);
 208  
 
 209  
         // TODO: This will need to be adapted to send undo/redo commands back
 210  
         // to our consumer (e.g. ArgoUML) if a new undo mechanism is implemented
 211  
         // for the Model subsystem - tfm
 212  0
         editingDomain = new UML2AdapterFactoryEditingDomain(
 213  
                 adapterFactory, commandStack, readOnlyMap);
 214  
 
 215  0
         ResourceSet resourceSet = editingDomain.getResourceSet();
 216  0
         Map<String, Object> extensionToFactoryMap = 
 217  
             resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
 218  0
         Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
 219  
 
 220  0
         if (path != null) {
 221  
             try {
 222  0
                 FileInputStream in = new FileInputStream(path);
 223  0
                 in.close();
 224  0
             } catch (IOException e) {
 225  0
                 throw (new RuntimeException(e));
 226  0
             }
 227  
 
 228  0
             path = path.replace('\\', '/');
 229  
             // These lines were one cause for issue 5915: (Were they needed?)
 230  
             // TODO: Review - tfm
 231  
             //if (Character.isLetter(path.charAt(0))) {
 232  
             //    path = '/' + path;
 233  
             //}
 234  0
             URI uri = URI.createURI("jar:file:" + path + "!/"); //$NON-NLS-1$ //$NON-NLS-2$
 235  0
             LOG.debug("eUML.resource URI --> " + uri); //$NON-NLS-1$
 236  
 
 237  0
             Registry packageRegistry = resourceSet.getPackageRegistry();
 238  0
             packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
 239  0
             packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
 240  
             // for other xmi files with further namespaces:
 241  0
             packageRegistry.put(XMI212UMLResource.UML_METAMODEL_2_1_1_NS_URI, UMLPackage.eINSTANCE);
 242  0
             packageRegistry.put(XMI212UMLResource.UML_METAMODEL_2_1_1_URI, UMLPackage.eINSTANCE);
 243  0
             packageRegistry.put(XMI212UMLResource.UML_METAMODEL_2_1_NS_URI, UMLPackage.eINSTANCE);
 244  0
             packageRegistry.put(XMI212UMLResource.UML_METAMODEL_2_1_URI, UMLPackage.eINSTANCE);
 245  0
             packageRegistry.put(XMI212UMLResource.UML_METAMODEL_2_2_NS_URI, UMLPackage.eINSTANCE);
 246  0
             packageRegistry.put(XMI212UMLResource.UML_METAMODEL_NS_URI, UMLPackage.eINSTANCE);
 247  0
             packageRegistry.put(XMI212UMLResource.UML_METAMODEL_URI, UMLPackage.eINSTANCE);
 248  
             // eclipse namespaces:
 249  0
             packageRegistry.put(UML212UMLResource.UML_METAMODEL_NS_URI, UMLPackage.eINSTANCE);
 250  0
             packageRegistry.put("http://www.eclipse.org/uml2/2.0.0/UML", UMLPackage.eINSTANCE);
 251  
 
 252  
             // For the .uml files in the eclipse jar files, we need this:
 253  0
             extensionToFactoryMap.put(
 254  
                     UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
 255  0
             uriMap.put(
 256  
                     URI.createURI(UMLResource.LIBRARIES_PATHMAP),
 257  
                     uri.appendSegment("libraries").appendSegment("")); //$NON-NLS-1$ //$NON-NLS-2$
 258  0
             uriMap.put(
 259  
                     URI.createURI(UMLResource.METAMODELS_PATHMAP),
 260  
                     uri.appendSegment("metamodels").appendSegment("")); //$NON-NLS-1$//$NON-NLS-2$
 261  0
             uriMap.put(
 262  
                     URI.createURI(UMLResource.PROFILES_PATHMAP),
 263  
                     uri.appendSegment("profiles").appendSegment("")); //$NON-NLS-1$//$NON-NLS-2$
 264  
         }
 265  
 
 266  0
         extensionToFactoryMap.put(
 267  
                 UML22UMLResource.FILE_EXTENSION,
 268  
                 UML22UMLResource.Factory.INSTANCE);
 269  0
         extensionToFactoryMap.put(
 270  
                 XMI2UMLResource.FILE_EXTENSION,
 271  
                 XMI2UMLResource.Factory.INSTANCE);
 272  0
         uriMap.putAll(UML22UMLExtendedMetaData.getURIMap());
 273  0
         uriMap.putAll(XMI2UMLExtendedMetaData.getURIMap());
 274  0
     }
 275  
 
 276  
     /**
 277  
      * Getter for {@link #editingDomain the Editing Domain}
 278  
      * 
 279  
      * @return the editing domain of the current EUMLModelImplementation
 280  
      *         instance
 281  
      */
 282  
     public EditingDomain getEditingDomain() {
 283  0
         return editingDomain;
 284  
     }
 285  
     
 286  
     /**
 287  
      * @return the read only map for resources in the EditingDomain
 288  
      */
 289  
     public Map<Resource, Boolean> getReadOnlyMap() {
 290  0
         return readOnlyMap;
 291  
     }
 292  
 
 293  
     public ActivityGraphsFactoryEUMLlImpl getActivityGraphsFactory() {
 294  0
         if (theActivityGraphsFactory == null) {
 295  0
             theActivityGraphsFactory = 
 296  
                 new ActivityGraphsFactoryEUMLlImpl(this);
 297  
         }
 298  0
         return theActivityGraphsFactory;
 299  
     }
 300  
 
 301  
     public ActivityGraphsHelperEUMLImpl getActivityGraphsHelper() {
 302  0
         if (theActivityGraphsHelper == null) {
 303  0
             theActivityGraphsHelper = new ActivityGraphsHelperEUMLImpl(this);
 304  
         }
 305  0
         return theActivityGraphsHelper;
 306  
     }
 307  
 
 308  
     public AggregationKindEUMLImpl getAggregationKind() {
 309  0
         if (theAggregationKind == null) {
 310  0
             theAggregationKind = new AggregationKindEUMLImpl();
 311  
         }
 312  0
         return theAggregationKind;
 313  
     }
 314  
 
 315  
     @SuppressWarnings("deprecation")
 316  
     public ChangeableKindEUMLImpl getChangeableKind() {
 317  0
         if (theChangeableKind == null) {
 318  0
             theChangeableKind = new ChangeableKindEUMLImpl();
 319  
         }
 320  0
         return theChangeableKind;
 321  
     }
 322  
 
 323  
     public CollaborationsFactoryEUMLImpl getCollaborationsFactory() {
 324  0
         if (theCollaborationsFactory == null) {
 325  0
             theCollaborationsFactory = new CollaborationsFactoryEUMLImpl(this);
 326  
         }
 327  0
         return theCollaborationsFactory;
 328  
     }
 329  
 
 330  
     public CollaborationsHelperEUMLImpl getCollaborationsHelper() {
 331  0
         if (theCollaborationsHelper == null) {
 332  0
             theCollaborationsHelper = new CollaborationsHelperEUMLImpl(this);
 333  
         }
 334  0
         return theCollaborationsHelper;
 335  
     }
 336  
 
 337  
     public CommonBehaviorFactoryEUMLImpl getCommonBehaviorFactory() {
 338  0
         if (theCommonBehaviorFactory == null) {
 339  0
             theCommonBehaviorFactory = new CommonBehaviorFactoryEUMLImpl(this);
 340  
         }
 341  0
         return theCommonBehaviorFactory;
 342  
     }
 343  
 
 344  
     public CommonBehaviorHelperEUMLImpl getCommonBehaviorHelper() {
 345  0
         if (theCommonBehaviorHelper == null) {
 346  0
             theCommonBehaviorHelper = new CommonBehaviorHelperEUMLImpl(this);
 347  
         }
 348  0
         return theCommonBehaviorHelper;
 349  
     }
 350  
 
 351  
     public ConcurrencyKindEUMLImpl getConcurrencyKind() {
 352  0
         if (theConcurrencyKind == null) {
 353  0
             theConcurrencyKind = new ConcurrencyKindEUMLImpl();
 354  
         }
 355  0
         return theConcurrencyKind;
 356  
     }
 357  
 
 358  
     public CopyHelperEUMLImpl getCopyHelper() {
 359  0
         if (theCopyHelper == null) {
 360  0
             theCopyHelper = new CopyHelperEUMLImpl(this);
 361  
         }
 362  0
         return theCopyHelper;
 363  
     }
 364  
 
 365  
     public CoreFactoryEUMLImpl getCoreFactory() {
 366  0
         if (theCoreFactory == null) {
 367  0
             theCoreFactory = new CoreFactoryEUMLImpl(this);
 368  
         }
 369  0
         return theCoreFactory;
 370  
     }
 371  
 
 372  
     public CoreHelperEUMLImpl getCoreHelper() {
 373  0
         if (theCoreHelper == null) {
 374  0
             theCoreHelper = new CoreHelperEUMLImpl(this);
 375  
         }
 376  0
         return theCoreHelper;
 377  
     }
 378  
 
 379  
     public DataTypesFactoryEUMLImpl getDataTypesFactory() {
 380  0
         if (theDataTypesFactory == null) {
 381  0
             theDataTypesFactory = new DataTypesFactoryEUMLImpl(this);
 382  
         }
 383  0
         return theDataTypesFactory;
 384  
     }
 385  
 
 386  
     public DataTypesHelperEUMLImpl getDataTypesHelper() {
 387  0
         if (theDataTypesHelper == null) {
 388  0
             theDataTypesHelper = new DataTypesHelperEUMLImpl(this);
 389  
         }
 390  0
         return theDataTypesHelper;
 391  
     }
 392  
 
 393  
     public DirectionKindEUMLImpl getDirectionKind() {
 394  0
         if (theDirectionKind == null) {
 395  0
             theDirectionKind = new DirectionKindEUMLImpl();
 396  
         }
 397  0
         return theDirectionKind;
 398  
     }
 399  
 
 400  
     public ExtensionMechanismsFactoryEUMLImpl getExtensionMechanismsFactory() {
 401  0
         if (theExtensionMechanismsFactory == null) {
 402  0
             theExtensionMechanismsFactory =
 403  
                 new ExtensionMechanismsFactoryEUMLImpl(this);
 404  
         }
 405  0
         return theExtensionMechanismsFactory;
 406  
     }
 407  
 
 408  
     public ExtensionMechanismsHelperEUMLImpl getExtensionMechanismsHelper() {
 409  0
         if (theExtensionMechanismsHelper == null) {
 410  0
             theExtensionMechanismsHelper =
 411  
                 new ExtensionMechanismsHelperEUMLImpl(this);
 412  
         }
 413  0
         return theExtensionMechanismsHelper;
 414  
     }
 415  
 
 416  
     public FacadeEUMLImpl getFacade() {
 417  0
         if (theFacade == null) {
 418  0
             theFacade = new FacadeEUMLImpl(this);
 419  
         }
 420  0
         return theFacade;
 421  
     }
 422  
 
 423  
     public MetaTypesEUMLImpl getMetaTypes() {
 424  0
         if (theMetaTypes == null) {
 425  0
             theMetaTypes = new MetaTypesEUMLImpl(this);
 426  
         }
 427  0
         return theMetaTypes;
 428  
     }
 429  
 
 430  
     public ModelEventPumpEUMLImpl getModelEventPump() {
 431  0
         if (theModelEventPump == null) {
 432  0
             theModelEventPump = new ModelEventPumpEUMLImpl(this);
 433  
         }
 434  0
         return theModelEventPump;
 435  
     }
 436  
 
 437  
     public ModelManagementFactoryEUMLImpl getModelManagementFactory() {
 438  0
         if (theModelManagementFactory == null) {
 439  0
             theModelManagementFactory =
 440  
                 new ModelManagementFactoryEUMLImpl(this);
 441  
         }
 442  0
         return theModelManagementFactory;
 443  
     }
 444  
 
 445  
     public ModelManagementHelperEUMLImpl getModelManagementHelper() {
 446  0
         if (theModelManagementHelper == null) {
 447  0
             theModelManagementHelper = new ModelManagementHelperEUMLImpl(this);
 448  
         }
 449  0
         return theModelManagementHelper;
 450  
     }
 451  
 
 452  
     public OrderingKindEUMLImpl getOrderingKind() {
 453  0
         if (theOrderingKind == null) {
 454  0
             theOrderingKind = new OrderingKindEUMLImpl();
 455  
         }
 456  0
         return theOrderingKind;
 457  
     }
 458  
 
 459  
     public PseudostateKindEUMLImpl getPseudostateKind() {
 460  0
         if (thePseudostateKind == null) {
 461  0
             thePseudostateKind = new PseudostateKindEUMLImpl();
 462  
         }
 463  0
         return thePseudostateKind;
 464  
     }
 465  
 
 466  
     @SuppressWarnings("deprecation")
 467  
     public ScopeKindEUMLImpl getScopeKind() {
 468  0
         if (theScopeKind == null) {
 469  0
             theScopeKind = new ScopeKindEUMLImpl();
 470  
         }
 471  0
         return theScopeKind;
 472  
     }
 473  
 
 474  
 
 475  
     public StateMachinesFactoryEUMLImpl getStateMachinesFactory() {
 476  0
         if (theStateMachinesFactory == null) {
 477  0
             theStateMachinesFactory = new StateMachinesFactoryEUMLImpl(this);
 478  
         }
 479  0
         return theStateMachinesFactory;
 480  
     }
 481  
 
 482  
     public StateMachinesHelperEUMLImpl getStateMachinesHelper() {
 483  0
         if (theStateMachinesHelper == null) {
 484  0
             theStateMachinesHelper = new StateMachinesHelperEUMLImpl(this);
 485  
         }
 486  0
         return theStateMachinesHelper;
 487  
     }
 488  
 
 489  
     public UmlFactoryEUMLImpl getUmlFactory() {
 490  0
         if (theUmlFactory == null) {
 491  0
             theUmlFactory = new UmlFactoryEUMLImpl(this);
 492  
         }
 493  0
         return theUmlFactory;
 494  
     }
 495  
 
 496  
     public UmlHelperEUMLImpl getUmlHelper() {
 497  0
         if (theUmlHelper == null) {
 498  0
             theUmlHelper = new UmlHelperEUMLImpl(this);
 499  
         }
 500  0
         return theUmlHelper;
 501  
     }
 502  
 
 503  
     public UseCasesFactoryEUMLImpl getUseCasesFactory() {
 504  0
         if (theUseCasesFactory == null) {
 505  0
             theUseCasesFactory = new UseCasesFactoryEUMLImpl(this);
 506  
         }
 507  0
         return theUseCasesFactory;
 508  
     }
 509  
 
 510  
     public UseCasesHelperEUMLImpl getUseCasesHelper() {
 511  0
         if (theUseCasesHelper == null) {
 512  0
             theUseCasesHelper = new UseCasesHelperEUMLImpl(this);
 513  
         }
 514  0
         return theUseCasesHelper;
 515  
     }
 516  
 
 517  
     public VisibilityKindEUMLImpl getVisibilityKind() {
 518  0
         if (theVisibilityKind == null) {
 519  0
             theVisibilityKind = new VisibilityKindEUMLImpl();
 520  
         }
 521  0
         return theVisibilityKind;
 522  
     }
 523  
 
 524  
     public XmiReaderEUMLImpl getXmiReader() throws UmlException {
 525  0
         return new XmiReaderEUMLImpl(this);
 526  
     }
 527  
 
 528  
     public XmiWriterEUMLImpl getXmiWriter(Object model, OutputStream stream,
 529  
             String version) throws UmlException {
 530  0
         return new XmiWriterEUMLImpl(this, model, stream, version);
 531  
     }
 532  
 
 533  
     public DiagramInterchangeModel getDiagramInterchangeModel() {
 534  0
         return null;
 535  
     }
 536  
 
 537  
     private CommandStackImpl getCommandStack() {
 538  0
         if (theCommandStack == null) {
 539  0
             theCommandStack = new CommandStackImpl(this);
 540  
         }
 541  0
         return theCommandStack;
 542  
     }
 543  
 
 544  
     /**
 545  
      * Unload all resources in the editing domain and clear the read only map.
 546  
      */
 547  
     void clearEditingDomain() {
 548  
         for (Resource resource 
 549  0
                 : editingDomain.getResourceSet().getResources()) {
 550  0
             unloadResource(resource);
 551  
         }
 552  0
     }
 553  
     
 554  
     void unloadResource(Resource resource) {
 555  0
         resource.unload();
 556  0
         readOnlyMap.remove(resource);
 557  0
     }
 558  
 }