| org.netbeans.modules.form.ResourceService
ResourceService | public interface ResourceService (Code) | | Interface used by the form editor to manipulate resources (property values
stored externally, represented by ResourceValue). Implementation is provided
by the Swing App Framework module, storing the resources in properties files.
Theoretically there could be other implementors, but practically there is no
need for that.
See Also: ResourceSupport author: Tomas Pavek |
Method Summary | |
void | autoSave(FileObject srcFile) Saves properties files edited for given source object (form). | ResourceValue | changeKey(ResourceValue resource, String newKey) Creates a new ResourceValue object with a new key. | ResourceValue | changeValue(ResourceValue resource, Object newValue, String newStringValue) Creates new ResourceValue object with a changed value. | void | close(FileObject srcFile) Called when the source file (form) is closed without saving changes. | ResourceValue | create(String key, Class type, Object value, String stringValue, FileObject srcFile) Creates ResourceValue object for given key and value. | ResourcePanel | createResourcePanel(Class valueType, FileObject srcFile) | Collection<String> | findKeys(String keyRegex, FileObject srcFile) Collects all available keys matching given regular expression (via
String.matches - i.e. | ResourceValue | get(String key, Class type, String localeSuffix, FileObject srcFile) Finds ResourceValue for given key, locale and source file. | String[][] | getAvailableLocales(FileObject srcFile) Obtains all currently available locales of properties files for given
source file. | java.awt.Component | getCreateLocaleComponent(PropertyEditor prEd, FileObject srcFile) Provides a visual component (modal dialog) usable as a property
customizer that allows create a new locale file for default properties
file belonging to given source file. | String | getInjectionCode(Object component, String variableName, FileObject srcFile) | List<URL> | getResourceFiles(FileObject srcFile) Returns the files that define resources for given source file.
Practically this includes the properties file (resource map) and all its
locale or OS variants. | boolean | isExcludedProperty(Class componentType, String propName) | void | prepareNew(FileObject srcFile) Called when a new form is created and opened to do some preparation work. | boolean | projectUsesResources(FileObject fileInProject) Returns whether the project represented by given file allows to use the
resources infrastructure (corresponding libraries are available on
projects classpath). | boolean | projectWantsUseResources(FileObject fileInProject) Returns whether forms in the project represented by given file should
actively be set to use the resources - i.e. | ResourceValue | switchLocale(ResourceValue resource, String localeSuffix) Creates a new ResourceValue corresponding to given locale (so getValue
will return the new locale specific value). | void | update(ResourceValue oldValue, ResourceValue newValue, FileObject srcFile, String localeSuffix) Updates properties file according to given ResourceValue objects - oldValue
is removed, newValue added. |
autoSave | void autoSave(FileObject srcFile)(Code) | | Saves properties files edited for given source object (form). This method
is called when the source is being saved - so the corresponding
properties files can be saved as well.
Parameters: srcFile - the source java file whose properties files should be saved |
changeKey | ResourceValue changeKey(ResourceValue resource, String newKey)(Code) | | Creates a new ResourceValue object with a new key. Does not save it to
the file at this moment, just returns the changed object. (The 'update'
method is called later.)
Parameters: resource - the ResourceValue to be changed Parameters: newKey - the new key new ResourceValue instance with the new key (otherwise the same) |
changeValue | ResourceValue changeValue(ResourceValue resource, Object newValue, String newStringValue)(Code) | | Creates new ResourceValue object with a changed value. Does not save it to
the file at this moment, just returns the changed object. (The 'update'
method is called later.)
Parameters: resource - the ResourceValue to be changed Parameters: newValue - the new value object; used as a fallback if the stringrepresentation is not usable for constructing the value Parameters: newStringValue - textual representation of the value; needed if thevalue object itself can't be saved directly new ResourceValue instance with the new value (otherwise the same) |
close | void close(FileObject srcFile)(Code) | | Called when the source file (form) is closed without saving changes.
The changes in corresponding properties file should be discarded as well.
Parameters: srcFile - the source java file whose properties files should be closed |
create | ResourceValue create(String key, Class type, Object value, String stringValue, FileObject srcFile)(Code) | | Creates ResourceValue object for given key and value. It is not saved
to the file yet. (For that purpose 'update' method is called later.)
Parameters: key - the key (not checked for uniqueness - don't care if a valuealready exists) Parameters: type - the type of the value (needed for the infrastructure todetermine the right converter from String) Parameters: value - the value object to be stored as a resource; used as afallback if stringValue is not valid for constructing the value Parameters: stringValue - textual representation of the value; needed if thevalue object itself can't be saved directly Parameters: srcFile - the source java file for which the resource is created(used to determine where to store the resource) initialized but not saved ResourceValue object |
findKeys | Collection<String> findKeys(String keyRegex, FileObject srcFile)(Code) | | Collects all available keys matching given regular expression (via
String.matches - i.e. key.matches(keyRegex) must be true).
Parameters: keyRegex - the regular expression that the key should match Parameters: srcFile - the source file whose resources are to be searched Collection of matching keys |
get | ResourceValue get(String key, Class type, String localeSuffix, FileObject srcFile)(Code) | | Finds ResourceValue for given key, locale and source file. If no data is
available for given specific locale then a less specific or default
locale data is returned.
Parameters: key - the key Parameters: type - the type of the value (needed for the infrastructure todetermine the right converter from String) Parameters: localeSuffix - the locale variant to be used (localization suffixincluding the initial underscore, e.g. _cs_CZ) Parameters: srcFile - the source java file for which the resource is obtained ResourceValue object with found data, or null |
getAvailableLocales | String[][] getAvailableLocales(FileObject srcFile)(Code) | | Obtains all currently available locales of properties files for given
source file. Returns two arrays of strings. The first one containes
locale suffixes, the second one corresponding display names for the user
(should be unique).
Parameters: srcFile - the source java file whose resources are in question array of available locales (locale suffixes and display names) |
getCreateLocaleComponent | java.awt.Component getCreateLocaleComponent(PropertyEditor prEd, FileObject srcFile)(Code) | | Provides a visual component (modal dialog) usable as a property
customizer that allows create a new locale file for default properties
file belonging to given source file. It writes the created locale as
a string (locale suffix) to the given propery editor.
Parameters: prEd - a property editor where the component writes the createdlocale suffix Parameters: srcFile - the source java file whose defining the resources scope(first suitable properties file will be used for creatingadditional locale variant) visual component of the customizer |
getResourceFiles | List<URL> getResourceFiles(FileObject srcFile)(Code) | | Returns the files that define resources for given source file.
Practically this includes the properties file (resource map) and all its
locale or OS variants. Other files referenced from the resource map
(like icons) are not included. The returned files can be used e.g. for
backup during a refactoring operation.
Parameters: srcFile - the source java file for which the resource files shouldbe returned list of properties files defining resources for given source file |
isExcludedProperty | boolean isExcludedProperty(Class componentType, String propName)(Code) | | |
prepareNew | void prepareNew(FileObject srcFile)(Code) | | Called when a new form is created and opened to do some preparation work.
Parameters: srcFile - the source java file just created |
projectUsesResources | boolean projectUsesResources(FileObject fileInProject)(Code) | | Returns whether the project represented by given file allows to use the
resources infrastructure (corresponding libraries are available on
projects classpath). If this method returns true, form editor will allow
forms in the project to use resources.
Parameters: fileInProject - a file representing the projevt (whatever sourcefile from the project) true if the given project uses the resources infrastracture(corresponding libraries are on the classpath) |
projectWantsUseResources | boolean projectWantsUseResources(FileObject fileInProject)(Code) | | Returns whether forms in the project represented by given file should
actively be set to use the resources - i.e. not only the resources
are allowed, but they should even be used by default.
Parameters: fileInProject - a file representing the projevt (whatever sourcefile from the project) true if the given project can use resources, false if theproject is not suitable for resources |
switchLocale | ResourceValue switchLocale(ResourceValue resource, String localeSuffix)(Code) | | Creates a new ResourceValue corresponding to given locale (so getValue
will return the new locale specific value). If no data is available for
this specific locale then a less specific or default locale data is provided.
Parameters: resource - the ResourceValue to be changed Parameters: localeSuffix - the locale variant to be used (localization suffixincluding the initial underscore, e.g. _cs_CZ) new ResourceValue instance containing data for the given locale |
update | void update(ResourceValue oldValue, ResourceValue newValue, FileObject srcFile, String localeSuffix) throws IOException(Code) | | Updates properties file according to given ResourceValue objects - oldValue
is removed, newValue added. Update goes into given locale - parent files
are updated too if given key is not present in them. New properties file
is created if needed.
Parameters: oldValue - the value to be removed or null Parameters: newValue - the value to be added or null Parameters: srcFile - the source java file whose properties files are going to bemodified Parameters: localeSuffix - the locale variant to be updated (localization suffixincluding the initial underscore, e.g. _cs_CZ) throws: java.io.IOException - when there is a problem with updating. |
|
|