public class PluginUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_ICON |
static java.util.Map<java.lang.Class<?>,java.util.LinkedHashMap<java.lang.String,PluginProperty>> |
defaultValuesProperties |
static java.io.File |
PLUGINS_DIR |
Constructor and Description |
---|
PluginUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
addToClassPath(java.net.URL u)
Given an URL to a resource (.jar, .class, .png, ...), adds that resource to the system class path
|
static PluginProperty |
createPluginProperty(java.lang.Object obj,
java.lang.reflect.Field f) |
static PluginProperty |
createPluginProperty(java.lang.Object obj,
java.lang.reflect.Field f,
boolean forEdit) |
static PluginProperty |
createPluginProperty(java.lang.Object obj,
java.lang.reflect.Field f,
java.lang.String defaultValueString,
boolean forEdit)
NOTE: the forEdit is important because if we want to load properties for the
GeneralPreferences
we pass forEdit=false so we don't call I18n that loads GeneralPreferences#language while we are
loading GeneralPreferences properties from file. |
static void |
editPluginProperties(java.lang.Object obj,
boolean editable) |
protected static void |
extractDefaultFieldsValues(java.lang.Object obj) |
static void |
extractFieldsWorker(java.lang.Class<?> clazz,
java.util.Vector<java.lang.reflect.Field> dFA) |
static java.lang.String |
getConfigXml(java.lang.Object obj) |
static java.util.Map<java.lang.String,PluginProperty> |
getDefaultsValues(java.lang.Object obj) |
static java.lang.String |
getLocalizedPluginName(java.lang.Class<?> clazz)
Tries to retrieve the plugin name from a
PluginDescription annotation or else uses the class name |
static java.lang.String |
getPluginDescription(java.lang.Class<?> clazz)
Retrieves the description for a given plugin using the
PluginDescription annotation |
static java.lang.String |
getPluginI18nName(java.lang.Class<?> clazz) |
static java.lang.String |
getPluginIcon(java.lang.Class<?> clazz)
Retrieves the filename of the icon to be used for this plugin as stated in the
PluginDescription
annotation |
static java.lang.String |
getPluginName(java.lang.Class<?> clazz)
Tries to retrieve the plugin name from a
PluginDescription annotation or else uses the class name |
static PluginProperty[] |
getPluginProperties(java.lang.Object obj) |
static PluginProperty[] |
getPluginProperties(java.lang.Object obj,
boolean forEdit)
Retrieves the plugin properties as an array
|
static java.util.LinkedHashMap<java.lang.String,PluginProperty> |
getProperties(java.lang.Object obj,
boolean forEdit)
Retrieves the properties found in a Plugin instance
|
static java.lang.String |
i18nTranslate(java.lang.String txt) |
static java.lang.String[] |
listPlugins(java.lang.String interfaceName)
Given the classname of an interface, gives all the classes that implement that interface
|
static void |
loadPlugins()
Adds all jars contained in the UGINS_DIR to the system's classpath
|
static void |
loadProperties(java.lang.Object obj,
java.lang.String instanceName) |
static void |
loadProperties(java.util.Properties props,
java.lang.Object obj) |
static void |
loadProperties(java.lang.String filename,
java.lang.Object obj) |
static void |
loadProperties(java.lang.String filename,
java.util.Properties props,
java.lang.Object obj) |
static java.util.Properties |
saveProperties(java.lang.Object obj,
boolean clean)
Inspects the plugin instance passed as a parameter and retrieves its properties as a java.util.Properties
|
static void |
saveProperties(java.lang.Object obj,
java.lang.String instanceName) |
static void |
saveProperties(java.lang.String filename,
boolean ignorePropertiesWithDefaultValues,
java.lang.Object obj) |
static void |
saveProperties(java.lang.String filename,
java.lang.Object obj) |
static void |
savePropertiesToXML(java.lang.String filename,
boolean ignorePropertiesWithDefaultValues,
java.lang.Object obj) |
static void |
savePropertiesToXML(java.lang.String filename,
java.lang.Object obj) |
static void |
setConfigXml(java.lang.Object obj,
java.lang.String xml) |
static void |
setPluginProperties(java.lang.Object obj,
java.util.LinkedHashMap<java.lang.String,PluginProperty> props) |
static void |
setPluginProperties(java.lang.Object obj,
com.l2fprod.common.propertysheet.Property[] props)
Changes the fields in the given object instance according to the properties passed as a parameter
|
static java.lang.String[] |
validatePluginProperties(java.lang.Object obj,
java.util.LinkedHashMap<java.lang.String,PluginProperty> props) |
static java.lang.String[] |
validatePluginProperties(java.lang.Object obj,
com.l2fprod.common.propertysheet.Property[] props) |
static PropertiesProvider |
wrapIntoAPlugInPropertiesProvider(java.lang.Object objWithNeptusPropertyAnotation)
|
public static java.lang.String DEFAULT_ICON
public static final java.io.File PLUGINS_DIR
public static java.util.Map<java.lang.Class<?>,java.util.LinkedHashMap<java.lang.String,PluginProperty>> defaultValuesProperties
public static java.lang.String getPluginName(java.lang.Class<?> clazz)
PluginDescription
annotation or else uses the class nameclazz
- The class of the pluginpublic static java.lang.String getPluginI18nName(java.lang.Class<?> clazz)
public static java.lang.String i18nTranslate(java.lang.String txt)
public static java.lang.String getLocalizedPluginName(java.lang.Class<?> clazz)
PluginDescription
annotation or else uses the class nameclazz
- The class of the pluginpublic static java.lang.String getPluginDescription(java.lang.Class<?> clazz)
PluginDescription
annotationclazz
- The class of the pluginpublic static java.lang.String getPluginIcon(java.lang.Class<?> clazz)
PluginDescription
annotationclazz
- The plugin classpublic static java.util.LinkedHashMap<java.lang.String,PluginProperty> getProperties(java.lang.Object obj, boolean forEdit)
obj
- The plugin instance to be inspected for propertiespublic static PluginProperty createPluginProperty(java.lang.Object obj, java.lang.reflect.Field f, boolean forEdit)
obj
- use the null for staticf
- public static PluginProperty createPluginProperty(java.lang.Object obj, java.lang.reflect.Field f)
public static PluginProperty createPluginProperty(java.lang.Object obj, java.lang.reflect.Field f, java.lang.String defaultValueString, boolean forEdit)
GeneralPreferences
we pass forEdit=false so we don't call I18n that loads GeneralPreferences#language
while we are
loading GeneralPreferences
properties from file.obj
- f
- defaultValueString
- or null if not known.public static void editPluginProperties(java.lang.Object obj, boolean editable)
public static PluginProperty[] getPluginProperties(java.lang.Object obj, boolean forEdit)
obj
- The plugin instance to be inspected for propertiespublic static PluginProperty[] getPluginProperties(java.lang.Object obj)
public static void setPluginProperties(java.lang.Object obj, com.l2fprod.common.propertysheet.Property[] props)
obj
- The plugin instance to be initializedprops
- The properties to be set on the given objectpublic static java.lang.String[] validatePluginProperties(java.lang.Object obj, com.l2fprod.common.propertysheet.Property[] props)
public static java.lang.String[] validatePluginProperties(java.lang.Object obj, java.util.LinkedHashMap<java.lang.String,PluginProperty> props)
public static void setPluginProperties(java.lang.Object obj, java.util.LinkedHashMap<java.lang.String,PluginProperty> props)
#setPluginProperties(Object, Property[])}
public static java.util.Properties saveProperties(java.lang.Object obj, boolean clean)
obj
- The plugin instance to be inspected for propertiesclean
- If true, the properties with default values will be removed from the resultprotected static void extractDefaultFieldsValues(java.lang.Object obj)
clazz
- public static java.util.Map<java.lang.String,PluginProperty> getDefaultsValues(java.lang.Object obj)
public static void saveProperties(java.lang.String filename, boolean ignorePropertiesWithDefaultValues, java.lang.Object obj) throws java.io.IOException
filename
- ignorePropertiesWithDefaultValues
- obj
- java.io.IOException
public static void saveProperties(java.lang.String filename, java.lang.Object obj) throws java.io.IOException
filename
- obj
- java.io.IOException
public static void savePropertiesToXML(java.lang.String filename, boolean ignorePropertiesWithDefaultValues, java.lang.Object obj) throws java.io.IOException
filename
- ignorePropertiesWithDefaultValues
- obj
- java.io.IOException
public static void savePropertiesToXML(java.lang.String filename, java.lang.Object obj) throws java.io.IOException
filename
- obj
- java.io.IOException
public static void loadProperties(java.lang.String filename, java.lang.Object obj) throws java.io.IOException
filename
- obj
- java.io.IOException
public static void loadProperties(java.lang.String filename, java.util.Properties props, java.lang.Object obj) throws java.io.IOException
filename
- props
- obj
- java.io.IOException
public static void loadProperties(java.util.Properties props, java.lang.Object obj)
props
- obj
- public static java.lang.String getConfigXml(java.lang.Object obj)
public static void setConfigXml(java.lang.Object obj, java.lang.String xml)
public static void loadProperties(java.lang.Object obj, java.lang.String instanceName)
public static void saveProperties(java.lang.Object obj, java.lang.String instanceName)
public static final PropertiesProvider wrapIntoAPlugInPropertiesProvider(java.lang.Object objWithNeptusPropertyAnotation)
objWithNeptusPropertyAnotation
- public static void extractFieldsWorker(java.lang.Class<?> clazz, java.util.Vector<java.lang.reflect.Field> dFA)
clazz
- dFA
- public static void loadPlugins()
public static java.lang.String[] listPlugins(java.lang.String interfaceName)
interfaceName
- the looked after interfacepublic static void addToClassPath(java.net.URL u) throws java.io.IOException
u
- The URL of the resource to be addedjava.io.IOException
- In the case that the resourse can not be readCopyright © 2004-2014 FEUP-LSTS and Neptus developers. All Rights Reserved.