Hello Tom, This commit creates an error in eUML. Please look at the explanation in-line bellow.
> Modified: trunk/src_new/org/argouml/uml/ProfileJava.java > Url: > http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ProfileJava.java?view=diff&rev=13169&p1=trunk/src_new/org/argouml/uml/ProfileJava.java&p2=trunk/src_new/org/argouml/uml/ProfileJava.java&r1=13168&r2=13169 > ============================================================================== > --- trunk/src_new/org/argouml/uml/ProfileJava.java (original) > +++ trunk/src_new/org/argouml/uml/ProfileJava.java 2007-07-27 > 15:26:33-0700 > @@ -31,6 +31,7 @@ > import java.io.InputStream; > import java.net.MalformedURLException; > import java.net.URL; > +import java.util.ArrayList; > import java.util.Collection; > import java.util.Iterator; > import java.util.zip.ZipEntry; > @@ -45,7 +46,7 @@ > import org.xml.sax.InputSource; > > /** > - * This class implements the abstract class Profile for use in modelling > + * This class implements the abstract class Profile for use in modeling > * Java language projects. Eventually, this class may be replaced by > * a configurable profile. > * > @@ -57,7 +58,7 @@ > * the argo.user.properties file. > * > * TODO: This is an i18n nightmare. Tons of hardcoded strings and > - * string concatentation. Change to use message formatting. - tfm 20060226 > + * string concatenation. Change to use message formatting. - tfm 20060226 > * > * @author Curt Arnold > */ > @@ -67,12 +68,14 @@ > */ > private static final Logger LOG = Logger.getLogger(ProfileJava.class); > > - private Object defaultModel; > + private Object profileModel; > + > + private Collection profileElements; > > static final String DEFAULT_PROFILE = > > "/org/argouml/model/mdr/profiles/default-uml14.xmi"; > > - private String defaultModelFilename; > + private String profileFilename; > > /** > * The constructor. > @@ -275,19 +278,30 @@ > return value; > } > > - /* > - * @see org.argouml.uml.Profile#getProfileModel() > - */ > + > + @SuppressWarnings("deprecation") > public Object getProfileModel() throws ProfileException { > - if (defaultModel == null) { > - defaultModel = loadProfileModel(); > + if (profileModel == null) { > + for (Object pkg : getProfilePackages()) { > + if (Model.getFacade().isAPackage(pkg)) { > + profileModel = pkg; > + return profileModel; > + } > + } > + profileModel = getProfilePackages().iterator().next(); > + } > + return profileModel; > + } > + > + > + public Collection getProfilePackages() throws ProfileException { > + if (profileElements == null) { > + profileElements = loadProfileModel(); > } > - return defaultModel; > + return profileElements; > } > > - /* > - * @see org.argouml.uml.Profile#setProfileModelFilename(java.lang.String) > - */ > + > public void setProfileModelFilename(String name) throws ProfileException > { > if (loadProfile(name) != null) { > Configuration.setString(Argo.KEY_DEFAULT_MODEL, name); > @@ -296,18 +310,16 @@ > } > } > > - /* > - * @see org.argouml.uml.Profile#getProfileModelFilename() > - */ > + > public String getProfileModelFilename() { > - if (defaultModelFilename == null) { > + if (profileFilename == null) { > // TODO: Can we remove the use of this property > // and just use the config file setting? - tfm 20060227 > - defaultModelFilename = System.getProperty("argo.defaultModel", > + profileFilename = System.getProperty("argo.defaultModel", > Configuration.getString(Argo.KEY_DEFAULT_MODEL, > DEFAULT_PROFILE)); > } > - return defaultModelFilename; > + return profileFilename; > } > > /** > @@ -322,33 +334,34 @@ > * > * @return the profile model object or null > */ > - public Object loadProfileModel() { > - Object profileModel = null; > + private Collection loadProfileModel() { > + Collection elements = new ArrayList(); > String modelFilename = getProfileModelFilename(); > > if (modelFilename != null) { > - profileModel = loadProfile(modelFilename); > - if (profileModel != null) { > - return profileModel; > + elements.addAll(loadProfile(modelFilename)); If "loadProfile(modelFilename)" returns null, a NullPointerException is thrown in elements.addAll(null). This is happening in eUML because modelFilename is "/org/argouml/model/mdr/profiles/default-uml14.xmi" Could you please change this into: - elements.addAll(loadProfile(modelFilename)); + Collection c = loadProfile(modelFilename); + if (c != null) { + elements.addAll(c); + } Bogdan > + if (!elements.isEmpty()) { > + return elements; > } > } > > if (!(DEFAULT_PROFILE.equals(modelFilename))) { > LOG.warn("Falling back to default profile '" > + DEFAULT_PROFILE + "'"); > - profileModel = loadProfile(DEFAULT_PROFILE); > - if (profileModel != null) { > - defaultModelFilename = DEFAULT_PROFILE; > - return profileModel; > + elements.addAll(loadProfile(DEFAULT_PROFILE)); > + if (!elements.isEmpty()) { > + profileFilename = DEFAULT_PROFILE; > + return elements; > } > } > > LOG.error("Failed to load any profile - returning empty model"); > - defaultModelFilename = ""; > - return Model.getModelManagementFactory().createModel(); > + profileFilename = ""; > + elements.add(Model.getModelManagementFactory().createModel()); > + return elements; > } > > - private Object loadProfile(String modelFilename) { > + private Collection loadProfile(String modelFilename) { > LOG.info("Loading profile '" + modelFilename + "'"); > InputStream is = null; > // > @@ -402,14 +415,7 @@ > XmiReader xmiReader = Model.getXmiReader(); > InputSource inputSource = new InputSource(is); > LOG.info("Loaded profile '" + modelFilename + "'"); > - Collection elements = xmiReader.parse(inputSource, true); > - if (elements.size() != 1) { > - LOG.error("Error loading profile '" + modelFilename > - + "' expected 1 top level element" + " found " > - + elements.size()); > - return null; > - } > - return elements.iterator().next(); > + return xmiReader.parse(inputSource, true); > } catch (UmlException e) { > LOG.error("Exception while loading profile '" > + modelFilename + "'", e); On 27 Jul 2007 22:26:34 -0000, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Author: tfmorris > Date: 2007-07-27 15:26:33-0700 > New Revision: 13169 > > Modified: > trunk/src_new/org/argouml/kernel/Project.java > trunk/src_new/org/argouml/kernel/ProjectImpl.java > trunk/src_new/org/argouml/persistence/ModelMemberFilePersister.java > trunk/src_new/org/argouml/persistence/XmiFilePersister.java > trunk/src_new/org/argouml/persistence/ZipFilePersister.java > trunk/src_new/org/argouml/uml/Profile.java > trunk/src_new/org/argouml/uml/ProfileJava.java > > Log: > Add support profiles & user models with: > > - multiple linked XMI files > > - multiple top level packages > ... > Modified: trunk/src_new/org/argouml/uml/ProfileJava.java > Url: > http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ProfileJava.java?view=diff&rev=13169&p1=trunk/src_new/org/argouml/uml/ProfileJava.java&p2=trunk/src_new/org/argouml/uml/ProfileJava.java&r1=13168&r2=13169 > ============================================================================== > --- trunk/src_new/org/argouml/uml/ProfileJava.java (original) > +++ trunk/src_new/org/argouml/uml/ProfileJava.java 2007-07-27 > 15:26:33-0700 > @@ -31,6 +31,7 @@ > import java.io.InputStream; > import java.net.MalformedURLException; > import java.net.URL; > +import java.util.ArrayList; > import java.util.Collection; > import java.util.Iterator; > import java.util.zip.ZipEntry; > @@ -45,7 +46,7 @@ > import org.xml.sax.InputSource; > > /** > - * This class implements the abstract class Profile for use in modelling > + * This class implements the abstract class Profile for use in modeling > * Java language projects. Eventually, this class may be replaced by > * a configurable profile. > * > @@ -57,7 +58,7 @@ > * the argo.user.properties file. > * > * TODO: This is an i18n nightmare. Tons of hardcoded strings and > - * string concatentation. Change to use message formatting. - tfm 20060226 > + * string concatenation. Change to use message formatting. - tfm 20060226 > * > * @author Curt Arnold > */ > @@ -67,12 +68,14 @@ > */ > private static final Logger LOG = Logger.getLogger(ProfileJava.class); > > - private Object defaultModel; > + private Object profileModel; > + > + private Collection profileElements; > > static final String DEFAULT_PROFILE = > > "/org/argouml/model/mdr/profiles/default-uml14.xmi"; > > - private String defaultModelFilename; > + private String profileFilename; > > /** > * The constructor. > @@ -275,19 +278,30 @@ > return value; > } > > - /* > - * @see org.argouml.uml.Profile#getProfileModel() > - */ > + > + @SuppressWarnings("deprecation") > public Object getProfileModel() throws ProfileException { > - if (defaultModel == null) { > - defaultModel = loadProfileModel(); > + if (profileModel == null) { > + for (Object pkg : getProfilePackages()) { > + if (Model.getFacade().isAPackage(pkg)) { > + profileModel = pkg; > + return profileModel; > + } > + } > + profileModel = getProfilePackages().iterator().next(); > + } > + return profileModel; > + } > + > + > + public Collection getProfilePackages() throws ProfileException { > + if (profileElements == null) { > + profileElements = loadProfileModel(); > } > - return defaultModel; > + return profileElements; > } > > - /* > - * @see org.argouml.uml.Profile#setProfileModelFilename(java.lang.String) > - */ > + > public void setProfileModelFilename(String name) throws ProfileException > { > if (loadProfile(name) != null) { > Configuration.setString(Argo.KEY_DEFAULT_MODEL, name); > @@ -296,18 +310,16 @@ > } > } > > - /* > - * @see org.argouml.uml.Profile#getProfileModelFilename() > - */ > + > public String getProfileModelFilename() { > - if (defaultModelFilename == null) { > + if (profileFilename == null) { > // TODO: Can we remove the use of this property > // and just use the config file setting? - tfm 20060227 > - defaultModelFilename = System.getProperty("argo.defaultModel", > + profileFilename = System.getProperty("argo.defaultModel", > Configuration.getString(Argo.KEY_DEFAULT_MODEL, > DEFAULT_PROFILE)); > } > - return defaultModelFilename; > + return profileFilename; > } > > /** > @@ -322,33 +334,34 @@ > * > * @return the profile model object or null > */ > - public Object loadProfileModel() { > - Object profileModel = null; > + private Collection loadProfileModel() { > + Collection elements = new ArrayList(); > String modelFilename = getProfileModelFilename(); > > if (modelFilename != null) { > - profileModel = loadProfile(modelFilename); > - if (profileModel != null) { > - return profileModel; > + elements.addAll(loadProfile(modelFilename)); If "loadProfile(modelFilename)" returns null, a NullPointerException is thrown in elements.addAll(null). This is happening in eUML because modelFilename is "/org/argouml/model/mdr/profiles/default-uml14.xmi" Could you please change this into: - elements.addAll(loadProfile(modelFilename)); + Collection c = loadProfile(modelFilename); + if (c != null) { + elements.addAll(c); + } Bogdan > + if (!elements.isEmpty()) { > + return elements; > } > } > > if (!(DEFAULT_PROFILE.equals(modelFilename))) { > LOG.warn("Falling back to default profile '" > + DEFAULT_PROFILE + "'"); > - profileModel = loadProfile(DEFAULT_PROFILE); > - if (profileModel != null) { > - defaultModelFilename = DEFAULT_PROFILE; > - return profileModel; > + elements.addAll(loadProfile(DEFAULT_PROFILE)); > + if (!elements.isEmpty()) { > + profileFilename = DEFAULT_PROFILE; > + return elements; > } > } > > LOG.error("Failed to load any profile - returning empty model"); > - defaultModelFilename = ""; > - return Model.getModelManagementFactory().createModel(); > + profileFilename = ""; > + elements.add(Model.getModelManagementFactory().createModel()); > + return elements; > } > > - private Object loadProfile(String modelFilename) { > + private Collection loadProfile(String modelFilename) { > LOG.info("Loading profile '" + modelFilename + "'"); > InputStream is = null; > // > @@ -402,14 +415,7 @@ > XmiReader xmiReader = Model.getXmiReader(); > InputSource inputSource = new InputSource(is); > LOG.info("Loaded profile '" + modelFilename + "'"); > - Collection elements = xmiReader.parse(inputSource, true); > - if (elements.size() != 1) { > - LOG.error("Error loading profile '" + modelFilename > - + "' expected 1 top level element" + " found " > - + elements.size()); > - return null; > - } > - return elements.iterator().next(); > + return xmiReader.parse(inputSource, true); > } catch (UmlException e) { > LOG.error("Exception while loading profile '" > + modelFilename + "'", e); The entire commit: On 27 Jul 2007 22:26:34 -0000, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Author: tfmorris > Date: 2007-07-27 15:26:33-0700 > New Revision: 13169 > > Modified: > trunk/src_new/org/argouml/kernel/Project.java > trunk/src_new/org/argouml/kernel/ProjectImpl.java > trunk/src_new/org/argouml/persistence/ModelMemberFilePersister.java > trunk/src_new/org/argouml/persistence/XmiFilePersister.java > trunk/src_new/org/argouml/persistence/ZipFilePersister.java > trunk/src_new/org/argouml/uml/Profile.java > trunk/src_new/org/argouml/uml/ProfileJava.java > > Log: > Add support profiles & user models with: > > - multiple linked XMI files > > - multiple top level packages > > Modified: trunk/src_new/org/argouml/kernel/Project.java > Url: > http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/kernel/Project.java?view=diff&rev=13169&p1=trunk/src_new/org/argouml/kernel/Project.java&p2=trunk/src_new/org/argouml/kernel/Project.java&r1=13168&r2=13169 > ============================================================================== > --- trunk/src_new/org/argouml/kernel/Project.java (original) > +++ trunk/src_new/org/argouml/kernel/Project.java 2007-07-27 > 15:26:33-0700 > @@ -445,17 +445,34 @@ > > /** > * @param theDefaultModel a uml model > + * @deprecated for 0.25.4 by tfmorris. Use > + * [EMAIL PROTECTED] #setProfiles(Collection)}. > */ > + @Deprecated > public void setDefaultModel(Object theDefaultModel); > > /** > + * @param packages a Collection of packages containing profiles. > + */ > + public void setProfiles(Collection packages); > + > + /** > * Get the default model. > * > * @return A model. > + * @deprecated for 0.25.4 by tfmorris. Use [EMAIL PROTECTED] > #getProfiles()}. > */ > + @Deprecated > public Object getDefaultModel(); > > /** > + * Get the collection of profile packages. > + * > + * @return collection of Packages containing profiles. > + */ > + public Object getProfiles(); > + > + /** > * Find a type by name in the default model. > * > * @param name the name. > @@ -464,17 +481,42 @@ > public Object findTypeInDefaultModel(String name); > > /** > - * Returns the root. > - * @return MModel > + * Returns the root package. > + * > + * @return the Package which is the root > + * @deprecated for 0.25.4 by tfmorris - use [EMAIL PROTECTED] > #getRoots()} to > + * packages/model elements which are at the top level. TODO: > We > + * probably need a getDefaultNamespace() method or something > + * similar to replace some uses of this. > */ > + @Deprecated > public Object getRoot(); > > /** > - * Sets the root. > - * @param root The root to set, a uml model > + * Sets the root package. > + * @param root The root to set, a UML Package > + * @deprecated for 0.25.4 by tfmorris - use [EMAIL PROTECTED] #setRoots}. > */ > + @Deprecated > public void setRoot(Object root); > > + > + /** > + * Return a collection of top level Model Elements. Normally for ArgoUML > + * created models, this will be a single Package or Model, but other > tools > + * may allow more liberal structures. > + * > + * @return Collection of top level ModelElements > + */ > + public Collection getRoots(); > + > + /** > + * Set the top level ModelElements for this project. > + * > + * @param elements Collection of top level ModelElements > + */ > + public void setRoots(Collection elements); > + > /** > * Returns true if the given name is a valid name for a diagram. Valid > means > * that it does not occur as a name for a diagram yet. > > Modified: trunk/src_new/org/argouml/kernel/ProjectImpl.java > Url: > http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/kernel/ProjectImpl.java?view=diff&rev=13169&p1=trunk/src_new/org/argouml/kernel/ProjectImpl.java&p2=trunk/src_new/org/argouml/kernel/ProjectImpl.java&r1=13168&r2=13169 > ============================================================================== > --- trunk/src_new/org/argouml/kernel/ProjectImpl.java (original) > +++ trunk/src_new/org/argouml/kernel/ProjectImpl.java 2007-07-27 > 15:26:33-0700 > @@ -58,6 +58,7 @@ > import org.argouml.uml.ProjectMemberModel; > import org.argouml.uml.cognitive.ProjectMemberTodoList; > import org.argouml.uml.diagram.ArgoDiagram; > +import org.argouml.uml.diagram.DiagramFactory; > import org.argouml.uml.diagram.ProjectMemberDiagram; > import org.tigris.gef.presentation.Fig; > import org.tigris.gef.undo.Memento; > @@ -117,15 +118,20 @@ > private int persistenceVersion; > > /** > - * Instances of the uml model. > + * Instances of the UML model. > */ > private final List models = new ArrayList(); > + > + private Object root; > + private Collection roots = new HashSet(); > + > > /** > - * Instances of the uml diagrams. > + * Instances of the UML diagrams. > */ > private final List<ArgoDiagram> diagrams = new ArrayList<ArgoDiagram>(); > - private Object defaultModel; > + > + private Collection<Object> profilePackages = new HashSet<Object>(); > private Object currentNamespace; > private Map<String, Object> uuidRefs; > private transient VetoableChangeSupport vetoSupport; > @@ -180,7 +186,7 @@ > // load the default model > // this is NOT the way how it should be since this makes argo > // depend on Java even more. > - setDefaultModel(profile.getProfileModel()); > + setProfiles(profile.getProfilePackages()); > } catch (ProfileException e) { > // TODO: how are we going to handle exceptions here? > // I think we need a ProjectException. > @@ -362,6 +368,7 @@ > // fire indeterminate change to avoid copying vector > if (!models.contains(model)) { > models.add(model); > + roots.add(model); > } > setCurrentNamespace(model); > setSaveEnabled(true); > @@ -377,16 +384,10 @@ > if (diagrams.size() == 1) { > // We're deleting the last diagram so lets create a new one > // TODO: Once we go MDI we won't need this. > - Object treeRoot = > - Model.getModelManagementFactory().getRootModel(); > - // TODO: This is the center of a very large dependency cycle > - // Just refuse to delete the last diagram for now - tfm > - LOG.error("Can't delete last diagram in the project"); > - return; > -// defaultDiagram = > -// DiagramFactory.getInstance().createDefaultDiagram( > -// treeRoot); > -// addMember(defaultDiagram); > + defaultDiagram = > + DiagramFactory.getInstance().createDefaultDiagram( > + getRoot()); > + addMember(defaultDiagram); > } else { > // Make the topmost diagram (that is not the one being > deleted) > // current. > @@ -522,7 +523,7 @@ > public Collection getModels() { > Set ret = new HashSet(); > ret.addAll(models); > - ret.add(defaultModel); > + ret.addAll(profilePackages); > return ret; > } > > @@ -574,6 +575,7 @@ > } > cls = findTypeInDefaultModel(s); > // hey, now we should move it to the model the user is working in > + // TODO: Remove this when we support linked profiles - tfm - 20070726 > if (cls != null) { > cls = > Model.getModelManagementHelper() > @@ -612,29 +614,34 @@ > return figs; > } > > + private Object findTypeInPackages(String name, Collection namespaces) { > + for (Object namespace : namespaces) { > + Object type = findTypeInModel(name, namespace); > + if (type != null) { > + return type; > + } > + } > + return null; > + } > > - public Object findTypeInModel(String s, Object ns) { > - > - if (!Model.getFacade().isANamespace(ns)) { > + public Object findTypeInModel(String typeName, Object namespace) { > + if (typeName == null) { > + throw new IllegalArgumentException("typeName must be non-null"); > + } > + if (!Model.getFacade().isANamespace(namespace)) { > throw new IllegalArgumentException( > - "Looking for the classifier " + s > - + " in a non-namespace object of " + ns > + "Looking for the classifier " + typeName > + + " in a non-namespace object of " + namespace > + ". A namespace was expected."); > } > > Collection allClassifiers = > Model.getModelManagementHelper() > - .getAllModelElementsOfKind(ns, > + .getAllModelElementsOfKind(namespace, > Model.getMetaTypes().getClassifier()); > > - Object[] classifiers = allClassifiers.toArray(); > - Object classifier = null; > - > - for (int i = 0; i < classifiers.length; i++) { > - > - classifier = classifiers[i]; > - if (Model.getFacade().getName(classifier) != null > - && Model.getFacade().getName(classifier).equals(s)) { > + for (Object classifier : allClassifiers) { > + if (typeName.equals(Model.getFacade().getName(classifier))) { > return classifier; > } > } > @@ -905,6 +912,7 @@ > } > > > + @SuppressWarnings("deprecation") > public void setDefaultModel(Object theDefaultModel) { > > if (!Model.getFacade().isAModel(theDefaultModel)) { > @@ -913,53 +921,109 @@ > + theDefaultModel.getClass().getName()); > } > > - defaultModel = theDefaultModel; > + profilePackages.clear(); > + profilePackages.add(theDefaultModel); > defaultModelTypeCache = new HashMap<String, Object>(); > } > > > - public Object getDefaultModel() { > - return defaultModel; > + public void setProfiles(Collection packages) { > + > + for (Object pkg : packages) { > + if (!Model.getFacade().isAPackage(pkg)) { > + throw new IllegalArgumentException( > + "Profiles must be of type Package. Received a " > + + pkg.getClass().getName()); > + } > + } > + > + profilePackages.clear(); > + profilePackages.addAll(packages); > + defaultModelTypeCache = new HashMap<String, Object>(); > } > > + @SuppressWarnings("deprecation") > + public Object getDefaultModel() { > + // First priority is Model for best backward compatibility > + for (Object pkg : profilePackages) { > + if (Model.getFacade().isAModel(pkg)) { > + return pkg; > + } > + } > + // then a Package > + for (Object pkg : profilePackages) { > + if (Model.getFacade().isAPackage(pkg)) { > + return pkg; > + } > + } > + // if all else fails, just the first element > + return profilePackages.iterator().next(); > + } > + > + public Collection getProfiles() { > + return profilePackages; > + } > > public Object findTypeInDefaultModel(String name) { > if (defaultModelTypeCache.containsKey(name)) { > return defaultModelTypeCache.get(name); > } > > - Object result = findTypeInModel(name, getDefaultModel()); > + Object result = findTypeInPackages(name, profilePackages); > defaultModelTypeCache.put(name, result); > return result; > } > > > + @SuppressWarnings("deprecation") > public Object getRoot() { > - return Model.getModelManagementFactory().getRootModel(); > + return root; > } > > > - public void setRoot(Object root) { > + @SuppressWarnings("deprecation") > + public void setRoot(Object theRoot) { > > - if (root == null) { > + if (theRoot == null) { > throw new IllegalArgumentException( > "A root model element is required"); > } > - if (!Model.getFacade().isAModel(root)) { > + if (!Model.getFacade().isAModel(theRoot)) { > throw new IllegalArgumentException( > "The root model element must be a model - got " > - + root.getClass().getName()); > + + theRoot.getClass().getName()); > } > > Object treeRoot = Model.getModelManagementFactory().getRootModel(); > if (treeRoot != null) { > models.remove(treeRoot); > } > - Model.getModelManagementFactory().setRootModel(root); > - addModel(root); > + root = theRoot; > + // TODO: We don't really want to do the following, but I'm not sure > + // what depends on it - tfm - 20070725 > + Model.getModelManagementFactory().setRootModel(theRoot); > + addModel(theRoot); > + } > + > + > + public Collection getRoots() { > + return roots; > } > > > + public void setRoots(Collection elements) { > + for (Object element : elements) { > + if (!Model.getFacade().isAPackage(element)) { > + LOG.warn("Top level element other than package found - " > + + Model.getFacade().getName(element)); > + } > + if (Model.getFacade().isAModel(element)) { > + addModel(element); > + } > + } > + roots = elements; > + } > + > public boolean isValidDiagramName(String name) { > boolean rv = true; > for (ArgoDiagram diagram : diagrams) { > @@ -1020,18 +1084,21 @@ > > members.clear(); > > - for (Object model : models) { > - LOG.debug("Deleting project model " > + for (Object model : roots) { > + LOG.debug("Deleting root element " > + Model.getFacade().getName(model)); > Model.getUmlFactory().delete(model); > } > + roots.clear(); > models.clear(); > > - if (defaultModel != null) { > - LOG.debug("Deleting profile model " > - + Model.getFacade().getName(defaultModel)); > - Model.getUmlFactory().delete(defaultModel); > - defaultModel = null; > + if (profilePackages != null) { > + for (Object pkg : profilePackages) { > + LOG.debug("Deleting profile element " > + + Model.getFacade().getName(pkg)); > + Model.getUmlFactory().delete(pkg); > + } > + profilePackages.clear(); > } > > diagrams.clear(); > @@ -1054,7 +1121,7 @@ > version = null; > searchpath = null; > historyFile = null; > - defaultModel = null; > + profilePackages = null; > currentNamespace = null; > vetoSupport = null; > activeDiagram = null; > > Modified: trunk/src_new/org/argouml/persistence/ModelMemberFilePersister.java > Url: > http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/persistence/ModelMemberFilePersister.java?view=diff&rev=13169&p1=trunk/src_new/org/argouml/persistence/ModelMemberFilePersister.java&p2=trunk/src_new/org/argouml/persistence/ModelMemberFilePersister.java&r1=13168&r2=13169 > ============================================================================== > --- trunk/src_new/org/argouml/persistence/ModelMemberFilePersister.java > (original) > +++ trunk/src_new/org/argouml/persistence/ModelMemberFilePersister.java > 2007-07-27 15:26:33-0700 > @@ -96,7 +96,7 @@ > // Created xmireader with method getErrors to check if parsing went > well > try { > source.setEncoding(Argo.getEncoding()); > - readModels(project, source); > + readModels(source); > mmodel = getCurModel(); > } catch (OpenException e) { > PersistenceManager.getInstance().setLastLoadStatus(false); > @@ -229,7 +229,6 @@ > } > > private Object curModel; > - private Project proj; > private HashMap uUIDRefs; > > private Collection elementsRead; > @@ -245,13 +244,6 @@ > } > > /** > - * @param p the project > - */ > - public void setProject(Project p) { > - proj = p; > - } > - > - /** > * Return XMI id to object map for the most recently read XMI file. > * > * @return the UUID > @@ -271,7 +263,7 @@ > * @param xmiExtensionParser the XmiExtensionParser > * @throws OpenException when there is an IO error > */ > - public synchronized void readModels(Project p, URL url, > + public synchronized void readModels(URL url, > XmiExtensionParser xmiExtensionParser) throws OpenException { > LOG.info("======================================="); > LOG.info("== READING MODEL " + url); > @@ -283,7 +275,7 @@ > url.openStream(), xmiExtensionParser, 100000, null)); > > source.setSystemId(url.toString()); > - readModels(p, source); > + readModels(source); > } catch (IOException ex) { > throw new OpenException(ex); > } > @@ -295,11 +287,9 @@ > * @param source The InputSource > * @throws OpenException If an error occur while reading the source > */ > - public synchronized void readModels(Project p, InputSource source) > + public synchronized void readModels(InputSource source) > throws OpenException { > > - proj = p; > - > XmiReader reader = null; > try { > reader = Model.getXmiReader(); > > Modified: trunk/src_new/org/argouml/persistence/XmiFilePersister.java > Url: > http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/persistence/XmiFilePersister.java?view=diff&rev=13169&p1=trunk/src_new/org/argouml/persistence/XmiFilePersister.java&p2=trunk/src_new/org/argouml/persistence/XmiFilePersister.java&r1=13168&r2=13169 > ============================================================================== > --- trunk/src_new/org/argouml/persistence/XmiFilePersister.java (original) > +++ trunk/src_new/org/argouml/persistence/XmiFilePersister.java 2007-07-27 > 15:26:33-0700 > @@ -244,7 +244,7 @@ > ModelMemberFilePersister modelPersister = > new ModelMemberFilePersister(); > > - modelPersister.readModels(p, source); > + modelPersister.readModels(source); > Object model = modelPersister.getCurModel(); > progressMgr.nextPhase(); > Model.getUmlHelper().addListenersToModel(model); > @@ -254,6 +254,7 @@ > modelPersister.registerDiagrams(p); > > p.setRoot(model); > + p.setRoots(modelPersister.getElementsRead()); > File defaultProjectFile = new File(file.getPath() + ".zargo"); > // Make sure the file doesn't exist so the user will > // get prompted to choose a new name > > Modified: trunk/src_new/org/argouml/persistence/ZipFilePersister.java > Url: > http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/persistence/ZipFilePersister.java?view=diff&rev=13169&p1=trunk/src_new/org/argouml/persistence/ZipFilePersister.java&p2=trunk/src_new/org/argouml/persistence/ZipFilePersister.java&r1=13168&r2=13169 > ============================================================================== > --- trunk/src_new/org/argouml/persistence/ZipFilePersister.java (original) > +++ trunk/src_new/org/argouml/persistence/ZipFilePersister.java 2007-07-27 > 15:26:33-0700 > @@ -238,7 +238,7 @@ > ModelMemberFilePersister modelPersister = > new ModelMemberFilePersister(); > > - modelPersister.readModels(p, is); > + modelPersister.readModels(is); > Object model = modelPersister.getCurModel(); > Model.getUmlHelper().addListenersToModel(model); > p.setUUIDRefs(modelPersister.getUUIDRefs()); > @@ -247,6 +247,7 @@ > modelPersister.registerDiagrams(p); > > p.setRoot(model); > + p.setRoots(modelPersister.getElementsRead()); > ProjectManager.getManager().setSaveEnabled(false); > return p; > } catch (IOException e) { > > Modified: trunk/src_new/org/argouml/uml/Profile.java > Url: > http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/Profile.java?view=diff&rev=13169&p1=trunk/src_new/org/argouml/uml/Profile.java&p2=trunk/src_new/org/argouml/uml/Profile.java&r1=13168&r2=13169 > ============================================================================== > --- trunk/src_new/org/argouml/uml/Profile.java (original) > +++ trunk/src_new/org/argouml/uml/Profile.java 2007-07-27 15:26:33-0700 > @@ -25,6 +25,7 @@ > > package org.argouml.uml; > > +import java.util.Collection; > import java.util.Iterator; > /** > * This abstract class captures the configurable behavior of Argo. > @@ -54,8 +55,15 @@ > /** > * @return the UML Model that contains the profile model > * @throws ProfileException if failed to get profile. > + * @deprecated for 0.25.4 by tfmorris. Use [EMAIL PROTECTED] > #getProfilePackages()}. > */ > public abstract Object getProfileModel() throws ProfileException; > + > + /** > + * @return the UML Model that contains the profile model > + * @throws ProfileException if failed to get profile. > + */ > + public abstract Collection getProfilePackages() throws ProfileException; > > /** > * Set the filename to load the profile model from. This will be > > Modified: trunk/src_new/org/argouml/uml/ProfileJava.java > Url: > http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ProfileJava.java?view=diff&rev=13169&p1=trunk/src_new/org/argouml/uml/ProfileJava.java&p2=trunk/src_new/org/argouml/uml/ProfileJava.java&r1=13168&r2=13169 > ============================================================================== > --- trunk/src_new/org/argouml/uml/ProfileJava.java (original) > +++ trunk/src_new/org/argouml/uml/ProfileJava.java 2007-07-27 > 15:26:33-0700 > @@ -31,6 +31,7 @@ > import java.io.InputStream; > import java.net.MalformedURLException; > import java.net.URL; > +import java.util.ArrayList; > import java.util.Collection; > import java.util.Iterator; > import java.util.zip.ZipEntry; > @@ -45,7 +46,7 @@ > import org.xml.sax.InputSource; > > /** > - * This class implements the abstract class Profile for use in modelling > + * This class implements the abstract class Profile for use in modeling > * Java language projects. Eventually, this class may be replaced by > * a configurable profile. > * > @@ -57,7 +58,7 @@ > * the argo.user.properties file. > * > * TODO: This is an i18n nightmare. Tons of hardcoded strings and > - * string concatentation. Change to use message formatting. - tfm 20060226 > + * string concatenation. Change to use message formatting. - tfm 20060226 > * > * @author Curt Arnold > */ > @@ -67,12 +68,14 @@ > */ > private static final Logger LOG = Logger.getLogger(ProfileJava.class); > > - private Object defaultModel; > + private Object profileModel; > + > + private Collection profileElements; > > static final String DEFAULT_PROFILE = > > "/org/argouml/model/mdr/profiles/default-uml14.xmi"; > > - private String defaultModelFilename; > + private String profileFilename; > > /** > * The constructor. > @@ -275,19 +278,30 @@ > return value; > } > > - /* > - * @see org.argouml.uml.Profile#getProfileModel() > - */ > + > + @SuppressWarnings("deprecation") > public Object getProfileModel() throws ProfileException { > - if (defaultModel == null) { > - defaultModel = loadProfileModel(); > + if (profileModel == null) { > + for (Object pkg : getProfilePackages()) { > + if (Model.getFacade().isAPackage(pkg)) { > + profileModel = pkg; > + return profileModel; > + } > + } > + profileModel = getProfilePackages().iterator().next(); > + } > + return profileModel; > + } > + > + > + public Collection getProfilePackages() throws ProfileException { > + if (profileElements == null) { > + profileElements = loadProfileModel(); > } > - return defaultModel; > + return profileElements; > } > > - /* > - * @see org.argouml.uml.Profile#setProfileModelFilename(java.lang.String) > - */ > + > public void setProfileModelFilename(String name) throws ProfileException > { > if (loadProfile(name) != null) { > Configuration.setString(Argo.KEY_DEFAULT_MODEL, name); > @@ -296,18 +310,16 @@ > } > } > > - /* > - * @see org.argouml.uml.Profile#getProfileModelFilename() > - */ > + > public String getProfileModelFilename() { > - if (defaultModelFilename == null) { > + if (profileFilename == null) { > // TODO: Can we remove the use of this property > // and just use the config file setting? - tfm 20060227 > - defaultModelFilename = System.getProperty("argo.defaultModel", > + profileFilename = System.getProperty("argo.defaultModel", > Configuration.getString(Argo.KEY_DEFAULT_MODEL, > DEFAULT_PROFILE)); > } > - return defaultModelFilename; > + return profileFilename; > } > > /** > @@ -322,33 +334,34 @@ > * > * @return the profile model object or null > */ > - public Object loadProfileModel() { > - Object profileModel = null; > + private Collection loadProfileModel() { > + Collection elements = new ArrayList(); > String modelFilename = getProfileModelFilename(); > > if (modelFilename != null) { > - profileModel = loadProfile(modelFilename); > - if (profileModel != null) { > - return profileModel; > + elements.addAll(loadProfile(modelFilename)); > + if (!elements.isEmpty()) { > + return elements; > } > } > > if (!(DEFAULT_PROFILE.equals(modelFilename))) { > LOG.warn("Falling back to default profile '" > + DEFAULT_PROFILE + "'"); > - profileModel = loadProfile(DEFAULT_PROFILE); > - if (profileModel != null) { > - defaultModelFilename = DEFAULT_PROFILE; > - return profileModel; > + elements.addAll(loadProfile(DEFAULT_PROFILE)); > + if (!elements.isEmpty()) { > + profileFilename = DEFAULT_PROFILE; > + return elements; > } > } > > LOG.error("Failed to load any profile - returning empty model"); > - defaultModelFilename = ""; > - return Model.getModelManagementFactory().createModel(); > + profileFilename = ""; > + elements.add(Model.getModelManagementFactory().createModel()); > + return elements; > } > > - private Object loadProfile(String modelFilename) { > + private Collection loadProfile(String modelFilename) { > LOG.info("Loading profile '" + modelFilename + "'"); > InputStream is = null; > // > @@ -402,14 +415,7 @@ > XmiReader xmiReader = Model.getXmiReader(); > InputSource inputSource = new InputSource(is); > LOG.info("Loaded profile '" + modelFilename + "'"); > - Collection elements = xmiReader.parse(inputSource, true); > - if (elements.size() != 1) { > - LOG.error("Error loading profile '" + modelFilename > - + "' expected 1 top level element" + " found " > - + elements.size()); > - return null; > - } > - return elements.iterator().next(); > + return xmiReader.parse(inputSource, true); > } catch (UmlException e) { > LOG.error("Exception while loading profile '" > + modelFilename + "'", e); > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
