Author: maurelio1234
Date: 2008-06-11 04:18:05-0700
New Revision: 14899
Removed:
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/uml/cognitive/critics/CrProfile.java
Modified:
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/cognitive/Agency.java
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/kernel/ProfileConfiguration.java
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/moduleloader/ModuleLoader2.java
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/Profile.java
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java
branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/uml/cognitive/critics/CrUML.java
Log:
removing CrProfile
Modified: branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/cognitive/Agency.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/cognitive/Agency.java?view=diff&rev=14899&p1=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/cognitive/Agency.java&p2=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/cognitive/Agency.java&r1=14898&r2=14899
==============================================================================
--- branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/cognitive/Agency.java (original)
+++ branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/cognitive/Agency.java 2008-06-11 04:18:05-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_criticsprofiles_maurelio1234/src/org/argouml/kernel/ProfileConfiguration.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/kernel/ProfileConfiguration.java?view=diff&rev=14899&p1=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/kernel/ProfileConfiguration.java&p2=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/kernel/ProfileConfiguration.java&r1=14898&r2=14899
==============================================================================
--- branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/kernel/ProfileConfiguration.java (original)
+++ branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/kernel/ProfileConfiguration.java 2008-06-11 04:18:05-0700
@@ -46,7 +46,7 @@
import org.argouml.profile.Profile;
import org.argouml.profile.ProfileException;
import org.argouml.profile.ProfileFacade;
-import org.argouml.uml.cognitive.critics.CrProfile;
+import org.argouml.uml.cognitive.critics.CrUML;
/**
* This class captures represents the unique access point for the
@@ -193,7 +193,7 @@
addProfile(dependency);
}
- for (CrProfile critic : p.getCritics()) {
+ for (CrUML critic : p.getCritics()) {
critic.setEnabled(true);
}
@@ -220,7 +220,7 @@
public void removeProfile(Profile p) {
profiles.remove(p);
- for (CrProfile critic : p.getCritics()) {
+ for (CrUML critic : p.getCritics()) {
critic.setEnabled(false);
}
Modified: branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/moduleloader/ModuleLoader2.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/moduleloader/ModuleLoader2.java?view=diff&rev=14899&p1=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/moduleloader/ModuleLoader2.java&p2=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/moduleloader/ModuleLoader2.java&r1=14898&r2=14899
==============================================================================
--- branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/moduleloader/ModuleLoader2.java (original)
+++ branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/moduleloader/ModuleLoader2.java 2008-06-11 04:18:05-0700
@@ -55,7 +55,7 @@
import org.argouml.profile.ProfileException;
import org.argouml.profile.ProfileFacade;
import org.argouml.profile.UserDefinedProfile;
-import org.argouml.uml.cognitive.critics.CrProfile;
+import org.argouml.uml.cognitive.critics.CrUML;
/**
* This is the module loader that loads modules implementing the
@@ -639,7 +639,7 @@
Translator.addClassLoader(classloader);
classLoaderAlreadyLoaded = true;
}
- Set<CrProfile> profiles = loadCritiquesForProfile(attr, classloader);
+ Set<CrUML> profiles = loadCritiquesForProfile(attr, classloader);
String modelPath = attr.getValue("Model");
UserDefinedProfile udp = new UserDefinedProfile(new URL(
@@ -658,27 +658,29 @@
}
}
- private Set<CrProfile> loadCritiquesForProfile(Attributes attr, ClassLoader classloader) {
- Set<CrProfile> ret = new HashSet<CrProfile>();
+ private Set<CrUML> loadCritiquesForProfile(Attributes attr, ClassLoader classloader) {
+ Set<CrUML> ret = new HashSet<CrUML>();
- String value = attr.getValue("Java-Critics");
- StringTokenizer st = new StringTokenizer(value, ",");
+ 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);
- CrProfile critic = (CrProfile) 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);
- }
- }
+ 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;
}
Modified: branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/Profile.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/Profile.java?view=diff&rev=14899&p1=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/Profile.java&p2=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/Profile.java&r1=14898&r2=14899
==============================================================================
--- branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/Profile.java (original)
+++ branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/Profile.java 2008-06-11 04:18:05-0700
@@ -28,7 +28,7 @@
import java.util.HashSet;
import java.util.Set;
-import org.argouml.uml.cognitive.critics.CrProfile;
+import org.argouml.uml.cognitive.critics.CrUML;
/**
@@ -42,7 +42,7 @@
private Set<Profile> importedProfiles = new HashSet<Profile>();
private Set<Profile> importingProfiles = new HashSet<Profile>();
- protected Set<CrProfile> critics = new HashSet<CrProfile>();
+ protected Set<CrUML> critics = new HashSet<CrUML>();
/**
* Add a dependency on the given profile from this profile.
@@ -123,7 +123,7 @@
/**
* @return Returns the critics defined by this profile.
*/
- public Set<CrProfile> getCritics() {
+ public Set<CrUML> getCritics() {
return critics;
}
}
Modified: branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java?view=diff&rev=14899&p1=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java&p2=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java&r1=14898&r2=14899
==============================================================================
--- branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java (original)
+++ branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java 2008-06-11 04:18:05-0700
@@ -44,7 +44,7 @@
import org.apache.log4j.Logger;
import org.argouml.i18n.Translator;
import org.argouml.model.Model;
-import org.argouml.uml.cognitive.critics.CrProfile;
+import org.argouml.uml.cognitive.critics.CrUML;
/**
* Represents a profile defined by the user
@@ -178,7 +178,7 @@
* @param critics the Critics defined by this profile
* @throws ProfileException
*/
- public UserDefinedProfile(URL url, Set<CrProfile> critics) throws ProfileException {
+ public UserDefinedProfile(URL url, Set<CrUML> critics) throws ProfileException {
LOG.info("load " + url);
ProfileReference reference = null;
@@ -258,14 +258,14 @@
Collection allCritiques = getAllCritiques();
for (Object critique : allCritiques) {
- CrProfile c = generateCriticFromModel(critique);
+ CrUML c = generateCriticFromModel(critique);
if (c!=null) {
this.critics.add(c);
}
}
}
- private CrProfile generateCriticFromModel(Object critique) {
+ private CrUML generateCriticFromModel(Object critique) {
// String ocl = Model.getDataTypesHelper().getBody(critique);
return null;
Modified: branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java?view=diff&rev=14899&p1=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java&p2=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java&r1=14898&r2=14899
==============================================================================
--- branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java (original)
+++ branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java 2008-06-11 04:18:05-0700
@@ -40,7 +40,7 @@
import org.argouml.profile.ProfileException;
import org.argouml.profile.ProfileManager;
import org.argouml.profile.UserDefinedProfile;
-import org.argouml.uml.cognitive.critics.CrProfile;
+import org.argouml.uml.cognitive.critics.CrUML;
/**
* Default <code>ProfileManager</code> implementation
@@ -183,8 +183,11 @@
|| getProfileForClass(p.getClass().getName()) == null) {
profiles.add(p);
- for (CrProfile critic : p.getCritics()) {
- Agency.register(critic, critic.getCriticizedMetatype());
+ for (CrUML critic : p.getCritics()) {
+ for (Object meta : critic.getCriticizedMetatypes()) {
+ Agency.register(critic, meta);
+ }
+
critic.setEnabled(false);
}
Removed: branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/uml/cognitive/critics/CrProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/uml/cognitive/critics/CrProfile.java?view=auto&rev=14898
Modified: branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/uml/cognitive/critics/CrUML.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/uml/cognitive/critics/CrUML.java?view=diff&rev=14899&p1=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/uml/cognitive/critics/CrUML.java&p2=branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/uml/cognitive/critics/CrUML.java&r1=14898&r2=14899
==============================================================================
--- branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/uml/cognitive/critics/CrUML.java (original)
+++ branches/gsoc2008/work_criticsprofiles_maurelio1234/src/org/argouml/uml/cognitive/critics/CrUML.java 2008-06-11 04:18:05-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,17 @@
}
/**
+ * The constructor for this class overriding the default
+ * 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 +109,7 @@
* @return the localized string
*/
protected String getLocalizedString(String key, String suffix) {
- return Translator.localize("critics." + key + suffix);
+ return Translator.localize(localizationPrefix + "." + key + suffix);
}
/**
@@ -242,7 +263,16 @@
return className.substring(className.lastIndexOf('.') + 1);
}
-
+ /**
+ * @return the metatype to be criticized by this critic, the Class
+ * metatype is assumed by default.
+ */
+ public Set<Object> getCriticizedMetatypes() {
+ Set<Object> ret = new HashSet<Object>();
+ ret.add(Model.getMetaTypes().getUMLClass());
+ return ret;
+ }
+
/**
* The UID.
*/
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.