Author: maurelio1234
Date: 2008-07-13 00:55:57-0700
New Revision: 15246
Added:
branches/gsoc2008/work_midterm_maurelio1234/
- copied from r15245, /trunk/src/argouml-app/
branches/gsoc2008/work_midterm_maurelio1234/ext/
- copied from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/ext/
branches/gsoc2008/work_midterm_maurelio1234/ext/argouml-critics.jar (props changed)
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/ext/argouml-critics.jar
branches/gsoc2008/work_midterm_maurelio1234/ext/jbeans.jar (props changed)
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/ext/jbeans.jar
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java.mine
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java.mine
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java.r14801
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java.r14801
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/
- copied from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/CompositeModelInterpreter.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/CompositeModelInterpreter.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ComputeTriggers.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/ComputeTriggers.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ContextApplicable.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/ContextApplicable.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/CrOCL.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/CrOCL.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/EvaluateInvariant.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/EvaluateInvariant.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/LambdaEvaluator.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/LambdaEvaluator.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ModelInterpreter.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/ModelInterpreter.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/OclInterpreter.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/OclInterpreter.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/
- copied from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/Bag.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/Bag.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/CollectionsModelInterpreter.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/CollectionsModelInterpreter.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/HashBag.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/HashBag.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/ModelAccessModelInterpreter.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/ModelAccessModelInterpreter.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/OCLAPIModelInterpreter.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/OCLAPIModelInterpreter.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/Uml14ModelInterpreter.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/Uml14ModelInterpreter.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ui/
- copied from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ui/
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ui/ProfilePropPanelFactory.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ui/ProfilePropPanelFactory.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ui/PropPanelCritic.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ui/PropPanelCritic.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/ActionManageProfiles.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/ui/explorer/ActionManageProfiles.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/GoProfileToCritics.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/ui/explorer/GoProfileToCritics.java
branches/gsoc2008/work_midterm_maurelio1234/tests/ArgoUML profile.internal.ocl tests with MDR.launch
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/tests/ArgoUML profile.internal.ocl tests with MDR.launch
branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/
- copied from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/tests/org/argouml/profile/internal/ocl/
branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestCrOCL.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/tests/org/argouml/profile/internal/ocl/TestCrOCL.java
branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestCrOCL2.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/tests/org/argouml/profile/internal/ocl/TestCrOCL2.java
branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestOclInterpreter.java
- copied unchanged from r15245, /branches/gsoc2008/work_criticsprofiles_maurelio1234/tests/org/argouml/profile/internal/ocl/TestOclInterpreter.java
Removed:
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/cognitive/critics/CrProfile.java
Modified:
branches/gsoc2008/work_midterm_maurelio1234/.classpath
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/cognitive/Agency.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/i18n/action.properties
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/i18n/misc.properties
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/kernel/ProfileConfiguration.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/moduleloader/ModuleLoader2.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/Profile.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileManager.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/init/InitProfileSubsystem.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/profiles/uml14/metaprofile.xmi
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/ProjectSettingsDialog.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/ExplorerPopup.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/PerspectiveManager.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/rules/GoProfileToModel.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/cognitive/critics/CrAttrNameConflict.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/cognitive/critics/CrUML.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/cognitive/critics/InitCognitiveCritics.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/diagram/ui/TabDiagram.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/ui/TabProps.java
branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserDefinedProfile.java
Log:
merging with trunk
old was: http://argouml.tigris.org/svn/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/
Modified: branches/gsoc2008/work_midterm_maurelio1234/.classpath
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/.classpath?view=diff&rev=15246&p1=/trunk/src/argouml-app/.classpath&p2=branches/gsoc2008/work_midterm_maurelio1234/.classpath&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/.classpath (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/.classpath 2008-07-13 00:55:57-0700
@@ -1,17 +1,18 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" output="build-eclipse-tests" path="tests"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry exported="true" kind="lib" path="lib/antlr-2.7.7.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/commons-logging-1.0.2.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/gef-0.12.4BETA3.jar" sourcepath="/gef/src"/>
- <classpathentry exported="true" kind="lib" path="lib/ocl-argo-1.1.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/swidgets-0.1.4.jar" sourcepath="/swidgets/src"/>
- <classpathentry exported="true" kind="lib" path="lib/toolbar-1.4.1-20071227.jar" sourcepath="/toolbar/src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
- <classpathentry kind="lib" path="/argouml-core-tools/lib/easymock12.jar"/>
- <classpathentry kind="lib" path="/argouml-core-tools/jdepend-2.9/lib/jdepend-2.9.jar"/>
- <classpathentry kind="output" path="build-eclipse"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" output="build-eclipse-tests" path="tests"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry exported="true" kind="lib" path="lib/antlr-2.7.7.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/commons-logging-1.0.2.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/gef-0.12.4BETA3.jar" sourcepath="/gef/src"/>
+ <classpathentry exported="true" kind="lib" path="lib/ocl-argo-1.1.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/swidgets-0.1.4.jar" sourcepath="/swidgets/src"/>
+ <classpathentry exported="true" kind="lib" path="lib/toolbar-1.4.1-20071227.jar" sourcepath="/toolbar/src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
+ <classpathentry kind="lib" path="/argouml-core-tools/lib/easymock12.jar"/>
+ <classpathentry kind="lib" path="/argouml-core-tools/jdepend-2.9/lib/jdepend-2.9.jar"/>
+ <classpathentry kind="lib" path="/argouml-core-tools/junit-3.8.2/junit.jar"/>
+ <classpathentry kind="output" path="build-eclipse"/>
+</classpath>
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/cognitive/Agency.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/cognitive/Agency.java?view=diff&rev=15246&p1=/trunk/src/argouml-app/src/org/argouml/cognitive/Agency.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/cognitive/Agency.java&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/cognitive/Agency.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/cognitive/Agency.java 2008-07-13 00:55:57-0700
@@ -31,9 +31,11 @@
import java.util.List;
import java.util.Observable;
import java.util.Observer;
+import java.util.Set;
import java.util.Vector;
import org.apache.log4j.Logger;
+import org.argouml.uml.cognitive.critics.CrUML;
/**
* Agency manages Critics. Since classes are not really first class
@@ -235,6 +237,19 @@
register(cr, (Class) clazz);
}
+ /**
+ * Register a critic in the global table of critics that have been
+ * loaded.
+ *
+ * @param cr the critic to register
+ */
+ public static void register(CrUML cr) {
+ Set<Object> metas = cr.getCriticizedMetatypes();
+ for (Object meta : metas) {
+ register(cr, meta);
+ }
+ }
+
private static Hashtable<Class, Collection<Critic>> cachedCritics =
new Hashtable<Class, Collection<Critic>>();
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/i18n/action.properties
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/i18n/action.properties?view=diff&rev=15246&p1=/trunk/src/argouml-app/src/org/argouml/i18n/action.properties&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/i18n/action.properties&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/i18n/action.properties (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/i18n/action.properties 2008-07-13 00:55:57-0700
@@ -126,6 +126,7 @@
action.invert-selection = Invert Selection
action.javadocs = Javadocs
action.layout = Layout
+action.manage-profiles = Manage Profiles...
action.more-info = More Info...
action.navigate-back = Navigate Back
action.navigate-forward = Navigate Forward
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/i18n/misc.properties
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/i18n/misc.properties?view=diff&rev=15246&p1=/trunk/src/argouml-app/src/org/argouml/i18n/misc.properties&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/i18n/misc.properties&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/i18n/misc.properties (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/i18n/misc.properties 2008-07-13 00:55:57-0700
@@ -147,11 +147,13 @@
misc.primitive.rounded-rectangle = Rounded Rectangle
misc.primitive.spline = Spline
misc.primitive.text = Text
+misc.profile.unnamed = Unnamed Profile
misc.profile.model = Profile->Model
misc.profileconfiguration.profile = Profile Configuration->Profile
misc.project.collaboration = Project->Collaboration
misc.project.diagram = Project->Diagram
misc.project.model = Project->Model
+misc.project.critic = Project->Critic
misc.project.profileconfiguration = Project->Profile Configuration
misc.project.roots = Project->Root Elements
misc.project.state-machine = Project->State Machine
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/kernel/ProfileConfiguration.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/kernel/ProfileConfiguration.java?view=diff&rev=15246&p1=/trunk/src/argouml-app/src/org/argouml/kernel/ProfileConfiguration.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/kernel/ProfileConfiguration.java&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/kernel/ProfileConfiguration.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/kernel/ProfileConfiguration.java 2008-07-13 00:55:57-0700
@@ -46,12 +46,13 @@
import org.argouml.profile.Profile;
import org.argouml.profile.ProfileException;
import org.argouml.profile.ProfileFacade;
+import org.argouml.uml.cognitive.critics.CrUML;
/**
- * This class captures represents the unique access point for the
- * configurability allowed by the use of profiles.
- *
- * @author maurelio1234
+ * This class captures represents the unique access point for the
+ * configurability allowed by the use of profiles.
+ *
+ * @author maurelio1234
*/
public class ProfileConfiguration extends AbstractProjectMember {
/**
@@ -69,22 +70,21 @@
private List<Profile> profiles = new ArrayList<Profile>();
private List<Object> profileModels = new ArrayList<Object>();
-
+
/**
* The extension used in serialization and returned by {@link #getType()}
*/
public static final String EXTENSION = "profile";
-
/**
* The configuration key for the default stereotype view.
*/
- public static final ConfigurationKey KEY_DEFAULT_STEREOTYPE_VIEW =
- Configuration.makeKey("profiles", "stereotypeView");
-
+ public static final ConfigurationKey KEY_DEFAULT_STEREOTYPE_VIEW = Configuration
+ .makeKey("profiles", "stereotypeView");
+
/**
- * The default constructor for this class. Sets the default profiles as
- * given by {@link org.argouml.profile.ProfileManager} as the profiles of
+ * The default constructor for this class. Sets the default profiles as
+ * given by {@link org.argouml.profile.ProfileManager} as the profiles of
* the project.
*
* @param project the project that contains this configuration
@@ -97,15 +97,16 @@
updateStrategies();
}
-
+
/**
- * The constructor for pre-defined profile configurations, such as when a
+ * The constructor for pre-defined profile configurations, such as when a
* project is read from a saved file.
+ *
* @param project the project that contains this configuration
- * @param configuredProfiles the {@link Profile}s that will be the project
- * profiles
+ * @param configuredProfiles the {@link Profile}s that will be the project
+ * profiles
*/
- public ProfileConfiguration(Project project,
+ public ProfileConfiguration(Project project,
Collection<Profile> configuredProfiles) {
super(EXTENSION, project);
for (Profile profile : configuredProfiles) {
@@ -113,11 +114,11 @@
}
updateStrategies();
}
-
+
private void updateStrategies() {
for (Profile profile : profiles) {
- activateFormatingStrategy(profile);
- activateDefaultTypeStrategy(profile);
+ activateFormatingStrategy(profile);
+ activateDefaultTypeStrategy(profile);
}
}
@@ -134,10 +135,10 @@
public DefaultTypeStrategy getDefaultTypeStrategy() {
return defaultTypeStrategy;
}
-
+
/**
- * Updates the current strategy to the strategy provided by the
- * passed profile. The profile should have been previously registered.
+ * Updates the current strategy to the strategy provided by the passed
+ * profile. The profile should have been previously registered.
*
* @param profile the profile providing the current default type strategy
*/
@@ -147,18 +148,18 @@
this.defaultTypeStrategy = profile.getDefaultTypeStrategy();
}
}
-
+
/**
- * Updates the current strategy to the strategy provided by the
- * passed profile. The profile should have been previously registered.
+ * Updates the current strategy to the strategy provided by the passed
+ * profile. The profile should have been previously registered.
*
* @param profile the profile providing the current formating strategy
*/
public void activateFormatingStrategy(Profile profile) {
- if (profile != null && profile.getFormatingStrategy() != null
- && getProfiles().contains(profile)) {
- this.formatingStrategy = profile.getFormatingStrategy();
- }
+ if (profile != null && profile.getFormatingStrategy() != null
+ && getProfiles().contains(profile)) {
+ this.formatingStrategy = profile.getFormatingStrategy();
+ }
}
/**
@@ -167,7 +168,7 @@
public List<Profile> getProfiles() {
return profiles;
}
-
+
/**
* Applies a new profile to this configuration
*
@@ -182,7 +183,7 @@
} catch (ProfileException e) {
LOG.warn("Error retrieving profile's " + p + " packages.", e);
}
-
+
FigNodeStrategy fns = p.getFigureStrategy();
if (fns != null) {
figNodeStrategies.add(fns);
@@ -192,13 +193,18 @@
addProfile(dependency);
}
+ for (CrUML critic : p.getCritics()) {
+ critic.setEnabled(true);
+ }
+
updateStrategies();
+
ArgoEventPump.fireEvent(new ArgoProfileEvent(
ArgoEventTypes.PROFILE_ADDED, new PropertyChangeEvent(this,
"profile", null, p)));
}
}
-
+
/**
* @return the list of models of the currently applied profile.
*/
@@ -207,12 +213,17 @@
}
/**
- * Removes the passed profile from the configuration.
+ * Removes the passed profile from the configuration.
*
* @param p the profile to be removed
*/
public void removeProfile(Profile p) {
profiles.remove(p);
+
+ for (CrUML critic : p.getCritics()) {
+ critic.setEnabled(false);
+ }
+
try {
profileModels.removeAll(p.getProfilePackages());
} catch (ProfileException e) {
@@ -244,30 +255,30 @@
ArgoEventTypes.PROFILE_REMOVED, new PropertyChangeEvent(this,
"profile", p, null)));
}
-
+
private FigNodeStrategy compositeFigNodeStrategy = new FigNodeStrategy() {
- public Image getIconForStereotype(Object element) {
- Iterator it = figNodeStrategies.iterator();
+ public Image getIconForStereotype(Object element) {
+ Iterator it = figNodeStrategies.iterator();
+
+ while (it.hasNext()) {
+ FigNodeStrategy strat = (FigNodeStrategy) it.next();
+ Image extra = strat.getIconForStereotype(element);
+
+ if (extra != null) {
+ return extra;
+ }
+ }
+ return null;
+ }
- while (it.hasNext()) {
- FigNodeStrategy strat = (FigNodeStrategy) it.next();
- Image extra = strat.getIconForStereotype(element);
-
- if (extra != null) {
- return extra;
- }
- }
- return null;
- }
-
};
-
+
/**
* @return the current FigNodeStrategy
*/
public FigNodeStrategy getFigNodeStrategy() {
- return compositeFigNodeStrategy;
+ return compositeFigNodeStrategy;
}
/**
@@ -275,18 +286,18 @@
* @see org.argouml.kernel.AbstractProjectMember#getType()
*/
public String getType() {
- return EXTENSION;
+ return EXTENSION;
}
/**
- * Objects of this class are always consistent, there's no need
- * to repair them.
+ * Objects of this class are always consistent, there's no need to repair
+ * them.
*
* @return the empty string.
* @see org.argouml.kernel.ProjectMember#repair()
*/
public String repair() {
- return "";
+ return "";
}
/**
@@ -298,9 +309,8 @@
return "Profile Configuration";
}
-
/**
- * Find a stereotype with the given name which is applicable to the given
+ * Find a stereotype with the given name which is applicable to the given
* element.
*
* @param name name of stereotype to look for
@@ -309,7 +319,7 @@
*/
public Object findStereotypeForObject(String name, Object element) {
Iterator iter = null;
-
+
for (Object model : profileModels) {
iter = Model.getFacade().getOwnedElements(model).iterator();
@@ -347,10 +357,8 @@
}
/**
- * Finds a type in a model by name
- *
- * FIXME: duplicated from the method with the same name in
- * org.argouml.profile.internal.ModelUtils.
+ * Finds a type in a model by name FIXME: duplicated from the method with
+ * the same name in org.argouml.profile.internal.ModelUtils.
*
* @param s the type name
* @param model the model
@@ -359,14 +367,12 @@
public static Object findTypeInModel(String s, Object model) {
if (!Model.getFacade().isANamespace(model)) {
- throw new IllegalArgumentException(
- "Looking for the classifier " + s
- + " in a non-namespace object of " + model
+ throw new IllegalArgumentException("Looking for the classifier "
+ + s + " in a non-namespace object of " + model
+ ". A namespace was expected.");
}
- Collection allClassifiers =
- Model.getModelManagementHelper()
+ Collection allClassifiers = Model.getModelManagementHelper()
.getAllModelElementsOfKind(model,
Model.getMetaTypes().getClassifier());
@@ -377,7 +383,7 @@
classifier = classifiers[i];
if (Model.getFacade().getName(classifier) != null
- && Model.getFacade().getName(classifier).equals(s)) {
+ && Model.getFacade().getName(classifier).equals(s)) {
return classifier;
}
}
@@ -386,12 +392,12 @@
}
/**
- * Find all the model elements in the configured {@link Profile}s
- * of the given meta type.
+ * Find all the model elements in the configured {@link Profile}s of the
+ * given meta type.
*
* @param metaType the meta type of the model elements to find
- * @return a {@link Collection} containing the model elements that
- * are of the given meta type
+ * @return a {@link Collection} containing the model elements that are of
+ * the given meta type
*/
@SuppressWarnings("unchecked")
public Collection findByMetaType(Object metaType) {
@@ -407,8 +413,7 @@
}
/**
- * @param modelElement
- * ModelElement for which find possible stereotypes
+ * @param modelElement ModelElement for which find possible stereotypes
* @return collection of stereotypes which are valid for the given model
* element.
*/
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/moduleloader/ModuleLoader2.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/moduleloader/ModuleLoader2.java?view=diff&rev=15246&p1=/trunk/src/argouml-app/src/org/argouml/moduleloader/ModuleLoader2.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/moduleloader/ModuleLoader2.java&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/moduleloader/ModuleLoader2.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/moduleloader/ModuleLoader2.java 2008-07-13 00:55:57-0700
@@ -41,6 +41,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.StringTokenizer;
import java.util.jar.Attributes;
import java.util.jar.JarEntry;
@@ -51,15 +52,21 @@
import org.argouml.application.api.AbstractArgoJPanel;
import org.argouml.application.api.Argo;
import org.argouml.i18n.Translator;
+import org.argouml.profile.Profile;
+import org.argouml.profile.ProfileException;
+import org.argouml.profile.ProfileFacade;
+import org.argouml.profile.UserDefinedProfile;
+import org.argouml.uml.cognitive.critics.CrUML;
/**
* This is the module loader that loads modules implementing the
- * ModuleInterface.<p>
- *
- * This is a singleton. There are convenience functions that are static
- * to access the module.<p>
- *
+ * ModuleInterface.
+ * <p>
+ * This is a singleton. There are convenience functions that are static to
+ * access the module.
+ * <p>
+ *
* @stereotype singleton
* @author Linus Tolke
* @since 0.15.4
@@ -71,16 +78,16 @@
private static final Logger LOG = Logger.getLogger(ModuleLoader2.class);
/**
- * This map contains the module loader information about the module.<p>
- *
+ * This map contains the module loader information about the module.
+ * <p>
* The keys is the list of available modules.
*/
private Map<ModuleInterface, ModuleStatus> moduleStatus;
-
+
/**
- * List of locations that we've searched and/or loaded modules
- * from. This is for information purposes only to allow it to
- * be displayed in the settings Environment tab.
+ * List of locations that we've searched and/or loaded modules from. This is
+ * for information purposes only to allow it to be displayed in the settings
+ * Environment tab.
*/
private List<String> extensionLocations = new ArrayList<String>();
@@ -108,16 +115,16 @@
* Constructor for this object.
*/
private ModuleLoader2() {
- moduleStatus = new HashMap<ModuleInterface, ModuleStatus>();
+ moduleStatus = new HashMap<ModuleInterface, ModuleStatus>();
}
/**
* Get hold of the instance of this object.
- *
+ *
* @return the instance
*/
public static ModuleLoader2 getInstance() {
- return INSTANCE;
+ return INSTANCE;
}
/**
@@ -132,45 +139,47 @@
}
if (status.isEnabled()) {
if (module instanceof DetailsTabProvider) {
- result.addAll(
- ((DetailsTabProvider) module).getDetailsTabs());
+ result.addAll(((DetailsTabProvider) module)
+ .getDetailsTabs());
}
}
}
return result;
}
+
/**
* Return a collection of all available modules.
- *
+ *
* @return A Collection of all available modules.
*/
private Collection<ModuleInterface> availableModules() {
- return Collections.unmodifiableCollection(moduleStatus.keySet());
+ return Collections.unmodifiableCollection(moduleStatus.keySet());
}
// Access methods for program infrastructure.
/**
- * Enables all selected modules and disabling all modules not selected.<p>
- *
- * In short this attempts to make the modules obey their selection.<p>
- *
+ * Enables all selected modules and disabling all modules not selected.
+ * <p>
+ * In short this attempts to make the modules obey their selection.
+ * <p>
+ *
* @param failingAllowed is <code>true</code> if enabling or disabling of
- * some of the modules is allowed to fail.
+ * some of the modules is allowed to fail.
*/
public static void doLoad(boolean failingAllowed) {
- getInstance().doInternal(failingAllowed);
+ getInstance().doInternal(failingAllowed);
}
// Access methods for modules that need to query about the status of
// other modules.
/**
* Gets the loaded status for some other module.
- *
+ *
* @return true if the module exists and is enabled.
* @param name is the module name of the queried module
*/
public static boolean isEnabled(String name) {
- return getInstance().isEnabledInternal(name);
+ return getInstance().isEnabledInternal(name);
}
// Access methods for the GUI that the user uses to enable and disable
@@ -178,82 +187,82 @@
/**
* Get a Collection with all the names.
- *
+ *
* @return all the names.
*/
public static Collection<String> allModules() {
- Collection<String> coll = new HashSet<String>();
+ Collection<String> coll = new HashSet<String>();
- for (ModuleInterface mf : getInstance().availableModules()) {
- coll.add(mf.getName());
- }
+ for (ModuleInterface mf : getInstance().availableModules()) {
+ coll.add(mf.getName());
+ }
- return coll;
+ return coll;
}
/**
* Get the selected.
- *
+ *
* @param name The name of the module.
* @return <code>true</code> if the module is selected.
*/
public static boolean isSelected(String name) {
- return getInstance().isSelectedInternal(name);
+ return getInstance().isSelectedInternal(name);
}
/**
* Get the selected.
- *
+ *
* @see #isSelected(String)
* @param name The name of the module.
* @return <code>true</code> if the module is selected.
*/
private boolean isSelectedInternal(String name) {
- Map.Entry<ModuleInterface, ModuleStatus> entry = findModule(name);
+ Map.Entry<ModuleInterface, ModuleStatus> entry = findModule(name);
- if (entry != null) {
- ModuleStatus status = entry.getValue();
+ if (entry != null) {
+ ModuleStatus status = entry.getValue();
- if (status == null) {
- return false;
- }
+ if (status == null) {
+ return false;
+ }
- return status.isSelected();
- }
- return false;
+ return status.isSelected();
+ }
+ return false;
}
/**
* Set the selected value.
- *
+ *
* @param name The name of the module.
* @param value Selected or not.
*/
public static void setSelected(String name, boolean value) {
- getInstance().setSelectedInternal(name, value);
+ getInstance().setSelectedInternal(name, value);
}
/**
* Set the selected value.
- *
+ *
* @see #setSelected(String, boolean)
* @param name The name of the module.
* @param value Selected or not.
*/
private void setSelectedInternal(String name, boolean value) {
- Map.Entry<ModuleInterface, ModuleStatus> entry = findModule(name);
+ Map.Entry<ModuleInterface, ModuleStatus> entry = findModule(name);
- if (entry != null) {
- ModuleStatus status = entry.getValue();
+ if (entry != null) {
+ ModuleStatus status = entry.getValue();
- status.setSelected(value);
- }
+ status.setSelected(value);
+ }
}
/**
- * Create a description of the module based on the information provided
- * by the module itself.
- *
+ * Create a description of the module based on the information provided by
+ * the module itself.
+ *
* @param name The name of the module.
* @return The description.
*/
@@ -262,21 +271,21 @@
}
/**
- * Create a description of the module based on the information provided
- * by the module itself.
- *
+ * Create a description of the module based on the information provided by
+ * the module itself.
+ *
* @see #getDescription(String)
* @param name The name of the module.
* @return The description.
*/
private String getDescriptionInternal(String name) {
- Map.Entry<ModuleInterface, ModuleStatus> entry = findModule(name);
+ Map.Entry<ModuleInterface, ModuleStatus> entry = findModule(name);
- if (entry == null) {
- throw new IllegalArgumentException("Module does not exist.");
- }
+ if (entry == null) {
+ throw new IllegalArgumentException("Module does not exist.");
+ }
- ModuleInterface module = entry.getKey();
+ ModuleInterface module = entry.getKey();
StringBuffer sb = new StringBuffer();
String desc = module.getInfo(ModuleInterface.DESCRIPTION);
if (desc != null) {
@@ -296,28 +305,27 @@
return sb.toString();
}
-
// Access methods for the program infrastructure
/**
* Enables all selected modules.
- *
- * @param failingAllowed is true if this is not the last attempt at
- * turning on.
+ *
+ * @param failingAllowed is true if this is not the last attempt at turning
+ * on.
*/
private void doInternal(boolean failingAllowed) {
- huntForModules();
+ huntForModules();
- boolean someModuleSucceeded;
- do {
- someModuleSucceeded = false;
+ boolean someModuleSucceeded;
+ do {
+ someModuleSucceeded = false;
- for (ModuleInterface module : getInstance().availableModules()) {
+ for (ModuleInterface module : getInstance().availableModules()) {
- ModuleStatus status = moduleStatus.get(module);
+ ModuleStatus status = moduleStatus.get(module);
- if (status == null) {
- continue;
- }
+ if (status == null) {
+ continue;
+ }
if (!status.isEnabled() && status.isSelected()) {
try {
@@ -347,68 +355,67 @@
}
} while (someModuleSucceeded);
- if (!failingAllowed) {
- // Notify the user that the modules in the list that are selected
- // but not enabled were not possible to enable and that are not
- // selected that we cannot disable.
- //
- // Currently we just log this.
- //
- // TODO: We could eventually pop up some warning window.
- //
- for (ModuleInterface module : getInstance().availableModules()) {
+ if (!failingAllowed) {
+ // Notify the user that the modules in the list that are selected
+ // but not enabled were not possible to enable and that are not
+ // selected that we cannot disable.
+ //
+ // Currently we just log this.
+ //
+ // TODO: We could eventually pop up some warning window.
+ //
+ for (ModuleInterface module : getInstance().availableModules()) {
- ModuleStatus status = moduleStatus.get(module);
+ ModuleStatus status = moduleStatus.get(module);
- if (status == null) {
- continue;
- }
+ if (status == null) {
+ continue;
+ }
- if (status.isEnabled() && status.isSelected()) {
- continue;
- }
+ if (status.isEnabled() && status.isSelected()) {
+ continue;
+ }
- if (!status.isEnabled() && !status.isSelected()) {
- continue;
- }
+ if (!status.isEnabled() && !status.isSelected()) {
+ continue;
+ }
- if (status.isSelected()) {
- LOG.warn("ModuleLoader was not able to enable module "
- + module.getName());
- } else {
- LOG.warn("ModuleLoader was not able to disable module "
- + module.getName());
- }
- }
- }
+ if (status.isSelected()) {
+ LOG.warn("ModuleLoader was not able to enable module "
+ + module.getName());
+ } else {
+ LOG.warn("ModuleLoader was not able to disable module "
+ + module.getName());
+ }
+ }
+ }
}
/**
* Gets the loaded status for some other module.
- *
+ *
* @return true if the module exists and is enabled.
* @param name is the module name of the queried module
*/
private boolean isEnabledInternal(String name) {
- Map.Entry<ModuleInterface, ModuleStatus> entry = findModule(name);
+ Map.Entry<ModuleInterface, ModuleStatus> entry = findModule(name);
- if (entry != null) {
- ModuleStatus status = entry.getValue();
+ if (entry != null) {
+ ModuleStatus status = entry.getValue();
- if (status == null) {
- return false;
- }
+ if (status == null) {
+ return false;
+ }
- return status.isEnabled();
- }
- return false;
+ return status.isEnabled();
+ }
+ return false;
}
-
/**
- * Return the ModuleInterface, ModuleStatus pair for the module
- * with the given name or <code>null</code> if there isn't any.
- *
+ * Return the ModuleInterface, ModuleStatus pair for the module with the
+ * given name or <code>null</code> if there isn't any.
+ *
* @param name The given name.
* @return A pair (Map.Entry).
*/
@@ -420,13 +427,14 @@
return entry;
}
}
- return null;
+ return null;
}
/**
- * Tries to find as many available modules as possible.<p>
- *
- * As the modules are found they are appended to {@link #moduleStatus}.<p>
+ * Tries to find as many available modules as possible.
+ * <p>
+ * As the modules are found they are appended to {@link #moduleStatus}.
+ * <p>
*/
private void huntForModules() {
huntForModulesFromExtensionDir();
@@ -449,75 +457,72 @@
}
}
}
-
+
/**
- * Find and enable modules from our "ext" directory and from the
- * directory specified in "argo.ext.dir".<p>
- *
- * TODO: This does a calculation of where our "ext" directory is.
- * We should eventually make sure that this calculation is
- * only present in one place in the code and not several.
+ * Find and enable modules from our "ext" directory and from the directory
+ * specified in "argo.ext.dir".
+ * <p>
+ * TODO: This does a calculation of where our "ext" directory is. We should
+ * eventually make sure that this calculation is only present in one place
+ * in the code and not several.
*/
private void huntForModulesFromExtensionDir() {
- // Use a little trick to find out where Argo is being loaded from.
+ // Use a little trick to find out where Argo is being loaded from.
String extForm = getClass().getResource(Argo.ARGOINI).toExternalForm();
- String argoRoot =
- extForm.substring(0,
- extForm.length() - Argo.ARGOINI.length());
-
- // If it's a jar, clean it up and make it look like a file url
- if (argoRoot.startsWith(JAR_PREFIX)) {
- argoRoot = argoRoot.substring(JAR_PREFIX.length());
- if (argoRoot.endsWith("!")) {
- argoRoot = argoRoot.substring(0, argoRoot.length() - 1);
- }
- }
+ String argoRoot = extForm.substring(0, extForm.length()
+ - Argo.ARGOINI.length());
- String argoHome = null;
+ // If it's a jar, clean it up and make it look like a file url
+ if (argoRoot.startsWith(JAR_PREFIX)) {
+ argoRoot = argoRoot.substring(JAR_PREFIX.length());
+ if (argoRoot.endsWith("!")) {
+ argoRoot = argoRoot.substring(0, argoRoot.length() - 1);
+ }
+ }
- if (argoRoot != null) {
- LOG.info("argoRoot is " + argoRoot);
- if (argoRoot.startsWith(FILE_PREFIX)) {
- argoHome =
- new File(argoRoot.substring(FILE_PREFIX.length()))
- .getAbsoluteFile().getParent();
- } else {
- argoHome = new File(argoRoot).getAbsoluteFile().getParent();
- }
+ String argoHome = null;
- try {
- argoHome = java.net.URLDecoder.decode(argoHome,
- Argo.getEncoding());
- } catch (UnsupportedEncodingException e) {
- LOG.warn("Encoding "
- + Argo.getEncoding()
- + " is unknown.");
- }
+ if (argoRoot != null) {
+ LOG.info("argoRoot is " + argoRoot);
+ if (argoRoot.startsWith(FILE_PREFIX)) {
+ argoHome = new File(argoRoot.substring(FILE_PREFIX.length()))
+ .getAbsoluteFile().getParent();
+ } else {
+ argoHome = new File(argoRoot).getAbsoluteFile().getParent();
+ }
+
+ try {
+ argoHome = java.net.URLDecoder.decode(argoHome, Argo
+ .getEncoding());
+ } catch (UnsupportedEncodingException e) {
+ LOG.warn("Encoding " + Argo.getEncoding() + " is unknown.");
+ }
- LOG.info("argoHome is " + argoHome);
- }
+ LOG.info("argoHome is " + argoHome);
+ }
- if (argoHome != null) {
+ if (argoHome != null) {
String extdir;
- if (argoHome.startsWith(FILE_PREFIX)) {
- extdir = argoHome.substring(FILE_PREFIX.length())
+ if (argoHome.startsWith(FILE_PREFIX)) {
+ extdir = argoHome.substring(FILE_PREFIX.length())
+ File.separator + "ext";
- } else {
- extdir = argoHome + File.separator + "ext";
- }
+ } else {
+ extdir = argoHome + File.separator + "ext";
+ }
extensionLocations.add(extdir);
- huntModulesFromNamedDirectory(extdir);
- }
+ huntModulesFromNamedDirectory(extdir);
+ }
String extdir = System.getProperty("argo.ext.dir");
- if (extdir != null) {
+ if (extdir != null) {
extensionLocations.add(extdir);
- huntModulesFromNamedDirectory(extdir);
- }
+ huntModulesFromNamedDirectory(extdir);
+ }
}
-
+
/**
* Get the list of locations that we've loaded extension modules from.
+ *
* @return A list of the paths we've loaded from.
*/
public List<String> getExtensionLocations() {
@@ -526,62 +531,58 @@
/**
* Find and enable a module from a given directory.
- *
+ *
* @param dirname The name of the directory.
*/
private void huntModulesFromNamedDirectory(String dirname) {
- File extensionDir = new File(dirname);
- if (extensionDir.isDirectory()) {
- File[] files = extensionDir.listFiles(new JarFileFilter());
- for (File file : files) {
- JarFile jarfile = null;
- // Try-catch only the JarFile instantiation so we
- // don't accidentally mask anything in ArgoJarClassLoader
- // or processJarFile.
- try {
- jarfile = new JarFile(file);
- if (jarfile != null) {
- // TODO: Should we be delegating to a different
- // classloader than the default here? - - tfm
- ClassLoader classloader =
- new URLClassLoader(new URL[] {
- file.toURI().toURL(),
- });
- try {
- processJarFile(classloader, file);
- } catch (ClassNotFoundException e) {
- LOG.error("The class is not found.", e);
- return;
- }
- }
- } catch (IOException ioe) {
- LOG.debug("Cannot open Jar file " + file, ioe);
- }
- }
- }
+ File extensionDir = new File(dirname);
+ if (extensionDir.isDirectory()) {
+ File[] files = extensionDir.listFiles(new JarFileFilter());
+ for (File file : files) {
+ JarFile jarfile = null;
+ // Try-catch only the JarFile instantiation so we
+ // don't accidentally mask anything in ArgoJarClassLoader
+ // or processJarFile.
+ try {
+ jarfile = new JarFile(file);
+ if (jarfile != null) {
+ // TODO: Should we be delegating to a different
+ // classloader than the default here? - - tfm
+ ClassLoader classloader = new URLClassLoader(
+ new URL[] { file.toURI().toURL(), });
+ try {
+ processJarFile(classloader, file);
+ } catch (ClassNotFoundException e) {
+ LOG.error("The class is not found.", e);
+ return;
+ }
+ }
+ } catch (IOException ioe) {
+ LOG.debug("Cannot open Jar file " + file, ioe);
+ }
+ }
+ }
}
/**
- * Check a jar file for an ArgoUML extension/module.<p>
- *
+ * Check a jar file for an ArgoUML extension/module.
+ * <p>
* If there isn't a manifest or it isn't readable, we fail silently.
- *
- * @param classloader The classloader to use.
- * @param file The file to process.
- * @throws ClassNotFoundException if the manifest file contains a class
- * that doesn't exist.
+ *
+ * @throws ClassNotFoundException if the manifest file contains a class that
+ * doesn't exist.
*/
private void processJarFile(ClassLoader classloader, File file)
throws ClassNotFoundException {
- LOG.info("Opening jar file " + file);
+ LOG.info("Opening jar file " + file);
JarFile jarfile;
- try {
- jarfile = new JarFile(file);
- } catch (IOException e) {
- LOG.error("Unable to open " + file, e);
+ try {
+ jarfile = new JarFile(file);
+ } catch (IOException e) {
+ LOG.error("Unable to open " + file, e);
return;
- }
+ }
Manifest manifest;
try {
@@ -593,26 +594,30 @@
LOG.error("Unable to read manifest of " + file, e);
return;
}
-
+
+ LOG.info("Reading profiles...");
+ try {
+ loadProfilesFromJarFile(jarfile.getManifest(), file, classloader);
+ } catch (IOException e) {
+ LOG.error("Unable to get MANIFEST from Jar of " + file, e);
+ }
+
boolean loadedClass = false;
if (manifest == null) {
Enumeration<JarEntry> jarEntries = jarfile.entries();
while (jarEntries.hasMoreElements()) {
JarEntry entry = jarEntries.nextElement();
- loadedClass =
- loadedClass
- | processEntry(classloader, entry.getName());
+ loadedClass = loadedClass
+ | processEntry(classloader, entry.getName());
}
} else {
Map<String, Attributes> entries = manifest.getEntries();
for (String key : entries.keySet()) {
// Look for our specification
- loadedClass =
- loadedClass
- | processEntry(classloader, key);
+ loadedClass = loadedClass | processEntry(classloader, key);
}
}
-
+
if (loadedClass) {
// Add this to search list for I18N properties
Translator.addClassLoader(classloader);
@@ -623,13 +628,130 @@
}
/**
+ * Interprets the MANIFEST file in the JAR in order to load the declared
+ * profile.
+ *
+ * @param file the file object referencing the Jar
+ * @param manifest the manifest file of the Jar
+ * @param classloader the classloader that loads the classes referenced by
+ * the Jar
+ */
+ private void loadProfilesFromJarFile(Manifest manifest, File file,
+ ClassLoader classloader) {
+ Map<String, Attributes> entries = manifest.getEntries();
+ boolean classLoaderAlreadyAdded = false;
+
+ for (String entryName : entries.keySet()) {
+ Attributes attr = entries.get(entryName);
+ if (new Boolean(attr.getValue("Profile") + "").booleanValue()) {
+ try {
+ // we only need to add the classloader once
+ // and if and only if there is at least a profile
+ // in the JAR
+ if (!classLoaderAlreadyAdded) {
+ Translator.addClassLoader(classloader);
+ classLoaderAlreadyAdded = true;
+ }
+ Set<CrUML> critics = loadJavaCriticsForProfile(attr,
+ classloader);
+ String modelPath = attr.getValue("Model");
+ URL modelURL = null;
+
+ if (modelPath != null) {
+ modelURL = new URL(JAR_PREFIX + FILE_PREFIX
+ + file.getCanonicalPath() + "!" + modelPath);
+ }
+
+ UserDefinedProfile udp = new UserDefinedProfile(entryName,
+ modelURL, critics,
+ loadManifestDependenciesForProfile(attr));
+
+ ProfileFacade.getManager().registerProfile(udp);
+ LOG.debug("Registered Profile: " + udp.getDisplayName()
+ + "...");
+ } catch (ProfileException e) {
+ LOG.error("Exception", e);
+ } catch (IOException e) {
+ LOG.error("Exception", e);
+ }
+ }
+
+ }
+ }
+
+ /**
+ * Resolves the dependencies for a Profile
+ *
+ * TODO How do we deal with the non-determinism in the order of the loaded
+ * profiles? (Maybe the d depended profiles were not loaded yet)
+ *
+ * @param attr a group of attributes in the MANIFEST file for this JAR
+ *
+ * @return the set of defined profiles
+ */
+ private Set<Profile> loadManifestDependenciesForProfile(Attributes attr) {
+ Set<Profile> ret = new HashSet<Profile>();
+ String value = attr.getValue("Depends-on");
+ if (value != null) {
+ StringTokenizer st = new StringTokenizer(value, ",");
+
+ while (st.hasMoreElements()) {
+ String entry = st.nextToken().trim();
+ Profile p = ProfileFacade.getManager()
+ .lookForRegisteredProfile(entry);
+ if (p != null) {
+ ret.add(p);
+ } else {
+ LOG.debug("Found unknown profile in dependency list! " + entry);
+ }
+ }
+ }
+
+ return ret;
+ }
+
+ /**
+ * Loads the Java critics defined by a profile
+ *
+ * @param attr the Manifest section of the profile
+ * @param classloader the classloader of the Jar
+ *
+ * @return the set of defined critics
+ */
+ private Set<CrUML> loadJavaCriticsForProfile(Attributes attr,
+ ClassLoader classloader) {
+ Set<CrUML> ret = new HashSet<CrUML>();
+
+ String value = attr.getValue("Java-Critics");
+ if (value != null) {
+ StringTokenizer st = new StringTokenizer(value, ",");
+
+ while (st.hasMoreElements()) {
+ String entry = st.nextToken().trim();
+
+ try {
+ Class cl = classloader.loadClass(entry);
+ CrUML critic = (CrUML) cl.newInstance();
+ ret.add(critic);
+ } catch (ClassNotFoundException e) {
+ LOG.error("Error loading class: " + entry, e);
+ } catch (InstantiationException e) {
+ LOG.error("Error instantianting class: " + entry, e);
+ } catch (IllegalAccessException e) {
+ LOG.error("Exception", e);
+ }
+ }
+ }
+
+ return ret;
+ }
+
+ /**
* Process a JAR file entry, attempting to load anything that looks like a
* Java class.
*
- * @param classloader
- * the classloader to use when loading the class
- * @param cname
- * the class name
+ * @param classloader the classloader to use when loading the class
+ * @param cname the class name
* @throws ClassNotFoundException
* @return true if class was a module class and loaded successfully
*/
@@ -646,23 +768,21 @@
/**
* Add a class from the current class loader.
- *
+ *
* @param classname The name of the class (including package).
* @throws ClassNotFoundException if the class classname is not found.
*/
- public static void addClass(String classname)
- throws ClassNotFoundException {
+ public static void addClass(String classname) throws ClassNotFoundException {
- getInstance().addClass(ModuleLoader2.class.getClassLoader(),
- classname);
+ getInstance().addClass(ModuleLoader2.class.getClassLoader(), classname);
}
/**
- * Try to load a module from the given ClassLoader.<p>
- *
+ * Try to load a module from the given ClassLoader.
+ * <p>
* Only add it as a module if it is a module (i.e. it implements the
* {@link ModuleInterface} interface.
- *
+ *
* @param classLoader The ClassLoader to load from.
* @param classname The name.
* @throws ClassNotFoundException if the class classname is not found.
@@ -689,7 +809,7 @@
LOG.error("Unexpected error while loading " + classname, e);
return false;
}
-
+
if (!ModuleInterface.class.isAssignableFrom(moduleClass)) {
LOG.debug("The class " + classname + " is not a module.");
return false;
@@ -697,16 +817,15 @@
Constructor defaultConstructor;
try {
- defaultConstructor =
- moduleClass.getDeclaredConstructor(new Class[] {});
+ defaultConstructor = moduleClass
+ .getDeclaredConstructor(new Class[] {});
} catch (SecurityException e) {
LOG.error("The default constructor for class " + classname
- + " is not accessable.",
- e);
+ + " is not accessable.", e);
return false;
} catch (NoSuchMethodException e) {
LOG.error("The default constructor for class " + classname
- + " is not found.", e);
+ + " is not found.", e);
return false;
} catch (NoClassDefFoundError e) {
LOG.error("Unable to find required class while loading "
@@ -725,7 +844,7 @@
}
Object moduleInstance;
try {
- moduleInstance = defaultConstructor.newInstance(new Object[]{});
+ moduleInstance = defaultConstructor.newInstance(new Object[] {});
} catch (IllegalArgumentException e) {
LOG.error("The constructor for class " + classname
+ " is called with incorrect argument.", e);
@@ -766,51 +885,48 @@
}
/**
- * Add a newly found module to {@link #moduleStatus}. If we already
- * know about it, don't add it.
- *
+ * Add a newly found module to {@link #moduleStatus}. If we already know
+ * about it, don't add it.
+ *
* @param mf The module to add.
*/
private void addModule(ModuleInterface mf) {
- // Since there is no way to compare the objects as equal,
- // we have to search through the list at this point.
+ // Since there is no way to compare the objects as equal,
+ // we have to search through the list at this point.
for (ModuleInterface foundMf : moduleStatus.keySet()) {
- if (foundMf.getName().equals(mf.getName())) {
- return;
- }
- }
+ if (foundMf.getName().equals(mf.getName())) {
+ return;
+ }
+ }
- // We havn't found it. Add it.
- ModuleStatus ms = new ModuleStatus();
+ // We havn't found it. Add it.
+ ModuleStatus ms = new ModuleStatus();
- // Enable it.
- // TODO: This by default selects all modules that are found.
- // Eventually we would rather obey a default either from the
- // modules themselves, from how they are found, and also
- // have information on what modules are selected from the
- // configuration.
- ms.setSelected();
+ // Enable it.
+ // TODO: This by default selects all modules that are found.
+ // Eventually we would rather obey a default either from the
+ // modules themselves, from how they are found, and also
+ // have information on what modules are selected from the
+ // configuration.
+ ms.setSelected();
- moduleStatus.put(mf, ms);
+ moduleStatus.put(mf, ms);
}
-
/**
* The file filter that selects Jar files.
*/
static class JarFileFilter implements FileFilter {
- /*
- * @see java.io.FileFilter#accept(java.io.File)
- */
- public boolean accept(File pathname) {
- return (pathname.canRead()
- && pathname.isFile()
- && pathname.getPath().toLowerCase().endsWith(".jar"));
- }
+ /*
+ * @see java.io.FileFilter#accept(java.io.File)
+ */
+ public boolean accept(File pathname) {
+ return (pathname.canRead() && pathname.isFile() && pathname
+ .getPath().toLowerCase().endsWith(".jar"));
+ }
}
}
-
/**
* Status for each of the available modules. This is created in one copy per
* available module.
@@ -828,61 +944,60 @@
/**
* Tells if the module is enabled or not.
- *
+ *
* @return true if the module is enabled.
*/
public boolean isEnabled() {
- return enabled;
+ return enabled;
}
/**
* Setter for enabled.
*/
public void setEnabled() {
- enabled = true;
+ enabled = true;
}
/**
* Setter for enabled.
*/
public void setDisabled() {
- enabled = false;
+ enabled = false;
}
/**
* Tells if the module is selected by the user or not.
- *
+ *
* @return true if it is selected.
*/
public boolean isSelected() {
- return selected;
+ return selected;
}
-
/**
* Setter for selected.
*/
public void setSelected() {
- selected = true;
+ selected = true;
}
/**
* Setter for selected.
*/
public void setUnselect() {
- selected = false;
+ selected = false;
}
/**
* Setter for selected.
- *
+ *
* @param value The value to set.
*/
public void setSelected(boolean value) {
- if (value) {
- setSelected();
- } else {
- setUnselect();
- }
+ if (value) {
+ setSelected();
+ } else {
+ setUnselect();
+ }
}
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/Profile.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/Profile.java?view=diff&rev=15246&p1=/trunk/src/argouml-app/src/org/argouml/profile/Profile.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/Profile.java&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/profile/Profile.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/Profile.java 2008-07-13 00:55:57-0700
@@ -28,18 +28,21 @@
import java.util.HashSet;
import java.util.Set;
+import org.argouml.uml.cognitive.critics.CrUML;
+
/**
* Abstract class representing a Profile. It contains default types and
* presentation characteristics that can be tailored to various modeling
* environments.
*
- * @author Marcos Aurélio
+ * @author Marcos Aur�lio
*/
public abstract class Profile {
private Set<Profile> importedProfiles = new HashSet<Profile>();
private Set<Profile> importingProfiles = new HashSet<Profile>();
+ protected Set<CrUML> critics = new HashSet<CrUML>();
/**
* Add a dependency on the given profile from this profile.
@@ -116,4 +119,11 @@
public String toString() {
return getDisplayName();
}
+
+ /**
+ * @return Returns the critics defined by this profile.
+ */
+ public Set<CrUML> getCritics() {
+ return critics;
+ }
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileManager.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileManager.java?view=diff&rev=15246&p1=/trunk/src/argouml-app/src/org/argouml/profile/ProfileManager.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileManager.java&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/profile/ProfileManager.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileManager.java 2008-07-13 00:55:57-0700
@@ -113,4 +113,12 @@
* the standard.
*/
Profile getUMLProfile();
+
+ /**
+ * Looks for registered Profile
+ *
+ * @param profile name
+ * @return profile
+ */
+ Profile lookForRegisteredProfile(String profile);
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java?view=diff&rev=15246&p1=/trunk/src/argouml-app/src/org/argouml/profile/UserDefinedProfile.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/profile/UserDefinedProfile.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java 2008-07-13 00:55:57-0700
@@ -24,35 +24,91 @@
package org.argouml.profile;
+import java.awt.Image;
+import java.io.BufferedInputStream;
import java.io.File;
-import java.io.Reader;
+import java.io.FileInputStream;
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
+import java.util.HashMap;
+import java.util.Set;
import java.util.StringTokenizer;
+import java.util.Vector;
+import javax.swing.ImageIcon;
+
+import org.apache.log4j.Logger;
+import org.argouml.cognitive.Translator;
import org.argouml.model.Model;
+import org.argouml.profile.internal.ocl.CrOCL;
+import org.argouml.uml.cognitive.critics.CrUML;
/**
* Represents a profile defined by the user
- *
- * @author Marcos Aur�lio
+ *
+ * @author maurelio1234
*/
public class UserDefinedProfile extends Profile {
+ /**
+ * Logger.
+ */
+ private static final Logger LOG = Logger.getLogger(UserDefinedProfile.class);
+
private String displayName;
+
private File modelFile;
private Collection profilePackages;
- private boolean fromZargo;
+
+ private UserDefinedFigNodeStrategy figNodeStrategy
+ = new UserDefinedFigNodeStrategy();
+
+ private class UserDefinedFigNodeStrategy implements FigNodeStrategy {
+
+ private HashMap<String, Image> images = new HashMap<String, Image>();
+
+ public Image getIconForStereotype(Object stereotype) {
+ return images.get(Model.getFacade().getName(stereotype));
+ }
+
+ /**
+ * Adds a new descriptor to this strategy
+ *
+ * @param fnd
+ */
+ public void addDesrciptor(FigNodeDescriptor fnd) {
+ images.put(fnd.stereotype, fnd.img);
+ }
+ }
+
+ private class FigNodeDescriptor {
+ String stereotype;
+
+ Image img;
+
+ String src;
+
+ int length;
+
+ /**
+ * @return if this descriptor ir valid
+ */
+ public boolean isValid() {
+ return stereotype != null && src != null && length > 0;
+ }
+ }
/**
* The default constructor for this class
*
- * @param file the file from where the model should be read
+ * @param file the file from where the model should be read
* @throws ProfileException if the profile could not be loaded
*/
public UserDefinedProfile(File file) throws ProfileException {
+ LOG.info("load " + file);
displayName = file.getName();
modelFile = file;
ProfileReference reference = null;
@@ -60,59 +116,68 @@
reference = new UserProfileReference(file.getPath());
} catch (MalformedURLException e) {
throw new ProfileException(
- "Failed to create the ProfileReference.", e);
+ "Failed to create the ProfileReference.", e);
}
profilePackages = new FileModelLoader().loadModel(reference);
- fromZargo = false;
- completeLoading();
+ finishLoading();
}
-
/**
- * A constructor that takes a file name and a reader, being the reader the
- * input method to get the profile model.
+ * A constructor that reads a file from an URL
*
- * @param fileName name of the profile model file.
- * @param reader a reader opened from where the profile model will be
- * loaded.
- * @throws ProfileException if something goes wrong in initializing the
- * profile.
- */
- public UserDefinedProfile(String fileName, Reader reader)
- throws ProfileException {
- displayName = fileName;
- ProfileReference reference = null;
- try {
- reference = new UserProfileReference(fileName);
- } catch (MalformedURLException e) {
- throw new ProfileException(
- "Failed to create the ProfileReference.", e);
- }
- profilePackages = new ReaderModelLoader(reader).loadModel(reference);
- fromZargo = true;
-
- completeLoading();
- }
-
-
- // TODO: Add missing Javadoc
+ * @param url the URL
+ * @throws ProfileException
+ */
public UserDefinedProfile(URL url) throws ProfileException {
- ProfileReference reference =
- new UserProfileReference(url.getPath(), url);
+ LOG.info("load " + url);
+
+ ProfileReference reference = null;
+ reference = new UserProfileReference(url.getPath(), url);
profilePackages = new URLModelLoader().loadModel(reference);
- fromZargo = false;
- completeLoading();
+ finishLoading();
}
+
+ /**
+ * A constructor that reads a file from an URL associated with some profiles
+ *
+ * @param displayName the display name of the profile
+ * @param url the URL of the profile mode
+ * @param critics the Critics defined by this profile
+ * @param dependencies the dependencies of this profile
+ *
+ * @throws ProfileException if the model cannot be loaded
+ */
+ public UserDefinedProfile(String displayName, URL url, Set<CrUML> critics,
+ Set<Profile> dependencies) throws ProfileException {
+ LOG.info("load " + url);
+
+ this.displayName = displayName;
+ if (url != null) {
+ ProfileReference reference = null;
+ reference = new UserProfileReference(url.getPath(), url);
+ profilePackages = new URLModelLoader().loadModel(reference);
+ } else {
+ profilePackages = new ArrayList(0);
+ }
+ this.critics = critics;
+
+ for (Profile profile : dependencies) {
+ addProfileDependency(profile);
+ }
+
+ finishLoading();
+ }
+
/**
* Reads the informations defined as TaggedValues
*/
- private void completeLoading() {
-
- for (Object obj : profilePackages) {
+ private void finishLoading() {
+
+ for (Object obj : profilePackages) {
if (Model.getExtensionMechanismsHelper().hasStereotype(obj,
"profile")) {
@@ -120,57 +185,133 @@
String name = Model.getFacade().getName(obj);
if (name != null) {
displayName = name;
+ } else {
+ if (displayName == null) {
+ displayName = Translator.localize("misc.profile.unnamed");
+ }
}
+ LOG.info("profile " + displayName);
- // TODO: Instead of a TaggedValue, why can't this just use
- // Dependencies with the <<appliedProfile>> stereotype? It
- // seems designed exactly for cases like this.
-
// load profile dependencies
- String dep = Model.getFacade().getTaggedValueValue(obj,
+ String dependencyListStr = Model.getFacade().getTaggedValueValue(obj,
"Dependency");
- StringTokenizer st = new StringTokenizer(dep, " ,;:");
+ StringTokenizer st = new StringTokenizer(dependencyListStr, " ,;:");
- String prof = null;
+ String profile = null;
while (st.hasMoreTokens()) {
- prof = st.nextToken();
- if (prof != null) {
- this.addProfileDependency(
- lookForRegisteredProfile(prof));
+ profile = st.nextToken();
+ if (profile != null) {
+ LOG.debug("AddingDependency " + profile);
+ this.
+ addProfileDependency(ProfileFacade.getManager().lookForRegisteredProfile(profile));
}
}
}
}
-
+
+ // load fig nodes
+ Collection allStereotypes = Model.getExtensionMechanismsHelper().getStereotypes(
+ profilePackages);
+ for (Object stereotype : allStereotypes) {
+ Collection tags = Model.getFacade().getTaggedValuesCollection(stereotype);
+
+ for (Object tag : tags) {
+ if (Model.getFacade().getTag(tag).toLowerCase()
+ .equals("figure")) {
+ LOG.debug("AddFigNode " + Model.getFacade().getName(stereotype));
+
+ String value = Model.getFacade().getValueOfTag(tag);
+ File f = new File(value);
+ FigNodeDescriptor fnd = null;
+ try {
+ fnd = loadImage(Model.getFacade().getName(stereotype)
+ .toString(), f);
+ figNodeStrategy.addDesrciptor(fnd);
+ } catch (IOException e) {
+ LOG.error("Error loading FigNode", e);
+ }
+ }
+ }
+ }
+
+ // load critiques
+ Vector<CrUML> allCritiques = getAllCritiquesInModel();
+
+ for (CrUML critique : allCritiques) {
+ this.critics.add(critique);
+ }
}
- private Profile lookForRegisteredProfile(String name) {
- ProfileManager man = ProfileFacade.getManager();
- List<Profile> regs = man.getRegisteredProfiles();
+ private CrUML generateCriticFromComment(Object critique) {
+ String ocl = ""+Model.getFacade().getBody(critique);
+ String headline = null;
+
+ Collection tags = Model.getFacade().getTaggedValuesCollection(critique);
- for (Profile profile : regs) {
- if (profile.getDisplayName().equalsIgnoreCase(name)) {
- return profile;
+ for (Object tag : tags) {
+ if (Model.getFacade().getTag(tag).toLowerCase()
+ .equals("headline")) {
+ headline = Model.getFacade().getValueOfTag(tag);
}
}
- return null;
+
+ LOG.debug("OCL-Critic: "+ocl);
+
+ if (headline == null) {
+ return new CrOCL(ocl);
+ } else {
+ return new CrOCL(ocl, headline);
+ }
}
-
- /**
- * @return the string that should represent this profile in the GUI. An
- * start (*) is placed on it if it comes from the currently opened
- * zargo file.
+ @SuppressWarnings("unchecked")
+ private Vector<CrUML> getAllCritiquesInModel() {
+ Vector<CrUML> ret = new Vector();
+
+ Collection comments = getAllCommentsInModel(profilePackages);
+
+ for (Object comment : comments) {
+ if (Model.getExtensionMechanismsHelper().hasStereotype(comment,
+ "Critic")) {
+ CrUML cr = generateCriticFromComment(comment);
+ if (cr!= null) {
+ ret.add(cr);
+ }
+ }
+ }
+ return ret;
+ }
+
+ @SuppressWarnings("unchecked")
+ private Collection getAllCommentsInModel(Collection objs) {
+ Collection col = new Vector<Object>();
+ for (Object obj : objs) {
+ if (Model.getFacade().isAComment(obj)) {
+ col.add(obj);
+ } else if (Model.getFacade().isANamespace(obj)) {
+ Collection contents = Model.getModelManagementHelper()
+ .getAllContents(obj);
+ if (contents != null) {
+ col.addAll(contents);
+ }
+ }
+ }
+ return col;
+ }
+
+
+ /**
+ * @return the string that should represent this profile in the GUI.
*/
public String getDisplayName() {
- return displayName + (fromZargo ? "*" : "");
+ return displayName;
}
-
/**
- * Returns null. This profile has no formatting strategy.
+ * Returns null. This profile has no formatting strategy.
+ *
* @return null.
*/
@Override
@@ -179,12 +320,13 @@
}
/**
- * Returns null. This profile has no figure strategy.
+ * Returns null. This profile has no figure strategy.
+ *
* @return null.
*/
@Override
public FigNodeStrategy getFigureStrategy() {
- return null;
+ return figNodeStrategy;
}
/**
@@ -199,13 +341,34 @@
*/
@Override
public String toString() {
- // TODO: I18N
- return super.toString() + " [" + getModelFile() + "]";
+ File str = getModelFile();
+ return super.toString() + (str !=null ? " [" + str + "]" : "");
}
-
@Override
public Collection getProfilePackages() {
return profilePackages;
}
+
+ private FigNodeDescriptor loadImage(String stereotype, File f)
+ throws IOException {
+ FigNodeDescriptor descriptor = new FigNodeDescriptor();
+ descriptor.length = (int) f.length();
+ descriptor.src = f.getPath();
+ descriptor.stereotype = stereotype;
+
+ BufferedInputStream bis = new BufferedInputStream(
+ new FileInputStream(f));
+
+ byte[] buf = new byte[descriptor.length];
+ try {
+ bis.read(buf);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ descriptor.img = new ImageIcon(buf).getImage();
+
+ return descriptor;
+ }
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/init/InitProfileSubsystem.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/init/InitProfileSubsystem.java?view=diff&rev=15246&p1=/trunk/src/argouml-app/src/org/argouml/profile/init/InitProfileSubsystem.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/init/InitProfileSubsystem.java&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/profile/init/InitProfileSubsystem.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/init/InitProfileSubsystem.java 2008-07-13 00:55:57-0700
@@ -25,6 +25,9 @@
package org.argouml.profile.init;
import org.argouml.profile.ProfileFacade;
+import org.argouml.profile.internal.ui.ProfilePropPanelFactory;
+import org.argouml.uml.ui.PropPanelFactory;
+import org.argouml.uml.ui.PropPanelFactoryManager;
/**
* Initializer class for the Profile subsystem.
@@ -39,6 +42,10 @@
public void init() {
ProfileFacade.setManager(
new org.argouml.profile.internal.ProfileManagerImpl());
+
+ /* Set up the property panels for critics: */
+ PropPanelFactory factory = new ProfilePropPanelFactory();
+ PropPanelFactoryManager.addPropPanelFactory(factory);
}
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java?view=diff&rev=15246&p1=/trunk/src/argouml-app/src/org/argouml/profile/internal/ProfileManagerImpl.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/profile/internal/ProfileManagerImpl.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java 2008-07-13 00:55:57-0700
@@ -31,6 +31,7 @@
import java.util.StringTokenizer;
import org.apache.log4j.Logger;
+import org.argouml.cognitive.Agency;
import org.argouml.configuration.Configuration;
import org.argouml.configuration.ConfigurationKey;
import org.argouml.model.Model;
@@ -39,6 +40,7 @@
import org.argouml.profile.ProfileException;
import org.argouml.profile.ProfileManager;
import org.argouml.profile.UserDefinedProfile;
+import org.argouml.uml.cognitive.critics.CrUML;
/**
* Default <code>ProfileManager</code> implementation
@@ -181,6 +183,14 @@
|| getProfileForClass(p.getClass().getName()) == null) {
profiles.add(p);
+ for (CrUML critic : p.getCritics()) {
+ for (Object meta : critic.getCriticizedMetatypes()) {
+ Agency.register(critic, meta);
+ }
+
+ critic.setEnabled(false);
+ }
+
// this profile could have not been loaded when
// the default profile configuration
// was loaded at first, so we need to do it again
@@ -322,4 +332,18 @@
return p;
}
+ /**
+ * @see org.argouml.profile.ProfileManager#lookForRegisteredProfile(java.lang.String)
+ */
+ public Profile lookForRegisteredProfile(String value) {
+ List<Profile> registeredProfiles = getRegisteredProfiles();
+
+ for (Profile profile : registeredProfiles) {
+ if (profile.getDisplayName().equalsIgnoreCase(value)) {
+ return profile;
+ }
+ }
+ return null;
+ }
+
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/profiles/uml14/metaprofile.xmi
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/profiles/uml14/metaprofile.xmi?view=diff&rev=15246&p1=/trunk/src/argouml-app/src/org/argouml/profile/profiles/uml14/metaprofile.xmi&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/profiles/uml14/metaprofile.xmi&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/profile/profiles/uml14/metaprofile.xmi (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/profiles/uml14/metaprofile.xmi 2008-07-13 00:55:57-0700
@@ -1,8 +1,8 @@
<?xml version = '1.0' encoding = 'UTF-8' ?>
-<XMI xmi.version = '1.2' xmlns:UML = 'org.omg.xmi.namespace.UML' timestamp = 'Sun May 25 10:34:59 CEST 2008'>
+<XMI xmi.version = '1.2' xmlns:UML = 'org.omg.xmi.namespace.UML' timestamp = 'Thu Jun 19 21:01:27 CEST 2008'>
<XMI.header> <XMI.documentation>
<XMI.exporter>ArgoUML (using Netbeans XMI Writer version 1.0)</XMI.exporter>
- <XMI.exporterVersion>PRE-0.25.5(6) revised on $Date: 2007-05-12 08:08:08 +0200 (sam., 12 mai 2007) $ </XMI.exporterVersion>
+ <XMI.exporterVersion>PRE-0.25.6(6) revised on $Date: 2007-05-12 08:08:08 +0200 (sam., 12 mai 2007) $ </XMI.exporterVersion>
</XMI.documentation>
<XMI.metamodel xmi.name="UML" xmi.version="1.4"/></XMI.header>
<XMI.content>
@@ -20,9 +20,9 @@
<UML:TagDefinition xmi.id = '127-0-1-1--3790810c:11a1f2b16a5:-8000:00000000000007C8'
name = 'Dependency' visibility = 'public' isSpecification = 'false'>
<UML:TagDefinition.multiplicity>
- <UML:Multiplicity xmi.id = '127-0-1-1--3790810c:11a1f2b16a5:-8000:00000000000007D7'>
+ <UML:Multiplicity xmi.id = '127-0-1-1--231af496:11aa229b828:-8000:0000000000000898'>
<UML:Multiplicity.range>
- <UML:MultiplicityRange xmi.id = '127-0-1-1--3790810c:11a1f2b16a5:-8000:00000000000007D6'
+ <UML:MultiplicityRange xmi.id = '127-0-1-1--231af496:11aa229b828:-8000:0000000000000897'
lower = '0' upper = '-1'/>
</UML:Multiplicity.range>
</UML:Multiplicity>
@@ -39,6 +39,33 @@
</UML:Multiplicity>
</UML:TagDefinition.multiplicity>
</UML:TagDefinition>
+ <UML:Stereotype xmi.id = '127-0-1-1--259518d7:11a5dd26371:-8000:00000000000008DF'
+ name = 'Critic' isSpecification = 'false' isRoot = 'false' isLeaf = 'false'
+ isAbstract = 'false'>
+ <UML:Stereotype.baseClass>Comment</UML:Stereotype.baseClass>
+ </UML:Stereotype>
+ <UML:TagDefinition xmi.id = '127-0-1-1--231af496:11aa229b828:-8000:0000000000000899'
+ name = 'Description' isSpecification = 'false'>
+ <UML:TagDefinition.multiplicity>
+ <UML:Multiplicity xmi.id = '127-0-1-1--231af496:11aa229b828:-8000:000000000000089A'>
+ <UML:Multiplicity.range>
+ <UML:MultiplicityRange xmi.id = '127-0-1-1--231af496:11aa229b828:-8000:000000000000089B'
+ lower = '0' upper = '1'/>
+ </UML:Multiplicity.range>
+ </UML:Multiplicity>
+ </UML:TagDefinition.multiplicity>
+ </UML:TagDefinition>
+ <UML:TagDefinition xmi.id = '127-0-1-1--231af496:11aa229b828:-8000:000000000000089C'
+ name = 'Headline' isSpecification = 'false'>
+ <UML:TagDefinition.multiplicity>
+ <UML:Multiplicity xmi.id = '127-0-1-1--231af496:11aa229b828:-8000:000000000000089D'>
+ <UML:Multiplicity.range>
+ <UML:MultiplicityRange xmi.id = '127-0-1-1--231af496:11aa229b828:-8000:000000000000089E'
+ lower = '0' upper = '1'/>
+ </UML:Multiplicity.range>
+ </UML:Multiplicity>
+ </UML:TagDefinition.multiplicity>
+ </UML:TagDefinition>
</UML:Namespace.ownedElement>
</UML:Model>
</XMI.content>
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/ProjectSettingsDialog.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/ProjectSettingsDialog.java?view=diff&rev=15246&p1=/trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsDialog.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/ProjectSettingsDialog.java&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsDialog.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/ProjectSettingsDialog.java 2008-07-13 00:55:57-0700
@@ -46,7 +46,7 @@
*
* @author michiel
*/
-class ProjectSettingsDialog extends ArgoDialog implements WindowListener {
+public class ProjectSettingsDialog extends ArgoDialog implements WindowListener {
private JButton applyButton;
private JButton resetToDefaultButton;
@@ -248,4 +248,17 @@
handleCancel();
}
+ /**
+ * Show the dialog with the tab as selected
+ * @param profilesTab tab to be selected
+ */
+ public void showDialog(ProjectSettingsTabProfile profilesTab) {
+ try {
+ tabs.setSelectedComponent(profilesTab);
+ } catch(Throwable t) {
+
+ }
+ showDialog();
+ }
+
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/ExplorerPopup.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/ExplorerPopup.java?view=diff&rev=15246&p1=/trunk/src/argouml-app/src/org/argouml/ui/explorer/ExplorerPopup.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/ExplorerPopup.java&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/ui/explorer/ExplorerPopup.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/ExplorerPopup.java 2008-07-13 00:55:57-0700
@@ -51,6 +51,7 @@
import org.argouml.ui.ActionCreateContainedModelElement;
import org.argouml.ui.ActionCreateEdgeModelElement;
import org.argouml.ui.targetmanager.TargetManager;
+import org.argouml.uml.cognitive.critics.CrUML;
import org.argouml.uml.diagram.ArgoDiagram;
import org.argouml.uml.diagram.activity.ui.UMLActivityDiagram;
import org.argouml.uml.diagram.sequence.ui.UMLSequenceDiagram;
@@ -192,7 +193,11 @@
if (!multiSelect && selectedItem instanceof Profile) {
this.add(new ActionExportProfileXMI((Profile) selectedItem));
}
-
+
+ if (!multiSelect && selectedItem instanceof ProfileConfiguration) {
+ this.add(new ActionManageProfiles());
+ }
+
if (modelElementsOnly) {
initMenuCreateModelElements();
}
@@ -759,7 +764,8 @@
Object selectedItem) {
boolean found = selectedItem instanceof ProfileConfiguration
|| selectedItem instanceof Profile
- || selectedItem instanceof ArgoDiagram;
+ || selectedItem instanceof ArgoDiagram
+ || selectedItem instanceof CrUML;
/* The next statement fixes an exception
* when right-clicking on e.g. an AssociationsNode
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/PerspectiveManager.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/PerspectiveManager.java?view=diff&rev=15246&p1=/trunk/src/argouml-app/src/org/argouml/ui/explorer/PerspectiveManager.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/PerspectiveManager.java&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/ui/explorer/PerspectiveManager.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/PerspectiveManager.java 2008-07-13 00:55:57-0700
@@ -332,6 +332,7 @@
classPerspective.addRule(new GoProjectToProfileConfiguration());
classPerspective.addRule(new GoProfileConfigurationToProfile());
classPerspective.addRule(new GoProfileToModel());
+ classPerspective.addRule(new GoProfileToCritics());
classPerspective.addRule(new GoProjectToRoots());
classPerspective.addRule(new GoNamespaceToClassifierAndPackage());
classPerspective.addRule(new GoNamespaceToDiagram());
@@ -350,6 +351,7 @@
packagePerspective.addRule(new GoProjectToProfileConfiguration());
packagePerspective.addRule(new GoProfileConfigurationToProfile());
packagePerspective.addRule(new GoProfileToModel());
+ packagePerspective.addRule(new GoProfileToCritics());
packagePerspective.addRule(new GoProjectToRoots());
packagePerspective.addRule(new GoNamespaceToOwnedElements());
packagePerspective.addRule(new GoPackageToElementImport());
@@ -398,6 +400,7 @@
diagramPerspective.addRule(new GoProjectToProfileConfiguration());
diagramPerspective.addRule(new GoProfileConfigurationToProfile());
diagramPerspective.addRule(new GoProfileToModel());
+ diagramPerspective.addRule(new GoProfileToCritics());
diagramPerspective.addRule(new GoModelToDiagrams());
diagramPerspective.addRule(new GoDiagramToNode());
diagramPerspective.addRule(new GoDiagramToEdge());
@@ -412,6 +415,7 @@
inheritancePerspective.addRule(new GoProjectToProfileConfiguration());
classPerspective.addRule(new GoProfileConfigurationToProfile());
classPerspective.addRule(new GoProfileToModel());
+ classPerspective.addRule(new GoProfileToCritics());
inheritancePerspective.addRule(new GoModelToBaseElements());
inheritancePerspective
.addRule(new GoGeneralizableElementToSpecialized());
@@ -423,6 +427,7 @@
associationsPerspective.addRule(new GoProjectToProfileConfiguration());
associationsPerspective.addRule(new GoProfileConfigurationToProfile());
associationsPerspective.addRule(new GoProfileToModel());
+ associationsPerspective.addRule(new GoProfileToCritics());
associationsPerspective.addRule(new GoNamespaceToDiagram());
associationsPerspective.addRule(new GoPackageToClass());
associationsPerspective.addRule(new GoClassToAssociatedClass());
@@ -434,6 +439,7 @@
residencePerspective.addRule(new GoProjectToProfileConfiguration());
residencePerspective.addRule(new GoProfileConfigurationToProfile());
residencePerspective.addRule(new GoProfileToModel());
+ residencePerspective.addRule(new GoProfileToCritics());
residencePerspective.addRule(new GoModelToNode());
residencePerspective.addRule(new GoNodeToResidentComponent());
residencePerspective.addRule(new GoComponentToResidentModelElement());
@@ -468,6 +474,7 @@
compositionPerspective.addRule(new GoProjectToProfileConfiguration());
compositionPerspective.addRule(new GoProfileConfigurationToProfile());
compositionPerspective.addRule(new GoProfileToModel());
+ compositionPerspective.addRule(new GoProfileToCritics());
compositionPerspective.addRule(new GoProjectToRoots());
compositionPerspective.addRule(new GoModelElementToContents());
compositionPerspective.addRule(new GoModelElementToContainedDiagrams());
@@ -533,6 +540,7 @@
new GoProjectToProfileConfiguration(),
new GoProfileConfigurationToProfile(),
new GoProfileToModel(),
+ new GoProfileToCritics(),
new GoProjectToRoots(),
new GoSignalToReception(), new GoStateMachineToTop(),
new GoStatemachineToDiagram(), new GoStateMachineToState(),
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/rules/GoProfileToModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/rules/GoProfileToModel.java?view=diff&rev=15246&p1=/trunk/src/argouml-app/src/org/argouml/ui/explorer/rules/GoProfileToModel.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/rules/GoProfileToModel.java&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/ui/explorer/rules/GoProfileToModel.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/rules/GoProfileToModel.java 2008-07-13 00:55:57-0700
@@ -33,7 +33,7 @@
import org.argouml.profile.ProfileException;
/**
- * Rule for Project->Profile.
+ * Rule for Profile->Model.
*
*/
public class GoProfileToModel extends AbstractPerspectiveRule {
@@ -51,7 +51,8 @@
public Collection getChildren(Object parent) {
if (parent instanceof Profile) {
try {
- return ((Profile) parent).getProfilePackages();
+ Collection col = ((Profile) parent).getProfilePackages();
+ return col;
} catch (ProfileException e) {
return Collections.EMPTY_SET;
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/cognitive/critics/CrAttrNameConflict.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/cognitive/critics/CrAttrNameConflict.java?view=diff&rev=15246&p1=/trunk/src/argouml-app/src/org/argouml/uml/cognitive/critics/CrAttrNameConflict.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/cognitive/critics/CrAttrNameConflict.java&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/uml/cognitive/critics/CrAttrNameConflict.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/cognitive/critics/CrAttrNameConflict.java 2008-07-13 00:55:57-0700
@@ -26,7 +26,9 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.Set;
import javax.swing.Icon;
@@ -104,5 +106,14 @@
return ClAttributeCompartment.getTheInstance();
}
+ /**
+ * @see org.argouml.uml.cognitive.critics.CrUML#getCriticizedMetatypes()
+ */
+ public Set<Object> getCriticizedMetatypes() {
+ Set<Object> ret = new HashSet<Object>();
+ ret.add(Model.getMetaTypes().getClassifier());
+ return ret;
+ }
+
}
Removed: /trunk/src/argouml-app/src/org/argouml/uml/cognitive/critics/CrProfile.java
Url: http://argouml.tigris.org/source/browse/argouml//trunk/src/argouml-app/src/org/argouml/uml/cognitive/critics/CrProfile.java?view=auto&rev=15245
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/cognitive/critics/CrUML.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/cognitive/critics/CrUML.java?view=diff&rev=15246&p1=/trunk/src/argouml-app/src/org/argouml/uml/cognitive/critics/CrUML.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/cognitive/critics/CrUML.java&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/uml/cognitive/critics/CrUML.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/cognitive/critics/CrUML.java 2008-07-13 00:55:57-0700
@@ -24,6 +24,9 @@
package org.argouml.uml.cognitive.critics;
+import java.util.HashSet;
+import java.util.Set;
+
import org.apache.log4j.Logger;
import org.argouml.cognitive.Critic;
import org.argouml.cognitive.Designer;
@@ -54,6 +57,13 @@
*/
private static final Logger LOG = Logger.getLogger(CrUML.class);
+ /**
+ * By default looks for the localized strings at the <code>critics</code>
+ * Resource, but critics defined elsewhere (out of ArgoUML main tree)
+ * may override this parameter
+ */
+ private String localizationPrefix = "critics";
+
/**
* The constructor for this class.
*/
@@ -61,6 +71,19 @@
}
/**
+ * The constructor for this class overriding the default
+ * localization resource.
+ *
+ * @param localizationPrefix the overriding localization resource
+ */
+ public CrUML(String localizationPrefix) {
+ if (localizationPrefix != null) {
+ this.localizationPrefix = localizationPrefix;
+ setupHeadAndDesc();
+ }
+ }
+
+ /**
* Set the resources for this critic based on the class name.
*
* @param key is the class name.
@@ -88,7 +111,7 @@
* @return the localized string
*/
protected String getLocalizedString(String key, String suffix) {
- return Translator.localize("critics." + key + suffix);
+ return Translator.localize(localizationPrefix + "." + key + suffix);
}
/**
@@ -118,11 +141,13 @@
* appears in the to-do tab of the details pane).
*
* MVW: Maybe we can make it part of the constructor CrUML()?
+ *
+ * FIXME: why override if nobody uses?
*/
- @Override
- public final void setHeadline(String s) {
- setupHeadAndDesc();
- }
+ //@Override
+ //public final void setHeadline(String s) {
+ //setupHeadAndDesc();
+ //}
/**
* Set up the locale specific text for the critic headline
@@ -242,7 +267,18 @@
return className.substring(className.lastIndexOf('.') + 1);
}
-
+ /**
+ * Get the metatypes to be criticized by this critic, the UML Class
+ * metatype is assumed by default.
+ *
+ * @return the metatypes
+ */
+ public Set<Object> getCriticizedMetatypes() {
+ Set<Object> ret = new HashSet<Object>();
+ ret.add(Model.getMetaTypes().getUMLClass());
+ return ret;
+ }
+
/**
* The UID.
*/
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/cognitive/critics/InitCognitiveCritics.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/cognitive/critics/InitCognitiveCritics.java?view=diff&rev=15246&p1=/trunk/src/argouml-app/src/org/argouml/uml/cognitive/critics/InitCognitiveCritics.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/cognitive/critics/InitCognitiveCritics.java&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/uml/cognitive/critics/InitCognitiveCritics.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/cognitive/critics/InitCognitiveCritics.java 2008-07-13 00:55:57-0700
@@ -269,7 +269,7 @@
* static initializer, register all appropriate critics.
*/
public void init() {
- Object modelCls = Model.getMetaTypes().getModel();
+ /*Object modelCls = Model.getMetaTypes().getModel();
Object packageCls = Model.getMetaTypes().getPackage();
Object classCls = Model.getMetaTypes().getUMLClass();
Object classifierCls = Model.getMetaTypes().getClassifier();
@@ -289,14 +289,14 @@
Object stateVertexCls = Model.getMetaTypes().getStateVertex();
Object stateCls = Model.getMetaTypes().getState();
Object compositieStateCls = Model.getMetaTypes().getCompositeState();
- Object synchStateCls = Model.getMetaTypes().getSynchState();
+ Object synchStateCls = Model.getMetaTypes().getSynchState();*/
// Class stateDiagramCls = UMLStateDiagram.class;
// Class useCaseDiagramCls = UMLUseCaseDiagram.class;
// Class classDiagramCls = UMLClassDiagram.class;
// TODO: Agency should allow registration by interface
// useful for MAssociation.
- Agency.register(crAssocNameConflict, namespaceCls);
+ /*Agency.register(crAssocNameConflict, namespaceCls);
Agency.register(crAttrNameConflict, classifierCls);
Agency.register(crOperNameConflict, classifierCls);
Agency.register(crCircularAssocClass, assocClassCls);
@@ -320,11 +320,11 @@
Agency.register(clsNaming, classCls);
Agency.register(clsNaming, interfaceCls);
Agency.register(clsNaming, actorCls);
- Agency.register(clsNaming, useCaseCls);
+ Agency.register(clsNaming, useCaseCls);*/
// TODO: should be just CrMissingName with a
// customized description
- Agency.register(crMissingClassName, modelCls);
+ /*Agency.register(crMissingClassName, modelCls);
Agency.register(crMissingAttrName, attrCls);
Agency.register(crMissingOperName, operCls);
Agency.register(crMissingStateName, stateVertexCls);
@@ -417,7 +417,7 @@
Agency.register(new CrNameConflict(), namespaceCls);
Agency.register(crAlreadyRealizes, classCls);
Agency.register(new CrUtilityViolated(), classifierCls);
- Agency.register(new CrOppEndVsAttr(), classifierCls);
+ Agency.register(new CrOppEndVsAttr(), classifierCls);*/
}
public List<GUISettingsTabInterface> getProjectSettingsTabs() {
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/diagram/ui/TabDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/diagram/ui/TabDiagram.java?view=diff&rev=15246&p1=/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/TabDiagram.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/diagram/ui/TabDiagram.java&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/TabDiagram.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/diagram/ui/TabDiagram.java 2008-07-13 00:55:57-0700
@@ -44,6 +44,7 @@
import org.apache.log4j.Logger;
import org.argouml.application.api.AbstractArgoJPanel;
import org.argouml.application.api.Argo;
+import org.argouml.cognitive.Critic;
import org.argouml.configuration.Configuration;
import org.argouml.kernel.ProjectManager;
import org.argouml.ui.TabModelTarget;
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/ui/TabProps.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/ui/TabProps.java?view=diff&rev=15246&p1=/trunk/src/argouml-app/src/org/argouml/uml/ui/TabProps.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/ui/TabProps.java&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/src/org/argouml/uml/ui/TabProps.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/uml/ui/TabProps.java 2008-07-13 00:55:57-0700
@@ -33,6 +33,7 @@
import org.apache.log4j.Logger;
import org.argouml.application.api.AbstractArgoJPanel;
+import org.argouml.cognitive.Critic;
import org.argouml.model.Model;
import org.argouml.swingext.UpArrowIcon;
import org.argouml.ui.TabModelTarget;
@@ -171,7 +172,9 @@
target = (target instanceof Fig) ? ((Fig) target).getOwner() : target;
if (!(target == null || Model.getFacade().isAUMLElement(target)
- || target instanceof ArgoDiagram)) {
+ || target instanceof ArgoDiagram
+ // TODO Improve extensibility of this!
+ || target instanceof Critic)) {
return;
}
@@ -269,8 +272,8 @@
: PropPanelFactoryManager.getFactories()) {
propPanel = factory.createPropPanel(targetObject);
if (propPanel != null) return propPanel;
- }
-
+ }
+
/* This does not work (anymore/yet?),
* since we never have a FigText here: */
if (targetObject instanceof FigText) {
@@ -327,7 +330,11 @@
if (target instanceof Fig) {
target = ((Fig) target).getOwner();
}
- return ((target instanceof Diagram || Model.getFacade().isAUMLElement(target))
+
+ // TODO: this should be more extensible... may be only
+ // "findPanelFor(target)" if there is a panel why not show it?
+ return ((target instanceof Diagram || Model.getFacade().isAUMLElement(
+ target)) || target instanceof Critic
&& findPanelFor(target) != null);
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserDefinedProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserDefinedProfile.java?view=diff&rev=15246&p1=/trunk/src/argouml-app/tests/org/argouml/profile/TestUserDefinedProfile.java&p2=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserDefinedProfile.java&r1=15245&r2=15246
==============================================================================
--- /trunk/src/argouml-app/tests/org/argouml/profile/TestUserDefinedProfile.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserDefinedProfile.java 2008-07-13 00:55:57-0700
@@ -25,16 +25,22 @@
package org.argouml.profile;
import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
import junit.framework.TestCase;
import org.argouml.FileHelper;
import org.argouml.model.InitializeModel;
+import org.argouml.profile.internal.ProfileManagerImpl;
+import org.argouml.profile.internal.ocl.CrOCL;
+import org.argouml.uml.cognitive.critics.CrUML;
/**
* Some basic tests for the {@link UserDefinedProfile} class.
*
* @author Luis Sergio Oliveira (euluis)
+ * @authos maurelio1234
*/
public class TestUserDefinedProfile extends TestCase {
@@ -70,4 +76,35 @@
assertTrue(profile.getDisplayName().contains(profileFile.getName()));
}
+ /**
+ * Test the constructor used for loading a profile from a Jar file
+ *
+ * TODO Test FigNode!
+ *
+ * @throws Exception if something goes wrong
+ */
+ public void testLoadingAsFromJar() throws Exception {
+ ProfileManager pm = new ProfileManagerImpl();
+
+ // create profile model
+ ProfileMother profileMother = new ProfileMother();
+ Object model = profileMother.createSimpleProfileModel();
+ // save the profile into a xmi file
+ File profileFile = new File(testDir, "testLoadingConstructor.xmi");
+ profileMother.saveProfileModel(model, profileFile);
+
+ CrOCL critic = new CrOCL("context Class inv: 3 > 2");
+ Set<CrUML> critics = new HashSet<CrUML>();
+ critics.add(critic);
+
+ Set<Profile> profiles = new HashSet<Profile>();
+ profiles.add(pm.getUMLProfile());
+
+ Profile profile = new UserDefinedProfile("displayName", profileFile
+ .toURI().toURL(), critics, profiles);
+
+ assertEquals(profile.getDisplayName(), "displayName");
+ assertTrue(profile.getDependencies().contains(pm.getUMLProfile()));
+ assertTrue(profile.getCritics().contains(critic));
+ }
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.