Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
PropPanelCritic |
|
| 2.0;2 |
1 | /* $Id: PropPanelCritic.java 18022 2010-02-16 08:24:42Z bobtarling $ | |
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) 2008 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.profile.internal.ui; | |
40 | ||
41 | import java.util.Collection; | |
42 | ||
43 | import javax.swing.ImageIcon; | |
44 | import javax.swing.JLabel; | |
45 | import javax.swing.JTextArea; | |
46 | import javax.swing.JTextField; | |
47 | ||
48 | import org.argouml.cognitive.Critic; | |
49 | import org.argouml.profile.internal.ocl.CrOCL; | |
50 | import org.argouml.uml.ui.PropPanel; | |
51 | ||
52 | /** | |
53 | * PropPanel for Critic | |
54 | * | |
55 | * @author maurelio1234 | |
56 | */ | |
57 | public class PropPanelCritic extends PropPanel { | |
58 | ||
59 | private JTextField criticClass; | |
60 | ||
61 | private JTextField name; | |
62 | ||
63 | private JTextField headline; | |
64 | ||
65 | private JTextField priority; | |
66 | ||
67 | private JTextArea description; | |
68 | ||
69 | private JTextArea ocl; | |
70 | ||
71 | private JLabel oclLabel; | |
72 | ||
73 | private JTextField supportedDecision; | |
74 | ||
75 | private JTextField knowledgeType; | |
76 | ||
77 | /** | |
78 | * Constructor | |
79 | */ | |
80 | public PropPanelCritic(Object target) { | |
81 | 0 | super("", (ImageIcon) null); |
82 | ||
83 | 0 | criticClass = new JTextField(); |
84 | 0 | addField("label.class", criticClass); |
85 | 0 | criticClass.setEditable(false); |
86 | ||
87 | 0 | name = new JTextField(); |
88 | 0 | addField("label.name", name); |
89 | 0 | name.setEditable(false); |
90 | ||
91 | 0 | headline = new JTextField(); |
92 | 0 | addField("label.headline", headline); |
93 | 0 | headline.setEditable(false); |
94 | ||
95 | 0 | description = new JTextArea(5, 30); |
96 | 0 | addField("label.description", description); |
97 | 0 | description.setEditable(false); |
98 | 0 | description.setLineWrap(true); |
99 | ||
100 | 0 | priority = new JTextField(); |
101 | 0 | addField("label.priority", priority); |
102 | 0 | priority.setEditable(false); |
103 | ||
104 | 0 | ocl = new JTextArea(5, 30); |
105 | 0 | oclLabel = addField("label.ocl", ocl); |
106 | 0 | ocl.setEditable(false); |
107 | 0 | ocl.setLineWrap(true); |
108 | ||
109 | 0 | supportedDecision = new JTextField(); |
110 | 0 | addField("label.decision", supportedDecision); |
111 | 0 | supportedDecision.setEditable(false); |
112 | ||
113 | 0 | knowledgeType = new JTextField(); |
114 | 0 | addField("label.knowledge_types", knowledgeType); |
115 | 0 | knowledgeType.setEditable(false); |
116 | ||
117 | 0 | setCritic((Critic) target); |
118 | 0 | } |
119 | ||
120 | /** | |
121 | * @param t the target | |
122 | * @see org.argouml.uml.ui.PropPanel#setTarget(java.lang.Object) | |
123 | */ | |
124 | private void setCritic(Critic c) { | |
125 | 0 | final String targetType = |
126 | c.getClass().getCanonicalName(); | |
127 | ||
128 | 0 | criticClass.setText(targetType); |
129 | ||
130 | 0 | name.setText(c.getCriticName()); |
131 | 0 | headline.setText(c.getHeadline()); |
132 | 0 | description.setText(c.getDescriptionTemplate()); |
133 | 0 | supportedDecision.setText("" + colToString(c.getSupportedDecisions())); |
134 | 0 | if (c instanceof CrOCL) { |
135 | 0 | oclLabel.setVisible(true); |
136 | 0 | ocl.setVisible(true); |
137 | 0 | ocl.setText(((CrOCL) c).getOCL()); |
138 | } else { | |
139 | 0 | oclLabel.setVisible(false); |
140 | 0 | ocl.setVisible(false); |
141 | } | |
142 | ||
143 | 0 | priority.setText("" + c.getPriority()); |
144 | 0 | knowledgeType.setText("" + colToString(c.getKnowledgeTypes())); |
145 | 0 | } |
146 | ||
147 | private String colToString(Collection set) { | |
148 | 0 | String r = ""; |
149 | 0 | int count = 0; |
150 | 0 | for (Object obj : set) { |
151 | 0 | if (count > 0) { |
152 | 0 | r += ", "; |
153 | } | |
154 | 0 | r += obj; |
155 | 0 | ++count; |
156 | } | |
157 | 0 | return r; |
158 | } | |
159 | } |