KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > client > SuggestionPerformer


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.modules.tasklist.client;
21
22 import org.netbeans.modules.tasklist.client.Suggestion;
23
24 /**
25  * A SuggestionPerformer is a class which is registered with a Suggestion,
26  * and when its perform() method is called, it carries out the Suggestion.
27  * It also has an interface for confirming the action, and customizing it.
28  *
29  * @author Tor Norbye
30  */

31 public interface SuggestionPerformer {
32     /** Perform the suggestion. This method should perform the
33      * task as described in the Suggestion's description.
34      * <p>
35      * You may perform the action in any thread you want. But you're
36      * responsible for ensuring that the action is still valid when
37      * it's run. (For example, if your action is going to edit a user
38      * document by inserting at a particular position, and your perform
39      * method puts this action on a thread which kicks in after 15 seconds,
40      * you have to be able to adjust the file position if the user edits
41      * the document in the mean time.)
42      * <p>
43      * Do not forget to adjust suggestion (in)validity.
44      *
45      * @param suggestion The suggestion to be performed
46      */

47     void perform(Suggestion suggestion);
48
49     /** Return a confirmation message (or component) for the action.
50      * This can be a Component, or a String (or any object whose
51      * toString() method returns the confirmation message you want).
52      * If you return null, the Suggestion will not provide any
53      * confirmation message to the user. That's not recommended for
54      * suggestions which modify any user data; also, users can easily
55      * disable suggestions they don't like through the confirmation
56      * dialog so modules are strongly encouraged to provide a confirmation
57      * description or component.
58      * <p>
59      * You can write out more detailed confirmations here; for
60      * example, a task to clean up the Imports in a file may include
61      * a listbox which describes all the import statements about to
62      * be removed. You can also let users edit this listbox (add
63      * a Remove button which removes selected items for example),
64      * and the perform() method can read values the panel back. If
65        you do this [add state to be considered
66      * by the perform() method] you should store this state in the
67      * SuggestionPerformer and make sure that you create a unique
68      * SuggestionPerformer instance for each Suggestion.
69      * <p>
70      *
71      * @param suggestion The suggestion that we want a confirmation
72      * description for.
73      * @return A component or string which contains a summary of what
74      * executing the Suggestion will accomplish. May be null.
75      */

76     Object JavaDoc getConfirmation(Suggestion suggestion);
77     
78     /**
79      * Indicate whether this action has a confirmation panel or text
80      * (without actually having to create it.)
81      *
82      * @return True iff this performer has a confirmation.
83      */

84     boolean hasConfirmation();
85 }
86
Popular Tags