TextParserAction.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.AsciiMathParser;
26 import org.qedeq.kernel.se.common.SourceFileExceptionList;
27 
28 /**
29  * Show preferences window.
30  *
31  @author  Michael Meyling
32  */
33 class TextParserAction extends AbstractAction {
34 
35     /** This class. */
36     private static final Class CLASS = TextParserAction.class;
37 
38     /** Controller reference. */
39     private final QedeqController controller;
40 
41     /**
42      * Constructor.
43      *
44      @param   controller  Controller.
45      */
46     TextParserAction(final QedeqController controller) {
47         this.controller = controller;
48     }
49 
50     public void actionPerformed(final ActionEvent e) {
51         final String resourceName = "textMathOperators.xml";
52         try {
53             final ParserPane pane = new ParserPane("Text"new AsciiMathParser(),
54                 "QEDEQ Text Parser Sample",
55                 resourceName,
56                 "a -> (b & c)\n"
57                  "A x (x in y <-> x in z) -> y = z\n"
58                  "set(x) <-> E y (y in x)\n"
59                  "E x A y a(x, y) -> A x E y a(x, y)\n"
60                  );
61             pane.setVisible(true);
62         catch (final SourceFileExceptionList xl) {
63             Trace.fatal(CLASS, this, "actionPerformed""Parser Window can not be opened", xl);
64             JOptionPane.showMessageDialog(
65                 controller.getMainFrame()"Parser Window can not be opened. There is a problem with \""
66                 + resourceName + "\"\n\n"
67                     "Just deleting this file in the config directory should fix the error."  "\n\n"
68                     + xl.toString()"Error",
69                     JOptionPane.ERROR_MESSAGE);
70         catch (final RuntimeException ex) {
71             Trace.fatal(CLASS, this, "actionPerformed""unexpected problem", ex);
72             JOptionPane.showMessageDialog(
73                 controller.getMainFrame()"Parser Window can not be opened" "\n"
74                     + ex.toString()"Error",
75                     JOptionPane.ERROR_MESSAGE);
76         }
77     }
78 
79 }