Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
StylePanelFigUseCase |
|
| 1.6666666666666667;1.667 |
1 | /* $Id: StylePanelFigUseCase.java 17867 2010-01-12 20:47:04Z 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 | * mvw | |
11 | ***************************************************************************** | |
12 | * | |
13 | * Some portions of this file was previously release using the BSD License: | |
14 | */ | |
15 | ||
16 | // Copyright (c) 1996-2009 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.use_case.ui; | |
40 | ||
41 | import java.awt.event.ItemEvent; | |
42 | ||
43 | import javax.swing.JCheckBox; | |
44 | ||
45 | import org.argouml.ui.StylePanelFigNodeModelElement; | |
46 | import org.argouml.i18n.Translator; | |
47 | ||
48 | /** | |
49 | * A class to provide a style panel for use cases.<p> | |
50 | * | |
51 | * This adds a check box to control the display of he extension point | |
52 | * compartment. | |
53 | * | |
54 | * @author Jeremy Bennett | |
55 | */ | |
56 | public class StylePanelFigUseCase extends StylePanelFigNodeModelElement { | |
57 | ||
58 | /** | |
59 | * The check box for toggling the visibility of extension points. | |
60 | */ | |
61 | 0 | private JCheckBox epCheckBox = |
62 | new JCheckBox(Translator.localize("checkbox.extension-points")); | |
63 | ||
64 | /** | |
65 | * Flag to indicate that a refresh is going on. | |
66 | */ | |
67 | 0 | private boolean refreshTransaction = false; |
68 | ||
69 | /** | |
70 | * Build a style panel. Just layout the relevant boxes. | |
71 | */ | |
72 | public StylePanelFigUseCase() { | |
73 | // Invoke the parent constructor first | |
74 | 0 | super(); |
75 | ||
76 | 0 | addToDisplayPane(epCheckBox); |
77 | // By default we don't show the attribute check box. Mark this object | |
78 | // as a listener for the check box. | |
79 | 0 | epCheckBox.setSelected(false); |
80 | 0 | epCheckBox.addItemListener(this); |
81 | 0 | } |
82 | ||
83 | /** | |
84 | * Refresh the display. This means setting the check box from the target use | |
85 | * case fig. | |
86 | * | |
87 | * @see org.argouml.ui.TabTarget#refresh() | |
88 | */ | |
89 | public void refresh() { | |
90 | ||
91 | 0 | refreshTransaction = true; |
92 | ||
93 | // Invoke the parent refresh first | |
94 | ||
95 | 0 | super.refresh(); |
96 | ||
97 | 0 | FigUseCase target = (FigUseCase) getTarget(); |
98 | ||
99 | 0 | epCheckBox.setSelected(target.isExtensionPointsVisible()); |
100 | ||
101 | 0 | refreshTransaction = false; |
102 | 0 | } |
103 | ||
104 | /** | |
105 | * Something has changed, check if its the check box.<p> | |
106 | * | |
107 | * @param e The event that triggered us. | |
108 | * | |
109 | * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent) | |
110 | */ | |
111 | public void itemStateChanged(ItemEvent e) { | |
112 | 0 | if (!refreshTransaction) { |
113 | 0 | if (e.getSource() == epCheckBox) { |
114 | 0 | FigUseCase target = (FigUseCase) getTarget(); |
115 | 0 | target.setExtensionPointsVisible(epCheckBox.isSelected()); |
116 | 0 | } else { |
117 | 0 | super.itemStateChanged(e); |
118 | } | |
119 | } | |
120 | 0 | } |
121 | ||
122 | } /* end class StylePanelFigUseCase */ |