Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
SelectionActionState |
|
| 1.5384615384615385;1.538 |
1 | /* $Id: SelectionActionState.java 17853 2010-01-12 19:55:46Z linus $ | |
2 | ***************************************************************************** | |
3 | * Copyright (c) 2009 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 | * tfmorris | |
11 | ***************************************************************************** | |
12 | * | |
13 | * Some portions of this file was previously release using the BSD License: | |
14 | */ | |
15 | ||
16 | // Copyright (c) 1996-2007 The Regents of the University of California. All | |
17 | // Rights Reserved. Permission to use, copy, modify, and distribute this | |
18 | // software and its documentation without fee, and without a written | |
19 | // agreement is hereby granted, provided that the above copyright notice | |
20 | // and this paragraph appear in all copies. This software program and | |
21 | // documentation are copyrighted by The Regents of the University of | |
22 | // California. The software program and documentation are supplied "AS | |
23 | // IS", without any accompanying services from The Regents. The Regents | |
24 | // does not warrant that the operation of the program will be | |
25 | // uninterrupted or error-free. The end-user understands that the program | |
26 | // was developed for research purposes and is advised not to rely | |
27 | // exclusively on the program for any reason. IN NO EVENT SHALL THE | |
28 | // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, | |
29 | // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, | |
30 | // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF | |
31 | // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF | |
32 | // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY | |
33 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
34 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE | |
35 | // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF | |
36 | // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, | |
37 | // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | |
38 | ||
39 | package org.argouml.uml.diagram.activity.ui; | |
40 | ||
41 | import javax.swing.Icon; | |
42 | ||
43 | import org.argouml.application.helpers.ResourceLoaderWrapper; | |
44 | import org.argouml.model.Model; | |
45 | import org.argouml.uml.diagram.ui.SelectionNodeClarifiers2; | |
46 | import org.tigris.gef.presentation.Fig; | |
47 | ||
48 | /** | |
49 | * @author jrobbins@ics.uci.edu | |
50 | */ | |
51 | public class SelectionActionState extends SelectionNodeClarifiers2 { | |
52 | ||
53 | 0 | private static Icon trans = |
54 | ResourceLoaderWrapper.lookupIconResource("Transition"); | |
55 | ||
56 | 0 | private static Icon transDown = |
57 | ResourceLoaderWrapper.lookupIconResource("TransitionDown"); | |
58 | ||
59 | 0 | private static Icon icons[] = |
60 | {transDown, | |
61 | transDown, | |
62 | trans, | |
63 | trans, | |
64 | null, | |
65 | }; | |
66 | ||
67 | // TODO: I18N required | |
68 | 0 | private static String instructions[] = |
69 | {"Add an incoming transition", | |
70 | "Add an outgoing transition", | |
71 | "Add an incoming transition", | |
72 | "Add an outgoing transition", | |
73 | null, | |
74 | "Move object(s)", | |
75 | }; | |
76 | ||
77 | 0 | private boolean showIncomingLeft = true; |
78 | ||
79 | 0 | private boolean showIncomingAbove = true; |
80 | ||
81 | 0 | private boolean showOutgoingRight = true; |
82 | ||
83 | 0 | private boolean showOutgoingBelow = true; |
84 | ||
85 | /** | |
86 | * Construct a new SelectionActionState for the given Fig. | |
87 | * | |
88 | * @param f The given Fig. | |
89 | */ | |
90 | public SelectionActionState(Fig f) { | |
91 | 0 | super(f); |
92 | 0 | } |
93 | ||
94 | ||
95 | /** | |
96 | * @param b true if the button is enabled | |
97 | */ | |
98 | public void setOutgoingButtonEnabled(boolean b) { | |
99 | 0 | setOutgoingRightButtonEnabled(b); |
100 | 0 | setOutgoingBelowButtonEnabled(b); |
101 | 0 | } |
102 | ||
103 | /** | |
104 | * @param b true if the button is enabled | |
105 | */ | |
106 | public void setIncomingButtonEnabled(boolean b) { | |
107 | 0 | setIncomingAboveButtonEnabled(b); |
108 | 0 | setIncomingLeftButtonEnabled(b); |
109 | 0 | } |
110 | ||
111 | /** | |
112 | * @param b true if the button is enabled | |
113 | */ | |
114 | public void setIncomingLeftButtonEnabled(boolean b) { | |
115 | 0 | showIncomingLeft = b; |
116 | 0 | } |
117 | ||
118 | /** | |
119 | * @param b true if the button is enabled | |
120 | */ | |
121 | public void setOutgoingRightButtonEnabled(boolean b) { | |
122 | 0 | showOutgoingRight = b; |
123 | 0 | } |
124 | ||
125 | /** | |
126 | * @param b true if the button is enabled | |
127 | */ | |
128 | public void setIncomingAboveButtonEnabled(boolean b) { | |
129 | 0 | showIncomingAbove = b; |
130 | 0 | } |
131 | ||
132 | /** | |
133 | * @param b true if the button is enabled | |
134 | */ | |
135 | public void setOutgoingBelowButtonEnabled(boolean b) { | |
136 | 0 | showOutgoingBelow = b; |
137 | 0 | } |
138 | ||
139 | @Override | |
140 | protected Object getNewNodeType(int index) { | |
141 | 0 | return Model.getMetaTypes().getActionState(); |
142 | } | |
143 | ||
144 | @Override | |
145 | protected Object getNewNode(int arg0) { | |
146 | 0 | return Model.getActivityGraphsFactory().createActionState(); |
147 | } | |
148 | ||
149 | @Override | |
150 | protected Icon[] getIcons() { | |
151 | 0 | Icon[] workingIcons = new Icon[icons.length]; |
152 | 0 | System.arraycopy(icons, 0, workingIcons, 0, icons.length); |
153 | 0 | if (!showOutgoingBelow) { |
154 | 0 | workingIcons[BOTTOM - BASE] = null; |
155 | } | |
156 | 0 | if (!showIncomingAbove) { |
157 | 0 | workingIcons[TOP - BASE] = null; |
158 | } | |
159 | 0 | if (!showIncomingLeft) { |
160 | 0 | workingIcons[LEFT - BASE] = null; |
161 | } | |
162 | 0 | if (!showOutgoingRight) { |
163 | 0 | workingIcons[RIGHT - BASE] = null; |
164 | } | |
165 | 0 | return workingIcons; |
166 | } | |
167 | ||
168 | @Override | |
169 | protected String getInstructions(int index) { | |
170 | 0 | return instructions[index - BASE]; |
171 | } | |
172 | ||
173 | @Override | |
174 | protected Object getNewEdgeType(int index) { | |
175 | 0 | return Model.getMetaTypes().getTransition(); |
176 | } | |
177 | ||
178 | @Override | |
179 | protected boolean isReverseEdge(int index) { | |
180 | 0 | if (index == TOP || index == LEFT ) { |
181 | 0 | return true; |
182 | } | |
183 | 0 | return false; |
184 | } | |
185 | ||
186 | } |