KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > spi > project > ui > support > ProjectSensitiveActions


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.spi.project.ui.support;
21
22 import javax.swing.Action JavaDoc;
23 import javax.swing.Icon JavaDoc;
24 import org.netbeans.modules.project.uiapi.Utilities;
25
26 /**
27  * Factory for creating project-sensitive actions.
28  * @author Petr Hrebejk
29  */

30 public class ProjectSensitiveActions {
31
32     private ProjectSensitiveActions() {}
33
34     /**
35      * Creates an action sensitive to the set of currently selected projects.
36      * When performed the action will call the given command on the {@link org.netbeans.spi.project.ActionProvider} of
37      * the selected project(s). The action will only be enabled when the exactly one
38      * project is selected and the command is enabled in the project's action provider.<BR>
39      * Shortcuts for actions are shared according to command, i.e. actions based on the same command
40      * will have the same shortcut.
41      * @param command the command which should be invoked when the action is
42      * performed (see e.g. constants in {@link org.netbeans.spi.project.ActionProvider})
43      * @param namePattern a pattern which should be used for determining the action's
44      * name (label). It takes two parameters a la {@link java.text.MessageFormat}: <code>{0}</code> - number of selected projects;
45      * <code>{1}</code> - name of the first project.
46      * @param icon icon of the action (or null)
47      * @return an action sensitive to the current project
48      */

49     public static Action JavaDoc projectCommandAction( String JavaDoc command, String JavaDoc namePattern, Icon JavaDoc icon ) {
50         return Utilities.getActionsFactory().projectCommandAction( command, namePattern, icon );
51     }
52     
53     /**
54      * Creates an action sensitive to the set of currently selected projects.
55      * When performed the action will call {@link ProjectActionPerformer#perform}
56      * on the action performer supplied
57      * as a parameter. The action will only be enabled when the exactly one
58      * project is selected and {@link ProjectActionPerformer#enable}
59      * returns true.<BR>
60      * Notice that it is not guaranteed that the {@link ProjectActionPerformer#enable}
61      * method will be called unless the project selection changes and someone is
62      * listeningon the action or explicitely asks for some of the action's values.
63      * @param performer an action performer.
64      * @param namePattern pattern which should be used for determining the action's
65      * name (label). It takes two parameters a la {@link java.text.MessageFormat}: <code>{0}</code> - number of selected projects;
66      * <code>{1}</code> - name of the first project.
67      * @param icon icon of the action (XXX or null?)
68      * @return an action sensitive to the current project
69      */

70     public static Action JavaDoc projectSensitiveAction( ProjectActionPerformer performer, String JavaDoc namePattern, Icon JavaDoc icon ) {
71         return Utilities.getActionsFactory().projectSensitiveAction( performer, namePattern, icon );
72     }
73     
74 }
75
Popular Tags