QedeqTreeContextMenu.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.tree;
17 
18 import javax.swing.JMenuItem;
19 import javax.swing.JPopupMenu;
20 
21 import org.qedeq.gui.se.control.QedeqController;
22 import org.qedeq.gui.se.pane.QedeqGuiConfig;
23 import org.qedeq.gui.se.util.GuiHelper;
24 import org.qedeq.gui.se.util.MenuHelper;
25 
26 
27 /**
28  * Context menu for nodes.
29  *
30  @author  Michael Meyling
31  */
32 public final class QedeqTreeContextMenu extends JPopupMenu {
33 
34     /**
35      * Constructor.
36      *
37      @param   controller  Reference holder to action information.
38      */
39     public QedeqTreeContextMenu(final QedeqController controller) {
40         final String resolution = QedeqGuiConfig.getInstance().getIconSize();
41         JMenuItem item = MenuHelper.createMenuItem("Remove"'R');
42         item.addActionListener(controller.getRemoveModuleAction());
43         item.setToolTipText("Unload selected QEDEQ modules. Changes status of dependent modules. "
44                 "Local module buffer is not affected.");
45         item.setIcon(GuiHelper.readImageIcon("tango/" + resolution + "/actions/edit-cut.png"));
46         this.add(item);
47 
48         this.addSeparator();
49 
50         item = MenuHelper.createMenuItem("Check Well-Formedness"'W');
51         item.setToolTipText(
52             "Check if all formulas are well formed within selected QEDEQ modules. This includes dependency checking.");
53         item.addActionListener(controller.getCheckLogicAction());
54         item.setIcon(GuiHelper.readImageIcon("tango/" + resolution + "/actions/run.png"));
55         this.add(item);
56 
57         this.addSeparator();
58 
59         final JMenuItem[] pluginMenu = controller.getPluginMenuEntries();
60         for (int i = 0; i < pluginMenu.length; i++) {
61             this.add(pluginMenu[i]);
62         }
63 
64         this.addSeparator();
65 
66         item = MenuHelper.createMenuItem("Remove Plugin Results"'R');
67         item.addActionListener(controller.getRemovePluginResultsAction());
68         item.setToolTipText(
69             "Remove all warnings and errors that were produced by all plugin executions for the selected module.");
70         item.setIcon(GuiHelper.readImageIcon("tango/" + resolution + "/actions/edit-clear.png"));
71         this.add(item);
72 
73         this.addSeparator();
74 
75         item = MenuHelper.createMenuItem("Terminate Threads"'T');
76         item.addActionListener(controller.getTerminateAllAction());
77         item.setToolTipText(
78             "Terminate all currently running plugin processes.");
79         item.setIcon(GuiHelper.readImageIcon("tango/" + resolution + "/actions/process-stop.png"));
80         this.add(item);
81 
82         this.addSeparator();
83 
84         item = MenuHelper.createMenuItem("Load from Web"'W');
85         item.setToolTipText("Load QEDEQ module from anywhere in the Web");
86         item.addActionListener(controller.getAddAction());
87         item.setIcon(GuiHelper.readImageIcon("tango/" + resolution + "/actions/list-add.png"));
88         this.add(item);
89 
90         item = MenuHelper.createMenuItem("Load local File"'F');
91         item.setToolTipText("Load QEDEQ module from file system");
92         item.addActionListener(controller.getAddFileAction());
93         item.setIcon(GuiHelper.readImageIcon("tango/" + resolution + "/actions/document-open.png"));
94         this.add(item);
95     }
96 
97 }