svn commit: r17353 - trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java
Bob Tarling <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: bobtarling
Date: 2009-09-24 08:25:27-0700
New Revision: 17353
Modified:
trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java
Log:
Issue 5771: If there is no href for a class that requires an owner in the constructor then ignore that element
Modified: trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java?view=diff&pathrev=17353&r1=17352&r2=17353
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java (original)
+++ trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java 2009-09-24 08:25:27-0700
@@ -90,6 +90,8 @@
private LinkedHashMap<FigEdge, Object> modelElementsByFigEdge =
new LinkedHashMap<FigEdge, Object>(50);
+ // TODO: Do we need this? Its not being used everywhere. If we keep is it
+ // safe to use in all other places?
private DiagramSettings diagramSettings;
// TODO: Use stylesheet to convert or wait till we use Fig
@@ -835,7 +837,11 @@
* @return
* @throws SAXException
*/
- private Fig constructFig(String className, String href, Rectangle bounds, Attributes attributes)
+ private Fig constructFig(
+ final String className,
+ final String href,
+ final Rectangle bounds,
+ final Attributes attributes)
throws SAXException {
final DiagramSettings diagramSettings =
@@ -855,15 +861,14 @@
&& parameterTypes[1].equals(Rectangle.class)
&& parameterTypes[2].equals(DiagramSettings.class)
) {
- Object parameters[] = new Object[3];
- Object owner = null;
- if (href != null) {
- owner = findOwner(href);
+ final Object parameters[] = new Object[3];
+ final Object owner = getOwner(className, href);
+ if (owner == null) {
+ return null;
}
parameters[0] = owner;
parameters[1] = bounds;
- parameters[2] =
- ((ArgoDiagram) getDiagram()).getDiagramSettings();
+ parameters[2] = diagramSettings;
constructor.setAccessible(true);
f = (Fig) constructor.newInstance(parameters);
@@ -873,10 +878,10 @@
&& parameterTypes[0].equals(DiagramEdgeSettings.class)
&& parameterTypes[1].equals(DiagramSettings.class)
) {
- Object parameters[] = new Object[2];
- Object owner = null;
- if (href != null) {
- owner = findOwner(href);
+ final Object parameters[] = new Object[2];
+ final Object owner = getOwner(className, href);
+ if (owner == null) {
+ return null;
}
String sourceUuid =
@@ -884,11 +889,6 @@
String destinationUuid =
attributes.getValue("destConnector");
- LOG.info("The source connector uuid is "
- + sourceUuid);
- LOG.info("The destination connector uuid is "
- + destinationUuid);
-
final Object source;
final Object destination;
if (sourceUuid != null && destinationUuid != null) {
@@ -902,8 +902,7 @@
DiagramEdgeSettings settings =
new DiagramEdgeSettings(owner, source, destination);
parameters[0] = settings;
- parameters[1] =
- ((ArgoDiagram) getDiagram()).getDiagramSettings();
+ parameters[1] = diagramSettings;
constructor.setAccessible(true);
f = (Fig) constructor.newInstance(parameters);
@@ -917,8 +916,7 @@
) {
Object parameters[] = new Object[2];
parameters[0] = bounds;
- parameters[1] =
- ((ArgoDiagram) getDiagram()).getDiagramSettings();
+ parameters[1] = diagramSettings;
constructor.setAccessible(true);
f = (Fig) constructor.newInstance(parameters);
@@ -934,13 +932,13 @@
&& parameterTypes[1].equals(DiagramSettings.class)
) {
Object parameters[] = new Object[2];
- Object owner = null;
- if (href != null) {
- owner = findOwner(href);
+
+ final Object owner = getOwner(className, href);
+ if (owner == null) {
+ return null;
}
parameters[0] = owner;
- parameters[1] =
- ((ArgoDiagram) getDiagram()).getDiagramSettings();
+ parameters[1] = diagramSettings;
constructor.setAccessible(true);
f = (Fig) constructor.newInstance(parameters);
@@ -971,6 +969,30 @@
}
/**
+ * Given the href extracted from the PGML return the model element with
+ * that uuid.
+ * @param className Used only for logging should the href not be found
+ * @param href The href
+ * @return
+ */
+ private Object getOwner(String className, String id) {
+ if (id == null) {
+ LOG.warn("There is no href attribute provided for a "
+ + className
+ + " so the diagram element is ignored on load");
+ return null;
+ }
+ final Object owner = findOwner(id);
+ if (owner == null) {
+ LOG.warn("The href " + id + " is not found for a "
+ + className
+ + " so the diagram element is ignored on load");
+ return null;
+ }
+ return owner;
+ }
+
+ /**
* @param container
* @param group
* @param attributes
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2399336
To unsubscribe from this discussion, e-mail: [[email protected]].