Initial commit from SVN.
This commit is contained in:
11
Vml Builder/.classpath
Normal file
11
Vml Builder/.classpath
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Class File Services"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Common"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Foundation"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Foundation View Builder"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Obfuscation"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
17
Vml Builder/.project
Normal file
17
Vml Builder/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Vml Builder</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 2008,2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.declarativeengineering.builder;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.common.debug.Debug;
|
||||
import com.common.debug.DefaultLog;
|
||||
import com.common.util.LiteList;
|
||||
import com.foundation.view.builder.IVmlBuilder;
|
||||
|
||||
/**
|
||||
* This is a simple interface for the plugin to interact with the VML builder code that is distributed with the framework.
|
||||
* <p>Note: The caller of the VML builder must create a new instance for each build thread. The instance should be released when the full build is complete so that application classes can be modified by the user.</p>
|
||||
*/
|
||||
public class VmlBuilder implements IVmlBuilder {
|
||||
private VmlBuilderClassLoader classLoader = null;
|
||||
/**
|
||||
* VmlBuilder constructor.
|
||||
*/
|
||||
public VmlBuilder() {
|
||||
super();
|
||||
}//VmlBuilder()//
|
||||
/**
|
||||
* Builds a vml file.
|
||||
* <p><b>Warning: This is not a thread safe method (and can't easily be made so due to the Debug Log).</b></p>
|
||||
* @param vmlStream The input stream containing the source VML being built.
|
||||
* @param builderPath The path to the builder jar containing the core code base for the VML builder.
|
||||
* @param componentTypePaths The directories containing the VML component files, one directory per component (usually).
|
||||
* @param packageName The package name for the generated VML/Java source code.
|
||||
* @param applicationClassPaths The class paths known by the application whose VML file is being built. This is used to load class metadata while building the java source from the VML.
|
||||
* @param results The mapping of results by their identifiers (to allow for more of a separation between the framework based builder code and the plugin).
|
||||
*/
|
||||
public void build(InputStream vmlStream, File builderPath, File[] componentTypePaths, String packageName, File[] applicationClassPaths, final HashMap results) {
|
||||
final StringBuffer log = new StringBuffer(10000);
|
||||
Debug.setLog(new DefaultLog() {
|
||||
public void log(String note, Throwable exception, boolean forceDisplay) {
|
||||
if(note != null) {
|
||||
log.append(note);
|
||||
log.append("\r\n");
|
||||
}//if//
|
||||
|
||||
if(exception != null) {
|
||||
StringWriter stringWriter = new StringWriter(1000);
|
||||
PrintWriter printWriter = new PrintWriter(stringWriter);
|
||||
|
||||
exception.printStackTrace(printWriter);
|
||||
log.append(stringWriter.toString());
|
||||
log.append("\r\n");
|
||||
}//if//
|
||||
}//log()//
|
||||
});
|
||||
|
||||
if(classLoader == null) {
|
||||
if(getClass().getName().startsWith("com")) {
|
||||
classLoader = new VmlBuilderClassLoader(builderPath, componentTypePaths, LiteList.EMPTY_LIST, LiteList.EMPTY_LIST, null);
|
||||
}//if//
|
||||
else {
|
||||
//TODO: Pass security...
|
||||
//Warning: If the included/excluded packages are modified they might also need modifying in the ant build for the builder.jar, and JetsonApplication, and SprocketApplication (both in the deployment workspace).//
|
||||
LiteList includedPackages = new LiteList(new String[] {"com/de22", "com/common", "com/foundation", "com/declarativeengineering"});
|
||||
//LiteList includedPackages = new LiteList(new String[0]);
|
||||
LiteList excludedPackages = new LiteList(new String[] {"com/foundation/view/swt/builder", "com/foundation/tcv/swt/builder", "com/declarativeengineering/jetson", "com/foundation/de22", "com/foundation/novocode", "com/de22/swt"});
|
||||
|
||||
classLoader = new VmlBuilderClassLoader(builderPath, componentTypePaths, excludedPackages, includedPackages, null);
|
||||
}//else//
|
||||
}//if//
|
||||
|
||||
//Note: We are using reflection here because we need to load the VmlBuilderStaging class in a different class loader that will create the zjar's from the control jars in all the control directories.//
|
||||
//Warning: We have to do this again in the VmlBuilderStaging class to demangle the java source that is generated.//
|
||||
try {
|
||||
Object staging = Class.forName("com.declarativeengineering.builder.VmlBuilderStaging", true, classLoader).newInstance();
|
||||
Method buildMethod = null;
|
||||
|
||||
//Try the unmangled name first.//
|
||||
// DEBUG
|
||||
try {
|
||||
buildMethod = staging.getClass().getMethod("build", new Class[] {InputStream.class, File[].class, String.class, File[].class, HashMap.class});
|
||||
}//try//
|
||||
catch(Throwable e) {
|
||||
//Debug.log(e);
|
||||
}//catch//
|
||||
|
||||
if(buildMethod == null) {
|
||||
try {
|
||||
buildMethod = staging.getClass().getMethod("ec06440700069006", new Class[] {InputStream.class, File[].class, String.class, File[].class, HashMap.class});
|
||||
}//try//
|
||||
catch(Throwable e) {
|
||||
Debug.log(e);
|
||||
}//catch//
|
||||
}//if//
|
||||
|
||||
buildMethod.invoke(staging, new Object[] {vmlStream, componentTypePaths, packageName, applicationClassPaths, results});
|
||||
}//try//
|
||||
catch(Throwable e) {
|
||||
Debug.log(e);
|
||||
}//catch//
|
||||
|
||||
//Place the log output into the results mapping.//
|
||||
results.put(RESULT_LOG, log.toString());
|
||||
}//build()//
|
||||
}//VmlBuilder//
|
||||
@@ -0,0 +1,358 @@
|
||||
/*
|
||||
* Copyright (c) 2003,2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.declarativeengineering.builder;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.jar.*;
|
||||
|
||||
import com.common.comparison.Comparator;
|
||||
import com.common.debug.Debug;
|
||||
import com.common.io.StreamSupport;
|
||||
import com.common.io.SymmetricInputStream;
|
||||
import com.common.security.ISymmetricAlgorithm;
|
||||
import com.common.util.*;
|
||||
import com.de22.obfuscation.RuntimeMangler;
|
||||
import com.foundation.util.xml.*;
|
||||
import com.foundation.view.builder.ViewBuilderException;
|
||||
import com.foundation.view.definition.ComponentType;
|
||||
import com.foundation.view.definition.IComponentType;
|
||||
import com.foundation.view.definition.TypeDefinitionException;
|
||||
|
||||
/**
|
||||
* Used to load the view component builders only.
|
||||
*/
|
||||
public class VmlBuilderClassLoader extends ClassLoader {
|
||||
public static final String TYPE_FILE_EXTENSION = ".cml"; //Control Modeling Language.//
|
||||
public static final String FILE_SEPARATOR = System.getProperty("file.separator");
|
||||
|
||||
/** The path to the builder code. */
|
||||
private File builderJar = null;
|
||||
/** The path to the jars containing builders for specific components. */
|
||||
private File[] jars = null;
|
||||
/** The mapping of unmangled class names indexed by mangled class names, used to reverse mangling in the generated java source. */
|
||||
private IHashMap mangleMap = new LiteHashMap(40);
|
||||
/** The mangler used to generate the zjar files. */
|
||||
private RuntimeMangler mangler = null;
|
||||
/** The optional algorithm to use to encrypt/decrypt the zjar entries. */
|
||||
private ISymmetricAlgorithm algorithm = null;
|
||||
/**
|
||||
* VmlBuilderClassLoader constructor.
|
||||
* @param codeBaseJarPath The path to the jar containing the core code base for the VML builder.
|
||||
* @param componentPaths The paths to the component directories where the component jars will be kept.
|
||||
* @param excludedPackages The collection of packages not to be included for any reason in the mangling (includes subpackages). (example: com/myproject/donotmangle)
|
||||
* @param includedPackages The collection of packages to include in the mangling if not explicitly excluded (includes subpackages). (example: com/myproject/domangle)
|
||||
* @param algorithm The optional algorithm used to encrypt the zjar contents.
|
||||
*/
|
||||
public VmlBuilderClassLoader(File codeBaseJarPath, File[] componentPaths, IList excludedPackages, IList includedPackages, ISymmetricAlgorithm algorithm) {
|
||||
super(null);
|
||||
long ts = System.currentTimeMillis();
|
||||
LiteList jars = new LiteList(componentPaths.length, 20);
|
||||
File[] jarFiles = null;
|
||||
LiteHashSet jarSet = new LiteHashSet(40, LiteHashSet.DEFAULT_LOAD_FACTOR, Comparator.getLogicalComparator(), LiteHashSet.STYLE_NO_DUPLICATES);
|
||||
|
||||
System.out.println("Initializing VmlBuilderClassLoader");
|
||||
this.builderJar = codeBaseJarPath;
|
||||
jarSet.add(codeBaseJarPath.getName());
|
||||
|
||||
//Note: The control directories are the folders containing component jars. Only one jar of a perticular name will be allowed for any set of control directories.//
|
||||
//Collect all the jars in the control directories.//
|
||||
for(int controlDirectoryIndex = 0; controlDirectoryIndex < componentPaths.length; controlDirectoryIndex++) {
|
||||
File nextControlDirectory = componentPaths[controlDirectoryIndex];
|
||||
File[] files = nextControlDirectory.listFiles();
|
||||
|
||||
for(int fileIndex = 0; fileIndex < files.length; fileIndex++) {
|
||||
File nextFile = files[fileIndex];
|
||||
|
||||
if(nextFile.isFile() && nextFile.canRead() && nextFile.getName().endsWith(".jar") && !jarSet.containsValue(nextFile.getName()) && !nextFile.getName().equalsIgnoreCase("builder.jar")) {
|
||||
jars.add(nextFile);
|
||||
jarSet.add(nextFile.getName());
|
||||
}//if//
|
||||
}//for//
|
||||
}//for//
|
||||
|
||||
//Mangle the component jars (generating zjar files).//
|
||||
jars.toArray(jarFiles = new File[jars.getSize()]);
|
||||
/* DEBUG
|
||||
try {
|
||||
Debug.log("Loading Jars: ");
|
||||
for(int index = 0; index < jarFiles.length; index++) {
|
||||
Debug.log(jarFiles[index].getCanonicalPath());
|
||||
}//for//
|
||||
Debug.log("End Jars");
|
||||
}catch(Throwable e) {Debug.log(e);}
|
||||
*/
|
||||
mangler = new RuntimeMangler(new File[] {codeBaseJarPath}, excludedPackages, includedPackages, mangleMap);
|
||||
|
||||
try {
|
||||
mangler.mangleJars(jarFiles, algorithm);
|
||||
}//try//
|
||||
catch(Throwable e) {
|
||||
Debug.log(e, "Failed to pre-mangle the VML component jars.");
|
||||
}//catch//
|
||||
|
||||
this.jars = new File[jarFiles.length];
|
||||
|
||||
//Convert the paths to the jars to paths to the zjars.//
|
||||
for(int index = 0; index < jarFiles.length; index++) {
|
||||
String path = jarFiles[index].getAbsolutePath();
|
||||
|
||||
this.jars[index] = new File(path.substring(0, path.length() - 3) + "zjar");
|
||||
}//for//
|
||||
System.out.println("Finished Initializing VmlBuilderClassLoader taking " + (System.currentTimeMillis() - ts) + "ms.");
|
||||
}//VmlBuilderClassLoader()//
|
||||
/**
|
||||
* Removes mangled class names from the java source.
|
||||
* @param source The java source potentially containing mangled class names.
|
||||
* @return The source without the mangled class names.
|
||||
*/
|
||||
public String demangleJavaSource(String source) {
|
||||
//TODO: Make this non-static in the mangler - and remove the need to have an external mangle map.
|
||||
return mangler.demangleSource(source, mangleMap);
|
||||
}//demangleJavaSource()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.ClassLoader#findClass(java.lang.String)
|
||||
*/
|
||||
protected Class findClass(String className) throws ClassNotFoundException {
|
||||
Class type = null;
|
||||
String classFileName = className.replace('.', '/') + ".class";
|
||||
|
||||
//Debug.log("Got to builder.jar's VmlBuilderClassLoader. Looking for class: " + className);
|
||||
/*
|
||||
try {
|
||||
type = super.findClass(className);
|
||||
}//try//
|
||||
catch(ClassNotFoundException e) {
|
||||
//Ignore.//
|
||||
}//catch//
|
||||
*/
|
||||
if(type == null) {
|
||||
type = findClass(builderJar, className, classFileName);
|
||||
|
||||
for(int index = 0; type == null && index < jars.length; index++) {
|
||||
if(jars[index].exists() && jars[index].canRead()) {
|
||||
type = findClass(jars[index], className, classFileName);
|
||||
}//if//
|
||||
}//while//
|
||||
}//if//
|
||||
|
||||
if(type == null) {
|
||||
throw new ClassNotFoundException("Couldn't find the class: " + className);
|
||||
}//if//
|
||||
|
||||
return type;
|
||||
}//findClass()//
|
||||
/**
|
||||
* Finds the given class by searching the given file or directory.
|
||||
* @param file The file or directory to search.
|
||||
* @param classFileName The name of the class to find.
|
||||
*/
|
||||
private Class findClass(File file, String className, String classFileName) throws ClassNotFoundException {
|
||||
Class type = null;
|
||||
|
||||
if(file.exists()) {
|
||||
byte[] bytes = null;
|
||||
|
||||
try {
|
||||
String path = file.getCanonicalPath();
|
||||
|
||||
if(path.endsWith(".jar")) {
|
||||
JarFile jar = new JarFile(file, false, JarFile.OPEN_READ);
|
||||
|
||||
try {
|
||||
JarEntry entry = jar.getJarEntry(classFileName);
|
||||
|
||||
if(entry != null) {
|
||||
InputStream in = jar.getInputStream(entry);
|
||||
|
||||
bytes = StreamSupport.readBytes(in, in.available());
|
||||
in.close();
|
||||
}//if//
|
||||
}//try//
|
||||
finally {
|
||||
if(jar != null) {
|
||||
jar.close();
|
||||
}//if//
|
||||
}//finally//
|
||||
}//if//
|
||||
else if(path.endsWith(".zjar")) {
|
||||
JarFile jar = new JarFile(file, false, JarFile.OPEN_READ);
|
||||
|
||||
try {
|
||||
JarEntry entry = jar.getJarEntry(classFileName);
|
||||
|
||||
if(entry != null) {
|
||||
InputStream in = jar.getInputStream(entry);
|
||||
|
||||
bytes = StreamSupport.readBytes(in, in.available());
|
||||
in.close();
|
||||
|
||||
//This reads in the bytes after decrypting and decompressing them - see RuntimeMangler for the code that creates the zjar.//
|
||||
if(algorithm != null) {
|
||||
ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
|
||||
SymmetricInputStream sin = new SymmetricInputStream(bin, algorithm);
|
||||
ZipInputStream zin = new ZipInputStream(sin);
|
||||
|
||||
bytes = StreamSupport.readBytes(zin, bytes.length * 2);
|
||||
}//if//
|
||||
}//if//
|
||||
}//try//
|
||||
finally {
|
||||
if(jar != null) {
|
||||
jar.close();
|
||||
}//if//
|
||||
}//finally//
|
||||
}//else if//
|
||||
|
||||
if(bytes != null) {
|
||||
type = defineClass(className, bytes, 0, bytes.length);
|
||||
}//if//
|
||||
}//try//
|
||||
catch(IOException e) {
|
||||
throw new ViewBuilderException(e, -1, -1, -1);
|
||||
}//catch//
|
||||
}//if//
|
||||
|
||||
return type;
|
||||
}//findClass()//
|
||||
/**
|
||||
* Loads component type objects from all *.cml files in the given paths.
|
||||
* The result collection will be filled with ComponentType instances indexed by the component type's name (String instances).
|
||||
* @param paths The directories or specific *.cml files to be loaded. Subdirectories will not be searched.
|
||||
* @param results The optional collection in which to place the resulting ComponentType instances.
|
||||
* @return The result mapping of component type instances indexed by their names. This will be the same object as the results parameter if results is not null.
|
||||
*/
|
||||
private static IHashMap loadComponentTypes(java.io.File[] paths, IHashMap results) {
|
||||
LiteHashSet searchedPaths = new LiteHashSet(20);
|
||||
|
||||
if(results == null) {
|
||||
results = new LiteHashMap(100);
|
||||
}//if//
|
||||
|
||||
for(int pathIndex = 0; pathIndex < paths.length; pathIndex++) {
|
||||
java.io.File path = paths[pathIndex];
|
||||
|
||||
if(path.exists()) {
|
||||
if(path.isDirectory()) {
|
||||
String canonicalPath = null;
|
||||
|
||||
try {
|
||||
path.getCanonicalPath();
|
||||
}//try//
|
||||
catch(Throwable e) {
|
||||
//Ignore.//
|
||||
}//catch//
|
||||
|
||||
if(canonicalPath == null || !searchedPaths.containsValue(canonicalPath)) {
|
||||
java.io.File[] files = path.listFiles(new java.io.FilenameFilter() {
|
||||
public boolean accept(File directory, String name) {
|
||||
return name.endsWith(TYPE_FILE_EXTENSION);
|
||||
}//accept()//
|
||||
});
|
||||
|
||||
searchedPaths.add(canonicalPath);
|
||||
|
||||
for(int fileIndex = 0; fileIndex < files.length; fileIndex++) {
|
||||
loadComponentType(files[fileIndex], results);
|
||||
}//for//
|
||||
}//if//
|
||||
}//if//
|
||||
else if((path.isFile()) && (path.getName().endsWith(TYPE_FILE_EXTENSION))) {
|
||||
loadComponentType(path, results);
|
||||
}//else if//
|
||||
else {
|
||||
//Ignore.//
|
||||
}//else//
|
||||
}//if//
|
||||
}//if//
|
||||
|
||||
initializeComponentTypes(results);
|
||||
|
||||
return results;
|
||||
}//loadComponentTypes()//
|
||||
/**
|
||||
* Loads component type objects from all *.cml files in the given paths.
|
||||
* @param path The file containing component type information.
|
||||
* @param results The collection in which to place the resulting ComponentType instance.
|
||||
*/
|
||||
private static void loadComponentType(File file, IHashMap types) {
|
||||
FileInputStream in = null;
|
||||
|
||||
try {
|
||||
DocumentBuilder builder = new DocumentBuilder(" while parsing the file: " + file.getAbsolutePath());
|
||||
IDocument document = null;
|
||||
IIterator iterator = null;
|
||||
|
||||
in = new FileInputStream(file);
|
||||
builder.setIgnoreComments(Boolean.TRUE);
|
||||
builder.setIgnoreTextWhitespace(Boolean.TRUE);
|
||||
document = builder.readDocument(in, null);
|
||||
iterator = document.getElements().iterator();
|
||||
|
||||
while(iterator.hasNext()) {
|
||||
IElement element = (IElement) iterator.next();
|
||||
|
||||
if((element.isNode()) && (((INode) element).getName().equalsIgnoreCase(IComponentType.NODE_NAME))) {
|
||||
ComponentType componentType = new ComponentType();
|
||||
|
||||
try {
|
||||
componentType.readXml((INode) element);
|
||||
|
||||
//Don't add duplicate types.//
|
||||
if(!types.containsKey(componentType.getName())) {
|
||||
types.put(componentType.getName(), componentType);
|
||||
|
||||
//Update the path to the builder code library.//
|
||||
if((componentType.getBuilderDefinition() != null) && (componentType.getBuilderDefinition().getCodeLocation() != null)) {
|
||||
componentType.getBuilderDefinition().setCodeLocation(new File(file.getParent(), componentType.getBuilderDefinition().getCodeLocation()).getAbsolutePath());
|
||||
}//if//
|
||||
}//if//
|
||||
else {
|
||||
//Don't throw an exception because this may not be an error.//
|
||||
//throw new ViewBuilderException("Found duplicate component type: " + componentType.getName(), -1, -1, -1);
|
||||
}//else//
|
||||
}//try//
|
||||
catch(ViewBuilderException e) {
|
||||
throw e;
|
||||
}//catch//
|
||||
catch(Throwable e) {
|
||||
Debug.log(e);
|
||||
throw new ViewBuilderException(e, -1, -1, -1);
|
||||
}//catch//
|
||||
}//if//
|
||||
}//while//
|
||||
}//try//
|
||||
catch(IOException e) {
|
||||
throw new ViewBuilderException(e, -1, -1, -1);
|
||||
}//catch//
|
||||
finally {
|
||||
if(in != null) {
|
||||
try {in.close();} catch(IOException e) {} //Ignore the exception.//
|
||||
}//if//
|
||||
}//finally//
|
||||
}//loadComponentType()//
|
||||
/**
|
||||
* Initializes each of the component types once all types have been loaded.
|
||||
* @param types The mapping of component types by the unique type name.
|
||||
*/
|
||||
private static void initializeComponentTypes(IHashMap types) {
|
||||
IIterator iterator = types.getKeys(new LiteList(types.getSize())).iterator();
|
||||
|
||||
while(iterator.hasNext()) {
|
||||
String typeName = (String) iterator.next();
|
||||
|
||||
try {
|
||||
((ComponentType) types.get(typeName)).initialize(types);
|
||||
}//try//
|
||||
catch(TypeDefinitionException e) {
|
||||
types.remove(typeName);
|
||||
throw new ViewBuilderException(e, -1, -1, -1);
|
||||
}//catch//
|
||||
}//while//
|
||||
}//initializeComponentTypes()//
|
||||
}//BuilderClassLoader//
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright (c) 2008,2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.declarativeengineering.builder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.common.debug.Debug;
|
||||
import com.common.util.IList;
|
||||
import com.common.util.LiteList;
|
||||
import com.foundation.view.builder.BuildFailedException;
|
||||
import com.foundation.view.builder.ClassMetadataLoader;
|
||||
import com.foundation.view.builder.IClassMetadataLoader;
|
||||
import com.foundation.view.builder.IVmlBuilder;
|
||||
import com.foundation.view.builder.ViewBuilderException;
|
||||
import com.foundation.view.builder.ViewSourceBuilder;
|
||||
import com.foundation.view.definition.Message;
|
||||
import com.foundation.view.definition.ViewModel;
|
||||
|
||||
public class VmlBuilderStaging implements IVmlBuilder {
|
||||
private IClassMetadataLoader loader = null;
|
||||
/**
|
||||
* VmlBuilderStaging constructor.
|
||||
*/
|
||||
public VmlBuilderStaging() {
|
||||
}//VmlBuilderStaging()//
|
||||
/**
|
||||
* Builds a vml file.
|
||||
* @param vmlStream The input stream containing the source VML being built.
|
||||
* @param componentTypePaths The directories containing the VML component files, one directory per component (usually).
|
||||
* @param packageName The package name for the generated VML/Java source code.
|
||||
* @param applicationClassPaths The class paths known by the application whose VML file is being built. This is used to load class metadata while building the java source from the VML.
|
||||
* @param results The mapping of results by their identifiers (to allow for more of a separation between the framework based builder code and the plugin).
|
||||
*/
|
||||
public void build(InputStream vmlStream, File[] componentTypePaths, String packageName, File[] applicationClassPaths, final HashMap results) {
|
||||
String source = null;
|
||||
IList messageStack = new LiteList(10, 100);
|
||||
ArrayList messages;
|
||||
|
||||
//Initialize and operate the view builder to generate the source and package name.//
|
||||
try {
|
||||
ViewSourceBuilder viewBuilder = null;
|
||||
ViewModel viewModel = null;
|
||||
|
||||
if(loader == null) {
|
||||
loader = new ClassMetadataLoader(applicationClassPaths);
|
||||
}//if//
|
||||
|
||||
//Initialize the view model and builder.//
|
||||
viewModel = new ViewModel(loader, messageStack) {
|
||||
protected void storeViewData(byte[] document) {
|
||||
//TODO: Place the modified VML in the results mapping.
|
||||
results.put(RESULT_VML_SOURCE, document);
|
||||
}//storeViewData()//
|
||||
};
|
||||
viewModel.initialize(ViewModel.loadComponentTypes(componentTypePaths, null), vmlStream, packageName);
|
||||
|
||||
if(!hasErrors(messageStack)) {
|
||||
viewBuilder = new ViewSourceBuilder(viewModel, loader);
|
||||
//Get the view's java source code.//
|
||||
source = viewBuilder.getViewSource(null);
|
||||
//Get the package name we are to use for the source.//
|
||||
packageName = viewModel.getViewMetadata().getPackage();
|
||||
}//if//
|
||||
}//try//
|
||||
catch(ViewBuilderException e) {
|
||||
messageStack.add(new Message(true, null, e, e.getLineNumber(), e.getCharacterStart(), e.getCharacterEnd()));
|
||||
}//catch//
|
||||
catch(BuildFailedException e) {
|
||||
//Ignore.//
|
||||
}//catch//
|
||||
catch(Throwable e) {
|
||||
messageStack.add(new Message(true, null, e));
|
||||
|
||||
while(e.getCause() != null) {
|
||||
e = e.getCause();
|
||||
messageStack.add(new Message(true, "Caused by:", e));
|
||||
}//while//
|
||||
}//catch//
|
||||
|
||||
//Place the messages into the results mapping.//
|
||||
messages = new ArrayList(messageStack.getSize());
|
||||
|
||||
for(int index = 0; index < messageStack.getSize(); index++) {
|
||||
Message message = (Message) messageStack.get(index);
|
||||
HashMap messageMap = new HashMap(10);
|
||||
|
||||
messageMap.put(RESULT_MESSAGE_TEXT, message.getMessage());
|
||||
messageMap.put(RESULT_MESSAGE_EXCEPTION, message.getException());
|
||||
messageMap.put(RESULT_MESSAGE_START_CHARACTER, new Integer(message.getStartCharacter()));
|
||||
messageMap.put(RESULT_MESSAGE_END_CHARACTER, new Integer(message.getEndCharacter()));
|
||||
messageMap.put(RESULT_MESSAGE_LINE_NUMBER, new Integer(message.getLineNumber()));
|
||||
messageMap.put(RESULT_MESSAGE_IS_ERROR, new Boolean(message.isError()));
|
||||
//log.append("VML Build Message [text: " + message.getMessage() + " |isError: " + message.isError() + "]\n");
|
||||
messages.add(messageMap);
|
||||
}//for//
|
||||
|
||||
//Write the source code to the java file.//
|
||||
if((source != null) && (source.length() > 0) && (packageName != null)) {
|
||||
Method method = null;
|
||||
|
||||
// DEBUG
|
||||
try {
|
||||
method = getClass().getClassLoader().getClass().getMethod("demangleJavaSource", new Class[] {String.class});
|
||||
}//try//
|
||||
catch(Throwable e) {
|
||||
//Debug.log(e);
|
||||
}//catch//
|
||||
|
||||
if(method == null) {
|
||||
try {
|
||||
method = getClass().getClassLoader().getClass().getMethod("e7300af2217feb13", new Class[] {String.class});
|
||||
}//try//
|
||||
catch(Throwable e) {
|
||||
Debug.log(e);
|
||||
}//catch//
|
||||
}//if//
|
||||
|
||||
try {
|
||||
source = (String) method.invoke(getClass().getClassLoader(), new Object[] {source});
|
||||
}//try//
|
||||
catch(Throwable e) {
|
||||
Debug.log(e, "Caught while de-mangling the java source.");
|
||||
}//catch//
|
||||
}//if//
|
||||
|
||||
//Place the compiler messages into the results mapping.//
|
||||
results.put(RESULT_MESSAGES, messages);
|
||||
//Place the java source into the results mapping.//
|
||||
results.put(RESULT_JAVA_SOURCE, source);
|
||||
//Place the package name into the results mapping.//
|
||||
results.put(RESULT_PACKAGE_NAME, packageName);
|
||||
}//build()//
|
||||
/**
|
||||
* Tests the message stack for errors.
|
||||
* @param messageStack The collection of compiler messages.
|
||||
* @return Whether any of the messages are errors.
|
||||
*/
|
||||
private boolean hasErrors(IList messageStack) {
|
||||
for(int index = 0; index < messageStack.getSize(); index++) {
|
||||
if(((Message) messageStack.get(index)).isError()) {
|
||||
return true;
|
||||
}//if//
|
||||
}//for//
|
||||
|
||||
return false;
|
||||
}//hasErrors()//
|
||||
}//VmlBuilderStaging//
|
||||
430
Vml Builder/src/com/foundation/view/builder/BuilderSupport.java
Normal file
430
Vml Builder/src/com/foundation/view/builder/BuilderSupport.java
Normal file
@@ -0,0 +1,430 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.builder;
|
||||
|
||||
import com.common.util.IList;
|
||||
import com.common.util.LiteHashSet;
|
||||
import com.common.util.LiteList;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.view.definition.Message;
|
||||
|
||||
public class BuilderSupport {
|
||||
public static final String[] EMPTY_CLASS_ARRAY = new String[0]; //Optimization.//
|
||||
private static final LiteHashSet primitiveTypeNames = new LiteHashSet(new Object[] {"boolean", "int", "byte", "short", "long", "float", "double", "char"});
|
||||
/**
|
||||
* BuilderSupport constructor.
|
||||
*/
|
||||
private BuilderSupport() {}
|
||||
/**
|
||||
* Gets the method return class and parameter classes in order that they occur. The return class will be first in the results.
|
||||
* @param methodSignature The full signature of the method including the return type. The full signature has the parameters in parenthesis followed by the return type.
|
||||
* @param feedbackStack The optional stack of feedback Message instances to use when generating errors and warnings.
|
||||
* @param debugElement The optional document element used to identify exactly where in the VML source the error occured.
|
||||
* @return The fully qualified class names using dot notation ('.' instead of '/' and '$' as separators, and with "[]" at the end for arrays). The first entry will be the return type of the method.
|
||||
*/
|
||||
public static String[] getMethodSignatureTypes(String methodSignature, IList feedbackStack, IElement debugElement) {
|
||||
String[] result = EMPTY_CLASS_ARRAY;
|
||||
|
||||
if((methodSignature != null) && (methodSignature.length() > 0)) {
|
||||
LiteList classes = new LiteList(10, 10);
|
||||
int arrayCount = 0;
|
||||
String className = null;
|
||||
boolean error = false;
|
||||
|
||||
if(methodSignature.charAt(0) == '(') {
|
||||
int parenIndex = methodSignature.indexOf(')');
|
||||
|
||||
if(parenIndex == -1 && methodSignature.length() >= parenIndex + 1) {
|
||||
error = true;
|
||||
}//if//
|
||||
else {
|
||||
className = methodSignature.substring(parenIndex + 1).replace('\\', '.').replace('/', '.').replace('$', '.');
|
||||
|
||||
for(int index = 0; !error && index < className.length(); index++) {
|
||||
switch(methodSignature.charAt(index)) {
|
||||
case '[': {
|
||||
arrayCount++;
|
||||
break;
|
||||
}//case//
|
||||
case 'L': {
|
||||
int endIndex = methodSignature.indexOf(';', index);
|
||||
|
||||
if(endIndex == -1) {
|
||||
error = true;
|
||||
}//if//
|
||||
else {
|
||||
className = methodSignature.substring(index + 1, endIndex).replace('\\', '.').replace('/', '.').replace('$', '.');
|
||||
index = endIndex;
|
||||
}//else//
|
||||
break;
|
||||
}//case//
|
||||
default: {
|
||||
//Class.forName does not allow "I"//
|
||||
switch(methodSignature.charAt(index)) {
|
||||
case 'J': {
|
||||
className = Long.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'I': {
|
||||
className = Integer.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'S': {
|
||||
className = Short.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'B': {
|
||||
className = Byte.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'F': {
|
||||
className = Float.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'D': {
|
||||
className = Double.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'C': {
|
||||
className = Character.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'Z': {
|
||||
className = Boolean.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
default: {
|
||||
error = true;
|
||||
}//default//
|
||||
}//switch//
|
||||
}//default//
|
||||
}//switch//
|
||||
|
||||
if(className != null) {
|
||||
while(arrayCount-- > 0) {
|
||||
className += "[]";
|
||||
}//while//
|
||||
|
||||
classes.add(className);
|
||||
|
||||
//Ensure we have no more characters in the signature.//
|
||||
if(index + 1 < className.length()) {
|
||||
error = true;
|
||||
}//if//
|
||||
}//if//
|
||||
}//for//
|
||||
}//else//
|
||||
}//if//
|
||||
|
||||
for(int index = 0; !error && index < methodSignature.length(); index++) {
|
||||
switch(methodSignature.charAt(index)) {
|
||||
case '[': {
|
||||
arrayCount++;
|
||||
break;
|
||||
}//case//
|
||||
case 'L': {
|
||||
int endIndex = methodSignature.indexOf(';', index);
|
||||
|
||||
if(endIndex == -1) {
|
||||
error = true;
|
||||
}//if//
|
||||
else {
|
||||
className = methodSignature.substring(index + 1, endIndex).replace('\\', '.').replace('/', '.').replace('$', '.');
|
||||
index = endIndex + 1;
|
||||
}//else//
|
||||
break;
|
||||
}//case//
|
||||
default: {
|
||||
//Class.forName does not allow "I"//
|
||||
switch(methodSignature.charAt(index)) {
|
||||
case 'J': {
|
||||
className = Long.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'I': {
|
||||
className = Integer.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'S': {
|
||||
className = Short.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'B': {
|
||||
className = Byte.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'F': {
|
||||
className = Float.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'D': {
|
||||
className = Double.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'C': {
|
||||
className = Character.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'Z': {
|
||||
className = Boolean.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
default: {
|
||||
error = true;
|
||||
}//default//
|
||||
}//switch//
|
||||
}//default//
|
||||
}//switch//
|
||||
|
||||
if(className != null) {
|
||||
while(arrayCount-- > 0) {
|
||||
className += "[]";
|
||||
}//while//
|
||||
|
||||
classes.add(className);
|
||||
arrayCount = 0;
|
||||
}//if//
|
||||
}//for//
|
||||
|
||||
if(classes.getSize() > 0) {
|
||||
result = new String[classes.getSize()];
|
||||
classes.toArray(result);
|
||||
}//if//
|
||||
|
||||
if(error) {
|
||||
String message = "Error: Invalid signature format. Signature = " + methodSignature + ". The signature must be in class file format where classes are fully qualified and begin with a capital 'L', end with a semi-colon ';', use '$' to separate inner class names, may use '/' instead of '.' to separate package names, and are prefixed with '[' for each array dimension. Native types use the letters J (long), I (integer), S (short), B (byte), F (float), D (double), Z (boolean). Example: ([ILjava.lang.Object)[[Ljava.lang.String; which means some method with a result of String[][] and parameters of (int[], Object).";
|
||||
|
||||
if(feedbackStack != null) {
|
||||
feedbackStack.add(new Message(true, message, debugElement));
|
||||
}//if//
|
||||
else {
|
||||
throw new ViewBuilderException(message, debugElement);
|
||||
}//else//
|
||||
}//if//
|
||||
}//if//
|
||||
|
||||
return result;
|
||||
}//getMethodSignatureTypes()//
|
||||
/**
|
||||
* Gets the method parameter classes in order that they occur.
|
||||
* @param methodParameters The parameters of the method excluding the return type.
|
||||
* @param feedbackStack The optional stack of feedback Message instances to use when generating errors and warnings.
|
||||
* @param debugElement The optional document element used to identify exactly where in the VML source the error occured.
|
||||
* @return The fully qualified class names using java source notation ('.' instead of '/' and '$' as separators, and with "[]" at the end for arrays).
|
||||
*/
|
||||
public static String[] getMethodParameterTypes(String methodSignature, IList feedbackStack, IElement debugElement) {
|
||||
String[] result = EMPTY_CLASS_ARRAY;
|
||||
|
||||
if((methodSignature != null) && (methodSignature.length() > 0)) {
|
||||
LiteList classes = new LiteList(10, 10);
|
||||
int arrayCount = 0;
|
||||
String className = null;
|
||||
boolean error = false;
|
||||
|
||||
for(int index = 0; !error && index < methodSignature.length(); index++) {
|
||||
switch(methodSignature.charAt(index)) {
|
||||
case '[': {
|
||||
arrayCount++;
|
||||
break;
|
||||
}//case//
|
||||
case 'L': {
|
||||
int endIndex = methodSignature.indexOf(';', index);
|
||||
|
||||
if(endIndex == -1) {
|
||||
error = true;
|
||||
}//if//
|
||||
else {
|
||||
className = methodSignature.substring(index + 1, endIndex).replace('\\', '.').replace('/', '.').replace('$', '.');
|
||||
index = endIndex;
|
||||
}//else//
|
||||
break;
|
||||
}//case//
|
||||
default: {
|
||||
//Class.forName does not allow "I"//
|
||||
switch(methodSignature.charAt(index)) {
|
||||
case 'J': {
|
||||
className = Long.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'I': {
|
||||
className = Integer.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'S': {
|
||||
className = Short.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'B': {
|
||||
className = Byte.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'F': {
|
||||
className = Float.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'D': {
|
||||
className = Double.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'C': {
|
||||
className = Character.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'Z': {
|
||||
className = Boolean.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
default: {
|
||||
error = true;
|
||||
}//default//
|
||||
}//switch//
|
||||
}//default//
|
||||
}//switch//
|
||||
|
||||
if(className != null) {
|
||||
while(arrayCount-- > 0) {
|
||||
className += "[]";
|
||||
}//while//
|
||||
|
||||
classes.add(className);
|
||||
arrayCount = 0;
|
||||
}//if//
|
||||
|
||||
if(error) {
|
||||
String message = "Error: Invalid signature format at " + index + ". Signature = " + methodSignature + ". The signature must be in class file format where classes are fully qualified and begin with a capital 'L', end with a semi-colon ';', use '$' to separate inner class names, may use '/' instead of '.' to separate package names, and are prefixed with '[' for each array dimension. Native types use the letters J (long), I (integer), S (short), B (byte), F (float), D (double), Z (boolean).";
|
||||
|
||||
if(feedbackStack != null) {
|
||||
feedbackStack.add(new Message(true, message, debugElement));
|
||||
throw new BuildFailedException();
|
||||
}//if//
|
||||
else {
|
||||
throw new ViewBuilderException(message, debugElement);
|
||||
}//else//
|
||||
}//if//
|
||||
}//for//
|
||||
|
||||
if(classes.getSize() > 0) {
|
||||
result = new String[classes.getSize()];
|
||||
classes.toArray(result);
|
||||
}//if//
|
||||
}//if//
|
||||
|
||||
return result;
|
||||
}//getMethodParameterTypes()//
|
||||
/**
|
||||
* Converts the class name from class file notation to java source notation.
|
||||
* @param className The class name using class file notation (eg: "[Ljava.lang.Object;" for java.lang.Object[] or "[[I" for int[][]).
|
||||
* @param feedbackStack The optional stack of feedback Message instances to use when generating errors and warnings.
|
||||
* @param debugElement The optional document element used to identify exactly where in the VML source the error occured.
|
||||
* @return The fully qualified class name using dot notation ('.' instead of '/' and '$' as separators, and with "[]" at the end for arrays). This will only return null if the parameter is null.
|
||||
*/
|
||||
public static String convertClassNameToJavaSourceNotation(String className, IList feedbackStack, IElement debugElement) {
|
||||
String result = null;
|
||||
|
||||
if((className != null) && (className.length() > 0)) {
|
||||
int arrayCount = 0;
|
||||
boolean error = false;
|
||||
|
||||
for(int index = 0; !error && result == null && index < className.length(); index++) {
|
||||
switch(className.charAt(index)) {
|
||||
case '[': {
|
||||
arrayCount++;
|
||||
break;
|
||||
}//case//
|
||||
case 'L': {
|
||||
int endIndex = className.indexOf(';', index);
|
||||
|
||||
if(endIndex == -1) {
|
||||
error = true;
|
||||
}//if//
|
||||
else {
|
||||
result = className.substring(index + 1, endIndex).replace('\\', '.').replace('/', '.').replace('$', '.');
|
||||
index = endIndex;
|
||||
}//else//
|
||||
break;
|
||||
}//case//
|
||||
default: {
|
||||
switch(className.charAt(index)) {
|
||||
case 'J': {
|
||||
result = Long.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'I': {
|
||||
result = Integer.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'S': {
|
||||
result = Short.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'B': {
|
||||
result = Byte.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'F': {
|
||||
result = Float.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'D': {
|
||||
result = Double.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'C': {
|
||||
result = Character.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'Z': {
|
||||
result = Boolean.TYPE.getName();
|
||||
break;
|
||||
}//case//
|
||||
case 'V': {
|
||||
result = "void";
|
||||
break;
|
||||
}//case//
|
||||
default: {
|
||||
error = true;
|
||||
}//default//
|
||||
}//switch//
|
||||
}//default//
|
||||
}//switch//
|
||||
|
||||
if(result != null) {
|
||||
while(arrayCount-- > 0) {
|
||||
result += "[]";
|
||||
}//while//
|
||||
|
||||
//Ensure we have no more characters in the class name.//
|
||||
if(index + 1 < className.length()) {
|
||||
error = true;
|
||||
}//if//
|
||||
}//if//
|
||||
|
||||
if(error) {
|
||||
String message = "Error: Invalid class name format at " + index + ". Class name = " + className + ". The class name must be in class file format where classes are fully qualified and begin with a capital 'L', end with a semi-colon ';', use '$' to separate inner class names, may use '/' instead of '.' to separate package names, and are prefixed with '[' for each array dimension. Native types use the letters J (long), I (integer), S (short), B (byte), F (float), D (double), Z (boolean).";
|
||||
|
||||
if(feedbackStack != null) {
|
||||
feedbackStack.add(new Message(true, message, debugElement));
|
||||
}//if//
|
||||
else {
|
||||
throw new ViewBuilderException(message, debugElement);
|
||||
}//else//
|
||||
}//if//
|
||||
}//for//
|
||||
}//if//
|
||||
|
||||
return result;
|
||||
}//convertClassNameToJavaSourceNotation()//
|
||||
/**
|
||||
* Determines whether the given class name (formatted for java source) refers to a primitive type.
|
||||
* @param className The java source formatted name of the class or primitive type.
|
||||
* @return Whether the class name is a primitive type.
|
||||
*/
|
||||
public static boolean isPrimitive(String className) {
|
||||
return primitiveTypeNames.containsValue(className);
|
||||
}//isPrimitive()//
|
||||
}//BuilderSupport//
|
||||
@@ -0,0 +1,374 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.builder;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import com.common.debug.Debug;
|
||||
import com.common.io.StreamSupport;
|
||||
import com.common.util.IIterator;
|
||||
import com.common.util.IList;
|
||||
import com.common.util.LiteHashMap;
|
||||
import com.common.util.LiteHashSet;
|
||||
import com.common.util.LiteList;
|
||||
import com.de22.javabytecode.Type;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.view.definition.Message;
|
||||
|
||||
public class ClassMetadataLoader implements IClassMetadataLoader {
|
||||
public static final String FILE_SEPARATOR = System.getProperty("file.separator");
|
||||
|
||||
/** The application's class paths (folders, zips, and jars containing the application's visible classes). */
|
||||
private File[] applicationClassPaths = null;
|
||||
/** The map of Type.TypeMetadata instances mapped by the class name for the class they describe. */
|
||||
private LiteHashMap typeMetadataMap = new LiteHashMap(100);
|
||||
/**
|
||||
* ClassMetadataLoader constructor.
|
||||
* @param applicationClassPaths The application's class paths (folders, zips, and jars containing the application's visible classes).
|
||||
*/
|
||||
public ClassMetadataLoader(File[] applicationClassPaths) {
|
||||
setApplicationClassPaths(applicationClassPaths);
|
||||
}//ClassMetadataLoader()//
|
||||
/**
|
||||
* Gets the application's class paths.
|
||||
* @return The application's class paths (directories, jars, and zips containing class files).
|
||||
*/
|
||||
protected File[] getApplicationClassPaths() {
|
||||
return applicationClassPaths;
|
||||
}//getApplicationClassPaths()//
|
||||
/**
|
||||
* Sets the application's class paths.
|
||||
* @param applicationClassPaths The application's class paths (directories, jars, and zips containing class files).
|
||||
*/
|
||||
private void setApplicationClassPaths(File[] applicationClassPaths) {
|
||||
this.applicationClassPaths = applicationClassPaths;
|
||||
}//setApplicationClassPaths()//
|
||||
/**
|
||||
* Gets the parameter class names in class file format given a method signature without a return type (in class file format).
|
||||
* @param methodSignature The method signature in class file format without a return type (so no parenthesis followed by the return type class name).
|
||||
* @param feedbackStack The optional stack of feedback Message instances to use when generating errors and warnings.
|
||||
* @param debugElement The optional document element used to identify exactly where in the VML source the error occured.
|
||||
* @return The fully qualified class names using java class file notation.
|
||||
*/
|
||||
public static String[] getMethodParameterTypes(String methodSignature, IList feedbackStack, IElement debugElement) {
|
||||
String[] result = BuilderSupport.EMPTY_CLASS_ARRAY;
|
||||
|
||||
if((methodSignature != null) && (methodSignature.length() > 0)) {
|
||||
LiteList classes = new LiteList(10, 10);
|
||||
int startIndex = 0;
|
||||
String className = null;
|
||||
boolean error = false;
|
||||
|
||||
for(int index = 0; !error && index < methodSignature.length(); index++) {
|
||||
switch(methodSignature.charAt(index)) {
|
||||
case '[': {
|
||||
break;
|
||||
}//case//
|
||||
case 'L': {
|
||||
int endIndex = methodSignature.indexOf(';', index);
|
||||
|
||||
if(endIndex == -1) {
|
||||
error = true;
|
||||
}//if//
|
||||
else {
|
||||
className = methodSignature.substring(startIndex, endIndex + 1).replace('.', '/');
|
||||
index = endIndex;
|
||||
startIndex = index + 1;
|
||||
}//else//
|
||||
break;
|
||||
}//case//
|
||||
default: {
|
||||
//Class.forName does not allow "I"//
|
||||
switch(methodSignature.charAt(index)) {
|
||||
case 'J':
|
||||
case 'I':
|
||||
case 'S':
|
||||
case 'B':
|
||||
case 'F':
|
||||
case 'D':
|
||||
case 'C':
|
||||
case 'Z': {
|
||||
className = methodSignature.substring(startIndex, index + 1);
|
||||
startIndex = index;
|
||||
break;
|
||||
}//case//
|
||||
default: {
|
||||
error = true;
|
||||
}//default//
|
||||
}//switch//
|
||||
}//default//
|
||||
}//switch//
|
||||
|
||||
if(className != null) {
|
||||
classes.add(className);
|
||||
}//if//
|
||||
|
||||
if(error) {
|
||||
String message = "Error: Invalid signature format at " + index + ". Signature = " + methodSignature + ". The signature must be in class file format where classes are fully qualified and begin with a capital 'L', end with a semi-colon ';', use '$' to separate inner class names, may use '/' instead of '.' to separate package names, and are prefixed with '[' for each array dimension. Native types use the letters J (long), I (integer), S (short), B (byte), F (float), D (double), Z (boolean).";
|
||||
|
||||
if(feedbackStack != null) {
|
||||
feedbackStack.add(new Message(true, message, debugElement));
|
||||
throw new BuildFailedException();
|
||||
}//if//
|
||||
else {
|
||||
throw new ViewBuilderException(message, debugElement);
|
||||
}//else//
|
||||
}//if//
|
||||
}//for//
|
||||
|
||||
if(classes.getSize() > 0) {
|
||||
result = new String[classes.getSize()];
|
||||
classes.toArray(result);
|
||||
}//if//
|
||||
}//if//
|
||||
|
||||
return result;
|
||||
}//getMethodParameterTypes()//
|
||||
/**
|
||||
* Recursively searches for the return type of the given method.
|
||||
* @param className The class or interface to search.
|
||||
* @param methodName The name of the method.
|
||||
* @param parameterTypes The array of parameters for the method, in class file format.
|
||||
* @param feedbackStack The optional stack of feedback Message instances to use when generating errors and warnings.
|
||||
* @param debugElement The optional document element used to identify exactly where in the VML source the error occured.
|
||||
* @return The result class name. This will be in java source format (eg: java.lang.Object[] or int[][]). The result will never be null.
|
||||
*/
|
||||
private String getMethodReturnType(String className, String methodName, String[] parameterTypes, LiteHashSet searchedSet, IList feedbackStack, IElement debugElement) {
|
||||
String result = null;
|
||||
Type.TypeMetadata metadata = getClassMetadata(className, feedbackStack, debugElement);
|
||||
|
||||
searchedSet.add(className);
|
||||
//
|
||||
// if(methodName.equals("getObjectColor")) {
|
||||
// feedbackStack.add(new Message(false, "Looking for " + methodName + " in the class " + className));
|
||||
// }
|
||||
//Search this class for the method.//
|
||||
for(int methodIndex = 0; result == null && methodIndex < metadata.getMethodCount(); methodIndex++) {
|
||||
String nextMethodName = metadata.getMethodName(methodIndex);
|
||||
//
|
||||
// if(methodName.equals("getObjectColor")) {
|
||||
// feedbackStack.add(new Message(false, "Looking at " + nextMethodName));
|
||||
// }
|
||||
if(nextMethodName.equals(methodName)) {
|
||||
String[] nextParameterTypes = metadata.getMethodParameterTypes(methodIndex);
|
||||
//
|
||||
// if(methodName.equals("getObjectColor")) {
|
||||
// feedbackStack.add(new Message(false, "Found getObjectColor()", new RuntimeException()));
|
||||
// for(int parameterIndex = 0; parameterIndex < nextParameterTypes.length; parameterIndex++) {
|
||||
// feedbackStack.add(new Message(false, "Looking for: " + parameterTypes[parameterIndex] + " Found: " + nextParameterTypes[parameterIndex]));
|
||||
// }//for//
|
||||
// }
|
||||
|
||||
if(nextParameterTypes.length == parameterTypes.length) {
|
||||
boolean matches = true;
|
||||
|
||||
//Compare the parameters which are both in class file format.//
|
||||
for(int parameterIndex = 0; matches && parameterIndex < nextParameterTypes.length; parameterIndex++) {
|
||||
matches = parameterTypes[parameterIndex].equals(nextParameterTypes[parameterIndex]);
|
||||
}//for//
|
||||
|
||||
if(matches) {
|
||||
result = metadata.getMethodReturnType(methodIndex);
|
||||
}//if//
|
||||
}//if//
|
||||
}//if//
|
||||
}//for//
|
||||
|
||||
if(result == null) {
|
||||
//Check the super class.//
|
||||
if(metadata.getSuperTypeName() != null) {
|
||||
if(!searchedSet.containsValue(metadata.getSuperTypeName())) {
|
||||
result = getMethodReturnType(metadata.getSuperTypeName(), methodName, parameterTypes, searchedSet, feedbackStack, debugElement);
|
||||
}//if//
|
||||
}//if//
|
||||
|
||||
//Check the interfaces.//
|
||||
for(int index = 0; result == null && index < metadata.getInterfaceCount(); index++) {
|
||||
String interfaceName = metadata.getInterfaceName(index);
|
||||
|
||||
if(!searchedSet.containsValue(interfaceName)) {
|
||||
result = getMethodReturnType(interfaceName, methodName, parameterTypes, searchedSet, feedbackStack, debugElement);
|
||||
}//if//
|
||||
}//for//
|
||||
}//if//
|
||||
|
||||
return result;
|
||||
}//getMethodReturnType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.builder.IClassMetadataLoader#getMethodReturnType(java.lang.String, java.lang.String, java.lang.String, com.common.util.IList, com.foundation.util.xml.IElement)
|
||||
*/
|
||||
public String getMethodReturnType(String definingType, String methodName, String methodSignature, IList feedbackStack, IElement debugElement) {
|
||||
String result = null;
|
||||
String[] parameterTypes = getMethodParameterTypes(methodSignature, feedbackStack, debugElement);
|
||||
LiteHashSet searchSet = new LiteHashSet(100);
|
||||
|
||||
//Recursively search for the return type for the given method.//
|
||||
result = getMethodReturnType(definingType, methodName, parameterTypes, searchSet, feedbackStack, debugElement);
|
||||
|
||||
//Report an error if we couldn't find the method.//
|
||||
if(result == null) {
|
||||
StringBuffer buffer = new StringBuffer(100);
|
||||
|
||||
buffer.append("Couldn't find the method ");
|
||||
buffer.append(methodName);
|
||||
buffer.append(parameterTypes.length == 0 ? "()" : "(");
|
||||
|
||||
for(int index = 0; index < parameterTypes.length; index++) {
|
||||
buffer.append(parameterTypes[index]);
|
||||
|
||||
if(index + 1 < parameterTypes.length) {
|
||||
buffer.append(", ");
|
||||
}//if//
|
||||
else {
|
||||
buffer.append(")");
|
||||
}//else//
|
||||
}//for//
|
||||
|
||||
buffer.append("\nSearched:");
|
||||
IIterator iterator = searchSet.iterator();
|
||||
|
||||
while(iterator.hasNext()) {
|
||||
buffer.append("\n\t");
|
||||
buffer.append(iterator.next().toString());
|
||||
}//while//
|
||||
|
||||
buffer.append("\n");
|
||||
feedbackStack.add(new Message(true, buffer.toString(), debugElement));
|
||||
throw new BuildFailedException();
|
||||
}//if//
|
||||
else {
|
||||
result = BuilderSupport.convertClassNameToJavaSourceNotation(result, feedbackStack, debugElement);
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//getMethodReturnType()//
|
||||
/**
|
||||
* Gets the metadata for the given class name.
|
||||
* @param className The name of the class whose metadata is required.
|
||||
* @param feedbackStack The optional stack of feedback Message instances to use when generating errors and warnings.
|
||||
* @param debugElement The optional document element used to identify exactly where in the VML source the error occured.
|
||||
* @return The basic metadata for the class.
|
||||
*/
|
||||
protected Type.TypeMetadata getClassMetadata(String className, IList feedbackStack, IElement debugElement) {
|
||||
Type.TypeMetadata result = (Type.TypeMetadata) typeMetadataMap.get(className);
|
||||
|
||||
if(result == null) {
|
||||
String classFileName = className.replace('.', '/') + ".class";
|
||||
|
||||
for(int index = 0; (index < applicationClassPaths.length) && (result == null); index++) {
|
||||
File file = applicationClassPaths[index];
|
||||
|
||||
if((file != null) && (file.exists())) {
|
||||
byte[] bytes = null;
|
||||
|
||||
if(file.isDirectory()) {
|
||||
file = new File(file.getAbsolutePath() + FILE_SEPARATOR + classFileName);
|
||||
|
||||
if((file.exists()) && (file.isFile())) {
|
||||
try {
|
||||
bytes = StreamSupport.readBytes(file);
|
||||
}//try//
|
||||
catch(IOException e) {
|
||||
Debug.log(e);
|
||||
}//catch//
|
||||
}//if//
|
||||
}//if//
|
||||
else if(file.getAbsolutePath().endsWith(".zip")) {
|
||||
try {
|
||||
ZipFile zip = new ZipFile(file, ZipFile.OPEN_READ);
|
||||
|
||||
try {
|
||||
ZipEntry entry = zip.getEntry(classFileName);
|
||||
|
||||
if(entry != null) {
|
||||
InputStream in = zip.getInputStream(entry);
|
||||
int count = 0;
|
||||
|
||||
bytes = new byte[in.available()];
|
||||
count = in.read(bytes);
|
||||
|
||||
while(count != bytes.length) {
|
||||
count += in.read(bytes, count, bytes.length - count);
|
||||
}//while//
|
||||
|
||||
in.close();
|
||||
}//if//
|
||||
}//try//
|
||||
finally {
|
||||
if(zip != null) {
|
||||
zip.close();
|
||||
}//if//
|
||||
}//finally//
|
||||
}//try//
|
||||
catch(IOException e) {
|
||||
Debug.log(e);
|
||||
}//catch//
|
||||
}//else if//
|
||||
else if(file.getAbsolutePath().endsWith(".jar")) {
|
||||
try {
|
||||
JarFile jar = new JarFile(file, false, JarFile.OPEN_READ);
|
||||
|
||||
try {
|
||||
JarEntry entry = jar.getJarEntry(classFileName);
|
||||
|
||||
if(entry != null) {
|
||||
InputStream in = jar.getInputStream(entry);
|
||||
int count = 0;
|
||||
|
||||
bytes = new byte[in.available()];
|
||||
count = in.read(bytes);
|
||||
|
||||
while(count != bytes.length) {
|
||||
count += in.read(bytes, count, bytes.length - count);
|
||||
}//while//
|
||||
|
||||
in.close();
|
||||
}//if//
|
||||
}//try//
|
||||
finally {
|
||||
if(jar != null) {
|
||||
jar.close();
|
||||
}//if//
|
||||
}//finally//
|
||||
}//try//
|
||||
catch(IOException e) {
|
||||
Debug.log(e);
|
||||
}//catch//
|
||||
}//else if//
|
||||
|
||||
if(bytes != null) {
|
||||
try {
|
||||
Type type = new Type();
|
||||
|
||||
type.readExternal(new com.common.io.ObjectInputStream(new ByteArrayInputStream(bytes), null, null));
|
||||
result = type.collectMetadata();
|
||||
typeMetadataMap.put(className, result);
|
||||
}//try//
|
||||
catch(Throwable e) {
|
||||
feedbackStack.add(new Message(true, "Could not collect metadata on the class: " + className + " found at/in: " + file + ".", e, debugElement));
|
||||
}//catch//
|
||||
}//if//
|
||||
}//if//
|
||||
}//for//
|
||||
|
||||
if(result == null) {
|
||||
feedbackStack.add(new Message(true, "Unable to locate metadata for the class: " + className, debugElement));
|
||||
throw new BuildFailedException();
|
||||
}//if//
|
||||
}//if//
|
||||
|
||||
return result;
|
||||
}//getClassMetadata()//
|
||||
}//ClassMetadataLoader//
|
||||
27
Vml Builder/src/com/foundation/view/builder/IVmlBuilder.java
Normal file
27
Vml Builder/src/com/foundation/view/builder/IVmlBuilder.java
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.builder;
|
||||
|
||||
public interface IVmlBuilder {
|
||||
/** An ArrayList of HashMap instances containing the RESULT_MESSAGE_xxx identifiers for each result message. */
|
||||
public static final String RESULT_MESSAGES = "messages";
|
||||
public static final String RESULT_MESSAGE_TEXT = "messageText";
|
||||
public static final String RESULT_MESSAGE_EXCEPTION = "messageException";
|
||||
public static final String RESULT_MESSAGE_START_CHARACTER = "messageStartCharacter";
|
||||
public static final String RESULT_MESSAGE_END_CHARACTER = "messageEndCharacter";
|
||||
public static final String RESULT_MESSAGE_LINE_NUMBER = "messageLineNumber";
|
||||
public static final String RESULT_MESSAGE_IS_ERROR = "messageIsError";
|
||||
/** A byte array containing the VML source bytes (UTF8 encoding). */
|
||||
public static final String RESULT_VML_SOURCE = "vmlSource";
|
||||
/** A string containing the Java source generated from the VML. */
|
||||
public static final String RESULT_JAVA_SOURCE = "javaSource";
|
||||
/** The string containing the package name used in the resulting java source. */
|
||||
public static final String RESULT_PACKAGE_NAME = "packageName";
|
||||
/** The string containing the log output for the compile job. */
|
||||
public static final String RESULT_LOG = "log";
|
||||
}//IVmlBuilder()//
|
||||
3517
Vml Builder/src/com/foundation/view/builder/ViewSourceBuilder.java
Normal file
3517
Vml Builder/src/com/foundation/view/builder/ViewSourceBuilder.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c) 2004,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.application.IApplication;
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.model.Model;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.view.application.BuilderApplication;
|
||||
|
||||
public abstract class AbstractModel extends Model implements IAbstractModel {
|
||||
public static final String OPTION_REQUIRED = "required";
|
||||
public static final String OPTION_OPTIONAL = "optional";
|
||||
public static final String OPTION_NONE = "none";
|
||||
|
||||
public static final Attribute DOCUMENT_ELEMENT = registerAttribute(AbstractModel.class, "documentElement");
|
||||
/**
|
||||
* AbstractModel constructor.
|
||||
*/
|
||||
public AbstractModel() {
|
||||
super();
|
||||
}//AbstractModel()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.common.IEntity#getApplication()
|
||||
*/
|
||||
public IApplication getApplication() {
|
||||
return BuilderApplication.getSingleton();
|
||||
}//getApplication()//
|
||||
/**
|
||||
* Reads a boolean from a source string.
|
||||
* @param source The source to read from.
|
||||
* @param defaultValue The optional default value if the source is unreadable or null.
|
||||
* @return The read boolean value.
|
||||
*/
|
||||
public Boolean readBoolean(String source, Boolean defaultValue) {
|
||||
Boolean result = null;
|
||||
|
||||
if(source != null) {
|
||||
result = ((source.equalsIgnoreCase("true")) || (source.equalsIgnoreCase("yes")) || (source.equalsIgnoreCase("t")) || (source.equalsIgnoreCase("y"))) ? Boolean.TRUE : Boolean.FALSE;
|
||||
}//if//
|
||||
else {
|
||||
result = defaultValue;
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//readBoolean()//
|
||||
/**
|
||||
* Reads the required type which can be one of [required, optional, none].
|
||||
* @param source The source to read from.
|
||||
* @param defaultValue The optional default value if the source is unreadable or null.
|
||||
* @return The read required type value.
|
||||
*/
|
||||
public String readRequiredType(String source, String defaultValue) {
|
||||
String result = null;
|
||||
|
||||
if(source != null) {
|
||||
if(source.equalsIgnoreCase(OPTION_REQUIRED)) {
|
||||
result = OPTION_REQUIRED;
|
||||
}//if//
|
||||
else if(source.equalsIgnoreCase(OPTION_OPTIONAL)) {
|
||||
result = OPTION_OPTIONAL;
|
||||
}//else if//
|
||||
else if(source.equalsIgnoreCase(OPTION_NONE)) {
|
||||
result = OPTION_NONE;
|
||||
}//else if//
|
||||
}//if//
|
||||
|
||||
if(result == null) {
|
||||
result = defaultValue;
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//readRequiredType()//
|
||||
/**
|
||||
* Gets the document element that best matches with this model, or null if the model was not created from a document.
|
||||
* <p>Note: This may be null or empty as it is an optional parameter useful only for debugging.</p>
|
||||
* @return The document element from which this model was derived.
|
||||
*/
|
||||
public IElement getDocumentElement() {
|
||||
return (IElement) getAttributeValue(DOCUMENT_ELEMENT);
|
||||
}//getDocumentElement()//
|
||||
/**
|
||||
* Sets the document element that best matches with this model, or null if the model was not created from a document.
|
||||
* <p>Note: This may be null or empty as it is an optional parameter useful only for debugging.</p>
|
||||
* @param element The document element from which this model was derived.
|
||||
*/
|
||||
protected void setDocumentElement(IElement element) {
|
||||
setAttributeValue(DOCUMENT_ELEMENT, element);
|
||||
}//setDocumentElement()//
|
||||
}//AbstractModel//
|
||||
148
Vml Builder/src/com/foundation/view/definition/AbstractPart.java
Normal file
148
Vml Builder/src/com/foundation/view/definition/AbstractPart.java
Normal file
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (c) 2005,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.common.util.IIterator;
|
||||
import com.common.util.IList;
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.view.builder.BuildFailedException;
|
||||
import com.foundation.view.builder.BuilderSupport;
|
||||
import com.foundation.view.builder.IViewSourceBuilder;
|
||||
|
||||
public class AbstractPart extends AbstractModel implements IAbstractPart {
|
||||
public static final Attribute COMPONENT = registerAttribute(AbstractPart.class, "component");
|
||||
public static final Attribute COMMENTS = registerAttribute(AbstractPart.class, "comments");
|
||||
/**
|
||||
* AbstractPart constructor.
|
||||
* <p><b>Warning: Only public for the purpose of creating reflections.</b></p>
|
||||
*/
|
||||
public AbstractPart() {
|
||||
}//AbstractPart()//
|
||||
/**
|
||||
* AbstractPart constructor.
|
||||
* @param component The component that defines the part.
|
||||
*/
|
||||
public AbstractPart(IComponentData component) {
|
||||
super();
|
||||
setComponent(component);
|
||||
}//AbstractPart()//
|
||||
/**
|
||||
* Gets the list (stack) of Message objects used to provide feedback to the developer.
|
||||
* @return The stack of errors and warnings which can be appended to as the build process progresses.
|
||||
*/
|
||||
public IList getFeedbackStack() {
|
||||
return getComponent().getViewModel().getFeedbackStack();
|
||||
}//getFeedbackStack()//
|
||||
/**
|
||||
* Locates the component data with the given name.
|
||||
* @param component The component doing the search. The search will look at the component's contained components (if any) and all components in parent containers.
|
||||
* @param name The name of the component. The first with this name will be returned.
|
||||
* @param typeName The optional name of the component data's type.
|
||||
* @return The value holder found, or null if no value holder exists with the name.
|
||||
*/
|
||||
protected IComponentData getNamedComponentData(IComponentData component, String name, String typeName) {
|
||||
IComponentData result = null;
|
||||
|
||||
if(component != null) {
|
||||
IComponentData parent = component.getParent();
|
||||
IIterator iterator = component.getComponents().iterator();
|
||||
|
||||
//Search this component's components first.//
|
||||
while((iterator.hasNext()) && (result == null)) {
|
||||
IComponentData next = (IComponentData) iterator.next();
|
||||
|
||||
if(((typeName == null) || (next.getComponentType().getName().equals(typeName))) && (next.hasProperty(IViewSourceBuilder.COMMON_PROPERTY_NAME, name))) {
|
||||
result = (IComponentData) next;
|
||||
}//if//
|
||||
}//while//
|
||||
|
||||
//Search each parent's components.//
|
||||
while((result == null) && (parent != null)) {
|
||||
iterator = parent.getComponents().iterator();
|
||||
|
||||
while((iterator.hasNext()) && (result == null)) {
|
||||
IComponentData next = (IComponentData) iterator.next();
|
||||
|
||||
if(((typeName == null) || (next.getComponentType().getName().equals(typeName))) && (next.hasProperty(IViewSourceBuilder.COMMON_PROPERTY_NAME, name))) {
|
||||
result = (IComponentData) next;
|
||||
}//if//
|
||||
}//while//
|
||||
|
||||
parent = parent.getParent();
|
||||
}//while//
|
||||
}//if//
|
||||
|
||||
return result;
|
||||
}//getNamedComponentData()//
|
||||
/**
|
||||
* Gets the value holder's held object class name.
|
||||
* @param valueHolderName The value holder whose value type is required.
|
||||
* @return The class of object held by the value holder.
|
||||
*/
|
||||
public String getValueHolderType(String valueHolderName) {
|
||||
IComponentData valueHolder = getValueHolder(valueHolderName);
|
||||
Object typeName = valueHolder.getPropertyValue(IViewSourceBuilder.VALUE_HOLDER_PROPERTY_TYPE);
|
||||
|
||||
if(typeName == null) {
|
||||
//TODO: Get the feedback stack from the ViewSourceBuilder (pass it through the constructor if necessary).
|
||||
getFeedbackStack().add(new Message(true, "Missing value holder type. The value holder must define a property '" + IViewSourceBuilder.VALUE_HOLDER_PROPERTY_TYPE + "' whose value is a fully qualified class name for the type of object held by the holder at runtime (eg: com.mypackage.MyClass).", valueHolder.getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//if//
|
||||
|
||||
return typeName.toString();
|
||||
}//getValueHolderType()//
|
||||
/**
|
||||
* Gets the value holder component.
|
||||
* @param valueHolderName The value holder's name.
|
||||
* @return The value holder component data.
|
||||
*/
|
||||
public IComponentData getValueHolder(String valueHolderName) {
|
||||
IComponentData valueHolder = null;
|
||||
|
||||
valueHolder = getNamedComponentData(getComponent(), valueHolderName, IViewSourceBuilder.COMMON_TYPE_NAME_VALUE_HOLDER);
|
||||
|
||||
if(valueHolder == null) {
|
||||
getFeedbackStack().add(new Message(true, "Invalid value holder name: " + valueHolderName, getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//if//
|
||||
|
||||
return valueHolder;
|
||||
}//getValueHolder()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAbstractPart#getMethodParameterTypes(java.lang.String)
|
||||
*/
|
||||
public String[] getMethodParameterTypes(String methodSignature) {
|
||||
return BuilderSupport.getMethodParameterTypes(methodSignature, getFeedbackStack(), getDocumentElement());
|
||||
}//getMethodParameterTypes()//
|
||||
/**
|
||||
* Gets the component data containing this reference.
|
||||
* @return The refering component data.
|
||||
*/
|
||||
public IComponentData getComponent() {
|
||||
return (IComponentData) getAttributeValue(COMPONENT);
|
||||
}//getComponent()//
|
||||
/**
|
||||
* Sets the component data containing this reference.
|
||||
* @param component The refering component data.
|
||||
*/
|
||||
public void setComponent(IComponentData component) {
|
||||
setAttributeValue(COMPONENT, component);
|
||||
}//setComponent()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAbstractPart#getComments()
|
||||
*/
|
||||
public String[] getComments() {
|
||||
return (String[]) getAttributeValue(COMMENTS);
|
||||
}//getComments()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAbstractPart#setComments(java.lang.String[])
|
||||
*/
|
||||
public void setComments(String[] comments) {
|
||||
setAttributeValue(COMMENTS, comments);
|
||||
}//setComments()//
|
||||
}//AbstractPart//
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2006,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.IManagedList;
|
||||
import com.foundation.util.ManagedList;
|
||||
import com.foundation.util.xml.IElement;
|
||||
|
||||
/**
|
||||
* The base class for the association group, association link, and association indirect link 'nodes' making up the tree.
|
||||
*/
|
||||
public class AssociationAbstractNodePart extends AssociationAbstractPart implements IAssociationAbstractNodePart {
|
||||
public static final Attribute CHILDREN = registerCollection(AssociationAbstractNodePart.class, "children", AO_LAZY);
|
||||
/**
|
||||
* AssociationAbstractNodePart constructor.
|
||||
* <p><b>Warning: Only public for the purpose of creating reflections.</b></p>
|
||||
*/
|
||||
public AssociationAbstractNodePart() {
|
||||
}//AssociationAbstractNodePart()//
|
||||
/**
|
||||
* AssociationAbstractNodePart constructor.
|
||||
* @param parent The parent node part, or null if this is the root node in the tree.
|
||||
* @param component The component that the part is being used by.
|
||||
* @param documentElement The XML document element that describes the part.
|
||||
*/
|
||||
public AssociationAbstractNodePart(IAssociationAbstractNodePart parent, IComponentData component, IElement documentElement) {
|
||||
super(parent, component, documentElement);
|
||||
}//AssociationAbstractNodePart()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.common.Entity#lazyLoadAttribute(com.foundation.metadata.Attribute)
|
||||
*/
|
||||
protected Object lazyLoadAttribute(Attribute attribute) {
|
||||
Object result = null;
|
||||
|
||||
if(attribute == CHILDREN) {
|
||||
result = new ManagedList(5, 20);
|
||||
}//if//
|
||||
else {
|
||||
result = super.lazyLoadAttribute(attribute);
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//lazyLoadAttribute()//
|
||||
/**
|
||||
* Gets the children that make up the tree that defines how the association value is derived.
|
||||
* @return The collection of AssociationLinkPart, AssociationIndirectLinkPart, and AssociationTargetPart instances that are used to get a value for the association.
|
||||
*/
|
||||
public IManagedList getChildren() {
|
||||
return (IManagedList) getAttributeValue(CHILDREN);
|
||||
}//getChildren()//
|
||||
/**
|
||||
* Gets the parent node in the tree.
|
||||
* @return The parent association node part which may be an association group, association link, or association indirect link, or will be null if this is the association group (root of the tree).
|
||||
*/
|
||||
public IAssociationAbstractNodePart getParent() {
|
||||
return (IAssociationAbstractNodePart) getAttributeValue(PARENT);
|
||||
}//getParent()//
|
||||
/**
|
||||
* Sets the parent node in the tree.
|
||||
* @param parent The parent association node part which may be an association group, association link, or association indirect link, or will be null if this is the association group (root of the tree).
|
||||
*/
|
||||
public void setParent(IAssociationAbstractNodePart parent) {
|
||||
setAttributeValue(PARENT, parent);
|
||||
}//setParent()//
|
||||
}//AssociationAbstractNodePart//
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2006,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.IElement;
|
||||
|
||||
public class AssociationAbstractPart extends AbstractPart implements IAssociationAbstractPart {
|
||||
public static final Attribute PARENT = registerAttribute(AssociationAbstractPart.class, "parent");
|
||||
/**
|
||||
* AssociationAbstractPart constructor.
|
||||
*/
|
||||
public AssociationAbstractPart() {
|
||||
}//AssociationAbstractPart()//
|
||||
/**
|
||||
* AssociationAbstractPart constructor.
|
||||
* @param parent The parent node part, or null if this is the root node in the tree.
|
||||
* @param component The component referencing the association.
|
||||
* @param documentElement The optional element of the document that defines this association. This is used for debugging.
|
||||
*/
|
||||
public AssociationAbstractPart(IAssociationAbstractNodePart parent, IComponentData component, IElement documentElement) {
|
||||
super(component);
|
||||
setDocumentElement(documentElement);
|
||||
setParent(parent);
|
||||
}//AssociationAbstractPart()//
|
||||
/**
|
||||
* Gets the AssociationAbstractPartType that is the parent for this part.
|
||||
* @return The parent association part which must either be an AssociationLinkPart or AssociationGroupPart.
|
||||
*/
|
||||
public IAssociationAbstractNodePart getParent() {
|
||||
return (IAssociationAbstractNodePart) getAttributeValue(PARENT);
|
||||
}//getParent()//
|
||||
/**
|
||||
* Gets the root part for the association tree of parts.
|
||||
* @return The association group part which is the root of any association part tree.
|
||||
*/
|
||||
public IAssociationGroupPart getRoot() {
|
||||
IAssociationAbstractPart part = this;
|
||||
|
||||
while(!(part instanceof IAssociationGroupPart)) {
|
||||
part = part.getParent();
|
||||
}//while//
|
||||
|
||||
return (IAssociationGroupPart) part;
|
||||
}//getRoot()//
|
||||
/**
|
||||
* Sets the AssociationAbstractPartType that is the parent for this part.
|
||||
* @param parent The parent association part which must either be an AssociationLinkPart or AssociationGroupPart.
|
||||
*/
|
||||
protected void setParent(IAssociationAbstractNodePart parent) {
|
||||
setAttributeValue(PARENT, parent);
|
||||
}//setParent()//
|
||||
}//AssociationAbstractPart//
|
||||
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
* Copyright (c) 2006,2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.view.builder.BuildFailedException;
|
||||
import com.foundation.view.builder.BuilderSupport;
|
||||
import com.foundation.view.builder.IClassMetadataLoader;
|
||||
import com.foundation.view.builder.IViewSourceBuilder;
|
||||
|
||||
/*
|
||||
* This is the base class for the association target part classes.
|
||||
*/
|
||||
public abstract class AssociationAbstractTargetPart extends AssociationAbstractPart implements IAssociationAbstractTargetPart {
|
||||
public static final Attribute ROW_TYPE_NAME = registerAttribute(AssociationAbstractTargetPart.class, "rowTypeName");
|
||||
public static final Attribute INVERT_LOGIC = registerAttribute(AssociationAbstractTargetPart.class, "invertLogic", Boolean.FALSE);
|
||||
public static final Attribute DECORATION_CAPABLE = registerAttribute(AssociationAbstractTargetPart.class, "decorationCapable", Boolean.FALSE);
|
||||
public static final Attribute DECORATION_ATTRIBUTE = registerAttribute(AssociationAbstractTargetPart.class, "decorationAttribute");
|
||||
public static final Attribute VALUE_HOLDER_NAME = registerAttribute(AssociationAbstractTargetPart.class, "valueHolderName");
|
||||
|
||||
/** A cached result type for the getter method. This is cached since it is a bit time intensive to find it. */
|
||||
protected String getterResultType = null;
|
||||
/**
|
||||
* AssociationAbstractTargetPart constructor.
|
||||
* <p><b>Warning: Only public for the purpose of creating reflections.</b></p>
|
||||
*/
|
||||
public AssociationAbstractTargetPart() {
|
||||
}//AssociationAbstractTargetPart()//
|
||||
/**
|
||||
* AssociationAbstractTargetPart constructor.
|
||||
* @param parent The parent for the association link or target part.
|
||||
* @param component The component data that the association part data is associated with.
|
||||
* @param documentElement The optional element of the document that defines this association. This is used for debugging.
|
||||
*/
|
||||
public AssociationAbstractTargetPart(IAssociationAbstractNodePart parent, IComponentData component, IElement documentElement) {
|
||||
super(parent, component, documentElement);
|
||||
}//AssociationAbstractTargetPart()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationAbstractTargetPart#getValueHolderName()
|
||||
*/
|
||||
public String getValueHolderName() {
|
||||
return (String) getAttributeValue(VALUE_HOLDER_NAME);
|
||||
}//getValueHolderName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationAbstractTargetPart#setValueHolderName(java.lang.String)
|
||||
*/
|
||||
public void setValueHolderName(String valueHolderName) {
|
||||
setAttributeValue(VALUE_HOLDER_NAME, valueHolderName);
|
||||
}//setValueHolderName()//
|
||||
/**
|
||||
* Gets the qualified class name for the row class.
|
||||
* @return The qualified class name of the row type supported by this association which may be null in certain cases.
|
||||
*/
|
||||
public String getRowTypeName() {
|
||||
return (String) getAttributeValue(ROW_TYPE_NAME);
|
||||
}//getRowTypeName()//
|
||||
/**
|
||||
* Sets the qualified class name for the row class.
|
||||
* @param rowTypeName The qualified class name of the row type supported by this association which may be null in certain cases.
|
||||
*/
|
||||
public void setRowTypeName(String rowTypeName) {
|
||||
setAttributeValue(ROW_TYPE_NAME, rowTypeName);
|
||||
}//setRowTypeName()//
|
||||
/**
|
||||
* Gets whether the association should invert the boolean result.
|
||||
* <p>This is only allowed (it is optional) for associations which have a type of java.lang.Boolean.</p>
|
||||
* @return Whether the boolean result should be inverted.
|
||||
*/
|
||||
public Boolean getInvertLogic() {
|
||||
return (Boolean) getAttributeValue(INVERT_LOGIC);
|
||||
}//getInvertLogic()//
|
||||
/**
|
||||
* Sets whether the association should invert the boolean result.
|
||||
* <p>This is only allowed (it is optional) for associations which have a type of java.lang.Boolean.</p>
|
||||
* @param invertLogic Whether the boolean result should be inverted.
|
||||
*/
|
||||
public void setInvertLogic(Boolean invertLogic) {
|
||||
setAttributeValue(INVERT_LOGIC, invertLogic);
|
||||
}//setInvertLogic()//
|
||||
/**
|
||||
* Gets the getter method name for the attribute.
|
||||
* @return The name of the getter method used to access the value.
|
||||
*/
|
||||
public abstract String getGetterName();
|
||||
/**
|
||||
* Gets the setter method name for the attribute.
|
||||
* @return The name of the setter method used to set the value.
|
||||
*/
|
||||
public abstract String getSetterName();
|
||||
/**
|
||||
* Gets the getter method's signature in class file format.
|
||||
* @return The signature that unqiuely identifies the getter method.
|
||||
*/
|
||||
public abstract String getGetterSignature();
|
||||
/**
|
||||
* Gets the setter method's signature in class file format.
|
||||
* @return The signature that unqiuely identifies the setter method.
|
||||
*/
|
||||
public abstract String getSetterSignature();
|
||||
/**
|
||||
* Gets the default row-type name for the target part.
|
||||
* @return The row-type name defined by the related value-holder. The value-holder may be specified by the group part if this is an immediate child of the group part.
|
||||
*/
|
||||
public abstract String getDefaultRowTypeName();
|
||||
/**
|
||||
* Gets the name of the class held by the value holder.
|
||||
* <p>TODO: Replace with getValueHolderType(String) defined in AbstactPart. They appear to do the exact same thing.</p>
|
||||
* @param component The component that uses the value holder.
|
||||
* @param valueHolderName The name of the value holder.
|
||||
* @return The fully qualified name of the value holder's held type.
|
||||
*/
|
||||
protected String getValueHolderTypeName(IComponentData component, String valueHolderName) {
|
||||
String result = null;
|
||||
|
||||
//Get the class of object which defines the attribute.//
|
||||
if(valueHolderName != null) {
|
||||
IComponentData valueHolder = getNamedComponentData(component, valueHolderName, IViewSourceBuilder.COMMON_TYPE_NAME_VALUE_HOLDER);
|
||||
|
||||
if(valueHolder != null) {
|
||||
Object value = valueHolder.getPropertyValue(IViewSourceBuilder.VALUE_HOLDER_PROPERTY_TYPE);
|
||||
|
||||
result = value != null ? value.toString() : null;
|
||||
}//if//
|
||||
else {
|
||||
getFeedbackStack().add(new Message(true, "Unable to find the value holder named: '" + valueHolderName + "'.", component.getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//else//
|
||||
}//if//
|
||||
|
||||
return result;
|
||||
}//getValueHolderTypeName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationAbstractTargetPart#getDecorationCapable()
|
||||
*/
|
||||
public Boolean getDecorationCapable() {
|
||||
return (Boolean) getAttributeValue(DECORATION_CAPABLE);
|
||||
}//getDecorationCapable()//
|
||||
/**
|
||||
* Sets whether the association may be linked to decorations.
|
||||
* @param decorationCapable Whether the association accesses decorations.
|
||||
*/
|
||||
public void setDecorationCapable(Boolean decorationCapable) {
|
||||
setAttributeValue(DECORATION_CAPABLE, decorationCapable);
|
||||
}//setDecorationCapable()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationAbstractTargetPart#getDecorationAttribute()
|
||||
*/
|
||||
public String getDecorationAttribute() {
|
||||
return (String) getAttributeValue(DECORATION_ATTRIBUTE);
|
||||
}//getDecorationAttribute()//
|
||||
/**
|
||||
* Sets the decoration attribute.
|
||||
* @param decorationAttribute The attribute to be used to access the decorations for the association.
|
||||
*/
|
||||
public void setDecorationAttribute(String decorationAttribute) {
|
||||
setAttributeValue(DECORATION_ATTRIBUTE, decorationAttribute);
|
||||
}//setDecorationAttribute()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationAbstractTargetPart#getGetterResultType(com.foundation.view.builder.IClassMetadataLoader)
|
||||
*/
|
||||
public String getGetterResultType(IClassMetadataLoader applicationClassMetadataLoader) {
|
||||
String result = null;
|
||||
|
||||
if(getterResultType != null) {
|
||||
result = getterResultType;
|
||||
}//if//
|
||||
else {
|
||||
//Use the value holder's type if available, otherwise the row type specified in the VML if available, otherwise use the group's value holder type if available.//
|
||||
String rowTypeName = getValueHolderName() != null || getRowTypeName() == null ? getDefaultRowTypeName() : getRowTypeName();
|
||||
|
||||
if(rowTypeName != null) {
|
||||
try {
|
||||
result = applicationClassMetadataLoader.getMethodReturnType(rowTypeName, getGetterName(), getGetterSignature(), getFeedbackStack(), getDocumentElement());
|
||||
}//try//
|
||||
catch(ClassNotFoundException e) {
|
||||
getFeedbackStack().add(new Message(true, "Invalid class name: " + rowTypeName, getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//catch//
|
||||
}//if//
|
||||
else {
|
||||
getFeedbackStack().add(new Message(true, "Error: The attribute must either specify a value-holder or value-type.", getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//else//
|
||||
|
||||
//Cache the result for efficiency.//
|
||||
getterResultType = result;
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//getGetterResultType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationAbstractTargetPart#getGetterSignatureTypeNames()
|
||||
*/
|
||||
public String[] getGetterSignatureTypeNames() {
|
||||
return BuilderSupport.getMethodParameterTypes(getGetterSignature(), getFeedbackStack(), getDocumentElement());
|
||||
}//getGetterSignatureTypeNames()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationAbstractTargetPart#getOriginalValueGetterSignatureTypeNames()
|
||||
*/
|
||||
public String[] getOriginalValueGetterSignatureTypeNames() {
|
||||
return BuilderSupport.getMethodParameterTypes(getOriginalValueGetterSignature(), getFeedbackStack(), getDocumentElement());
|
||||
}//getOriginalValueGetterSignatureTypeNames()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationAbstractTargetPart#getSetterSignatureTypeNames()
|
||||
*/
|
||||
public String[] getSetterSignatureTypeNames() {
|
||||
return BuilderSupport.getMethodParameterTypes(getSetterSignature(), getFeedbackStack(), getDocumentElement());
|
||||
}//getSetterSignatureTypeNames()//
|
||||
}//AssociationAbstractTargetPart//
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
/**
|
||||
* Encapsulates the association-attribute data which defines attributes whose values are given to the association-nodes which register event handlers to receive notification when the association's result requires refreshing.
|
||||
*/
|
||||
public class AssociationAttributePart extends AbstractPart {
|
||||
/** The name of the attribute whose value will be plugged into the association nodes to register a tree of events. */
|
||||
private String attributeName = null;
|
||||
/** Whether to navigate the collection's values if the attribute's value is a collection. This should default to false. */
|
||||
private boolean navigateCollectionValues = false;
|
||||
/**
|
||||
* AssociationAttributePart constructor.
|
||||
* <p><b>Warning: Only public for the purpose of creating reflections.</b></p>
|
||||
*/
|
||||
public AssociationAttributePart() {
|
||||
}//AssociationAttributePart()//
|
||||
/**
|
||||
* AssociationAttributePart constructor.
|
||||
* @param component The component that defines the part.
|
||||
* @param attributeName The name of the attribute whose value will be plugged into the association nodes to register a tree of events.
|
||||
* @param navigateCollectionValues Whether to navigate the collection's values if the attribute's value is a collection. This should default to false.
|
||||
*/
|
||||
public AssociationAttributePart(IComponentData component, String attributeName, boolean navigateCollectionValues) {
|
||||
super(component);
|
||||
this.attributeName = attributeName;
|
||||
this.navigateCollectionValues = navigateCollectionValues;
|
||||
}//AssociationAttributePart()//
|
||||
/**
|
||||
* Gets the name of the attribute whose value will be plugged into the association nodes to register a tree of events.
|
||||
* @return The attribute name.
|
||||
*/
|
||||
public String getAttributeName() {
|
||||
return attributeName;
|
||||
}//getAttributeName()//
|
||||
/**
|
||||
* Gets whether to navigate the collection's values if the attribute's value is a collection. This should default to false.
|
||||
* @return Whether to navigate collected values.
|
||||
*/
|
||||
public boolean getNavigateCollectionValues() {
|
||||
return navigateCollectionValues;
|
||||
}//getNavigateCollectionValues()//
|
||||
}//AssociationAttributePart//
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (c) 2006,2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.view.builder.IClassMetadataLoader;
|
||||
|
||||
/**
|
||||
* Defines an association part that returns a result value for the association to the user control.
|
||||
* This association target part uses an attribute to access the target value and only listens to the attribute change event.
|
||||
*/
|
||||
public class AssociationAttributeTargetPart extends AssociationAbstractTargetPart implements IAssociationAttributeTargetPart {
|
||||
public static final Attribute ATTRIBUTE_NAME = registerAttribute(AssociationAttributeTargetPart.class, "attributeName");
|
||||
/**
|
||||
* AssociationAttributeTargetPart constructor.
|
||||
* <p><b>Warning: Only public for the purpose of creating reflections.</b></p>
|
||||
*/
|
||||
public AssociationAttributeTargetPart() {
|
||||
}//AssociationAttributeTargetPart()//
|
||||
/**
|
||||
* AssociationAttributeTargetPart constructor.
|
||||
* @param parent The parent for the association target part.
|
||||
* @param component The component referencing the attribute.
|
||||
* @param documentElement The optional element of the document that defines this association. This is used for debugging.
|
||||
*/
|
||||
public AssociationAttributeTargetPart(IAssociationAbstractNodePart parent, IComponentData component, IElement documentElement) {
|
||||
super(parent, component, documentElement);
|
||||
}//AssociationAttributeTargetPart()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationAbstractTargetPart#getOriginalValueGetterName()
|
||||
*/
|
||||
public String getOriginalValueGetterName() {
|
||||
//A getter cannot be set of the original value when using an attribute association. The code will call the IEntity.getOldAttributeValue(Attribute) method instead.//
|
||||
return null;
|
||||
}//getOriginalValueGetterName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationAbstractTargetPart#getOriginalValueGetterSignature()
|
||||
*/
|
||||
public String getOriginalValueGetterSignature() {
|
||||
//A getter cannot be set of the original value when using an attribute association. The code will call the IEntity.getOldAttributeValue(Attribute) method instead.//
|
||||
return null;
|
||||
}//getOriginalValueGetterSignature()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.AssociationAbstractTargetPart#getDefaultRowTypeName()
|
||||
*/
|
||||
public String getDefaultRowTypeName() {
|
||||
String result = null;
|
||||
|
||||
if(getValueHolderName() != null) {
|
||||
result = getValueHolderTypeName(getComponent(), getValueHolderName());
|
||||
}//if//
|
||||
else if(getParent() instanceof AssociationGroupPart) {
|
||||
result = getValueHolderTypeName(getComponent(), ((AssociationGroupPart) getParent()).getValueHolderName());
|
||||
}//else if//
|
||||
|
||||
return result;
|
||||
}//getDefaultRowTypeName()//
|
||||
/**
|
||||
* Sets the qualified class name for the class which defines the referenced part.
|
||||
* <p>This is only used for multi associations or single associations where the target is nested in a link association.</p>
|
||||
* <p><b>Warning: This method will clear the attribute & getter/setter data.</b></p>
|
||||
* @param rowTypeName The qualified class name of the row type supported by this association.
|
||||
*/
|
||||
public void setRowTypeName(String rowTypeName) {
|
||||
super.setRowTypeName(rowTypeName);
|
||||
//Clear the attribute data since it will require new information.//
|
||||
setAttributeName(null);
|
||||
}//setRowTypeName()//
|
||||
/**
|
||||
* Gets the name of the attribute.
|
||||
* @return The name of the attribute.
|
||||
*/
|
||||
public String getAttributeName() {
|
||||
return (String) getAttributeValue(ATTRIBUTE_NAME);
|
||||
}//getAttributeName()//
|
||||
/**
|
||||
* Sets the name of the attribute.
|
||||
* @param attributeName The name of the attribute.
|
||||
*/
|
||||
public void setAttributeName(String attributeName) {
|
||||
setAttributeValue(ATTRIBUTE_NAME, attributeName);
|
||||
}//setAttributeName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.AssociationAbstractTargetPart#getGetterName()
|
||||
*/
|
||||
public String getGetterName() {
|
||||
return "get" + Character.toUpperCase(getAttributeName().charAt(0)) + getAttributeName().substring(1);
|
||||
}//getGetterName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.AssociationAbstractTargetPart#getSetterName()
|
||||
*/
|
||||
public String getSetterName() {
|
||||
return "set" + Character.toUpperCase(getAttributeName().charAt(0)) + getAttributeName().substring(1);
|
||||
}//getSetterName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.AssociationAbstractTargetPart#getGetterSignature()
|
||||
*/
|
||||
public String getGetterSignature() {
|
||||
return null;
|
||||
}//getGetterSignature()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.AssociationAbstractTargetPart#getSetterSignature()
|
||||
*/
|
||||
public String getSetterSignature() {
|
||||
return null;
|
||||
}//getSetterSignature()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.AssociationAbstractTargetPart#getSetterSignatureTypeNames()
|
||||
*/
|
||||
public String[] getSetterSignatureTypeNames() {
|
||||
IClassMetadataLoader loader = ((ViewModel) getComponent().getViewModel()).getApplicationClassMetadataLoader();
|
||||
String type = getGetterResultType(loader);
|
||||
|
||||
return new String[] {type};
|
||||
}//getSetterSignatureTypeNames()//
|
||||
}//AssociationAttributeTargetPart//
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2006,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.IElement;
|
||||
|
||||
/**
|
||||
* Encapsulates the set of association nodes (and leaf nodes) that are used to locate a value for the association.
|
||||
*/
|
||||
public class AssociationGroupPart extends AssociationAbstractNodePart implements IAssociationGroupPart {
|
||||
public static final String ATTRIBUTE_FUNCTION = "function";
|
||||
|
||||
public static final Attribute TYPE = registerAttribute(AssociationGroupPart.class, "type");
|
||||
public static final Attribute VALUE_HOLDER_NAME = registerAttribute(AssociationGroupPart.class, "valueHolderName");
|
||||
/**
|
||||
* AssociationGroupPart constructor.
|
||||
* <p><b>Warning: Only public for the purpose of creating reflections.</b></p>
|
||||
*/
|
||||
public AssociationGroupPart() {
|
||||
}//AssociationGroupPart()//
|
||||
/**
|
||||
* AssociationGroupPart constructor.
|
||||
* @param type The type definition for the attribute.
|
||||
* @param component The component referencing the attribute.
|
||||
* @param documentElement The optional element of the document that defines this association. This is used for debugging.
|
||||
*/
|
||||
public AssociationGroupPart(IAssociationPartType type, IComponentData component, IElement documentElement) {
|
||||
super(null, component, documentElement);
|
||||
setType(type);
|
||||
}//AssociationGroupPart()//
|
||||
/**
|
||||
* Gets the AssociationPartType that defines how this association should look.
|
||||
* @return The definition for this association (similar to how a class works for an instance).
|
||||
*/
|
||||
public IAssociationPartType getType() {
|
||||
return (IAssociationPartType) getAttributeValue(TYPE);
|
||||
}//getType()//
|
||||
/**
|
||||
* Sets the AssociationPartType that defines how this association should look.
|
||||
* @param type The definition for this association (similar to how a class works for an instance).
|
||||
*/
|
||||
private void setType(IAssociationPartType type) {
|
||||
setAttributeValue(TYPE, type);
|
||||
}//setType()//
|
||||
/**
|
||||
* Gets the name of the value holder associated with the part.
|
||||
* <p>This is only used for root level links in the group and only if this is a single-association. This must be null otherwise.</p>
|
||||
* @return The the name of the value holder whose value has the attribute that will be listened to.
|
||||
*/
|
||||
public String getValueHolderName() {
|
||||
return (String) getAttributeValue(VALUE_HOLDER_NAME);
|
||||
}//getValueHolderName()//
|
||||
/**
|
||||
* Sets the name of the value holder associated with the part.
|
||||
* <p>This is only used for root level links in the group and only if this is a single-association. This must be null otherwise.</p>
|
||||
* <p><b>Warning: This method will clear the attribute data.</b></p>
|
||||
* @param valueHolderName The the name of the value holder which can be null for multi-associations.
|
||||
*/
|
||||
public void setValueHolderName(String valueHolderName) {
|
||||
setAttributeValue(VALUE_HOLDER_NAME, valueHolderName);
|
||||
}//setValueHolderName()//
|
||||
}//AssociationGroupPart//
|
||||
@@ -0,0 +1,206 @@
|
||||
/*
|
||||
* Copyright (c) 2006,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.IManagedList;
|
||||
import com.foundation.util.ManagedList;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.view.builder.BuildFailedException;
|
||||
import com.foundation.view.builder.BuilderSupport;
|
||||
import com.foundation.view.builder.IClassMetadataLoader;
|
||||
|
||||
/*
|
||||
* This class models a link in the tree of association tags that result in the association target tags.
|
||||
* The indirect link is a specialized link that allows a row value to be passed to a value-holder value via a method to get the value for the link.
|
||||
* The indirect link tracks events similar to the method target code, the user can specify a tree of events to be listened to.
|
||||
*/
|
||||
public class AssociationIndirectLinkPart extends AssociationAbstractNodePart implements IAssociationIndirectLinkPart {
|
||||
public static final Attribute VALUE_HOLDER_NAME = registerAttribute(AssociationIndirectLinkPart.class, "valueHolderName");
|
||||
public static final Attribute ROW_TYPE_NAME = registerAttribute(AssociationIndirectLinkPart.class, "rowTypeName");
|
||||
public static final Attribute EVENTS = registerCollection(AssociationIndirectLinkPart.class, "events", AO_LAZY);
|
||||
public static final Attribute ATTRIBUTES = registerCollection(AssociationIndirectLinkPart.class, "attributes", AO_LAZY);
|
||||
public static final Attribute NODES = registerCollection(AssociationIndirectLinkPart.class, "nodes", AO_LAZY);
|
||||
public static final Attribute GETTER_NAME = registerAttribute(AssociationIndirectLinkPart.class, "getterName");
|
||||
public static final Attribute GETTER_SIGNATURE = registerAttribute(AssociationIndirectLinkPart.class, "getterSignature");
|
||||
public static final Attribute SETTER_NAME = registerAttribute(AssociationIndirectLinkPart.class, "setterName");
|
||||
public static final Attribute SETTER_SIGNATURE = registerAttribute(AssociationIndirectLinkPart.class, "setterSignature");
|
||||
public static final Attribute INVERT_LOGIC = registerAttribute(AssociationIndirectLinkPart.class, "invertLogic", Boolean.FALSE);
|
||||
|
||||
/** A cached result type for the getter method. This is cached since it is a bit time intensive to find it. */
|
||||
private String getterResultType = null;
|
||||
/**
|
||||
* AssociationLinkPart constructor.
|
||||
* <p><b>Warning: Only public for the purpose of creating reflections.</b></p>
|
||||
*/
|
||||
public AssociationIndirectLinkPart() {
|
||||
}//AssociationLinkPart()//
|
||||
/**
|
||||
* AssociationLinkPart constructor.
|
||||
* @param parent The parent for the association link part.
|
||||
* @param component The component referencing the association.
|
||||
* @param documentElement The optional element of the document that defines this association. This is used for debugging.
|
||||
*/
|
||||
public AssociationIndirectLinkPart(IAssociationAbstractNodePart parent, IComponentData component, IElement documentElement) {
|
||||
super(parent, component, documentElement);
|
||||
}//AssociationLinkPart()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.common.Entity#lazyLoadAttribute(com.foundation.metadata.Attribute)
|
||||
*/
|
||||
protected Object lazyLoadAttribute(Attribute attribute) {
|
||||
Object result = null;
|
||||
|
||||
if(attribute == EVENTS) {
|
||||
result = new ManagedList(5, 20);
|
||||
}//if//
|
||||
else if(attribute == ATTRIBUTES) {
|
||||
result = new ManagedList(5, 20);
|
||||
}//else if//
|
||||
else if(attribute == NODES) {
|
||||
result = new ManagedList(5, 20);
|
||||
}//else if//
|
||||
else {
|
||||
result = super.lazyLoadAttribute(attribute);
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//lazyLoadAttribute()//
|
||||
/**
|
||||
* Gets the EventPart instances that should be listened to for the target value.
|
||||
* @return The collection of EventPart instances, one for each event listened to on the association's result.
|
||||
*/
|
||||
public IManagedList getEvents() {
|
||||
return (IManagedList) getAttributeValue(EVENTS);
|
||||
}//getEvents()//
|
||||
/**
|
||||
* Gets the AttributePart instances that should be listened to for the target value.
|
||||
* @return The collection of AttributePart instances, one for each attribute listened to on the association's result.
|
||||
*/
|
||||
public IManagedList getAttributes() {
|
||||
return (IManagedList) getAttributeValue(ATTRIBUTES);
|
||||
}//getAttributes()//
|
||||
/**
|
||||
* Gets the association nodes that contain additional change listening for the target value.
|
||||
* This allows listening to events furthor down in the object tree, beyond the target value.
|
||||
* @return The collection of AssociationNodePart instances.
|
||||
*/
|
||||
public IManagedList getNodes() {
|
||||
return (IManagedList) getAttributeValue(NODES);
|
||||
}//getNodes()//
|
||||
/**
|
||||
* Gets the name of the required value holder associated with the part.
|
||||
* @return The name of the value holder whose value has the getter method and events that will be listened to.
|
||||
*/
|
||||
public String getValueHolderName() {
|
||||
return (String) getAttributeValue(VALUE_HOLDER_NAME);
|
||||
}//getValueHolderName()//
|
||||
/**
|
||||
* Sets the name of the required value holder associated with the part.
|
||||
* <p><b>Warning: This method will clear the method data.</b></p>
|
||||
* @param valueHolderName The name of the value holder whose value has the getter method and events that will be listened to.
|
||||
*/
|
||||
public void setValueHolderName(String valueHolderName) {
|
||||
setAttributeValue(VALUE_HOLDER_NAME, valueHolderName);
|
||||
//Clear the method data since it will require new information.//
|
||||
setGetterName(null);
|
||||
setGetterSignature(null);
|
||||
}//setValueHolderName()//
|
||||
/**
|
||||
* Gets the type of row which will be passed to the accessor method.
|
||||
* @return The qualified class name of the row type supported by this association.
|
||||
*/
|
||||
public String getRowTypeName() {
|
||||
return (String) getAttributeValue(ROW_TYPE_NAME);
|
||||
}//getRowTypeName()//
|
||||
/**
|
||||
* Sets the type of row which will be passed to the accessor method.
|
||||
* <p><b>Warning: This method will clear the method data.</b></p>
|
||||
* @param rowTypeName The qualified class name of the row type supported by this association.
|
||||
*/
|
||||
public void setRowTypeName(String rowTypeName) {
|
||||
setAttributeValue(ROW_TYPE_NAME, rowTypeName);
|
||||
//Clear the method data since it will require new information.//
|
||||
setGetterName(null);
|
||||
setGetterSignature(null);
|
||||
}//setRowTypeName()//
|
||||
/**
|
||||
* Gets the name of the getter method used to get the result of the link.
|
||||
* @return The name of the getter method defined by the value holder's held value.
|
||||
*/
|
||||
public String getGetterName() {
|
||||
return (String) getAttributeValue(GETTER_NAME);
|
||||
}//getGetterName()//
|
||||
/**
|
||||
* Sets the name of the getter method used to get the result of the link.
|
||||
* @param getterName The name of the getter method defined by the value holder's held value.
|
||||
*/
|
||||
public void setGetterName(String getterName) {
|
||||
setAttributeValue(GETTER_NAME, getterName);
|
||||
}//setGetterName()//
|
||||
/**
|
||||
* Gets the signature of the getter method used to get the result of the link.
|
||||
* @return The signature of the getter method defined by the value holder's held value.
|
||||
*/
|
||||
public String getGetterSignature() {
|
||||
return (String) getAttributeValue(GETTER_SIGNATURE);
|
||||
}//getGetterSignature()//
|
||||
/**
|
||||
* Sets the signature of the getter method used to get the result of the link.
|
||||
* @param getterSignature The signature of the getter method defined by the value holder's held value.
|
||||
*/
|
||||
public void setGetterSignature(String getterSignature) {
|
||||
setAttributeValue(GETTER_SIGNATURE, getterSignature);
|
||||
}//setGetterSignature()//
|
||||
/**
|
||||
* Gets the class that is returned by the getter method.
|
||||
* @param applicationClassMetadataLoader The class loader to use to load the application class metadata.
|
||||
* @return The getter method's return type which will always be non-null.
|
||||
*/
|
||||
public String getGetterResultType(IClassMetadataLoader applicationClassMetadataLoader) {
|
||||
String result = null;
|
||||
|
||||
if(getterResultType != null) {
|
||||
result = getterResultType;
|
||||
}//if//
|
||||
else {
|
||||
if(getValueHolderName() != null) {
|
||||
try {
|
||||
result = applicationClassMetadataLoader.getMethodReturnType(getValueHolderType(getValueHolderName()), getGetterName(), getGetterSignature(), getFeedbackStack(), getDocumentElement());
|
||||
}//try//
|
||||
catch(ClassNotFoundException e) {
|
||||
getFeedbackStack().add(new Message(true, "Invalid class name: " + getValueHolderType(getValueHolderName()), getValueHolder(getValueHolderName()).getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//catch//
|
||||
}//if//
|
||||
else if(getRowTypeName() != null) {
|
||||
try {
|
||||
result = applicationClassMetadataLoader.getMethodReturnType(getRowTypeName(), getGetterName(), getGetterSignature(), getFeedbackStack(), getDocumentElement());
|
||||
}//try//
|
||||
catch(ClassNotFoundException e) {
|
||||
getFeedbackStack().add(new Message(true, "Invalid class name: " + getRowTypeName(), getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//catch//
|
||||
}//else if//
|
||||
else {
|
||||
getFeedbackStack().add(new Message(true, "Error: The attribute must either specify a value-holder or value-type.", getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//else//
|
||||
|
||||
//Cache the result for efficiency.//
|
||||
getterResultType = result;
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//getGetterResultType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationIndirectLinkPart#getGetterSignatureTypeNames()
|
||||
*/
|
||||
public String[] getGetterSignatureTypeNames() {
|
||||
return BuilderSupport.getMethodParameterTypes(getGetterSignature(), getFeedbackStack(), getDocumentElement());
|
||||
}//getGetterSignatureTypeNames()//
|
||||
}//AssociationLinkPart//
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2006,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.view.builder.BuildFailedException;
|
||||
import com.foundation.view.builder.IClassMetadataLoader;
|
||||
|
||||
/*
|
||||
* This class models a link in the tree of association tags that result in the association target tags.
|
||||
* Links can only use attributes to access values and may not specify additional events.
|
||||
*/
|
||||
public class AssociationLinkPart extends AssociationAbstractNodePart implements IAssociationLinkPart {
|
||||
public static final Attribute ROW_TYPE_NAME = registerAttribute(AssociationLinkPart.class, "rowTypeName");
|
||||
public static final Attribute ATTRIBUTE_NAME = registerAttribute(AssociationLinkPart.class, "attributeName");
|
||||
/**
|
||||
* AssociationLinkPart constructor.
|
||||
* <p><b>Warning: Only public for the purpose of creating reflections.</b></p>
|
||||
*/
|
||||
public AssociationLinkPart() {
|
||||
}//AssociationLinkPart()//
|
||||
/**
|
||||
* AssociationLinkPart constructor.
|
||||
* @param parent The parent for the association link part.
|
||||
* @param component The component referencing the association.
|
||||
* @param documentElement The optional element of the document that defines this association. This is used for debugging.
|
||||
*/
|
||||
public AssociationLinkPart(IAssociationAbstractNodePart parent, IComponentData component, IElement documentElement) {
|
||||
super(parent, component, documentElement);
|
||||
}//AssociationLinkPart()//
|
||||
/**
|
||||
* Gets the qualified class name for the class which defines the referenced part, or if value holder related, the type of row which will be passed to the accessor methods.
|
||||
* @return The qualified class name of the row type supported by this association.
|
||||
*/
|
||||
public String getRowTypeName() {
|
||||
return (String) getAttributeValue(ROW_TYPE_NAME);
|
||||
}//getRowTypeName()//
|
||||
/**
|
||||
* Sets the qualified class name for the class which defines the referenced part, or if value holder related, the type of row which will be passed to the accessor methods.
|
||||
* <p><b>Warning: This method will clear the attribute data.</b></p>
|
||||
* @param rowTypeName The qualified class name of the row type supported by this association.
|
||||
*/
|
||||
public void setRowTypeName(String rowTypeName) {
|
||||
setAttributeValue(ROW_TYPE_NAME, rowTypeName);
|
||||
//Clear the attribute data since it will require new information.//
|
||||
setAttributeName(null);
|
||||
}//setRowTypeName()//
|
||||
/**
|
||||
* Gets the name of the attribute.
|
||||
* @return The name of the attribute.
|
||||
*/
|
||||
public String getAttributeName() {
|
||||
return (String) getAttributeValue(ATTRIBUTE_NAME);
|
||||
}//getAttributeName()//
|
||||
/**
|
||||
* Sets the name of the attribute.
|
||||
* @param attributeName The name of the attribute.
|
||||
*/
|
||||
public void setAttributeName(String attributeName) {
|
||||
setAttributeValue(ATTRIBUTE_NAME, attributeName);
|
||||
}//setAttributeName()//
|
||||
/**
|
||||
* Gets the getter method name for the attribute.
|
||||
* @return The name of the getter method used to access the value.
|
||||
*/
|
||||
public String getGetterName() {
|
||||
return "get" + Character.toUpperCase(getAttributeName().charAt(0)) + getAttributeName().substring(1);
|
||||
}//getGetterName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationLinkPart#getGetterResultType(com.foundation.view.builder.IClassMetadataLoader)
|
||||
*/
|
||||
public String getGetterResultType(IClassMetadataLoader applicationClassMetadataLoader) {
|
||||
String result = null;
|
||||
|
||||
if(getRowTypeName() != null) {
|
||||
try {
|
||||
result = applicationClassMetadataLoader.getMethodReturnType(getRowTypeName(), getGetterName(), null, getFeedbackStack(), getDocumentElement());
|
||||
}//try//
|
||||
catch(ClassNotFoundException e) {
|
||||
getFeedbackStack().add(new Message(true, "Invalid class name: " + getRowTypeName(), getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//catch//
|
||||
}//if//
|
||||
else {
|
||||
getFeedbackStack().add(new Message(true, "Error: The association must specify a row-type.", getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//getGetterResultType()//
|
||||
}//AssociationLinkPart//
|
||||
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
* Copyright (c) 2006,2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.IManagedList;
|
||||
import com.foundation.util.ManagedList;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.view.builder.BuildFailedException;
|
||||
import com.foundation.view.builder.IClassMetadataLoader;
|
||||
|
||||
/**
|
||||
* Defines an association part that returns a result value for the association to the user control.
|
||||
* This association target part uses getter and optional setter methods to access the target value and listens to an arbitrary tree of events to know when the target value changes.
|
||||
*/
|
||||
public class AssociationMethodTargetPart extends AssociationAbstractTargetPart implements IAssociationMethodTargetPart {
|
||||
public static final Attribute EVENTS = registerCollection(AssociationMethodTargetPart.class, "events", AO_LAZY);
|
||||
public static final Attribute ATTRIBUTES = registerCollection(AssociationMethodTargetPart.class, "attributes", AO_LAZY);
|
||||
public static final Attribute NODES = registerCollection(AssociationMethodTargetPart.class, "nodes", AO_LAZY);
|
||||
public static final Attribute GETTER_NAME = registerAttribute(AssociationMethodTargetPart.class, "getterName");
|
||||
public static final Attribute GETTER_SIGNATURE = registerAttribute(AssociationMethodTargetPart.class, "getterSignature");
|
||||
public static final Attribute SETTER_NAME = registerAttribute(AssociationMethodTargetPart.class, "setterName");
|
||||
public static final Attribute SETTER_SIGNATURE = registerAttribute(AssociationMethodTargetPart.class, "setterSignature");
|
||||
public static final Attribute ORIGINAL_VALUE_GETTER_NAME = registerAttribute(AssociationMethodTargetPart.class, "originalValueGetterName");
|
||||
public static final Attribute ORIGINAL_VALUE_GETTER_SIGNATURE = registerAttribute(AssociationMethodTargetPart.class, "originalValueGetterSignature");
|
||||
/**
|
||||
* AssociationTargetPart constructor.
|
||||
* <p><b>Warning: Only public for the purpose of creating reflections.</b></p>
|
||||
*/
|
||||
public AssociationMethodTargetPart() {
|
||||
}//AssociationTargetPart()//
|
||||
/**
|
||||
* AssociationTargetPart constructor.
|
||||
* @param parent The parent for the association target part.
|
||||
* @param component The component referencing the attribute.
|
||||
* @param documentElement The optional element of the document that defines this association. This is used for debugging.
|
||||
*/
|
||||
public AssociationMethodTargetPart(IAssociationAbstractNodePart parent, IComponentData component, IElement documentElement) {
|
||||
super(parent, component, documentElement);
|
||||
}//AssociationTargetPart()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationAbstractTargetPart#getOriginalValueGetterName()
|
||||
*/
|
||||
public String getOriginalValueGetterName() {
|
||||
return (String) getAttributeValue(ORIGINAL_VALUE_GETTER_NAME);
|
||||
}//getOriginalValueGetterName()//
|
||||
/**
|
||||
* Sets the getter method name used to access the original value for the association.
|
||||
* @param originalValueGetterName The method called when the association needs the original value (the value the new value is over writing).
|
||||
*/
|
||||
public void setOriginalValueGetterName(String originalValueGetterName) {
|
||||
setAttributeValue(ORIGINAL_VALUE_GETTER_NAME, originalValueGetterName);
|
||||
}//getOriginalValueGetterName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationAbstractTargetPart#getOriginalValueGetterSignature()
|
||||
*/
|
||||
public String getOriginalValueGetterSignature() {
|
||||
return (String) getAttributeValue(ORIGINAL_VALUE_GETTER_SIGNATURE);
|
||||
}//getOriginalValueGetterSignature()//
|
||||
/**
|
||||
* Sets the getter method signature used to access the original value for the association.
|
||||
* @param originalValueGetterSignature The signature of the method called when the association needs the original value (the value the new value is over writing).
|
||||
*/
|
||||
public void setOriginalValueGetterSignature(String originalValueGetterSignature) {
|
||||
setAttributeValue(ORIGINAL_VALUE_GETTER_SIGNATURE, originalValueGetterSignature);
|
||||
}//setOriginalValueGetterSignature()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.common.Entity#lazyLoadAttribute(com.foundation.metadata.Attribute)
|
||||
*/
|
||||
protected Object lazyLoadAttribute(Attribute attribute) {
|
||||
Object result = null;
|
||||
|
||||
if(attribute == EVENTS) {
|
||||
result = new ManagedList(5, 20);
|
||||
}//if//
|
||||
else if(attribute == ATTRIBUTES) {
|
||||
result = new ManagedList(5, 20);
|
||||
}//else if//
|
||||
else if(attribute == NODES) {
|
||||
result = new ManagedList(5, 20);
|
||||
}//else if//
|
||||
else {
|
||||
result = super.lazyLoadAttribute(attribute);
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//lazyLoadAttribute()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.AssociationAbstractTargetPart#getDefaultRowTypeName()
|
||||
*/
|
||||
public String getDefaultRowTypeName() {
|
||||
String result = null;
|
||||
|
||||
if(getValueHolderName() != null) {
|
||||
result = getValueHolderTypeName(getComponent(), getValueHolderName());
|
||||
}//if//
|
||||
else if(getParent() instanceof AssociationGroupPart) {
|
||||
result = getValueHolderTypeName(getComponent(), ((AssociationGroupPart) getParent()).getValueHolderName());
|
||||
}//else if//
|
||||
|
||||
return result;
|
||||
}//getDefaultRowTypeName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.AssociationAbstractTargetPart#setValueHolderName(java.lang.String)
|
||||
*/
|
||||
public void setValueHolderName(String valueHolderName) {
|
||||
super.setValueHolderName(valueHolderName);
|
||||
setGetterName(null);
|
||||
setGetterSignature(null);
|
||||
setSetterName(null);
|
||||
setSetterSignature(null);
|
||||
}//setValueHolderName()//
|
||||
/**
|
||||
* Sets the qualified class name for the type of row which will have the accessor methods or be passed to the accessor methods (depending on whether a value holder is specified).
|
||||
* <p>This is required if this is part of a multi-association or if this target's parent is not the group.</p>
|
||||
* <p><b>Warning: This method will clear the getter/setter data.</b></p>
|
||||
* @param rowTypeName The qualified class name of the row type supported by this association.
|
||||
*/
|
||||
public void setRowTypeName(String rowTypeName) {
|
||||
super.setRowTypeName(rowTypeName);
|
||||
setGetterName(null);
|
||||
setGetterSignature(null);
|
||||
setSetterName(null);
|
||||
setSetterSignature(null);
|
||||
}//setRowTypeName()//
|
||||
/**
|
||||
* Gets the event names that should be listened to for the target value.
|
||||
* @return The collection of String instances, one for each event listened to on the association's result.
|
||||
*/
|
||||
public IManagedList getEvents() {
|
||||
return (IManagedList) getAttributeValue(EVENTS);
|
||||
}//getEvents()//
|
||||
/**
|
||||
* Gets the attributes names that should be listened to for the target value.
|
||||
* @return The collection of String instances, one for each attribute listened to on the association's result.
|
||||
*/
|
||||
public IManagedList getAttributes() {
|
||||
return (IManagedList) getAttributeValue(ATTRIBUTES);
|
||||
}//getAttributes()//
|
||||
/**
|
||||
* Gets the association nodes that contain additional change listening for the target value.
|
||||
* This allows listening to events furthor down in the object tree, beyond the target value.
|
||||
* @return The collection of AssociationNodePart instances.
|
||||
*/
|
||||
public IManagedList getNodes() {
|
||||
return (IManagedList) getAttributeValue(NODES);
|
||||
}//getNodes()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.AssociationAbstractTargetPart#getGetterName()
|
||||
*/
|
||||
public String getGetterName() {
|
||||
return (String) getAttributeValue(GETTER_NAME);
|
||||
}//getGetterName()//
|
||||
/**
|
||||
* Sets the getter method name.
|
||||
* @param getterName The name of the getter method used to access the value.
|
||||
*/
|
||||
public void setGetterName(String getterName) {
|
||||
setAttributeValue(GETTER_NAME, getterName);
|
||||
}//setGetterName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.AssociationAbstractTargetPart#getGetterSignature()
|
||||
*/
|
||||
public String getGetterSignature() {
|
||||
return (String) getAttributeValue(GETTER_SIGNATURE);
|
||||
}//getGetterSignature()//
|
||||
/**
|
||||
* Sets the getter method's signature in class file format.
|
||||
* @param getterSignature The signature that unqiuely identifies the getter method.
|
||||
*/
|
||||
public void setGetterSignature(String getterSignature) {
|
||||
setAttributeValue(GETTER_SIGNATURE, getterSignature);
|
||||
}//setGetterSignature()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.AssociationAbstractTargetPart#getSetterName()
|
||||
*/
|
||||
public String getSetterName() {
|
||||
return (String) getAttributeValue(SETTER_NAME);
|
||||
}//getSetterName()//
|
||||
/**
|
||||
* Sets the optional setter method name.
|
||||
* @param setterMethodName The name of the setter method used to set the value.
|
||||
*/
|
||||
public void setSetterName(String setterName) {
|
||||
setAttributeValue(SETTER_NAME, setterName);
|
||||
}//setSetterName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.AssociationAbstractTargetPart#getSetterSignature()
|
||||
*/
|
||||
public String getSetterSignature() {
|
||||
return (String) getAttributeValue(SETTER_SIGNATURE);
|
||||
}//getSetterSignature()//
|
||||
/**
|
||||
* Sets the setter method's signature in class file format.
|
||||
* @param setterSignature The signature that unqiuely identifies the setter method.
|
||||
*/
|
||||
public void setSetterSignature(String setterSignature) {
|
||||
setAttributeValue(SETTER_SIGNATURE, setterSignature);
|
||||
}//setSetterSignature()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationAbstractTargetPart#getGetterResultType(com.foundation.view.builder.IClassMetadataLoader)
|
||||
*/
|
||||
public String getGetterResultType(IClassMetadataLoader applicationClassMetadataLoader) {
|
||||
String result = null;
|
||||
|
||||
if(getterResultType != null) {
|
||||
result = getterResultType;
|
||||
}//if//
|
||||
else {
|
||||
//Use the value holder's type if available, otherwise the row type specified in the VML.//
|
||||
String rowTypeName = getValueHolderName() != null || getRowTypeName() == null ? getDefaultRowTypeName() : getRowTypeName();
|
||||
|
||||
if(rowTypeName != null) {
|
||||
try {
|
||||
result = applicationClassMetadataLoader.getMethodReturnType(rowTypeName, getGetterName(), getGetterSignature(), getFeedbackStack(), getDocumentElement());
|
||||
}//try//
|
||||
catch(ClassNotFoundException e) {
|
||||
getFeedbackStack().add(new Message(true, "Invalid class name: " + rowTypeName, getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//catch//
|
||||
}//if//
|
||||
else {
|
||||
getFeedbackStack().add(new Message(true, "Error: The attribute must either specify a value-holder or value-type.", getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//else//
|
||||
|
||||
//Cache the result for efficiency.//
|
||||
getterResultType = result;
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//getGetterResultType()//
|
||||
}//AssociationTargetPart//
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2006,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.IManagedList;
|
||||
import com.foundation.util.ManagedList;
|
||||
import com.foundation.util.xml.IElement;
|
||||
|
||||
/**
|
||||
* Association nodes are used by an association target or link to build an arbitrary tree of listeners to models which will indicate that the target value has been altered.
|
||||
*/
|
||||
public class AssociationNodePart extends AbstractPart implements IAssociationNodePart {
|
||||
public static final Attribute EVENTS = registerCollection(AssociationNodePart.class, "events", AO_LAZY);
|
||||
public static final Attribute ATTRIBUTES = registerCollection(AssociationNodePart.class, "attributes", AO_LAZY);
|
||||
public static final Attribute ROW_TYPE_NAME = registerAttribute(AssociationNodePart.class, "rowTypeName");
|
||||
/**
|
||||
* AssociationNodePart constructor.
|
||||
* <p><b>Warning: Only public for the purpose of creating reflections.</b></p>
|
||||
*/
|
||||
public AssociationNodePart() {
|
||||
}//AssociationNodePart()//
|
||||
/**
|
||||
* AssociationNodePart constructor.
|
||||
* @param parent The target which is defining this node.
|
||||
* @param component The component referencing the attribute.
|
||||
* @param documentElement The optional element of the document that defines this association. This is used for debugging.
|
||||
*/
|
||||
public AssociationNodePart(IComponentData component, IElement documentElement) {
|
||||
super(component);
|
||||
setDocumentElement(documentElement);
|
||||
}//AssociationNodePart()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.common.Entity#lazyLoadAttribute(com.foundation.metadata.Attribute)
|
||||
*/
|
||||
protected Object lazyLoadAttribute(Attribute attribute) {
|
||||
Object result = null;
|
||||
|
||||
if(attribute == EVENTS) {
|
||||
result = new ManagedList(5, 20);
|
||||
}//if//
|
||||
else if(attribute == ATTRIBUTES) {
|
||||
result = new ManagedList(5, 20);
|
||||
}//else if//
|
||||
else {
|
||||
result = super.lazyLoadAttribute(attribute);
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//lazyLoadAttribute()//
|
||||
/**
|
||||
* Gets the event names that should be listened to for the leaf node.
|
||||
* <p>Warning: This is only valid for leaf nodes.</p>
|
||||
* @return The collection of String instances, one for each event listened to on the association's result.
|
||||
*/
|
||||
public IManagedList getEvents() {
|
||||
return (IManagedList) getAttributeValue(EVENTS);
|
||||
}//getEvents()//
|
||||
/**
|
||||
* Gets the attributes names that should be listened to for the leaf node.
|
||||
* <p>Warning: This is only valid for leaf nodes.</p>
|
||||
* @return The collection of String instances, one for each attribute listened to on the association's result.
|
||||
*/
|
||||
public IManagedList getAttributes() {
|
||||
return (IManagedList) getAttributeValue(ATTRIBUTES);
|
||||
}//getAttributes()//
|
||||
/**
|
||||
* Gets the qualified class name which defines what values this node applies to.
|
||||
* @return The qualified class name of the row type supported by this association node.
|
||||
*/
|
||||
public String getRowTypeName() {
|
||||
return (String) getAttributeValue(ROW_TYPE_NAME);
|
||||
}//getRowTypeName()//
|
||||
/**
|
||||
* Sets the qualified class name which defines what values this node applies to.
|
||||
* @param rowTypeName The qualified class name of the row type supported by this association node.
|
||||
*/
|
||||
public void setRowTypeName(String rowTypeName) {
|
||||
setAttributeValue(ROW_TYPE_NAME, rowTypeName);
|
||||
}//setRowTypeName()//
|
||||
}//AssociationNodePart//
|
||||
@@ -0,0 +1,450 @@
|
||||
/*
|
||||
* Copyright (c) 2005,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.common.comparison.Comparator;
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.IManagedList;
|
||||
import com.foundation.util.ManagedList;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.view.builder.BuildFailedException;
|
||||
import com.foundation.view.builder.BuilderSupport;
|
||||
import com.foundation.view.builder.IClassMetadataLoader;
|
||||
|
||||
/**
|
||||
* Encapsulates a association between a component's function and either an attribute or a getter and/or setter methods and zero or more events.
|
||||
* <p>TODO: Allow the event(s) to be bound to other value holder held values in addition to the row or value holder that the attribute or methods are bound to. This is useful if the object doesn't fire the right events and the view controller will be firing a special event.</p>
|
||||
*/
|
||||
public class AssociationPart extends AbstractPart implements IAssociationPart {
|
||||
public static final Attribute TYPE = registerAttribute(AssociationPart.class, "type");
|
||||
public static final Attribute VALUE_HOLDER_NAME = registerAttribute(AssociationPart.class, "valueHolderName");
|
||||
public static final Attribute HELD_TYPE_NAME = registerAttribute(AssociationPart.class, "heldTypeName");
|
||||
public static final Attribute ROW_TYPE_NAME = registerAttribute(AssociationPart.class, "rowTypeName");
|
||||
public static final Attribute ATTRIBUTE_NAME = registerAttribute(AssociationPart.class, "attributeName");
|
||||
public static final Attribute GETTER_NAME = registerAttribute(AssociationPart.class, "getterName");
|
||||
public static final Attribute GETTER_SIGNATURE = registerAttribute(AssociationPart.class, "getterSignature");
|
||||
public static final Attribute SETTER_NAME = registerAttribute(AssociationPart.class, "setterName");
|
||||
public static final Attribute SETTER_SIGNATURE = registerAttribute(AssociationPart.class, "setterSignature");
|
||||
public static final Attribute EVENTS = registerAttribute(AssociationPart.class, "events");
|
||||
public static final Attribute CHILD_ASSOCIATION = registerAttribute(AssociationPart.class, "childAssociation");
|
||||
public static final Attribute INVERT_LOGIC = registerAttribute(AssociationPart.class, "invertLogic", Boolean.FALSE);
|
||||
public static final Attribute CONVERT_TO_CONTROL_NAME = registerAttribute(AssociationPart.class, "convertToControlName");
|
||||
public static final Attribute CONVERT_TO_CONTROL_SIGNATURE = registerAttribute(AssociationPart.class, "convertToControlSignature");
|
||||
public static final Attribute CONVERT_FROM_CONTROL_NAME = registerAttribute(AssociationPart.class, "convertFromControlName");
|
||||
public static final Attribute CONVERT_FROM_CONTROL_SIGNATURE = registerAttribute(AssociationPart.class, "convertFromControlSignature");
|
||||
public static final Attribute CONVERT_VALUE_HOLDER_NAME = registerAttribute(AssociationPart.class, "convertValueHolderName");
|
||||
|
||||
/** The event part type for the association events. */
|
||||
public static final EventPartType ASSOCIATION_EVENT_PART_TYPE = new EventPartType();
|
||||
|
||||
static {
|
||||
ASSOCIATION_EVENT_PART_TYPE.setMultiple(Boolean.TRUE);
|
||||
ASSOCIATION_EVENT_PART_TYPE.setFunction("");
|
||||
ASSOCIATION_EVENT_PART_TYPE.setRequired(Boolean.FALSE);
|
||||
ASSOCIATION_EVENT_PART_TYPE.setRequiresValueHolder(Boolean.FALSE);
|
||||
}//static//
|
||||
|
||||
/** A cached result type for the getter method. This is cached since it is a bit time intensive to find it. */
|
||||
private String getterResultType = null;
|
||||
/**
|
||||
* AssociationPart constructor.
|
||||
* <p><b>Warning: Only public for the purpose of creating reflections.</b></p>
|
||||
*/
|
||||
public AssociationPart() {
|
||||
}//AssociationPart()//
|
||||
/**
|
||||
* AssociationPart constructor.
|
||||
* @param type The type definition for the attribute.
|
||||
* @param component The component referencing the attribute.
|
||||
* @param documentElement The optional element of the document that defines this association. This is used for debugging.
|
||||
*/
|
||||
public AssociationPart(IAssociationPartType type, IComponentData component, IElement documentElement) {
|
||||
super(component);
|
||||
setDocumentElement(documentElement);
|
||||
setType(type);
|
||||
setEvents(new ManagedList(1, 10));
|
||||
}//AssociationPart()//
|
||||
/**
|
||||
* AssociationPart constructor.
|
||||
* @param type The type definition for the attribute.
|
||||
* @param component The component referencing the attribute.
|
||||
* @param name The name of the attribute.
|
||||
* @param valueHolderName The name of the value holder whose held value will be used to get/set the attribute. This is required if the type is not multi, otherwise optional.
|
||||
* @param heldTypeName The qualified class name for the class which defines the association. This is only allowed (optional) if there is a value holder related to the association. This is never allowed for child associations (in a chain).
|
||||
* @param rowTypeName The qualified class name for the class which defines the referenced part, or if value holder related, the type of row which will be passed to the accessor methods. This must be non-null if this is a multi-association (multiple component items registered with the association). If this is a child association (chained) then this is the type of data passed to the association from the parent association.
|
||||
* @param applicationClassLoader The class loader which can load the attribute's defining class to figure out the attribute type.
|
||||
* @param invertLogic Whether the boolean result should be inverted. This is ignored for associations that don't result in a boolean value.
|
||||
* @param documentElement The optional element of the document that defines this association. This is used for debugging.
|
||||
*/
|
||||
public AssociationPart(IAssociationPartType type, IComponentData component, String attributeName, String valueHolderName, String heldTypeName, String rowTypeName, IClassMetadataLoader applicationClassMetadataLoader, Boolean invertLogic, IElement documentElement) {
|
||||
super(component);
|
||||
setDocumentElement(documentElement);
|
||||
setType(type);
|
||||
setValueHolderName(valueHolderName);
|
||||
setHeldTypeName(heldTypeName);
|
||||
setRowTypeName(rowTypeName);
|
||||
setInvertLogic(invertLogic);
|
||||
setAttributeName(attributeName);
|
||||
|
||||
if(type.getGetter() != OPTION_NONE) {
|
||||
setGetterName("get" + Character.toUpperCase(attributeName.charAt(0)) + attributeName.substring(1));
|
||||
}//if//
|
||||
|
||||
if(type.getSetter() != OPTION_NONE) {
|
||||
setSetterName("set" + Character.toUpperCase(attributeName.charAt(0)) + attributeName.substring(1));
|
||||
setSetterSignature("L" + getGetterResultType(applicationClassMetadataLoader) + ";");
|
||||
}//if//
|
||||
|
||||
setEvents(new ManagedList(1, 10));
|
||||
getEvents().add(new EventPart(ASSOCIATION_EVENT_PART_TYPE, component, attributeName, valueHolderName, heldTypeName, rowTypeName, documentElement));
|
||||
}//AssociationPart()//
|
||||
/**
|
||||
* Gets the AssociationPartType that defines how this attribute part should look.
|
||||
* @return The definition for this attribute part (similar to how a class works for an instance).
|
||||
*/
|
||||
public IAssociationPartType getType() {
|
||||
return (IAssociationPartType) getAttributeValue(TYPE);
|
||||
}//getType()//
|
||||
/**
|
||||
* Sets the AssociationPartType that defines how this attribute part should look.
|
||||
* @param type The definition for this attribute part (similar to how a class works for an instance).
|
||||
*/
|
||||
private void setType(IAssociationPartType type) {
|
||||
setAttributeValue(TYPE, type);
|
||||
}//setType()//
|
||||
/**
|
||||
* Gets the name of the value holder associated with the part.
|
||||
* <p>This is required for single-associations, for multi-associations it is optional, but if provided the the getter and setter methods may accept the row object as a parameter.</p>
|
||||
* @return The the name of the value holder which can be null for multi-associations.
|
||||
*/
|
||||
public String getValueHolderName() {
|
||||
return (String) getAttributeValue(VALUE_HOLDER_NAME);
|
||||
}//getValueHolderName()//
|
||||
/**
|
||||
* Sets the name of the value holder associated with the part.
|
||||
* <p>This is required for single-associations, for multi-associations it is optional, but if provided the the getter and setter methods may accept the row object as a parameter.</p>
|
||||
* <p><b>Warning: This method will clear the attribute & getter/setter data.</b></p>
|
||||
* @param valueHolderName The the name of the value holder which can be null for multi-associations.
|
||||
*/
|
||||
public void setValueHolderName(String valueHolderName) {
|
||||
setAttributeValue(VALUE_HOLDER_NAME, valueHolderName);
|
||||
//Clear the attribute and getter/setter data since it will require new information.//
|
||||
setAttributeName(null);
|
||||
setGetterName(null);
|
||||
setGetterSignature(null);
|
||||
setSetterName(null);
|
||||
setSetterSignature(null);
|
||||
}//setValueHolderName()//
|
||||
/**
|
||||
* Gets the qualified class name for the class which defines the association.
|
||||
* <p>This is only allowed (it is optional) for associations which define a value holder.</p>
|
||||
* @return The qualified class name of the value holder held type defining the attribute, methods, and events in this part.
|
||||
*/
|
||||
public String getHeldTypeName() {
|
||||
return (String) getAttributeValue(HELD_TYPE_NAME);
|
||||
}//getHeldTypeName()//
|
||||
/**
|
||||
* Sets the qualified class name for the class which defines the association.
|
||||
* <p>This is only allowed (it is optional) for associations which define a value holder.</p>
|
||||
* <p><b>Warning: This method will clear the attribute & getter/setter data.</b></p>
|
||||
* @param heldTypeName The qualified class name of the value holder held type defining the attribute, methods, and events in this part.
|
||||
*/
|
||||
public void setHeldTypeName(String heldTypeName) {
|
||||
setAttributeValue(HELD_TYPE_NAME, heldTypeName);
|
||||
//Clear the attribute and getter/setter data since it will require new information.//
|
||||
setAttributeName(null);
|
||||
setGetterName(null);
|
||||
setGetterSignature(null);
|
||||
setSetterName(null);
|
||||
setSetterSignature(null);
|
||||
}//setHeldTypeName()//
|
||||
/**
|
||||
* Gets the qualified class name for the class which defines the referenced part, or if value holder related, the type of row which will be passed to the accessor methods.
|
||||
* <p>This is only defined for multi-associations and not for single-associations since only multi-associations have rows.
|
||||
* If this is a child association (chained) then this is the type of data passed to the association from the parent association.</p>
|
||||
* @return The qualified class name of the row type supported by this association.
|
||||
*/
|
||||
public String getRowTypeName() {
|
||||
return (String) getAttributeValue(ROW_TYPE_NAME);
|
||||
}//getRowTypeName()//
|
||||
/**
|
||||
* Sets the qualified class name for the class which defines the referenced part, or if value holder related, the type of row which will be passed to the accessor methods.
|
||||
* <p>This is only defined for multi-associations and not for single-associations since only multi-associations have rows.
|
||||
* If this is a child association (chained) then this is the type of data passed to the association from the parent association.</p>
|
||||
* <p><b>Warning: This method will clear the attribute & getter/setter data.</b></p>
|
||||
* @param rowTypeName The qualified class name of the row type supported by this association.
|
||||
*/
|
||||
public void setRowTypeName(String rowTypeName) {
|
||||
setAttributeValue(ROW_TYPE_NAME, rowTypeName);
|
||||
//Clear the attribute and getter/setter data since it will require new information.//
|
||||
setAttributeName(null);
|
||||
setGetterName(null);
|
||||
setGetterSignature(null);
|
||||
setSetterName(null);
|
||||
setSetterSignature(null);
|
||||
}//setRowTypeName()//
|
||||
/**
|
||||
* Gets the optional name of the attribute.
|
||||
* @return The name of the attribute, or null if a getter and/or setter and events will be non-null.
|
||||
*/
|
||||
public String getAttributeName() {
|
||||
return (String) getAttributeValue(ATTRIBUTE_NAME);
|
||||
}//getAttributeName()//
|
||||
/**
|
||||
* Sets the optional name of the attribute.
|
||||
* @param attributeName The name of the attribute, or null if a getter and/or setter and events will be non-null.
|
||||
*/
|
||||
public void setAttributeName(String attributeName) {
|
||||
setAttributeValue(ATTRIBUTE_NAME, attributeName);
|
||||
}//setAttributeName()//
|
||||
/**
|
||||
* Gets the getter optional method name.
|
||||
* @return The name of the getter method used to access the value.
|
||||
*/
|
||||
public String getGetterName() {
|
||||
return (String) getAttributeValue(GETTER_NAME);
|
||||
}//getGetterName()//
|
||||
/**
|
||||
* Sets the optional getter method name.
|
||||
* @param getterName The name of the getter method used to access the value.
|
||||
*/
|
||||
public void setGetterName(String getterName) {
|
||||
setAttributeValue(GETTER_NAME, getterName);
|
||||
}//setGetterName()//
|
||||
/**
|
||||
* Gets the getter method's signature in class file format.
|
||||
* @return The signature that unqiuely identifies the getter method.
|
||||
*/
|
||||
public String getGetterSignature() {
|
||||
return (String) getAttributeValue(GETTER_SIGNATURE);
|
||||
}//getGetterSignature()//
|
||||
/**
|
||||
* Sets the getter method's signature in class file format.
|
||||
* @param getterSignature The signature that unqiuely identifies the getter method.
|
||||
*/
|
||||
public void setGetterSignature(String getterSignature) {
|
||||
setAttributeValue(GETTER_SIGNATURE, getterSignature);
|
||||
}//setGetterSignature()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationPart#getGetterResultType(com.foundation.view.builder.IClassMetadataLoader)
|
||||
*/
|
||||
public String getGetterResultType(IClassMetadataLoader applicationClassMetadataLoader) {
|
||||
String result = null;
|
||||
|
||||
if(getterResultType != null) {
|
||||
result = getterResultType;
|
||||
}//if//
|
||||
else {
|
||||
if(getValueHolderName() != null) {
|
||||
if(getHeldTypeName() != null) {
|
||||
try {
|
||||
result = applicationClassMetadataLoader.getMethodReturnType(getHeldTypeName(), getGetterName(), getGetterSignature(), getFeedbackStack(), getDocumentElement());
|
||||
}//try//
|
||||
catch(ClassNotFoundException e) {
|
||||
getFeedbackStack().add(new Message(true, "Invalid class name: " + getHeldTypeName(), getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//catch//
|
||||
}//if//
|
||||
else {
|
||||
try {
|
||||
result = applicationClassMetadataLoader.getMethodReturnType(getValueHolderType(getValueHolderName()), getGetterName(), getGetterSignature(), getFeedbackStack(), getDocumentElement());
|
||||
}//try//
|
||||
catch(ClassNotFoundException e) {
|
||||
getFeedbackStack().add(new Message(true, "Invalid class name: " + getValueHolderType(getValueHolderName()), getValueHolder(getValueHolderName()).getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//catch//
|
||||
}//else//
|
||||
}//if//
|
||||
else if(getRowTypeName() != null) {
|
||||
try {
|
||||
result = applicationClassMetadataLoader.getMethodReturnType(getRowTypeName(), getGetterName(), getGetterSignature(), getFeedbackStack(), getDocumentElement());
|
||||
}//try//
|
||||
catch(ClassNotFoundException e) {
|
||||
getFeedbackStack().add(new Message(true, "Invalid class name: " + getRowTypeName(), getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//catch//
|
||||
}//else if//
|
||||
else {
|
||||
getFeedbackStack().add(new Message(true, "Error: The attribute must either specify a value-holder or value-type.", getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//else//
|
||||
|
||||
//Cache the result for efficiency.//
|
||||
getterResultType = result;
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//getGetterResultType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationPart#getGetterSignatureTypeNames()
|
||||
*/
|
||||
public String[] getGetterSignatureTypeNames() {
|
||||
return BuilderSupport.getMethodParameterTypes(getGetterSignature(), getFeedbackStack(), getDocumentElement());
|
||||
}//getGetterSignatureTypeNames()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationPart#getSetterSignatureTypeNames()
|
||||
*/
|
||||
public String[] getSetterSignatureTypeNames() {
|
||||
return BuilderSupport.getMethodParameterTypes(getSetterSignature(), getFeedbackStack(), getDocumentElement());
|
||||
}//getSetterSignatureTypeNames()//
|
||||
/**
|
||||
* Gets the optional setter method name.
|
||||
* @return The name of the setter method used to set the value.
|
||||
*/
|
||||
public String getSetterName() {
|
||||
return (String) getAttributeValue(SETTER_NAME);
|
||||
}//getSetterName()//
|
||||
/**
|
||||
* Sets the optional setter method name.
|
||||
* @param setterMethodName The name of the setter method used to set the value.
|
||||
*/
|
||||
public void setSetterName(String setterName) {
|
||||
setAttributeValue(SETTER_NAME, setterName);
|
||||
}//setSetterName()//
|
||||
/**
|
||||
* Gets the setter method's signature in class file format.
|
||||
* @return The signature that unqiuely identifies the setter method.
|
||||
*/
|
||||
public String getSetterSignature() {
|
||||
return (String) getAttributeValue(SETTER_SIGNATURE);
|
||||
}//getSetterSignature()//
|
||||
/**
|
||||
* Sets the setter method's signature in class file format.
|
||||
* @param setterSignature The signature that unqiuely identifies the setter method.
|
||||
*/
|
||||
public void setSetterSignature(String setterSignature) {
|
||||
setAttributeValue(SETTER_SIGNATURE, setterSignature);
|
||||
}//setSetterSignature()//
|
||||
/**
|
||||
* Gets the event associations for this association.
|
||||
* @return The EventAssociation instances for this association.
|
||||
*/
|
||||
public IManagedList getEvents() {
|
||||
return (IManagedList) getAttributeValue(EVENTS);
|
||||
}//getEvents()//
|
||||
/**
|
||||
* Sets the association value changed events.
|
||||
* @param events The EventAssociation instances for this association.
|
||||
*/
|
||||
private void setEvents(IManagedList events) {
|
||||
setAttributeValue(EVENTS, events);
|
||||
}//setEvents()//
|
||||
/**
|
||||
* Gets the child association for this association chain.
|
||||
* @return The next association in the chain.
|
||||
*/
|
||||
public IAssociationPart getChildAssociation() {
|
||||
return (IAssociationPart) getAttributeValue(CHILD_ASSOCIATION);
|
||||
}//getEventName()//
|
||||
/**
|
||||
* Sets the child association for this association chain.
|
||||
* @param childAssociation The next association in the chain.
|
||||
*/
|
||||
public void setChildAssociation(IAssociationPart childAssociation) {
|
||||
setAttributeValue(CHILD_ASSOCIATION, childAssociation);
|
||||
}//setChildAssociation()//
|
||||
/**
|
||||
* Gets whether the association should invert the boolean result.
|
||||
* <p>This is only allowed (it is optional) for associations which have a type of java.lang.Boolean.</p>
|
||||
* @return Whether the boolean result should be inverted.
|
||||
*/
|
||||
public Boolean getInvertLogic() {
|
||||
return (Boolean) getAttributeValue(INVERT_LOGIC);
|
||||
}//getInvertLogic()//
|
||||
/**
|
||||
* Sets whether the association should invert the boolean result.
|
||||
* <p>This is only allowed (it is optional) for associations which have a type of java.lang.Boolean.</p>
|
||||
* @param invertLogic Whether the boolean result should be inverted.
|
||||
*/
|
||||
public void setInvertLogic(Boolean invertLogic) {
|
||||
setAttributeValue(INVERT_LOGIC, invertLogic);
|
||||
}//setInvertLogic()//
|
||||
/**
|
||||
* Gets the optional name of the method called, passing the data and returning the converted data, prior to using the data in the control.
|
||||
* @return The conversion method name called before refreshing the control.
|
||||
*/
|
||||
public String getConvertToControlName() {
|
||||
return (String) getAttributeValue(CONVERT_TO_CONTROL_NAME);
|
||||
}//getConvertToControlName()//
|
||||
/**
|
||||
* Sets the optional name of the method called, passing the data and returning the converted data, prior to using the data in the control.
|
||||
* @param convertToControlName The conversion method name called before refreshing the control.
|
||||
*/
|
||||
public void setConvertToControlName(String convertToControlName) {
|
||||
setAttributeValue(CONVERT_TO_CONTROL_NAME, convertToControlName);
|
||||
}//setConvertToControlName()//
|
||||
/**
|
||||
* Gets the signature of the method called, passing the data and returning the converted data, prior to using the data in the control.
|
||||
* <p>This is required if the name is set.</p>
|
||||
* @return The conversion method signature called before refreshing the control.
|
||||
*/
|
||||
public String getConvertToControlSignature() {
|
||||
return (String) getAttributeValue(CONVERT_TO_CONTROL_SIGNATURE);
|
||||
}//getConvertToControlSignature()//
|
||||
/**
|
||||
* Sets the signature of the method called, passing the data and returning the converted data, prior to using the data in the control.
|
||||
* <p>This is required if the name is set.</p>
|
||||
* @param convertToControlSignature The conversion method signature called before refreshing the control.
|
||||
*/
|
||||
public void setConvertToControlSignature(String convertToControlSignature) {
|
||||
setAttributeValue(CONVERT_TO_CONTROL_SIGNATURE, convertToControlSignature);
|
||||
}//setConvertToControlSignature()//
|
||||
/**
|
||||
* Gets the optional name of the method called, passing the data and returning the converted data, prior to placing the data in the model.
|
||||
* @return The conversion method name called before synchronizing the control.
|
||||
*/
|
||||
public String getConvertFromControlName() {
|
||||
return (String) getAttributeValue(CONVERT_FROM_CONTROL_NAME);
|
||||
}//getConvertFromControlName()//
|
||||
/**
|
||||
* Sets the optional name of the method called, passing the data and returning the converted data, prior to placing the data in the model.
|
||||
* @param convertFromControlName The conversion method name called before synchronizing the control.
|
||||
*/
|
||||
public void setConvertFromControlName(String convertFromControlName) {
|
||||
setAttributeValue(CONVERT_FROM_CONTROL_NAME, convertFromControlName);
|
||||
}//setConvertFromControlName()//
|
||||
/**
|
||||
* Gets the signature of the method called, passing the data and returning the converted data, prior to placing the data in the model.
|
||||
* <p>This is required if the name is set.</p>
|
||||
* @return The conversion method signature called before synchronizing the control.
|
||||
*/
|
||||
public String getConvertFromControlSignature() {
|
||||
return (String) getAttributeValue(CONVERT_FROM_CONTROL_SIGNATURE);
|
||||
}//getConvertFromControlSignature()//
|
||||
/**
|
||||
* Sets the signature of the method called, passing the data and returning the converted data, prior to placing the data in the model.
|
||||
* <p>This is required if the name is set.</p>
|
||||
* @param convertFromControlSignature The conversion method signature called before synchronizing the control.
|
||||
*/
|
||||
public void setConvertFromControlSignature(String convertFromControlSignature) {
|
||||
setAttributeValue(CONVERT_FROM_CONTROL_SIGNATURE, convertFromControlSignature);
|
||||
}//setConvertFromControlSignature()//
|
||||
/**
|
||||
* Gets the name of the value holder associated with the conversion methods defined by the part.
|
||||
* <p>This is required for associations that specify a TO or FROM conversion.</p>
|
||||
* @return The the name of the value holder which can be null for multi-associations.
|
||||
*/
|
||||
public String getConvertValueHolderName() {
|
||||
return (String) getAttributeValue(CONVERT_VALUE_HOLDER_NAME);
|
||||
}//getConvertValueHolderName()//
|
||||
/**
|
||||
* Sets the name of the value holder used by the part to convert data during a refresh or synchronize.
|
||||
* <p><b>Warning: This method will clear the conversion to/from data.</b></p>
|
||||
* @param convertValueHolderName The the name of the value holder which may only be null if no conversion method names and signatures are provided.
|
||||
*/
|
||||
public void setConvertValueHolderName(String convertValueHolderName) {
|
||||
if(!Comparator.equals(convertValueHolderName, getConvertValueHolderName())) {
|
||||
setAttributeValue(CONVERT_VALUE_HOLDER_NAME, convertValueHolderName);
|
||||
//Clear the conversion data since it will require new information.//
|
||||
setConvertToControlName(null);
|
||||
setConvertToControlSignature(null);
|
||||
setConvertFromControlName(null);
|
||||
setConvertFromControlSignature(null);
|
||||
}//if//
|
||||
}//setConvertValueHolderName()//
|
||||
}//AssociationPart//
|
||||
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* Copyright (c) 2005,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.INode;
|
||||
import com.foundation.view.builder.ViewBuilderException;
|
||||
|
||||
/*
|
||||
* Defines the metadata for an association used by the vml.
|
||||
*/
|
||||
public class AssociationPartType extends AbstractModel implements IAssociationPartType {
|
||||
public static final Attribute FUNCTION = registerAttribute(AssociationPartType.class, "function");
|
||||
public static final Attribute ASSOCIATION_TYPE = registerAttribute(AssociationPartType.class, "associationType");
|
||||
public static final Attribute UNIQUE_ROW_TYPE = registerAttribute(AssociationPartType.class, "uniqueRowType");
|
||||
public static final Attribute GETTER = registerAttribute(AssociationPartType.class, "getter");
|
||||
public static final Attribute SETTER = registerAttribute(AssociationPartType.class, "setter");
|
||||
public static final Attribute DATA_TYPE = registerAttribute(AssociationPartType.class, "dataType");
|
||||
/**
|
||||
* AssociationPartType constructor.
|
||||
*/
|
||||
public AssociationPartType() {
|
||||
super();
|
||||
}//AssociationPartType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationPartType#getFunction()
|
||||
*/
|
||||
public String getFunction() {
|
||||
return (String) getAttributeValue(FUNCTION);
|
||||
}//getFunction()//
|
||||
/**
|
||||
* Sets the function of the association.
|
||||
* @param function The function determines which part of the component uses it.
|
||||
*/
|
||||
public void setFunction(String function) {
|
||||
setAttributeValue(FUNCTION, function);
|
||||
}//setFunction()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationPartType#getAssociationType()
|
||||
*/
|
||||
public Integer getAssociationType() {
|
||||
return (Integer) getAttributeValue(ASSOCIATION_TYPE);
|
||||
}//getAssociationType()//
|
||||
/**
|
||||
* Sets the type of association.
|
||||
* @param associationType The type code for the association defining whether it is a single association meaning one value in and one out, multi meaning N values in and N values out, or variable meaning it could be either single or multi.
|
||||
*/
|
||||
public void setAssociationType(Integer associationType) {
|
||||
setAttributeValue(ASSOCIATION_TYPE, associationType);
|
||||
}//setAssociationType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationPartType#isAssociationTypeSingle()
|
||||
*/
|
||||
public boolean isAssociationTypeSingle() {
|
||||
return getAssociationType() != null && getAssociationType().intValue() == ASSOCIATION_TYPE_SINGLE;
|
||||
}//isAssociationTypeSingle()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationPartType#isAssociationTypeMulti()
|
||||
*/
|
||||
public boolean isAssociationTypeMulti() {
|
||||
return getAssociationType() != null && getAssociationType().intValue() == ASSOCIATION_TYPE_MULTI;
|
||||
}//isAssociationTypeMulti()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationPartType#isAssociationTypeVariable()
|
||||
*/
|
||||
public boolean isAssociationTypeVariable() {
|
||||
return getAssociationType() != null && getAssociationType().intValue() == ASSOCIATION_TYPE_VARIABLE;
|
||||
}//isAssociationTypeVariable()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationPartType#isAssociationTypeCollectingMulti()
|
||||
*/
|
||||
public boolean isAssociationTypeCollectingMulti() {
|
||||
return getAssociationType() != null && getAssociationType().intValue() == ASSOCIATION_TYPE_COLLECTIONG_MULTI;
|
||||
}//isAssociationTypeCollectingMulti()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationPartType#getUniqueRowType()
|
||||
*/
|
||||
public Boolean getUniqueRowType() {
|
||||
return (Boolean) getAttributeValue(UNIQUE_ROW_TYPE);
|
||||
}//getUniqueRowType()//
|
||||
/**
|
||||
* Sets whether the association must not duplicate the row type in another association with the same function and in the same component.
|
||||
* @param uniqueRowType Whether associations of this type in the same component must have unique row types.
|
||||
*/
|
||||
public void setUniqueRowType(Boolean uniqueRowType) {
|
||||
setAttributeValue(UNIQUE_ROW_TYPE, uniqueRowType);
|
||||
}//setUniqueRowType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationPartType#getGetter()
|
||||
*/
|
||||
public String getGetter() {
|
||||
return (String) getAttributeValue(GETTER);
|
||||
}//getGetter()//
|
||||
/**
|
||||
* Sets whether a getter method is required, optional, or unnecessary for the association.
|
||||
* @param getter One of [OPTION_REQUIRED, OPTION_OPTIONAL, OPTION_NONE] indicating whether the view must specify a getter method.
|
||||
*/
|
||||
public void setGetter(String getter) {
|
||||
setAttributeValue(GETTER, getter);
|
||||
}//setGetter()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationPartType#getSetter()
|
||||
*/
|
||||
public String getSetter() {
|
||||
return (String) getAttributeValue(SETTER);
|
||||
}//getSetter()//
|
||||
/**
|
||||
* Sets whether a setter method is required, optional, or unnecessary for the association.
|
||||
* @param setter One of [OPTION_REQUIRED, OPTION_OPTIONAL, OPTION_NONE] indicating whether the view must specify a setter method.
|
||||
*/
|
||||
public void setSetter(String setter) {
|
||||
setAttributeValue(SETTER, setter);
|
||||
}//setSetter()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationPartType#getDataType()
|
||||
*/
|
||||
public String getDataType() {
|
||||
return (String) getAttributeValue(DATA_TYPE);
|
||||
}//getDataType()//
|
||||
/**
|
||||
* Sets the class that the association must return instances of.
|
||||
* @param dataType The name of the class that the attribute of getter and setter must return or take as a parameter.
|
||||
*/
|
||||
public void setDataType(String dataType) {
|
||||
setAttributeValue(DATA_TYPE, dataType);
|
||||
}//setDataType()//
|
||||
/**
|
||||
* Reads the model from the XML node.
|
||||
* @param node The node containing model data.
|
||||
*/
|
||||
public void readXml(INode node) {
|
||||
String associationType = node.getAttributeValue(ATTRIBUTE_ASSOCIATION_TYPE, true, true);
|
||||
Integer associationTypeCode = null;
|
||||
|
||||
if((associationType == null) || (associationType.equalsIgnoreCase("single"))) {
|
||||
associationTypeCode = new Integer(ASSOCIATION_TYPE_SINGLE);
|
||||
}//if//
|
||||
else if(associationType.equalsIgnoreCase("multi")) {
|
||||
associationTypeCode = new Integer(ASSOCIATION_TYPE_MULTI);
|
||||
}//else if//
|
||||
else if(associationType.equalsIgnoreCase("variable")) {
|
||||
associationTypeCode = new Integer(ASSOCIATION_TYPE_VARIABLE);
|
||||
}//else if//
|
||||
else if(associationType.equalsIgnoreCase("collecting")) {
|
||||
associationTypeCode = new Integer(ASSOCIATION_TYPE_COLLECTIONG_MULTI);
|
||||
}//else if//
|
||||
else {
|
||||
throw new ViewBuilderException("Error: Invalid association-type value: '" + associationType + "'.", 1, -1, -1);
|
||||
}//else//
|
||||
|
||||
setFunction(node.getAttributeValue(ATTRIBUTE_FUNCTION, true, true));
|
||||
setAssociationType(associationTypeCode);
|
||||
setUniqueRowType(readBoolean(node.getAttributeValue(ATTRIBUTE_UNIQUE_ROW_TYPE, true, true), Boolean.TRUE));
|
||||
setGetter(readRequiredType(node.getAttributeValue(ATTRIBUTE_GETTER, true, true), OPTION_OPTIONAL));
|
||||
setSetter(readRequiredType(node.getAttributeValue(ATTRIBUTE_SETTER, true, true), OPTION_OPTIONAL));
|
||||
setDataType(node.getAttributeValue(ATTRIBUTE_DATA_TYPE, true, true));
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the model to the XML node.
|
||||
* @param node The node that will receive the model data.
|
||||
*/
|
||||
public void writeXml(INode node) {
|
||||
}//writeXml()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return object != null && getClass().equals(object.getClass()) && (getFunction().equals(((IAssociationPartType) object).getFunction()));
|
||||
}//equals()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
public int hashCode() {
|
||||
return getFunction().hashCode();
|
||||
}//hashCode()//
|
||||
}//AssociationPartType//
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.view.builder.IClassMetadataLoader;
|
||||
|
||||
/**
|
||||
* Defines an association part that returns a result value for the association to the user control.
|
||||
* This association target part uses a fixed target value and has no listeners.
|
||||
*/
|
||||
public class AssociationValueTargetPart extends AssociationAbstractTargetPart implements IAssociationValueTargetPart {
|
||||
public static final Attribute VALUE = registerAttribute(AssociationValueTargetPart.class, "value");
|
||||
public static final Attribute IS_CODE = registerAttribute(AssociationValueTargetPart.class, "isCode", Boolean.FALSE);
|
||||
/**
|
||||
* AssociationValueTargetPart constructor.
|
||||
* <p><b>Warning: Only public for the purpose of creating reflections.</b></p>
|
||||
*/
|
||||
public AssociationValueTargetPart() {
|
||||
}//AssociationValueTargetPart()//
|
||||
/**
|
||||
* AssociationValueTargetPart constructor.
|
||||
* @param value The value for the association.
|
||||
* @param isCode Whether the value is source code that will resolve to a value at runtime.
|
||||
* @param parent The parent for the association target part.
|
||||
* @param component The component referencing the attribute.
|
||||
* @param documentElement The optional element of the document that defines this association. This is used for debugging.
|
||||
*/
|
||||
public AssociationValueTargetPart(String value, boolean isCode, IAssociationAbstractNodePart parent, IComponentData component, IElement documentElement) {
|
||||
super(parent, component, documentElement);
|
||||
setValue(value);
|
||||
setIsCode(isCode ? Boolean.TRUE : Boolean.FALSE);
|
||||
}//AssociationValueTargetPart()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationAbstractTargetPart#getOriginalValueGetterName()
|
||||
*/
|
||||
public String getOriginalValueGetterName() {
|
||||
//A getter cannot be set of the original value when using an attribute association. The code will call the IEntity.getOldAttributeValue(Attribute) method instead.//
|
||||
return null;
|
||||
}//getOriginalValueGetterName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationAbstractTargetPart#getOriginalValueGetterSignature()
|
||||
*/
|
||||
public String getOriginalValueGetterSignature() {
|
||||
//A getter cannot be set of the original value when using an attribute association. The code will call the IEntity.getOldAttributeValue(Attribute) method instead.//
|
||||
return null;
|
||||
}//getOriginalValueGetterSignature()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.AssociationAbstractTargetPart#getDefaultRowTypeName()
|
||||
*/
|
||||
public String getDefaultRowTypeName() {
|
||||
String result = null;
|
||||
|
||||
if(getValueHolderName() != null) {
|
||||
result = getValueHolderTypeName(getComponent(), getValueHolderName());
|
||||
}//if//
|
||||
else if(getParent() instanceof AssociationGroupPart) {
|
||||
result = getValueHolderTypeName(getComponent(), ((AssociationGroupPart) getParent()).getValueHolderName());
|
||||
}//else if//
|
||||
|
||||
return result;
|
||||
}//getDefaultRowTypeName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationValueTargetPart#getValue()
|
||||
*/
|
||||
public String getValue() {
|
||||
return (String) getAttributeValue(VALUE);
|
||||
}//getValue()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationValueTargetPart#setValue(java.lang.String)
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
setAttributeValue(VALUE, value);
|
||||
}//setValue()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationValueTargetPart#getIsCode()
|
||||
*/
|
||||
public Boolean getIsCode() {
|
||||
return (Boolean) getAttributeValue(IS_CODE);
|
||||
}//getIsCode()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAssociationValueTargetPart#setIsCode(java.lang.Boolean)
|
||||
*/
|
||||
public void setIsCode(Boolean isCode) {
|
||||
setAttributeValue(IS_CODE, isCode);
|
||||
}//setIsCode()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.AssociationAbstractTargetPart#getGetterName()
|
||||
*/
|
||||
public String getGetterName() {
|
||||
return null;
|
||||
}//getGetterName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.AssociationAbstractTargetPart#getSetterName()
|
||||
*/
|
||||
public String getSetterName() {
|
||||
return null;
|
||||
}//getSetterName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.AssociationAbstractTargetPart#getGetterSignature()
|
||||
*/
|
||||
public String getGetterSignature() {
|
||||
return null;
|
||||
}//getGetterSignature()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.AssociationAbstractTargetPart#getSetterSignature()
|
||||
*/
|
||||
public String getSetterSignature() {
|
||||
return null;
|
||||
}//getSetterSignature()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.AssociationAbstractTargetPart#getSetterSignatureTypeNames()
|
||||
*/
|
||||
public String[] getSetterSignatureTypeNames() {
|
||||
return null;
|
||||
}//getSetterSignatureTypeNames()//
|
||||
}//AssociationValueTargetPart//
|
||||
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright (c) 2004,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.view.builder.BuildFailedException;
|
||||
import com.foundation.view.builder.IClassMetadataLoader;
|
||||
|
||||
public class AttributePart extends ReferencePart implements IAttributePart {
|
||||
public static final Attribute TYPE = registerAttribute(AttributePart.class, "type");
|
||||
|
||||
/** A cached result type for the getter method. This is cached since it is a bit time intensive to find it. */
|
||||
private String getterResultType = null;
|
||||
/**
|
||||
* AttributePart constructor.
|
||||
* <p><b>Warning: Only public for the purpose of creating reflections.</b></p>
|
||||
*/
|
||||
public AttributePart() {
|
||||
}//AttributePart()//
|
||||
/**
|
||||
* AttributePart constructor.
|
||||
* @param type The type definition for the attribute.
|
||||
* @param component The component referencing the attribute.
|
||||
* @param documentElement The optional element of the document that defines this part. This is used for debugging.
|
||||
*/
|
||||
public AttributePart(IAttributePartType type, IComponentData component, IElement documentElement) {
|
||||
this(type, component, null, null, null, documentElement);
|
||||
}//AttributePart()//
|
||||
/**
|
||||
* AttributePart constructor.
|
||||
* @param type The type definition for the attribute.
|
||||
* @param component The component referencing the attribute.
|
||||
* @param name The name of the attribute.
|
||||
* @param valueHolderName The name of the value holder associated with the part.
|
||||
* @param valueTypeName The qualified class name for the value holder held object subclass which defines the referenced part.
|
||||
* @param documentElement The optional element of the document that defines this part. This is used for debugging.
|
||||
*/
|
||||
public AttributePart(IAttributePartType type, IComponentData component, String name, String valueHolderName, String valueTypeName, IElement documentElement) {
|
||||
super(component, name, valueHolderName, valueTypeName, null, documentElement);
|
||||
setType(type);
|
||||
}//AttributePart()//
|
||||
/**
|
||||
* AttributePart constructor.
|
||||
* @param type The type definition for the attribute.
|
||||
* @param component The component referencing the attribute.
|
||||
* @param name The name of the attribute.
|
||||
* @param rowTypeName The qualified class name for the row or data object class which defines the referenced part.
|
||||
* @param documentElement The optional element of the document that defines this part. This is used for debugging.
|
||||
*/
|
||||
public AttributePart(IAttributePartType type, IComponentData component, String name, String rowTypeName, IElement documentElement) {
|
||||
super(component, name, null, null, rowTypeName, documentElement);
|
||||
setType(type);
|
||||
}//AttributePart()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAttributePart#getAttributeType(com.foundation.view.builder.IClassMetadataLoader)
|
||||
*/
|
||||
public String getAttributeType(IClassMetadataLoader applicationClassMetadataLoader) {
|
||||
String result = null;
|
||||
|
||||
if(getterResultType != null) {
|
||||
result = getterResultType;
|
||||
}//if//
|
||||
else {
|
||||
if(getValueHolderName() != null) {
|
||||
if(getHeldTypeName() != null) {
|
||||
try {
|
||||
result = applicationClassMetadataLoader.getMethodReturnType(getHeldTypeName(), getGetMethodName(), null, getFeedbackStack(), getDocumentElement());
|
||||
}//try//
|
||||
catch(ClassNotFoundException e) {
|
||||
getFeedbackStack().add(new Message(true, "Invalid class name: " + getHeldTypeName(), getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//catch//
|
||||
}//if//
|
||||
else {
|
||||
try {
|
||||
result = applicationClassMetadataLoader.getMethodReturnType(getValueHolderType(getValueHolderName()), getGetMethodName(), null, getFeedbackStack(), getDocumentElement());
|
||||
}//try//
|
||||
catch(ClassNotFoundException e) {
|
||||
getFeedbackStack().add(new Message(true, "Invalid class name: " + getValueHolderType(getValueHolderName()), getValueHolder(getValueHolderName()).getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//catch//
|
||||
}//else//
|
||||
}//if//
|
||||
else if(getRowTypeName() != null) {
|
||||
try {
|
||||
result = applicationClassMetadataLoader.getMethodReturnType(getRowTypeName(), getGetMethodName(), null, getFeedbackStack(), getDocumentElement());
|
||||
}//try//
|
||||
catch(ClassNotFoundException e) {
|
||||
getFeedbackStack().add(new Message(true, "Invalid class name: " + getRowTypeName(), getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//catch//
|
||||
}//else if//
|
||||
else {
|
||||
getFeedbackStack().add(new Message(true, "Error: The attribute must either specify a value-holder or value-type.", getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//else//
|
||||
|
||||
//Cache the result for efficiency.//
|
||||
getterResultType = result;
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//getAttributeType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAttributePart#getGetMethodName()
|
||||
*/
|
||||
public String getGetMethodName() {
|
||||
String methodName = null;
|
||||
|
||||
if(methodName == null) {
|
||||
String attributeName = getName();
|
||||
|
||||
methodName = "get" + Character.toUpperCase(attributeName.charAt(0)) + attributeName.substring(1);
|
||||
}//if//
|
||||
|
||||
return methodName;
|
||||
}//getGetMethodName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAttributePart#getSetMethodName()
|
||||
*/
|
||||
public String getSetMethodName() {
|
||||
String methodName = null;
|
||||
|
||||
if(methodName == null) {
|
||||
String attributeName = getName();
|
||||
|
||||
methodName = "set" + Character.toUpperCase(attributeName.charAt(0)) + attributeName.substring(1);
|
||||
}//if//
|
||||
|
||||
return methodName;
|
||||
}//getSetMethodName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAttributePart#getSetMethodParemeterType(java.lang.String)
|
||||
*/
|
||||
public String getSetMethodParemeterType(String defaultType) {
|
||||
return defaultType;
|
||||
}//getSetMethodParemeterType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IAttributePart#getType()
|
||||
*/
|
||||
public IAttributePartType getType() {
|
||||
return (IAttributePartType) getAttributeValue(TYPE);
|
||||
}//getType()//
|
||||
/**
|
||||
* Sets the AttributePartType that defines how this attribute part should look.
|
||||
* @param type The definition for this attribute part (similar to how a class works for an instance).
|
||||
*/
|
||||
private void setType(IAttributePartType type) {
|
||||
setAttributeValue(TYPE, type);
|
||||
}//setType()//
|
||||
}//AttributePart//
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2004,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.util.xml.INode;
|
||||
|
||||
public class AttributePartType extends ReferencePartType implements IAttributePartType {
|
||||
public static final String NODE_NAME = "attribute";
|
||||
/**
|
||||
* AttributePartType constructor.
|
||||
*/
|
||||
public AttributePartType() {
|
||||
super();
|
||||
}//AttributePartType()//
|
||||
/**
|
||||
* Reads the model from the XML node.
|
||||
* @param node The node containing model data.
|
||||
*/
|
||||
public void readXml(INode node) {
|
||||
super.readXml(node);
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the model to the XML node.
|
||||
* @param node The node that will receive the model data.
|
||||
*/
|
||||
public void writeXml(INode node) {
|
||||
super.writeXml(node);
|
||||
}//writeXml()//
|
||||
}//AttributePartType//
|
||||
@@ -0,0 +1,353 @@
|
||||
/*
|
||||
* Copyright (c) 2004,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.common.util.*;
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.IManagedList;
|
||||
import com.foundation.util.ManagedList;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.util.xml.INode;
|
||||
|
||||
public class BuilderDefinition extends AbstractModel implements IBuilderDefinition {
|
||||
private static final String ATTRIBUTE_JAR = "jar";
|
||||
private static final String ATTRIBUTE_CLASS = "class";
|
||||
private static final String NODE_THICK_SWT = "thick-swt";
|
||||
private static final String NODE_THIN_SWT = "thin-swt";
|
||||
|
||||
private static final String ARCHITECTURE_THIN = "thin";
|
||||
private static final String ARCHITECTURE_THICK = "thick";
|
||||
private static final String WINDOW_SYSTEM_SWT = "swt";
|
||||
private static final IPlatform PLATFORM_THICK_SWT = new Platform(ARCHITECTURE_THICK, WINDOW_SYSTEM_SWT, "com.foundation.view.swt.Component", "com.foundation.view.swt.Container");
|
||||
private static final IPlatform PLATFORM_THIN_SWT = new Platform(ARCHITECTURE_THIN, WINDOW_SYSTEM_SWT, "com.foundation.tcv.swt.server.Component", "com.foundation.tcv.swt.server.Container");
|
||||
|
||||
public static final Attribute CODE_LOCATION = registerAttribute(BuilderDefinition.class, "codeLocation");
|
||||
public static final Attribute PLATFORM_TYPE_MAP = registerAttribute(BuilderDefinition.class, "platformTypeMap");
|
||||
|
||||
//A list of all platform combinations supported by JEF.//
|
||||
private static final IList platformTypes = new LiteList(new Object[] {
|
||||
PLATFORM_THICK_SWT,
|
||||
PLATFORM_THIN_SWT
|
||||
});
|
||||
|
||||
static {
|
||||
platformTypes.isChangeable(false);
|
||||
}//static//
|
||||
|
||||
/**
|
||||
* Defines a platform to which the view can be built. Platforms are currently predefined by JEF.
|
||||
* TODO: The supported platforms should be specified in an XML file.
|
||||
*/
|
||||
public static class Platform extends AbstractModel implements IPlatform {
|
||||
public static final Attribute ARCHITECTURE_TYPE = registerAttribute(Platform.class, "architectureType");
|
||||
public static final Attribute WINDOW_SYSTEM = registerAttribute(Platform.class, "windowSystem");
|
||||
public static final Attribute COMPONENT_TYPE_NAME = registerAttribute(Platform.class, "componentTypeName");
|
||||
public static final Attribute CONTAINER_TYPE_NAME = registerAttribute(Platform.class, "containerTypeName");
|
||||
|
||||
/**
|
||||
* Platform constructor.
|
||||
* This constructor should only be used for looking up a platform. Platforms must specify a qualified component & container type name.
|
||||
* @param architectureType
|
||||
* @param windowSystem
|
||||
*/
|
||||
public Platform(String architectureType, String windowSystem) {
|
||||
setArchitectureType(architectureType);
|
||||
setWindowSystem(windowSystem);
|
||||
}//Platform()//
|
||||
/**
|
||||
* Platform constructor.
|
||||
* The component & container qualified class names are necessary to provide implementation independance.
|
||||
* @param architectureType
|
||||
* @param windowSystem
|
||||
* @param componentTypeName
|
||||
* @param containerTypeName
|
||||
*/
|
||||
public Platform(String architectureType, String windowSystem, String componentTypeName, String containerTypeName) {
|
||||
setArchitectureType(architectureType);
|
||||
setWindowSystem(windowSystem);
|
||||
setComponentTypeName(componentTypeName);
|
||||
setContainerTypeName(containerTypeName);
|
||||
}//Platform()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPlatform#getArchitectureType()
|
||||
*/
|
||||
public String getArchitectureType() {
|
||||
return (String) getAttributeValue(ARCHITECTURE_TYPE);
|
||||
}//getArchitectureType()//
|
||||
/**
|
||||
* Sets the architectureType value.
|
||||
* @param architectureType The architectureType value.
|
||||
*/
|
||||
private void setArchitectureType(String architectureType) {
|
||||
setAttributeValue(ARCHITECTURE_TYPE, architectureType);
|
||||
}//setArchitectureType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPlatform#getWindowSystem()
|
||||
*/
|
||||
public String getWindowSystem() {
|
||||
return (String) getAttributeValue(WINDOW_SYSTEM);
|
||||
}//getWindowSystem()//
|
||||
/**
|
||||
* Sets the windowSystem value.
|
||||
* @param windowSystem The windowSystem value.
|
||||
*/
|
||||
private void setWindowSystem(String windowSystem) {
|
||||
setAttributeValue(WINDOW_SYSTEM, windowSystem);
|
||||
}//setWindowSystem()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPlatform#getComponentTypeName()
|
||||
*/
|
||||
public String getComponentTypeName() {
|
||||
return (String) getAttributeValue(COMPONENT_TYPE_NAME);
|
||||
}//getComponentTypeName()//
|
||||
/**
|
||||
* Sets the componentTypeName value.
|
||||
* @param componentTypeName The componentTypeName value.
|
||||
*/
|
||||
private void setComponentTypeName(String componentTypeName) {
|
||||
setAttributeValue(COMPONENT_TYPE_NAME, componentTypeName);
|
||||
}//setComponentTypeName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPlatform#getContainerTypeName()
|
||||
*/
|
||||
public String getContainerTypeName() {
|
||||
return (String) getAttributeValue(CONTAINER_TYPE_NAME);
|
||||
}//getContainerTypeName()//
|
||||
/**
|
||||
* Sets the containerTypeName value.
|
||||
* @param containerTypeName The containerTypeName value.
|
||||
*/
|
||||
private void setContainerTypeName(String containerTypeName) {
|
||||
setAttributeValue(CONTAINER_TYPE_NAME, containerTypeName);
|
||||
}//setContainerTypeName()//
|
||||
/**
|
||||
* Gets the platform in a string that can be later read back in as a platform.
|
||||
*/
|
||||
public String toString() {
|
||||
return getArchitectureType() + ':' + getWindowSystem();
|
||||
}//toString()//
|
||||
/**
|
||||
* Gets the platform for the given string. The string must be in the form [arch]:[system]. For example thin:swt or thick:swing.
|
||||
* @param platformText The plaform text. The format should be the same as produced by the toString method.
|
||||
* @return One of the platform objects in the getPlatformTypes() list, or null if one could not be read from the string, or if the platform is not one of those predefined.
|
||||
*/
|
||||
public static IPlatform fromString(String platformText) {
|
||||
int index = platformText != null ? platformText.indexOf(':') : -1;
|
||||
|
||||
if(index >= 0) {
|
||||
index = getPlatformTypes().getIndexOf(new Platform(platformText.substring(0, index).trim(), platformText.substring(index + 1)));
|
||||
}//if//
|
||||
|
||||
return (IPlatform) (index >= 0 ? getPlatformTypes().get(index) : null);
|
||||
}//fromString()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
boolean result = false;
|
||||
|
||||
if(object instanceof Platform) {
|
||||
if((getArchitectureType() != null) && (getArchitectureType().equals(((IPlatform) object).getArchitectureType())) || (getArchitectureType() == null) && (((IPlatform) object).getArchitectureType() == null)) {
|
||||
if((getWindowSystem() != null) && (getWindowSystem().equals(((IPlatform) object).getWindowSystem())) || (getWindowSystem() == null) && (((IPlatform) object).getWindowSystem() == null)) {
|
||||
result = true;
|
||||
}//if//
|
||||
}//if//
|
||||
}//if//
|
||||
|
||||
return result;
|
||||
}//equals()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
public int hashCode() {
|
||||
return getArchitectureType().hashCode() ^ getWindowSystem().hashCode();
|
||||
}//hashCode()//
|
||||
}//Platform//
|
||||
|
||||
/**
|
||||
* Encapsulates all the metadata for reflections used by the view.
|
||||
*/
|
||||
public static class ReflectionMetadata extends AbstractModel implements IReflectionMetadata {
|
||||
public static final Attribute TYPE_METADATA = registerCollection(ReflectionMetadata.class, "typeMetadata", AO_LAZY);
|
||||
|
||||
/**
|
||||
* ReflectionMetadata constructor.
|
||||
*/
|
||||
public ReflectionMetadata() {
|
||||
super();
|
||||
}//ReflectionMetadata()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.common.Entity#lazyLoadAttribute(com.foundation.metadata.Attribute)
|
||||
*/
|
||||
protected Object lazyLoadAttribute(Attribute attribute) {
|
||||
Object result = null;
|
||||
|
||||
if(attribute == TYPE_METADATA) {
|
||||
result = new ManagedList(10, 20);
|
||||
}//if//
|
||||
else {
|
||||
result = super.lazyLoadAttribute(attribute);
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//lazyLoadAttribute()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IReflectionMetadata#getTypeMetadata()
|
||||
*/
|
||||
public IManagedList getTypeMetadata() {
|
||||
return (IManagedList) getAttributeValue(TYPE_METADATA);
|
||||
}//getTypeMetadata()//
|
||||
}//ReflectionMetadata//
|
||||
|
||||
/**
|
||||
* Encapsulates the type metadata for reflections used by the view.
|
||||
*/
|
||||
public static class TypeMetadata extends AbstractModel {
|
||||
public static final Attribute NAME = registerAttribute(TypeMetadata.class, "name");
|
||||
public static final Attribute IS_INCLUSIVE = registerAttribute(TypeMetadata.class, "isInclusive", Boolean.TRUE);
|
||||
public static final Attribute ATTRIBUTE_NAMES = registerCollection(TypeMetadata.class, "attributeNames", AO_LAZY);
|
||||
|
||||
/**
|
||||
* TypeMetadata constructor.
|
||||
* @param The qualified class name for the type.
|
||||
*/
|
||||
public TypeMetadata(String name) {
|
||||
super();
|
||||
}//TypeMetadata()//
|
||||
/**
|
||||
* TypeMetadata constructor.
|
||||
* @param The qualified class name for the type.
|
||||
* @param Whether the attribute list is inclusive instead of exclusive. This defaults to be inclusive.
|
||||
*/
|
||||
public TypeMetadata(String name, boolean isInclusive) {
|
||||
super();
|
||||
setAttributeValue(NAME, name);
|
||||
setAttributeValue(IS_INCLUSIVE, isInclusive ? Boolean.TRUE : Boolean.FALSE);
|
||||
}//TypeMetadata()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.common.Entity#lazyLoadAttribute(com.foundation.metadata.Attribute)
|
||||
*/
|
||||
protected Object lazyLoadAttribute(Attribute attribute) {
|
||||
Object result = null;
|
||||
|
||||
if(attribute == ATTRIBUTE_NAMES) {
|
||||
result = new ManagedList(10, 20);
|
||||
}//if//
|
||||
else {
|
||||
result = super.lazyLoadAttribute(attribute);
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//lazyLoadAttribute()//
|
||||
/**
|
||||
* Gets the qualified type name.
|
||||
* @return The type's qualified class name.
|
||||
*/
|
||||
public String getName() {
|
||||
return (String) getAttributeValue(NAME);
|
||||
}//getName()//
|
||||
/**
|
||||
* Gets whether the attribute names are inclusive versus exclusive.
|
||||
* @return Whether the attribute names should be reflected, otherwise the listed attributes will not be reflected and all other attributes will be.
|
||||
*/
|
||||
public Boolean getIsInclusive() {
|
||||
return (Boolean) getAttributeValue(IS_INCLUSIVE);
|
||||
}//getIsInclusive()//
|
||||
/**
|
||||
* Gets the attribute names either included or excluded for the type.
|
||||
* @return The type's attribute names.
|
||||
*/
|
||||
public IManagedList getAttributeNames() {
|
||||
return (IManagedList) getAttributeValue(ATTRIBUTE_NAMES);
|
||||
}//getAttributeNames()//
|
||||
}//ReflectionMetadata//
|
||||
/**
|
||||
* BuilderDefinition constructor.
|
||||
*/
|
||||
public BuilderDefinition() {
|
||||
super();
|
||||
|
||||
setPlatformTypeMap(new LiteHashMap(5));
|
||||
}//BuilderDefinition()//
|
||||
/**
|
||||
* Gets the collection of all supported platforms.
|
||||
* @return The target platforms supported by JEF.
|
||||
*/
|
||||
public static IList getPlatformTypes() {
|
||||
return platformTypes;
|
||||
}//getPlatformTypes()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IBuilderDefinition#getCodeLocation()
|
||||
*/
|
||||
public String getCodeLocation() {
|
||||
return (String) getAttributeValue(CODE_LOCATION);
|
||||
}//getCodeLocation()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IBuilderDefinition#setCodeLocation(java.lang.String)
|
||||
*/
|
||||
public void setCodeLocation(String codeLocation) {
|
||||
setAttributeValue(CODE_LOCATION, codeLocation);
|
||||
}//setCodeLocation()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IBuilderDefinition#getPlatformTypeMap()
|
||||
*/
|
||||
public IHashMap getPlatformTypeMap() {
|
||||
return (IHashMap) getAttributeValue(PLATFORM_TYPE_MAP);
|
||||
}//getPlatformTypeMap()//
|
||||
/**
|
||||
* Gets the collection of builder class names indexed by platform.
|
||||
* @param platformTypeMap The builder class name/platform mapping.
|
||||
*/
|
||||
private void setPlatformTypeMap(IHashMap platformTypeMap) {
|
||||
setAttributeValue(PLATFORM_TYPE_MAP, platformTypeMap);
|
||||
}//setPlatformTypeMap()//
|
||||
/**
|
||||
* Reads the model from the XML node.
|
||||
* @param node The node containing model data.
|
||||
*/
|
||||
public void readXml(INode node) {
|
||||
IIterator iterator = null;
|
||||
|
||||
setCodeLocation(node.getAttributeValue(ATTRIBUTE_JAR));
|
||||
|
||||
iterator = node.getElements().iterator();
|
||||
|
||||
while(iterator.hasNext()) {
|
||||
IElement next = (IElement) iterator.next();
|
||||
|
||||
if(next.isNode()) {
|
||||
INode subNode = (INode) next;
|
||||
String subNodeName = subNode.getName();
|
||||
|
||||
if(NODE_THIN_SWT.equals(subNodeName)) {
|
||||
String typeName = subNode.getAttributeValue(ATTRIBUTE_CLASS, true, true);
|
||||
|
||||
if(typeName != null) {
|
||||
getPlatformTypeMap().put(PLATFORM_THIN_SWT, typeName);
|
||||
}//if//
|
||||
}//if//
|
||||
else if(NODE_THICK_SWT.equals(subNodeName)) {
|
||||
String typeName = subNode.getAttributeValue(ATTRIBUTE_CLASS, true, true);
|
||||
|
||||
if(typeName != null) {
|
||||
getPlatformTypeMap().put(PLATFORM_THICK_SWT, typeName);
|
||||
}//if//
|
||||
}//else if//
|
||||
else {
|
||||
//Unexpected node type. Will ignore.//
|
||||
}//else//
|
||||
}//if//
|
||||
}//while//
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the model to the XML node.
|
||||
* @param node The node that will receive the model data.
|
||||
*/
|
||||
public void writeXml(INode node) {
|
||||
}//writeXml()//
|
||||
}//BuilderDefinition//
|
||||
1303
Vml Builder/src/com/foundation/view/definition/ComponentData.java
Normal file
1303
Vml Builder/src/com/foundation/view/definition/ComponentData.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2004,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.INode;
|
||||
|
||||
public class ComponentPartType extends AbstractModel implements IComponentPartType {
|
||||
private static final String ATTRIBUTE_TYPE = "type";
|
||||
private static final String ATTRIBUTE_REQUIRED = "required";
|
||||
private static final String ATTRIBUTE_MULTIPLE = "multiple";
|
||||
private static final String ATTRIBUTE_UNIQUE_PROPERTY = "unique-property";
|
||||
|
||||
public static final Attribute TYPE = registerAttribute(ComponentPartType.class, "type");
|
||||
public static final Attribute REQUIRED = registerAttribute(ComponentPartType.class, "required");
|
||||
public static final Attribute MULTIPLE = registerAttribute(ComponentPartType.class, "multiple");
|
||||
public static final Attribute UNIQUE_PROPERTY = registerAttribute(ComponentPartType.class, "uniqueProperty");
|
||||
/**
|
||||
* ComponentPartType constructor.
|
||||
*/
|
||||
public ComponentPartType() {
|
||||
super();
|
||||
}//ComponentPartType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentPartType#getType()
|
||||
*/
|
||||
public String getType() {
|
||||
return (String) getAttributeValue(TYPE);
|
||||
}//getType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentPartType#setType(java.lang.String)
|
||||
*/
|
||||
public void setType(String type) {
|
||||
setAttributeValue(TYPE, type);
|
||||
}//setType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentPartType#getRequired()
|
||||
*/
|
||||
public Boolean getRequired() {
|
||||
return (Boolean) getAttributeValue(REQUIRED);
|
||||
}//getRequired()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentPartType#setRequired(java.lang.Boolean)
|
||||
*/
|
||||
public void setRequired(Boolean required) {
|
||||
setAttributeValue(REQUIRED, required);
|
||||
}//setRequired()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentPartType#getMultiple()
|
||||
*/
|
||||
public Boolean getMultiple() {
|
||||
return (Boolean) getAttributeValue(MULTIPLE);
|
||||
}//getMultiple()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentPartType#setMultiple(java.lang.Boolean)
|
||||
*/
|
||||
public void setMultiple(Boolean multiple) {
|
||||
setAttributeValue(MULTIPLE, multiple);
|
||||
}//setMultiple()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentPartType#getUniqueProperty()
|
||||
*/
|
||||
public String getUniqueProperty() {
|
||||
return (String) getAttributeValue(UNIQUE_PROPERTY);
|
||||
}//getUniqueProperty()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentPartType#setUniqueProperty(java.lang.String)
|
||||
*/
|
||||
public void setUniqueProperty(String uniqueProperty) {
|
||||
setAttributeValue(UNIQUE_PROPERTY, uniqueProperty);
|
||||
}//setUniqueProperty()//
|
||||
/**
|
||||
* Reads the model from the XML node.
|
||||
* @param node The node containing model data.
|
||||
*/
|
||||
public void readXml(INode node) {
|
||||
setType(node.getAttributeValue(ATTRIBUTE_TYPE, true, true));
|
||||
setRequired(readBoolean(node.getAttributeValue(ATTRIBUTE_REQUIRED, true, true), Boolean.FALSE));
|
||||
setMultiple(readBoolean(node.getAttributeValue(ATTRIBUTE_MULTIPLE, true, true), Boolean.FALSE));
|
||||
setUniqueProperty(node.getAttributeValue(ATTRIBUTE_UNIQUE_PROPERTY, true, true));
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the model to the XML node.
|
||||
* @param node The node that will receive the model data.
|
||||
*/
|
||||
public void writeXml(INode node) {
|
||||
}//writeXml()//
|
||||
}//ComponentPartType//
|
||||
@@ -0,0 +1,766 @@
|
||||
/*
|
||||
* Copyright (c) 2004,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.common.comparison.Comparator;
|
||||
import com.common.util.*;
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.*;
|
||||
import com.foundation.util.xml.*;
|
||||
import com.foundation.view.builder.ViewBuilderException;
|
||||
|
||||
public class ComponentType extends AbstractModel implements IComponentType {
|
||||
private static final String NODE_BUILDER = "builder";
|
||||
private static final String ATTRIBUTE_NAME = "name";
|
||||
private static final String ATTRIBUTE_INHERIT_STYLES = "inherit-styles";
|
||||
private static final String ATTRIBUTE_EXTENDS = "extends";
|
||||
private static final String ATTRIBUTE_ASSOCIATED_TYPE = "associated-type";
|
||||
|
||||
private boolean isInitialized = false;
|
||||
|
||||
public static final Attribute NAME = registerAttribute(ComponentType.class, "name");
|
||||
public static final Attribute INHERIT_STYLES = registerAttribute(ComponentType.class, "inheritStyles");
|
||||
public static final Attribute STYLES = registerAttribute(ComponentType.class, "styles");
|
||||
public static final Attribute DECLARED_STYLES = registerAttribute(ComponentType.class, "declaredStyles");
|
||||
public static final Attribute STYLE_SETS = registerAttribute(ComponentType.class, "styleSets");
|
||||
public static final Attribute DECLARED_STYLE_SETS = registerAttribute(ComponentType.class, "declaredStyleSets");
|
||||
public static final Attribute BUILDER_DEFINITION = registerAttribute(ComponentType.class, "builderDefinition");
|
||||
public static final Attribute PROPERTY_TYPES = registerCollection(ComponentType.class, "propertyTypes", AO_REFERENCED | AO_LAZY);
|
||||
public static final Attribute ASSOCIATION_TYPES = registerCollection(ComponentType.class, "associationTypes", AO_REFERENCED | AO_LAZY);
|
||||
public static final Attribute ATTRIBUTES = registerCollection(ComponentType.class, "attributes", AO_REFERENCED | AO_LAZY);
|
||||
public static final Attribute METHODS = registerCollection(ComponentType.class, "methods", AO_REFERENCED | AO_LAZY);
|
||||
public static final Attribute EVENTS = registerCollection(ComponentType.class, "events", AO_REFERENCED | AO_LAZY);
|
||||
public static final Attribute LINKS = registerCollection(ComponentType.class, "links", AO_REFERENCED | AO_LAZY);
|
||||
public static final Attribute LINK_TARGETS = registerCollection(ComponentType.class, "linkTargets", AO_REFERENCED | AO_LAZY);
|
||||
public static final Attribute KEY = registerAttribute(ComponentType.class, "key");
|
||||
public static final Attribute COMPONENTS = registerCollection(ComponentType.class, "components", AO_REFERENCED | AO_LAZY);
|
||||
public static final Attribute DEFINED_COMPONENT_TYPES = registerCollection(ComponentType.class, "definedComponentTypes", AO_REFERENCED | AO_LAZY);
|
||||
public static final Attribute EXTENDED_TYPE_NAME = registerAttribute(ComponentType.class, "extendedTypeName");
|
||||
public static final Attribute EXTENDED_TYPE = registerAttribute(ComponentType.class, "extendedType");
|
||||
public static final Attribute ASSOCIATED_TYPE_NAME = registerAttribute(ComponentType.class, "associatedTypeName");
|
||||
public static final Attribute ASSOCIATED_TYPE = registerAttribute(ComponentType.class, "associatedType");
|
||||
public static final Attribute DEFINING_TYPE = registerAttribute(ComponentType.class, "definingType");
|
||||
public static final Attribute CHILD_TYPES = registerCollection(ComponentType.class, "childTypes", AO_REFERENCED | AO_LAZY);
|
||||
/**
|
||||
* ComponentType constructor.
|
||||
*/
|
||||
public ComponentType() {
|
||||
super();
|
||||
setDeclaredStyles(new LiteList(5, 10));
|
||||
setStyles(new LiteList(10, 20));
|
||||
setDeclaredStyleSets(new LiteList(5, 8));
|
||||
setStyleSets(new LiteList(3, 5));
|
||||
}//ComponentType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.common.Entity#lazyLoadAttribute(com.foundation.metadata.Attribute)
|
||||
*/
|
||||
protected Object lazyLoadAttribute(Attribute attribute) {
|
||||
Object result = null;
|
||||
|
||||
if(attribute == PROPERTY_TYPES) {
|
||||
result = new ManagedList(10, 20);
|
||||
}//if//
|
||||
else if(attribute == ASSOCIATION_TYPES) {
|
||||
result = new ManagedList(10, 20);
|
||||
}//else if//
|
||||
else if(attribute == ATTRIBUTES) {
|
||||
result = new ManagedList(10, 20);
|
||||
}//else if//
|
||||
else if(attribute == METHODS) {
|
||||
result = new ManagedList(10, 20);
|
||||
}//else if//
|
||||
else if(attribute == EVENTS) {
|
||||
result = new ManagedList(10, 20);
|
||||
}//else if//
|
||||
else if(attribute == LINKS) {
|
||||
result = new ManagedList(10, 20);
|
||||
}//else if//
|
||||
else if(attribute == LINK_TARGETS) {
|
||||
result = new ManagedList(10, 20);
|
||||
}//else if//
|
||||
else if(attribute == COMPONENTS) {
|
||||
result = new ManagedList(10, 20);
|
||||
}//else if//
|
||||
else if(attribute == DEFINED_COMPONENT_TYPES) {
|
||||
result = new ManagedList(10, 20);
|
||||
}//else if//
|
||||
else if(attribute == CHILD_TYPES) {
|
||||
result = new ManagedList(10, 20);
|
||||
}//else if//
|
||||
else {
|
||||
result = super.lazyLoadAttribute(attribute);
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//lazyLoadAttribute()//
|
||||
/**
|
||||
* Initializes the component type after being read.
|
||||
* @param componentTypeMap The mapping of all known component types by the unique type name.
|
||||
*/
|
||||
public void initialize(IHashMap componentTypeMap) throws TypeDefinitionException {
|
||||
if(!isInitialized) {
|
||||
isInitialized = true;
|
||||
|
||||
if(getExtendedTypeName() != null) {
|
||||
//Search the defining type first for the extended type.//
|
||||
if(getDefiningType() != null) {
|
||||
setExtendedType(getDefiningType().getDefinedComponentType(getExtendedTypeName()));
|
||||
}//if//
|
||||
|
||||
//Search the global type map for the extended type.//
|
||||
if(getExtendedType() == null) {
|
||||
setExtendedType((IComponentType) componentTypeMap.get(getExtendedTypeName()));
|
||||
}//if//
|
||||
|
||||
//Notify the user of the error.//
|
||||
if(getExtendedType() == null) {
|
||||
throw new com.foundation.view.builder.ViewBuilderException(new TypeDefinitionException("The component type '" + getName() + "' extends type '" + getExtendedTypeName() + "' which could not be found."), -1, -1, -1);
|
||||
}//if//
|
||||
else {
|
||||
getExtendedType().getChildTypes().add(this);
|
||||
}//else//
|
||||
}//if//
|
||||
|
||||
//This is optional for most types. It is currently only used by layout types.//
|
||||
if(getAssociatedTypeName() != null) {
|
||||
setAssociatedType((IComponentType) componentTypeMap.get(getAssociatedTypeName()));
|
||||
|
||||
if(getAssociatedType() == null) {
|
||||
throw new TypeDefinitionException("Associated type '" + getAssociatedTypeName() + "' not found.");
|
||||
}//if//
|
||||
}//if//
|
||||
|
||||
if(getExtendedType() != null) {
|
||||
//Make certain the extended type is initialized before adding up the styles.//
|
||||
((ComponentType) getExtendedType()).initialize(componentTypeMap);
|
||||
|
||||
//Inherit styles & style sets.//
|
||||
if(getInheritStyles().booleanValue()) {
|
||||
//Note: Styles & StyleSets are added to both the DeclaredStyles and DeclaredStyleSets as well as the Styles and StyleSets collections while the component type is being read.//
|
||||
getStyles().addAll(getExtendedType().getStyles());
|
||||
getStyleSets().addAll(getExtendedType().getStyleSets());
|
||||
}//if//
|
||||
}//if//
|
||||
|
||||
if(getDefinedComponentTypes().getSize() > 0) {
|
||||
IIterator iterator = getDefinedComponentTypes().iterator();
|
||||
|
||||
while(iterator.hasNext()) {
|
||||
ComponentType next = (ComponentType) iterator.next();
|
||||
|
||||
next.setDefiningType(this);
|
||||
next.initialize(componentTypeMap);
|
||||
}//while//
|
||||
}//if//
|
||||
}//if//
|
||||
}//initialize()//
|
||||
/**
|
||||
* Collects all type names for the base type and all child types.
|
||||
* @param baseType The base type from which to start the search.
|
||||
* @return The set of all type names.
|
||||
*/
|
||||
public IHashSet collectTypeNames() {
|
||||
IHashSet result = new LiteHashSet(10);
|
||||
|
||||
collectTypeNames(this, result);
|
||||
|
||||
return result;
|
||||
}//collectTypeNames()//
|
||||
/**
|
||||
* Collects all type names for the base type and all child types.
|
||||
* @param baseType The base type from which to start the search.
|
||||
* @return The set of all type names.
|
||||
*/
|
||||
private void collectTypeNames(ComponentType baseType, IHashSet typeNameSet) {
|
||||
IIterator iterator = baseType.getChildTypes().iterator();
|
||||
|
||||
typeNameSet.add(baseType.getName());
|
||||
|
||||
while(iterator.hasNext()) {
|
||||
collectTypeNames((ComponentType) iterator.next(), typeNameSet);
|
||||
}//while//
|
||||
}//collectTypeNames()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#extendsType(com.foundation.view.definition.IComponentType)
|
||||
*/
|
||||
public boolean extendsType(IComponentType type) {
|
||||
boolean result = false;
|
||||
IComponentType extendedType = getExtendedType();
|
||||
|
||||
while((!result) && (extendedType != null)) {
|
||||
if(extendedType.equals(type)) {
|
||||
result = true;
|
||||
}//if//
|
||||
else {
|
||||
extendedType = extendedType.getExtendedType();
|
||||
}//else//
|
||||
}//while//
|
||||
|
||||
return result;
|
||||
}//extendsType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return (String) getAttributeValue(NAME);
|
||||
}//getName()//
|
||||
/**
|
||||
* Sets the name value.
|
||||
* @param name The name value.
|
||||
*/
|
||||
private void setName(String name) {
|
||||
setAttributeValue(NAME, name);
|
||||
}//setName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getBuilderDefinition()
|
||||
*/
|
||||
public IBuilderDefinition getBuilderDefinition() {
|
||||
return (IBuilderDefinition) getAttributeValue(BUILDER_DEFINITION);
|
||||
}//getBuilderDefinition()//
|
||||
/**
|
||||
* Sets the builderDefinition value.
|
||||
* @param builderDefinition The builderDefinition value.
|
||||
*/
|
||||
private void setBuilderDefinition(IBuilderDefinition builderDefinition) {
|
||||
setAttributeValue(BUILDER_DEFINITION, builderDefinition);
|
||||
}//setBuilderDefinition()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getProperties()
|
||||
*/
|
||||
public IManagedList getProperties() {
|
||||
return (IManagedList) getAttributeValue(PROPERTY_TYPES);
|
||||
}//getProperties()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getProperty(java.lang.String)
|
||||
*/
|
||||
public IPropertyPartType getProperty(String name) {
|
||||
IPropertyPartType result = null;
|
||||
IIterator iterator = getProperties().iterator();
|
||||
|
||||
while((result == null) && (iterator.hasNext())) {
|
||||
IPropertyPartType next = (IPropertyPartType) iterator.next();
|
||||
|
||||
if(name.equals(next.getName())) {
|
||||
result = next;
|
||||
}//if//
|
||||
}//while//
|
||||
|
||||
if((result == null) && (getExtendedType() != null)) {
|
||||
result = getExtendedType().getProperty(name);
|
||||
}//if//
|
||||
|
||||
return result;
|
||||
}//getProperty()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getAssociations()
|
||||
*/
|
||||
public IManagedList getAssociations() {
|
||||
return (IManagedList) getAttributeValue(ASSOCIATION_TYPES);
|
||||
}//getAssociations()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getAssociation(java.lang.String)
|
||||
*/
|
||||
public IAssociationPartType getAssociation(String function) {
|
||||
IAssociationPartType result = null;
|
||||
IIterator iterator = getAssociations().iterator();
|
||||
|
||||
while((result == null) && (iterator.hasNext())) {
|
||||
IAssociationPartType next = (IAssociationPartType) iterator.next();
|
||||
|
||||
if(Comparator.equals(function, next.getFunction())) {
|
||||
result = next;
|
||||
}//if//
|
||||
}//while//
|
||||
|
||||
if((result == null) && (getExtendedType() != null)) {
|
||||
result = getExtendedType().getAssociation(function);
|
||||
}//if//
|
||||
|
||||
return result;
|
||||
}//getAssociation()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getAttributes()
|
||||
*/
|
||||
public IManagedList getAttributes() {
|
||||
return (IManagedList) getAttributeValue(ATTRIBUTES);
|
||||
}//getAttributes()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getAttribute(java.lang.String)
|
||||
*/
|
||||
public IAttributePartType getAttribute(String function) {
|
||||
IAttributePartType result = null;
|
||||
IIterator iterator = getAttributes().iterator();
|
||||
|
||||
while((result == null) && (iterator.hasNext())) {
|
||||
AttributePartType next = (AttributePartType) iterator.next();
|
||||
|
||||
if(function.equals(next.getFunction())) {
|
||||
result = next;
|
||||
}//if//
|
||||
}//while//
|
||||
|
||||
if((result == null) && (getExtendedType() != null)) {
|
||||
result = getExtendedType().getAttribute(function);
|
||||
}//if//
|
||||
|
||||
return result;
|
||||
}//getAttribute()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getMethods()
|
||||
*/
|
||||
public IManagedList getMethods() {
|
||||
return (IManagedList) getAttributeValue(METHODS);
|
||||
}//getMethods()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getMethod(java.lang.String)
|
||||
*/
|
||||
public IMethodPartType getMethod(String function) {
|
||||
IMethodPartType result = null;
|
||||
IIterator iterator = getMethods().iterator();
|
||||
|
||||
while((result == null) && (iterator.hasNext())) {
|
||||
MethodPartType next = (MethodPartType) iterator.next();
|
||||
|
||||
if(function.equals(next.getFunction())) {
|
||||
result = next;
|
||||
}//if//
|
||||
}//while//
|
||||
|
||||
if((result == null) && (getExtendedType() != null)) {
|
||||
result = getExtendedType().getMethod(function);
|
||||
}//if//
|
||||
|
||||
return result;
|
||||
}//getMethod()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getEvents()
|
||||
*/
|
||||
public IManagedList getEvents() {
|
||||
return (IManagedList) getAttributeValue(EVENTS);
|
||||
}//getEvents()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getEvent(java.lang.String)
|
||||
*/
|
||||
public IEventPartType getEvent(String function) {
|
||||
IEventPartType result = null;
|
||||
IIterator iterator = getEvents().iterator();
|
||||
|
||||
while((result == null) && (iterator.hasNext())) {
|
||||
EventPartType next = (EventPartType) iterator.next();
|
||||
|
||||
if(function.equals(next.getFunction())) {
|
||||
result = next;
|
||||
}//if//
|
||||
}//while//
|
||||
|
||||
if((result == null) && (getExtendedType() != null)) {
|
||||
result = getExtendedType().getEvent(function);
|
||||
}//if//
|
||||
|
||||
return result;
|
||||
}//getEvent()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getLinks()
|
||||
*/
|
||||
public IManagedList getLinks() {
|
||||
return (IManagedList) getAttributeValue(LINKS);
|
||||
}//getLinks()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getLink(java.lang.String)
|
||||
*/
|
||||
public ILinkPartType getLink(String function) {
|
||||
ILinkPartType result = null;
|
||||
IIterator iterator = getLinks().iterator();
|
||||
|
||||
while((result == null) && (iterator.hasNext())) {
|
||||
ILinkPartType next = (ILinkPartType) iterator.next();
|
||||
|
||||
if(function.equals(next.getFunction())) {
|
||||
result = next;
|
||||
}//if//
|
||||
}//while//
|
||||
|
||||
if((result == null) && (getExtendedType() != null)) {
|
||||
result = getExtendedType().getLink(function);
|
||||
}//if//
|
||||
|
||||
return result;
|
||||
}//getLink()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getLinkTargets()
|
||||
*/
|
||||
public IManagedList getLinkTargets() {
|
||||
return (IManagedList) getAttributeValue(LINK_TARGETS);
|
||||
}//getLinkTargets()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getLinkTarget(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public ILinkTargetPartType getLinkTarget(String name, String dataType) {
|
||||
ILinkTargetPartType result = null;
|
||||
IIterator iterator = getLinkTargets().iterator();
|
||||
|
||||
while((result == null) && (iterator.hasNext())) {
|
||||
ILinkTargetPartType next = (ILinkTargetPartType) iterator.next();
|
||||
|
||||
if(Comparator.equals(name, next.getName()) && Comparator.equals(dataType, next.getDataType())) {
|
||||
result = next;
|
||||
}//if//
|
||||
}//while//
|
||||
|
||||
if((result == null) && (getExtendedType() != null)) {
|
||||
result = getExtendedType().getLinkTarget(name, dataType);
|
||||
}//if//
|
||||
|
||||
return result;
|
||||
}//getLinkTarget()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getKey()
|
||||
*/
|
||||
public IKeyPartType getKey() {
|
||||
IKeyPartType result = (IKeyPartType) getAttributeValue(KEY);
|
||||
|
||||
if((result == null) && (getExtendedType() != null)) {
|
||||
result = getExtendedType().getKey();
|
||||
}//if//
|
||||
|
||||
return result;
|
||||
}//getKey()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getComponents()
|
||||
*/
|
||||
public IManagedList getComponents() {
|
||||
return (IManagedList) getAttributeValue(COMPONENTS);
|
||||
}//getComponents()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getDefinedComponentTypes()
|
||||
*/
|
||||
public IManagedList getDefinedComponentTypes() {
|
||||
return (IManagedList) getAttributeValue(DEFINED_COMPONENT_TYPES);
|
||||
}//getDefinedComponentTypes()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getDefinedComponentType(java.lang.String)
|
||||
*/
|
||||
public IComponentType getDefinedComponentType(String typeName) {
|
||||
IComponentType result = null;
|
||||
IIterator iterator = getDefinedComponentTypes().iterator();
|
||||
|
||||
//Search this type for sub-types defined within this type.//
|
||||
while((result == null) && (iterator.hasNext())) {
|
||||
IComponentType nextType = (IComponentType) iterator.next();
|
||||
|
||||
if(nextType.getName().equals(typeName)) {
|
||||
result = nextType;
|
||||
}//if//
|
||||
else {
|
||||
nextType = nextType.getExtendedType();
|
||||
|
||||
//Search the parent type for sub-types defined within it.//
|
||||
while((result == null) && (nextType != null)) {
|
||||
if(nextType.getName().equals(typeName)) {
|
||||
result = nextType;
|
||||
}//if//
|
||||
|
||||
nextType = nextType.getExtendedType();
|
||||
}//if//
|
||||
}//else//
|
||||
}//while//
|
||||
|
||||
//Search the parent type for sub-types defined within it.//
|
||||
if((result == null) && (getExtendedType() != null)) {
|
||||
result = getExtendedType().getDefinedComponentType(typeName);
|
||||
}//if//
|
||||
|
||||
//Search the defining type for sub-types defined within it.//
|
||||
if((result == null) && (getDefiningType() != null)) {
|
||||
result = getDefiningType().getDefinedComponentType(typeName);
|
||||
}//if//
|
||||
|
||||
return result;
|
||||
}//getDefinedComponentType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getExtendedTypeName()
|
||||
*/
|
||||
public String getExtendedTypeName() {
|
||||
return (String) getAttributeValue(EXTENDED_TYPE_NAME);
|
||||
}//getExtendedTypeName()//
|
||||
/**
|
||||
* Sets the extendedTypeName value.
|
||||
* @param extendedTypeName The extendedTypeName value.
|
||||
*/
|
||||
private void setExtendedTypeName(String extendedTypeName) {
|
||||
setAttributeValue(EXTENDED_TYPE_NAME, extendedTypeName);
|
||||
}//setExtendedTypeName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getExtendedType()
|
||||
*/
|
||||
public IComponentType getExtendedType() {
|
||||
return (IComponentType) getAttributeValue(EXTENDED_TYPE);
|
||||
}//getExtendedType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#setExtendedType(com.foundation.view.definition.IComponentType)
|
||||
*/
|
||||
public void setExtendedType(IComponentType extendedType) {
|
||||
setAttributeValue(EXTENDED_TYPE, extendedType);
|
||||
setExtendedTypeName(extendedType != null ? extendedType.getName() : null);
|
||||
}//setExtendedType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getAssociatedType()
|
||||
*/
|
||||
public IComponentType getAssociatedType() {
|
||||
return (IComponentType) getAttributeValue(ASSOCIATED_TYPE);
|
||||
}//getAssociatedType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#setAssociatedType(com.foundation.view.definition.IComponentType)
|
||||
*/
|
||||
public void setAssociatedType(IComponentType associatedType) {
|
||||
setAttributeValue(ASSOCIATED_TYPE, associatedType);
|
||||
setAssociatedTypeName(associatedType != null ? associatedType.getName() : null);
|
||||
}//setAssociatedType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getAssociatedTypeName()
|
||||
*/
|
||||
public String getAssociatedTypeName() {
|
||||
return (String) getAttributeValue(ASSOCIATED_TYPE_NAME);
|
||||
}//getAssociatedTypeName()//
|
||||
/**
|
||||
* Sets the associatedTypeName value.
|
||||
* This is optional for most types. It is currently only used by layout types.
|
||||
* @param associatedTypeName The associatedTypeName value.
|
||||
*/
|
||||
private void setAssociatedTypeName(String associatedTypeName) {
|
||||
setAttributeValue(ASSOCIATED_TYPE_NAME, associatedTypeName);
|
||||
}//setAssociatedTypeName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getDefiningType()
|
||||
*/
|
||||
public IComponentType getDefiningType() {
|
||||
return (IComponentType) getAttributeValue(DEFINING_TYPE);
|
||||
}//getDefiningType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#setDefiningType(com.foundation.view.definition.IComponentType)
|
||||
*/
|
||||
public void setDefiningType(IComponentType definingType) {
|
||||
setAttributeValue(DEFINING_TYPE, definingType);
|
||||
}//setDefiningType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getStyles()
|
||||
*/
|
||||
public IList getStyles() {
|
||||
return (IList) getAttributeValue(STYLES);
|
||||
}//getStyles()//
|
||||
/**
|
||||
* Sets the collection of styles.
|
||||
* @param styles The list of all styles.
|
||||
*/
|
||||
private void setStyles(IList styles) {
|
||||
setAttributeValue(STYLES, styles);
|
||||
}//setStyles()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getDeclaredStyles()
|
||||
*/
|
||||
public IList getDeclaredStyles() {
|
||||
return (IList) getAttributeValue(DECLARED_STYLES);
|
||||
}//getDeclaredStyles()//
|
||||
/**
|
||||
* Sets the collection of styles declared by the type.
|
||||
* @param declaredStyles The list of all styles declared by this type only.
|
||||
*/
|
||||
private void setDeclaredStyles(IList declaredStyles) {
|
||||
setAttributeValue(DECLARED_STYLES, declaredStyles);
|
||||
}//setDeclaredStyles()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getInheritStyles()
|
||||
*/
|
||||
public Boolean getInheritStyles() {
|
||||
return (Boolean) getAttributeValue(INHERIT_STYLES);
|
||||
}//getInheritStyles()//
|
||||
/**
|
||||
* Determines whether the super type's styles will be inherited.
|
||||
* @param inheritStyles Whether to inherit the super type's styles.
|
||||
*/
|
||||
private void setInheritStyles(Boolean inheritStyles) {
|
||||
setAttributeValue(INHERIT_STYLES, inheritStyles);
|
||||
}//setInheritStyles()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getStyleSets()
|
||||
*/
|
||||
public IList getStyleSets() {
|
||||
return (IList) getAttributeValue(STYLE_SETS);
|
||||
}//getStyleSets()//
|
||||
/**
|
||||
* Sets the collection of style sets.
|
||||
* @param styleSets The list of all style sets.
|
||||
*/
|
||||
private void setStyleSets(IList styleSets) {
|
||||
setAttributeValue(STYLE_SETS, styleSets);
|
||||
}//setStyleSets()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getDeclaredStyleSets()
|
||||
*/
|
||||
public IList getDeclaredStyleSets() {
|
||||
return (IList) getAttributeValue(DECLARED_STYLE_SETS);
|
||||
}//getDeclaredStyleSets()//
|
||||
/**
|
||||
* Sets the collection of declared style sets.
|
||||
* @param styleSets The list of all declared style sets.
|
||||
*/
|
||||
private void setDeclaredStyleSets(IList declaredStyleSets) {
|
||||
setAttributeValue(DECLARED_STYLE_SETS, declaredStyleSets);
|
||||
}//setDeclaredStyleSets()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#getChildTypes()
|
||||
*/
|
||||
public IManagedList getChildTypes() {
|
||||
return (IManagedList) getAttributeValue(CHILD_TYPES);
|
||||
}//getChildTypes()//
|
||||
/**
|
||||
* Reads the model from the XML node.
|
||||
* @param node The node containing model data.
|
||||
*/
|
||||
public void readXml(INode node) {
|
||||
IIterator iterator = null;
|
||||
|
||||
try {
|
||||
setName(node.getAttributeValue(ATTRIBUTE_NAME, true, true));
|
||||
setExtendedTypeName(node.getAttributeValue(ATTRIBUTE_EXTENDS, true, true));
|
||||
setAssociatedTypeName(node.getAttributeValue(ATTRIBUTE_ASSOCIATED_TYPE, true, true));
|
||||
setInheritStyles(readBoolean(node.getAttributeValue(ATTRIBUTE_INHERIT_STYLES, true, true), Boolean.TRUE));
|
||||
iterator = node.getElements().iterator();
|
||||
|
||||
while(iterator.hasNext()) {
|
||||
IElement next = (IElement) iterator.next();
|
||||
|
||||
if(next.isNode()) {
|
||||
INode subNode = (INode) next;
|
||||
String subNodeName = subNode.getName();
|
||||
|
||||
if(NODE_BUILDER.equals(subNodeName)) {
|
||||
BuilderDefinition builderDefinition = new BuilderDefinition();
|
||||
|
||||
builderDefinition.readXml(subNode);
|
||||
setBuilderDefinition(builderDefinition);
|
||||
}//if//
|
||||
else if(IPropertyPartType.NODE_NAME.equals(subNodeName)) {
|
||||
PropertyPartType part = new PropertyPartType();
|
||||
|
||||
part.readXml(subNode);
|
||||
getProperties().add(part);
|
||||
}//else if//
|
||||
else if(IAssociationPartType.METADATA_NODE_NAME.equals(subNodeName)) {
|
||||
AssociationPartType part = new AssociationPartType();
|
||||
|
||||
part.readXml(subNode);
|
||||
getAssociations().add(part);
|
||||
}//else if//
|
||||
else if(AttributePartType.NODE_NAME.equals(subNodeName)) {
|
||||
AttributePartType part = new AttributePartType();
|
||||
|
||||
part.readXml(subNode);
|
||||
getAttributes().add(part);
|
||||
}//else if//
|
||||
else if(IMethodPartType.NODE_NAME.equals(subNodeName)) {
|
||||
MethodPartType part = new MethodPartType();
|
||||
|
||||
part.readXml(subNode);
|
||||
getMethods().add(part);
|
||||
}//else if//
|
||||
else if(EventPartType.NODE_NAME.equals(subNodeName)) {
|
||||
EventPartType part = new EventPartType();
|
||||
|
||||
part.readXml(subNode);
|
||||
getEvents().add(part);
|
||||
}//else if//
|
||||
else if(ILinkPartType.NODE_NAME.equals(subNodeName)) {
|
||||
LinkPartType part = new LinkPartType();
|
||||
|
||||
try {
|
||||
part.readXml(subNode);
|
||||
}//try//
|
||||
catch(com.foundation.view.builder.ViewBuilderException e) {
|
||||
throw new com.foundation.view.builder.ViewBuilderException(e.toString() + " Caught while reading the component type: " + getName(), e, null);
|
||||
}//catch//
|
||||
|
||||
getLinks().add(part);
|
||||
}//else if//
|
||||
else if(ILinkTargetPartType.NODE_NAME.equals(subNodeName)) {
|
||||
LinkTargetPartType part = new LinkTargetPartType();
|
||||
|
||||
part.readXml(subNode);
|
||||
getLinkTargets().add(part);
|
||||
}//else if//
|
||||
else if(IKeyPartType.NODE_NAME.equals(subNodeName)) {
|
||||
KeyPartType part = new KeyPartType();
|
||||
|
||||
part.readXml(subNode);
|
||||
setAttributeValue(KEY, part);
|
||||
}//else if//
|
||||
else if(IComponentPartType.NODE_NAME.equals(subNodeName)) {
|
||||
ComponentPartType part = new ComponentPartType();
|
||||
|
||||
part.readXml(subNode);
|
||||
getComponents().add(part);
|
||||
}//else if//
|
||||
else if(IComponentType.NODE_NAME.equals(subNodeName)) {
|
||||
ComponentType type = new ComponentType();
|
||||
|
||||
type.readXml(subNode);
|
||||
getDefinedComponentTypes().add(type);
|
||||
}//else if//
|
||||
else if(IStyleType.NODE_NAME.equals(subNodeName)) {
|
||||
StyleType type = new StyleType();
|
||||
|
||||
type.readXml(subNode);
|
||||
getDeclaredStyles().add(type);
|
||||
getStyles().add(type);
|
||||
}//else if//
|
||||
else if(IStyleSet.NODE_NAME.equals(subNodeName)) {
|
||||
StyleSet type = new StyleSet();
|
||||
|
||||
type.readXml(subNode);
|
||||
getDeclaredStyleSets().add(type);
|
||||
getStyleSets().add(type);
|
||||
}//else if//
|
||||
else {
|
||||
//Unexpected node type. Will ignore.//
|
||||
}//else//
|
||||
}//if//
|
||||
}//while//
|
||||
}//try//
|
||||
catch(ViewBuilderException e) {
|
||||
throw new ViewBuilderException("Caught exception while reading the component type named: " + getName() + ".", e, null);
|
||||
}//catch//
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the model to the XML node.
|
||||
* @param node The node that will receive the model data.
|
||||
*/
|
||||
public void writeXml(INode node) {
|
||||
}//writeXml()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
public String toString() {
|
||||
return getName();
|
||||
}//toString()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
//Note: The name of the component type must be unique for any loaded set.//
|
||||
return (object instanceof ComponentType) && (getName().equals(((IComponentType) object).getName()));
|
||||
}//equals()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IComponentType#hashCode()
|
||||
*/
|
||||
public int hashCode() {
|
||||
return getName().hashCode();
|
||||
}//hashCode()//
|
||||
}//ComponentType//
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2004,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.IElement;
|
||||
|
||||
public class EventPart extends ReferencePart implements IEventPart {
|
||||
public static final Attribute TYPE = registerAttribute(EventPart.class, "type");
|
||||
/**
|
||||
* EventPart constructor.
|
||||
* <p><b>Warning: Only public for the purpose of creating reflections.</b></p>
|
||||
*/
|
||||
public EventPart() {
|
||||
}//EventPart()//
|
||||
/**
|
||||
* EventPart constructor.
|
||||
* @param type The type definition for the event.
|
||||
* @param component The component referencing the attribute.
|
||||
* @param documentElement The optional element of the document that defines this part. This is used for debugging.
|
||||
*/
|
||||
public EventPart(IEventPartType type, IComponentData component, IElement documentElement) {
|
||||
this(type, component, null, null, null, documentElement);
|
||||
}//EventPart()//
|
||||
/**
|
||||
* EventPart constructor.
|
||||
* @param type The type definition for the event.
|
||||
* @param component The component referencing the attribute.
|
||||
* @param name The name of the event.
|
||||
* @param valueHolderName The name of the value holder associated with the part.
|
||||
* @param valueTypeName The qualified class name for the value holder held object subclass which defines the referenced part.
|
||||
* @param rowTypeName The qualified class name for the row or data object class which defines the referenced part.
|
||||
* @param documentElement The optional element of the document that defines this part. This is used for debugging.
|
||||
*/
|
||||
public EventPart(IEventPartType type, IComponentData component, String name, String valueHolderName, String valueTypeName, String rowTypeName, IElement documentElement) {
|
||||
super(component, name, valueHolderName, valueTypeName, rowTypeName, documentElement);
|
||||
setType(type);
|
||||
}//EventPart()//
|
||||
/**
|
||||
* EventPart constructor.
|
||||
* @param type The type definition for the event.
|
||||
* @param component The component referencing the attribute.
|
||||
* @param name The name of the event.
|
||||
* @param valueHolderName The name of the value holder associated with the part.
|
||||
* @param valueTypeName The qualified class name for the value holder held object subclass which defines the referenced part.
|
||||
* @param documentElement The optional element of the document that defines this part. This is used for debugging.
|
||||
*/
|
||||
public EventPart(IEventPartType type, IComponentData component, String name, String valueHolderName, String valueTypeName, IElement documentElement) {
|
||||
super(component, name, valueHolderName, valueTypeName, null, documentElement);
|
||||
setType(type);
|
||||
}//EventPart()//
|
||||
/**
|
||||
* EventPart constructor.
|
||||
* @param type The type definition for the event.
|
||||
* @param component The component referencing the attribute.
|
||||
* @param name The name of the event.
|
||||
* @param valueHolderName The name of the value holder associated with the part.
|
||||
* @param rowTypeName The qualified class name for the row or data object class which defines the referenced part.
|
||||
* @param documentElement The optional element of the document that defines this part. This is used for debugging.
|
||||
*/
|
||||
public EventPart(IEventPartType type, IComponentData component, String name, String rowTypeName, IElement documentElement) {
|
||||
super(component, name, null, null, rowTypeName, documentElement);
|
||||
setType(type);
|
||||
}//EventPart()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IEventPart#getType()
|
||||
*/
|
||||
public IEventPartType getType() {
|
||||
return (IEventPartType) getAttributeValue(TYPE);
|
||||
}//getType()//
|
||||
/**
|
||||
* Sets the type value.
|
||||
* @param type The type value.
|
||||
*/
|
||||
private void setType(IEventPartType type) {
|
||||
setAttributeValue(TYPE, type);
|
||||
}//setType()//
|
||||
}//EventPart//
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2004,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.util.xml.INode;
|
||||
|
||||
public class EventPartType extends ReferencePartType implements IEventPartType {
|
||||
public static final String NODE_NAME = "event";
|
||||
/**
|
||||
* EventPartType constructor.
|
||||
*/
|
||||
public EventPartType() {
|
||||
super();
|
||||
}//EventPartType()//
|
||||
/**
|
||||
* Reads the model from the XML node.
|
||||
* @param node The node containing model data.
|
||||
*/
|
||||
public void readXml(INode node) {
|
||||
super.readXml(node);
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the model to the XML node.
|
||||
* @param node The node that will receive the model data.
|
||||
*/
|
||||
public void writeXml(INode node) {
|
||||
super.writeXml(node);
|
||||
}//writeXml()//
|
||||
}//EventPartType//
|
||||
247
Vml Builder/src/com/foundation/view/definition/KeyPart.java
Normal file
247
Vml Builder/src/com/foundation/view/definition/KeyPart.java
Normal file
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
* Copyright (c) 2007,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.view.IKeyBinding;
|
||||
import com.foundation.view.builder.BuildFailedException;
|
||||
import com.foundation.view.builder.IClassMetadataLoader;
|
||||
|
||||
public class KeyPart extends AbstractPart implements IKeyPart {
|
||||
public static final Attribute TYPE = registerAttribute(KeyPart.class, "type");
|
||||
public static final Attribute CHARACTER = registerAttribute(KeyPart.class, "character");
|
||||
public static final Attribute ALT = registerAttribute(KeyPart.class, "alt", Boolean.FALSE);
|
||||
public static final Attribute SHIFT = registerAttribute(KeyPart.class, "shift", Boolean.FALSE);
|
||||
public static final Attribute CONTROL = registerAttribute(KeyPart.class, "control", Boolean.FALSE);
|
||||
public static final Attribute COMMAND = registerAttribute(KeyPart.class, "command", Boolean.FALSE);
|
||||
public static final Attribute METHOD = registerAttribute(KeyPart.class, "method");
|
||||
public static final Attribute SIGNATURE = registerAttribute(KeyPart.class, "signature");
|
||||
public static final Attribute VALUE_HOLDER_NAME = registerAttribute(KeyPart.class, "valueHolderName");
|
||||
public static final Attribute HELD_TYPE_NAME = registerAttribute(KeyPart.class, "heldTypeName");
|
||||
public static final Attribute ROW_TYPE_NAME = registerAttribute(KeyPart.class, "rowTypeName");
|
||||
|
||||
/** A cached result type for the getter method. This is cached since it is a bit time intensive to find it. */
|
||||
private String getterResultType = null;
|
||||
/**
|
||||
* KeyPart constructor.
|
||||
*/
|
||||
public KeyPart() {
|
||||
}//KeyPart()//
|
||||
/**
|
||||
* KeyPart constructor.
|
||||
* @param type The type definition for the method.
|
||||
* @param component The component referencing the attribute.
|
||||
* @param documentElement The optional element of the document that defines this part. This is used for debugging.
|
||||
*/
|
||||
public KeyPart(IKeyPartType type, IComponentData component, IElement documentElement) {
|
||||
super(component);
|
||||
setAttributeValue(TYPE, type);
|
||||
setDocumentElement(documentElement);
|
||||
}//KeyPart()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#getHeldTypeName()
|
||||
*/
|
||||
public String getHeldTypeName() {
|
||||
return (String) getAttributeValue(HELD_TYPE_NAME);
|
||||
}//getHeldTypeName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#getCharacter()
|
||||
*/
|
||||
public Integer getCharacter() {
|
||||
return (Integer) getAttributeValue(CHARACTER);
|
||||
}//getCharacter()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#getMethod()
|
||||
*/
|
||||
public String getMethod() {
|
||||
return (String) getAttributeValue(METHOD);
|
||||
}//getMethod()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#getRowTypeName()
|
||||
*/
|
||||
public String getRowTypeName() {
|
||||
return (String) getAttributeValue(ROW_TYPE_NAME);
|
||||
}//getRowTypeName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#getSignature()
|
||||
*/
|
||||
public String getSignature() {
|
||||
return (String) getAttributeValue(SIGNATURE);
|
||||
}//getSignature()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#getType()
|
||||
*/
|
||||
public IKeyPartType getType() {
|
||||
return (IKeyPartType) getAttributeValue(TYPE);
|
||||
}//getType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#getValueHolderName()
|
||||
*/
|
||||
public String getValueHolderName() {
|
||||
return (String) getAttributeValue(VALUE_HOLDER_NAME);
|
||||
}//getValueHolderName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#setHeldTypeName(java.lang.String)
|
||||
*/
|
||||
public void setHeldTypeName(String heldTypeName) {
|
||||
setAttributeValue(HELD_TYPE_NAME, heldTypeName);
|
||||
}//setHeldTypeName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#setCharacter(java.lang.Integer)
|
||||
*/
|
||||
public void setCharacter(Integer character) {
|
||||
setAttributeValue(CHARACTER, character);
|
||||
}//setCharacter()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#setMethod(java.lang.String)
|
||||
*/
|
||||
public void setMethod(String method) {
|
||||
setAttributeValue(METHOD, method);
|
||||
}//setMethod()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#setRowTypeName(java.lang.String)
|
||||
*/
|
||||
public void setRowTypeName(String rowTypeName) {
|
||||
setAttributeValue(ROW_TYPE_NAME, rowTypeName);
|
||||
}//setRowTypeName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#setSignature(java.lang.String)
|
||||
*/
|
||||
public void setSignature(String signature) {
|
||||
setAttributeValue(SIGNATURE, signature);
|
||||
}//setSignature()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#setValueHolderName(java.lang.String)
|
||||
*/
|
||||
public void setValueHolderName(String valueHolderName) {
|
||||
setAttributeValue(VALUE_HOLDER_NAME, valueHolderName);
|
||||
}//setValueHolderName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#getAlt()
|
||||
*/
|
||||
public Boolean getAlt() {
|
||||
return (Boolean) getAttributeValue(ALT);
|
||||
}//getAlt()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#getCommand()
|
||||
*/
|
||||
public Boolean getCommand() {
|
||||
return (Boolean) getAttributeValue(COMMAND);
|
||||
}//getCommand()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#getControl()
|
||||
*/
|
||||
public Boolean getControl() {
|
||||
return (Boolean) getAttributeValue(CONTROL);
|
||||
}//getControl()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#getShift()
|
||||
*/
|
||||
public Boolean getShift() {
|
||||
return (Boolean) getAttributeValue(SHIFT);
|
||||
}//getShift()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#setAlt(java.lang.Boolean)
|
||||
*/
|
||||
public void setAlt(Boolean alt) {
|
||||
setAttributeValue(ALT, alt);
|
||||
}//setAlt()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#setCommand(java.lang.Boolean)
|
||||
*/
|
||||
public void setCommand(Boolean command) {
|
||||
setAttributeValue(COMMAND, command);
|
||||
}//setCommand()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#setControl(java.lang.Boolean)
|
||||
*/
|
||||
public void setControl(Boolean control) {
|
||||
setAttributeValue(CONTROL, control);
|
||||
}//setControl()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#setShift(java.lang.Boolean)
|
||||
*/
|
||||
public void setShift(Boolean shift) {
|
||||
setAttributeValue(SHIFT, shift);
|
||||
}//setShift()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#getModifiers()
|
||||
*/
|
||||
public int getModifiers() {
|
||||
int modifiers = 0;
|
||||
|
||||
if(getAlt().booleanValue()) {
|
||||
modifiers |= IKeyBinding.MODIFIER_ALT;
|
||||
}//if//
|
||||
|
||||
if(getShift().booleanValue()) {
|
||||
modifiers |= IKeyBinding.MODIFIER_SHIFT;
|
||||
}//if//
|
||||
|
||||
if(getControl().booleanValue()) {
|
||||
modifiers |= IKeyBinding.MODIFIER_CONTROL;
|
||||
}//if//
|
||||
|
||||
if(getCommand().booleanValue()) {
|
||||
modifiers |= IKeyBinding.MODIFIER_COMMAND;
|
||||
}//if//
|
||||
|
||||
return modifiers;
|
||||
}//getModifiers()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPart#getMethodReturnType(java.lang.ClassLoader)
|
||||
*/
|
||||
public String getMethodReturnType(IClassMetadataLoader applicationClassMetadataLoader) throws ClassNotFoundException {
|
||||
String result = null;
|
||||
|
||||
if(getterResultType != null) {
|
||||
result = getterResultType;
|
||||
}//if//
|
||||
else {
|
||||
if(getValueHolderName() != null) {
|
||||
if(getHeldTypeName() != null) {
|
||||
try {
|
||||
result = applicationClassMetadataLoader.getMethodReturnType(getHeldTypeName(), getMethod(), getSignature(), getFeedbackStack(), getDocumentElement());
|
||||
}//try//
|
||||
catch(ClassNotFoundException e) {
|
||||
getFeedbackStack().add(new Message(true, "Invalid class name: " + getHeldTypeName(), getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//catch//
|
||||
}//if//
|
||||
else {
|
||||
try {
|
||||
result = applicationClassMetadataLoader.getMethodReturnType(getValueHolderType(getValueHolderName()), getMethod(), getSignature(), getFeedbackStack(), getDocumentElement());
|
||||
}//try//
|
||||
catch(ClassNotFoundException e) {
|
||||
getFeedbackStack().add(new Message(true, "Invalid class name: " + getValueHolderType(getValueHolderName()), getValueHolder(getValueHolderName()).getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//catch//
|
||||
}//else//
|
||||
}//if//
|
||||
else if(getRowTypeName() != null) {
|
||||
try {
|
||||
result = applicationClassMetadataLoader.getMethodReturnType(getRowTypeName(), getMethod(), getSignature(), getFeedbackStack(), getDocumentElement());
|
||||
}//try//
|
||||
catch(ClassNotFoundException e) {
|
||||
getFeedbackStack().add(new Message(true, "Invalid class name: " + getRowTypeName(), getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//catch//
|
||||
}//else if//
|
||||
else {
|
||||
getFeedbackStack().add(new Message(true, "Error: The attribute must either specify a value-holder or value-type.", getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//else//
|
||||
|
||||
//Cache the result for efficiency.//
|
||||
getterResultType = result;
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//getMethodReturnType()//
|
||||
}//KeyPart//
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2007,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.INode;
|
||||
|
||||
public class KeyPartType extends AbstractModel implements IKeyPartType {
|
||||
public static final Attribute REQUIRES_VALUE_HOLDER = registerAttribute(KeyPartType.class, "requiresValueHolder");
|
||||
|
||||
public static final String ATTRIBUTE_REQUIRES_VALUE_HOLDER = "requires-value-holder";
|
||||
/**
|
||||
* KeyPartType constructor.
|
||||
*/
|
||||
public KeyPartType() {
|
||||
}//KeyPartType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPartType#getRequiresValueHolder()
|
||||
*/
|
||||
public Boolean getRequiresValueHolder() {
|
||||
return (Boolean) getAttributeValue(REQUIRES_VALUE_HOLDER);
|
||||
}//getRequiresValueHolder()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IKeyPartType#setRequiresValueHolder(java.lang.Boolean)
|
||||
*/
|
||||
public void setRequiresValueHolder(Boolean requiresValueHolder) {
|
||||
setAttributeValue(REQUIRES_VALUE_HOLDER, requiresValueHolder);
|
||||
}//setRequiresValueHolder()//
|
||||
/**
|
||||
* Reads the model from the XML node.
|
||||
* @param node The node containing model data.
|
||||
*/
|
||||
public void readXml(INode node) {
|
||||
setRequiresValueHolder(readBoolean(node.getAttributeValue(ATTRIBUTE_REQUIRES_VALUE_HOLDER, true, true), Boolean.TRUE));
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the model to the XML node.
|
||||
* @param node The node that will receive the model data.
|
||||
*/
|
||||
public void writeXml(INode node) {
|
||||
}//writeXml()//
|
||||
}//KeyPartType//
|
||||
121
Vml Builder/src/com/foundation/view/definition/LinkPart.java
Normal file
121
Vml Builder/src/com/foundation/view/definition/LinkPart.java
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (c) 2006,2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.IElement;
|
||||
|
||||
public class LinkPart extends AbstractPart implements ILinkPart {
|
||||
public static final Attribute TYPE = registerAttribute(LinkPart.class, "type");
|
||||
public static final Attribute TARGET_COMPONENT_NAME = registerAttribute(LinkPart.class, "targetComponentName");
|
||||
public static final Attribute TARGET_NAME = registerAttribute(LinkPart.class, "targetName");
|
||||
public static final Attribute DATA = registerAttribute(LinkPart.class, "data");
|
||||
public static final Attribute INVERT_LOGIC = registerAttribute(LinkPart.class, "invertLogic", Boolean.FALSE);
|
||||
public static final Attribute NULL_VALUE = registerAttribute(LinkPart.class, "nullValue", Boolean.FALSE);
|
||||
/**
|
||||
* LinkPart constructor.
|
||||
* <p><b>Warning: Only public for the purpose of creating reflections.</b></p>
|
||||
*/
|
||||
public LinkPart() {
|
||||
super();
|
||||
}//LinkPart()//
|
||||
/**
|
||||
* LinkPart constructor.
|
||||
* @param type The type for this part.
|
||||
* @param component The component that defines the part.
|
||||
* @param targetComponentName The name of the linked component.
|
||||
* @param targetName The targeted component's target name for the link.
|
||||
* @param invertLogic Whether the link should invert boolean data.
|
||||
* @param nullValue The value to use if the input is null. This should default to 'false'.
|
||||
* @param documentElement The optional element of the document that defines this part. This is used for debugging.
|
||||
*/
|
||||
public LinkPart(ILinkPartType type, IComponentData component, String targetComponentName, String targetName, String data, Boolean invertLogic, Boolean nullValue, IElement documentElement) {
|
||||
super(component);
|
||||
|
||||
setType(type);
|
||||
setTargetComponentName(targetComponentName);
|
||||
setTargetName(targetName);
|
||||
setData(data);
|
||||
setInvertLogic(invertLogic);
|
||||
setNullValue(nullValue);
|
||||
setDocumentElement(documentElement);
|
||||
}//LinkPart()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.ILinkPart#getType()
|
||||
*/
|
||||
public ILinkPartType getType() {
|
||||
return (ILinkPartType) getAttributeValue(TYPE);
|
||||
}//getType()//
|
||||
/**
|
||||
* Sets the type.
|
||||
* @param type The type for this part.
|
||||
*/
|
||||
private void setType(ILinkPartType type) {
|
||||
setAttributeValue(TYPE, type);
|
||||
}//setType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.ILinkPart#getTargetComponentName()
|
||||
*/
|
||||
public String getTargetComponentName() {
|
||||
return (String) getAttributeValue(TARGET_COMPONENT_NAME);
|
||||
}//getTargetComponentName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.ILinkPart#setTargetComponentName(java.lang.String)
|
||||
*/
|
||||
public void setTargetComponentName(String targetComponentName) {
|
||||
setAttributeValue(TARGET_COMPONENT_NAME, targetComponentName);
|
||||
}//setTargetComponentName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.ILinkPart#getTargetName()
|
||||
*/
|
||||
public String getTargetName() {
|
||||
return (String) getAttributeValue(TARGET_NAME);
|
||||
}//getTargetName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.ILinkPart#setTargetName(java.lang.String)
|
||||
*/
|
||||
public void setTargetName(String targetName) {
|
||||
setAttributeValue(TARGET_NAME, targetName);
|
||||
}//setTargetName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.ILinkPart#getData()
|
||||
*/
|
||||
public String getData() {
|
||||
return (String) getAttributeValue(DATA);
|
||||
}//getData()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.ILinkPart#setData(java.lang.String)
|
||||
*/
|
||||
public void setData(String data) {
|
||||
setAttributeValue(DATA, data);
|
||||
}//setData()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.ILinkPart#getInvertLogic()
|
||||
*/
|
||||
public Boolean getInvertLogic() {
|
||||
return (Boolean) getAttributeValue(INVERT_LOGIC);
|
||||
}//getInvertLogic()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.ILinkPart#setInvertLogic(java.lang.Boolean)
|
||||
*/
|
||||
public void setInvertLogic(Boolean invertLogic) {
|
||||
setAttributeValue(INVERT_LOGIC, invertLogic);
|
||||
}//setInvertLogic()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.ILinkPart#getNullValue()
|
||||
*/
|
||||
public Boolean getNullValue() {
|
||||
return (Boolean) getAttributeValue(NULL_VALUE);
|
||||
}//getNullValue()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.ILinkPart#setNullValue(java.lang.Boolean)
|
||||
*/
|
||||
public void setNullValue(Boolean nullValue) {
|
||||
setAttributeValue(NULL_VALUE, nullValue);
|
||||
}//setNullValue()//
|
||||
}//LinkPart//
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2006,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.common.comparison.Comparator;
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.INode;
|
||||
|
||||
/*
|
||||
* Declared by a component that allows linking to another component.
|
||||
*/
|
||||
public class LinkPartType extends AbstractModel implements ILinkPartType {
|
||||
public static final Attribute FUNCTION = registerAttribute(LinkPartType.class, "function");
|
||||
public static final Attribute DATA_TYPE = registerAttribute(LinkPartType.class, "dataType");
|
||||
/**
|
||||
* LinkPartType constructor.
|
||||
*/
|
||||
public LinkPartType() {
|
||||
super();
|
||||
}//LinkPartType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.ILinkPartType#getFunction()
|
||||
*/
|
||||
public String getFunction() {
|
||||
return (String) getAttributeValue(FUNCTION);
|
||||
}//getFunction()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.ILinkPartType#setFunction(java.lang.String)
|
||||
*/
|
||||
public void setFunction(String function) {
|
||||
setAttributeValue(FUNCTION, function);
|
||||
}//setFunction()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.ILinkPartType#getDataType()
|
||||
*/
|
||||
public String getDataType() {
|
||||
return (String) getAttributeValue(DATA_TYPE);
|
||||
}//getDataType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.ILinkPartType#setDataType(java.lang.String)
|
||||
*/
|
||||
public void setDataType(String dataType) {
|
||||
setAttributeValue(DATA_TYPE, dataType);
|
||||
}//setDataType()//
|
||||
/**
|
||||
* Reads the model from the XML node.
|
||||
* @param node The node containing model data.
|
||||
*/
|
||||
public void readXml(INode node) {
|
||||
setFunction(node.getAttributeValue(ATTRIBUTE_FUNCTION, true, true));
|
||||
setDataType(node.getAttributeValue(ATTRIBUTE_DATA_TYPE, true, true));
|
||||
|
||||
if(getFunction() == null) {
|
||||
throw new com.foundation.view.builder.ViewBuilderException("Must provide a 'function' property in the type definition.", null);
|
||||
}//if//
|
||||
else if(node.getAttributeValue(ATTRIBUTE_DATA_TYPE, false, false) == null) {
|
||||
throw new com.foundation.view.builder.ViewBuilderException("Must provide a 'data-type' property in the type definition (it may be empty).", null);
|
||||
}//else if//
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the model to the XML node.
|
||||
* @param node The node that will receive the model data.
|
||||
*/
|
||||
public void writeXml(INode node) {
|
||||
}//writeXml()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return object != null && getClass().equals(object.getClass()) && (Comparator.equals(getFunction(),((ILinkPartType) object).getFunction()));
|
||||
}//equals()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
public int hashCode() {
|
||||
return getFunction().hashCode();
|
||||
}//hashCode()//
|
||||
}//LinkPartType//
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2006,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.INode;
|
||||
|
||||
/**
|
||||
* Declared by a component that allows another component to link to it.
|
||||
* The linking component's data type must exactly match this component's data type and the linking component's target must match this link target's name.
|
||||
*/
|
||||
public class LinkTargetPartType extends AbstractModel implements ILinkTargetPartType {
|
||||
public static final Attribute NAME = registerAttribute(LinkTargetPartType.class, "name");
|
||||
public static final Attribute DATA_TYPE = registerAttribute(LinkTargetPartType.class, "dataType");
|
||||
/**
|
||||
* LinkTargetPartType constructor.
|
||||
*/
|
||||
public LinkTargetPartType() {
|
||||
super();
|
||||
}//LinkTargetPartType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.ILinkTargetPartType#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return (String) getAttributeValue(NAME);
|
||||
}//getName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.ILinkTargetPartType#setName(java.lang.String)
|
||||
*/
|
||||
public void setName(String name) {
|
||||
setAttributeValue(NAME, name);
|
||||
}//setName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.ILinkTargetPartType#getDataType()
|
||||
*/
|
||||
public String getDataType() {
|
||||
return (String) getAttributeValue(DATA_TYPE);
|
||||
}//getDataType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.ILinkTargetPartType#setDataType(java.lang.String)
|
||||
*/
|
||||
public void setDataType(String dataType) {
|
||||
setAttributeValue(DATA_TYPE, dataType);
|
||||
}//setDataType()//
|
||||
/**
|
||||
* Reads the model from the XML node.
|
||||
* @param node The node containing model data.
|
||||
*/
|
||||
public void readXml(INode node) {
|
||||
setName(node.getAttributeValue(ATTRIBUTE_NAME, true, true));
|
||||
setDataType(node.getAttributeValue(ATTRIBUTE_DATA_TYPE, true, true));
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the model to the XML node.
|
||||
* @param node The node that will receive the model data.
|
||||
*/
|
||||
public void writeXml(INode node) {
|
||||
}//writeXml()//
|
||||
}//LinkTargetPartType//
|
||||
163
Vml Builder/src/com/foundation/view/definition/MethodPart.java
Normal file
163
Vml Builder/src/com/foundation/view/definition/MethodPart.java
Normal file
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright (c) 2004,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.view.builder.BuildFailedException;
|
||||
import com.foundation.view.builder.BuilderSupport;
|
||||
import com.foundation.view.builder.IClassMetadataLoader;
|
||||
|
||||
public class MethodPart extends ReferencePart implements IMethodPart {
|
||||
public static final Attribute TYPE = registerAttribute(MethodPart.class, "type");
|
||||
public static final Attribute SIGNATURE = registerAttribute(MethodPart.class, "signature");
|
||||
|
||||
/** A cached result type for the getter method. This is cached since it is a bit time intensive to find it. */
|
||||
private String getterResultType = null;
|
||||
/**
|
||||
* MethodPart constructor.
|
||||
* <p><b>Warning: Only public for the purpose of creating reflections.</b></p>
|
||||
*/
|
||||
public MethodPart() {
|
||||
}//MethodPart()//
|
||||
/**
|
||||
* MethodPart constructor.
|
||||
* @param type The type definition for the method.
|
||||
* @param component The component referencing the attribute.
|
||||
* @param documentElement The optional element of the document that defines this part. This is used for debugging.
|
||||
*/
|
||||
public MethodPart(IMethodPartType type, IComponentData component, IElement documentElement) {
|
||||
this(type, component, null, null, null, null, documentElement);
|
||||
}//MethodPart()//
|
||||
/**
|
||||
* MethodPart constructor.
|
||||
* @param type The type definition for the method.
|
||||
* @param component The component referencing the attribute.
|
||||
* @param name The name of the method.
|
||||
* @param valueHolderName The name of the value holder associated with the part.
|
||||
* @param valueTypeName The qualified class name for the value holder held object subclass which defines the referenced part.
|
||||
* @param rowTypeName The qualified class name for the row or data object class which defines the referenced part.
|
||||
* @param signature The method signature in the class file format. ex: Ljava.lang.ObjectI -> (java.lang.Object, int)
|
||||
* @param documentElement The optional element of the document that defines this part. This is used for debugging.
|
||||
*/
|
||||
public MethodPart(IMethodPartType type, IComponentData component, String name, String valueHolderName, String heldTypeName, String rowTypeName, String signature, IElement documentElement) {
|
||||
super(component, name, valueHolderName, heldTypeName, rowTypeName, documentElement);
|
||||
setType(type);
|
||||
setSignature(signature);
|
||||
}//MethodPart()//
|
||||
/**
|
||||
* MethodPart constructor.
|
||||
* @param type The type definition for the method.
|
||||
* @param component The component referencing the attribute.
|
||||
* @param name The name of the method.
|
||||
* @param valueHolderName The name of the value holder associated with the part.
|
||||
* @param valueTypeName The qualified class name for the value holder held object subclass which defines the referenced part.
|
||||
* @param signature The method signature in the class file format. ex: Ljava.lang.ObjectI -> (java.lang.Object, int)
|
||||
* @param documentElement The optional element of the document that defines this part. This is used for debugging.
|
||||
*/
|
||||
public MethodPart(IMethodPartType type, IComponentData component, String name, String valueHolderName, String heldTypeName, String signature, IElement documentElement) {
|
||||
super(component, name, valueHolderName, heldTypeName, null, documentElement);
|
||||
setType(type);
|
||||
setSignature(signature);
|
||||
}//MethodPart()//
|
||||
/**
|
||||
* MethodPart constructor.
|
||||
* @param type The type definition for the method.
|
||||
* @param component The component referencing the attribute.
|
||||
* @param name The name of the method.
|
||||
* @param rowTypeName The qualified class name for the row or data object class which defines the referenced part.
|
||||
* @param signature The method signature in the class file format. ex: Ljava.lang.ObjectI -> (java.lang.Object, int)
|
||||
* @param documentElement The optional element of the document that defines this part. This is used for debugging.
|
||||
*/
|
||||
public MethodPart(IMethodPartType type, IComponentData component, String name, String rowTypeName, String signature, IElement documentElement) {
|
||||
super(component, name, null, null, rowTypeName, documentElement);
|
||||
setType(type);
|
||||
setSignature(signature);
|
||||
}//MethodPart()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IMethodPart#getMethodParameterTypes()
|
||||
*/
|
||||
public String[] getMethodParameterTypes() {
|
||||
return BuilderSupport.getMethodParameterTypes(getSignature(), getFeedbackStack(), getDocumentElement());
|
||||
}//getMethodParameterTypes()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IMethodPart#getMethodReturnType(java.lang.ClassLoader)
|
||||
*/
|
||||
public String getMethodReturnType(IClassMetadataLoader applicationClassMetadataLoader) {
|
||||
String result = null;
|
||||
|
||||
if(getterResultType != null) {
|
||||
result = getterResultType;
|
||||
}//if//
|
||||
else {
|
||||
if(getValueHolderName() != null) {
|
||||
if(getHeldTypeName() != null) {
|
||||
try {
|
||||
result = applicationClassMetadataLoader.getMethodReturnType(getHeldTypeName(), getName(), getSignature(), getFeedbackStack(), getDocumentElement());
|
||||
}//try//
|
||||
catch(ClassNotFoundException e) {
|
||||
getFeedbackStack().add(new Message(true, "Invalid class name: " + getHeldTypeName(), getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//catch//
|
||||
}//if//
|
||||
else {
|
||||
try {
|
||||
result = applicationClassMetadataLoader.getMethodReturnType(getValueHolderType(getValueHolderName()), getName(), getSignature(), getFeedbackStack(), getDocumentElement());
|
||||
}//try//
|
||||
catch(ClassNotFoundException e) {
|
||||
getFeedbackStack().add(new Message(true, "Invalid class name: " + getValueHolderType(getValueHolderName()), getValueHolder(getValueHolderName()).getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//catch//
|
||||
}//else//
|
||||
}//if//
|
||||
else if(getRowTypeName() != null) {
|
||||
try {
|
||||
result = applicationClassMetadataLoader.getMethodReturnType(getRowTypeName(), getName(), getSignature(), getFeedbackStack(), getDocumentElement());
|
||||
}//try//
|
||||
catch(ClassNotFoundException e) {
|
||||
getFeedbackStack().add(new Message(true, "Invalid class name: " + getRowTypeName(), getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//catch//
|
||||
}//else if//
|
||||
else {
|
||||
getFeedbackStack().add(new Message(true, "Error: The attribute must either specify a value-holder or value-type.", getDocumentElement()));
|
||||
throw new BuildFailedException();
|
||||
}//else//
|
||||
|
||||
//Cache the result for efficiency.//
|
||||
getterResultType = result;
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//getMethodReturnType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IMethodPart#getType()
|
||||
*/
|
||||
public IMethodPartType getType() {
|
||||
return (IMethodPartType) getAttributeValue(TYPE);
|
||||
}//getType()//
|
||||
/**
|
||||
* Sets the type value.
|
||||
* @param type The type value.
|
||||
*/
|
||||
private void setType(IMethodPartType type) {
|
||||
setAttributeValue(TYPE, type);
|
||||
}//setType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IMethodPart#getSignature()
|
||||
*/
|
||||
public String getSignature() {
|
||||
return (String) getAttributeValue(SIGNATURE);
|
||||
}//getSignature()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IMethodPart#setSignature(java.lang.String)
|
||||
*/
|
||||
public void setSignature(String signature) {
|
||||
setAttributeValue(SIGNATURE, signature);
|
||||
}//setSignature()//
|
||||
}//MethodPart//
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2004,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.util.xml.INode;
|
||||
|
||||
public class MethodPartType extends ReferencePartType implements IMethodPartType {
|
||||
/**
|
||||
* MethodPartType constructor.
|
||||
*/
|
||||
public MethodPartType() {
|
||||
super();
|
||||
}//MethodPartType()//
|
||||
/**
|
||||
* Reads the model from the XML node.
|
||||
* @param node The node containing model data.
|
||||
*/
|
||||
public void readXml(INode node) {
|
||||
super.readXml(node);
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the model to the XML node.
|
||||
* @param node The node that will receive the model data.
|
||||
*/
|
||||
public void writeXml(INode node) {
|
||||
super.writeXml(node);
|
||||
}//writeXml()//
|
||||
}//MethodPartType//
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2004,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
|
||||
public class PropertyPart extends AbstractModel implements IPropertyPart {
|
||||
public static final Attribute VALUE = registerAttribute(PropertyPart.class, "value");
|
||||
public static final Attribute TYPE = registerAttribute(PropertyPart.class, "type");
|
||||
/**
|
||||
* PropertyPart constructor.
|
||||
* <p><b>Warning: Only public for the purpose of creating reflections.</b></p>
|
||||
*/
|
||||
public PropertyPart() {
|
||||
super();
|
||||
}//PropertyPart()//
|
||||
/**
|
||||
* PropertyPart constructor.
|
||||
*/
|
||||
public PropertyPart(IPropertyPartType type) {
|
||||
this(type, null);
|
||||
}//PropertyPart()//
|
||||
/**
|
||||
* PropertyPart constructor.
|
||||
* @param type The initial property type.
|
||||
* @param value The initial value.
|
||||
*/
|
||||
public PropertyPart(IPropertyPartType type, Object value) {
|
||||
super();
|
||||
|
||||
setType(type);
|
||||
setValue(value);
|
||||
}//PropertyPart()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPropertyPart#getValue()
|
||||
*/
|
||||
public Object getValue() {
|
||||
return (Object) getAttributeValue(VALUE);
|
||||
}//getValue()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPropertyPart#setValue(java.lang.Object)
|
||||
*/
|
||||
public void setValue(Object value) {
|
||||
setAttributeValue(VALUE, value);
|
||||
}//setValue()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPropertyPart#getType()
|
||||
*/
|
||||
public IPropertyPartType getType() {
|
||||
return (IPropertyPartType) getAttributeValue(TYPE);
|
||||
}//getType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPropertyPart#setType(com.foundation.view.definition.PropertyPartType)
|
||||
*/
|
||||
public void setType(IPropertyPartType type) {
|
||||
setAttributeValue(TYPE, type);
|
||||
}//setType()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
public String toString() {
|
||||
return getValue() != null ? getValue().toString() : "null";
|
||||
}//toString()//
|
||||
}//PropertyPart//
|
||||
@@ -0,0 +1,517 @@
|
||||
/*
|
||||
* Copyright (c) 2004,2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
|
||||
import com.common.util.*;
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.*;
|
||||
import com.foundation.view.*;
|
||||
import com.foundation.view.resource.ResourceReference;
|
||||
|
||||
public class PropertyPartType extends AbstractModel implements IPropertyPartType {
|
||||
private static final String NODE_VALUE = "value"; //Used to specify the allowed values for the property.//
|
||||
private static final String NODE_VALUES = "values"; //Used to specify the allowed values for the property.//
|
||||
private static final String ATTRIBUTE_NAME = "name";
|
||||
private static final String ATTRIBUTE_TYPE = "type";
|
||||
private static final String ATTRIBUTE_IS_LIST = "is-list";
|
||||
private static final String ATTRIBUTE_REQUIRED = "required";
|
||||
private static final String ATTRIBUTE_DEFAULT_VALUE = "default-value";
|
||||
private static final String ATTRIBUTE_VALUE_NAME = "name"; //Used to specify the allowed values for the property.//
|
||||
private static final String ATTRIBUTE_ALLOW_RESOURCE = "allow-resource";
|
||||
|
||||
private static final Integer TYPE_NUMBER_UNKNOWN = new Integer(TYPE_UNKNOWN);
|
||||
private static final Integer TYPE_NUMBER_STRING = new Integer(TYPE_STRING);
|
||||
private static final Integer TYPE_NUMBER_INTEGER = new Integer(TYPE_INTEGER);
|
||||
private static final Integer TYPE_NUMBER_POSITIVE_INTEGER = new Integer(TYPE_POSITIVE_INTEGER);
|
||||
private static final Integer TYPE_NUMBER_BOOLEAN = new Integer(TYPE_BOOLEAN);
|
||||
private static final Integer TYPE_NUMBER_COLOR = new Integer(TYPE_COLOR);
|
||||
private static final Integer TYPE_NUMBER_FONT = new Integer(TYPE_FONT);
|
||||
private static final Integer TYPE_NUMBER_IMAGE = new Integer(TYPE_IMAGE);
|
||||
private static final Integer TYPE_NUMBER_LONG = new Integer(TYPE_LONG);
|
||||
private static final Integer TYPE_NUMBER_POSITIVE_LONG = new Integer(TYPE_POSITIVE_LONG);
|
||||
private static final Integer TYPE_NUMBER_FLOAT = new Integer(TYPE_FLOAT);
|
||||
private static final Integer TYPE_NUMBER_POSITIVE_FLOAT = new Integer(TYPE_POSITIVE_FLOAT);
|
||||
private static final Integer TYPE_NUMBER_DOUBLE = new Integer(TYPE_DOUBLE);
|
||||
private static final Integer TYPE_NUMBER_POSITIVE_DOUBLE = new Integer(TYPE_POSITIVE_DOUBLE);
|
||||
private static final Integer TYPE_NUMBER_BIG_DECIMAL = new Integer(TYPE_BIG_DECIMAL);
|
||||
private static final Integer TYPE_NUMBER_CHARACTER = new Integer(TYPE_CHARACTER);
|
||||
private static final Integer TYPE_NUMBER_DATE = new Integer(TYPE_DATE);
|
||||
private static final Integer TYPE_NUMBER_TYPE = new Integer(TYPE_TYPE);
|
||||
private static final Integer TYPE_NUMBER_GRADIENT = new Integer(TYPE_GRADIENT);
|
||||
private static final Integer TYPE_NUMBER_IMAGES = new Integer(TYPE_IMAGES);
|
||||
|
||||
public static final Attribute NAME = registerAttribute(PropertyPartType.class, "name");
|
||||
public static final Attribute TYPE = registerAttribute(PropertyPartType.class, "type");
|
||||
public static final Attribute IS_LIST = registerAttribute(PropertyPartType.class, "isList");
|
||||
public static final Attribute REQUIRED = registerAttribute(PropertyPartType.class, "required");
|
||||
public static final Attribute DEFAULT_VALUE = registerAttribute(PropertyPartType.class, "defaultValue");
|
||||
public static final Attribute VALUES = registerAttribute(PropertyPartType.class, "values");
|
||||
public static final Attribute ALLOW_RESOURCE = registerAttribute(PropertyPartType.class, "allowResource");
|
||||
/**
|
||||
* PropertyPartType constructor.
|
||||
*/
|
||||
public PropertyPartType() {
|
||||
super();
|
||||
}//PropertyPartType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPropertyPartType#convert(java.lang.String)
|
||||
*/
|
||||
public Object convert(String value) {
|
||||
Object result = null;
|
||||
|
||||
if(getIsList().booleanValue()) {
|
||||
//TODO: Support lists of property values. This is not easy for strings.
|
||||
}//if//
|
||||
else {
|
||||
result = internalConvert(value);
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//convert()//
|
||||
/**
|
||||
* Converts the string value into the proper type for the property definition.
|
||||
* @param value The string value.
|
||||
* @return The value in the form of the property type.
|
||||
*/
|
||||
private Object internalConvert(String value) {
|
||||
Object result = null;
|
||||
|
||||
if((getAllowResource() != null) && (getAllowResource().booleanValue()) && (ResourceReference.isResourceUrl(value))) {
|
||||
result = new ResourceReference(value);
|
||||
}//if//
|
||||
else if(value != null) {
|
||||
switch(getType().intValue()) {
|
||||
case TYPE_BOOLEAN: {
|
||||
result = Boolean.valueOf(value.trim());
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_INTEGER: {
|
||||
result = Integer.valueOf(value.trim());
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_POSITIVE_INTEGER: {
|
||||
result = Integer.valueOf(value.trim());
|
||||
|
||||
if((result != null) && (((Integer) result).intValue() < 0)) {
|
||||
result = new Integer(Math.abs(((Integer) result).intValue()));
|
||||
}//if//
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_COLOR: {
|
||||
result = new JefColor(value.trim());
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_FONT: {
|
||||
result = JefFont.getJefFonts(value.trim());
|
||||
break;
|
||||
}//case// {
|
||||
case TYPE_LONG: {
|
||||
try {
|
||||
long temp = Long.parseLong(value.trim());
|
||||
result = new Long(temp);
|
||||
}//try//
|
||||
catch(java.lang.NumberFormatException e) {
|
||||
throw new com.foundation.view.builder.ViewBuilderException("Failed to create Long from the value, '" + value + "', for the property, '" + getName() + "'.", e, -1, -1, -1);
|
||||
}//catch//
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_POSITIVE_LONG: {
|
||||
try {
|
||||
long temp = Long.parseLong(value.trim());
|
||||
result = new Long(Math.abs(temp));
|
||||
}//try//
|
||||
catch(java.lang.NumberFormatException e) {
|
||||
throw new com.foundation.view.builder.ViewBuilderException("Failed to create Long from the value, '" + value + "', for the property, '" + getName() + "'.", e, -1, -1, -1);
|
||||
}//catch//
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_FLOAT: {
|
||||
result = Float.valueOf(value.trim());
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_POSITIVE_FLOAT: {
|
||||
result = Float.valueOf(value.trim());
|
||||
|
||||
if((result != null) && (((Float) result).floatValue() < 0)) {
|
||||
result = new Float(Math.abs(((Float) result).floatValue()));
|
||||
}//if//
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_DOUBLE: {
|
||||
result = Double.valueOf(value.trim());
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_POSITIVE_DOUBLE: {
|
||||
result = Double.valueOf(value.trim());
|
||||
|
||||
if((result != null) && (((Double) result).doubleValue() < 0)) {
|
||||
result = new Double(Math.abs(((Double) result).doubleValue()));
|
||||
}//if//
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_BIG_DECIMAL: {
|
||||
result = new BigDecimal(value.trim());
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_CHARACTER: {
|
||||
result = value.length() > 0 ? new Character(value.charAt(0)) : null;
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_DATE: {
|
||||
try {
|
||||
result = value.length() > 0 ? DEFAULT_DATE_FORMAT.parse(value) : null;
|
||||
}//try//
|
||||
catch(ParseException e) {
|
||||
throw new com.foundation.view.builder.ViewBuilderException("Failed to create Date from the value, '" + value + "', for the property, '" + getName() + "'.", e, -1, -1, -1);
|
||||
}//catch//
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_GRADIENT: {
|
||||
result = new JefGradient(value.trim());
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_TYPE:
|
||||
case TYPE_IMAGE:
|
||||
case TYPE_IMAGES:
|
||||
case TYPE_STRING:
|
||||
default: {
|
||||
result = value;
|
||||
|
||||
if(((String) value).length() == 0) {
|
||||
result = null;
|
||||
}//if//
|
||||
break;
|
||||
}//default//
|
||||
}//switch//
|
||||
}//else if//
|
||||
|
||||
return result;
|
||||
}//internalConvert()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPropertyPartType#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return (String) getAttributeValue(NAME);
|
||||
}//getName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPropertyPartType#setName(java.lang.String)
|
||||
*/
|
||||
public void setName(String name) {
|
||||
setAttributeValue(NAME, name);
|
||||
}//setName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPropertyPartType#getType()
|
||||
*/
|
||||
public Integer getType() {
|
||||
return (Integer) getAttributeValue(TYPE);
|
||||
}//getType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPropertyPartType#setType(java.lang.String)
|
||||
*/
|
||||
public void setType(String type) {
|
||||
int typeNumber = TYPE_UNKNOWN;
|
||||
|
||||
if(TYPE_TEXT_STRING.equals(type)) {
|
||||
typeNumber = TYPE_STRING;
|
||||
}//if//
|
||||
else if(TYPE_TEXT_INTEGER.equals(type)) {
|
||||
typeNumber = TYPE_INTEGER;
|
||||
}//else if//
|
||||
else if(TYPE_TEXT_POSITIVE_INTEGER.equals(type)) {
|
||||
typeNumber = TYPE_POSITIVE_INTEGER;
|
||||
}//else if//
|
||||
else if(TYPE_TEXT_BOOLEAN.equals(type)) {
|
||||
typeNumber = TYPE_BOOLEAN;
|
||||
}//else if//
|
||||
else if(TYPE_TEXT_COLOR.equals(type)) {
|
||||
typeNumber = TYPE_COLOR;
|
||||
}//else if//
|
||||
else if(TYPE_TEXT_FONT.equals(type)) {
|
||||
typeNumber = TYPE_FONT;
|
||||
}//else if//
|
||||
else if(TYPE_TEXT_IMAGE.equals(type)) {
|
||||
typeNumber = TYPE_IMAGE;
|
||||
}//else if//
|
||||
else if(TYPE_TEXT_IMAGES.equals(type)) {
|
||||
typeNumber = TYPE_IMAGES;
|
||||
}//else if//
|
||||
else if(TYPE_TEXT_LONG.equals(type)) {
|
||||
typeNumber = TYPE_LONG;
|
||||
}//else if//
|
||||
else if(TYPE_TEXT_POSITIVE_LONG.equals(type)) {
|
||||
typeNumber = TYPE_POSITIVE_LONG;
|
||||
}//else if//
|
||||
else if(TYPE_TEXT_FLOAT.equals(type)) {
|
||||
typeNumber = TYPE_FLOAT;
|
||||
}//else if//
|
||||
else if(TYPE_TEXT_POSITIVE_FLOAT.equals(type)) {
|
||||
typeNumber = TYPE_POSITIVE_FLOAT;
|
||||
}//else if//
|
||||
else if(TYPE_TEXT_DOUBLE.equals(type)) {
|
||||
typeNumber = TYPE_DOUBLE;
|
||||
}//else if//
|
||||
else if(TYPE_TEXT_POSITIVE_DOUBLE.equals(type)) {
|
||||
typeNumber = TYPE_POSITIVE_DOUBLE;
|
||||
}//else if//
|
||||
else if(TYPE_TEXT_BIG_DECIMAL.equals(type)) {
|
||||
typeNumber = TYPE_BIG_DECIMAL;
|
||||
}//else if//
|
||||
else if(TYPE_TEXT_CHARACTER.equals(type)) {
|
||||
typeNumber = TYPE_CHARACTER;
|
||||
}//else if//
|
||||
else if(TYPE_TEXT_CHARACTER.equals(type)) {
|
||||
typeNumber = TYPE_CHARACTER;
|
||||
}//else if//
|
||||
else if(TYPE_TEXT_DATE.equals(type)) {
|
||||
typeNumber = TYPE_DATE;
|
||||
}//else if//
|
||||
else if(TYPE_TEXT_TYPE.equals(type)) {
|
||||
typeNumber = TYPE_TYPE;
|
||||
}//else if//
|
||||
else if(TYPE_TEXT_GRADIENT.equals(type)) {
|
||||
typeNumber = TYPE_GRADIENT;
|
||||
}//else if//
|
||||
|
||||
setType(typeNumber);
|
||||
}//setType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPropertyPartType#setType(int)
|
||||
*/
|
||||
public void setType(int type) {
|
||||
Integer typeNumber = null;
|
||||
|
||||
switch(type) {
|
||||
case TYPE_STRING: {
|
||||
typeNumber = TYPE_NUMBER_STRING;
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_BOOLEAN: {
|
||||
typeNumber = TYPE_NUMBER_BOOLEAN;
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_POSITIVE_INTEGER: {
|
||||
typeNumber = TYPE_NUMBER_POSITIVE_INTEGER;
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_INTEGER: {
|
||||
typeNumber = TYPE_NUMBER_INTEGER;
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_COLOR: {
|
||||
typeNumber = TYPE_NUMBER_COLOR;
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_FONT: {
|
||||
typeNumber = TYPE_NUMBER_FONT;
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_IMAGE: {
|
||||
typeNumber = TYPE_NUMBER_IMAGE;
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_IMAGES: {
|
||||
typeNumber = TYPE_NUMBER_IMAGES;
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_LONG: {
|
||||
typeNumber = TYPE_NUMBER_LONG;
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_POSITIVE_LONG: {
|
||||
typeNumber = TYPE_NUMBER_POSITIVE_LONG;
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_FLOAT: {
|
||||
typeNumber = TYPE_NUMBER_FLOAT;
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_POSITIVE_FLOAT: {
|
||||
typeNumber = TYPE_NUMBER_POSITIVE_FLOAT;
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_DOUBLE: {
|
||||
typeNumber = TYPE_NUMBER_DOUBLE;
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_POSITIVE_DOUBLE: {
|
||||
typeNumber = TYPE_NUMBER_POSITIVE_DOUBLE;
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_BIG_DECIMAL: {
|
||||
typeNumber = TYPE_NUMBER_BIG_DECIMAL;
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_CHARACTER: {
|
||||
typeNumber = TYPE_NUMBER_CHARACTER;
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_DATE: {
|
||||
typeNumber = TYPE_NUMBER_DATE;
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_TYPE: {
|
||||
typeNumber = TYPE_NUMBER_TYPE;
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_GRADIENT: {
|
||||
typeNumber = TYPE_NUMBER_GRADIENT;
|
||||
break;
|
||||
}//case//
|
||||
default: {
|
||||
typeNumber = TYPE_NUMBER_UNKNOWN;
|
||||
break;
|
||||
}//default//
|
||||
}//switch//
|
||||
|
||||
setType(typeNumber);
|
||||
}//setType()//
|
||||
/**
|
||||
* Sets the type number.
|
||||
* @param type The type number.
|
||||
*/
|
||||
private void setType(Integer type) {
|
||||
setAttributeValue(TYPE, type);
|
||||
}//setType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPropertyPartType#getIsList()
|
||||
*/
|
||||
public Boolean getIsList() {
|
||||
return (Boolean) getAttributeValue(IS_LIST);
|
||||
}//getIsList()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPropertyPartType#setIsList(java.lang.Boolean)
|
||||
*/
|
||||
public void setIsList(Boolean isList) {
|
||||
setAttributeValue(IS_LIST, isList);
|
||||
}//setIsList()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPropertyPartType#getRequired()
|
||||
*/
|
||||
public Boolean getRequired() {
|
||||
return (Boolean) getAttributeValue(REQUIRED);
|
||||
}//getRequired()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPropertyPartType#setRequired(java.lang.Boolean)
|
||||
*/
|
||||
public void setRequired(Boolean required) {
|
||||
setAttributeValue(REQUIRED, required);
|
||||
}//setRequired()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPropertyPartType#getAllowResource()
|
||||
*/
|
||||
public Boolean getAllowResource() {
|
||||
return (Boolean) getAttributeValue(ALLOW_RESOURCE);
|
||||
}//getAllowResource()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPropertyPartType#setAllowResource(java.lang.Boolean)
|
||||
*/
|
||||
public void setAllowResource(Boolean allowResource) {
|
||||
setAttributeValue(ALLOW_RESOURCE, allowResource);
|
||||
}//setAllowResource()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPropertyPartType#getDefaultValue()
|
||||
*/
|
||||
public Object getDefaultValue() {
|
||||
return (Object) getAttributeValue(DEFAULT_VALUE);
|
||||
}//getDefaultValue()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPropertyPartType#setDefaultValue(java.lang.Object)
|
||||
*/
|
||||
public void setDefaultValue(Object defaultValue) {
|
||||
setAttributeValue(DEFAULT_VALUE, defaultValue);
|
||||
}//setDefaultValue()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPropertyPartType#getValues()
|
||||
*/
|
||||
public IList getValues() {
|
||||
return (IList) getAttributeValue(VALUES);
|
||||
}//getValues()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IPropertyPartType#setValues(com.common.util.IList)
|
||||
*/
|
||||
public void setValues(IList values) {
|
||||
setAttributeValue(VALUES, values);
|
||||
}//setValues()//
|
||||
/**
|
||||
* Reads the model from the XML node.
|
||||
* @param node The node containing model data.
|
||||
*/
|
||||
public void readXml(INode node) {
|
||||
IIterator iterator = node.getElements().iterator();
|
||||
|
||||
setName(node.getAttributeValue(ATTRIBUTE_NAME, true, true));
|
||||
setType(node.getAttributeValue(ATTRIBUTE_TYPE, true, true));
|
||||
setIsList(readBoolean(node.getAttributeValue(ATTRIBUTE_IS_LIST, true, true), Boolean.FALSE));
|
||||
setRequired(readBoolean(node.getAttributeValue(ATTRIBUTE_REQUIRED, true, true), Boolean.FALSE));
|
||||
setDefaultValue(convert(node.getAttributeValue(ATTRIBUTE_DEFAULT_VALUE, true, true)));
|
||||
setAllowResource(readBoolean(node.getAttributeValue(ATTRIBUTE_ALLOW_RESOURCE, true, true), Boolean.FALSE));
|
||||
|
||||
while(iterator.hasNext()) {
|
||||
IElement nextElement = (IElement) iterator.next();
|
||||
|
||||
if(nextElement.isNode()) {
|
||||
INode nextNode = (INode) nextElement;
|
||||
|
||||
if(NODE_VALUES.equals(nextNode.getName())) {
|
||||
if(getValues() == null) {
|
||||
IList values = new LiteList(10, 20);
|
||||
|
||||
setValues(values);
|
||||
//Load the values into the collection.//
|
||||
loadValues(nextNode, values);
|
||||
}//if//
|
||||
else {
|
||||
//TODO: Warn the user that the values node may only be specified once. Multiple specifications will be ignored.//
|
||||
}//else//
|
||||
}//if//
|
||||
else {
|
||||
//TODO: Warn the user that the given node is not valid and will be ignored.//
|
||||
}//else//
|
||||
}//if//
|
||||
}//while//
|
||||
}//readXml()//
|
||||
/**
|
||||
* Loads the property values from the values node.
|
||||
* @param node The node containing the value nodes which specify valid values for the property.
|
||||
* @param values The collection that will accept new values.
|
||||
*/
|
||||
private void loadValues(INode node, IList values) {
|
||||
IIterator iterator = node.getElements().iterator();
|
||||
|
||||
while(iterator.hasNext()) {
|
||||
IElement nextElement = (IElement) iterator.next();
|
||||
|
||||
if(nextElement.isNode()) {
|
||||
INode nextNode = (INode) nextElement;
|
||||
|
||||
if(NODE_VALUE.equals(nextNode)) {
|
||||
String name = nextNode.getAttributeValue(ATTRIBUTE_VALUE_NAME, true, true);
|
||||
|
||||
if(name != null) {
|
||||
values.add(name);
|
||||
}//if//
|
||||
else {
|
||||
//TODO: Warn the user that the given node is does not contain the name attribute and will be ignored.//
|
||||
}//else//
|
||||
}//if//
|
||||
else {
|
||||
//TODO: Warn the user that the given node is not valid and will be ignored.//
|
||||
}//else//
|
||||
}//if//
|
||||
}//while//
|
||||
}//loadValues()//
|
||||
/**
|
||||
* Writes the model to the XML node.
|
||||
* @param node The node that will receive the model data.
|
||||
*/
|
||||
public void writeXml(INode node) {
|
||||
}//writeXml()//
|
||||
}//PropertyPartType//
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2004,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.IElement;
|
||||
|
||||
public class ReferencePart extends AbstractPart implements IReferencePart {
|
||||
public static final Attribute NAME = registerAttribute(ReferencePart.class, "name");
|
||||
public static final Attribute VALUE_HOLDER_NAME = registerAttribute(ReferencePart.class, "valueHolderName");
|
||||
public static final Attribute HELD_TYPE_NAME = registerAttribute(ReferencePart.class, "heldTypeName");
|
||||
public static final Attribute ROW_TYPE_NAME = registerAttribute(ReferencePart.class, "rowTypeName");
|
||||
/**
|
||||
* ReferencePart constructor.
|
||||
* <p><b>Warning: Only public for the purpose of creating reflections.</b></p>
|
||||
*/
|
||||
public ReferencePart() {
|
||||
}//ReferencePart()//
|
||||
/**
|
||||
* ReferencePart constructor.
|
||||
* @param component The component that this reference is a part of.
|
||||
* @param name The name for the reference part which is dependant on the reference part type.
|
||||
* @param valueHolderName The name of the value holder associated with the part.
|
||||
* @param heldTypeName The qualified class name for the class of value held by the value holder for which this reference is valid.
|
||||
* @param rowTypeName The qualified class name defining which row or data objects this reference is good for.
|
||||
* @param documentElement The optional element of the document that defines this part. This is used for debugging.
|
||||
*/
|
||||
public ReferencePart(IComponentData component, String name, String valueHolderName, String heldTypeName, String rowTypeName, IElement documentElement) {
|
||||
super(component);
|
||||
setDocumentElement(documentElement);
|
||||
setName(name);
|
||||
setValueHolderName(valueHolderName);
|
||||
setHeldTypeName(heldTypeName);
|
||||
setRowTypeName(rowTypeName);
|
||||
}//ReferencePart()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IReferencePart#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return (String) getAttributeValue(NAME);
|
||||
}//getName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IReferencePart#setName(java.lang.String)
|
||||
*/
|
||||
public void setName(String name) {
|
||||
setAttributeValue(NAME, name);
|
||||
}//setName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IReferencePart#getValueHolderName()
|
||||
*/
|
||||
public String getValueHolderName() {
|
||||
return (String) getAttributeValue(VALUE_HOLDER_NAME);
|
||||
}//getValueHolderName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IReferencePart#setValueHolderName(java.lang.String)
|
||||
*/
|
||||
public void setValueHolderName(String valueHolderName) {
|
||||
setAttributeValue(VALUE_HOLDER_NAME, valueHolderName);
|
||||
}//setValueHolderName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IReferencePart#getHeldTypeName()
|
||||
*/
|
||||
public String getHeldTypeName() {
|
||||
return (String) getAttributeValue(HELD_TYPE_NAME);
|
||||
}//getHeldTypeName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IReferencePart#setHeldTypeName(java.lang.String)
|
||||
*/
|
||||
public void setHeldTypeName(String heldTypeName) {
|
||||
setAttributeValue(HELD_TYPE_NAME, heldTypeName);
|
||||
}//setHeldTypeName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IReferencePart#getRowTypeName()
|
||||
*/
|
||||
public String getRowTypeName() {
|
||||
return (String) getAttributeValue(ROW_TYPE_NAME);
|
||||
}//getRowTypeName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IReferencePart#setRowTypeName(java.lang.String)
|
||||
*/
|
||||
public void setRowTypeName(String rowTypeName) {
|
||||
setAttributeValue(ROW_TYPE_NAME, rowTypeName);
|
||||
}//setRowTypeName()//
|
||||
}//ReferencePart//
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 2004,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.INode;
|
||||
|
||||
public class ReferencePartType extends AbstractModel implements IReferencePartType {
|
||||
public static final Attribute FUNCTION = registerAttribute(ReferencePartType.class, "function");
|
||||
public static final Attribute REQUIRED = registerAttribute(ReferencePartType.class, "required");
|
||||
public static final Attribute REQUIRES_VALUE_HOLDER = registerAttribute(ReferencePartType.class, "requiresValueHolder");
|
||||
public static final Attribute MULTIPLE = registerAttribute(ReferencePartType.class, "multiple");
|
||||
/**
|
||||
* ReferencePartType constructor.
|
||||
*/
|
||||
public ReferencePartType() {
|
||||
super();
|
||||
}//ReferencePartType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IReferencePartType#getFunction()
|
||||
*/
|
||||
public String getFunction() {
|
||||
return (String) getAttributeValue(FUNCTION);
|
||||
}//getFunction()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IReferencePartType#setFunction(java.lang.String)
|
||||
*/
|
||||
public void setFunction(String function) {
|
||||
setAttributeValue(FUNCTION, function);
|
||||
}//setFunction()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IReferencePartType#getRequired()
|
||||
*/
|
||||
public Boolean getRequired() {
|
||||
return (Boolean) getAttributeValue(REQUIRED);
|
||||
}//getRequired()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IReferencePartType#setRequired(java.lang.Boolean)
|
||||
*/
|
||||
public void setRequired(Boolean required) {
|
||||
setAttributeValue(REQUIRED, required);
|
||||
}//setRequired()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IReferencePartType#getRequiresValueHolder()
|
||||
*/
|
||||
public Boolean getRequiresValueHolder() {
|
||||
return (Boolean) getAttributeValue(REQUIRES_VALUE_HOLDER);
|
||||
}//getRequiresValueHolder()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IReferencePartType#setRequiresValueHolder(java.lang.Boolean)
|
||||
*/
|
||||
public void setRequiresValueHolder(Boolean requiresValueHolder) {
|
||||
setAttributeValue(REQUIRES_VALUE_HOLDER, requiresValueHolder);
|
||||
}//setRequiresValueHolder()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IReferencePartType#getMultiple()
|
||||
*/
|
||||
public Boolean getMultiple() {
|
||||
return (Boolean) getAttributeValue(MULTIPLE);
|
||||
}//getMultiple()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IReferencePartType#setMultiple(java.lang.Boolean)
|
||||
*/
|
||||
public void setMultiple(Boolean multiple) {
|
||||
setAttributeValue(MULTIPLE, multiple);
|
||||
}//setMultiple()//
|
||||
/**
|
||||
* Reads the model from the XML node.
|
||||
* @param node The node containing model data.
|
||||
*/
|
||||
public void readXml(INode node) {
|
||||
setFunction(node.getAttributeValue(ATTRIBUTE_FUNCTION, true, true));
|
||||
setRequired(readBoolean(node.getAttributeValue(ATTRIBUTE_REQUIRED, true, true), Boolean.FALSE));
|
||||
setRequiresValueHolder(readBoolean(node.getAttributeValue(ATTRIBUTE_REQUIRES_VALUE_HOLDER, true, true), Boolean.TRUE));
|
||||
setMultiple(readBoolean(node.getAttributeValue(ATTRIBUTE_MULTIPLE, true, true), Boolean.TRUE));
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the model to the XML node.
|
||||
* @param node The node that will receive the model data.
|
||||
*/
|
||||
public void writeXml(INode node) {
|
||||
}//writeXml()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return object != null && getClass().equals(object.getClass()) && (getFunction().equals(((IReferencePartType) object).getFunction()));
|
||||
}//equals()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
public int hashCode() {
|
||||
return getFunction().hashCode();
|
||||
}//hashCode()//
|
||||
}//ReferencePartType//
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2004,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.INode;
|
||||
|
||||
public class StyleAlteration extends AbstractModel implements IStyleAlteration {
|
||||
private static final String ATTRIBUTE_NAME = "name";
|
||||
private static final String ATTRIBUTE_VALUE = "value";
|
||||
|
||||
public static final Attribute NAME = registerAttribute(StyleAlteration.class, "name");
|
||||
public static final Attribute VALUE = registerAttribute(StyleAlteration.class, "value");
|
||||
/**
|
||||
* StyleAlteration constructor.
|
||||
*/
|
||||
public StyleAlteration() {
|
||||
super();
|
||||
}//StyleAlteration()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IStyleAlteration#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return (String) getAttributeValue(NAME);
|
||||
}//getName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IStyleAlteration#setName(java.lang.String)
|
||||
*/
|
||||
public void setName(String name) {
|
||||
setAttributeValue(NAME, name);
|
||||
}//setName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IStyleAlteration#getValue()
|
||||
*/
|
||||
public Boolean getValue() {
|
||||
return (Boolean) getAttributeValue(VALUE);
|
||||
}//getValue()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IStyleAlteration#setValue(java.lang.Boolean)
|
||||
*/
|
||||
public void setValue(Boolean value) {
|
||||
setAttributeValue(VALUE, value);
|
||||
}//setValue()//
|
||||
/**
|
||||
* Reads the model from the XML node.
|
||||
* @param node The node containing model data.
|
||||
*/
|
||||
public void readXml(INode node) {
|
||||
setName(node.getAttributeValue(ATTRIBUTE_NAME, true, true));
|
||||
setValue(readBoolean(node.getAttributeValue(ATTRIBUTE_VALUE, true, true), Boolean.FALSE));
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the model to the XML node.
|
||||
* @param node The node that will receive the model data.
|
||||
*/
|
||||
public void writeXml(INode node) {
|
||||
}//writeXml()//
|
||||
}//StyleAlteration//
|
||||
97
Vml Builder/src/com/foundation/view/definition/StyleSet.java
Normal file
97
Vml Builder/src/com/foundation/view/definition/StyleSet.java
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2004,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.common.util.IIterator;
|
||||
import com.common.util.IList;
|
||||
import com.common.util.LiteList;
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.util.xml.INode;
|
||||
|
||||
public class StyleSet extends AbstractModel implements IStyleSet {
|
||||
private static final String ATTRIBUTE_NAME = "name";
|
||||
private static final String NODE_ALTER = "alter";
|
||||
|
||||
public static final Attribute NAME = registerAttribute(StyleSet.class, "name");
|
||||
public static final Attribute ALTERATIONS = registerAttribute(StyleSet.class, "alterations");
|
||||
/**
|
||||
* StyleSet constructor.
|
||||
*/
|
||||
public StyleSet() {
|
||||
super();
|
||||
setAlterations(new LiteList(1, 5));
|
||||
}//StyleSet()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IStyleSet#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return (String) getAttributeValue(NAME);
|
||||
}//getName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IStyleSet#setName(java.lang.String)
|
||||
*/
|
||||
public void setName(String name) {
|
||||
setAttributeValue(NAME, name);
|
||||
}//setName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IStyleSet#getAlterations()
|
||||
*/
|
||||
public IList getAlterations() {
|
||||
return (IList) getAttributeValue(ALTERATIONS);
|
||||
}//getAlterations()//
|
||||
/**
|
||||
* Sets the collection of style alterations to be applied when this style is turned on.
|
||||
* @param alterations The alterations list to be applied when setting this style.
|
||||
*/
|
||||
private void setAlterations(IList alterations) {
|
||||
setAttributeValue(ALTERATIONS, alterations);
|
||||
}//setNewAttribute()//
|
||||
/**
|
||||
* Reads the model from the XML node.
|
||||
* @param node The node containing model data.
|
||||
*/
|
||||
public void readXml(INode node) {
|
||||
IIterator iterator = null;
|
||||
|
||||
setName(node.getAttributeValue(ATTRIBUTE_NAME, true, true));
|
||||
|
||||
iterator = node.getElements().iterator();
|
||||
|
||||
while(iterator.hasNext()) {
|
||||
IElement next = (IElement) iterator.next();
|
||||
|
||||
if(next.isNode()) {
|
||||
INode subNode = (INode) next;
|
||||
String subNodeName = subNode.getName();
|
||||
|
||||
if(NODE_ALTER.equals(subNodeName)) {
|
||||
StyleAlteration styleAlteration = new StyleAlteration();
|
||||
|
||||
styleAlteration.readXml(subNode);
|
||||
getAlterations().add(styleAlteration);
|
||||
}//if//
|
||||
else {
|
||||
//Unexpected node type. Will ignore.//
|
||||
}//else//
|
||||
}//if//
|
||||
}//while//
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the model to the XML node.
|
||||
* @param node The node that will receive the model data.
|
||||
*/
|
||||
public void writeXml(INode node) {
|
||||
}//writeXml()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
public String toString() {
|
||||
return super.toString() + " " + getName();
|
||||
}//toString()//
|
||||
}//StyleSet//
|
||||
111
Vml Builder/src/com/foundation/view/definition/StyleType.java
Normal file
111
Vml Builder/src/com/foundation/view/definition/StyleType.java
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2004,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.common.util.*;
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.util.xml.INode;
|
||||
|
||||
public class StyleType extends AbstractModel implements IStyleType {
|
||||
private static final String ATTRIBUTE_NAME = "name";
|
||||
private static final String ATTRIBUTE_REQUIRED = "required";
|
||||
//private static final String ATTRIBUTE_VALUE = "value";
|
||||
private static final String NODE_ALTER = "alter";
|
||||
|
||||
public static final Attribute NAME = registerAttribute(StyleType.class, "name");
|
||||
public static final Attribute REQUIRED = registerAttribute(StyleType.class, "required");
|
||||
public static final Attribute ALTERATIONS = registerAttribute(StyleType.class, "alterations");
|
||||
/**
|
||||
* StyleType constructor.
|
||||
*/
|
||||
public StyleType() {
|
||||
super();
|
||||
setAlterations(new LiteList(1, 5));
|
||||
}//StyleType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IStyleType#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return (String) getAttributeValue(NAME);
|
||||
}//getName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IStyleType#setName(java.lang.String)
|
||||
*/
|
||||
public void setName(String name) {
|
||||
setAttributeValue(NAME, name);
|
||||
}//setName()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IStyleType#getRequired()
|
||||
*/
|
||||
public Boolean getRequired() {
|
||||
return (Boolean) getAttributeValue(REQUIRED);
|
||||
}//getRequired()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IStyleType#setRequired(java.lang.Boolean)
|
||||
*/
|
||||
public void setRequired(Boolean required) {
|
||||
setAttributeValue(REQUIRED, required);
|
||||
}//setRequired()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IStyleType#getAlterations()
|
||||
*/
|
||||
public IList getAlterations() {
|
||||
return (IList) getAttributeValue(ALTERATIONS);
|
||||
}//getAlterations()//
|
||||
/**
|
||||
* Sets the collection of style alterations to be applied when this style is turned on.
|
||||
* @param alterations The alterations list to be applied when setting this style.
|
||||
*/
|
||||
private void setAlterations(IList alterations) {
|
||||
setAttributeValue(ALTERATIONS, alterations);
|
||||
}//setNewAttribute()//
|
||||
/**
|
||||
* Reads the model from the XML node.
|
||||
* @param node The node containing model data.
|
||||
*/
|
||||
public void readXml(INode node) {
|
||||
IIterator iterator = null;
|
||||
|
||||
setName(node.getAttributeValue(ATTRIBUTE_NAME, true, true));
|
||||
setRequired(readBoolean(node.getAttributeValue(ATTRIBUTE_REQUIRED, true, true), Boolean.FALSE));
|
||||
|
||||
iterator = node.getElements().iterator();
|
||||
|
||||
while(iterator.hasNext()) {
|
||||
IElement next = (IElement) iterator.next();
|
||||
|
||||
if(next.isNode()) {
|
||||
INode subNode = (INode) next;
|
||||
String subNodeName = subNode.getName();
|
||||
|
||||
if(NODE_ALTER.equals(subNodeName)) {
|
||||
StyleAlteration styleAlteration = new StyleAlteration();
|
||||
|
||||
styleAlteration.readXml(subNode);
|
||||
getAlterations().add(styleAlteration);
|
||||
}//if//
|
||||
else {
|
||||
//Unexpected node type. Will ignore.//
|
||||
}//else//
|
||||
}//if//
|
||||
}//while//
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the model to the XML node.
|
||||
* @param node The node that will receive the model data.
|
||||
*/
|
||||
public void writeXml(INode node) {
|
||||
}//writeXml()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
public String toString() {
|
||||
return super.toString() + " " + getName();
|
||||
}//toString()//
|
||||
}//StyleType//
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2004,2008 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.definition;
|
||||
|
||||
import com.foundation.metadata.Attribute;
|
||||
|
||||
public class ViewMetadata extends AbstractModel implements IViewMetadata {
|
||||
public static final Attribute PACKAGE = registerAttribute(ViewMetadata.class, "package");
|
||||
public static final Attribute PLATFORM = registerAttribute(ViewMetadata.class, "platform");
|
||||
public static final Attribute REFLECTION_METADATA = registerAttribute(ViewMetadata.class, "reflectionMetadata");
|
||||
/**
|
||||
* ViewMetadata constructor.
|
||||
*/
|
||||
public ViewMetadata() {
|
||||
super();
|
||||
}//ViewMetadata()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IViewMetadata#getPackage()
|
||||
*/
|
||||
public String getPackage() {
|
||||
return (String) getAttributeValue(PACKAGE);
|
||||
}//getPackage()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IViewMetadata#setPackage(java.lang.String)
|
||||
*/
|
||||
public void setPackage(String packageName) {
|
||||
setAttributeValue(PACKAGE, packageName);
|
||||
}//setPackage()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IViewMetadata#getPlatform()
|
||||
*/
|
||||
public IPlatform getPlatform() {
|
||||
return (IPlatform) getAttributeValue(PLATFORM);
|
||||
}//getPlatform()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IViewMetadata#setPlatform(com.foundation.view.definition.BuilderDefinition.Platform)
|
||||
*/
|
||||
public void setPlatform(IPlatform platform) {
|
||||
setAttributeValue(PLATFORM, platform);
|
||||
}//setPlatform()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IViewMetadata#getReflectionMetadata()
|
||||
*/
|
||||
public IReflectionMetadata getReflectionMetadata() {
|
||||
return (IReflectionMetadata) getAttributeValue(REFLECTION_METADATA);
|
||||
}//getReflectionMetadata()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.definition.IViewMetadata#setReflectionMetadata(com.foundation.view.definition.IReflectionMetadata)
|
||||
*/
|
||||
public void setReflectionMetadata(IReflectionMetadata reflectionMetadata) {
|
||||
setAttributeValue(REFLECTION_METADATA, reflectionMetadata);
|
||||
}//setReflectionMetadata()//
|
||||
}//ViewMetadata//
|
||||
2315
Vml Builder/src/com/foundation/view/definition/ViewModel.java
Normal file
2315
Vml Builder/src/com/foundation/view/definition/ViewModel.java
Normal file
File diff suppressed because it is too large
Load Diff
77
Vml Builder/src/com/foundation/view/resource/ImageData.java
Normal file
77
Vml Builder/src/com/foundation/view/resource/ImageData.java
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.resource;
|
||||
|
||||
import com.common.util.StringSupport;
|
||||
import com.foundation.model.Model;
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.xml.INode;
|
||||
|
||||
public class ImageData extends Model {
|
||||
private static final String XML_BYTES = "bytes";
|
||||
private static final String XML_NAME = "name";
|
||||
|
||||
public static final Attribute BYTES = registerAttribute(ImageData.class, "bytes");
|
||||
public static final Attribute NAME = registerAttribute(ImageData.class, "name");
|
||||
/**
|
||||
* ImageData constructor.
|
||||
*/
|
||||
public ImageData() {
|
||||
}//ImageData()//
|
||||
/**
|
||||
* ImageData constructor.
|
||||
* @param bytes The image data.
|
||||
*/
|
||||
public ImageData(byte[] bytes) {
|
||||
setBytes(bytes);
|
||||
}//ImageData()//
|
||||
/**
|
||||
* Reads the object data from the xml node.
|
||||
* @param imageDataNode The node to read from.
|
||||
*/
|
||||
public void readXml(INode imageDataNode) {
|
||||
setBytes(StringSupport.fromHexString(imageDataNode.getAttributeValue(XML_BYTES, true, true)));
|
||||
setName(imageDataNode.getAttributeValue(XML_NAME, true, true));
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the object data to the xml node.
|
||||
* @param imageDataNode The node to write to.
|
||||
*/
|
||||
public void writeXml(INode imageDataNode) {
|
||||
imageDataNode.addAttribute(XML_BYTES, StringSupport.toHexString(getBytes()));
|
||||
imageDataNode.addAttribute(XML_NAME, getName());
|
||||
}//writeXml()//
|
||||
/**
|
||||
* Gets the image bytes.
|
||||
* @return The bytes.
|
||||
*/
|
||||
public byte[] getBytes() {
|
||||
return (byte[]) getAttributeValue(BYTES);
|
||||
}//getBytes()//
|
||||
/**
|
||||
* Sets the image bytes.
|
||||
* @param bytes The bytes.
|
||||
*/
|
||||
public void setBytes(byte[] bytes) {
|
||||
setAttributeValue(BYTES, bytes);
|
||||
}//setBytes()//
|
||||
/**
|
||||
* Gets the original file name (including extension).
|
||||
* @return The name.
|
||||
*/
|
||||
public String getName() {
|
||||
return (String) getAttributeValue(NAME);
|
||||
}//getName()//
|
||||
/**
|
||||
* Sets the original file name (including extension).
|
||||
* @param name The name.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
setAttributeValue(NAME, name);
|
||||
}//setName()//
|
||||
}//ImageData//
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.resource;
|
||||
|
||||
import com.foundation.model.Model;
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.util.IManagedList;
|
||||
import com.foundation.util.ManagedList;
|
||||
|
||||
/**
|
||||
* Encapsulates a set of ImageData instances.
|
||||
*/
|
||||
public class ImageDataSet extends Model {
|
||||
public static final Attribute IMAGE_DATA = registerCollection(ImageDataSet.class, "imageData", AO_PART_OF | AO_LAZY);
|
||||
/**
|
||||
* ImageDataSet constructor.
|
||||
*/
|
||||
public ImageDataSet() {
|
||||
}//ImageDataSet()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.common.Entity#lazyLoadAttribute(com.foundation.metadata.Attribute)
|
||||
*/
|
||||
protected Object lazyLoadAttribute(Attribute attribute) {
|
||||
Object result = null;
|
||||
|
||||
if(attribute == IMAGE_DATA) {
|
||||
result = new ManagedList(10, 100);
|
||||
}//if//
|
||||
else {
|
||||
result = super.lazyLoadAttribute(attribute);
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//lazyLoadAttribute()//
|
||||
/**
|
||||
* Gets the collecton of ImageData instances.
|
||||
* @return The set of all ImageData objects.
|
||||
*/
|
||||
public IManagedList getImageData() {
|
||||
return (IManagedList) getAttributeValue(IMAGE_DATA);
|
||||
}//getImageData()//
|
||||
}//ImageDataSet//
|
||||
308
Vml Builder/src/com/foundation/view/resource/XmlResource.java
Normal file
308
Vml Builder/src/com/foundation/view/resource/XmlResource.java
Normal file
@@ -0,0 +1,308 @@
|
||||
/*
|
||||
* Copyright (c) 2006,2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.resource;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import com.common.comparison.Comparator;
|
||||
import com.common.debug.Debug;
|
||||
import com.common.util.IIterator;
|
||||
import com.common.util.LiteList;
|
||||
import com.common.util.StringSupport;
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.model.Model;
|
||||
import com.foundation.util.xml.IAbstractNode;
|
||||
import com.foundation.util.xml.INode;
|
||||
import com.foundation.view.JefColor;
|
||||
import com.foundation.view.JefFont;
|
||||
import com.foundation.view.JefGradient;
|
||||
|
||||
public class XmlResource extends Model implements IResource {
|
||||
private static final DateFormat DEFAULT_DATE_FORMATTER = SimpleDateFormat.getDateTimeInstance();
|
||||
public static final String XML_NODE = "resource";
|
||||
public static final String XML_ATTRIBUTE_NAME = "id";
|
||||
public static final String XML_ATTRIBUTE_TYPE = "type";
|
||||
public static final String XML_ATTRIBUTE_VALUE = "value";
|
||||
public static final String XML_ATTRIBUTE_VALUE_METADATA = "value-metadata";
|
||||
public static final String XML_NODE_VALUE = "value";
|
||||
|
||||
/** The resource's name which is used to reference the resource. */
|
||||
public static final Attribute NAME = registerAttribute(XmlResource.class, "name");
|
||||
/** The resource type which defines the value's type. */
|
||||
public static final Attribute TYPE = registerAttribute(XmlResource.class, "type", new Integer(IResource.TYPE_STRING));
|
||||
/** The actual value for the resource. */
|
||||
public static final Attribute VALUE = registerAttribute(XmlResource.class, "value", AO_PART_OF);
|
||||
/** The value's optional metadata which can make editing the resources easier. */
|
||||
public static final Attribute VALUE_METADATA = registerAttribute(XmlResource.class, "valueMetadata");
|
||||
public static final Attribute PARENT = registerAttribute(XmlResource.class, "parent", XmlResourceCategory.class);
|
||||
/**
|
||||
* XmlResource constructor.
|
||||
*/
|
||||
public XmlResource() {
|
||||
super();
|
||||
}//XmlResource()//
|
||||
/**
|
||||
* XmlResource constructor.
|
||||
* @param resourceNode The resource node that contains the data for this resource.
|
||||
*/
|
||||
public XmlResource(INode resourceNode) {
|
||||
super();
|
||||
readXml(resourceNode);
|
||||
}//XmlResource()//
|
||||
/**
|
||||
* Reads the resource from XML.
|
||||
* @param node The node containing this object's data.
|
||||
*/
|
||||
public void readXml(IAbstractNode node) {
|
||||
String typeName = node.getAttributeValue(XML_ATTRIBUTE_TYPE, true, true);
|
||||
Integer typeNumber = (Integer) IResource.typeNameToNumberMap.get(typeName);
|
||||
|
||||
if(typeNumber == null) {
|
||||
typeNumber = new Integer(IResource.TYPE_STRING);
|
||||
Debug.log(new RuntimeException("Error: Missing or malformed type attribute in the resource with the name '" + node.getAttributeValue(XML_ATTRIBUTE_NAME, false, false) + "'."));
|
||||
}//if//
|
||||
|
||||
setAttributeValue(NAME, node.getAttributeValue(XML_ATTRIBUTE_NAME, false, false));
|
||||
setAttributeValue(TYPE, typeNumber);
|
||||
setAttributeValue(VALUE_METADATA, node.getAttributeValue(XML_ATTRIBUTE_VALUE_METADATA, true, true));
|
||||
|
||||
switch(getType().intValue()) {
|
||||
case IResource.TYPE_IMAGE: {
|
||||
if(node.hasAttribute(XML_ATTRIBUTE_VALUE)) {
|
||||
String hexData = node.getAttributeValue(XML_ATTRIBUTE_VALUE, true, true);
|
||||
|
||||
if(hexData != null) {
|
||||
byte[] bytes = StringSupport.fromHexString(hexData);
|
||||
|
||||
setAttributeValue(VALUE, new ImageData(bytes));
|
||||
}//if//
|
||||
else {
|
||||
setAttributeValue(VALUE, null);
|
||||
}//else//
|
||||
}//if//
|
||||
else {
|
||||
INode valueNode = node.findNode(XML_NODE_VALUE);
|
||||
|
||||
if(valueNode != null) {
|
||||
ImageData imageData = new ImageData();
|
||||
|
||||
imageData.readXml(valueNode);
|
||||
setValue(imageData);
|
||||
}//if//
|
||||
}//else//
|
||||
break;
|
||||
}//case//
|
||||
case IResource.TYPE_IMAGES: {
|
||||
LiteList valueNodes = new LiteList(10, 100);
|
||||
ImageDataSet imageDataSet = new ImageDataSet();
|
||||
|
||||
node.findNodes(XML_NODE_VALUE, valueNodes, false);
|
||||
setValue(imageDataSet);
|
||||
|
||||
for(int index = 0; index < valueNodes.getSize(); index++) {
|
||||
INode valueNode = (INode) valueNodes.get(index);
|
||||
ImageData imageData = new ImageData();
|
||||
|
||||
imageData.readXml(valueNode);
|
||||
imageDataSet.getImageData().add(imageData);
|
||||
}//if//
|
||||
break;
|
||||
}//case//
|
||||
case IResource.TYPE_BOOLEAN: {
|
||||
setAttributeValue(VALUE, new Boolean(node.getAttributeValue(XML_ATTRIBUTE_VALUE, true, true)));
|
||||
break;
|
||||
}//case//
|
||||
case IResource.TYPE_CHARACTER: {
|
||||
setAttributeValue(VALUE, new Character(node.getAttributeValue(XML_ATTRIBUTE_VALUE, true, true).charAt(0)));
|
||||
break;
|
||||
}//case//
|
||||
case IResource.TYPE_COLOR: {
|
||||
setAttributeValue(VALUE, new JefColor(node.getAttributeValue(XML_ATTRIBUTE_VALUE, true, true)));
|
||||
break;
|
||||
}//case//
|
||||
case IResource.TYPE_GRADIENT: {
|
||||
setAttributeValue(VALUE, new JefGradient(node.getAttributeValue(XML_ATTRIBUTE_VALUE, true, true)));
|
||||
break;
|
||||
}//case//
|
||||
case IResource.TYPE_FONT: {
|
||||
setAttributeValue(VALUE, JefFont.getJefFonts(node.getAttributeValue(XML_ATTRIBUTE_VALUE, true, true)));
|
||||
break;
|
||||
}//case//
|
||||
case IResource.TYPE_DATE: {
|
||||
String dateText = node.getAttributeValue(XML_ATTRIBUTE_VALUE, true, true);
|
||||
java.util.Date date = null;
|
||||
|
||||
try {
|
||||
date = dateText == null ? null : DEFAULT_DATE_FORMATTER.parse(dateText);
|
||||
}//try//
|
||||
catch(ParseException e) {
|
||||
Debug.log(e, "Unable to parse the date: " + dateText);
|
||||
}//catch//
|
||||
|
||||
setAttributeValue(VALUE, date);
|
||||
break;
|
||||
}//case//
|
||||
case IResource.TYPE_STRING: {
|
||||
setAttributeValue(VALUE, node.getAttributeValue(XML_ATTRIBUTE_VALUE, false, false));
|
||||
break;
|
||||
}//case//
|
||||
case IResource.TYPE_POSITIVE_INTEGER:
|
||||
case IResource.TYPE_INTEGER: {
|
||||
setAttributeValue(VALUE, new Integer(node.getAttributeValue(XML_ATTRIBUTE_VALUE, true, false)));
|
||||
break;
|
||||
}//case//
|
||||
case IResource.TYPE_POSITIVE_LONG:
|
||||
case IResource.TYPE_LONG: {
|
||||
setAttributeValue(VALUE, new Long(node.getAttributeValue(XML_ATTRIBUTE_VALUE, true, false)));
|
||||
break;
|
||||
}//case//
|
||||
case IResource.TYPE_POSITIVE_FLOAT:
|
||||
case IResource.TYPE_FLOAT: {
|
||||
setAttributeValue(VALUE, new Float(node.getAttributeValue(XML_ATTRIBUTE_VALUE, true, false)));
|
||||
break;
|
||||
}//case//
|
||||
case IResource.TYPE_POSITIVE_DOUBLE:
|
||||
case IResource.TYPE_DOUBLE: {
|
||||
setAttributeValue(VALUE, new Double(node.getAttributeValue(XML_ATTRIBUTE_VALUE, true, false)));
|
||||
break;
|
||||
}//case//
|
||||
default: {
|
||||
Debug.log(new RuntimeException("Failed to identify the resource type: " + node.getAttributeValue(XML_ATTRIBUTE_TYPE, true, false)));
|
||||
break;
|
||||
}//default//
|
||||
}//switch//
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the resource to XML.
|
||||
* @param parent The parent XML node.
|
||||
*/
|
||||
public void writeXml(IAbstractNode parent) {
|
||||
INode resourceNode = parent.createNode(XML_NODE);
|
||||
|
||||
resourceNode.addAttribute(XML_ATTRIBUTE_NAME, getName());
|
||||
resourceNode.addAttribute(XML_ATTRIBUTE_TYPE, IResource.TYPE_NAMES[getType().intValue()]);
|
||||
resourceNode.addAttribute(XML_ATTRIBUTE_VALUE_METADATA, getValueMetadata());
|
||||
|
||||
switch(getType().intValue()) {
|
||||
case IResource.TYPE_IMAGE: {
|
||||
ImageData imageData = (ImageData) getValue();
|
||||
INode valueNode = resourceNode.createNode(XML_NODE_VALUE);
|
||||
|
||||
imageData.writeXml(valueNode);
|
||||
break;
|
||||
}//case//
|
||||
case IResource.TYPE_IMAGES: {
|
||||
ImageDataSet imageDataSet = (ImageDataSet) getValue();
|
||||
|
||||
for(int index = 0; index < imageDataSet.getImageData().getSize(); index++) {
|
||||
ImageData next = (ImageData) imageDataSet.getImageData().get(index);
|
||||
INode valueNode = resourceNode.createNode(XML_NODE_VALUE);
|
||||
|
||||
next.writeXml(valueNode);
|
||||
}//for//
|
||||
break;
|
||||
}//case//
|
||||
case IResource.TYPE_FONT: {
|
||||
resourceNode.addAttribute(XML_ATTRIBUTE_VALUE, JefFont.getJefFontsString((JefFont[]) getValue()));
|
||||
break;
|
||||
}//case//
|
||||
case IResource.TYPE_DATE: {
|
||||
resourceNode.addAttribute(XML_ATTRIBUTE_VALUE, DEFAULT_DATE_FORMATTER.format((java.util.Date) getValue()));
|
||||
break;
|
||||
}//case//
|
||||
default: {
|
||||
resourceNode.addAttribute(XML_ATTRIBUTE_VALUE, getValue());
|
||||
break;
|
||||
}//default//
|
||||
}//switch//
|
||||
}//writeXml()//
|
||||
/**
|
||||
* Gets the resource's name which is used to reference the resource from within the application.
|
||||
* @return The unique (within the resource group) name of the resource.
|
||||
*/
|
||||
public String getName() {
|
||||
return (String) getAttributeValue(NAME);
|
||||
}//getName()//
|
||||
/**
|
||||
* Sets the resource's name.
|
||||
* @param name The unique name of the resource.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
setAttributeValue(NAME, name);
|
||||
}//setName()//
|
||||
/**
|
||||
* Gets the type code for the resource's value.
|
||||
* @return The resource type which defines the value's type.
|
||||
*/
|
||||
public Integer getType() {
|
||||
return (Integer) getAttributeValue(TYPE);
|
||||
}//getType()//
|
||||
/**
|
||||
* Sets the resource's type.
|
||||
* @param type The resource type.
|
||||
*/
|
||||
public void setType(Integer type) {
|
||||
//Clear the value first so that we don't generate casting errors.//
|
||||
if(getType().intValue() != type.intValue()) {
|
||||
switch(type.intValue()) {
|
||||
case TYPE_IMAGE: {
|
||||
setValue(new ImageData());
|
||||
break;
|
||||
}//case//
|
||||
case TYPE_IMAGES: {
|
||||
setValue(new ImageDataSet());
|
||||
break;
|
||||
}//case//
|
||||
default: {
|
||||
setValue(null);
|
||||
break;
|
||||
}//default//
|
||||
}//switch//
|
||||
}//if//
|
||||
|
||||
setAttributeValue(TYPE, type);
|
||||
}//setType()//
|
||||
/**
|
||||
* Gets the resource's value.
|
||||
* <p>Note: The value is always the full value and never a reference to a value elsewhere. An image type for example will store a byte[] containing the image bytes. A font type stores an array of JefFont instances.</p>
|
||||
* @return The value for the resource.
|
||||
*/
|
||||
public Object getValue() {
|
||||
return getAttributeValue(VALUE);
|
||||
}//getValue()//
|
||||
/**
|
||||
* Sets the resource's value.
|
||||
* @param value The value for the resource.
|
||||
*/
|
||||
public void setValue(Object value) {
|
||||
setAttributeValue(VALUE, value);
|
||||
}//setValue()//
|
||||
/**
|
||||
* Gets optional text associated with the value to make it easier to identify the resource when in an editor.
|
||||
* @return The value's optional metadata.
|
||||
*/
|
||||
public String getValueMetadata() {
|
||||
return (String) getAttributeValue(VALUE_METADATA);
|
||||
}//getValueMetadata()//
|
||||
/**
|
||||
* Sets optional text associated with the value to make it easier to identify the resource when in an editor.
|
||||
* @param valueMetadata The value's optional metadata.
|
||||
*/
|
||||
public void setValueMetadata(String valueMetadata) {
|
||||
setAttributeValue(VALUE_METADATA, valueMetadata);
|
||||
}//setValueMetadata()//
|
||||
/**
|
||||
* Gets the referencing parent.
|
||||
* @return The parent.
|
||||
*/
|
||||
public XmlResourceCategory getParent() {
|
||||
return (XmlResourceCategory) getAttributeValue(PARENT);
|
||||
}//getParent()//
|
||||
}//XmlResource//
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2006,2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.resource;
|
||||
|
||||
import com.common.util.IIterator;
|
||||
import com.common.util.LiteList;
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.model.Model;
|
||||
import com.foundation.util.IManagedList;
|
||||
import com.foundation.util.ManagedList;
|
||||
import com.foundation.util.xml.IAbstractNode;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.util.xml.INode;
|
||||
|
||||
public class XmlResourceCategory extends Model {
|
||||
public static final String XML_NODE = "category";
|
||||
public static final String XML_ATTRIBUTE_NAME = "id";
|
||||
|
||||
/** The resource category's name. */
|
||||
public static final Attribute NAME = registerAttribute(XmlResourceCategory.class, "name");
|
||||
/** The resources for this package's group's category. */
|
||||
public static final Attribute RESOURCES = registerCollection(XmlResourceCategory.class, "resources", AO_LAZY | AO_PART_OF);
|
||||
public static final Attribute PARENT = registerAttribute(XmlResourceCategory.class, "parent", XmlResourceGroup.class);
|
||||
/**
|
||||
* XmlResourceCategory constructor.
|
||||
*/
|
||||
public XmlResourceCategory() {
|
||||
super();
|
||||
}//XmlResourceCategory()//
|
||||
/**
|
||||
* XmlResourceCategory constructor.
|
||||
* @param categoryNode The node containing the data for the category.
|
||||
*/
|
||||
public XmlResourceCategory(INode categoryNode) {
|
||||
super();
|
||||
readXml(categoryNode);
|
||||
}//XmlResourceCategory()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.common.Entity#lazyLoadAttribute(com.foundation.metadata.Attribute)
|
||||
*/
|
||||
protected Object lazyLoadAttribute(Attribute attribute) {
|
||||
Object result = null;
|
||||
|
||||
if(attribute == RESOURCES) {
|
||||
result = new ManagedList(10, 20);
|
||||
}//if//
|
||||
else {
|
||||
result = super.lazyLoadAttribute(attribute);
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//lazyLoadAttribute()//
|
||||
/**
|
||||
* Gets the resource category's name.
|
||||
* @return The unique name of the resource category within the context of the containing group.
|
||||
*/
|
||||
public String getName() {
|
||||
return (String) getAttributeValue(NAME);
|
||||
}//getName()//
|
||||
/**
|
||||
* Sets the resource category's name.
|
||||
* @param name The unique name of the resource category.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
setAttributeValue(NAME, name);
|
||||
}//setName()//
|
||||
/**
|
||||
* Gets the collection of all resources defined for this category.
|
||||
* @return The resources defined for this resource category.
|
||||
*/
|
||||
public IManagedList getResources() {
|
||||
return (IManagedList) getAttributeValue(RESOURCES);
|
||||
}//getResources()//
|
||||
/**
|
||||
* Reads the category from XML.
|
||||
* @param node The node containing this object's data.
|
||||
*/
|
||||
public void readXml(IAbstractNode node) {
|
||||
LiteList resourceNodes = new LiteList(10, 40);
|
||||
|
||||
setAttributeValue(NAME, node.getAttributeValue(XML_ATTRIBUTE_NAME, false, false));
|
||||
|
||||
node.findNodes(XmlResource.XML_NODE, resourceNodes);
|
||||
|
||||
for(IIterator iterator = resourceNodes.iterator(); iterator.hasNext(); ) {
|
||||
getResources().add(new XmlResource((INode) iterator.next()));
|
||||
}//while//
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the category to XML.
|
||||
* @param parent The parent XML node.
|
||||
*/
|
||||
public void writeXml(IAbstractNode parent) {
|
||||
INode node = parent.createNode(XML_NODE);
|
||||
|
||||
node.addAttribute(XML_ATTRIBUTE_NAME, getName());
|
||||
|
||||
for(IIterator iterator = getResources().iterator(); iterator.hasNext(); ) {
|
||||
((XmlResource) iterator.next()).writeXml(node);
|
||||
}//while//
|
||||
}//writeXml()//
|
||||
/**
|
||||
* Gets the referencing parent.
|
||||
* @return The parent.
|
||||
*/
|
||||
public XmlResourceGroup getParent() {
|
||||
return (XmlResourceGroup) getAttributeValue(PARENT);
|
||||
}//getParent()//
|
||||
}//XmlResourceCategory//
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.resource;
|
||||
|
||||
import com.foundation.model.Model;
|
||||
import com.foundation.util.xml.IAbstractNode;
|
||||
import com.foundation.util.xml.INode;
|
||||
|
||||
public class XmlResourceCategoryClassification extends Model {
|
||||
public static final String XML_NODE = "category-classfication";
|
||||
/**
|
||||
* XmlResourceCategoryClassification constructor.
|
||||
*/
|
||||
public XmlResourceCategoryClassification() {
|
||||
}//XmlResourceCategoryClassification()//
|
||||
/**
|
||||
* XmlResourceCategoryClassification constructor.
|
||||
*/
|
||||
public XmlResourceCategoryClassification(INode node) {
|
||||
readXml(node);
|
||||
}//XmlResourceCategoryClassification()//
|
||||
/**
|
||||
* Reads the metadata from XML.
|
||||
* @param node The node containing this object's data.
|
||||
*/
|
||||
public void readXml(IAbstractNode node) {
|
||||
// String version = node.getAttributeValue(XML_ATTRIBUTE_VERSION, true, true, "0");
|
||||
//
|
||||
// try {
|
||||
// int versionNumber = Integer.parseInt(version);
|
||||
//
|
||||
// setAttributeValue(NAME, node.getAttributeValue(XML_ATTRIBUTE_NAME, false, false));
|
||||
//
|
||||
// if(versionNumber == 0) {
|
||||
// IIterator iterator = node.getElements().iterator();
|
||||
//
|
||||
// while(iterator.hasNext()) {
|
||||
// IElement next = (IElement) iterator.next();
|
||||
//
|
||||
// if((next.isNode()) && (((INode) next).getName().equals(XmlResourcePackage.XML_NODE))) {
|
||||
// getPackages().add(new XmlResourcePackage((INode) next));
|
||||
// }//if//
|
||||
// }//while//
|
||||
// }//if//
|
||||
// else if(versionNumber == 1) {
|
||||
// INode packagesNode = node.findNode(XML_NODE_PACKAGES);
|
||||
// INode categoryClassificationsNode = node.findNode(XML_NODE_CATEGORY_CLASSIFICATIONS);
|
||||
// INode fontDefinitionsNode = node.findNode(XML_NODE_FONT_DEFINITIONS);
|
||||
// LiteList packageNodes = new LiteList(10, 40);
|
||||
// LiteList categoryClassificationsNodes = new LiteList(10, 40);
|
||||
// LiteList fontDefinitionsNodes = new LiteList(10, 40);
|
||||
//
|
||||
// packagesNode.findNodes(XmlResourcePackage.XML_NODE, packageNodes);
|
||||
// categoryClassificationsNode.findNodes(XmlResourceCategoryClassification.XML_NODE, categoryClassificationsNodes);
|
||||
// fontDefinitionsNode.findNodes(XmlResourceFontDefinition.XML_NODE, fontDefinitionsNodes);
|
||||
//
|
||||
// for(IIterator iterator = packageNodes.iterator(); iterator.hasNext(); ) {
|
||||
// getPackages().add(new XmlResourcePackage((INode) iterator.next()));
|
||||
// }//for//
|
||||
//
|
||||
// for(IIterator iterator = categoryClassificationsNodes.iterator(); iterator.hasNext(); ) {
|
||||
// getCategoryClassifications().add(new XmlResourceCategoryClassification((INode) iterator.next()));
|
||||
// }//for//
|
||||
//
|
||||
// for(IIterator iterator = fontDefinitionsNodes.iterator(); iterator.hasNext(); ) {
|
||||
// getFontDefinitions().add(new XmlResourceFontDefinition((INode) iterator.next()));
|
||||
// }//for//
|
||||
// }//else if//
|
||||
// else {
|
||||
// throw new RuntimeException("Bad version number: XRES file.");
|
||||
// }//else//
|
||||
// }//try//
|
||||
// catch(Throwable e) {
|
||||
// Debug.log(e, "Failed to read the XRES file due to a corruption in the format.");
|
||||
// throw new RuntimeException("Failed to read the XRES file.");
|
||||
// }//catch//
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the metadata from XML.
|
||||
* @param parent The parent XML node.
|
||||
*/
|
||||
public void writeXml(IAbstractNode parent) {
|
||||
// INode resourcesNode = parent.createNode(XML_NODE_RESOURCE_METADATA);
|
||||
// INode packagesNode = resourcesNode.createNode(XML_NODE_PACKAGES);
|
||||
// INode categoryClassificationsNode = resourcesNode.createNode(XML_NODE_CATEGORY_CLASSIFICATIONS);
|
||||
// INode fontDefinitionsNode = resourcesNode.createNode(XML_NODE_FONT_DEFINITIONS);
|
||||
//
|
||||
// resourcesNode.addAttribute(XML_ATTRIBUTE_NAME, getName());
|
||||
//
|
||||
// for(IIterator iterator = getPackages().iterator(); iterator.hasNext(); ) {
|
||||
// ((XmlResourcePackage) iterator.next()).writeXml(packagesNode);
|
||||
// }//for//
|
||||
//
|
||||
// for(IIterator iterator = getCategoryClassifications().iterator(); iterator.hasNext(); ) {
|
||||
// ((XmlResourcePackage) iterator.next()).writeXml(categoryClassificationsNode);
|
||||
// }//for//
|
||||
//
|
||||
// for(IIterator iterator = getFontDefinitions().iterator(); iterator.hasNext(); ) {
|
||||
// ((XmlResourcePackage) iterator.next()).writeXml(fontDefinitionsNode);
|
||||
// }//for//
|
||||
}//writeXml()//
|
||||
}//XmlResourceCategoryClassification//
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.resource;
|
||||
|
||||
import com.common.debug.Debug;
|
||||
import com.common.util.IIterator;
|
||||
import com.common.util.LiteList;
|
||||
import com.foundation.model.Model;
|
||||
import com.foundation.util.xml.IAbstractNode;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.util.xml.INode;
|
||||
|
||||
public class XmlResourceFontDefinition extends Model {
|
||||
public static final String XML_NODE = "font-definition";
|
||||
/**
|
||||
* XmlResourceFontDefinition constructor.
|
||||
*/
|
||||
public XmlResourceFontDefinition() {
|
||||
}//XmlResourceFontDefinition()//
|
||||
/**
|
||||
* XmlResourceFontDefinition constructor.
|
||||
*/
|
||||
public XmlResourceFontDefinition(INode node) {
|
||||
readXml(node);
|
||||
}//XmlResourceFontDefinition()//
|
||||
/**
|
||||
* Reads the metadata from XML.
|
||||
* @param node The node containing this object's data.
|
||||
*/
|
||||
public void readXml(IAbstractNode node) {
|
||||
// String version = node.getAttributeValue(XML_ATTRIBUTE_VERSION, true, true, "0");
|
||||
//
|
||||
// try {
|
||||
// int versionNumber = Integer.parseInt(version);
|
||||
//
|
||||
// setAttributeValue(NAME, node.getAttributeValue(XML_ATTRIBUTE_NAME, false, false));
|
||||
//
|
||||
// if(versionNumber == 0) {
|
||||
// IIterator iterator = node.getElements().iterator();
|
||||
//
|
||||
// while(iterator.hasNext()) {
|
||||
// IElement next = (IElement) iterator.next();
|
||||
//
|
||||
// if((next.isNode()) && (((INode) next).getName().equals(XmlResourcePackage.XML_NODE))) {
|
||||
// getPackages().add(new XmlResourcePackage((INode) next));
|
||||
// }//if//
|
||||
// }//while//
|
||||
// }//if//
|
||||
// else if(versionNumber == 1) {
|
||||
// INode packagesNode = node.findNode(XML_NODE_PACKAGES);
|
||||
// INode categoryClassificationsNode = node.findNode(XML_NODE_CATEGORY_CLASSIFICATIONS);
|
||||
// INode fontDefinitionsNode = node.findNode(XML_NODE_FONT_DEFINITIONS);
|
||||
// LiteList packageNodes = new LiteList(10, 40);
|
||||
// LiteList categoryClassificationsNodes = new LiteList(10, 40);
|
||||
// LiteList fontDefinitionsNodes = new LiteList(10, 40);
|
||||
//
|
||||
// packagesNode.findNodes(XmlResourcePackage.XML_NODE, packageNodes);
|
||||
// categoryClassificationsNode.findNodes(XmlResourceCategoryClassification.XML_NODE, categoryClassificationsNodes);
|
||||
// fontDefinitionsNode.findNodes(XmlResourceFontDefinition.XML_NODE, fontDefinitionsNodes);
|
||||
//
|
||||
// for(IIterator iterator = packageNodes.iterator(); iterator.hasNext(); ) {
|
||||
// getPackages().add(new XmlResourcePackage((INode) iterator.next()));
|
||||
// }//for//
|
||||
//
|
||||
// for(IIterator iterator = categoryClassificationsNodes.iterator(); iterator.hasNext(); ) {
|
||||
// getCategoryClassifications().add(new XmlResourceCategoryClassification((INode) iterator.next()));
|
||||
// }//for//
|
||||
//
|
||||
// for(IIterator iterator = fontDefinitionsNodes.iterator(); iterator.hasNext(); ) {
|
||||
// getFontDefinitions().add(new XmlResourceFontDefinition((INode) iterator.next()));
|
||||
// }//for//
|
||||
// }//else if//
|
||||
// else {
|
||||
// throw new RuntimeException("Bad version number: XRES file.");
|
||||
// }//else//
|
||||
// }//try//
|
||||
// catch(Throwable e) {
|
||||
// Debug.log(e, "Failed to read the XRES file due to a corruption in the format.");
|
||||
// throw new RuntimeException("Failed to read the XRES file.");
|
||||
// }//catch//
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the metadata from XML.
|
||||
* @param parent The parent XML node.
|
||||
*/
|
||||
public void writeXml(IAbstractNode parent) {
|
||||
// INode resourcesNode = parent.createNode(XML_NODE_RESOURCE_METADATA);
|
||||
// INode packagesNode = resourcesNode.createNode(XML_NODE_PACKAGES);
|
||||
// INode categoryClassificationsNode = resourcesNode.createNode(XML_NODE_CATEGORY_CLASSIFICATIONS);
|
||||
// INode fontDefinitionsNode = resourcesNode.createNode(XML_NODE_FONT_DEFINITIONS);
|
||||
//
|
||||
// resourcesNode.addAttribute(XML_ATTRIBUTE_NAME, getName());
|
||||
//
|
||||
// for(IIterator iterator = getPackages().iterator(); iterator.hasNext(); ) {
|
||||
// ((XmlResourcePackage) iterator.next()).writeXml(packagesNode);
|
||||
// }//for//
|
||||
//
|
||||
// for(IIterator iterator = getCategoryClassifications().iterator(); iterator.hasNext(); ) {
|
||||
// ((XmlResourcePackage) iterator.next()).writeXml(categoryClassificationsNode);
|
||||
// }//for//
|
||||
//
|
||||
// for(IIterator iterator = getFontDefinitions().iterator(); iterator.hasNext(); ) {
|
||||
// ((XmlResourcePackage) iterator.next()).writeXml(fontDefinitionsNode);
|
||||
// }//for//
|
||||
}//writeXml()//
|
||||
}//XmlResourceFontDefinition//
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2006,2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.resource;
|
||||
|
||||
import com.common.util.IIterator;
|
||||
import com.common.util.LiteList;
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.model.Model;
|
||||
import com.foundation.util.IManagedList;
|
||||
import com.foundation.util.ManagedList;
|
||||
import com.foundation.util.xml.IAbstractNode;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.util.xml.INode;
|
||||
|
||||
public class XmlResourceGroup extends Model {
|
||||
public static final String XML_NODE = "group";
|
||||
public static final String XML_ATTRIBUTE_NAME = "id";
|
||||
|
||||
/** The resource group's name. */
|
||||
public static final Attribute NAME = registerAttribute(XmlResourceGroup.class, "name");
|
||||
/** The categories that define data for this group. */
|
||||
public static final Attribute CATEGORIES = registerCollection(XmlResourceGroup.class, "categories", AO_LAZY | AO_PART_OF);
|
||||
public static final Attribute PARENT = registerAttribute(XmlResourceGroup.class, "parent", XmlResourcePackage.class);
|
||||
/**
|
||||
* XmlResourceGroup constructor.
|
||||
*/
|
||||
public XmlResourceGroup() {
|
||||
super();
|
||||
}//XmlResourceGroup()//
|
||||
/**
|
||||
* XmlResourceCategory constructor.
|
||||
* @param groupNode The node containing the data for the group.
|
||||
*/
|
||||
public XmlResourceGroup(INode groupNode) {
|
||||
super();
|
||||
readXml(groupNode);
|
||||
}//XmlResourceGroup()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.common.Entity#lazyLoadAttribute(com.foundation.metadata.Attribute)
|
||||
*/
|
||||
protected Object lazyLoadAttribute(Attribute attribute) {
|
||||
Object result = null;
|
||||
|
||||
if(attribute == CATEGORIES) {
|
||||
result = new ManagedList(10, 20);
|
||||
}//if//
|
||||
else {
|
||||
result = super.lazyLoadAttribute(attribute);
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//lazyLoadAttribute()//
|
||||
/**
|
||||
* Gets the resource group's name.
|
||||
* @return The unique name of the resource group within the context of the containing package.
|
||||
*/
|
||||
public String getName() {
|
||||
return (String) getAttributeValue(NAME);
|
||||
}//getName()//
|
||||
/**
|
||||
* Sets the resource group's name.
|
||||
* @param name The unique name of the resource group.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
setAttributeValue(NAME, name);
|
||||
}//setName()//
|
||||
/**
|
||||
* Gets the collection of all categories defined for this group.
|
||||
* @return The categories defined for this resource group.
|
||||
*/
|
||||
public IManagedList getCategories() {
|
||||
return (IManagedList) getAttributeValue(CATEGORIES);
|
||||
}//getCategories()//
|
||||
/**
|
||||
* Reads the group from XML.
|
||||
* @param node The node containing this object's data.
|
||||
*/
|
||||
public void readXml(IAbstractNode node) {
|
||||
LiteList categoryNodes = new LiteList(10, 40);
|
||||
|
||||
setAttributeValue(NAME, node.getAttributeValue(XML_ATTRIBUTE_NAME, false, false));
|
||||
|
||||
node.findNodes(XmlResourceCategory.XML_NODE, categoryNodes);
|
||||
|
||||
for(IIterator iterator = categoryNodes.iterator(); iterator.hasNext(); ) {
|
||||
getCategories().add(new XmlResourceCategory((INode) iterator.next()));
|
||||
}//while//
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the group to XML.
|
||||
* @param parent The parent XML node.
|
||||
*/
|
||||
public void writeXml(IAbstractNode parent) {
|
||||
INode node = parent.createNode(XML_NODE);
|
||||
|
||||
node.addAttribute(XML_ATTRIBUTE_NAME, getName());
|
||||
|
||||
for(IIterator iterator = getCategories().iterator(); iterator.hasNext(); ) {
|
||||
((XmlResourceCategory) iterator.next()).writeXml(node);
|
||||
}//while//
|
||||
}//writeXml()//
|
||||
/**
|
||||
* Gets the referencing parent.
|
||||
* @return The parent.
|
||||
*/
|
||||
public XmlResourcePackage getParent() {
|
||||
return (XmlResourcePackage) getAttributeValue(PARENT);
|
||||
}//getParent()//
|
||||
}//XmlResourceGroup//
|
||||
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Copyright (c) 2006,2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.resource;
|
||||
|
||||
import com.common.debug.Debug;
|
||||
import com.common.util.IIterator;
|
||||
import com.common.util.LiteList;
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.model.Model;
|
||||
import com.foundation.util.IManagedList;
|
||||
import com.foundation.util.ManagedList;
|
||||
import com.foundation.util.xml.IAbstractNode;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.util.xml.INode;
|
||||
|
||||
/**
|
||||
* There is only one resources tag in an xres file and it contains all the resource metadata.
|
||||
*/
|
||||
public class XmlResourceMetadata extends Model {
|
||||
public static final String XML_NODE_RESOURCE_METADATA = "resources";
|
||||
public static final String XML_NODE_PACKAGES = "packages";
|
||||
public static final String XML_NODE_CATEGORY_CLASSIFICATIONS = "category-classifications";
|
||||
public static final String XML_NODE_FONT_DEFINITIONS = "font-definitions";
|
||||
public static final String XML_ATTRIBUTE_NAME = "id";
|
||||
public static final String XML_ATTRIBUTE_VERSION = "version";
|
||||
|
||||
/** The resource data's name. */
|
||||
public static final Attribute NAME = registerAttribute(XmlResourceMetadata.class, "name");
|
||||
/** The packages defined in the resource metadata. */
|
||||
public static final Attribute PACKAGES = registerCollection(XmlResourceMetadata.class, "packages", AO_LAZY | AO_PART_OF);
|
||||
/** The category classifications. */
|
||||
public static final Attribute CATEGORY_CLASSIFICATIONS = registerCollection(XmlResourceMetadata.class, "categoryClassifications", AO_LAZY | AO_PART_OF);
|
||||
/** The font definitions. */
|
||||
public static final Attribute FONT_DEFINITIONS = registerCollection(XmlResourceMetadata.class, "fontDefinitions", AO_LAZY | AO_PART_OF);
|
||||
/**
|
||||
* XmlResourceMetadata constructor.
|
||||
*/
|
||||
public XmlResourceMetadata() {
|
||||
super();
|
||||
}//XmlResourceMetadata()//
|
||||
/**
|
||||
* XmlResourceMetadata constructor.
|
||||
* @param packageNode The node containing the data for the package.
|
||||
*/
|
||||
public XmlResourceMetadata(INode node) {
|
||||
super();
|
||||
readXml(node);
|
||||
}//XmlResourceMetadata()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.common.Entity#lazyLoadAttribute(com.foundation.metadata.Attribute)
|
||||
*/
|
||||
protected Object lazyLoadAttribute(Attribute attribute) {
|
||||
Object result = null;
|
||||
|
||||
if(attribute == PACKAGES) {
|
||||
result = new ManagedList(10, 20);
|
||||
}//if//
|
||||
else if(attribute == CATEGORY_CLASSIFICATIONS) {
|
||||
result = new ManagedList(10, 20);
|
||||
}//else if//
|
||||
else if(attribute == FONT_DEFINITIONS) {
|
||||
result = new ManagedList(10, 20);
|
||||
}//else if//
|
||||
else {
|
||||
result = super.lazyLoadAttribute(attribute);
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//lazyLoadAttribute()//
|
||||
/**
|
||||
* Gets the resource data's name.
|
||||
* @return The unique name of the resource data.
|
||||
*/
|
||||
public String getName() {
|
||||
return (String) getAttributeValue(NAME);
|
||||
}//getName()//
|
||||
/**
|
||||
* Sets the resource data's name.
|
||||
* @param name The unique name of the resource data.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
setAttributeValue(NAME, name);
|
||||
}//setName()//
|
||||
/**
|
||||
* Gets the collection of all resource packages.
|
||||
* @return The packages defined in the resource xml.
|
||||
*/
|
||||
public IManagedList getPackages() {
|
||||
return (IManagedList) getAttributeValue(PACKAGES);
|
||||
}//getPackages()//
|
||||
/**
|
||||
* Gets the collection of all category classifications. A category classification is referenced by name from the groups, and determines what categories the group has.
|
||||
* @return The category classifications defined in the resource xml.
|
||||
*/
|
||||
public IManagedList getCategoryClassifications() {
|
||||
return (IManagedList) getAttributeValue(CATEGORY_CLASSIFICATIONS);
|
||||
}//getCategoryClassifications()//
|
||||
/**
|
||||
* Gets the collection of all font's defined by the system. The font picker uses the font definitions to allow the user to choose from pre-defined fonts. The font then doesn't need to be on the developer's machine to be used by the application.
|
||||
* @return The font definitions defined in the resource xml.
|
||||
*/
|
||||
public IManagedList getFontDefinitions() {
|
||||
return (IManagedList) getAttributeValue(FONT_DEFINITIONS);
|
||||
}//getFontDefinitions()//
|
||||
/**
|
||||
* Reads the metadata from XML.
|
||||
* @param node The node containing this object's data.
|
||||
*/
|
||||
public void readXml(IAbstractNode node) {
|
||||
String version = node.getAttributeValue(XML_ATTRIBUTE_VERSION, true, true, "0");
|
||||
|
||||
try {
|
||||
int versionNumber = Integer.parseInt(version);
|
||||
|
||||
setAttributeValue(NAME, node.getAttributeValue(XML_ATTRIBUTE_NAME, false, false));
|
||||
|
||||
if(versionNumber == 0) {
|
||||
IIterator iterator = node.getElements().iterator();
|
||||
|
||||
while(iterator.hasNext()) {
|
||||
IElement next = (IElement) iterator.next();
|
||||
|
||||
if((next.isNode()) && (((INode) next).getName().equals(XmlResourcePackage.XML_NODE))) {
|
||||
getPackages().add(new XmlResourcePackage((INode) next));
|
||||
}//if//
|
||||
}//while//
|
||||
}//if//
|
||||
else if(versionNumber == 1) {
|
||||
INode packagesNode = node.findNode(XML_NODE_PACKAGES);
|
||||
INode categoryClassificationsNode = node.findNode(XML_NODE_CATEGORY_CLASSIFICATIONS);
|
||||
INode fontDefinitionsNode = node.findNode(XML_NODE_FONT_DEFINITIONS);
|
||||
LiteList packageNodes = new LiteList(10, 40);
|
||||
LiteList categoryClassificationsNodes = new LiteList(10, 40);
|
||||
LiteList fontDefinitionsNodes = new LiteList(10, 40);
|
||||
|
||||
packagesNode.findNodes(XmlResourcePackage.XML_NODE, packageNodes);
|
||||
categoryClassificationsNode.findNodes(XmlResourceCategoryClassification.XML_NODE, categoryClassificationsNodes);
|
||||
fontDefinitionsNode.findNodes(XmlResourceFontDefinition.XML_NODE, fontDefinitionsNodes);
|
||||
|
||||
for(IIterator iterator = packageNodes.iterator(); iterator.hasNext(); ) {
|
||||
getPackages().add(new XmlResourcePackage((INode) iterator.next()));
|
||||
}//for//
|
||||
|
||||
for(IIterator iterator = categoryClassificationsNodes.iterator(); iterator.hasNext(); ) {
|
||||
getCategoryClassifications().add(new XmlResourceCategoryClassification((INode) iterator.next()));
|
||||
}//for//
|
||||
|
||||
for(IIterator iterator = fontDefinitionsNodes.iterator(); iterator.hasNext(); ) {
|
||||
getFontDefinitions().add(new XmlResourceFontDefinition((INode) iterator.next()));
|
||||
}//for//
|
||||
}//else if//
|
||||
else {
|
||||
throw new RuntimeException("Bad version number: XRES file.");
|
||||
}//else//
|
||||
}//try//
|
||||
catch(Throwable e) {
|
||||
Debug.log(e, "Failed to read the XRES file due to a corruption in the format.");
|
||||
throw new RuntimeException("Failed to read the XRES file.");
|
||||
}//catch//
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the metadata from XML.
|
||||
* @param parent The parent XML node.
|
||||
*/
|
||||
public void writeXml(IAbstractNode parent) {
|
||||
INode resourcesNode = parent.createNode(XML_NODE_RESOURCE_METADATA);
|
||||
INode packagesNode = resourcesNode.createNode(XML_NODE_PACKAGES);
|
||||
INode categoryClassificationsNode = resourcesNode.createNode(XML_NODE_CATEGORY_CLASSIFICATIONS);
|
||||
INode fontDefinitionsNode = resourcesNode.createNode(XML_NODE_FONT_DEFINITIONS);
|
||||
|
||||
resourcesNode.addAttribute(XML_ATTRIBUTE_VERSION, "1");
|
||||
resourcesNode.addAttribute(XML_ATTRIBUTE_NAME, getName());
|
||||
|
||||
for(IIterator iterator = getPackages().iterator(); iterator.hasNext(); ) {
|
||||
((XmlResourcePackage) iterator.next()).writeXml(packagesNode);
|
||||
}//for//
|
||||
|
||||
for(IIterator iterator = getCategoryClassifications().iterator(); iterator.hasNext(); ) {
|
||||
((XmlResourcePackage) iterator.next()).writeXml(categoryClassificationsNode);
|
||||
}//for//
|
||||
|
||||
for(IIterator iterator = getFontDefinitions().iterator(); iterator.hasNext(); ) {
|
||||
((XmlResourcePackage) iterator.next()).writeXml(fontDefinitionsNode);
|
||||
}//for//
|
||||
}//writeXml()//
|
||||
}//XmlResourceMetadata//
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2006,2009 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.resource;
|
||||
|
||||
import com.common.debug.Debug;
|
||||
import com.common.util.IIterator;
|
||||
import com.common.util.LiteList;
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.model.Model;
|
||||
import com.foundation.util.IManagedList;
|
||||
import com.foundation.util.ManagedList;
|
||||
import com.foundation.util.xml.IAbstractNode;
|
||||
import com.foundation.util.xml.IElement;
|
||||
import com.foundation.util.xml.INode;
|
||||
|
||||
public class XmlResourcePackage extends Model {
|
||||
public static final String XML_NODE = "package";
|
||||
public static final String XML_ATTRIBUTE_NAME = "id";
|
||||
|
||||
/** The resource category's name. */
|
||||
public static final Attribute NAME = registerAttribute(XmlResourcePackage.class, "name");
|
||||
/** The resources for this package's group's category. */
|
||||
public static final Attribute GROUPS = registerCollection(XmlResourcePackage.class, "groups", AO_LAZY | AO_PART_OF);
|
||||
public static final Attribute PARENT = registerAttribute(XmlResourcePackage.class, "parent", XmlResourceMetadata.class);
|
||||
/**
|
||||
* XmlResourcePackage constructor.
|
||||
*/
|
||||
public XmlResourcePackage() {
|
||||
super();
|
||||
}//XmlResourcePackage()//
|
||||
/**
|
||||
* XmlResourcePackage constructor.
|
||||
* @param packageNode The node containing the data for the package.
|
||||
*/
|
||||
public XmlResourcePackage(INode packageNode) {
|
||||
super();
|
||||
readXml(packageNode);
|
||||
}//XmlResourcePackage()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.common.Entity#lazyLoadAttribute(com.foundation.metadata.Attribute)
|
||||
*/
|
||||
protected Object lazyLoadAttribute(Attribute attribute) {
|
||||
Object result = null;
|
||||
|
||||
if(attribute == GROUPS) {
|
||||
result = new ManagedList(10, 20);
|
||||
}//if//
|
||||
else {
|
||||
result = super.lazyLoadAttribute(attribute);
|
||||
}//else//
|
||||
|
||||
return result;
|
||||
}//lazyLoadAttribute()//
|
||||
/**
|
||||
* Gets the resource package's name.
|
||||
* @return The unique name of the resource package.
|
||||
*/
|
||||
public String getName() {
|
||||
return (String) getAttributeValue(NAME);
|
||||
}//getName()//
|
||||
/**
|
||||
* Sets the resource package's name.
|
||||
* @param name The unique name of the resource package.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
setAttributeValue(NAME, name);
|
||||
}//setName()//
|
||||
/**
|
||||
* Gets the collection of all resource groups defined for this package.
|
||||
* @return The groups defined for this resource package.
|
||||
*/
|
||||
public IManagedList getGroups() {
|
||||
return (IManagedList) getAttributeValue(GROUPS);
|
||||
}//getGroups()//
|
||||
/**
|
||||
* Reads the metadata from XML.
|
||||
* @param node The node containing this object's data.
|
||||
*/
|
||||
public void readXml(IAbstractNode node) {
|
||||
LiteList groupNodes = new LiteList(10, 40);
|
||||
|
||||
setAttributeValue(NAME, node.getAttributeValue(XML_ATTRIBUTE_NAME, false, false));
|
||||
|
||||
node.findNodes(XmlResourceGroup.XML_NODE, groupNodes);
|
||||
|
||||
for(IIterator iterator = groupNodes.iterator(); iterator.hasNext(); ) {
|
||||
getGroups().add(new XmlResourceGroup((INode) iterator.next()));
|
||||
}//while//
|
||||
}//readXml()//
|
||||
/**
|
||||
* Writes the package to XML.
|
||||
* @param parent The parent XML node.
|
||||
*/
|
||||
public void writeXml(IAbstractNode parent) {
|
||||
INode node = parent.createNode(XML_NODE);
|
||||
IIterator iterator = getGroups().iterator();
|
||||
|
||||
node.addAttribute(XML_ATTRIBUTE_NAME, getName());
|
||||
|
||||
while(iterator.hasNext()) {
|
||||
((XmlResourceGroup) iterator.next()).writeXml(node);
|
||||
}//while//
|
||||
}//writeXml()//
|
||||
/**
|
||||
* Gets the referencing parent.
|
||||
* @return The parent.
|
||||
*/
|
||||
public XmlResourceMetadata getParent() {
|
||||
return (XmlResourceMetadata) getAttributeValue(PARENT);
|
||||
}//getParent()//
|
||||
}//XmlResourcePackage//
|
||||
Reference in New Issue
Block a user