svn commit: r19389 - trunk/src/argouml-app/src/org/argouml/ui/explorer/PerspectiveManager.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: bobtarling
Date: 2011-05-10 01:40:57-0700
New Revision: 19389

Modified:
   trunk/src/argouml-app/src/org/argouml/ui/explorer/PerspectiveManager.java

Log:
Not sure why the previous code failed at runtime but this refactor works around the problem.

Modified: trunk/src/argouml-app/src/org/argouml/ui/explorer/PerspectiveManager.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/explorer/PerspectiveManager.java?view=diff&pathrev=19389&r1=19388&r2=19389
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/explorer/PerspectiveManager.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/explorer/PerspectiveManager.java	2011-05-10 01:40:57-0700
@@ -534,7 +534,8 @@
      */
     public void loadRules() {
 
-        PerspectiveRule[] ruleNamesArray = {new GoAssocRoleToMessages(),
+        PerspectiveRule[] ruleNamesArray = {
+            new GoAssocRoleToMessages(),
             new GoBehavioralFeatureToStateDiagram(),
             new GoBehavioralFeatureToStateMachine(),
             new GoClassifierToBehavioralFeature(),
@@ -604,13 +605,26 @@
             // empty for now
         };
 
-        rules = Arrays.asList(ruleNamesArray);
         if (Model.getFacade().getUmlVersion().charAt(0) == '1') {
-            rules.addAll(Arrays.asList(ruleNamesArray14));
+            ruleNamesArray = appendArrays(ruleNamesArray, ruleNamesArray14);
         } else {
-            rules.addAll(Arrays.asList(ruleNamesArray2));
+            ruleNamesArray = appendArrays(ruleNamesArray, ruleNamesArray2);
         }
+        
+        rules = Arrays.asList(ruleNamesArray);
     }
+    
+    private <T> T[] appendArrays(T[] first, T[] second) {
+        if (first.length == 0) {
+            return second;
+        }
+        if (second.length == 0) {
+            return first;
+        }
+        T[] result = Arrays.copyOf(first, first.length + second.length);
+        System.arraycopy(second, 0, result, first.length, second.length);
+        return result;
+    }    
 
     /**
      * Add a rule to the list of rules.

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2733599

To unsubscribe from this discussion, e-mail: [[email protected]].
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.