LatexParserAction.java
01 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
02  *
03  * Copyright 2000-2013,  Michael Meyling <mime@qedeq.org>.
04  *
05  * "Hilbert II" is free software; you can redistribute
06  * it and/or modify it under the terms of the GNU General Public
07  * License as published by the Free Software Foundation; either
08  * version 2 of the License, or (at your option) any later version.
09  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  */
15 
16 package org.qedeq.gui.se.control;
17 
18 import java.awt.event.ActionEvent;
19 
20 import javax.swing.AbstractAction;
21 import javax.swing.JOptionPane;
22 
23 import org.qedeq.base.trace.Trace;
24 import org.qedeq.gui.se.pane.ParserPane;
25 import org.qedeq.kernel.bo.parser.LatexMathParser;
26 import org.qedeq.kernel.se.common.SourceFileExceptionList;
27 
28 /**
29  * Show preferences window.
30  *
31  @author  Michael Meyling
32  */
33 class LatexParserAction extends AbstractAction {
34 
35     /** This class. */
36     private static final Class CLASS = LatexParserAction.class;
37 
38     /** Controller reference. */
39     private final QedeqController controller;
40 
41     /**
42      * Constructor.
43      *
44      @param   controller  Controller.
45      */
46     LatexParserAction(final QedeqController controller) {
47         this.controller = controller;
48     }
49 
50     public void actionPerformed(final ActionEvent e) {
51         final String resourceName = "latexMathOperators.xml";
52         try {
53             final ParserPane pane = new ParserPane("LaTeX"new LatexMathParser(),
54                 "QEDEQ LaTeX Parser Sample",
55                 resourceName,
56                 "x \\land (y \\lor z) \\leftrightarrow (x \\land y) \\lor "
57                  "(x \\land z)\n\n\\{ x | y \\in x \\} = \\{ z | y \\in x \\}");
58             pane.setVisible(true);
59         catch (final SourceFileExceptionList xl) {
60             Trace.fatal(CLASS, this, "actionPerformed""Parser Window can not be opened", xl);
61             JOptionPane.showMessageDialog(
62                 controller.getMainFrame()"Parser Window can not be opened. There is a problem with \""
63                 + resourceName + "\"\n\n"
64                     "Just deleting this file in the config directory should fix the error."  "\n\n"
65                     + xl.toString()"Error",
66                     JOptionPane.ERROR_MESSAGE);
67         catch (final RuntimeException ex) {
68             Trace.fatal(CLASS, this, "actionPerformed""unexpected problem", ex);
69             JOptionPane.showMessageDialog(
70                 controller.getMainFrame()"Parser Window can not be opened" "\n"
71                     + ex.toString()"Error",
72                     JOptionPane.ERROR_MESSAGE);
73         }
74     }
75 
76 }