svn commit: r15368 - branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile: . profiles/uml14

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: maurelio1234
Date: 2008-07-25 02:51:17-0700
New Revision: 15368

Modified:
   branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java
   branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/profiles/uml14/metaprofile.xmi

Log:
adding i18n for critics defined as ocl in profile xmi

Modified: branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java?view=diff&rev=15368&p1=branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java&p2=branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java&r1=15367&r2=15368
==============================================================================
--- branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java	(original)
+++ branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java	2008-07-25 02:51:17-0700
@@ -265,26 +265,26 @@
         String moreInfoURL = null;
 
         Collection tags = Model.getFacade().getTaggedValuesCollection(critique);
-
+        boolean i18nFound = false;
+        
         for (Object tag : tags) {
-            if (Model.getFacade().getTag(tag).toLowerCase().equals("headline")) {
+            if (Model.getFacade().getTag(tag).toLowerCase().equals("i18n")) {
+                i18nFound = true;
+                String i18nSource = Model.getFacade().getValueOfTag(tag);
+                headline = Translator.localize(i18nSource + "-head");
+                description = Translator.localize(i18nSource + "-desc");
+                moreInfoURL = Translator.localize(i18nSource + "-moreInfoURL");
+            } else if (!i18nFound
+                    && Model.getFacade().getTag(tag).toLowerCase().equals(
+                            "headline")) {
                 headline = Model.getFacade().getValueOfTag(tag);
-            } else if (Model.getFacade().getTag(tag).toLowerCase().equals(
-                    "description")) {
+            } else if (!i18nFound
+                    && Model.getFacade().getTag(tag).toLowerCase().equals(
+                            "description")) {
                 description = Model.getFacade().getValueOfTag(tag);
             } else if (Model.getFacade().getTag(tag).toLowerCase().equals(
                     "priority")) {
-                String prioStr = Model.getFacade().getValueOfTag(tag);
-
-                if (prioStr.toLowerCase().equals("high")) {
-                    priority = ToDoItem.HIGH_PRIORITY;
-                } else if (prioStr.toLowerCase().equals("med")) {
-                    priority = ToDoItem.MED_PRIORITY;
-                } else if (prioStr.toLowerCase().equals("low")) {
-                    priority = ToDoItem.LOW_PRIORITY;
-                } else if (prioStr.toLowerCase().equals("interruptive")) {
-                    priority = ToDoItem.INTERRUPTIVE_PRIORITY;
-                }
+                priority = str2Priority(Model.getFacade().getValueOfTag(tag));
             } else if (Model.getFacade().getTag(tag).toLowerCase().equals(
                     "supporteddecision")) {
                 String decStr = Model.getFacade().getValueOfTag(tag);
@@ -292,40 +292,12 @@
                 StringTokenizer st = new StringTokenizer(decStr, ",;:");
 
                 while (st.hasMoreTokens()) {
-                    String token = st.nextToken().trim().toLowerCase();
-
-                    if (token.equals("behavior"))
-                        supportedDecisions.add(UMLDecision.BEHAVIOR);
-                    if (token.equals("containment"))
-                        supportedDecisions.add(UMLDecision.CONTAINMENT);
-                    if (token.equals("classselection"))
-                        supportedDecisions.add(UMLDecision.CLASS_SELECTION);
-                    if (token.equals("codegen"))
-                        supportedDecisions.add(UMLDecision.CODE_GEN);
-                    if (token.equals("expectedusage"))
-                        supportedDecisions.add(UMLDecision.EXPECTED_USAGE);
-                    if (token.equals("inheritance"))
-                        supportedDecisions.add(UMLDecision.INHERITANCE);
-                    if (token.equals("instantiation"))
-                        supportedDecisions.add(UMLDecision.INSTANCIATION);
-                    if (token.equals("methods"))
-                        supportedDecisions.add(UMLDecision.METHODS);
-                    if (token.equals("modularity"))
-                        supportedDecisions.add(UMLDecision.MODULARITY);
-                    if (token.equals("naming"))
-                        supportedDecisions.add(UMLDecision.NAMING);
-                    if (token.equals("patterns"))
-                        supportedDecisions.add(UMLDecision.PATTERNS);
-                    if (token.equals("plannedextensions"))
-                        supportedDecisions.add(UMLDecision.PLANNED_EXTENSIONS);
-                    if (token.equals("relationships"))
-                        supportedDecisions.add(UMLDecision.RELATIONSHIPS);
-                    if (token.equals("statemachines"))
-                        supportedDecisions.add(UMLDecision.STATE_MACHINES);
-                    if (token.equals("stereotypes"))
-                        supportedDecisions.add(UMLDecision.STEREOTYPES);
-                    if (token.equals("storage"))
-                        supportedDecisions.add(UMLDecision.STORAGE);
+                    Decision decision = str2Decision(st.nextToken().trim()
+                            .toLowerCase());
+                    
+                    if (decision != null) {
+                        supportedDecisions.add(decision);
+                    }
                 }
             } else if (Model.getFacade().getTag(tag).toLowerCase().equals(
                     "knowledgetype")) {
@@ -334,33 +306,16 @@
                 StringTokenizer st = new StringTokenizer(ktStr, ",;:");
 
                 while (st.hasMoreTokens()) {
-                    String token = st.nextToken().trim().toLowerCase();
-
-                    if (token.equals("completeness"))
-                        knowledgeTypes.add(Critic.KT_COMPLETENESS);
-                    if (token.equals("consistency"))
-                        knowledgeTypes.add(Critic.KT_CONSISTENCY);
-                    if (token.equals("correctness"))
-                        knowledgeTypes.add(Critic.KT_CORRECTNESS);
-                    if (token.equals("designers"))
-                        knowledgeTypes.add(Critic.KT_DESIGNERS);
-                    if (token.equals("experiencial"))
-                        knowledgeTypes.add(Critic.KT_EXPERIENCIAL);
-                    if (token.equals("optimization"))
-                        knowledgeTypes.add(Critic.KT_OPTIMIZATION);
-                    if (token.equals("organizational"))
-                        knowledgeTypes.add(Critic.KT_ORGANIZATIONAL);
-                    if (token.equals("presentation"))
-                        knowledgeTypes.add(Critic.KT_PRESENTATION);
-                    if (token.equals("semantics"))
-                        knowledgeTypes.add(Critic.KT_SEMANTICS);
-                    if (token.equals("syntax"))
-                        knowledgeTypes.add(Critic.KT_SYNTAX);
-                    if (token.equals("tool"))
-                        knowledgeTypes.add(Critic.KT_TOOL);
+                    String knowledge = str2KnowledgeType(st.nextToken().trim()
+                            .toLowerCase());
+                    
+                    if (knowledge != null) {
+                        knowledgeTypes.add(knowledge);
+                    }
                 }
-            } else if (Model.getFacade().getTag(tag).toLowerCase().equals(
-                    "moreinfourl")) {
+            } else if (!i18nFound
+                    && Model.getFacade().getTag(tag).toLowerCase().equals(
+                            "moreinfourl")) {
                 moreInfoURL = Model.getFacade().getValueOfTag(tag);
             }
 
@@ -379,11 +334,118 @@
 
     }
 
-    @SuppressWarnings("unchecked")
+    private String str2KnowledgeType(String token) {
+        String knowledge = null;
+        
+        if (token.equals("completeness")) {
+            knowledge = Critic.KT_COMPLETENESS;
+        }
+        if (token.equals("consistency")) {
+            knowledge = Critic.KT_CONSISTENCY;
+        }
+        if (token.equals("correctness")) {
+            knowledge = Critic.KT_CORRECTNESS;
+        }
+        if (token.equals("designers")) {
+            knowledge = Critic.KT_DESIGNERS;
+        }
+        if (token.equals("experiencial")) {
+            knowledge = Critic.KT_EXPERIENCIAL;
+        }
+        if (token.equals("optimization")) {
+            knowledge = Critic.KT_OPTIMIZATION;
+        }
+        if (token.equals("organizational")) {
+            knowledge = Critic.KT_ORGANIZATIONAL;
+        }
+        if (token.equals("presentation")) {
+            knowledge = Critic.KT_PRESENTATION;
+        }
+        if (token.equals("semantics")) {
+            knowledge = Critic.KT_SEMANTICS;
+        }
+        if (token.equals("syntax")) {
+            knowledge = Critic.KT_SYNTAX;
+        }
+        if (token.equals("tool")) {
+            knowledge = Critic.KT_TOOL;
+        }
+        return knowledge;
+    }
+
+    private int str2Priority(String prioStr) {
+        int prio = ToDoItem.MED_PRIORITY;
+        
+        if (prioStr.toLowerCase().equals("high")) {
+            prio = ToDoItem.HIGH_PRIORITY;
+        } else if (prioStr.toLowerCase().equals("med")) {
+            prio = ToDoItem.MED_PRIORITY;
+        } else if (prioStr.toLowerCase().equals("low")) {
+            prio = ToDoItem.LOW_PRIORITY;
+        } else if (prioStr.toLowerCase().equals("interruptive")) {
+            prio = ToDoItem.INTERRUPTIVE_PRIORITY;
+        }
+        return prio;
+    }
+
+    private Decision str2Decision(String token) {
+        Decision decision = null;
+        
+        if (token.equals("behavior")) {
+            decision = UMLDecision.BEHAVIOR;
+        }
+        if (token.equals("containment")) {                        
+            decision = UMLDecision.CONTAINMENT;
+        }
+        if (token.equals("classselection")) {
+            decision = UMLDecision.CLASS_SELECTION;
+        }
+        if (token.equals("codegen")) {
+            decision = UMLDecision.CODE_GEN;
+        }
+        if (token.equals("expectedusage")) {
+            decision = UMLDecision.EXPECTED_USAGE;
+        }
+        if (token.equals("inheritance")) {
+            decision = UMLDecision.INHERITANCE;
+        }
+        if (token.equals("instantiation")) {
+            decision = UMLDecision.INSTANCIATION;
+        }
+        if (token.equals("methods")) {
+            decision = UMLDecision.METHODS;
+        }
+        if (token.equals("modularity")) {
+            decision = UMLDecision.MODULARITY;
+        }
+        if (token.equals("naming")) {                       
+            decision = UMLDecision.NAMING;
+        }
+        if (token.equals("patterns")) {
+            decision = UMLDecision.PATTERNS;
+        }
+        if (token.equals("plannedextensions")) {
+            decision = UMLDecision.PLANNED_EXTENSIONS;
+        }
+        if (token.equals("relationships")) {
+            decision = UMLDecision.RELATIONSHIPS;
+        }
+        if (token.equals("statemachines")) {
+            decision = UMLDecision.STATE_MACHINES;
+        }
+        if (token.equals("stereotypes")) {
+            decision = UMLDecision.STEREOTYPES;
+        }
+        if (token.equals("storage")) {
+            decision = UMLDecision.STORAGE;
+        }
+        return decision;
+    }
+
     private Vector<CrUML> getAllCritiquesInModel() {
-        Vector<CrUML> ret = new Vector();
+        Vector<CrUML> ret = new Vector<CrUML>();
 
-        Collection comments = getAllCommentsInModel(profilePackages);
+        Collection<Object> comments = getAllCommentsInModel(profilePackages);
 
         for (Object comment : comments) {
             if (Model.getExtensionMechanismsHelper().hasStereotype(comment,
@@ -399,14 +461,14 @@
     }
 
     @SuppressWarnings("unchecked")
-    private Collection getAllCommentsInModel(Collection objs) {
-        Collection col = new Vector<Object>();
+    private Collection<Object> getAllCommentsInModel(Collection objs) {
+        Collection<Object> 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);
+                Collection contents = Model
+                        .getModelManagementHelper().getAllContents(obj);
                 if (contents != null) {
                     col.addAll(contents);
                 }

Modified: branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/profiles/uml14/metaprofile.xmi
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/profiles/uml14/metaprofile.xmi?view=diff&rev=15368&p1=branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/profiles/uml14/metaprofile.xmi&p2=branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/profiles/uml14/metaprofile.xmi&r1=15367&r2=15368
==============================================================================
--- branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/profiles/uml14/metaprofile.xmi	(original)
+++ branches/gsoc2008/work_issue5042_maurelio1234/src/org/argouml/profile/profiles/uml14/metaprofile.xmi	2008-07-25 02:51:17-0700
@@ -1,5 +1,5 @@
 <?xml version = '1.0' encoding = 'UTF-8' ?>
-<XMI xmi.version = '1.2' xmlns:UML = 'org.omg.xmi.namespace.UML' timestamp = 'Thu Jul 17 07:16:58 CEST 2008'>
+<XMI xmi.version = '1.2' xmlns:UML = 'org.omg.xmi.namespace.UML' timestamp = 'Fri Jul 25 09:56:02 CEST 2008'>
   <XMI.header>    <XMI.documentation>
       <XMI.exporter>ArgoUML (using Netbeans XMI Writer version 1.0)</XMI.exporter>
       <XMI.exporterVersion>PRE-0.26.beta1(6) revised on $Date: 2007-05-12 08:08:08 +0200 (sam., 12 mai 2007) $ </XMI.exporterVersion>
@@ -7,7 +7,7 @@
     <XMI.metamodel xmi.name="UML" xmi.version="1.4"/></XMI.header>
   <XMI.content>
     <UML:Model xmi.id = '127-0-1-1--3790810c:11a1f2b16a5:-8000:00000000000007BD'
-      name = 'ArgoUMLProfile' isSpecification = 'false' isRoot = 'false' isLeaf = 'false'
+      name = 'metaprofile' isSpecification = 'false' isRoot = 'false' isLeaf = 'false'
       isAbstract = 'false'>
       <UML:ModelElement.stereotype>
         <UML:Stereotype href = 'http://argouml.org/profiles/uml14/default-uml14.xmi#.:0000000000000877'/>
@@ -110,6 +110,17 @@
             </UML:Multiplicity>
           </UML:TagDefinition.multiplicity>
         </UML:TagDefinition>
+        <UML:TagDefinition xmi.id = '127-0-1-1--4d07ba8d:11b593372d3:-8000:00000000000008D7'
+          name = 'i18n' isSpecification = 'false'>
+          <UML:TagDefinition.multiplicity>
+            <UML:Multiplicity xmi.id = '127-0-1-1--4d07ba8d:11b593372d3:-8000:00000000000008DB'>
+              <UML:Multiplicity.range>
+                <UML:MultiplicityRange xmi.id = '127-0-1-1--4d07ba8d:11b593372d3:-8000:00000000000008DA'
+                  lower = '0' upper = '1'/>
+              </UML:Multiplicity.range>
+            </UML:Multiplicity>
+          </UML:TagDefinition.multiplicity>
+        </UML:TagDefinition>
       </UML:Namespace.ownedElement>
     </UML:Model>
   </XMI.content>
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.