svn commit: r16969 - trunk/src/argouml-core-model-euml/src/org/argouml/model/euml
Tom Morris <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: tfmorris
Date: 2009-03-26 13:14:11-0700
New Revision: 16969
Modified:
trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java
trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/UmlFactoryEUMLImpl.java
trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/XmiReaderEUMLImpl.java
Log:
RESOLVED - issue 5751: UML 2.x files get deleted after load. Add support for multiple extents.
http://argouml.tigris.org/issues/show_bug.cgi?id=5751
Modified: trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java?view=diff&pathrev=16969&r1=16968&r2=16969
==============================================================================
--- trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java (original)
+++ trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java 2009-03-26 13:14:11-0700
@@ -1,5 +1,4 @@
-// $Id$
-// Copyright (c) 2007,2008 Tom Morris and other contributors
+// Copyright (c) 2007,2009 Tom Morris and other contributors
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -9,14 +8,14 @@
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
-// * Neither the name of the ArgoUML Project nor the
-// names of its contributors may be used to endorse or promote products
-// derived from this software without specific prior written permission.
+// * Neither the name of the project or its contributors may be used
+// to endorse or promote products derived from this software without
+// specific prior written permission.
//
-// THIS SOFTWARE IS PROVIDED BY THE ArgoUML PROJECT ``AS IS'' AND ANY
+// THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-// DISCLAIMED. IN NO EVENT SHALL THE ArgoUML PROJECT BE LIABLE FOR ANY
+// DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -541,10 +540,14 @@
* Unload all resources in the editing domain and clear the read only map.
*/
void clearEditingDomain() {
- for (Resource resource : editingDomain.getResourceSet().getResources()) {
- resource.unload();
+ for (Resource resource
+ : editingDomain.getResourceSet().getResources()) {
+ unloadResource(resource);
}
- readOnlyMap.clear();
}
+ void unloadResource(Resource resource) {
+ resource.unload();
+ readOnlyMap.remove(resource);
+ }
}
Modified: trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/UmlFactoryEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/UmlFactoryEUMLImpl.java?view=diff&pathrev=16969&r1=16968&r2=16969
==============================================================================
--- trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/UmlFactoryEUMLImpl.java (original)
+++ trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/UmlFactoryEUMLImpl.java 2009-03-26 13:14:11-0700
@@ -32,12 +32,14 @@
import java.util.List;
import java.util.Map;
-import org.argouml.model.NotImplementedException;
+import org.apache.log4j.Logger;
import org.argouml.model.AbstractModelFactory;
import org.argouml.model.IllegalModelElementConnectionException;
+import org.argouml.model.InvalidElementException;
import org.argouml.model.MetaTypes;
import org.argouml.model.UmlFactory;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.uml2.uml.Abstraction;
import org.eclipse.uml2.uml.AggregationKind;
@@ -64,6 +66,9 @@
*/
class UmlFactoryEUMLImpl implements UmlFactory, AbstractModelFactory {
+ private static final Logger LOG =
+ Logger.getLogger(UmlFactoryEUMLImpl.class);
+
/**
* The model implementation.
*/
@@ -221,8 +226,9 @@
}
public Object buildNode(Object elementType, Object container) {
-
- throw new NotImplementedException();
+ Object element = buildNode(elementType);
+ modelImpl.getCoreHelper().addOwnedElement(container, element);
+ return element;
}
public Object buildNode(Object elementType) {
@@ -378,8 +384,9 @@
}
public boolean isContainmentValid(Object metaType, Object container) {
-
- throw new NotImplementedException();
+// throw new NotImplementedException();
+ // TODO: Can we get this info from UML2 plugin?
+ return true;
}
/**
@@ -453,9 +460,14 @@
}
public void deleteExtent(Object element) {
- // TODO: This is adequate because we only support a single editing
- // domain right now, but it needs to be enhanced for multiple domains.
- modelImpl.clearEditingDomain();
- }
+ Resource resource = ((EObject) element).eResource();
+ if (resource != null) {
+ modelImpl.unloadResource(resource);
+ } else {
+ LOG.warn("Tried to delete null resource");
+ throw new InvalidElementException(
+ element != null ? element.toString() : "Null" );
+ }
+ }
}
Modified: trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/XmiReaderEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/XmiReaderEUMLImpl.java?view=diff&pathrev=16969&r1=16968&r2=16969
==============================================================================
--- trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/XmiReaderEUMLImpl.java (original)
+++ trunk/src/argouml-core-model-euml/src/org/argouml/model/euml/XmiReaderEUMLImpl.java 2009-03-26 13:14:11-0700
@@ -1,7 +1,7 @@
// $Id$
-// Copyright (c) 2007,2008 Tom Morris and other contributors
+/// Copyright (c) 2007,2009 Tom Morris and other contributors
// All rights reserved.
-//
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
@@ -9,14 +9,14 @@
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
-// * Neither the name of the ArgoUML Project nor the
-// names of its contributors may be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE ArgoUML PROJECT ``AS IS'' AND ANY
+// * Neither the name of the project or its contributors may be used
+// to endorse or promote products derived from this software without
+// specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-// DISCLAIMED. IN NO EVENT SHALL THE ArgoUML PROJECT BE LIABLE FOR ANY
+// DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -40,17 +40,20 @@
import java.util.Map;
import java.util.Set;
+import org.apache.log4j.Logger;
import org.argouml.model.UmlException;
import org.argouml.model.XmiReader;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.edit.domain.EditingDomain;
import org.xml.sax.InputSource;
/**
* The implementation of the XmiReader for EUML2.
*/
class XmiReaderEUMLImpl implements XmiReader {
+
+ private static final Logger LOG = Logger.getLogger(XmiReaderEUMLImpl.class);
/**
* The model implementation.
@@ -104,12 +107,21 @@
}
InputStream is = null;
boolean needsClosing = false;
+ String name = inputSource.getSystemId();
+ if (name == null) {
+ name = inputSource.getPublicId();
+ }
+ if (name == null) {
+ name = inputSource.toString();
+ }
+ LOG.debug("Parsing " + name);
if (inputSource.getByteStream() != null) {
is = inputSource.getByteStream();
} else if (inputSource.getSystemId() != null) {
try {
URL url = new URL(inputSource.getSystemId());
if (url != null) {
+ LOG.debug("Parsing URL " + url);
is = url.openStream();
if (is != null) {
is = new BufferedInputStream(is);
@@ -127,13 +139,13 @@
throw new UnsupportedOperationException();
}
-
- // TODO: This won't work if the user loads a profile and then
- // a user model or multiple user models. - tfm
- modelImpl.clearEditingDomain();
+ String id = inputSource.getSystemId();
+ if (id == null) {
+ id = inputSource.getPublicId();
+ }
+ Resource r = UMLUtil.getResource(modelImpl,
+ URI.createURI(id), readOnly);
- Resource r = UMLUtil.getResource(modelImpl, UMLUtil.DEFAULT_URI,
- readOnly);
try {
modelImpl.getModelEventPump().stopPumpingEvents();
r.load(is, null);
@@ -150,6 +162,8 @@
}
}
resource = r;
+ LOG.debug("Parsed resource " + resource
+ + " with " + resource.getContents().size() + " elements");
return r.getContents();
}
@@ -160,11 +174,12 @@
public String getTagName() {
if (resource == null) {
- throw new IllegalStateException();
+ return "uml:Model"; //$NON-NLS-1$
}
List l = resource.getContents();
if (!l.isEmpty()) {
- return "uml:" + modelImpl.getMetaTypes().getName(l.get(0)); //$NON-NLS-1$
+ return "uml:" //$NON-NLS-1$
+ + modelImpl.getMetaTypes().getName(l.get(0));
} else {
return null;
}
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=1434617
To unsubscribe from this discussion, e-mail: [[email protected]].