Coverage Report - org.argouml.notation.providers.NotationUtilityProviders
 
Classes in this File Line Coverage Branch Coverage Complexity
NotationUtilityProviders
0%
0/40
0%
0/20
4.333
 
 1  
 /* $Id$
 2  
  *******************************************************************************
 3  
  * Copyright (c) 2010 Contributors - see below
 4  
  * All rights reserved. This program and the accompanying materials
 5  
  * are made available under the terms of the Eclipse Public License v1.0
 6  
  * which accompanies this distribution, and is available at
 7  
  * http://www.eclipse.org/legal/epl-v10.html
 8  
  *
 9  
  * Contributors:
 10  
  *    Michiel van der Wulp
 11  
  *******************************************************************************
 12  
  */
 13  
 
 14  
 package org.argouml.notation.providers;
 15  
 
 16  
 import java.util.Collection;
 17  
 import java.util.Iterator;
 18  
 
 19  
 import org.argouml.model.Model;
 20  
 import org.argouml.notation.NotationProvider;
 21  
 
 22  
 /**
 23  
  * Utility code for the classes in this package.
 24  
  *
 25  
  * @author Michiel van der Wulp
 26  
  */
 27  0
 class NotationUtilityProviders {
 28  
 
 29  
 
 30  
     static void addListenersForTransition(NotationProvider np, 
 31  
             Object transition) {
 32  0
         np.addElementListener(transition, 
 33  
                 new String[] {"guard", "trigger", "effect"});
 34  
 
 35  0
         Object guard = Model.getFacade().getGuard(transition);
 36  0
         if (guard != null) {
 37  0
             np.addElementListener(guard, "expression");
 38  
             /* We are not interested in the name. */
 39  
         }
 40  
 
 41  0
         Object trigger = Model.getFacade().getTrigger(transition);
 42  0
         addListenersForEvent(np, trigger);
 43  
 
 44  0
         Object effect = Model.getFacade().getEffect(transition);
 45  0
         addListenersForAction(np, effect);
 46  0
     }    
 47  
     
 48  
     static private void addListenersForEvent(NotationProvider np, 
 49  
             Object event) {
 50  0
         if (event != null) {
 51  0
             if (Model.getFacade().isAEvent(event)) {
 52  0
                 np.addElementListener(event,
 53  
                         new String[] {
 54  
                             "parameter", "name"});
 55  
             }
 56  0
             if (Model.getFacade().isATimeEvent(event)) {
 57  0
                 np.addElementListener(event, new String[] {"when"});
 58  
             }
 59  0
             if (Model.getFacade().isAChangeEvent(event)) {
 60  0
                 np.addElementListener(event,
 61  
                         new String[] {"changeExpression"});
 62  
             }
 63  
             /* And the parameter names and values: */
 64  0
             Collection prms = Model.getFacade().getParameters(event);
 65  0
             Iterator i = prms.iterator();
 66  0
             while (i.hasNext()) {
 67  0
                 Object parameter = i.next();
 68  0
                 np.addElementListener(parameter, 
 69  
                       new String[] {"defaultValue", "name", "type", "kind"});
 70  0
             }
 71  
         }
 72  0
     }
 73  
     
 74  
     static void addListenersForAction(NotationProvider np, 
 75  
             Object action) {
 76  0
         if (action != null) {
 77  0
             np.addElementListener(action,
 78  
                     new String[] {
 79  
                     "script", "actualArgument", "action"
 80  
             });
 81  
             /* And the arguments: */
 82  0
             Collection args = Model.getFacade().getActualArguments(action);
 83  0
             Iterator i = args.iterator();
 84  0
             while (i.hasNext()) {
 85  0
                 Object argument = i.next();
 86  0
                 np.addElementListener(argument, "value");
 87  0
             }
 88  0
             if (Model.getFacade().isAActionSequence(action)) {
 89  0
                 Collection subactions = Model.getFacade().getActions(action);
 90  0
                 i = subactions.iterator();
 91  0
                 while (i.hasNext()) {
 92  0
                     Object a = i.next();
 93  0
                     addListenersForAction(np, a);
 94  0
                 }
 95  
             }
 96  
         }
 97  0
     }
 98  
 
 99  
 }