ProofTextParserAction.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.ProofParserPane;
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 ProofTextParserAction extends AbstractAction {
34 
35     /** This class. */
36     private static final Class CLASS = ProofTextParserAction.class;
37 
38     /** Controller reference. */
39     private final QedeqController controller;
40 
41     /**
42      * Constructor.
43      *
44      @param   controller  Controller.
45      */
46     ProofTextParserAction(final QedeqController controller) {
47         this.controller = controller;
48     }
49 
50     public void actionPerformed(final ActionEvent e) {
51         final String resourceName = "proofTextMathOperators.xml";
52         try {
53             final ProofParserPane pane = new ProofParserPane("Proof Text"new AsciiMathParser(),
54                 "QEDEQ Proof Text Parser Sample",
55                 resourceName,
56                    "     A -> A & A\n"
57                 "(1)  B -> (A -> (A & B))   Add axiom:AND-3\n"
58                 "(2)  A -> (A -> (A & A))   subpred B A 1\n"
59                 "(3)     A                  Hypothesis\n"
60                 "(4)     A -> (A & A)       MP 2, 3\n"
61                 "(5)    A & A               MP 4, 3\n"
62                 "(6) A -> (A & A)           Conclusion\n\n\n\n\n\n\n\n\n"
63                 );
64             pane.setVisible(true);
65         catch (final SourceFileExceptionList xl) {
66             Trace.fatal(CLASS, this, "actionPerformed""Parser Window can not be opened", xl);
67             JOptionPane.showMessageDialog(
68                 controller.getMainFrame()"Parser Window can not be opened. There is a problem with \""
69                 + resourceName + "\"\n\n"
70                     "Just deleting this file in the config directory should fix the error."  "\n\n"
71                     + xl.toString()"Error",
72                     JOptionPane.ERROR_MESSAGE);
73         catch (final RuntimeException ex) {
74             Trace.fatal(CLASS, this, "actionPerformed""unexpected problem", ex);
75             JOptionPane.showMessageDialog(
76                 controller.getMainFrame()"Parser Window can not be opened" "\n"
77                     + ex.toString()"Error",
78                     JOptionPane.ERROR_MESSAGE);
79         }
80     }
81 
82 }