1 /***
2 *
3 * The owl-s matcher software is subject to the GNU Lesser General
4 * Public License Version 2.1 (the "License"). You may not copy or use this
5 * file, in either source code or executable form, except in compliance
6 * with the License. You may obtain a copy of the License at
7 * http://www.fsf.org/licenses/lgpl.txt or http://www.opensource.org/.
8 *
9 * Software distributed under the License is distributed on an "AS IS"
10 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied without
11 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the License for the specific language governing rights and
13 * limitations under the License.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this distribution; if not, write to the
17 *
18 * Free Software Foundation, Inc.,
19 * 59 Temple Place, Suite 330,
20 * Boston, MA 02111-1307 USA
21 *
22 * Copyright (C) 2003-2004
23 * TU Berlin, FG IVS
24 * Stefan Tang,
25 * Christoph Liebetruth,
26 * Michael C. Jaeger,
27 *
28 * More information available at http://ivs.tu-berlin.de/
29 *
30 * $Id$
31 *
32 */
33 package de.tuberlin.ivs.owl.gui;
34
35 import java.awt.*;
36 import javax.swing.*;
37 import de.tuberlin.ivs.owl.matching.ExtendedMatchingResult;
38 import java.awt.event.*;
39 import java.util.*;
40 import de.tuberlin.ivs.owl.service.Input;
41 import de.tuberlin.ivs.owl.service.Output;
42
43 /***
44 * Displays the detailed matching result of either input or output matching.
45 *
46 * @author Stefan Tang (steftang@stanford.edu), Christoph Liebetruth (christophl@voelcker.com)
47 * @version 1.1
48 */
49 public class ShowParameterResultDialog extends JDialog {
50
51
52
53
54 JPanel panel1 = new JPanel();
55 JPanel jPanel1 = new JPanel();
56 JPanel jPanel2 = new JPanel();
57 JButton closeButton = new JButton();
58 BorderLayout borderLayout1 = new BorderLayout();
59 JPanel jPanel3 = new JPanel();
60 JPanel jPanel4 = new JPanel();
61 GridLayout gridLayout1 = new GridLayout();
62 JPanel jPanel5 = new JPanel();
63 JPanel jPanel6 = new JPanel();
64 JLabel matchedLabel = new JLabel();
65 BorderLayout borderLayout2 = new BorderLayout();
66 JScrollPane jScrollPane1 = new JScrollPane();
67 GridLayout gridLayout2 = new GridLayout();
68 JList matchedList = new JList();
69 GridLayout gridLayout3 = new GridLayout();
70 JPanel jPanel7 = new JPanel();
71 JPanel jPanel8 = new JPanel();
72 JLabel unmatchedLabel = new JLabel();
73 BorderLayout borderLayout3 = new BorderLayout();
74 GridLayout gridLayout4 = new GridLayout();
75 GridLayout gridLayout5 = new GridLayout();
76 JScrollPane jScrollPane2 = new JScrollPane();
77 JList unmatchedList = new JList();
78
79 boolean input = true;
80 ExtendedMatchingResult result;
81
82 /***
83 * Constructor.
84 * @param frame The parent frame of this dialog.
85 * @param title The title of this dialog.
86 * @param modal true if the parent frame should be disabled when this dialog
87 * is displayed, false otherwise.
88 * @param result The extended result that contains all the matching results.
89 * @param input true if the info to be displayed concerns the inputs, false
90 * for displaying the outputs.
91 */
92 public ShowParameterResultDialog(Frame frame, String title, boolean modal, ExtendedMatchingResult result, boolean input) {
93 super(frame, title, modal);
94 this.result = result;
95 this.input = input;
96 try {
97 jbInit();
98 pack();
99 }
100 catch(Exception ex) {
101 ex.printStackTrace();
102 }
103 initializeFields();
104 }
105
106
107 private void jbInit() throws Exception {
108 panel1.setLayout(borderLayout1);
109 closeButton.setText("Close");
110 closeButton.addActionListener(new ShowParameterResultDialog_closeButton_actionAdapter(this));
111 jPanel1.setBorder(BorderFactory.createEtchedBorder());
112 jPanel1.setLayout(gridLayout1);
113 gridLayout1.setRows(2);
114 matchedLabel.setFont(new java.awt.Font("Dialog", 1, 11));
115 matchedLabel.setHorizontalAlignment(SwingConstants.LEFT);
116 matchedLabel.setText("Matched Input Pairs");
117 matchedLabel.setVerticalAlignment(SwingConstants.CENTER);
118 jPanel3.setLayout(borderLayout2);
119 jPanel6.setLayout(gridLayout2);
120 jPanel5.setLayout(gridLayout3);
121 unmatchedLabel.setFont(new java.awt.Font("Dialog", 1, 11));
122 unmatchedLabel.setText("Unmatched Inputs");
123 jPanel4.setLayout(borderLayout3);
124 jPanel8.setLayout(gridLayout4);
125 jPanel7.setLayout(gridLayout5);
126 getContentPane().add(panel1);
127 panel1.add(jPanel1, BorderLayout.CENTER);
128 jPanel1.add(jPanel3, null);
129 jPanel3.add(jPanel5, BorderLayout.NORTH);
130 jPanel5.add(matchedLabel, null);
131 jPanel3.add(jPanel6, BorderLayout.CENTER);
132 jPanel6.add(jScrollPane1, null);
133 jScrollPane1.getViewport().add(matchedList, null);
134 jPanel1.add(jPanel4, null);
135 jPanel4.add(jPanel7, BorderLayout.CENTER);
136 jPanel7.add(jScrollPane2, null);
137 jScrollPane2.getViewport().add(unmatchedList, null);
138 jPanel4.add(jPanel8, BorderLayout.NORTH);
139 jPanel8.add(unmatchedLabel, null);
140 panel1.add(jPanel2, BorderLayout.SOUTH);
141 jPanel2.add(closeButton, null);
142 }
143
144 /***
145 * Initializes all the fields with available information.
146 */
147 private void initializeFields() {
148 if (result==null) {
149 return;
150 }
151 if (input) {
152 matchedLabel.setText("Matched Input Pairs");
153 unmatchedLabel.setText("Unmatched Inputs");
154 if (result.getMatchedAdvInputs()!=null) {
155 Vector matchedInputs = new Vector();
156 Enumeration enum = result.getMatchedAdvInputs().keys();
157 while (enum.hasMoreElements()) {
158 Object mykey = enum.nextElement();
159 Input advInput = (Input)mykey;
160 String advType = "Thing";
161 String reqType = "Thing";
162 advType = advInput.getRestrictedTo();
163 if (advType!=null) {
164 if (advType.lastIndexOf("#")>0) {
165 advType = advType.substring(advType.lastIndexOf("#")+1);
166 }
167 }
168 Input reqInput = (Input)result.getMatchedAdvInputs().get(mykey);
169 reqType = reqInput.getRestrictedTo();
170 if (reqType!=null) {
171 if (reqType.lastIndexOf("#")>0) {
172 reqType = reqType.substring(reqType.lastIndexOf("#")+1);
173 }
174 }
175 matchedInputs.addElement(advInput.getPropertyName() + " : " + advType +
176 " - " + reqInput.getPropertyName()+" : " + reqType);
177 }
178 matchedList.setListData(matchedInputs);
179 }
180 if (result.getUnmatchedAdvInputs()!=null) {
181 Vector unmatchedInputs = new Vector();
182 if (result.getUnmatchedAdvInputs()!=null) {
183 for (int i = 0; i < result.getUnmatchedAdvInputs().size(); i++) {
184 Input advInput = (Input)result.getUnmatchedAdvInputs().elementAt(i);
185 String advType = "Thing";
186 advType = advInput.getRestrictedTo();
187 if (advType != null) {
188 if (advType.lastIndexOf("#") > 0) {
189 advType = advType.substring(advType.lastIndexOf("#") + 1);
190 }
191 }
192 unmatchedInputs.addElement(advInput.getPropertyName() + " : " + advType);
193 }
194 unmatchedList.setListData(unmatchedInputs);
195 }
196 }
197
198
199 } else {
200 matchedLabel.setText("Matched Output Pairs");
201 unmatchedLabel.setText("Unmatched Outputs");
202 if (result.getMatchedReqOutputs()!=null) {
203 Vector matchedOutputs = new Vector();
204 Enumeration enum = result.getMatchedReqOutputs().keys();
205 while (enum.hasMoreElements()) {
206 Object mykey = enum.nextElement();
207 Output reqOutput = (Output)mykey;
208 String advType = "Thing";
209 String reqType = "Thing";
210 reqType = reqOutput.getRestrictedTo();
211 if (reqType!=null) {
212 if (reqType.lastIndexOf("#")>0) {
213 reqType = reqType.substring(reqType.lastIndexOf("#")+1);
214 }
215 }
216 Output advOutput = (Output)result.getMatchedReqOutputs().get(mykey);
217 advType = advOutput.getRestrictedTo();
218 if (advType!=null) {
219 if (advType.lastIndexOf("#")>0) {
220 advType = advType.substring(advType.lastIndexOf("#")+1);
221 }
222 }
223 matchedOutputs.addElement(reqOutput.getPropertyName() + " : " + reqType + " - " + advOutput.getPropertyName() + " : " + advType);
224 }
225 matchedList.setListData(matchedOutputs);
226 }
227 if (result.getUnmatchedReqOutputs()!=null) {
228 Vector unmatchedOutputs = new Vector();
229 if (result.getUnmatchedReqOutputs()!=null) {
230 for (int i = 0; i < result.getUnmatchedReqOutputs().size(); i++) {
231 Output reqOutput = (Output)result.getUnmatchedReqOutputs().elementAt(i);
232 String reqType = "Thing";
233 reqType = reqOutput.getRestrictedTo();
234 if (reqType != null) {
235 if (reqType.lastIndexOf("#") > 0) {
236 reqType = reqType.substring(reqType.lastIndexOf("#") + 1);
237 }
238 }
239 unmatchedOutputs.addElement(reqOutput.getPropertyName() + " : " + reqType);
240 }
241 unmatchedList.setListData(unmatchedOutputs);
242 }
243 }
244
245 }
246
247 }
248
249
250 void closeButton_actionPerformed(ActionEvent e) {
251 this.hide();
252 }
253 }
254
255
256
257
258 class ShowParameterResultDialog_closeButton_actionAdapter implements java.awt.event.ActionListener {
259 ShowParameterResultDialog adaptee;
260 ShowParameterResultDialog_closeButton_actionAdapter(ShowParameterResultDialog adaptee) {
261 this.adaptee = adaptee;
262 }
263 public void actionPerformed(ActionEvent e) {
264 adaptee.closeButton_actionPerformed(e);
265 }
266 }