KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > editor > codetemplates > spi > CodeTemplateProcessor


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.lib.editor.codetemplates.spi;
21
22 /**
23  * Fills in default values of the code template's parameters and may react
24  * to user's typing modifications of the parameters.
25  * <br>
26  * Each processor is associated with {@link CodeTemplateInsertRequest}
27  * which was given to it during construction by {@link CodeTemplateProcessorFactory}.
28  * @see CodeTemplateProcessorFactory
29  *
30  * @author Miloslav Metelka
31  */

32 public interface CodeTemplateProcessor {
33
34     /**
35      * Update the values of the parameters in the parsed code template
36      * before the code template gets physically inserted into the document.
37      * <br/>
38      * The processor may call {@link CodeTemplateInsertRequest#getMasterParameters()}
39      * to find the master parameters.
40      * <br/>
41      * On each parameter {@link CodeTemplateParameter#setValue(String)}
42      * can be called. The value will be propagated to all slave parameters
43      * automatically.
44      */

45     void updateDefaultValues();
46
47     /**
48      * Notification that a master parameter's value has been modified
49      * by the user and the processor may need to react to it.
50      * <br/>
51      * This notification is only done after the code template was physically
52      * inserted into the document i.e. {@link CodeTemplateInsertRequest#isInserted()}
53      * returns true.
54      *
55      * <br/>
56      * Typically the processor either does nothing or it may change other
57      * parameter(s)' values. The change may occur in the same thread
58      * or it may post the parameter's new value recomputation and changing
59      * into another thread.
60      *
61      * <p>
62      * The processor is only allowed to change master parameters.
63      * </p>
64      *
65      * <p>
66      * Slave parameter's changes are not notified at all.
67      * </p>
68      *
69      * @param masterParameter master parameter that was changed.
70      * @param typingChange allows to react to user's typing immediately
71      * or only react once the active parameter gets changed e.g. by <i>TAB</i>.
72      * <br/>
73      * <code>true</code> is passed if the parameter value was modified
74      * by user's typing. Some processors may want such immediate reaction.
75      * <br/>
76      * Others will only react when this parameter
77      * is <code>false</code> which happens when
78      * at least one typing change occurred in the current active parameter
79      * and the active parameter is being changed by <i>TAB</i>
80      * or <i>Shift-TAB</i> or <i>Enter</i>.
81      */

82     void parameterValueChanged(CodeTemplateParameter masterParameter, boolean typingChange);
83
84     /**
85      * Notify the processor that the insert request which it services
86      * was already completed and there is no more work to do.
87      * <br/>
88      * The processor can free possible resources related to the insert
89      * request processing.
90      *
91      * @see CodeTemplateInsertRequest#isReleased()
92      */

93     void release();
94
95 }
96
Popular Tags