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 com.borland.jbuilder.node.JavaFileNode;
24  import com.borland.primetime.ide.Browser;
25  import com.borland.primetime.ide.BrowserAction;
26  import com.borland.primetime.node.Node;
27  
28  /***
29   * The class handles the action the user performs when selecting Checkstyle on the contextual menu of a file tab or when
30   * he use the toolbar icon.
31   * @author Henri Tremblay
32   * @version $Revision: 1.7 $ $Date: 2003/12/07 16:07:53 $
33   */
34  public class CheckStyleAction extends BrowserAction
35  {
36     /*** Default Constructor. */
37     public CheckStyleAction() {
38        super("JBCS", 'C',
39           "Checkstyle is a development tool to help programmers write "
40           + "Java code that adheres to a coding standard",
41           CheckStyleOpenTool.ICON, "Run Checkstyle on current file");
42     }
43  
44     /***
45      * @param browser  The active browser.
46      * @see            BrowserAction
47      */
48     public void actionPerformed(Browser browser) {
49        Node node = browser.getActiveNode();
50        if(node instanceof JavaFileNode) {
51           CheckStyleOpenTool.checkNodes(browser, new JavaFileNode[] { (JavaFileNode) node} );
52        }
53        else {
54           // Display in the status bar
55           new MessageHandler(browser).writeStatusBarMessage("Checkstyle - Not a Java source file");
56        }
57     }
58  }