Coverage Report - org.argouml.uml.diagram.ui.FigEnumLiteralsCompartment
 
Classes in this File Line Coverage Branch Coverage Complexity
FigEnumLiteralsCompartment
0%
0/12
N/A
1
 
 1  
 /* $Id: FigEnumLiteralsCompartment.java 17730 2010-01-03 12:52:27Z bobtarling $
 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  
  *    Tom Morris
 11  
  *    Bob Tarling
 12  
  *******************************************************************************
 13  
  *
 14  
  * Some portions of this file was previously release using the BSD License:
 15  
  */
 16  
 // $Id: FigEnumLiteralsCompartment.java 17730 2010-01-03 12:52:27Z bobtarling $
 17  
 // Copyright (c) 1996-2009 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.uml.diagram.ui;
 41  
 
 42  
 import java.awt.Rectangle;
 43  
 import java.util.Collection;
 44  
 
 45  
 import org.argouml.model.Model;
 46  
 import org.argouml.notation.NotationProviderFactory2;
 47  
 import org.argouml.ui.targetmanager.TargetManager;
 48  
 import org.argouml.uml.diagram.DiagramSettings;
 49  
 import org.argouml.uml.diagram.static_structure.ui.FigEnumerationLiteral;
 50  
 
 51  
 /**
 52  
  * The Fig for the compartment of an Enumeration 
 53  
  * that shows a list of enumeration literals.
 54  
  * 
 55  
  * @author Tom Morris
 56  
  */
 57  
 public class FigEnumLiteralsCompartment extends FigCompartment {
 58  
     /**
 59  
      * Serial version for initial implementation.
 60  
      */
 61  
     private static final long serialVersionUID = 829674049363538379L;
 62  
 
 63  
     /**
 64  
      * Constructor.
 65  
      * 
 66  
      * @param owner owning UML element
 67  
      * @param bounds bounding rectangle
 68  
      * @param settings render settings
 69  
      */
 70  
     public FigEnumLiteralsCompartment(Object owner, Rectangle bounds, 
 71  
             DiagramSettings settings) {
 72  0
         super(owner, bounds, settings);
 73  0
         super.populate();
 74  
         
 75  
         // TODO: We don't really want this to be filled, but if it's not then
 76  
         // the user can't double click in the compartment to add a new literal
 77  
         // Apparently GEF thinks unfilled figs are only selectable by border
 78  
 //        setFilled(false);
 79  0
     }
 80  
     
 81  
     /*
 82  
      * @see org.argouml.uml.diagram.ui.FigEditableCompartment#getUmlCollection()
 83  
      */
 84  
     protected Collection getUmlCollection() {
 85  0
         return Model.getFacade().getEnumerationLiterals(getOwner());
 86  
     }
 87  
 
 88  
     /*
 89  
      * @see org.argouml.uml.diagram.ui.FigEditableCompartment#getNotationType()
 90  
      */
 91  
     protected int getNotationType() {
 92  
         /* The EnumerationLiteral uses a dedicated notation that supports 
 93  
          * parsing "name1;name2;name3" and stereotypes. 
 94  
          * Also supports deleting a literal by erasing text. */
 95  0
         return NotationProviderFactory2.TYPE_ENUMERATION_LITERAL;
 96  
     }
 97  
 
 98  
     /**
 99  
      * @see org.argouml.uml.diagram.ui.FigCompartment#createModelElement()
 100  
      */
 101  
     protected void createModelElement() {
 102  0
         Object enumeration = getGroup().getOwner();
 103  0
         Object literal = Model.getCoreFactory().buildEnumerationLiteral(
 104  
                 "literal",  enumeration);
 105  0
         TargetManager.getInstance().setTarget(literal);
 106  0
     }
 107  
 
 108  
     @Override
 109  
     protected FigSingleLineTextWithNotation createFigText(Object owner,
 110  
             Rectangle bounds, DiagramSettings settings) {
 111  0
         return new FigEnumerationLiteral(owner, bounds, settings);
 112  
     }
 113  
 
 114  
     @Override
 115  
     public String getName() {
 116  
         /* TODO: The UML does not seem to define this name. Or is it? */
 117  0
         return "enumeration literals";
 118  
     }
 119  
     
 120  
     /**
 121  
      * Returns the meta type for Enumeration-Literal to indicate the type of
 122  
      * model element within this compartment.
 123  
      * @return a model element type
 124  
      */
 125  
     public Object getCompartmentType() {
 126  0
         return Model.getMetaTypes().getEnumerationLiteral();
 127  
     }
 128  
 }