Coverage Report - org.argouml.notation.providers.OperationNotation
 
Classes in this File Line Coverage Branch Coverage Complexity
OperationNotation
0%
0/31
0%
0/40
8
 
 1  
 /* $Id: OperationNotation.java 18852 2010-11-20 19:27:11Z mvw $
 2  
  *****************************************************************************
 3  
  * Copyright (c) 2009-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  
  *    thn
 11  
  *    Michiel van der Wulp
 12  
  *****************************************************************************
 13  
  *
 14  
  * Some portions of this file was previously release using the BSD License:
 15  
  */
 16  
 
 17  
 // Copyright (c) 2005-2007 The Regents of the University of California. All
 18  
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 19  
 // software and its documentation without fee, and without a written
 20  
 // agreement is hereby granted, provided that the above copyright notice
 21  
 // and this paragraph appear in all copies.  This software program and
 22  
 // documentation are copyrighted by The Regents of the University of
 23  
 // California. The software program and documentation are supplied "AS
 24  
 // IS", without any accompanying services from The Regents. The Regents
 25  
 // does not warrant that the operation of the program will be
 26  
 // uninterrupted or error-free. The end-user understands that the program
 27  
 // was developed for research purposes and is advised not to rely
 28  
 // exclusively on the program for any reason.  IN NO EVENT SHALL THE
 29  
 // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
 30  
 // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
 31  
 // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
 32  
 // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
 33  
 // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
 34  
 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 35  
 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
 36  
 // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
 37  
 // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
 38  
 // UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 39  
 
 40  
 package org.argouml.notation.providers;
 41  
 
 42  
 import java.beans.PropertyChangeEvent;
 43  
 
 44  
 import org.argouml.model.AddAssociationEvent;
 45  
 import org.argouml.model.Model;
 46  
 import org.argouml.model.RemoveAssociationEvent;
 47  
 import org.argouml.notation.NotationProvider;
 48  
 
 49  
 /**
 50  
  * This abstract class forms the basis of all Notation providers
 51  
  * for the text shown in the operation compartment of a Class.
 52  
  * Subclass this for all languages.
 53  
  *
 54  
  * @author Michiel van der Wulp
 55  
  */
 56  
 public abstract class OperationNotation extends NotationProvider {
 57  
 
 58  
     /**
 59  
      * The constructor.
 60  
      *
 61  
      * @param operation The operation.
 62  
      */
 63  0
     public OperationNotation(Object operation) {
 64  0
         if (!Model.getFacade().isAOperation(operation) 
 65  
                 && !Model.getFacade().isAReception(operation)) {
 66  0
             throw new IllegalArgumentException(
 67  
                     "This is not an Operation or Reception.");
 68  
         }
 69  0
     }
 70  
 
 71  
     @Override
 72  
     public void initialiseListener(Object modelElement) {
 73  0
         addElementListener(modelElement);
 74  0
         if (Model.getFacade().isAOperation(modelElement)) {
 75  
             // We also show stereotypes
 76  0
             for (Object uml : Model.getFacade().getStereotypes(modelElement)) {
 77  0
                 addElementListener(uml);
 78  
             }
 79  
             // We also show parameters
 80  0
             for (Object uml : Model.getFacade().getParameters(modelElement)) {
 81  0
                 addElementListener(uml);
 82  
                 // We also show the type (of which e.g. the name may change)
 83  0
                 Object type = Model.getFacade().getType(uml);
 84  0
                 if (type != null) {
 85  0
                     addElementListener(type);
 86  
                 }
 87  0
             }
 88  
             // We also show tagged values for UML 1
 89  
             // TODO: what to do for UML2 here?
 90  0
             if ( Model.getFacade().getUmlVersion().charAt(0) == '1') {
 91  0
                 for (Object uml : Model.getFacade().getTaggedValuesCollection(
 92  
                         modelElement)) {
 93  0
                     addElementListener(uml);     
 94  
                 }   
 95  
             }
 96  
         }
 97  0
     }
 98  
 
 99  
     @Override
 100  
     public void updateListener(Object modelElement, PropertyChangeEvent pce) {
 101  0
         if (pce.getSource() == modelElement
 102  
                 && ("stereotype".equals(pce.getPropertyName()) 
 103  
                         || "parameter".equals(pce.getPropertyName())
 104  
                         || "taggedValue".equals(pce.getPropertyName()))) {
 105  0
             if (pce instanceof AddAssociationEvent) {
 106  0
                 addElementListener(pce.getNewValue());
 107  
             }
 108  0
             if (pce instanceof RemoveAssociationEvent) {
 109  0
                 removeElementListener(pce.getOldValue());
 110  
             }
 111  
         }
 112  0
         if (!Model.getUmlFactory().isRemoved(modelElement)) {
 113  
             //  We also show types of parameters
 114  0
             for (Object param : Model.getFacade().getParameters(modelElement)) {
 115  0
                 if (pce.getSource() == param
 116  
                         && ("type".equals(pce.getPropertyName()))) {
 117  0
                     if (pce instanceof AddAssociationEvent) {
 118  0
                         addElementListener(pce.getNewValue());
 119  
                     }
 120  0
                     if (pce instanceof RemoveAssociationEvent) {
 121  0
                         removeElementListener(pce.getOldValue());
 122  
                     }
 123  
                 }
 124  
             }
 125  
         }
 126  0
     }
 127  
 
 128  
 }