+ * This will be on the attributes of the BeanDescriptor for the factory class. It will be complete, in that if this + * factory is inherited from another factory, it must copy in the superclass's factory attribute. They won't be + * automatically merged. + *
+ * The format is an Object[][]. The first dimension at index zero is for toolkit wide information and then indexes one and beyond are one for each creation method name. The second dimension is for one entry + * of classwide data and the rest are the data for + * each creation method. + *
+ * The first entry at Object[0] will be {initString, isShared, onFreeform}
where:
+ *
null
if it doesn't
+ * need one (i.e. all static) or if the default constructor should be used.
+ * This is used when a component is dropped from the palette that is for a toolkit component.
+ * false
if each call to the creation method should have a new instance of the toolkit. This means that the toolkit manages only
+ * one instance. This is more like a controller than a toolkit in this case. true
if it should
+ * try to reuse the toolkit of the parent if it has one, or any other found toolkit of the same type, (i.e. a subtype will be acceptable).
+ * This is used when a component is dropped from the palette that is for a toolkit component.
+ * true
if the toolkit is created that it should appear on the freeform surface to be selectable. This would be of use
+ * if the toolkit had properties that need to be set. If the toolkit had no properties then it doesn't need to be selectable and should
+ * not be on the freeform. Use false
in that case.
+ *
+ * The second and other entries of the array are of the format:
+ * {methodName, returnedClassname, isStatic, Object[], ...}
where:
+ *
Boolean.TRUE
if the method is a static method, Boolean.FALSE
if not.
+ * This is used when a component is dropped from the palette that is for a toolkit component.
+ * null
if that arg is not a property. There can be more than one array if there
+ * is more than one factory method of the same name, and returns the same type, but what is different is only the number of arguments.
+ * If there is a
+ * factory method that has no properties as arguments or has no arguments, don't include an array for it. For example if there was only one factory method and it had no
+ * arguments then there would not be any arrays.
+ * Currently cannot handle where more than one method has the same number of arguments but different types for the arguments.
+ * + * A example is: + *
+ * new Object[][] {
+ * {"new a.b.c.Toolkit(\"ABC\")", Boolean.TRUE, Boolean.FALSE},
+ * {"createButton", "a.b.c.Button", Boolean.FALSE, new Object[] {"parent", "text"}, new Object[] {"parent"}}
+ * }
+ *
+ *
+ *
+ * This example says that this class is toolkit (factory). To construct an instead use "new a.b.c.Toolkit(\"ABC\")"
and it is shared
+ * with other objects created from this factory instance. Also, the factory method is "createButton", returns an "a.b.c.Button", and it is
+ * not a static call (i.e. use a toolkit instance to create it). It has two forms of factory methods. One is two arguments where the first
+ * arg is the parent property and the second arg is the text property. The other form has only one argument, the parent property.
+ *
+ * The way this is used in a palette entry to drop a new object that a toolkit can create is to have an expression of the form
+ * {toolkit:classname}.factorymethod(args)
. So for the above example it would be {toolkit:a.b.c.Toolkit}.createButton(parent)
.
+ * The classname must be fully-qualified and if an inner class it must use the "$" instead of "." for the name, i.e. a.b.c.Toolkit.InnerFactory
+ * would be a.b.c.Toolkit$InnerFactory.
+ *
+ * NOTE: This is an EXPERIMENTAL API and can change in the future until committed.
+ *
+ * @since 1.2.0
*/
public static final String FACTORY_CREATION = "FACTORY_CREATION";//$NON-NLS-1$
diff --git a/plugins/org.eclipse.jem.beaninfo/beaninfoCommon/org/eclipse/jem/internal/beaninfo/common/FeatureAttributeValue.java b/plugins/org.eclipse.jem.beaninfo/beaninfoCommon/org/eclipse/jem/internal/beaninfo/common/FeatureAttributeValue.java
index 9d040b72c..e4bc536c4 100644
--- a/plugins/org.eclipse.jem.beaninfo/beaninfoCommon/org/eclipse/jem/internal/beaninfo/common/FeatureAttributeValue.java
+++ b/plugins/org.eclipse.jem.beaninfo/beaninfoCommon/org/eclipse/jem/internal/beaninfo/common/FeatureAttributeValue.java
@@ -10,7 +10,7 @@
*******************************************************************************/
/*
* $RCSfile: FeatureAttributeValue.java,v $
- * $Revision: 1.9 $ $Date: 2005/12/14 21:21:02 $
+ * $Revision: 1.10 $ $Date: 2006/02/06 17:14:43 $
*/
package org.eclipse.jem.internal.beaninfo.common;
@@ -47,6 +47,7 @@ public class FeatureAttributeValue implements Serializable {
private transient Object value;
private transient Object internalValue;
+ private boolean implicitValue;
private static final long serialVersionUID = 1105717634844L;
/**
@@ -60,6 +61,10 @@ public class FeatureAttributeValue implements Serializable {
public FeatureAttributeValue(String initString) {
// Use the init string to create the value. This is our
// own short-hand for this.
+ if (initString.startsWith(IMPLICIT)) {
+ setImplicitValue(true);
+ initString = initString.substring(IMPLICIT.length());
+ }
value = parseString(initString);
}
@@ -72,7 +77,7 @@ public class FeatureAttributeValue implements Serializable {
public FeatureAttributeValue() {
}
-
+
/**
* @return Returns the value.
*
@@ -125,7 +130,11 @@ public class FeatureAttributeValue implements Serializable {
public String toString() {
if (value == null)
return super.toString();
- return makeString(value);
+ StringBuffer out = new StringBuffer(100);
+ if (isImplicitValue())
+ out.append(IMPLICIT);
+ makeString(value, out);
+ return out.toString();
}
@@ -166,10 +175,11 @@ public class FeatureAttributeValue implements Serializable {
makeString(value, out);
return out.toString();
}
-
+
private static final Pattern QUOTE = Pattern.compile("\""); // Pattern for searching for double-quote. Make it static so don't waste time compiling each time. //$NON-NLS-1$
private static final String NULL = "null"; // Output string for null //$NON-NLS-1$
private static final String INVALID = "INV"; // Invalid object flag. //$NON-NLS-1$
+ private static final String IMPLICIT = "implicit,"; // Implicit flag. //$NON-NLS-1$
/*
* Used for recursive building of the string.
@@ -746,5 +756,30 @@ public class FeatureAttributeValue implements Serializable {
} else
return val; // It is the value itself.
}
+
+
+ /**
+ * Is this FeatureAttributeValue an implicit value, i.e. one that came from
+ * BeanInfo Introspection and not from an override file.
+ *
+ * @return Returns the implicitValue.
+ *
+ * @since 1.2.0
+ */
+ public boolean isImplicitValue() {
+ return implicitValue;
+ }
+
+
+ /**
+ * Set the implicit value flag.
+ * @param implicitValue The implicitValue to set.
+ *
+ * @see #isImplicitValue()
+ * @since 1.2.0
+ */
+ public void setImplicitValue(boolean implicitValue) {
+ this.implicitValue = implicitValue;
+ }
}
diff --git a/plugins/org.eclipse.jem.beaninfo/vm_beaninfovm/org/eclipse/jem/beaninfo/vm/BaseBeanInfo.java b/plugins/org.eclipse.jem.beaninfo/vm_beaninfovm/org/eclipse/jem/beaninfo/vm/BaseBeanInfo.java
index 4cfc8de21..e5392dd8c 100644
--- a/plugins/org.eclipse.jem.beaninfo/vm_beaninfovm/org/eclipse/jem/beaninfo/vm/BaseBeanInfo.java
+++ b/plugins/org.eclipse.jem.beaninfo/vm_beaninfovm/org/eclipse/jem/beaninfo/vm/BaseBeanInfo.java
@@ -12,7 +12,7 @@ package org.eclipse.jem.beaninfo.vm;
/*
* $RCSfile: BaseBeanInfo.java,v $
- * $Revision: 1.11 $ $Date: 2005/10/18 15:32:19 $
+ * $Revision: 1.12 $ $Date: 2006/02/06 17:14:43 $
*/
import java.awt.Image;
@@ -195,7 +195,7 @@ public abstract class BaseBeanInfo extends SimpleBeanInfo implements IBaseBeanIn
* @param cls
* bean for which the bean descriptor is being created.
* @param args
- * arg pairs, [0] keyword, [1] value, [2] keyword, [3] value, etc.
+ * arg pairs, [0] keyword, [1] value, [2] keyword, [3] value, etc. or null if no args
* @return new bean descriptor
*
* @since 1.1.0
@@ -203,22 +203,25 @@ public abstract class BaseBeanInfo extends SimpleBeanInfo implements IBaseBeanIn
public static BeanDescriptor createBeanDescriptor(Class cls, Object[] args) {
Class customizerClass = null;
- /* Find the specified customizerClass */
- for (int i = 0; i < args.length; i += 2) {
- if (CUSTOMIZERCLASS.equals(args[i])) {
- customizerClass = (Class) args[i + 1];
- break;
+ if (args != null) {
+ /* Find the specified customizerClass */
+ for (int i = 0; i < args.length; i += 2) {
+ if (CUSTOMIZERCLASS.equals(args[i])) {
+ customizerClass = (Class) args[i + 1];
+ break;
+ }
}
}
BeanDescriptor bd = new BeanDescriptor(cls, customizerClass);
- for (int i = 0; i < args.length; i += 2) {
- String key = (String) args[i];
- Object value = args[i + 1];
- setFeatureDescriptorValue(bd, key, value);
- }
-
+ if (args != null) {
+ for (int i = 0; i < args.length; i += 2) {
+ String key = (String) args[i];
+ Object value = args[i + 1];
+ setFeatureDescriptorValue(bd, key, value);
+ }
+ }
return bd;
}
@@ -230,7 +233,7 @@ public abstract class BaseBeanInfo extends SimpleBeanInfo implements IBaseBeanIn
* @param name
* Name of event set
* @param args
- * arg pairs, [0] keyword, [1] value, [2] keyword, [3] value, etc.
+ * arg pairs, [0] keyword, [1] value, [2] keyword, [3] value, etc. or null if no args.
* @param lmds
* array of MethodDescriptors defining the listener methods
* @param listenerType
@@ -272,16 +275,17 @@ public abstract class BaseBeanInfo extends SimpleBeanInfo implements IBaseBeanIn
new Object[] { name}));
}
;
- // set the event set descriptor properties
- for (int i = 0; i < args.length; i += 2) {
- String key = (String) args[i];
- Object value = args[i + 1];
- if (INDEFAULTEVENTSET.equals(key)) {
- esd.setInDefaultEventSet(((Boolean) value).booleanValue());
- } else
- setFeatureDescriptorValue(esd, key, value);
- }
-
+ if (args != null) {
+ // set the event set descriptor properties
+ for (int i = 0; i < args.length; i += 2) {
+ String key = (String) args[i];
+ Object value = args[i + 1];
+ if (INDEFAULTEVENTSET.equals(key)) {
+ esd.setInDefaultEventSet(((Boolean) value).booleanValue());
+ } else
+ setFeatureDescriptorValue(esd, key, value);
+ }
+ }
return esd;
}
@@ -293,7 +297,7 @@ public abstract class BaseBeanInfo extends SimpleBeanInfo implements IBaseBeanIn
* @param name
* name of the method.
* @param args
- * arg pairs, [0] keyword, [1] value, [2] keyword, [3] value, etc.
+ * arg pairs, [0] keyword, [1] value, [2] keyword, [3] value, etc. or null if no args
* @param params
* parameter descriptors or null
if no parameter descriptors.
* @param paramTypes
@@ -323,12 +327,14 @@ public abstract class BaseBeanInfo extends SimpleBeanInfo implements IBaseBeanIn
new Object[] { name}));
}
;
- // set the method properties
- for (int i = 0; i < args.length; i += 2) {
- String key = (String) args[i];
- Object value = args[i + 1];
- setFeatureDescriptorValue(md, key, value);
- }
+ if (args != null) {
+ // set the method properties
+ for (int i = 0; i < args.length; i += 2) {
+ String key = (String) args[i];
+ Object value = args[i + 1];
+ setFeatureDescriptorValue(md, key, value);
+ }
+ }
return md;
}
@@ -383,7 +389,7 @@ public abstract class BaseBeanInfo extends SimpleBeanInfo implements IBaseBeanIn
* @param name
* name of parameter
* @param args
- * arg pairs, [0] keyword, [1] value, [2] keyword, [3] value, etc.
+ * arg pairs, [0] keyword, [1] value, [2] keyword, [3] value, etc. or null if no args
* @return new parameter descriptor
*
* @since 1.1.0
@@ -399,13 +405,14 @@ public abstract class BaseBeanInfo extends SimpleBeanInfo implements IBaseBeanIn
;
// set the name
pd.setName(name);
- // set the method properties
- for (int i = 0; i < args.length; i += 2) {
- String key = (String) args[i];
- Object value = args[i + 1];
- setFeatureDescriptorValue(pd, key, value);
- }
-
+ if (args != null) {
+ // set the method properties
+ for (int i = 0; i < args.length; i += 2) {
+ String key = (String) args[i];
+ Object value = args[i + 1];
+ setFeatureDescriptorValue(pd, key, value);
+ }
+ }
return pd;
}
@@ -425,7 +432,7 @@ public abstract class BaseBeanInfo extends SimpleBeanInfo implements IBaseBeanIn
* no getter or setter.
* @param name
* @param field
- * @param args
+ * @param args arg pairs, [0] keyword, [1] value, [2] keyword, [3] value, etc. or null if no args
* @return
*
* @since 1.1.0
@@ -494,7 +501,7 @@ public abstract class BaseBeanInfo extends SimpleBeanInfo implements IBaseBeanIn
* @param cls
* The class to use to find read/write methods in args. If no read/write methods specified, then this may be null.
* @param args
- * The arguments to override from fromPD. arg pairs, [0] keyword, [1] value, [2] keyword, [3] value, etc.
+ * The arguments to override from fromPD. arg pairs, [0] keyword, [1] value, [2] keyword, [3] value, etc. or null if none to override
*/
public void replacePropertyDescriptor(PropertyDescriptor[] pds, String name, Class cls, Object[] args) {
PropertyDescriptor pd = null;
@@ -566,60 +573,64 @@ public abstract class BaseBeanInfo extends SimpleBeanInfo implements IBaseBeanIn
}
private static void applyPropertyArguments(PropertyDescriptor pd, Object[] args, Class cls) {
- for (int i = 0; i < args.length; i += 2) {
- String key = (String) args[i];
- Object value = args[i + 1];
-
- if (!applyCommonPropertyArguments(pd, key, value)) {
- if (READMETHOD.equals(key)) {
- String methodName = (String) value;
- Method method;
- try {
- method = cls.getMethod(methodName, new Class[0]);
- pd.setReadMethod(method);
- } catch (Exception e) {
- throwError(e, java.text.MessageFormat.format(RESBUNDLE.getString("{0}_no_read_method_EXC_"), //$NON-NLS-1$
- new Object[] { cls, methodName}));
- }
- } else if (WRITEMETHOD.equals(key)) {
- String methodName = (String) value;
- try {
- if (methodName == null) {
- pd.setWriteMethod(null);
- } else {
- Method method;
- Class type = pd.getPropertyType();
- method = cls.getMethod(methodName, new Class[] { type});
- pd.setWriteMethod(method);
+ if (args != null) {
+ for (int i = 0; i < args.length; i += 2) {
+ String key = (String) args[i];
+ Object value = args[i + 1];
+
+ if (!applyCommonPropertyArguments(pd, key, value)) {
+ if (READMETHOD.equals(key)) {
+ String methodName = (String) value;
+ Method method;
+ try {
+ method = cls.getMethod(methodName, new Class[0]);
+ pd.setReadMethod(method);
+ } catch (Exception e) {
+ throwError(e, java.text.MessageFormat.format(RESBUNDLE.getString("{0}_no_read_method_EXC_"), //$NON-NLS-1$
+ new Object[] { cls, methodName}));
+ }
+ } else if (WRITEMETHOD.equals(key)) {
+ String methodName = (String) value;
+ try {
+ if (methodName == null) {
+ pd.setWriteMethod(null);
+ } else {
+ Method method;
+ Class type = pd.getPropertyType();
+ method = cls.getMethod(methodName, new Class[] { type});
+ pd.setWriteMethod(method);
+ }
+ } catch (Exception e) {
+ throwError(e, java.text.MessageFormat.format(RESBUNDLE.getString("{0}_no_write_method_EXC_"), //$NON-NLS-1$
+ new Object[] { cls, methodName}));
}
- } catch (Exception e) {
- throwError(e, java.text.MessageFormat.format(RESBUNDLE.getString("{0}_no_write_method_EXC_"), //$NON-NLS-1$
- new Object[] { cls, methodName}));
+ } else {
+ // arbitrary value
+ setFeatureDescriptorValue(pd, key, value);
}
- } else {
- // arbitrary value
- setFeatureDescriptorValue(pd, key, value);
}
}
}
}
private static void applyFieldArguments(PropertyDescriptor pd, Object[] args) {
- for (int i = 0; i < args.length; i += 2) {
- String key = (String) args[i];
- Object value = args[i + 1];
-
- if (!applyCommonPropertyArguments(pd, key, value)) {
- if (READMETHOD.equals(key)) {
- // ignored for field.
- } else if (WRITEMETHOD.equals(key)) {
- // ignored for field.
- } else {
- // arbitrary value
- setFeatureDescriptorValue(pd, key, value);
+ if (args != null) {
+ for (int i = 0; i < args.length; i += 2) {
+ String key = (String) args[i];
+ Object value = args[i + 1];
+
+ if (!applyCommonPropertyArguments(pd, key, value)) {
+ if (READMETHOD.equals(key)) {
+ // ignored for field.
+ } else if (WRITEMETHOD.equals(key)) {
+ // ignored for field.
+ } else {
+ // arbitrary value
+ setFeatureDescriptorValue(pd, key, value);
+ }
}
}
- }
+ }
}
/**
--
cgit v1.2.3