diff options
author | cbateman | 2008-01-09 21:03:59 +0000 |
---|---|---|
committer | cbateman | 2008-01-09 21:03:59 +0000 |
commit | e4b50318c70f6505af55c16abb8e14ba3cdafc98 (patch) | |
tree | abe36ac420937aea3cbba8a930c34b0a66148465 | |
parent | c7e0d2abac90aad25a1d55e9f2c28f1c2f1006fa (diff) | |
download | webtools.jsf-e4b50318c70f6505af55c16abb8e14ba3cdafc98.tar.gz webtools.jsf-e4b50318c70f6505af55c16abb8e14ba3cdafc98.tar.xz webtools.jsf-e4b50318c70f6505af55c16abb8e14ba3cdafc98.zip |
Forking copy of the new common.runtime plugin into the main development area from experimental.
57 files changed, 3042 insertions, 0 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/.classpath b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/.classpath new file mode 100644 index 000000000..ce7393340 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/.project b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/.project new file mode 100644 index 000000000..4fe172b47 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.jst.jsf.common.runtime</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/.settings/org.eclipse.jdt.core.prefs b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..a1a8746a7 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,62 @@ +#Tue Oct 23 09:14:07 PDT 2007 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 +org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=ignore +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.3 diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/META-INF/MANIFEST.MF b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/META-INF/MANIFEST.MF new file mode 100644 index 000000000..caa9ba5a5 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/META-INF/MANIFEST.MF @@ -0,0 +1,18 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: CommonComponentPlugin Plug-in +Bundle-SymbolicName: org.eclipse.jst.jsf.common.runtime +Bundle-Version: 1.0.0 +Bundle-Activator: org.eclipse.jst.jsf.common.runtime.internal.JSFCommonRuntimePlugin +Require-Bundle: org.eclipse.core.runtime +Eclipse-LazyStart: true +Bundle-RequiredExecutionEnvironment: J2SE-1.4 +Export-Package: org.eclipse.jst.jsf.common.runtime.internal.debug, + org.eclipse.jst.jsf.common.runtime.internal.model, + org.eclipse.jst.jsf.common.runtime.internal.model.bean, + org.eclipse.jst.jsf.common.runtime.internal.model.behavioural, + org.eclipse.jst.jsf.common.runtime.internal.model.component, + org.eclipse.jst.jsf.common.runtime.internal.model.decorator, + org.eclipse.jst.jsf.common.runtime.internal.model.event, + org.eclipse.jst.jsf.common.runtime.internal.model.types, + org.eclipse.jst.jsf.common.runtime.internal.view.model.common diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/build.properties b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/build.properties new file mode 100644 index 000000000..34d2e4d2d --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/instrumentation/WebContent/WEB-INF/faces-config.xml b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/instrumentation/WebContent/WEB-INF/faces-config.xml new file mode 100644 index 000000000..15eef3bf0 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/instrumentation/WebContent/WEB-INF/faces-config.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!DOCTYPE faces-config PUBLIC + "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" + "http://java.sun.com/dtd/web-facesconfig_1_1.dtd"> + +<faces-config> + <lifecycle> + <phase-listener> + instrument.PhaseListener1</phase-listener> + </lifecycle> +</faces-config> diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/instrumentation/jar/jsfrt.jar b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/instrumentation/jar/jsfrt.jar Binary files differnew file mode 100644 index 000000000..50936737b --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/instrumentation/jar/jsfrt.jar diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/instrumentation/src/instrument/MyMonitorMessageFactory.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/instrumentation/src/instrument/MyMonitorMessageFactory.java new file mode 100644 index 000000000..f03216b1f --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/instrumentation/src/instrument/MyMonitorMessageFactory.java @@ -0,0 +1,122 @@ +package instrument; + +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.util.Iterator; + +import javax.faces.component.UIComponent; +import javax.faces.component.UIInput; +import javax.faces.component.UIOutput; + +import org.eclipse.jst.jsf.common.runtime.internal.debug.JSFMonitorMessage; +import org.eclipse.jst.jsf.common.runtime.internal.model.component.ComponentFactory; +import org.eclipse.jst.jsf.common.runtime.internal.model.component.ComponentInfo; +import org.eclipse.jst.jsf.common.runtime.internal.model.component.FacetInfo; +import org.eclipse.jst.jsf.common.runtime.internal.model.component.UIInputInfo; +import org.eclipse.jst.jsf.common.runtime.internal.model.component.UIOutputInfo; + +public class MyMonitorMessageFactory +{ + public static JSFMonitorMessage createJSFMonitorMessage(InputStream inStream) throws IOException, ClassCastException, ClassNotFoundException + { + ObjectInputStream objectStream = new ObjectInputStream(inStream); + Object nextObject = objectStream.readObject(); + return (JSFMonitorMessage) nextObject; + } + + static ComponentInfo buildComponentTree(UIComponent component, boolean isFacet) + { + final ComponentInfo componentInfo = getComponentData(component, isFacet); + + for (Iterator it = component.getChildren().iterator(); it.hasNext();) + { + UIComponent child = (UIComponent) it.next(); + componentInfo.getChildren().add(buildComponentTree(child, false)); + } + + for (Iterator it = component.getFacets().values().iterator(); it.hasNext();) + { + UIComponent facet = (UIComponent) it.next(); + componentInfo.getChildren().add(buildComponentTree(facet, true)); + } + + return componentInfo; + } + + private static ComponentInfo getComponentData(final UIComponent component, boolean isFacet) + { + if (isFacet) + { + return calculateFacetInfo(component); + } + else if (component instanceof UIInput) + { + return calculateUIInput((UIInput)component); + } + else if (component instanceof UIOutput) + { + return calculateUIOutput((UIOutput)component); + } + + // default; just make a component + return calculateComponentInfo(component); + } + + private static ComponentInfo calculateComponentInfo(UIComponent component) + { + final String id = component.getId(); + final String parentId = component.getParent() == null ? null : component.getParent().getId(); + final String componentFamily = component.getFamily(); + final String renderFamily = component.getRendererType(); + final String componentType = null; + final String componentClass = component.getClass().getCanonicalName(); + + return ComponentFactory.createComponentInfo + (id, parentId, componentFamily, renderFamily, componentType, componentClass); + } + + private static FacetInfo calculateFacetInfo(UIComponent component) + { + final String id = component.getId(); + final String parentId = component.getParent() == null ? null : component.getParent().getId(); + final String componentFamily = component.getFamily(); + final String renderFamily = component.getRendererType(); + final String componentType = null; + final String componentClass = component.getClass().getCanonicalName(); + + return ComponentFactory.createFacetInfo + (id, parentId, componentFamily, renderFamily, componentType, componentClass); + } + + private static UIInputInfo calculateUIInput(UIInput uiInput) + { + final String id = uiInput.getId(); + final String parentId = uiInput.getParent() == null ? null : uiInput.getParent().getId(); + final String componentFamily = uiInput.getFamily(); + final String renderFamily = uiInput.getRendererType(); + final String componentType = null; + final String componentClass = uiInput.getClass().getCanonicalName(); + final String isValid = Boolean.toString(uiInput.isValid()); + final String isImmediate = Boolean.toString(uiInput.isImmediate()); + final String isRequired = Boolean.toString(uiInput.isRequired()); + final String isRendered = Boolean.toString(uiInput.isRendered()); + + return ComponentFactory.createUIInputInfo + (id, parentId, componentFamily, renderFamily, isValid, isImmediate, isRequired, isRendered, componentType, componentClass); + } + + private static UIOutputInfo calculateUIOutput(UIOutput uiOutput) + { + final String id = uiOutput.getId(); + final String parentId = uiOutput.getParent() == null ? null : uiOutput.getParent().getId(); + final String componentFamily = uiOutput.getFamily(); + final String renderFamily = uiOutput.getRendererType(); + final String componentType = null; + final String componentClass = uiOutput.getClass().getCanonicalName(); + final String isRendered = Boolean.toString(uiOutput.isRendered()); + + return ComponentFactory.createUIOutputInfo + (id, parentId, componentFamily, renderFamily, isRendered, componentType, componentClass); + } +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/instrumentation/src/instrument/PhaseListener1.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/instrumentation/src/instrument/PhaseListener1.java new file mode 100644 index 000000000..f24e970e7 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/instrumentation/src/instrument/PhaseListener1.java @@ -0,0 +1,332 @@ +package instrument; + +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.io.Writer; +import java.net.Socket; +import java.net.UnknownHostException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Stack; +import java.util.concurrent.LinkedBlockingQueue; + +import javax.faces.FactoryFinder; +import javax.faces.component.UIComponent; +import javax.faces.component.UIViewRoot; +import javax.faces.context.FacesContext; +import javax.faces.context.ResponseWriter; +import javax.faces.event.PhaseEvent; +import javax.faces.event.PhaseId; +import javax.faces.event.PhaseListener; +import javax.faces.render.RenderKit; +import javax.faces.render.RenderKitFactory; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +import org.eclipse.jst.jsf.common.runtime.internal.debug.ComponentTreeMessage; +import org.eclipse.jst.jsf.common.runtime.internal.debug.JSFMonitorMessage; +import org.eclipse.jst.jsf.common.runtime.internal.debug.MonitorMessageFactory; +import org.eclipse.jst.jsf.common.runtime.internal.debug.RenderAttribute; +import org.eclipse.jst.jsf.common.runtime.internal.debug.RenderNode; +import org.eclipse.jst.jsf.common.runtime.internal.model.component.ComponentInfo; + +/** + * @author cbateman + * + */ +public class PhaseListener1 implements PhaseListener +{ + SocketClient _socketClient; + ResponseWriter _savedRW; + LoggingResponseWriter _injectRW; + + /** + * + */ + private static final long serialVersionUID = 6564874625827591775L; + + public PhaseListener1() + { + System.out.println("Initialized PhaseListener: "+this); + _socketClient = new SocketClient(3702); + Thread thread = new Thread(_socketClient); + thread.start(); + + } + + public void afterPhase(PhaseEvent event) { + if(PhaseId.RENDER_RESPONSE.equals(event.getPhaseId())) + { + System.out.printf("afterPhase: %s, for view id: %s\n",event.getPhaseId(),event.getFacesContext().getViewRoot().getViewId()); + dumpComponentTree(event.getFacesContext()); + + if (_savedRW != null) + { + event.getFacesContext().setResponseWriter(_savedRW); + } + + if (_injectRW != null) + { + dumpNode(_injectRW._rootComponentNode, ""); + } + } + } + + private void dumpNode(RenderNode node, String prefix) + { + System.out.printf("%s%s for component %s\n", prefix, node.getRenderedNodeName(), node.getComponentId()); + + for (final Iterator it = node.getChildren().iterator();it.hasNext();) + { + RenderNode child = (RenderNode) it.next(); + dumpNode(child, prefix+"\t"); + } + } + + public void beforePhase(PhaseEvent event) { + if (PhaseId.RENDER_RESPONSE.equals(event.getPhaseId())) + { + FacesContext facesContext = event.getFacesContext(); + RenderKitFactory renderFactory = + (RenderKitFactory)FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY); + RenderKit renderKit = renderFactory.getRenderKit(facesContext, + facesContext.getViewRoot().getRenderKitId()); + + _savedRW = facesContext.getResponseWriter(); + + try + { + Writer writer = ((ServletResponse) facesContext.getExternalContext().getResponse()).getWriter(); + String charEncoding = ((ServletRequest)facesContext.getExternalContext().getRequest()).getCharacterEncoding(); + ResponseWriter responseWriter = renderKit.createResponseWriter + (writer, + null /*Default: get the allowed content-types from the accept-header*/, + charEncoding); + _injectRW = new LoggingResponseWriter(responseWriter); + facesContext.setResponseWriter(_injectRW); + } + catch (IOException ioe) + { + ioe.printStackTrace(); + } + } +// System.out.printf("beforePhase: %s, for view id: %s\n",event.getPhaseId(),event.getFacesContext().getViewRoot().getViewId()); +// dumpComponentTree(event.getFacesContext()); + } + + public PhaseId getPhaseId() { + return PhaseId.ANY_PHASE; + } + + private void dumpComponentTree(final FacesContext facesContext) + { + final UIViewRoot root = facesContext.getViewRoot(); + + if (root != null) + { + final String viewId = root.getViewId(); + final ComponentInfo rootComponent = MyMonitorMessageFactory.buildComponentTree(root,false); + ComponentTreeMessage message = + MonitorMessageFactory.createTreeMessage(viewId, rootComponent, _injectRW._rootComponentNode); + _socketClient.put(message); + } + } + + + private static class SocketClient implements Runnable + { + private final int _port; + + private LinkedBlockingQueue<JSFMonitorMessage> _queue = + new LinkedBlockingQueue<JSFMonitorMessage>(); + + SocketClient(final int port) + { + _port = port; + } + + public void run() + { + JSFMonitorMessage buffer = null; + + try + { + while ((buffer = _queue.take()) != null) + { + Socket socket = null; + + try + { + socket = new Socket("127.0.0.1", _port); + ObjectOutputStream stream = new ObjectOutputStream(socket.getOutputStream()); + stream.writeObject(buffer); +// PrintWriter writer = new PrintWriter(socket.getOutputStream(), true); +// writer.println(buffer); +// writer.flush(); + } catch (UnknownHostException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + finally + { + if (socket != null && !socket.isClosed()) + { + try { + socket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + + public void put(JSFMonitorMessage message) + { + _queue.add(message); + } + } + + private static class LoggingResponseWriter extends ResponseWriter + { + private final ResponseWriter _wrapWriter; + private final Stack/*<RenderNode>*/ _parentStack; + private RenderNode _curNode; + private RenderNode _rootComponentNode; + + // map component id to the root rendernode rendered for it + private Map _componentToHtml; + + LoggingResponseWriter(ResponseWriter wrapWriter) + { + _wrapWriter = wrapWriter; + _parentStack = new Stack(); + + _componentToHtml = new HashMap/*<String,RenderNode>*/(); + } + + public ResponseWriter cloneWithWriter(Writer writer) { + return _wrapWriter.cloneWithWriter(writer); + } + + public void endDocument() throws IOException { + _wrapWriter.endDocument(); + } + + public void endElement(String element) throws IOException { + _curNode = (RenderNode) _parentStack.pop(); + _wrapWriter.endElement(element); + } + + public void flush() throws IOException { + _wrapWriter.flush(); + } + + public String getCharacterEncoding() { + return _wrapWriter.getCharacterEncoding(); + } + + public String getContentType() { + return _wrapWriter.getContentType(); + } + + public void startDocument() throws IOException { + _rootComponentNode = new RenderNode(null, null); + _wrapWriter.startDocument(); + } + + public void startElement(String elementName, UIComponent component) + throws IOException + { + String componentId = null; + + if (component != null) + { + componentId = component.getId(); + } + + RenderNode oldNode = _curNode; + // push the curNode. Pushing null indicates the root of the document + _parentStack.push(oldNode); + + _curNode = new RenderNode(componentId, elementName); + + // note that assumption here is that the first html element + // we see corresponding to a component is the root of its + // html tree. This may not be true if a component renders + // more than one root element or if the output is generated + // any thing but pre-order (parent first) tranversal of the + // component tree. TODO: this algorithm needs refining + if (!_componentToHtml.containsKey(componentId)) + { + _componentToHtml.put(componentId, _curNode); + } + + // if the current node isn't null, then append this new element + if (oldNode != null) + { + oldNode.getChildren().add(_curNode); + } + // otherwise, we are at the doc root, so append there instead + else + { + _rootComponentNode.getChildren().add(_curNode); + } + + + // do the normal write + _wrapWriter.startElement(elementName, component); + } + + public void writeAttribute(String name, Object value, String componentPropertyName) + throws IOException { + + System.out.printf("%s: [%s,%s]\n", name, value.toString(), componentPropertyName); + final RenderAttribute attribute = + new RenderAttribute(name, value.toString(), componentPropertyName); + + if (_curNode != null) + { + _curNode.getRenderedAttributes().add(attribute); + } + _wrapWriter.writeAttribute(name, value, componentPropertyName); + } + + public void writeComment(Object obj) throws IOException { + _wrapWriter.writeComment(obj); + } + + public void writeText(Object arg0, String arg1) throws IOException { + _wrapWriter.writeText(arg0, arg1); + } + + public void writeText(char[] arg0, int arg1, int arg2) + throws IOException { + _wrapWriter.writeText(arg0, arg1, arg2); + } + + public void writeURIAttribute(String arg0, Object arg1, String arg2) + throws IOException { + _wrapWriter.writeURIAttribute(arg0, arg1, arg2); + } + + public void close() throws IOException { + _wrapWriter.close(); + } + + public void write(char[] cbuf, int off, int len) throws IOException { + _wrapWriter.write(cbuf, off, len); + } + + public ResponseWriter getWrapWriter() { + return _wrapWriter; + } + } +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/JSFCommonRuntimePlugin.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/JSFCommonRuntimePlugin.java new file mode 100644 index 000000000..f7724d09a --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/JSFCommonRuntimePlugin.java @@ -0,0 +1,59 @@ +package org.eclipse.jst.jsf.common.runtime.internal; + +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.Status; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class JSFCommonRuntimePlugin extends Plugin { + + // The plug-in ID + public static final String PLUGIN_ID = "CommonComponentPlugin"; + + // The shared instance + private static JSFCommonRuntimePlugin plugin; + + /** + * The constructor + */ + public JSFCommonRuntimePlugin() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(final BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(final BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static JSFCommonRuntimePlugin getDefault() { + return plugin; + } + + public static void log(final String message, final Throwable t) + { + final ILog log = getDefault().getLog(); + final IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message, t); + log.log(status); + } +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/debug/ComponentTreeMessage.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/debug/ComponentTreeMessage.java new file mode 100644 index 000000000..c24e1d53b --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/debug/ComponentTreeMessage.java @@ -0,0 +1,218 @@ +package org.eclipse.jst.jsf.common.runtime.internal.debug; + +import org.eclipse.jst.jsf.common.runtime.internal.model.component.ComponentInfo; + + +public class ComponentTreeMessage extends JSFMonitorMessage +{ + /** + * + */ + private static final long serialVersionUID = -6282344329821994209L; + private String _viewId; + private ComponentInfo _treeRoot; + private RenderNode _renderRoot; + // private HashMap<String, ComponentInfo> _idIndex; + + public ComponentTreeMessage() + { + //_idIndex = new HashMap<String, ComponentInfo>(); + } + + public final String getViewId() { + return _viewId; + } + + public final ComponentInfo getTreeRoot() { + return _treeRoot; + } + + public final RenderNode getRenderRoot() { + return _renderRoot; + } + + final void setRenderRoot(RenderNode renderRoot) { + _renderRoot = renderRoot; + } + + final void setTreeRoot(ComponentInfo treeRoot) + { + _treeRoot = treeRoot; + } + + final void setViewId(final String viewId) + { + _viewId = viewId; + } + +// @Override +// protected void deserialize(InputStream inStream) throws IOException, ClassNotFoundException +// { +// ObjectInputStream objectInputStream = new ObjectInputStream(inStream); +// +// Object obj = objectInputStream.readObject(); +// int bytesRead = super.deserialize(inStream); +// +// // first line must be startView +// final BufferedReader reader = +// new BufferedReader(new InputStreamReader(inStream)); +// +// String line = reader.readLine(); +// +// if (line != null +// && line.startsWith(START_VIEW)) +// { +// _viewId = line.substring(START_VIEW.length()).trim(); +// bytesRead += line.length()+1; +// } +// +// // loop until EOF +// while ((line = reader.readLine())!=null) +// { +// bytesRead += line.length()+1; +// +// if (line.startsWith("component:")) +// { +// parseComponent(line.substring("component:".length()).trim()); +// } +// else if (line.startsWith("facet:")) +// { +// parseFacet(line.substring("facet:".length()).trim()); +// } +// else if (line.startsWith("uiInput:")) +// { +// parseUIInput(line.substring("uiInput:".length()).trim()); +// } +// else if (line.startsWith("uiOutput:")) +// { +// parseUIOutput(line.substring("uiOutput:".length()).trim()); +// } +// else if (line.startsWith("endView")) +// { +// // +// } +// } +// return bytesRead; +// } + +// private ComponentInfo parseComponent(final String line) +// { +// final String[] fields = line.split(","); +// if (fields.length >= 4) +// { +// String parentId = "!".equals(fields[0]) ? null : fields[0]; +// String id = "!".equals(fields[1]) ? null : fields[1]; +// String componentFamily = fields[2]; +// String renderFamily = fields[3]; +// +// ComponentInfo componentInfo = +// ComponentFactory.createComponentInfo +// (id, parentId, componentFamily, renderFamily); +// +// if (id == null) +// { +// _treeRoot = componentInfo; +// _idIndex.put(null, componentInfo); +// } +// else +// { +// _idIndex.put(id, componentInfo); +// +// ComponentInfo parent = +// (ComponentInfo)_idIndex.get(parentId); +// +// if (parent != null) +// { +// parent.getChildren().add(componentInfo); +// } +// else +// { +// _treeRoot.getChildren().add(componentInfo); +// } +// } +// } +// return null; +// } +// +// private FacetInfo parseFacet(final String line) +// { +// final String[] fields = line.split(","); +// +// if (fields.length >= 4) +// { +// String parentId = "!".equals(fields[0]) ? null : fields[0]; +// String id = "!".equals(fields[1]) ? null : fields[1]; +// String componentFamily = fields[2]; +// String renderFamily = fields[3]; +// +// FacetInfo facetInfo = +// ComponentFactory.createFacetInfo(id, parentId, componentFamily, renderFamily); +// ComponentInfo parent = _idIndex.get(parentId); +// +// if (parent != null) +// { +// parent.getChildren().add(facetInfo); +// } +// +// return facetInfo; +// } +// return null; +// } +// +// private UIInputInfo parseUIInput(final String line) +// { +// final String[] fields = line.split(","); +// +// if (fields.length >= 7) +// { +// String parentId = "!".equals(fields[0]) ? null : fields[0]; +// String id = "!".equals(fields[1]) ? null : fields[1]; +// String componentFamily = fields[2]; +// String renderFamily = fields[3]; +// String isValid = fields[4]; +// String isImmediate = fields[5]; +// String isRequired = fields[6]; +// String isRendered = fields[7]; +// +// UIInputInfo uiInputInfo = +// ComponentFactory.createUIInputInfo +// (id, parentId, componentFamily, renderFamily, isValid, isImmediate, isRequired, isRendered); +// ComponentInfo parent = _idIndex.get(parentId); +// +// if (parent != null) +// { +// parent.getChildren().add(uiInputInfo); +// } +// +// return uiInputInfo; +// } +// return null; +// } +// +// private UIOutputInfo parseUIOutput(final String line) +// { +// final String[] fields = line.split(","); +// +// if (fields.length >= 4) +// { +// String parentId = "!".equals(fields[0]) ? null : fields[0]; +// String id = "!".equals(fields[1]) ? null : fields[1]; +// String componentFamily = fields[2]; +// String renderFamily = fields[3]; +// String isRendered = fields[4]; +// +// UIOutputInfo uiOutputInfo = +// ComponentFactory.createUIOutputInfo(id, parentId, componentFamily, renderFamily, isRendered); +// +// ComponentInfo parent = _idIndex.get(parentId); +// +// if (parent != null) +// { +// parent.getChildren().add(uiOutputInfo); +// } +// +// return uiOutputInfo; +// } +// return null; +// } +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/debug/JSFMonitorMessage.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/debug/JSFMonitorMessage.java new file mode 100644 index 000000000..f4c89dd16 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/debug/JSFMonitorMessage.java @@ -0,0 +1,16 @@ +package org.eclipse.jst.jsf.common.runtime.internal.debug; + +import java.io.Serializable; + +/** + * Super of all messages that are sent by the JSF debug monitor + * @author cbateman + * + */ +public abstract class JSFMonitorMessage implements Serializable +{ + /** + * + */ + private static final long serialVersionUID = -5417558019077000040L; +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/debug/MonitorMessageFactory.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/debug/MonitorMessageFactory.java new file mode 100644 index 000000000..19d5c5e76 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/debug/MonitorMessageFactory.java @@ -0,0 +1,15 @@ +package org.eclipse.jst.jsf.common.runtime.internal.debug; + +import org.eclipse.jst.jsf.common.runtime.internal.model.component.ComponentInfo; + +public class MonitorMessageFactory +{ + public static ComponentTreeMessage createTreeMessage(final String viewId, final ComponentInfo root, final RenderNode renderRoot) + { + ComponentTreeMessage message = new ComponentTreeMessage(); + message.setViewId(viewId); + message.setTreeRoot(root); + message.setRenderRoot(renderRoot); + return message; + } +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/debug/RenderAttribute.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/debug/RenderAttribute.java new file mode 100644 index 000000000..910fbc5af --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/debug/RenderAttribute.java @@ -0,0 +1,29 @@ +package org.eclipse.jst.jsf.common.runtime.internal.debug; + +public class RenderAttribute extends JSFMonitorMessage { + + /** + * + */ + private static final long serialVersionUID = -4601065346261130623L; + + private final String _name; // the name of the attribute. TODO: local vs. namespace? + private final String _value; // the rendered value of the node + private final String _propertyName; // the property name on the corresponding component + // may be null + public RenderAttribute(String name, String value, String propertyName) { + super(); + _name = name; + _propertyName = propertyName; + _value = value; + } + public final String getName() { + return _name; + } + public final String getValue() { + return _value; + } + public final String getPropertyName() { + return _propertyName; + } +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/debug/RenderNode.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/debug/RenderNode.java new file mode 100644 index 000000000..d2ff6efab --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/debug/RenderNode.java @@ -0,0 +1,53 @@ +package org.eclipse.jst.jsf.common.runtime.internal.debug; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class RenderNode extends JSFMonitorMessage +{ + /** + * + */ + private static final long serialVersionUID = -2843929405836710015L; + + private final String _componentId; // the id of the component id that caused the node to render + private final String _renderedNodeName; // the node + private final List/*<RenderedAttribute>*/ _renderedAttributes; // attributes + private final List _children; // the rendered children of renderedNode based + // on the output document hiearchy + public RenderNode(String componentId, String renderedNodeName) { + super(); + _componentId = componentId; + _renderedNodeName = renderedNodeName; + + _children = new ArrayList(); + _renderedAttributes = new ArrayList(); + } + public final String getComponentId() { + return _componentId; + } + public final List getChildren() { + return _children; + } + public final String getRenderedNodeName() { + return _renderedNodeName; + } + public final List getRenderedAttributes() { + return _renderedAttributes; + } + public String toString() + { + String toString = "Root node: "+_renderedNodeName+", attributes: ["; + + for (Iterator it = _renderedAttributes.iterator(); it.hasNext();) + { + final RenderAttribute attribute = (RenderAttribute) it.next(); + toString+=attribute.getName() + "=" + attribute.getValue(); + + toString+=it.hasNext() ? ", " : "]"; + } + + return toString; + } +}
\ 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/ViewObject.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/ViewObject.java new file mode 100644 index 000000000..c4de29e88 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/ViewObject.java @@ -0,0 +1,276 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.Decorator; + +/** + * The base type of all objects that participate in the lifecycle of a view. + * This may be used to hold either design time or runtime information. + * + * @author cbateman + * + */ +public abstract class ViewObject implements Serializable /* IAdaptable? */ +{ + private Map/* <Class, List<Decorator>> */_decorators; + private Map/* <Class, Object */_adapters; + /** + * + */ + private static final long serialVersionUID = 1592205691642453075L; + + /** + * This call may be create a new data structure and should be considered of + * much higher cost than most calls. + * + * @return all decorators of this object. List should be assumed by clients + * to be unmodifiable and may throw mutation exceptions + */ + public List getAllDecorators() { + final int size = getDecoratorMap().size(); + + if (size == 0) { + return Collections.EMPTY_LIST; + } + + final List allDecorators = new ArrayList(); + for (final Iterator entryIt = getDecoratorMap().entrySet().iterator(); entryIt + .hasNext();) { + final Map.Entry entry = (Map.Entry) entryIt.next(); + final List decorators = (List) entry.getValue(); + allDecorators.addAll(decorators); + } + + return Collections.unmodifiableList(allDecorators); + } + + /** + * @param decoratorType + * @return all decorators of this object associated with the class type. The + * returned list should be assumed to be unmodifiable. Returns an + * empty list if no decorators are associated with decoratorType + */ + public List getDecorators(final Class decoratorType) { + final List decorators = (List) getDecoratorMap().get(decoratorType); + + if (decorators == null) { + return Collections.EMPTY_LIST; + } else { + return Collections.unmodifiableList(decorators); + } + } + + /** + * Add the decorator using decorator.getClass to associate the type. Must be + * equivalent to addDecorator(decorator, decorator.getClass()); + * + * @param decorator + * the decorator to add. <b>Must NOT be null.</b> + * @throws IllegalArgumentException + * if decorator is null. + */ + public void addDecorator(final Decorator decorator) { + if (decorator == null) { + throw new IllegalArgumentException("Arguments must not be null"); + } + final Class associationType = decorator.getClass(); + addDecorator(decorator, associationType); + } + + /** + * Add the decorator using the associatedType. Normally you should call + * {@link #addDecorator(Decorator)} however in some cases you may wish to + * associated a decorator with a class type other than its own. For example, + * sub-classes of ValidatorDecorator will want to associated with + * ValidatorDecorator.getClass() in most cases so that it is included in any + * common examination of component validators. + * + * @param decorator + * to add. <b>Must NOT be null.</b> + * @param associatedType + * the key to store decorator <b>Must NOT be null</b> + * @throws IllegalArgumentException + * if decorator or associatedType is null + */ + public void addDecorator(final Decorator decorator, + final Class associatedType) { + if (decorator == null || associatedType == null) { + throw new IllegalArgumentException("Arguments must not be null"); + } + + List decoratorsByType = (List) getDecoratorMap().get(associatedType); + + if (decoratorsByType == null) { + decoratorsByType = new ArrayList(2); + getDecoratorMap().put(associatedType, decoratorsByType); + } + + decoratorsByType.add(decorator); + } + + /** + * Removes decorator if it is associated to associatedType on this view + * object. + * + * @param decorator + * @param associatedType + * @return true if the decorator was found and removed. + * @throws IllegalArgumentException + * if decorator or associatedType is null + */ + public boolean removeDecorator(final Decorator decorator, + final Class associatedType) { + if (decorator == null || associatedType == null) { + throw new IllegalArgumentException("Arguments must not be null"); + } + + final List decoratorsByType = (List) getDecoratorMap().get( + associatedType); + + if (decoratorsByType != null) { + return decoratorsByType.remove(decorator); + } + + return false; + } + + /** + * <p>Get the adapter associated the class key.</p> + * + * <p>If addAdapter has been called with adapterType, then this + * adapter object should always be called. In the default implementation, + * if there is no explicit adapter, "this" is returned if (this instanceof adapterType). + * + * @param adapterType + * @return the interface adapter associated with the class key or null if + * not found + */ + public Object getAdapter(final Class adapterType) { + if (adapterType == null) { + return null; + } + + Object adapter = getAdapterMap().get(adapterType); + + if (adapter == null) + { + if (adapterType.isInstance(this)) { + adapter = this; + } + } + + return adapter; + } + + /** + * Adds the interface adapter object under adapterType key. There can be at + * most one adapter registered for each class key. + * + * @param adapterType + * @param adapter + * @throws IllegalArgumentException + * if adapterType or adapter is null or if casting adapter to + * adapterType would * cause a ClassCastException (i.e. if + * !(adapter instanceof adapterType)) + */ + public void addAdapter(final Class adapterType, final Object adapter) { + if (adapterType == null || adapter == null) { + throw new IllegalArgumentException("Arguments must not be null"); + } + + if (!adapterType.isInstance(adapter)) { + throw new IllegalArgumentException("adapter: " + adapter + + " must be cast compatible to class: " + adapterType); + } + getAdapterMap().put(adapterType, adapter); + } + + /** + * Note that {@link #getAdapter(Class)} may still return non-null after + * this is called if (this instanceof adapterType). + * + * @param adapterType + * @return the adapter for adapterType that was just removed or null if not + * found + */ + public Object removeAdapter(final Class adapterType) { + return getAdapterMap().remove(adapterType); + } + + /** + * Note that this only returns those adapters added using + * {@link #addAdapter(Class, Object)}. It does not return any + * implicit adapters resulting from (this instanceof type). + * + * @return the map of all adapters. Maps is immutable and may throw + * exceptions on attempts to mutate. + */ + public Map getAllAdapters() + { + if (getAdapterMap().size() == 0) + { + return Collections.EMPTY_MAP; + } + return Collections.unmodifiableMap(getAdapterMap()); + } + + /** + * <p> + * The contract for this method is that it must always return a usable Map + * and that map must be the same on every call. Lazy construction may be + * used (as it is by default). The default map size is 4 and load factor is + * 3 meaning that there should be decent tradeoff between wasted table size + * and overhead used to increase it should the number of decorators exceed + * 3. <b>Must never return null.</b> + * </p> + * + * <p> + * Generally, the method should not need to be overridden, however it is + * provided to allow sub-classes to change the way the decorators map is + * constructed. + * </p> + * + * @return the map containing lists of decorators keyed by class. + * + */ + protected Map getDecoratorMap() { + if (_decorators == null) { + _decorators = new HashMap(4); + } + return _decorators; + } + + /** + * <p> + * The contract for this method is that it must always return a usable Map + * and that map must be the same on every call. Lazy construction may be + * used (as it is by default). The default map size is 4 and load factor is + * 3 meaning that there should be decent tradeoff between wasted table size + * and overhead used to increase it should the number of decorators exceed + * 3. <b>Must never return null.</b> + * </p> + * + * <p> + * Generally, the method should not need to be overridden, however it is + * provided to allow sub-classes to change the way the decorators map is + * constructed. + * </p> + * + * @return the map containing lists of decorators keyed by class. + * + */ + protected Map getAdapterMap() { + if (_adapters == null) { + _adapters = new HashMap(4); + } + + return _adapters; + } +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/bean/DataModelInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/bean/DataModelInfo.java new file mode 100644 index 000000000..aaaedffe6 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/bean/DataModelInfo.java @@ -0,0 +1,49 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.bean; + +import java.io.Serializable; + +/** + * Design time analog of runtime DataModel bean + * + * @author cbateman + * + */ +public class DataModelInfo implements Serializable +{ + /** + * serializable id + */ + private static final long serialVersionUID = 6461056497382677871L; + + private final boolean _rowAvailable; + private final int _rowCount; + private final SerializableObject _rowData; + private final int _rowIndex; + private final SerializableObject _wrappedData; + + public DataModelInfo(boolean rowAvailable, int rowCount, Object rowData, + int rowIndex, Object wrappedData) { + super(); + _rowAvailable = rowAvailable; + _rowCount = rowCount; + _rowData = new SerializableObject(rowData); + _rowIndex = rowIndex; + _wrappedData = new SerializableObject(wrappedData); + } + + public final boolean isRowAvailable() { + return _rowAvailable; + } + public final int getRowCount() { + return _rowCount; + } + public final Object getRowData() { + return _rowData.getMaybeSerializable(); + } + public final int getRowIndex() { + return _rowIndex; + } + public final Object getWrappedData() { + return _wrappedData.getMaybeSerializable(); + } +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/bean/SerializableObject.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/bean/SerializableObject.java new file mode 100644 index 000000000..9488d75ce --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/bean/SerializableObject.java @@ -0,0 +1,63 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.bean; + +import java.io.IOException; +import java.io.NotSerializableException; +import java.io.Serializable; + +/** + * A special object used in place of Object to ensure that when an interface + * requires a generic #{@link java.lang.Object}, it won't throw serialization + * exception when a containing object is serialized. + * + * @author cbateman + * + */ +public class SerializableObject implements Serializable +{ + /** + * + */ + private static final long serialVersionUID = 9133733048469500692L; + private Object _maybeSerializable; + + public SerializableObject(Object maybeSerializable) + { + _maybeSerializable = maybeSerializable; + } + + +// /** +// * Provided to support serialization. Should not be used by sub-classes +// * or clients except in this regard. +// */ +// protected SerializableObject() +// { +// _maybeSerializable = null; +// } + + public final Object getMaybeSerializable() { + return _maybeSerializable; + } + + + private void writeObject(java.io.ObjectOutputStream out) + throws IOException + { + try + { + out.writeObject(_maybeSerializable); + } + catch (NotSerializableException nse) + { + // do nothing, the object isn't guaranteed to be serializable, + // but we don't want this be an error + out.writeObject(null); + } + } + + private void readObject(java.io.ObjectInputStream in) + throws IOException, ClassNotFoundException + { + _maybeSerializable = in.readObject(); + } +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/ActionSourceInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/ActionSourceInfo.java new file mode 100644 index 000000000..e6536a14e --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/ActionSourceInfo.java @@ -0,0 +1,57 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.behavioural; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ActionListenerDecorator; + +public class ActionSourceInfo implements IActionSourceInfo +{ + /** + * serializable id + */ + private static final long serialVersionUID = 6531166406473466685L; + + private final String _action; + private final String _actionListener; + private final boolean _immediate; + private List/*<ActionListenerDecorator>*/ _actionListeners; + + public ActionSourceInfo(final String action, final String actionListener, + final boolean immediate) + { + super(); + _action = action; + _actionListener = actionListener; + _immediate = immediate; + } + + public void addActionListener(final ActionListenerDecorator actionListener) { + if (_actionListeners == null) + { + _actionListeners = new ArrayList(2); + } + _actionListeners.add(actionListener); + } + + public String getAction() { + return _action; + } + + public String getActionListener() { + return _actionListener; + } + + public List getActionListeners() { + if (_actionListeners == null) + { + return Collections.EMPTY_LIST; + } + return Collections.unmodifiableList(_actionListeners); + } + + public boolean isImmediate() { + return _immediate; + } +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/ActionSourceInfo2.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/ActionSourceInfo2.java new file mode 100644 index 000000000..34492aa26 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/ActionSourceInfo2.java @@ -0,0 +1,21 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.behavioural; + +public class ActionSourceInfo2 extends ActionSourceInfo implements + IActionSource2Info +{ + /** + * serializable id + */ + private static final long serialVersionUID = 5811194815559772378L; + private final String _actionExpression; + + public ActionSourceInfo2(final String action, final String actionListener, + final boolean immediate, final String actionExpression) { + super(action, actionListener, immediate); + _actionExpression = actionExpression; + } + + public String getActionExpression() { + return _actionExpression; + } +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/EditableValueHolderInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/EditableValueHolderInfo.java new file mode 100644 index 000000000..21022a96f --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/EditableValueHolderInfo.java @@ -0,0 +1,108 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.behavioural; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ConverterDecorator; +import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ValidatorDecorator; +import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ValueChangeListenerDecorator; + +public class EditableValueHolderInfo extends ValueHolderInfo implements + IEditableValueHolderInfo +{ + /** + * + */ + private static final long serialVersionUID = -2115990809157328451L; + + private final boolean _localSetValue; + private final Object _submittedValue; + private final String _validator; + private final String _valueChangeListener; + private final boolean _isImmediate; + private final boolean _isRequired; + private final boolean _isValid; + private List _validators; + private List _valueChangeListeners; + + public EditableValueHolderInfo(final ConverterDecorator converterDecorator, + final Object localValue, final Object value, final boolean isImmediate, + final boolean isRequired, final boolean isValid, final boolean localSetValue, + final Object submittedValue, final String validator, final String valueChangeListener) + { + super(converterDecorator, localValue, value); + _isImmediate = isImmediate; + _isRequired = isRequired; + _isValid = isValid; + _localSetValue = localSetValue; + _submittedValue = submittedValue; + _validator = validator; + _valueChangeListener = valueChangeListener; + } + + public final boolean isLocalSetValue() { + return _localSetValue; + } + + public final Object getSubmittedValue() { + return _submittedValue; + } + + public final String getValidator() { + return _validator; + } + + public final String getValueChangeListener() { + return _valueChangeListener; + } + + public final boolean isImmediate() { + return _isImmediate; + } + + public final boolean isRequired() { + return _isRequired; + } + + public final boolean isValid() { + return _isValid; + } + + public void addValidator(final ValidatorDecorator validator) + { + if (_validators == null) + { + _validators = new ArrayList(2); + } + _validators.add(validator); + } + + public void addValueChangeListener( + final ValueChangeListenerDecorator valueChangeListenerInfo) + { + if (_valueChangeListeners == null) + { + _valueChangeListeners = new ArrayList(2); + } + _valueChangeListeners.add(valueChangeListenerInfo); + } + + public List getValidators() { + if (_validators == null) + { + return Collections.EMPTY_LIST; + } + + return Collections.unmodifiableList(_validators); + } + + public List getValueChangeListeners() { + if (_valueChangeListeners == null) + { + return Collections.EMPTY_LIST; + } + + return Collections.unmodifiableList(_valueChangeListeners); + } +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/IActionSource2Info.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/IActionSource2Info.java new file mode 100644 index 000000000..6fef11b3c --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/IActionSource2Info.java @@ -0,0 +1,20 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.behavioural; + +/** + * Design-time analog for the ActionSource2 interface. + * + * @author cbateman + * + */ +public interface IActionSource2Info extends IActionSourceInfo +{ + /** + * TODO: this method is similar to getAction on ActionSource from + * our perspective since the actual string rep of the EL is basically + * the same... + * + * @return an EL method expression that represents a call to + * an action method. + */ + String getActionExpression(); +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/IActionSourceInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/IActionSourceInfo.java new file mode 100644 index 000000000..4de338baf --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/IActionSourceInfo.java @@ -0,0 +1,56 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.behavioural; + +import java.io.Serializable; +import java.util.List; + +import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ActionListenerDecorator; + +/** + * A design time analog for the runtime ActionSource interface. + * + * @author cbateman + * + */ +public interface IActionSourceInfo extends Serializable +{ + /** + * @return true if action listener associated with this action source + * should be executed immediately after the apply request values phase. + * Default is false. + */ + boolean isImmediate(); + + + /** + * Add the action listener to the list + * + * @param actionListener + */ + void addActionListener(ActionListenerDecorator actionListener); + + /** + * @return all action listeners registered. List should be considered + * immutable and may throw exceptions if modified. + */ + List/*<ActionListenerDecorator>*/ getActionListeners(); + + /** + * <b> NOTE: this method is deprecated in the runtime spec and exists for + * backward compatibility with JSF 1.1. You should avoid using it except in + * conjunction with JSF 1.1 tooling support. This method will be deprecated + * once the runtime spec removes the underlying API</b> + + * @return a method binding expression describing an action handler + */ + String getAction(); + + /** + * <b> NOTE: this method is deprecated in the runtime spec and exists for + * backward compatibility with JSF 1.1. You should avoid using it except in + * conjunction with JSF 1.1 tooling support. This method will be deprecated + * once the runtime spec removes the underlying API</b> + * + * @return a method binding expression describing an action listener + */ + String getActionListener(); +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/IEditableValueHolderInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/IEditableValueHolderInfo.java new file mode 100644 index 000000000..823e24c56 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/IEditableValueHolderInfo.java @@ -0,0 +1,94 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.behavioural; + +import java.util.List; + +import org.eclipse.jst.jsf.common.runtime.internal.model.ViewObject; +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 for the JSF runtime EditableValueHolder interface. + * + * @author cbateman + * + */ +public interface IEditableValueHolderInfo extends IValueHolderInfo { + /** + * @return the flag indicating whether the value of the value holder should + * be evaluated in the apply request values phase instead of the + * process validations phase + */ + boolean isImmediate(); + + /** + * @return true if the value has been set + */ + boolean isLocalSetValue(); + + /** + * @return true if validation should consider this field required (must be + * non-empty). + */ + boolean isRequired(); + + /** + * @return the submitted, unconverted value of the component. + */ + Object getSubmittedValue(); + + /** + * @return false if validation has determined that the value property of + * this component is not valid. + */ + boolean isValid(); + + /** + * <b> NOTE: this method is deprecated in the runtime spec and exists for + * backward compatibility with JSF 1.1. You should avoid using it except in + * conjunction with JSF 1.1 tooling support. This method will be deprecated + * once the runtime spec removes the underlying API</b> + * + * @return a method binding expression that refers to a validator method + */ + String getValidator(); + + /** + * <b> NOTE: this method is deprecated in the runtime spec and exists for + * backward compatibility with JSF 1.1. You should avoid using it except in + * conjunction with JSF 1.1 tooling support. This method will be deprecated + * once the runtime spec removes the underlying API</b> + * + * @return a method binding expression that refers to a value change + * listener + */ + String getValueChangeListener(); + + /** + * Add validator to the list of validators for this component. Should be + * equivalent to + * {@link ViewObject#addDecorator(org.eclipse.jst.jsf.common.runtime.internal.model.decorator.Decorator, Class)}. + * + * @param validator + */ + void addValidator(ValidatorDecorator validator); + + /** + * @return the list of validators for this component. Should be considered + * unmodifiable (may throw exception). + */ + List/* <ValidatorDecorator> */getValidators(); + + /** + * Add the value change listener to this component. + * + * @param valueChangeListenerInfo + */ + void addValueChangeListener( + ValueChangeListenerDecorator valueChangeListenerInfo); + + /** + * @return the list of value change listeners. Should be considered + * unmodifiable (may throw exception). + */ + List/* <ValueChangeListenerDecorator> */getValueChangeListeners(); +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/INamingContainerInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/INamingContainerInfo.java new file mode 100644 index 000000000..52baf703a --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/INamingContainerInfo.java @@ -0,0 +1,11 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.behavioural; + +/** + * Design time analog for the NamingContainer interface. + * + * @author cbateman + * + */ +public interface INamingContainerInfo { + // tagging interface +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/IValueHolderInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/IValueHolderInfo.java new file mode 100644 index 000000000..7340f7f89 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/IValueHolderInfo.java @@ -0,0 +1,32 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.behavioural; + +import java.io.Serializable; + +import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ConverterDecorator; + +/** + * Represents design time information about the ValueHolder behavioural + * interface. + * + * @author cbateman + * + */ +public interface IValueHolderInfo extends Serializable +{ + /** + * @return the value, may be null + */ + Object getValue(); + + /** + * @return the raw value without expression value evaluation. Note that + * {@link #getValue()} may return the same value in cases where this value + * holder is derived at design time without EL expression evaluation. May be null. + */ + Object getLocalValue(); + + /** + * @return the converter for this value holder or null if none. + */ + ConverterDecorator getConverter(); +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/ValueHolderInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/ValueHolderInfo.java new file mode 100644 index 000000000..1cab43748 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/behavioural/ValueHolderInfo.java @@ -0,0 +1,32 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.behavioural; + +import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ConverterDecorator; + +public class ValueHolderInfo implements IValueHolderInfo +{ + /** + * + */ + private static final long serialVersionUID = 5000699728360703727L; + + protected final Object _value; + protected final Object _localValue; + protected final ConverterDecorator _converterDecorator; + + public ValueHolderInfo(final ConverterDecorator converterDecorator, + final Object localValue, final Object value) { + super(); + _converterDecorator = converterDecorator; + _localValue = localValue; + _value = value; + } + public final Object getValue() { + return _value; + } + public final Object getLocalValue() { + return _localValue; + } + public final ConverterDecorator getConverter() { + return _converterDecorator; + } +} 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 new file mode 100644 index 000000000..dc135f241 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/ComponentFactory.java @@ -0,0 +1,76 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.component; + +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; + +public class ComponentFactory { + + public final static Class VALUE_HOLDER = IValueHolderInfo.class; + public final static Class EDITABLE_VALUE_HOLDER = IEditableValueHolderInfo.class; + public final static Class ACTION_SOURCE = IActionSourceInfo.class; + public final static Class ACTION_SOURCE2 = IActionSource2Info.class; + public final static Class CONVERTER = ConverterDecorator.class; + public final static Class FACET = FacetDecorator.class; + public final static Class VALIDATOR = ValidatorDecorator.class; + public final static Class VALUE_CHANGE_LISTENER = IValueChangeListenerInfo.class; + public final static Class ACTION_LISTENER = IActionListenerInfo.class; + public final static Class NAMING_CONTAINER = INamingContainerInfo.class; + + public static ComponentInfo createComponentInfo(final String id, + final ComponentInfo parent, final ComponentTypeInfo typeInfo, + final boolean isRendered) { + return new ComponentInfo(id, parent, typeInfo, isRendered); + } + + 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); + } + + 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); + } + + 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); + } + + 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); + } + + 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); + } +} 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 new file mode 100644 index 000000000..386d94214 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/ComponentInfo.java @@ -0,0 +1,177 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.component; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.jst.jsf.common.runtime.internal.debug.RenderNode; +import org.eclipse.jst.jsf.common.runtime.internal.model.ViewObject; +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 +{ + /** + * serializable id + */ + private static final long serialVersionUID = 2517204356825585699L; + + private final static int DEFAULT_ARRAY_SIZE = 4; + + protected final String _id; + protected final ComponentInfo _parent; + protected final ComponentTypeInfo _componentTypeInfo; + protected final boolean _isRendered; + protected RenderNode _rootRenderedNode; // may be null if we don't have it + + protected ComponentInfo(final String id, final ComponentInfo parent, final ComponentTypeInfo componentTypeInfo, final boolean isRendered) + { + _id = translateForNull(id); + _parent = parent; + _componentTypeInfo = componentTypeInfo; + _isRendered = isRendered; + } + + private String translateForNull(final String arg) + { + + if (arg == null || "!".equals(arg.trim())) + { + return null; + } + return arg.trim(); + } + + private List/*<ComponentInfo>*/ _children; + + public final String getId() { + return _id; + } + + public final ComponentTypeInfo getComponentTypeInfo() { + return _componentTypeInfo; + } + + /** + * @return the children. List is unmodifiable. List contains all children + * including facets. + */ + public final List/*<ComponentInfo>*/ getChildren() { + if (_children == null) + { + return Collections.EMPTY_LIST; + } + return Collections.unmodifiableList(_children); + } + + /** + * Get the sub-set of {@link #getChildren()} that are facets. + * This is a convenience method for {@link #getDecorators(FacetDecorator.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 (_children == null) + { + _children = new ArrayList(DEFAULT_ARRAY_SIZE); + } + _children.add(childComponent); + } + + /** + * @param name + * @param facetComponent + */ + public final void addFacet(final String name, final ComponentInfo facetComponent) + { + addChild(facetComponent); + addDecorator(new FacetDecorator(name, facetComponent)); + } + + 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; + } + + 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 = _parent != null ? _parent.getId() : "null"; + return getMostSpecificComponentName() + ": id=" + _id + ", parentId: " + + parentId + ", family=" + + _componentTypeInfo.getComponentFamily() + ", render=" + + _componentTypeInfo.getRenderFamily(); + } + + public String getMostSpecificComponentName() + { + return "Component"; + } + + public final void setRenderNode(final RenderNode rootNode) + { + _rootRenderedNode = rootNode; + } + + public final RenderNode getRenderNode() + { + return _rootRenderedNode; + } + + public final ComponentInfo getParent() { + return _parent; + } + + public final boolean isRendered() { + return _isRendered; + } +} 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 new file mode 100644 index 000000000..0c1bd35b5 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/ComponentTypeInfo.java @@ -0,0 +1,47 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.component; + +import org.eclipse.jst.jsf.common.runtime.internal.model.types.IClassTypeInfo; +import org.eclipse.jst.jsf.common.runtime.internal.model.types.TypeInfo; + +public class ComponentTypeInfo extends TypeInfo implements IClassTypeInfo { + /** + * serializable uid + */ + private static final long serialVersionUID = -311156682935177206L; + protected final String _componentType; // may be null, since may not be + // known at runtime + protected final String _componentClass; + protected final String _componentFamily; + protected final String _renderFamily; + + public ComponentTypeInfo(final String componentType, + final String componentClass, final String componentFamily, + final String renderFamily) { + _componentType = componentType; + _componentClass = componentClass; + _componentFamily = componentFamily; + _renderFamily = renderFamily; + } + + public final String getComponentType() { + return _componentType; + } + + public final String getClassName() { + return _componentClass; + } + + public final String getComponentFamily() { + return _componentFamily; + } + + public final String getRenderFamily() { + return _renderFamily; + } + + public String toString() { + return "Component Type Info: type = " + _componentType + " class= " + + _componentClass + " family=" + _componentFamily + + " renderer=" + _renderFamily; + } +} 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 new file mode 100644 index 000000000..da4bfa6cb --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/UICommandInfo.java @@ -0,0 +1,68 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.component; + +import java.util.Iterator; +import java.util.List; + +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; + +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; + + 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); + } + } + } + + 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; + } +} 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 new file mode 100644 index 000000000..e7065f05a --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/UIDataInfo.java @@ -0,0 +1,104 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.component; + +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 { + public final static String FACET_NAME_FOOTER = "footer"; + public final static String FACET_NAME_HEADER = "header"; + /** + * 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; + + 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); + } + } + + public final DataModelInfo getDataModel() { + return _dataModel; + } + + public final int getFirst() { + return _first; + } + + public final int getRowCount() { + return _rowCount; + } + + public final boolean isRowAvailable() { + return _rowAvailable; + } + + public final Object getRowData() { + return _rowData.getMaybeSerializable(); + } + + public final int getRowIndex() { + return _rowIndex; + } + + public final int getRows() { + return _rows; + } + + public final Object getValue() { + return _value.getMaybeSerializable(); + } + + public final String getVar() { + return _var; + } + + public final ComponentInfo getHeader() + { + return getFacet(FACET_NAME_HEADER); + } + + public final ComponentInfo getFooter() + { + return getFacet(FACET_NAME_FOOTER); + } +}
\ 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 new file mode 100644 index 000000000..a9d7d551c --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/UIFormInfo.java @@ -0,0 +1,43 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.component; + +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; + + 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; + } + + /** + * @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; + } +} 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 new file mode 100644 index 000000000..80ea8c7f1 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/UIInputInfo.java @@ -0,0 +1,120 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.component; + +import java.util.Iterator; +import java.util.List; + +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; + +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; + + 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); + } + } + } + + public String toString() { + final String toString = super.toString(); + return toString + ", isValid=" + _isValid + ", isImmediate=" + + _isImmediate + ", isRequired=" + _isRequired; + } + + // @Override + public String getMostSpecificComponentName() { + return "UIInput"; + } + + 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 new file mode 100644 index 000000000..4815ffd35 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/component/UIOutputInfo.java @@ -0,0 +1,65 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.component; + +import java.util.List; + +import org.eclipse.jst.jsf.common.runtime.internal.model.behavioural.IValueHolderInfo; +import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ConverterDecorator; + +public class UIOutputInfo extends ComponentInfo implements IValueHolderInfo { + /** + * serializable uid + */ + private static final long serialVersionUID = 9096297578991706150L; + + protected final Object _value; + protected final Object _localValue; + + 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); + } + } + } + + public String toString() { + return super.toString() + ", isRendered=" + _isRendered; + } + + // @Override + public String getMostSpecificComponentName() { + return "UIOutput"; + } + + 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 diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ActionListenerDecorator.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ActionListenerDecorator.java new file mode 100644 index 000000000..c2621f68e --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ActionListenerDecorator.java @@ -0,0 +1,22 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.decorator; + +import org.eclipse.jst.jsf.common.runtime.internal.model.component.ComponentInfo; + +/** + * Design time ActionListener decorator + * + * @author cbateman + * + */ +public class ActionListenerDecorator extends ComponentDecorator { + + /** + * + */ + private static final long serialVersionUID = 3806862878381550874L; + + public ActionListenerDecorator(ComponentInfo decorates) { + super(decorates); + } + +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ComponentDecorator.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ComponentDecorator.java new file mode 100644 index 000000000..266b207f0 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ComponentDecorator.java @@ -0,0 +1,26 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.decorator; + +import org.eclipse.jst.jsf.common.runtime.internal.model.component.ComponentInfo; + +/** + * @author cbateman + * + */ +public abstract class ComponentDecorator extends Decorator +{ + /** + * + */ + private static final long serialVersionUID = 4378142984217256364L; + + private final ComponentInfo _decorates; + + public ComponentDecorator(final ComponentInfo decorates) + { + _decorates = decorates; + } + + public final ComponentInfo getDecorates() { + return _decorates; + } +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ConverterDecorator.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ConverterDecorator.java new file mode 100644 index 000000000..3ee1d14ba --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ConverterDecorator.java @@ -0,0 +1,18 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.decorator; + +import org.eclipse.jst.jsf.common.runtime.internal.model.component.ComponentInfo; + +public class ConverterDecorator extends ComponentDecorator { + + /** + * serializable id + */ + private static final long serialVersionUID = 3838224353030247227L; + + + public ConverterDecorator(final ComponentInfo decorates) + { + super(decorates); + } + +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ConverterTypeInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ConverterTypeInfo.java new file mode 100644 index 000000000..4d6135d29 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ConverterTypeInfo.java @@ -0,0 +1,69 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.decorator; + +import org.eclipse.jst.jsf.common.runtime.internal.model.types.IClassTypeInfo; +import org.eclipse.jst.jsf.common.runtime.internal.model.types.TypeInfo; + +/** + * Type information about a converter. + * + * @author cbateman + * + */ +public class ConverterTypeInfo extends TypeInfo implements IClassTypeInfo +{ + /** + * serializable id + */ + private static final long serialVersionUID = -7238952424045449907L; + + private final String _className; + private final String _converterId; + + /** + * For unknown converters, use the UNKNOWN constant. + * + * @param className + * @param converterId + * @throws #{@link IllegalArgumentException} if both className and + * converterId are null. + * + */ + public ConverterTypeInfo(String className, String converterId) + { + super(); + if (className == null && converterId == null) + { + throw new IllegalArgumentException("converterClass and converterId must not both be null. For unknown validator use the UNKNOWN constant"); + } + + _className = className; + _converterId = converterId; + } + + public static final ConverterTypeInfo UNKNOWN = + new ConverterTypeInfo((Object)null); + + /** + * A private constructor used to create the UNRESOLVED constant. + * We use an Object arg here (which is discarded) rather than using + * the zero-arg constructor so as not mess up anything like Serializable + * that may depend on how zero-arg constructors are defined. + * + * @param unresolved + */ + private ConverterTypeInfo(Object unresolved) + { + _className = _converterId = null; + } + + public String getClassName() + { + return _className; + } + + + public final String getConverterId() + { + return _converterId; + } +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/Decorator.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/Decorator.java new file mode 100644 index 000000000..57750c827 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/Decorator.java @@ -0,0 +1,15 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.decorator; + +import java.io.Serializable; + +import org.eclipse.jst.jsf.common.runtime.internal.model.ViewObject; + +public abstract class Decorator extends ViewObject implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3138829736243154022L; + + +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/FacetDecorator.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/FacetDecorator.java new file mode 100644 index 000000000..f05f73a5c --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/FacetDecorator.java @@ -0,0 +1,22 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.decorator; + +import org.eclipse.jst.jsf.common.runtime.internal.model.component.ComponentInfo; + +public class FacetDecorator extends ComponentDecorator +{ + /** + * + */ + private static final long serialVersionUID = 94806944978127012L; + + private final String _name; + + public FacetDecorator(final String name, final ComponentInfo component) { + super(component); + _name = name; + } + + public final String getName() { + return _name; + } +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ValidatorDecorator.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ValidatorDecorator.java new file mode 100644 index 000000000..cd0910527 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ValidatorDecorator.java @@ -0,0 +1,15 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.decorator; + +import org.eclipse.jst.jsf.common.runtime.internal.model.component.ComponentInfo; + +public class ValidatorDecorator extends ComponentDecorator { + /** + * + */ + private static final long serialVersionUID = -2898015711621314782L; + + + public ValidatorDecorator(final ComponentInfo decorates) { + super(decorates); + } +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ValidatorTypeInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ValidatorTypeInfo.java new file mode 100644 index 000000000..9ee4836bd --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ValidatorTypeInfo.java @@ -0,0 +1,63 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.decorator; + +import org.eclipse.jst.jsf.common.runtime.internal.model.types.IClassTypeInfo; +import org.eclipse.jst.jsf.common.runtime.internal.model.types.TypeInfo; + +public class ValidatorTypeInfo extends TypeInfo implements IClassTypeInfo +{ + /** + * + */ + private static final long serialVersionUID = 7512992316792276160L; + private final String _validatorId; + private final String _className; + + + /** + * For unknown validators, use the UNKNOWN constant. + * + * @param validatorClass + * @param validatorId + * @throws #{@link IllegalArgumentException} if both className and + * converterId are null. + * + */ + public ValidatorTypeInfo(String validatorClass, String validatorId) + { + super(); + + if (validatorClass == null && validatorId == null) + { + throw new IllegalArgumentException("validatorClass and validatorId must not both be null. For unknown validator use the UNKNOWN constant"); + } + _className = validatorClass; + _validatorId = validatorId; + } + + public static final ValidatorTypeInfo UNKNOWN = + new ValidatorTypeInfo((Object)null); + + /** + * A private constructor used to create the UNRESOLVED constant. + * We use an Object arg here (which is discarded) rather than using + * the zero-arg constructor so as not mess up anything like Serializable + * that may depend on how zero-arg constructors are defined. + * + * @param unresolved + */ + private ValidatorTypeInfo(Object unresolved) + { + _className = _validatorId = null; + } + + public final String getValidatorId() + { + return _validatorId; + } + + public String getClassName() + { + return _className; + } + +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ValueChangeListenerDecorator.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ValueChangeListenerDecorator.java new file mode 100644 index 000000000..2e9d4119b --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/decorator/ValueChangeListenerDecorator.java @@ -0,0 +1,17 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.decorator; + +import org.eclipse.jst.jsf.common.runtime.internal.model.component.ComponentInfo; +import org.eclipse.jst.jsf.common.runtime.internal.model.event.IValueChangeListenerInfo; + +public class ValueChangeListenerDecorator extends ComponentDecorator implements + IValueChangeListenerInfo +{ + /** + * serializable id + */ + private static final long serialVersionUID = 9045831927898936727L; + + public ValueChangeListenerDecorator(ComponentInfo decorates) { + super(decorates); + } +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/event/IActionListenerInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/event/IActionListenerInfo.java new file mode 100644 index 000000000..78cebdb79 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/event/IActionListenerInfo.java @@ -0,0 +1,11 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.event; + +/** + * A design time analog for the ActionListener + * @author cbateman + * + */ +public interface IActionListenerInfo extends IFacesListenerInfo +{ + +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/event/IFacesListenerInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/event/IFacesListenerInfo.java new file mode 100644 index 000000000..d94f1bd40 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/event/IFacesListenerInfo.java @@ -0,0 +1,11 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.event; + +/** + * A design-time analog for the runtime Faces Listener. + * @author cbateman + * + */ +public interface IFacesListenerInfo +{ + // no methods +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/event/IValueChangeListenerInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/event/IValueChangeListenerInfo.java new file mode 100644 index 000000000..edefda03d --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/event/IValueChangeListenerInfo.java @@ -0,0 +1,11 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.event; + +/** + * A design time analog for the runtime ValueChangeListener interface. + * + * @author cbateman + * + */ +public interface IValueChangeListenerInfo extends IFacesListenerInfo { + +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/types/IClassTypeInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/types/IClassTypeInfo.java new file mode 100644 index 000000000..c533a6f4b --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/types/IClassTypeInfo.java @@ -0,0 +1,12 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.types; + +public interface IClassTypeInfo +{ + /** + * The fully qualified class name, i.e. java.lang.String + * + * @return the fully qualified class name in dot notation + * + */ + String getClassName(); +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/types/TypeInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/types/TypeInfo.java new file mode 100644 index 000000000..63692151f --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/model/types/TypeInfo.java @@ -0,0 +1,11 @@ +package org.eclipse.jst.jsf.common.runtime.internal.model.types; + +import java.io.Serializable; + +public abstract class TypeInfo implements Serializable +{ + /** + * serializable id + */ + private static final long serialVersionUID = -3653573923653759724L; +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/IComponentTagElement.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/IComponentTagElement.java new file mode 100644 index 000000000..cc409972b --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/IComponentTagElement.java @@ -0,0 +1,14 @@ +package org.eclipse.jst.jsf.common.runtime.internal.view.model.common; + +import org.eclipse.jst.jsf.common.runtime.internal.model.component.ComponentTypeInfo; + +/** + * A JSF tag element that maps one-to-one to a JSF UIComponent + * + * @author cbateman + * + */ +public interface IComponentTagElement extends IJSFTagElement +{ + ComponentTypeInfo getComponent(); +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/IConverterTagElement.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/IConverterTagElement.java new file mode 100644 index 000000000..91a459c13 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/IConverterTagElement.java @@ -0,0 +1,12 @@ +package org.eclipse.jst.jsf.common.runtime.internal.view.model.common; + +import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ConverterTypeInfo; + +public interface IConverterTagElement extends IJSFTagElement +{ + /** + * @return the type info for the converter represented by this + * element + */ + ConverterTypeInfo getConverter(); +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/IHandlerTagElement.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/IHandlerTagElement.java new file mode 100644 index 000000000..57dbbb263 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/IHandlerTagElement.java @@ -0,0 +1,58 @@ +package org.eclipse.jst.jsf.common.runtime.internal.view.model.common; + +import java.io.Serializable; + +import org.eclipse.jst.jsf.common.runtime.internal.model.types.TypeInfo; + +public interface IHandlerTagElement extends IJSFTagElement +{ + static class TagHandlerType extends TypeInfo implements Serializable + { + /** + * serializable id + */ + private static final long serialVersionUID = 5062853948108253861L; + + private final static int HANDLER_TYPE_FACET = 0; + private final static int HANDLER_TYPE_ACTIONLISTENER = 1; + private final static int HANDLER_TYPE_VALUECHANGELISTENER = 2; + private final static int HANDLER_TYPE_ATTRIBUTE = 3; + + private final static String[] strValues = + {"facet", "actionLister", "valueChangeListener"}; + + private final int _intValue; + + public TagHandlerType(int intValue) + { + _intValue = intValue; + } + + public String toString() + { + return strValues[_intValue]; + } + + protected final int intValue() + { + return _intValue; + } + + public final static TagHandlerType FACET = + new TagHandlerType(HANDLER_TYPE_FACET); + public final static TagHandlerType ACTIONLISTENER = + new TagHandlerType(HANDLER_TYPE_ACTIONLISTENER); + public final static TagHandlerType VALUECHANGELISTENER = + new TagHandlerType(HANDLER_TYPE_VALUECHANGELISTENER); + public final static TagHandlerType ATTRIBUTE = + new TagHandlerType(HANDLER_TYPE_ATTRIBUTE); + + } + + /** + * @return the tag handler type as defined by standard known types of + * tags that do not (necessarily) translate into standard objects at + * runtime but may modify the view in some way. + */ + TagHandlerType getTagHandlerType(); +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/IJSFTagElement.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/IJSFTagElement.java new file mode 100644 index 000000000..22b054c51 --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/IJSFTagElement.java @@ -0,0 +1,60 @@ +package org.eclipse.jst.jsf.common.runtime.internal.view.model.common; + +import java.io.Serializable; + +/** + * An abstraction of a tag element that maps to a JSF artifact (i.e. component, validator) + * + * @author cbateman + * + */ +public interface IJSFTagElement extends ITagElement +{ + static class TagType implements Serializable + { + /** + * serializable id + */ + private static final long serialVersionUID = -2845327764902349963L; + private final static int TYPE_COMPONENT = 0; + private final static int TYPE_CONVERTER = 1; + private final static int TYPE_VALIDATOR = 2; + private final static int TYPE_HANDLER = 3; + //private final static int TYPE_UNKNOWN = 4; + + private final static String[] strValues = + {"component", "converter", "validator", "handler"}; + + private final int _intValue; + + public TagType(int intValue) + { + _intValue = intValue; + } + + public String toString() + { + return strValues[_intValue]; + } + + protected final int intValue() + { + return _intValue; + } + + public final static TagType COMPONENT = + new TagType(TYPE_COMPONENT); + public final static TagType CONVERTER = + new TagType(TYPE_CONVERTER); + public final static TagType VALIDATOR = + new TagType(TYPE_VALIDATOR); + public final static TagType HANDLER = + new TagType(TYPE_HANDLER); + } + + /** + * @return the type of tag as distinguished by how it may affect the + * view at runtime. + */ + TagType getType(); +}
\ 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/view/model/common/ITagElement.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/ITagElement.java new file mode 100644 index 000000000..71952cd6a --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/ITagElement.java @@ -0,0 +1,15 @@ +package org.eclipse.jst.jsf.common.runtime.internal.view.model.common; + +public interface ITagElement { + + /** + * @return the name of the tag + */ + public abstract String getName(); + + /** + * @return the fully qualified class name in dot separated format + * (i.e. javax.faces.webapp.ConverterTag) + */ + public abstract String getTagHandlerClassName(); +}
\ 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/view/model/common/IValidatorTagElement.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/IValidatorTagElement.java new file mode 100644 index 000000000..5a3c4e14d --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/IValidatorTagElement.java @@ -0,0 +1,14 @@ +package org.eclipse.jst.jsf.common.runtime.internal.view.model.common; + +import org.eclipse.jst.jsf.common.runtime.internal.model.decorator.ValidatorTypeInfo; + +/** + * Represents a tag element for a JSF validator. + * + * @author cbateman + * + */ +public interface IValidatorTagElement extends IJSFTagElement +{ + ValidatorTypeInfo getValidator(); +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/Namespace.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/Namespace.java new file mode 100644 index 000000000..13f6905ad --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/Namespace.java @@ -0,0 +1,32 @@ +package org.eclipse.jst.jsf.common.runtime.internal.view.model.common; + +import java.util.Collection; + +/** + * Abstracts an xml namespace used to define a set of view tags + * + */ +public abstract class Namespace +{ + /** + * @return the namespace uri. MUST NOT BE NULL + */ + public abstract String getNSUri(); + + /** + * @return the view elements in this namespace. May be + * empty but MUST NOT BE NULL. + */ + public abstract Collection getViewElements(); + + /** + * @return a user readable display name for this namespace or + * null if none. + */ + public abstract String getDisplayName(); + + public String toString() + { + return getNSUri(); + } +} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/TagElement.java b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/TagElement.java new file mode 100644 index 000000000..cfba225fa --- /dev/null +++ b/jsf/plugins/org.eclipse.jst.jsf.common.runtime/src/org/eclipse/jst/jsf/common/runtime/internal/view/model/common/TagElement.java @@ -0,0 +1,20 @@ +package org.eclipse.jst.jsf.common.runtime.internal.view.model.common; + +/** + * Abstract a tag element used to construct a view element + * + * @author cbateman + * + */ +public abstract class TagElement implements ITagElement +{ + /* (non-Javadoc) + * @see viewhandlerprototype.model.ITagElement#getName() + */ + public abstract String getName(); + + /* (non-Javadoc) + * @see org.eclipse.jst.jsf.common.runtime.internal.view.model.common.ITagElement#getTagHandlerClassName() + */ + public abstract String getTagHandlerClassName(); +} |