Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
FigOperationsCompartment |
|
| 1.0;1 |
1 | /* $Id: FigOperationsCompartment.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 | * Bob Tarling | |
11 | ******************************************************************************* | |
12 | * | |
13 | * Some portions of this file was previously release using the BSD License: | |
14 | */ | |
15 | ||
16 | // $Id: FigOperationsCompartment.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 | ||
41 | package org.argouml.uml.diagram.ui; | |
42 | ||
43 | import java.awt.Rectangle; | |
44 | import java.util.Collection; | |
45 | ||
46 | import org.argouml.kernel.Project; | |
47 | import org.argouml.model.Model; | |
48 | import org.argouml.notation.NotationProviderFactory2; | |
49 | import org.argouml.ui.targetmanager.TargetManager; | |
50 | import org.argouml.uml.diagram.DiagramSettings; | |
51 | import org.argouml.uml.diagram.static_structure.ui.FigOperation; | |
52 | ||
53 | /** | |
54 | * The compartment that contains Operations and/or Receptions. | |
55 | * | |
56 | * @author Bob Tarling | |
57 | */ | |
58 | public class FigOperationsCompartment extends FigCompartment { | |
59 | ||
60 | /** | |
61 | * Constructor for an Operations compartment. | |
62 | * | |
63 | * @param owner owning UML element | |
64 | * @param bounds position and size | |
65 | * @param settings render settings | |
66 | */ | |
67 | public FigOperationsCompartment(Object owner, Rectangle bounds, | |
68 | DiagramSettings settings) { | |
69 | 0 | super(owner, bounds, settings); |
70 | 0 | super.populate(); |
71 | 0 | } |
72 | ||
73 | /* | |
74 | * @see org.argouml.uml.diagram.ui.FigEditableCompartment#getUmlCollection() | |
75 | */ | |
76 | protected Collection getUmlCollection() { | |
77 | 0 | Object classifier = getOwner(); |
78 | 0 | return Model.getFacade().getOperationsAndReceptions(classifier); |
79 | } | |
80 | ||
81 | /* | |
82 | * @see org.argouml.uml.diagram.ui.FigEditableCompartment#getNotationType() | |
83 | */ | |
84 | protected int getNotationType() { | |
85 | 0 | return NotationProviderFactory2.TYPE_OPERATION; |
86 | } | |
87 | ||
88 | /** | |
89 | * @param owner owning UML element | |
90 | * @param bounds position and size | |
91 | * @param settings render settings | |
92 | * @return a FigSingleLineTextWithNotation which can be used to | |
93 | * display the text. | |
94 | */ | |
95 | @Override | |
96 | protected FigSingleLineTextWithNotation createFigText(Object owner, | |
97 | Rectangle bounds, | |
98 | DiagramSettings settings) { | |
99 | 0 | return new FigOperation(owner, bounds, settings); |
100 | } | |
101 | ||
102 | /* | |
103 | * By default, when double-clicking on the compartment, | |
104 | * we create an Operation (not a Reception). | |
105 | */ | |
106 | protected void createModelElement() { | |
107 | 0 | Object classifier = getGroup().getOwner(); |
108 | 0 | Project project = getProject(); |
109 | ||
110 | 0 | Object returnType = project.getDefaultReturnType(); |
111 | 0 | Object oper = Model.getCoreFactory().buildOperation(classifier, |
112 | returnType); | |
113 | 0 | TargetManager.getInstance().setTarget(oper); |
114 | 0 | } |
115 | ||
116 | @Override | |
117 | public String getName() { | |
118 | 0 | return "operations"; |
119 | } | |
120 | ||
121 | /** | |
122 | * Returns the meta type for Operation to indicate the type of model | |
123 | * element within this compartment. | |
124 | * @return a model element type | |
125 | */ | |
126 | public Object getCompartmentType() { | |
127 | 0 | return Model.getMetaTypes().getOperation(); |
128 | } | |
129 | } |