01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2005 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //
09:
10: package de.uka.ilkd.key.ocl.gf;
11:
12: import java.awt.Component;
13: import java.awt.event.ActionEvent;
14: import java.awt.event.ActionListener;
15:
16: import javax.swing.*;
17:
18: /** Provide a choice of output formats: OCL or Natural Language. NL can be
19: * formatted using either HTML or LaTeX.
20: */
21: public class ExportFormatMenu extends JPanel {
22: public static int OCL = 0, HTML = 1, LATEX = 2;
23:
24: private static String[] menuStrings = { "OCL",
25: "Natural Language/HTML (requires GF)",
26: "Natural Language/LaTeX (requires GF)" };
27:
28: private JComboBox formatMenu;
29: private int selection;
30:
31: private ActionListener al = new ActionListener() {
32: public void actionPerformed(ActionEvent e) {
33: JComboBox cb = (JComboBox) e.getSource();
34: String s = (String) cb.getSelectedItem();
35: if (s.equals("OCL")) {
36: selection = OCL;
37: } else if (s.equals("Natural Language/HTML (requires GF)")) {
38: selection = HTML;
39: } else if (s.equals("Natural Language/LaTeX (requires GF)")) {
40: selection = LATEX;
41: } else { // should never occur
42: selection = OCL;
43: }
44: }
45: };
46:
47: public ExportFormatMenu() {
48: super ();
49: this .setLayout(new BoxLayout(this , BoxLayout.Y_AXIS));
50: formatMenu = new JComboBox(menuStrings);
51: formatMenu.setSelectedIndex(0);
52: formatMenu.addActionListener(al);
53: this .add(Box.createVerticalGlue());
54: JLabel text = new JLabel("Choose output format:");
55: this .add(text);
56: text.setAlignmentX(Component.CENTER_ALIGNMENT);
57: this .add(formatMenu);
58: }
59:
60: public int getSelection() {
61: return selection;
62: }
63: }
|