KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > form > I18nService


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.form;
21
22 import java.awt.Component JavaDoc;
23 import java.beans.PropertyEditor JavaDoc;
24 import java.io.IOException JavaDoc;
25 import org.openide.loaders.DataObject;
26
27 /**
28  * Interface of an internationalization service - form editor needs it to
29  * perform automatic internationalization of forms. It is designed with respect
30  * to the existing i18n architecture - i.e. to keep FormI18nStringEditor working
31  * with the values created by the form editor.
32  */

33 public interface I18nService {
34
35     /**
36      * Creates I18nValue object for given key and value. Should not be added
37      * to the bundle file yet. (For that purpose 'update' method is called later.)
38      */

39     I18nValue create(String JavaDoc key, String JavaDoc value, DataObject srcDataObject);
40
41     /**
42      * Creates a new I18nValue object with a new key. Should do no changes to
43      * the bundle file at this moment.
44      */

45     I18nValue changeKey(I18nValue prev, String JavaDoc newKey);
46
47     /**
48      * Creates a new I18nValue object with changed value. Should not do any
49      * changes to the bundle file.
50      */

51     I18nValue changeValue(I18nValue prev, String JavaDoc value);
52
53     /**
54      * Creates a new I18nValue refering to given locale (both for reading and
55      * writing from now).
56      */

57     I18nValue switchLocale(I18nValue value, String JavaDoc localeSuffix);
58
59     /**
60      * Updates bundle file according to given I18nValue objects - oldValue is
61      * removed, newValue added. Update goes into given locale - parent files
62      * are updated too if given key is not present in them. New properties file
63      * is created if needed.
64      */

65     void update(I18nValue oldValue, I18nValue newValue,
66                 DataObject srcDataObject, String JavaDoc bundleName, String JavaDoc localeSuffix,
67                 boolean canRemove)
68         throws IOException JavaDoc;
69
70     /**
71      * Returns property editor to be used for editing internationalized
72      * property of given type (e.g. String). If an existing suitable editor is
73      * passed then it is returned and no new property editor is created.
74      */

75     PropertyEditor JavaDoc getPropertyEditor(Class JavaDoc type, PropertyEditor JavaDoc existing);
76
77     /**
78      * Evaluates the effect of changing a property editor. The property editor
79      * determines whether a property can hold internationalized value.
80      * @return -1 if an i18n editor is changed to plain type editor,
81      * 0 if the type of editor does no change,
82      * 1 if a plain type editor is changed to i18n one
83      */

84     int analyzePropertyEditorChange(PropertyEditor JavaDoc oldPE, PropertyEditor JavaDoc newPE);
85
86     /**
87      * Provides a component usable as property customizer (so typically a modal
88      * dialog) that allows to choose (or create) a properties bundle file within
89      * the project of given form data object. The selected file should be
90      * written to the given property editor (via setValue) as a resource name
91      * string.
92      */

93     Component JavaDoc getBundleSelectionComponent(PropertyEditor JavaDoc pe, DataObject srcDataObject);
94
95     /**
96      * Returns all currently available locales for given bundle in two arrays
97      * os strings. The first one containes locale suffixes, the second one
98      * corresponding display names for the user (should be unique).
99      */

100     String JavaDoc[][] getAvailableLocales(DataObject srcDataObject, String JavaDoc bundleName);
101
102     /**
103      * Provides a visual component (modal dialog) usable as a property
104      * customizer that allows create a new locale file for given bundle (default
105      * bundle name provided). The created locale should be written as a string
106      * (locale suffix) to the given propery editor.
107      */

108     Component JavaDoc getCreateLocaleComponent(PropertyEditor JavaDoc pe, DataObject srcDataObject, String JavaDoc bundleName);
109
110     /**
111      * Saves properties files edited for given source object (form). This method
112      * is called when a form is being saved - so the corresponding bundle is
113      * saved as well.
114      */

115     void autoSave(DataObject srcDataObject);
116
117     /**
118      * Called when a form is closed without saving changes. The changes in
119      * corresponding properties file can be discarded as well.
120      */

121     void close(DataObject srcDataObject);
122
123     /**
124      * Checks project of given form whether it is suitable to be automatically
125      * internationalized by default. Currently new forms in module projects
126      * should be set to auto i18n, while standard user (J2SE) projects not.
127      * [If we decide all projects should be internationalized, we can remove
128      * this method.]
129      */

130     boolean isDefaultInternationalizableProject(DataObject srcDataObject);
131 }
132
Popular Tags