01: package org.mandarax.examples.jdbc;
02:
03: /*
04: * Copyright (C) 1999-2004 <a href="mailto:mandarax@jbdietrich.com">Jens Dietrich</a>
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: */
20:
21: import java.awt.*;
22: import java.awt.event.ActionEvent;
23: import java.awt.event.ActionListener;
24: import java.util.*;
25: import javax.swing.*;
26: import org.mandarax.kernel.Derivation;
27: import org.mandarax.util.ProofAnalyzer;
28:
29: /**
30: * Simple view visualizing a derivation.
31: * @author <a href="mailto:jens@jbdietrich.com">Jens Dietrich</a>
32: * @version 3.3.2 <29 December 2004>
33: */
34:
35: class SimpleDerivationView extends JDialog {
36: private Derivation derivation = null;
37:
38: /*
39: * Open a display dialog.
40: * @param window a parent component
41: * @param derivation a derivation
42: * @param resultNumber the result number
43: */
44: static void show(Component parent, Derivation derivation,
45: int resultNumber) {
46: JFrame window = (JFrame) SwingUtilities
47: .getWindowAncestor(parent);
48: SimpleDerivationView view = new SimpleDerivationView(window,
49: derivation, resultNumber);
50: view.setSize(600, 300);
51: view.setLocationRelativeTo(window);
52: view.show();
53: }
54:
55: /*
56: * Constructor.
57: * @author jens
58: * @param owner the owner window
59: * @param derivation a derivation
60: * @param resultNumber the result number
61: */
62: SimpleDerivationView(Frame owner, Derivation derivation,
63: int resultNumber) {
64: super (owner, "Derivation", true);
65: JPanel main = new JPanel(new BorderLayout(5, 5));
66: this .setContentPane(main);
67: Collection clauses = ProofAnalyzer.getAppliedClauses(
68: derivation, resultNumber);
69: Vector clausesAsVector = new Vector();
70: clausesAsVector.addAll(clauses);
71: JList list = new JList(clausesAsVector);
72: main.add(new JScrollPane(list), BorderLayout.CENTER);
73: main.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
74: // close button
75: JPanel pane = new JPanel(new FlowLayout(FlowLayout.CENTER));
76: JButton butClose = new JButton(" OK ");
77: butClose.addActionListener(new ActionListener() {
78: public void actionPerformed(ActionEvent e) {
79: dispose();
80: }
81: });
82: pane.add(butClose);
83: main.add(pane, BorderLayout.SOUTH);
84: }
85:
86: }
|