diff options
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component')
11 files changed, 0 insertions, 2338 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/AbstractVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/AbstractVisitor.java deleted file mode 100644 index a18b04fc0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/AbstractVisitor.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.runtime.internal.model.component; - -/** - * Implemented by visitors - * - * @author cbateman - * - */ -public abstract class AbstractVisitor -{ - /** - * A policy to control visitation - */ - protected final VisitationPolicy _policy; - - /** - * @param policy - */ - protected AbstractVisitor(final VisitationPolicy policy) - { - super(); - _policy = policy; - } - - /** - * @param object - */ - public abstract void visit(Object object); - - /** - * @return the visitation policy - */ - public VisitationPolicy getPolicy() - { - return _policy; - } - - /** - * A policy that allows a visitor to configure how it will visit a tree. - * - */ - public static final class VisitationPolicy - { - /** - * indicates pre-order, parent first traversal (root visited first) - */ - public static final int VISIT_PARENT_FIRST = 0; // pre-order - // tree - // visit - /** - * indicates post-order, children first traveral (root visited last) - */ - public static final int VISIT_CHILDREN_FIRST = 1; // post-order - // tree - // visit - /** - * A default parent first policy - */ - public final static VisitationPolicy ParentFirstPolicy = new VisitationPolicy( - VISIT_PARENT_FIRST); - /** - * A default children first policy - */ - public final static VisitationPolicy ChildrenFirstPolicy = new VisitationPolicy( - VISIT_CHILDREN_FIRST); - - private final int _ordering; - - /** - * @param ordering - */ - public VisitationPolicy(final int ordering) - { - _ordering = ordering; - } - - /** - * @return the ordering - */ - public final int getOrdering() - { - return _ordering; - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/ComponentFactory.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/ComponentFactory.java deleted file mode 100644 index a3c376252..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/ComponentFactory.java +++ /dev/null @@ -1,399 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.runtime.internal.model.component; - -import java.util.Map; - -import org.eclipse.jst.jsf.common.runtime.internal.model.bean.DataModelInfo; -import org.eclipse.jst.jsf.common.runtime.internal.model.behavioural.IActionSource2Info; -import org.eclipse.jst.jsf.common.runtime.internal.model.behavioural.IActionSourceInfo; -import org.eclipse.jst.jsf.common.runtime.internal.model.behavioural.IEditableValueHolderInfo; -import org.eclipse.jst.jsf.common.runtime.internal.model.behavioural.INamingContainerInfo; -import org.eclipse.jst.jsf.common.runtime.internal.model.behavioural.IValueHolderInfo; -import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ConverterDecorator; -import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.FacetDecorator; -import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ValidatorDecorator; -import org.eclipse.jst.jsf.common.runtime.internal.model.event.IActionListenerInfo; -import org.eclipse.jst.jsf.common.runtime.internal.model.event.IValueChangeListenerInfo; - -/** - * Factory for creating component related objects. - * - * @author cbateman - * - */ -public class ComponentFactory -{ - - /** - * The key for the standard ValueHolder adapter interface - */ - public final static Class VALUE_HOLDER = IValueHolderInfo.class; - /** - * The key for the standard EditableValueHolder adapter interface - */ - public final static Class EDITABLE_VALUE_HOLDER = IEditableValueHolderInfo.class; - /** - * The key for the standard ActionSource adapter interface - */ - public final static Class ACTION_SOURCE = IActionSourceInfo.class; - /** - * The key for the standard ActionSource2 adapter interface - */ - public final static Class ACTION_SOURCE2 = IActionSource2Info.class; - /** - * The key for the standard NamingContainer adapter interface - */ - public final static Class NAMING_CONTAINER = INamingContainerInfo.class; - - /** - * The key for the standard Converter decorator - */ - public final static Class CONVERTER = ConverterDecorator.class; - /** - * The key for the standard Facet decorator - */ - public final static Class FACET = FacetDecorator.class; - /** - * The key for the standard Validator decorator - */ - public final static Class VALIDATOR = ValidatorDecorator.class; - /** - * The key for the standard ValueChangeListener decorator - */ - public final static Class VALUE_CHANGE_LISTENER = IValueChangeListenerInfo.class; - /** - * The key for the standard ActionListener decorator - */ - public final static Class ACTION_LISTENER = IActionListenerInfo.class; - - /** - * Base class name for UIInput's - */ - public final static String BASE_CLASS_UIINPUT = "javax.faces.component.UIInput"; //$NON-NLS-1$ - /** - * Base class name for UIOutput's - */ - public final static String BASE_CLASS_UIOUTPUT = "javax.faces.component.UIOutput"; //$NON-NLS-1$ - /** - * Base class name for UICommand's - */ - public final static String BASE_CLASS_UICOMMAND = "javax.faces.component.UICommand"; //$NON-NLS-1$ - /** - * Base class name for UIData's - */ - public final static String BASE_CLASS_UIDATA = "javax.faces.component.UIData"; //$NON-NLS-1$ - /** - * Base class name for UIForm's - */ - public final static String BASE_CLASS_UIFORM = "javax.faces.component.UIForm"; //$NON-NLS-1$ - - /** - * Interface name for ValueHolder's - */ - public final static String INTERFACE_VALUEHOLDER = "javax.faces.component.ValueHolder"; //$NON-NLS-1$ - /** - * Interface name for EditableValueHolder's - */ - public final static String INTERFACE_EDITABLEVALUEHOLDER = "javax.faces.component.EditableValueHolder"; //$NON-NLS-1$ - /** - * Interface name for ActionSource's - */ - public final static String INTERFACE_ACTIONSOURCE = "javax.faces.component.ActionSource"; //$NON-NLS-1$ - /** - * Interface name for ActionSource2's - */ - public final static String INTERFACE_ACTIONSOURCE2 = "javax.faces.component.ActionSource2"; //$NON-NLS-1$ - /** - * Interface name for NamingContainer's - */ - public final static String INTERFACE_NAMINGCONTAINER = "javax.faces.component.NamingContainer"; //$NON-NLS-1$ - - /** - * @param id - * @param parent - * @param typeInfo - * @param isRendered - * @return a new component info - */ - public static ComponentInfo createComponentInfo(final String id, - final ComponentInfo parent, final ComponentTypeInfo typeInfo, - final boolean isRendered) - { - return new ComponentInfo(id, parent, typeInfo, isRendered); - } - - /** - * If the rendered attribute isn't set, defaults it. - * - * @param attributes - */ - public static void maybeDefaultRendered(final Map attributes) - { - if (!(attributes.get("rendered") instanceof Boolean)) //$NON-NLS-1$ - { - attributes.put("rendered", Boolean.TRUE); //$NON-NLS-1$ - } - } - - /** - * @param parent - * @param componentTypeInfo - * @param attributes - * @return a new component info - */ - public static ComponentInfo createComponentInfo(final ComponentInfo parent, - final ComponentTypeInfo componentTypeInfo, final Map attributes) - { - maybeDefaultRendered(attributes); - return new ComponentInfo(parent, componentTypeInfo, attributes); - } - - /** - * @param id - * @param parent - * @param typeInfo - * @param editableValueHolder - * @param isRendered - * @return a new UIInputInfo - */ - public static UIInputInfo createUIInputInfo(final String id, - final ComponentInfo parent, final ComponentTypeInfo typeInfo, - final IEditableValueHolderInfo editableValueHolder, - final boolean isRendered) - { - return new UIInputInfo(id, parent, typeInfo, editableValueHolder, - isRendered); - } - - /** - * @param parent - * @param typeInfo - * @param attributes - * @return a new UIInputInfo - */ - public static UIInputInfo createUIInputInfo(final ComponentInfo parent, - final ComponentTypeInfo typeInfo, final Map attributes) - { - maybeDefaultRendered(attributes); - return new UIInputInfo(parent, typeInfo, attributes); - } - - /** - * @param id - * @param parent - * @param typeInfo - * @param valueHolderInfo - * @param isRendered - * @return a new UIOutputInfo - */ - public static UIOutputInfo createUIOutputInfo(final String id, - final ComponentInfo parent, final ComponentTypeInfo typeInfo, - final IValueHolderInfo valueHolderInfo, final boolean isRendered) - { - return new UIOutputInfo(id, parent, typeInfo, valueHolderInfo, - isRendered); - } - - /** - * @param parent - * @param typeInfo - * @param attributes - * @return a new UIOutputInfo - */ - public static UIOutputInfo createUIOutputInfo(final ComponentInfo parent, - final ComponentTypeInfo typeInfo, final Map attributes) - { - maybeDefaultRendered(attributes); - return new UIOutputInfo(parent, typeInfo, attributes); - } - - /** - * @param id - * @param parent - * @param typeInfo - * @param actionSourceInfo - * @param isRendered - * @return a new UICommandInfo - */ - public static UICommandInfo createUICommandInfo(final String id, - final ComponentInfo parent, final ComponentTypeInfo typeInfo, - final IActionSourceInfo actionSourceInfo, final boolean isRendered) - { - return new UICommandInfo(id, parent, typeInfo, isRendered, - actionSourceInfo); - } - - /** - * @param parent - * @param typeInfo - * @param attributes - * @return a new UICommandInfo - */ - public static UICommandInfo createUICommandInfo(final ComponentInfo parent, - final ComponentTypeInfo typeInfo, final Map attributes) - { - maybeDefaultRendered(attributes); - return new UICommandInfo(parent, typeInfo, attributes); - } - - /** - * @param id - * @param parent - * @param typeInfo - * @param isRendered - * @param prependId - * @param submitted - * @return a new UIFormInfo - */ - public static UIFormInfo createUIFormInfo(final String id, - final ComponentInfo parent, final ComponentTypeInfo typeInfo, - final boolean isRendered, final boolean prependId, - final boolean submitted) - { - return new UIFormInfo(id, parent, typeInfo, isRendered, prependId, - submitted); - } - - /** - * @param parent - * @param typeInfo - * @param attributes - * @return a new UIFormInfo - */ - public static UIFormInfo createUIFormInfo(final ComponentInfo parent, - final ComponentTypeInfo typeInfo, final Map attributes) - { - maybeDefaultRendered(attributes); - maybeDefaultPrependId(attributes); - maybeDefaultSubmitted(attributes); - return new UIFormInfo(parent, typeInfo, attributes); - } - - private static void maybeDefaultSubmitted(Map attributes) - { - if (!(attributes.get("submitted") instanceof Boolean)) //$NON-NLS-1$ - { - attributes.put("submitted", Boolean.FALSE); //$NON-NLS-1$ - } - } - - private static void maybeDefaultPrependId(Map attributes) - { - if (!(attributes.get("prependId") instanceof Boolean)) //$NON-NLS-1$ - { - attributes.put("prependId", Boolean.FALSE); //$NON-NLS-1$ - } - } - - /** - * @param id - * @param parent - * @param typeInfo - * @param isRendered - * @param dataModel - * @param first - * @param footer - * @param header - * @param rowCount - * @param rowAvailable - * @param rowData - * @param rowIndex - * @param rows - * @param value - * @param var - * @return a new UIDataInfo - */ - public static UIDataInfo createUIDataInfo(final String id, - final ComponentInfo parent, final ComponentTypeInfo typeInfo, - final boolean isRendered, final DataModelInfo dataModel, - final int first, final ComponentInfo footer, - final ComponentInfo header, final int rowCount, - final boolean rowAvailable, final Object rowData, - final int rowIndex, final int rows, final Object value, - final String var) - { - return new UIDataInfo(id, parent, typeInfo, isRendered, dataModel, - first, footer, header, rowCount, rowAvailable, rowData, - rowIndex, rows, value, var); - } - - /** - * @param parent - * @param typeInfo - * @param attributes - * @return the UIDataInfo - */ - public static UIDataInfo createUIDataInfo(final ComponentInfo parent, - final ComponentTypeInfo typeInfo, final Map attributes) - { - maybeDefaultRendered(attributes); - maybeDefaultFirst(attributes); - maybeDefaultRowCount(attributes); - maybeDefaultRowAvailable(attributes); - maybeDefaultRowIndex(attributes); - maybeDefaultRows(attributes); - maybeDefaultVar(attributes); - return new UIDataInfo(parent, typeInfo, attributes); - } - - - private static final Integer ZERO = new Integer(0); - private static final Integer MINUS_ONE = new Integer(-1); - - private static void maybeDefaultFirst(Map attributes) - { - if (!(attributes.get("first") instanceof Integer)) //$NON-NLS-1$ - { - attributes.put("first", ZERO); //$NON-NLS-1$ - } - } - - private static void maybeDefaultRowCount(Map attributes) - { - if (!(attributes.get("rowCount") instanceof Integer)) //$NON-NLS-1$ - { - attributes.put("rowCount", MINUS_ONE); //$NON-NLS-1$ - } - } - - private static void maybeDefaultRowAvailable(Map attributes) - { - if (! (attributes.get("rowAvailable") instanceof Boolean)) //$NON-NLS-1$ - { - attributes.put("rowAvailable", Boolean.FALSE); //$NON-NLS-1$ - } - } - - private static void maybeDefaultRowIndex(Map attributes) - { - if (! (attributes.get("rowIndex") instanceof Integer)) //$NON-NLS-1$ - { - attributes.put("rowIndex", MINUS_ONE); //$NON-NLS-1$ - } - } - - private static void maybeDefaultRows(Map attributes) - { - if (! (attributes.get("rows") instanceof Integer)) //$NON-NLS-1$ - { - attributes.put("rows", ZERO); //$NON-NLS-1$ - } - } - - private static void maybeDefaultVar(Map attributes) - { - if (! (attributes.get("var") instanceof String)) //$NON-NLS-1$ - { - attributes.put("var", "** default variable **"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/ComponentInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/ComponentInfo.java deleted file mode 100644 index 12619e4b1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/ComponentInfo.java +++ /dev/null @@ -1,930 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.runtime.internal.model.component; - -import java.beans.BeanInfo; -import java.beans.IntrospectionException; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; -import java.io.Serializable; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Map.Entry; - -import org.eclipse.jst.jsf.common.runtime.internal.model.ViewObject; -import org.eclipse.jst.jsf.common.runtime.internal.model.component.AbstractVisitor.VisitationPolicy; -import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.FacetDecorator; - -/** - * Models a basic UI component instance - * - * TODO: should implement a visitor pattern to traverse component trees - * - * @author cbateman - * - */ -public class ComponentInfo extends ViewObject implements Serializable, - IVisitable -{ - /** - * serializable id - */ - private static final long serialVersionUID = 2517204356825585699L; - - private final static int DEFAULT_ARRAY_SIZE = 4; - - private transient BeanPropertyManager _beanPropertyManager; - /** - * Encapsulates all of the data for the view object - */ - protected final ComponentInfoData _data; - - // initialized - // by - // getBeanProperties - - /** - * @param id - * @param parent - * @param componentTypeInfo - * @param isRendered - */ - protected ComponentInfo(final String id, final ComponentInfo parent, - final ComponentTypeInfo componentTypeInfo, final boolean isRendered) - { - super(new ComponentInfoData(id, parent, componentTypeInfo, isRendered)); - _data = (ComponentInfoData) super.getData(); - - final Set propExclude = new HashSet(); - propExclude.add("attributeNames"); - propExclude.add("componentTypeInfo"); - propExclude.add("valueChangeListeners"); - propExclude.add("visitableChildren"); - - _beanPropertyManager = new BeanPropertyManager(this, propExclude); - } - - /** - * @param data - */ - protected ComponentInfo(final ComponentInfoData data) - { - super(data); - _data = data; - } - - /** - * Construct a new component info using the attributes keyed by name in - * attributes to set values. The names must match the corresponding bean - * property names. Primitives should be wrapped in their corresponding - * object types. Exceptions will be thrown if there is a type mismatch on an - * expected type. Number will be used for all numeric primitive wrappers an - * the corresponding "to" will be called. - * - * @param parent - * @param componentTypeInfo - * @param attributes - * @throws ClassCastException - * if an attribute's value doesn't match the expected type - * @throws NullPointerException - * if an attribute value is null for a value whose type is - * expected to be primitive - * @throws IllegalArgumentException - * if attributes does not contain a required key. - */ - protected ComponentInfo(final ComponentInfo parent, - final ComponentTypeInfo componentTypeInfo, final Map attributes) - { - this(getStringProperty("id", attributes, false), parent, //$NON-NLS-1$ - componentTypeInfo, getBooleanProperty("rendered", attributes, false)); //$NON-NLS-1$ - } - - /** - * @param key - * @param attributes - * @param mandatory - * @return the value in attributes at location key, forcing a - * ClassCastException if it turns out not to be a String. - * @throws ClassCastException - * if the attribute for key is not a String - * @throws IllegalArgumentException - * if the attribute for key is null but mandatory is true. - */ - protected static String getStringProperty(final String key, - final Map attributes, final boolean mandatory) - { - final Object value = attributes.get(key); - - if (mandatory && value == null) - { - throw new IllegalArgumentException(key - + " is a mandatory attribute"); //$NON-NLS-1$ - } - return (String) value; - } - - /** - * @param key - * @param attributes - * @param mandatory - * - * @return the value in attributes at location, forcing a ClassCastExceptio - * if it is not a Boolean and mandatory. returns false if no value - * and not mandatory - * @throws IllegalArgumentException - * if key is not found and value is mandatory - */ - protected static boolean getBooleanProperty(final String key, - final Map attributes, final boolean mandatory) - { - final Boolean value = (Boolean) attributes.get(key); - - if (value == null) - { - if (mandatory) - { - throw new IllegalArgumentException(key + "is mandatory"); //$NON-NLS-1$ - } - return false; - } - - return value.booleanValue(); - } - - /** - * @param key - * @param attributes - * @return the integer property for key. Casts the value to Number and calls - * Number.intValue(). 0 if no value. - */ - protected static int getIntegerProperty(final String key, - final Map attributes) - { - final Number value = (Number) attributes.get(key); - - if (value == null) - { - return 0; - } - - return value.intValue(); - } - - /** - * @param key - * @param attributes - * @return the component info value from attributes - */ - protected static ComponentInfo getComponentProperty(final String key, - final Map attributes) - { - return (ComponentInfo) attributes.get(key); - } - - /** - * @return the id - */ - public final String getId() - { - return _data.getId(); - } - - /** - * @return the component type info - */ - public final ComponentTypeInfo getComponentTypeInfo() - { - return _data.getComponentTypeInfo(); - } - - /** - * Pre-condition: isModifiable() == true Post-condition: getChildren() will - * return an empty list. - */ - protected final void clearChildren() - { - _data.getChildren().clear(); - } - - /** - * @return the children. List is unmodifiable. List contains all children - * including facets. - */ - public final List/* <ComponentInfo> */getChildren() - { - if (_data.isProtected()) - { - return _data.getChildren(); - } - return Collections.unmodifiableList(_data.getChildren()); - } - - /** - * Get the sub-set of {@link #getChildren()} that are facets. This is a - * convenience method for {@link #getDecorators(Class)} - * - * @return all component children that are facets - */ - public final List getFacets() - { - return getDecorators(ComponentFactory.FACET); - } - - /** - * @param childComponent - */ - public final void addChild(final ComponentInfo childComponent) - { - if (childComponent == this) - { - throw new IllegalArgumentException( - "A component cannot be its own child"); //$NON-NLS-1$ - } - _data.addChild(childComponent); - // we need to reset the child's parent to me - childComponent.setParent(this); - } - - /** - * @param parent - */ - public final void setParent(ComponentInfo parent) - { - _data.setParent(parent); - } - - /** - * @param name - * @param facetComponent - */ - public final void addFacet(final String name, - final ComponentInfo facetComponent) - { - addChild(facetComponent); - addDecorator(new FacetDecorator(name, facetComponent)); - } - - /** - * @param component - * @return if component corresponds to a facet of this component, returns - * the name of that facet. Returns null if not found. - */ - public final String getFacetName(final ComponentInfo component) - { - if (component == null) - { - return null; - } - - final List facets = getDecorators(ComponentFactory.FACET); - - for (final Iterator it = facets.iterator(); it.hasNext();) - { - final FacetDecorator facet = (FacetDecorator) it.next(); - if (component == facet.getDecorates()) - { - return facet.getName(); - } - } - - // component is not a facet - return null; - } - - /** - * @param name - * @return if this has a facet called name, then returns it's single root - * component. - */ - public final ComponentInfo getFacet(final String name) - { - if (name == null) - { - return null; - } - - final List facets = getDecorators(ComponentFactory.FACET); - - for (final Iterator it = facets.iterator(); it.hasNext();) - { - final FacetDecorator facet = (FacetDecorator) it.next(); - if (name.equals(facet.getName())) - { - return facet.getDecorates(); - } - } - - // not found - return null; - } - - public String toString() - { - final String parentId = getParent() != null ? getParent().getId() - : "null"; //$NON-NLS-1$ - String toString = getMostSpecificComponentName() + ": id=" //$NON-NLS-1$ - + _data.getId() + ", parentId: " + parentId + ", family=" //$NON-NLS-1$ //$NON-NLS-2$ - + getComponentTypeInfo().getComponentFamily() + ", render=" //$NON-NLS-1$ - + getComponentTypeInfo().getRenderFamily() + ", rendered=" //$NON-NLS-1$ - + isRendered(); - - // use bean introspection to dump child properties - if (this.getClass() != ComponentInfo.class) - { - toString += dumpProperties(); - } - - return toString; - } - - private String dumpProperties() - { - String properties = ""; //$NON-NLS-1$ - try - { - final BeanInfo beanInfo = Introspector.getBeanInfo(this.getClass(), - ComponentInfo.class); - - final PropertyDescriptor[] descriptors = beanInfo - .getPropertyDescriptors(); - for (int i = 0; i < descriptors.length; i++) - { - final PropertyDescriptor desc = descriptors[i]; - final String name = desc.getName(); - final Object valueObj = desc.getValue(name); - final String value = valueObj != null ? valueObj.toString() - : "null"; //$NON-NLS-1$ - properties += ", " + name + "=" + value; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - catch (final IntrospectionException e) - { - return "Error introspecting bean: " + e.getLocalizedMessage(); //$NON-NLS-1$ - } - - return properties; - } - - /** - * @return used for toString. Clients should not use. - */ - protected String getMostSpecificComponentName() - { - return "UIComponent"; //$NON-NLS-1$ - } - - /** - * @return the parent of this component or null. - */ - public final ComponentInfo getParent() - { - return _data.getParent(); - } - - /** - * @return the rendered flag - */ - public final boolean isRendered() - { - return _data.isRendered(); - } - - public synchronized void addAdapter(final Class adapterType, - final Object adapter) - { - super.addAdapter(adapterType, adapter); - - // force an update on the next call to getBeanProperties - _beanPropertyManager.reset(); - } - - public synchronized Object removeAdapter(final Class adapterType) - { - final Object removed = super.removeAdapter(adapterType); - - _beanPropertyManager.reset(); - - return removed; - } - - /** - * @return the set of all bean property names for this component. The set is - * unmodifiable and will throw exceptions if modification is - * attempted. - */ - protected final Map/* <String, ComponentBeanProperty> */getBeanProperties() - { - return Collections.unmodifiableMap(_beanPropertyManager - .getBeanProperties()); - } - - /** - * @author cbateman - * - */ - public static class ComponentInfoData extends ViewObjectData - { - /** - * - */ - private static final long serialVersionUID = 5052732412917986062L; - /** - * the component id - */ - private final String _id; - /** - * the component's parent or null if none - */ - private ComponentInfo _parent; - - /** - * the type info for this component - */ - protected final ComponentTypeInfo _componentTypeInfo; - /** - * the rendered flage - */ - protected final boolean _isRendered; - - private List /* <ComponentInfo> */_children = new ArrayList( - DEFAULT_ARRAY_SIZE); - - /** - * @param id - * @param parent - * @param componentTypeInfo - * @param isRendered - */ - public ComponentInfoData(final String id, ComponentInfo parent, - ComponentTypeInfo componentTypeInfo, boolean isRendered) - { - super(false); - _id = id; - _parent = parent; - _componentTypeInfo = componentTypeInfo; - _isRendered = isRendered; - } - - /** - * @param childComponent - */ - protected void addChild(ComponentInfo childComponent) - { - enforceProtection(); - - getChildren().add(childComponent); - } - - /** - * @return the modifiable list of children - */ - protected final List/* <ComponentInfo> */getChildren() - { - return _children; - } - - protected void doBeforeProtecting() - { - super.doBeforeProtecting(); - // compact the children array list - if (_children.size() > 0) - { - _children = Collections.unmodifiableList(_children); - } - else - { - _children = Collections.EMPTY_LIST; - } - } - - /** - * @return the isRendered flag - */ - protected final boolean isRendered() - { - return _isRendered; - } - - /** - * @return the component type info flag - */ - protected final ComponentTypeInfo getComponentTypeInfo() - { - return _componentTypeInfo; - } - - /** - * @return the parent or null if no parent - */ - protected final ComponentInfo getParent() - { - return _parent; - } - - /** - * @param parent - */ - protected final void setParent(ComponentInfo parent) - { - enforceProtection(); - _parent = parent; - } - - /** - * @return the component id - */ - protected final String getId() - { - return _id; - } - } - - /** - * This is similar to the runtime getAttributes().get(name) call. The reason - * we don't implement a Map of all attribute values is that the implicit - * property structure can change at any time due to add/removeAdapter. To - * get all attributes known for a component, instead use: - * - * The synchronized block is advised to protect against concurrent - * modification exceptions on the keySet iterator. - * - * @param name - * - * @return the value of the attribute or null if none. - * - */ - public synchronized ComponentBeanProperty getAttribute(final String name) - { - return (ComponentBeanProperty) getBeanProperties().get(name); - } - - /** - * @return the set of valid attribute names. The Set is not modifiable. - */ - public synchronized Set/* <String> */getAttributeNames() - { - return getBeanProperties().keySet(); - } - - /** - * Stores a bean property descriptor along information about which - * implementation class declares it and what key to pass to getAdapter() in - * order to get it. - * - */ - public final static class ComponentBeanProperty - { - private final PropertyDescriptor _propertyDescriptor; - private final Object _declaringImplementation; - private final Class _adapterKeyClass; - - // only instantiable locally - private ComponentBeanProperty(Class adapterKeyClass, - Object declaringImplementationClass, - PropertyDescriptor propertyDescriptor) - { - super(); - _adapterKeyClass = adapterKeyClass; - _declaringImplementation = declaringImplementationClass; - _propertyDescriptor = propertyDescriptor; - } - - /** - * @return the value of property - */ - public final Object getValue() - { - final Method method = _propertyDescriptor.getReadMethod(); - if (method != null) - { - try - { - method.setAccessible(true); - return method.invoke(_declaringImplementation, - new Object[0]); - } - catch (IllegalArgumentException e) - { - e.printStackTrace(); - } - catch (IllegalAccessException e) - { - e.printStackTrace(); - } - catch (InvocationTargetException e) - { - e.printStackTrace(); - } - } - // if any step fails, return null - return null; - } - - /** - * @return the property descriptor - */ - public final PropertyDescriptor getPropertyDescriptor() - { - return _propertyDescriptor; - } - - /** - * @return the implemenation - */ - public final Object getDeclaringImplementationClass() - { - return _declaringImplementation; - } - - /** - * @return the adapter class for the interface that the declaring - * implementation is providing the impl for - */ - public final Class getAdapterKeyClass() - { - return _adapterKeyClass; - } - } - - /** - * Manages bean property information for a component - * - * @author cbateman - * - */ - protected final static class BeanPropertyManager - { - /** - * a map of the bean property names exposed by this component including - * all those added by addAdapter(). - * - * this is synthetic based the class definition and installed adapters - * so as long that info is available, no need to serialize. - */ - protected transient Map /* - * <String, - * ComponentBeanProperty> - */_beanProperties; // lazily - private final transient ComponentInfo _component; - private final transient Set _excludeNames; - - /** - * @param component - * @param excludeNames - */ - protected BeanPropertyManager(final ComponentInfo component, - final Set excludeNames) - { - _component = component; - _excludeNames = excludeNames; - } - - /** - * Will throw exception of the calling thread already holds the "this" - * monitor lock. This is to ensure that caller always acquires locks in - * appropriate order to prevent deadlock. - * - * @return the internal set of bean properties. This Set may be modified - * internally. - */ - public Map getBeanProperties() - { - if (Thread.holdsLock(this)) - { - throw new IllegalStateException( - "Must not already own this lock"); //$NON-NLS-1$ - } - - // must always acquire component lock first to prevent deadlock - synchronized (_component) - { - synchronized (this) - { - if (_beanProperties == null) - { - _beanProperties = calculateAllBeanPropNames(ViewObject.class); - } - - return _beanProperties; - } - } - } - - /** - * Will throw exception if the calling thread already holds the "this" - * monitor lock. This is to ensure that caller always acquires locks in - * appropriate order to prevent deadlock. - * - * Clears the internal map and sets to null. This will force it to be - * completely new built on the next call to getBeanProperties - */ - public void reset() - { - if (Thread.holdsLock(this)) - { - throw new IllegalStateException( - "Must not already own this lock"); //$NON-NLS-1$ - } - - // must always acquire component lock first to prevent deadlock - synchronized (_component) - { - synchronized (this) - { - if (_beanProperties != null) - { - _beanProperties.clear(); - _beanProperties = null; - } - } - } - } - - /** - * @param stopClass - * @return a synchronized map of all bean property names on this class - * up to stopClass, as well as all adapter property names (as - * though this really implemented them). - */ - private Map calculateAllBeanPropNames(final Class stopClass) - { - // use a set to prevents the duplicates - final Map allProperties = new HashMap(); - - { - final Class myClass = _component.getClass(); - final List myProperties = getOrCreateBeanProperties(myClass, - stopClass); - - addToMap(myProperties, _component, myClass, allProperties, _excludeNames); - } - - { - for (final Iterator it = _component.getAdapterMap().entrySet() - .iterator(); it.hasNext();) - { - Map.Entry entry = (Entry) it.next(); - - final Class adapterClass = (Class) entry.getKey(); - final Object declaringClass = entry.getValue(); - // get all props, excluding the ones on Object. - final List props = getOrCreateBeanProperties(adapterClass, - null); - addToMap(props, declaringClass, adapterClass, allProperties, - _excludeNames); - } - } - - return Collections.synchronizedMap(allProperties); - } - - private static void addToMap( - final List/* <ComponentBeanProperty> */addThese, - final Object declaringObject, final Class declaringAdapter, - final Map toMe, - Set excludeNames) - { - for (final Iterator it = addThese.iterator(); it.hasNext();) - { - final PropertyDescriptor desc = (PropertyDescriptor) it.next(); - - if (!toMe.containsKey(desc.getName()) - && !excludeNames.contains(desc.getName())) - { - toMe.put(desc.getName(), new ComponentBeanProperty( - declaringAdapter, declaringObject, desc)); - } - } - } - - /** - * lazily loaded with the local properties (those not defined using - * adapters) - * - * MUST INITIALIZE early so can synchronize on it - */ - private transient static Map /* <Class, List<PropertyDescriptor> */PROPERTY_MAP = new HashMap(); - - /** - * @param startClass - * @param stopClass - * @return a unmodifiable list of properties starting from startClass. - * stopClass is only used if an entry doesn't already exist in - * PROPERTY_MAP for startClass. The method is synchronized on - * the PROPERTY_MAP it updates. - */ - protected static List/* <PropertyDescriptor */getOrCreateBeanProperties( - final Class startClass, final Class stopClass) - { - synchronized (PROPERTY_MAP) - { - List localBeanProps = (List) PROPERTY_MAP.get(startClass); - - if (localBeanProps == null) - { - localBeanProps = calculateBeanProperties(startClass, - stopClass); - PROPERTY_MAP.put(startClass, Collections - .unmodifiableList(localBeanProps)); - } - - return localBeanProps; - } - } - - /** - * @param startClass - * @param stopClass - * @return a List<String> containing all of the bean names between - * startClass and stopClass. Start class must be a descendant - * (sub-class, sub-sub-class etc.) of stopClass. The properties - * on stopClass are excluded from analysis. - */ - private static List/* <PropertyDescriptor> */calculateBeanProperties( - final Class startClass, final Class stopClass) - { - BeanInfo beanInfo; - List names = new ArrayList(); - - try - { - beanInfo = Introspector.getBeanInfo(startClass, stopClass); - final PropertyDescriptor[] descriptors = beanInfo - .getPropertyDescriptors(); - - if (descriptors != null) - { - names = Arrays.asList(descriptors); - } - } - catch (final IntrospectionException e) - { - e.printStackTrace(); - } - return names; - } - - } - - /** - * Visits this node and it's entire tree and makes all nodes protected. - */ - public final void setSubtreeProtected() - { - // lock children first - final ComponentTreeVisitor protectionVisitor = new ComponentTreeVisitor(VisitationPolicy.ChildrenFirstPolicy) - { - public void visit(ComponentInfo component) - { - component.setProtected(); - } - }; - - accept(protectionVisitor); - } - - public void accept(AbstractVisitor visitor) - { - // check policy ordering - if (visitor.getPolicy().getOrdering() == VisitationPolicy.VISIT_PARENT_FIRST) - { - visitor.visit(this); - visitChildren(visitor); - } - else - { - visitChildren(visitor); - visitor.visit(this); - } - } - - private void visitChildren(AbstractVisitor visitor) - { - for (final Iterator it = getVisitableChildren(); it.hasNext();) - { - visitor.visit(it.next()); - } - } - - public Iterator getVisitableChildren() - { - return getChildren().iterator(); - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/ComponentTreeVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/ComponentTreeVisitor.java deleted file mode 100644 index 4bedc7c67..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/ComponentTreeVisitor.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.runtime.internal.model.component; - -/** - * An abstract class sub-classed by objects that wish to apply a Visitor pattern - * type visitation to a component tree. - * - * @author cbateman - * - */ -public abstract class ComponentTreeVisitor extends AbstractVisitor -{ - /** - * @param policy - */ - public ComponentTreeVisitor(final VisitationPolicy policy) - { - super(policy); - } - - /** - * @param component - */ - public abstract void visit(final ComponentInfo component); - - public final void visit(final Object object) - { - visit((ComponentInfo) object); - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/ComponentTypeInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/ComponentTypeInfo.java deleted file mode 100644 index 74c7c9bcb..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/ComponentTypeInfo.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.runtime.internal.model.component; - -import org.eclipse.jst.jsf.common.runtime.internal.model.types.ClassTypeInfo; - -/** - * Type information about a UIComponent - * - * @author cbateman - * - */ -public class ComponentTypeInfo extends ClassTypeInfo -{ - /** - * serializable uid - */ - private static final long serialVersionUID = -311156682935177206L; - /** - * the ComponentType (see JSF spec for definition) - */ - protected final String _componentType; // may be null, since may not be - // known at runtime - /** - * the component family (see JSF spec) - */ - protected final String _componentFamily; - /** - * the render family (see JSF spec) - */ - protected final String _renderFamily; - - /** - * @param componentType - * @param componentClass - * @param componentFamily - * @param renderFamily - */ - public ComponentTypeInfo(final String componentType, - final String componentClass, final String componentFamily, - final String renderFamily) - { - super(componentClass, new String[0], new String[0]); - _componentType = componentType; - _componentFamily = componentFamily; - _renderFamily = renderFamily; - } - - /** - * @param componentType - * @param superClasses - * @param interfaces - * @param componentClass - * @param componentFamily - * @param renderFamily - */ - public ComponentTypeInfo(final String componentType, - final String componentClass, - final String[] superClasses, final String[] interfaces, - final String componentFamily, - final String renderFamily) - { - super(componentClass, superClasses, interfaces); - _componentType = componentType; - _componentFamily = componentFamily; - _renderFamily = renderFamily; - } - - /** - * @return the component type or null if unknown (may not be at runtime) - */ - public final String getComponentType() - { - return _componentType; - } - - /** - * @return the component family - */ - public final String getComponentFamily() - { - return _componentFamily; - } - - /** - * @return the render family - */ - public final String getRenderFamily() - { - return _renderFamily; - } - - public String toString() - { - return "Component Type Info: type = " + _componentType + " family=" + _componentFamily //$NON-NLS-1$ //$NON-NLS-2$ - + " renderer=" + _renderFamily + ", "+super.toString(); //$NON-NLS-1$ //$NON-NLS-2$ - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/IVisitable.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/IVisitable.java deleted file mode 100644 index 6ddd83b34..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/IVisitable.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.runtime.internal.model.component; - -import java.util.Iterator; - -/** - * Implemented by a class that can accept visitors - * - */ -interface IVisitable -{ - /** - * Called on a visitable to accept a visitor - * - * @param visitor - */ - void accept(AbstractVisitor visitor); - - /** - * @return an iterator that returns IVisitable children. - */ - Iterator getVisitableChildren(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/UICommandInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/UICommandInfo.java deleted file mode 100644 index 9ff50f466..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/UICommandInfo.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.runtime.internal.model.component; - -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.jst.jsf.common.runtime.internal.model.behavioural.IActionSource2Info; -import org.eclipse.jst.jsf.common.runtime.internal.model.behavioural.IActionSourceInfo; -import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ActionListenerDecorator; - -/** - * An design time analog of the standard UICommand. - * @author cbateman - * - */ -public class UICommandInfo extends ComponentInfo implements IActionSource2Info { - private final String _actionExpression; - private final String _actionListener; - private final boolean _isImmediate; - - /** - * serialization id - */ - private static final long serialVersionUID = -9025172832535840949L; - - /** - * @param id - * @param parent - * @param componentTypeInfo - * @param isRendered - * @param actionSourceInfo - */ - protected UICommandInfo(final String id, final ComponentInfo parent, - final ComponentTypeInfo componentTypeInfo, - final boolean isRendered, final IActionSourceInfo actionSourceInfo) { - super(id, parent, componentTypeInfo, isRendered); - - if (actionSourceInfo == null) { - _actionExpression = null; - _actionListener = null; - _isImmediate = false; - } else { - // TODO: having action and actionExpression will come back to - // to bite us. - _actionExpression = actionSourceInfo.getAction(); - _actionListener = actionSourceInfo.getActionListener(); - _isImmediate = actionSourceInfo.isImmediate(); - - for (final Iterator it = actionSourceInfo.getActionListeners() - .iterator(); it.hasNext();) { - final ActionListenerDecorator actionListener = - (ActionListenerDecorator) it.next(); - addActionListener(actionListener); - } - } - } - - /** - * @param parent - * @param componentTypeInfo - * @param attributes - */ - protected UICommandInfo(final ComponentInfo parent, final ComponentTypeInfo componentTypeInfo, - Map attributes) - { - this(getStringProperty("id", attributes, true), //$NON-NLS-1$ - parent, componentTypeInfo, - getBooleanProperty("rendered", attributes, false), //$NON-NLS-1$ - getActionSourceInfo("$actionSourceInfo", attributes) //$NON-NLS-1$ - ); - } - - private static IActionSourceInfo getActionSourceInfo(String key, - Map attributes) - { - return (IActionSourceInfo) attributes.get(key); - } - - public String getActionExpression() { - return _actionExpression; - } - - public final void addActionListener(final ActionListenerDecorator actionListener) { - addDecorator(actionListener, ComponentFactory.ACTION_LISTENER); - } - - public final String getAction() { - return _actionExpression; - } - - public final String getActionListener() { - return _actionListener; - } - - public final List getActionListeners() { - return getDecorators(ComponentFactory.ACTION_LISTENER); - } - - public final boolean isImmediate() { - return _isImmediate; - } - - protected String getMostSpecificComponentName() - { - return "UICommand"; //$NON-NLS-1$ - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/UIDataInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/UIDataInfo.java deleted file mode 100644 index 56981af98..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/UIDataInfo.java +++ /dev/null @@ -1,219 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.runtime.internal.model.component; - -import java.util.Map; - -import org.eclipse.jst.jsf.common.runtime.internal.model.bean.DataModelInfo; -import org.eclipse.jst.jsf.common.runtime.internal.model.bean.SerializableObject; -import org.eclipse.jst.jsf.common.runtime.internal.model.behavioural.INamingContainerInfo; - -/** - * Design time analog to UIData. - * - * @author cbateman - * - */ -public class UIDataInfo extends ComponentInfo implements INamingContainerInfo -{ - /** - * the standard name for the footer facet - */ - public final static String FACET_NAME_FOOTER = "footer"; //$NON-NLS-1$ - /** - * the standard name for the header facet. - */ - public final static String FACET_NAME_HEADER = "header"; //$NON-NLS-1$ - /** - * serialization id - */ - private static final long serialVersionUID = 3473288390914978784L; - - private final DataModelInfo _dataModel; - private final int _first; - private final int _rowCount; - private final boolean _rowAvailable; - private final SerializableObject _rowData; - private final int _rowIndex; - private final int _rows; - private final SerializableObject _value; - private final String _var; - - /** - * @param id - * @param parent - * @param componentTypeInfo - * @param isRendered - * @param dataModel - * @param first - * @param footer - * @param header - * @param rowCount - * @param rowAvailable - * @param rowData - * @param rowIndex - * @param rows - * @param value - * @param var - */ - public UIDataInfo(final String id, final ComponentInfo parent, - final ComponentTypeInfo componentTypeInfo, - final boolean isRendered, final DataModelInfo dataModel, - final int first, final ComponentInfo footer, - final ComponentInfo header, final int rowCount, - final boolean rowAvailable, final Object rowData, - final int rowIndex, final int rows, final Object value, - final String var) - { - super(id, parent, componentTypeInfo, isRendered); - _dataModel = dataModel; - _first = first; - _rowCount = rowCount; - _rowAvailable = rowAvailable; - _rowData = new SerializableObject(rowData); - _rowIndex = rowIndex; - _rows = rows; - _value = new SerializableObject(value); - _var = var; - - if (footer != null) - { - addFacet(FACET_NAME_FOOTER, footer); - } - - if (header != null) - { - addFacet(FACET_NAME_HEADER, header); - } - } - - /** - * @param parent - * @param componentTypeInfo - * @param attributes - */ - public UIDataInfo(final ComponentInfo parent, - final ComponentTypeInfo componentTypeInfo, Map attributes) - { - this(getStringProperty("id", attributes, true), parent, //$NON-NLS-1$ - componentTypeInfo, - getBooleanProperty("rendered", attributes, false), //$NON-NLS-1$ - getDataModelInfo("$dataModel", attributes), //$NON-NLS-1$ - getIntegerProperty("first", attributes), //$NON-NLS-1$ - getComponentProperty("footer", attributes), //$NON-NLS-1$ - getComponentProperty("header", attributes), //$NON-NLS-1$ - getIntegerProperty("rowCount", attributes), //$NON-NLS-1$ - getBooleanProperty("rowAvailable", attributes, false), //$NON-NLS-1$ - attributes.get("rowData"), //$NON-NLS-1$ - getIntegerProperty("rowIndex", attributes), //$NON-NLS-1$ - getIntegerProperty("rows", attributes), //$NON-NLS-1$ - attributes.get("value"), //$NON-NLS-1$ - getStringProperty("var", attributes, false)); //$NON-NLS-1$ - } - - private static DataModelInfo getDataModelInfo(String key, Map attributes) - { - return (DataModelInfo) attributes.get(key); - } - - /** - * @return the data model - */ - public final DataModelInfo getDataModel() - { - return _dataModel; - } - - /** - * @return the first row - */ - public final int getFirst() - { - return _first; - } - - /** - * @return the row count - */ - public final int getRowCount() - { - return _rowCount; - } - - /** - * @return true if the row is available - */ - public final boolean isRowAvailable() - { - return _rowAvailable; - } - - /** - * @return the row data (may be null if not serialiable) - */ - public final Object getRowData() - { - return _rowData.getMaybeSerializable(); - } - - /** - * @return the row index - */ - public final int getRowIndex() - { - return _rowIndex; - } - - /** - * @return the rows - */ - public final int getRows() - { - return _rows; - } - - /** - * @return the value of the model (may be null if not serialiable) - */ - public final Object getValue() - { - return _value.getMaybeSerializable(); - } - - /** - * @return the name used to define the EL row variable - */ - public final String getVar() - { - return _var; - } - - /** - * @return the header facet or null. - */ - public final ComponentInfo getHeader() - { - return getFacet(FACET_NAME_HEADER); - } - - /** - * @return the footer facet or null. - */ - public final ComponentInfo getFooter() - { - return getFacet(FACET_NAME_FOOTER); - } - - protected String getMostSpecificComponentName() - { - return "UIData"; //$NON-NLS-1$ - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/UIFormInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/UIFormInfo.java deleted file mode 100644 index 2b8233055..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/UIFormInfo.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.runtime.internal.model.component; - -import java.util.Map; - -import org.eclipse.jst.jsf.common.runtime.internal.model.behavioural.INamingContainerInfo; - -/** - * A design-time analog for the UIForm. - * - * @author cbateman - */ -public class UIFormInfo extends ComponentInfo implements INamingContainerInfo -{ - /** - * serializable id - */ - private static final long serialVersionUID = 6961034911873576644L; - - private final boolean _prependId; - private final boolean _submitted; - - /** - * @param id - * @param parent - * @param componentTypeInfo - * @param isRendered - * @param prependId - * @param submitted - */ - protected UIFormInfo(final String id, final ComponentInfo parent, - final ComponentTypeInfo componentTypeInfo, final boolean isRendered - , final boolean prependId, final boolean submitted) { - super(id, parent, componentTypeInfo, isRendered); - _prependId = prependId; - _submitted = submitted; - } - - /** - * @param parent - * @param componentTypeInfo - * @param attributes - */ - protected UIFormInfo(final ComponentInfo parent, ComponentTypeInfo componentTypeInfo, - Map attributes) - { - this(getStringProperty("id", attributes, true), //$NON-NLS-1$ - parent, - componentTypeInfo, - getBooleanProperty("rendered", attributes, false), //$NON-NLS-1$ - getBooleanProperty("prependId", attributes, false), //$NON-NLS-1$ - getBooleanProperty("submitted", attributes, false)); //$NON-NLS-1$ - } - - /** - * JSF 1.2 only - * - * @return true if the form allows its id to be prepended to its - * descendent's ids. - */ - public final boolean isPrependId() - { - return _prependId; - } - - /** - * @return true if the form is submitted. - */ - public final boolean isSubmitted() { - return _submitted; - } - - protected String getMostSpecificComponentName() - { - return "UIForm"; //$NON-NLS-1$ - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/UIInputInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/UIInputInfo.java deleted file mode 100644 index 14a613192..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/UIInputInfo.java +++ /dev/null @@ -1,182 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.runtime.internal.model.component; - -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.jst.jsf.common.runtime.internal.model.behavioural.IEditableValueHolderInfo; -import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ValidatorDecorator; -import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ValueChangeListenerDecorator; - -/** - * A design-time analog of the standard UIInput. - * - * @author cbateman - * - */ -public class UIInputInfo extends UIOutputInfo implements - IEditableValueHolderInfo -{ - /** - * serializable uid - */ - private static final long serialVersionUID = -6055473902554910848L; - private final boolean _isValid; - private final boolean _isImmediate; - private final boolean _isRequired; - private final Object _submittedValue; - private final String _validator; - private final String _valueChangeListener; - private final boolean _localSetValue; - - /** - * @param id - * @param parent - * @param typeInfo - * @param editableValueHolderInfo - * @param isRendered - */ - protected UIInputInfo(final String id, final ComponentInfo parent, - final ComponentTypeInfo typeInfo, - final IEditableValueHolderInfo editableValueHolderInfo, - final boolean isRendered) - { - super(id, parent, typeInfo, editableValueHolderInfo, isRendered); - - if (editableValueHolderInfo == null) - { - _isValid = true; - _isImmediate = false; - _isRequired = false; - _localSetValue = false; - _submittedValue = null; - _validator = null; - _valueChangeListener = null; - } - else - { - _isValid = editableValueHolderInfo.isValid(); - _isImmediate = editableValueHolderInfo.isImmediate(); - _isRequired = editableValueHolderInfo.isRequired(); - _localSetValue = editableValueHolderInfo.isLocalSetValue(); - _submittedValue = editableValueHolderInfo.getSubmittedValue(); - _validator = editableValueHolderInfo.getValidator(); - _valueChangeListener = editableValueHolderInfo - .getValueChangeListener(); - - for (final Iterator it = editableValueHolderInfo.getValidators() - .iterator(); it.hasNext();) - { - final ValidatorDecorator validator = (ValidatorDecorator) it - .next(); - addValidator(validator); - } - - for (final Iterator it = editableValueHolderInfo - .getValueChangeListeners().iterator(); it.hasNext();) - { - final ValueChangeListenerDecorator valueChangeListener = (ValueChangeListenerDecorator) it - .next(); - addValueChangeListener(valueChangeListener); - } - } - } - - /** - * @param parent - * @param typeInfo - * @param attributes - */ - protected UIInputInfo(final ComponentInfo parent, - final ComponentTypeInfo typeInfo, Map attributes) - { - this(getStringProperty("id", attributes, true), parent, typeInfo, //$NON-NLS-1$ - getEditableValueHolderInfo("$editableValueHolderInfo", //$NON-NLS-1$ - attributes), getBooleanProperty("rendered", attributes, false)); //$NON-NLS-1$ - } - - private static IEditableValueHolderInfo getEditableValueHolderInfo( - String key, Map attributes) - { - return (IEditableValueHolderInfo) attributes.get(key); - } - - // public String toString() { - // final String toString = super.toString(); - // return toString + ", isValid=" + _isValid + ", isImmediate=" - // + _isImmediate + ", isRequired=" + _isRequired; - // } - - // @Override - protected String getMostSpecificComponentName() - { - return "UIInput"; //$NON-NLS-1$ - } - - public final boolean isValid() - { - return _isValid; - } - - public final boolean isImmediate() - { - return _isImmediate; - } - - public final boolean isRequired() - { - return _isRequired; - } - - public final Object getSubmittedValue() - { - return _submittedValue; - } - - public final String getValidator() - { - return _validator; - } - - public final String getValueChangeListener() - { - return _valueChangeListener; - } - - public final boolean isLocalSetValue() - { - return _localSetValue; - } - - public final void addValidator(final ValidatorDecorator validator) - { - addDecorator(validator, ComponentFactory.VALIDATOR); - } - - public final void addValueChangeListener( - final ValueChangeListenerDecorator valueChangeListenerInfo) - { - addDecorator(valueChangeListenerInfo, - ComponentFactory.VALUE_CHANGE_LISTENER); - } - - public final List getValidators() - { - return getDecorators(ComponentFactory.VALIDATOR); - } - - public final List getValueChangeListeners() - { - return getDecorators(ComponentFactory.VALUE_CHANGE_LISTENER); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/UIOutputInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/UIOutputInfo.java deleted file mode 100644 index bf5f3563a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/UIOutputInfo.java +++ /dev/null @@ -1,132 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.runtime.internal.model.component; - -import java.util.List; -import java.util.Map; - -import org.eclipse.jst.jsf.common.runtime.internal.model.behavioural.IValueHolderInfo; -import org.eclipse.jst.jsf.common.runtime.internal.model.behavioural.ValueHolderInfo; -import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ConverterDecorator; - -/** - * A design-time analog for the UIOutput - * - * @author cbateman - * - */ -public class UIOutputInfo extends ComponentInfo implements IValueHolderInfo { - /** - * serializable uid - */ - private static final long serialVersionUID = 9096297578991706150L; - - /** - * the value - */ - protected final Object _value; - /** - * the value before any EL evaluation - */ - protected final Object _localValue; - - /** - * @param id - * @param parent - * @param typeInfo - * @param valueHolderInfo - * @param isRendered - */ - protected UIOutputInfo(final String id, final ComponentInfo parent, - final ComponentTypeInfo typeInfo, - final IValueHolderInfo valueHolderInfo, final boolean isRendered) { - super(id, parent, typeInfo, isRendered); - - if (valueHolderInfo == null) { - _value = null; - _localValue = null; - } else { - _value = valueHolderInfo.getValue(); - _localValue = valueHolderInfo.getLocalValue(); - - final ConverterDecorator converter = valueHolderInfo.getConverter(); - if (converter != null) { - addDecorator(converter, ComponentFactory.CONVERTER); - } - } - } - - /** - * @param parent - * @param typeInfo - * @param attributes - */ - protected UIOutputInfo(final ComponentInfo parent, final ComponentTypeInfo typeInfo, - final Map attributes) - { - this(getStringProperty("id", attributes, true), //$NON-NLS-1$ - parent, - typeInfo, - getValueHolderInfo("$valueHolderInfo", attributes), //$NON-NLS-1$ - getBooleanProperty("rendered", attributes, false)); //$NON-NLS-1$ - } - - /** - * @param key - * @param attributes - * @return the non-standard value holder info that encapsulates the - * ValueHolder properties. This is never mandatory. - */ - protected static IValueHolderInfo getValueHolderInfo(String key, Map attributes) - { - IValueHolderInfo info = (IValueHolderInfo) attributes.get(key); - - if (info != null) - { - return info; - } - Object value = attributes.get("value"); - if (value != null) - { - Object converter = attributes.get("converter"); - Object localValue = attributes.get("localValue"); - - return new ValueHolderInfo((ConverterDecorator) converter, localValue, value); - } - return null; - } - - // @Override - protected String getMostSpecificComponentName() { - return "UIOutput"; //$NON-NLS-1$ - } - - public final ConverterDecorator getConverter() { - // should only be a single converter decorator... - // so on this interface we'll return the first one if present. - // to do things like error checking, use the getDecorator - final List converters = getDecorators(ComponentFactory.CONVERTER); - - if (converters.size() > 0) { - return (ConverterDecorator) converters.get(0); - } - - return null; - } - - public final Object getLocalValue() { - return _localValue; - } - - public final Object getValue() { - return _value; - } -}
\ No newline at end of file |