View Javadoc

1   /*
2    * JBCS - A JBuilder Plugin for Checkstyle
3    *
4    * This program is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU General Public License
6    * as published by the Free Software Foundation; either version 2
7    * of the License, or (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program; if not, write to the Free Software
16   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17   *
18   * Copyright © 2003
19   * Henri Tremblay
20   */
21  package com.henri.jbcs;
22  
23  import java.awt.event.ActionEvent;
24  
25  import com.borland.jbuilder.node.JavaFileNode;
26  import com.borland.primetime.editor.EditorAction;
27  import com.borland.primetime.ide.Browser;
28  import com.borland.primetime.node.Node;
29  
30  /***
31   * A key bindable EditorAction. Called when the keyboard shortcut is used
32   *
33   * @author Henri Tremblay
34   * @see EditorAction
35   * @version $Revision: 1.3 $ $Date: 2004/09/01 21:42:22 $
36   */
37  public class CheckStyleKeymapAction extends EditorAction
38  {
39  
40     /***
41      * @see   EditorAction
42      */
43     public CheckStyleKeymapAction() {
44        super("jbcs");
45        putValue("LongDescription",
46           "Checkstyle is a development tool to help programmers write "
47           + "Java code that adheres to a coding standard");
48        putValue("ActionGroup", "OpenTools");
49     }
50  
51     /***
52      * Triggers <code>ACTION_CheckStyle.actionPerformed()</code> when the JDK
53      * fires a key event
54      *
55      * @param e  The action event.
56      */
57     public void actionPerformed(ActionEvent e) {
58        Browser browser = Browser.getActiveBrowser();
59        Node node = browser.getActiveNode();
60        if(node instanceof JavaFileNode) {
61           CheckStyleOpenTool.checkNodes(browser, new JavaFileNode[] {(JavaFileNode) node});
62        }
63        else {
64           // Display in the status bar
65           new MessageHandler(browser).writeStatusBarMessage("Checkstyle - Not a Java source file");
66        }
67     }
68  }