Initial commit from SVN.
This commit is contained in:
@@ -0,0 +1,241 @@
|
||||
package com.foundation.web.application;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLStreamHandler;
|
||||
import java.util.Enumeration;
|
||||
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.foundation.util.xml.*;
|
||||
|
||||
/**
|
||||
* Used to load the view component builders only.
|
||||
*/
|
||||
public class AppClassLoader extends ClassLoader {
|
||||
/** The path to the jars containing the application classes. */
|
||||
private File[] jars = null;
|
||||
/**
|
||||
* AppClassLoader constructor.
|
||||
* @param jars The java.io.File objects for each jar loadable.
|
||||
*/
|
||||
public AppClassLoader(LiteList jars) {
|
||||
super();
|
||||
this.jars = new File[jars.getSize()];
|
||||
|
||||
//Convert the paths to the jars to paths to the zjars.//
|
||||
for(int index = 0; index < jars.getSize(); index++) {
|
||||
this.jars[index] = (File) jars.get(index);
|
||||
}//for//
|
||||
}//AppClassLoader()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.ClassLoader#findResource(java.lang.String)
|
||||
*/
|
||||
protected URL findResource(String name) {
|
||||
URL result = null;
|
||||
|
||||
name = name.replace('\\', '/');
|
||||
|
||||
while(name.charAt(0) == '/') {
|
||||
name = name.substring(1);
|
||||
}//while//
|
||||
|
||||
for(int index = 0; result == null && index < jars.length; index++) {
|
||||
result = findResource(jars[index], name);
|
||||
}//for//
|
||||
|
||||
return result;
|
||||
}//findResource()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.ClassLoader#findLibrary(java.lang.String)
|
||||
*/
|
||||
protected String findLibrary(String libname) {
|
||||
return super.findLibrary(libname);
|
||||
}//findLibrary()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.ClassLoader#findResources(java.lang.String)
|
||||
*/
|
||||
protected Enumeration findResources(String name) throws IOException {
|
||||
return super.findResources(name);
|
||||
}//findResources()//
|
||||
/**
|
||||
* 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 URL findResource(File file, String name) {
|
||||
URL result = null;
|
||||
|
||||
if(file.exists()) {
|
||||
boolean cleanup = true;
|
||||
|
||||
try {
|
||||
JarFile jar = new JarFile(file, false, JarFile.OPEN_READ);
|
||||
|
||||
try {
|
||||
JarEntry entry = jar.getJarEntry(name);
|
||||
|
||||
if(entry != null) {
|
||||
/*
|
||||
final JarFile jf = jar;
|
||||
final JarEntry je = entry;
|
||||
|
||||
cleanup = false;
|
||||
result = new URL("", null, 0, name, new URLStreamHandler() {
|
||||
protected URLConnection openConnection(URL u) throws IOException {
|
||||
return new URLConnection(u) {
|
||||
public void connect() throws IOException {
|
||||
}//connect()//
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return jf.getInputStream(je);
|
||||
}//getInputStream()//
|
||||
public void finalize() {
|
||||
try {jf.close();} catch(IOException e) {e.printStackTrace();}
|
||||
}//finalize()//
|
||||
};
|
||||
}//openConnection()//
|
||||
});
|
||||
*/
|
||||
final File jFile = file;
|
||||
final String jeName = name;
|
||||
|
||||
result = new URL("", null, 0, name, new URLStreamHandler() {
|
||||
protected URLConnection openConnection(URL u) throws IOException {
|
||||
return new URLConnection(u) {
|
||||
public void connect() throws IOException {
|
||||
}//connect()//
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return new InputStream() {
|
||||
JarFile _jar = new JarFile(jFile, false, JarFile.OPEN_READ);
|
||||
JarEntry _entry = _jar.getJarEntry(jeName);
|
||||
InputStream _in = _jar.getInputStream(_entry);
|
||||
|
||||
public int read() throws IOException {
|
||||
return _in.read();
|
||||
}//read()//
|
||||
public int available() throws IOException {
|
||||
return _in.available();
|
||||
}//available()//
|
||||
public synchronized void mark(int readlimit) {
|
||||
_in.mark(readlimit);
|
||||
}//mark()//
|
||||
public boolean markSupported() {
|
||||
return _in.markSupported();
|
||||
}//markSupported()//
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
return _in.read(b, off, len);
|
||||
}//read()//
|
||||
public int read(byte[] b) throws IOException {
|
||||
return _in.read(b);
|
||||
}//read()//
|
||||
public synchronized void reset() throws IOException {
|
||||
_in.reset();
|
||||
}//reset()//
|
||||
public long skip(long n) throws IOException {
|
||||
return _in.skip(n);
|
||||
}//skip()//
|
||||
public void close() throws IOException {
|
||||
try {_jar.close();} catch(IOException e) {e.printStackTrace();}
|
||||
super.close();
|
||||
}//close()//
|
||||
};
|
||||
}//getInputStream()//
|
||||
};
|
||||
}//openConnection()//
|
||||
});
|
||||
}//if//
|
||||
}//try//
|
||||
finally {
|
||||
if(cleanup && jar != null) {
|
||||
jar.close();
|
||||
}//if//
|
||||
}//finally//
|
||||
}//try//
|
||||
catch(IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}//catch//
|
||||
}//if//
|
||||
|
||||
return result;
|
||||
}//findResource()//
|
||||
/* (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("AppClassLoader - Looking the for class: " + className);
|
||||
/*
|
||||
try {
|
||||
type = super.findClass(className);
|
||||
}//try//
|
||||
catch(ClassNotFoundException e) {
|
||||
//Ignore.//
|
||||
}//catch//
|
||||
*/
|
||||
if(type == null) {
|
||||
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 {
|
||||
if(file.getPath().toLowerCase().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//
|
||||
|
||||
if(bytes != null) {
|
||||
type = defineClass(className, bytes, 0, bytes.length);
|
||||
}//if//
|
||||
}//try//
|
||||
catch(IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}//catch//
|
||||
}//if//
|
||||
|
||||
return type;
|
||||
}//findClass()//
|
||||
}//AppClassLoader//
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
package com.foundation.web.model;
|
||||
|
||||
import com.foundation.application.IApplication;
|
||||
import com.foundation.model.Model;
|
||||
import com.foundation.web.application.WebServerApplication;
|
||||
|
||||
public abstract class AbstractModel extends Model {
|
||||
/**
|
||||
* AbstractModel constructor.
|
||||
*/
|
||||
public AbstractModel() {
|
||||
}//AbstractModel()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.common.Entity#getApplication()
|
||||
*/
|
||||
public IApplication getApplication() {
|
||||
return WebServerApplication.getSingleton();
|
||||
}//getApplication()//
|
||||
}//AbstractModel//
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.foundation.web.server;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Date;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import com.common.debug.Debug;
|
||||
import com.foundation.web.interfaces.IContent;
|
||||
import com.foundation.web.interfaces.IMimeType;
|
||||
import com.foundation.web.interfaces.IMimeTypeProvider;
|
||||
|
||||
/**
|
||||
* Used by the web server (shouldn't generally be used by the developer) to wrapper a response content object to allow for compression.
|
||||
* The developer shouldn't use this directly (see the response's compress property) since it's use is automatically determined by the web server based on the response compress settings, the application's default settings, and the browser's accepted compression algoirithms list.
|
||||
*/
|
||||
public class GzipContent implements IContent {
|
||||
private IContent wrapperedContent;
|
||||
private ByteBuffer compressedBytes = null;
|
||||
/**
|
||||
* GzipContent constructor.
|
||||
* @param wrapperedContent The content to be compressed.
|
||||
*/
|
||||
public GzipContent(IContent wrapperedContent) {
|
||||
this.wrapperedContent = wrapperedContent;
|
||||
|
||||
try {
|
||||
ByteArrayOutputStream bout = new ByteArrayOutputStream((int) (wrapperedContent.getSize() >> 1));
|
||||
GZIPOutputStream out = new GZIPOutputStream(bout);
|
||||
ByteBuffer buffer = ByteBuffer.allocate(10000);
|
||||
int count = 0;
|
||||
|
||||
while(count != -1) {
|
||||
count = wrapperedContent.get(buffer);
|
||||
|
||||
if(count > 0) {
|
||||
out.write(buffer.array(), 0, count);
|
||||
}//if//
|
||||
}//while//
|
||||
|
||||
compressedBytes = ByteBuffer.wrap(bout.toByteArray());
|
||||
}//try//
|
||||
catch(Throwable e) {
|
||||
Debug.log(e);
|
||||
}//catch//
|
||||
}//GzipContent()//
|
||||
public long getSize() {
|
||||
return compressedBytes != null ? compressedBytes.limit() : wrapperedContent != null ? wrapperedContent.getSize() : 0;
|
||||
}//getSize()//
|
||||
public long getStart() {
|
||||
return wrapperedContent.getStart();
|
||||
}//getStart()//
|
||||
public long getEnd() {
|
||||
return wrapperedContent.getEnd();
|
||||
}//getEnd()//
|
||||
public int get(ByteBuffer buffer) {
|
||||
int count = 0;
|
||||
|
||||
if(compressedBytes != null) {
|
||||
if(compressedBytes.hasRemaining()) {
|
||||
count = Math.min(compressedBytes.remaining(), buffer.remaining());
|
||||
|
||||
buffer.put(compressedBytes.array(), compressedBytes.arrayOffset() + compressedBytes.position(), count);
|
||||
compressedBytes.position(compressedBytes.position() + count);
|
||||
}//if//
|
||||
}//if//
|
||||
else if(wrapperedContent != null) {
|
||||
count = wrapperedContent.get(buffer);
|
||||
}//else//
|
||||
|
||||
return count;
|
||||
}//get()//
|
||||
public void reset() {
|
||||
if(compressedBytes != null) {
|
||||
compressedBytes.position(0);
|
||||
}//if//
|
||||
else if(wrapperedContent != null) {
|
||||
wrapperedContent.reset();
|
||||
}//else if//
|
||||
}//reset()//
|
||||
public void release() {
|
||||
if(wrapperedContent != null) {
|
||||
wrapperedContent.release();
|
||||
}//if//
|
||||
}//release()//
|
||||
public Date getLastModifiedDate() {
|
||||
return wrapperedContent != null ? wrapperedContent.getLastModifiedDate() : null;
|
||||
}//getLastModifiedDate()//
|
||||
public IMimeType getMimeType(IMimeTypeProvider provider) {
|
||||
return wrapperedContent != null ? wrapperedContent.getMimeType(provider) : null;
|
||||
}//getMimeType()//
|
||||
public String getCacheDirective() {
|
||||
return wrapperedContent != null ? wrapperedContent.getCacheDirective() : null;
|
||||
}//getCacheDirective()//
|
||||
public Date getExpiresDirective() {
|
||||
return wrapperedContent != null ? wrapperedContent.getExpiresDirective() : null;
|
||||
}//getExpiresDirective()//
|
||||
public Integer getCacheLength() {
|
||||
return wrapperedContent != null ? wrapperedContent.getCacheLength() : null;
|
||||
}//getCacheLength()//
|
||||
public Boolean getIsDownloaded() {
|
||||
return wrapperedContent != null ? wrapperedContent.getIsDownloaded() : null;
|
||||
}//getIsDownloaded()//
|
||||
public String getDownloadName() {
|
||||
return wrapperedContent != null ? wrapperedContent.getDownloadName() : null;
|
||||
}//getDownloadName()//
|
||||
public void setDownloadName(String downloadName) {
|
||||
if(wrapperedContent != null) wrapperedContent.setDownloadName(downloadName);
|
||||
}//setDownloadName()//
|
||||
}//GzipContent//
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.foundation.web.server;
|
||||
|
||||
import com.common.orb.Address;
|
||||
|
||||
public interface IServiceListener {
|
||||
public static final int TYPE_HTTP = 0;
|
||||
public static final int TYPE_SSL = 1;
|
||||
/**
|
||||
* Gets the names for the service.
|
||||
* @return The application defined service names.
|
||||
*/
|
||||
public String[] getServiceNames();
|
||||
/**
|
||||
* Gets the type identifier for the listener.
|
||||
* @return One of the TYPE_xxx identifiers defined by the IServiceListener interface.
|
||||
*/
|
||||
public int getType();
|
||||
/**
|
||||
* Gets the address associated with the listener.
|
||||
* @return The listener's address.
|
||||
*/
|
||||
public Address getAddress();
|
||||
}//IServiceListener//
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.web.server;
|
||||
|
||||
import com.foundation.web.interfaces.IContent;
|
||||
|
||||
/**
|
||||
* The handler called by the web server to get output given an error.
|
||||
*/
|
||||
public interface IWebServerErrorHandler {
|
||||
/**
|
||||
* Gets the content to display when a requested domain is not being served by the webserver
|
||||
* @param request The request.
|
||||
* @return The result.
|
||||
*/
|
||||
public IContent domainNotHosted(Request request);
|
||||
}//IWebServerErrorHandler//
|
||||
1478
Foundation Web Core/src/com/foundation/web/server/Request.java
Normal file
1478
Foundation Web Core/src/com/foundation/web/server/Request.java
Normal file
File diff suppressed because it is too large
Load Diff
291
Foundation Web Core/src/com/foundation/web/server/Response.java
Normal file
291
Foundation Web Core/src/com/foundation/web/server/Response.java
Normal file
@@ -0,0 +1,291 @@
|
||||
/*
|
||||
* Copyright (c) 2007,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.web.server;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Date;
|
||||
|
||||
import com.common.debug.Debug;
|
||||
import com.common.io.StreamSupport;
|
||||
import com.common.util.LiteHashMap;
|
||||
import com.common.util.LiteList;
|
||||
import com.foundation.event.IRequestHandler;
|
||||
import com.foundation.web.interfaces.*;
|
||||
|
||||
/**
|
||||
* Encapsulates a server response to a client HTTP request.
|
||||
*/
|
||||
public class Response implements IResponse {
|
||||
/** The sequence number for the request. */
|
||||
private int requestNumber = 0;
|
||||
/** Used to chain responses together when sending. */
|
||||
private Response nextResponse = null;
|
||||
/** The session associated with the response. */
|
||||
private ISession session = null;
|
||||
/** The application that is serving the response. */
|
||||
private IWebApplication application = null;
|
||||
/** The content which is returned to the requester if there isn't a forward url provided or an error code. */
|
||||
private IContent content = null;
|
||||
/** This is normally null, it is to allow errors and other abnormal responses to send specialized codes. */
|
||||
private String customHeader = null;
|
||||
/** This is normally null, it is to allow errors and other abnormal responses to send specialized codes. */
|
||||
private String header = null;
|
||||
/** The character set used by the content (if text). */
|
||||
private String characterSet = "UTF-8";
|
||||
/** Only set if we are forwarding - in which case the content is ignored. */
|
||||
private String forwardUri = null;
|
||||
/** Sets the redirect URI that the web server will use to send a response to this request. */
|
||||
private String redirectUri = null;
|
||||
/** The error type code or zero if no error occured. */
|
||||
private int errorType = 0;
|
||||
/** Whether the response should be compressed if possible (allowed by the client). Defaults may be set in the application via the WebOptions. */
|
||||
private Boolean compress = null;
|
||||
/** The request that spawned this response. */
|
||||
private Request request = null;
|
||||
/** The header field names in the order they should be sent. */
|
||||
private LiteList headerFieldNames = null;
|
||||
/** The header fields to be used if provided. If set, the server will not auto-generate the header. The first line of the response is mapped to a null field name (null key). */
|
||||
private LiteHashMap headerFieldMap = null;
|
||||
/**
|
||||
* Response constructor.
|
||||
* @param request The request that this response is for.
|
||||
* @param session The session associated with the response.
|
||||
* @param application The application providing the response.
|
||||
*/
|
||||
public Response(Request request, ISession session, IWebApplication application) {
|
||||
this.application = application;
|
||||
this.request = request;
|
||||
this.requestNumber = request.getRequestNumber();
|
||||
this.session = session;
|
||||
}//Response()//
|
||||
/**
|
||||
* Closes the response and cleans up any resources associated with it.
|
||||
*/
|
||||
protected void close() {
|
||||
if(content != null) {
|
||||
content.release();
|
||||
}//if//
|
||||
|
||||
if(request != null) {
|
||||
request.close();
|
||||
}//if//
|
||||
}//close()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.web.IResponse#getRequest()
|
||||
*/
|
||||
public IRequest getRequest() {
|
||||
return request;
|
||||
}//getRequest()//
|
||||
/**
|
||||
* Gets the sequence number for the request.
|
||||
* @return The request number which is used to order the responses.
|
||||
*/
|
||||
public int getRequestNumber() {
|
||||
return requestNumber;
|
||||
}//getRequestNumber()//
|
||||
/**
|
||||
* Gets the header for the response.
|
||||
* @return The header for the response, or null if the default header should be used.
|
||||
*/
|
||||
public String getHeader() {
|
||||
return header;
|
||||
}//getHeader()//
|
||||
/**
|
||||
* Gets the session that is the context for the request and response.
|
||||
* @return The session associated with the response.
|
||||
*/
|
||||
public ISession getSession() {
|
||||
return session;
|
||||
}//getSession()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.web.interfaces.IResponse#getErrorType()
|
||||
*/
|
||||
public int getErrorType() {
|
||||
return errorType;
|
||||
}//getErrorType()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.web.interfaces.IResponse#isError()
|
||||
*/
|
||||
public boolean isError() {
|
||||
return errorType != 0;
|
||||
}//isError()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.web.IResponse#setError(int)
|
||||
*/
|
||||
public void setError(int errorType) {
|
||||
if(this.content == null) {
|
||||
//Ignore additional error codes.//
|
||||
if(this.errorType == 0) {
|
||||
this.errorType = errorType;
|
||||
this.content = application.getErrorContent(errorType);
|
||||
this.header = application.getErrorHeader(errorType);
|
||||
}//if//
|
||||
}//if//
|
||||
else {
|
||||
throw new RuntimeException("Cannot set the response content twice.");
|
||||
}//else//
|
||||
}//setError()//
|
||||
/**
|
||||
* Gets the character set used by the content (if text).
|
||||
* @return The content's character set.
|
||||
*/
|
||||
public String getCharacterSet() {
|
||||
return characterSet;
|
||||
}//getCharacterSet()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.web.IResponse#getContent()
|
||||
*/
|
||||
public IContent getContent() {
|
||||
return content;
|
||||
}//getContent()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.web.IResponse#setContent(com.foundation.web.IContent)
|
||||
*/
|
||||
public void setContent(IContent content) {
|
||||
if(this.content == null) {
|
||||
this.content = content;
|
||||
}//if//
|
||||
else {
|
||||
throw new RuntimeException("Cannot set the response content twice.");
|
||||
}//else//
|
||||
}//setContent()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.web.IResponse#getApplication()
|
||||
*/
|
||||
public IWebApplication getApplication() {
|
||||
return application;
|
||||
}//getApplication()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.web.interfaces.IResponse#getForwardUri()
|
||||
*/
|
||||
public String getForwardUri() {
|
||||
return forwardUri;
|
||||
}//getForwardUri()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.web.interfaces.IResponse#setForwardUri(java.lang.String)
|
||||
*/
|
||||
public void setForwardUri(String forwardUri) {
|
||||
this.forwardUri = forwardUri;
|
||||
}//setForwardUri()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.web.interfaces.IResponse#getRedirectUri()
|
||||
*/
|
||||
public String getRedirectUri() {
|
||||
return redirectUri;
|
||||
}//getRedirectUri()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.web.interfaces.IResponse#setRedirectUri(java.lang.String)
|
||||
*/
|
||||
public void setRedirectUri(String redirectUri) {
|
||||
this.redirectUri = redirectUri;
|
||||
}//setRedirectUri()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.web.interfaces.IResponse#getCompress()
|
||||
*/
|
||||
public Boolean getCompress() {
|
||||
return compress == null ? getApplication() != null ? getApplication().getCompressResponses() ? Boolean.TRUE : Boolean.FALSE : Boolean.FALSE : compress;
|
||||
}//getCompress()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.web.interfaces.IResponse#setCompress(java.lang.Boolean)
|
||||
*/
|
||||
public void setCompress(Boolean compress) {
|
||||
this.compress = compress;
|
||||
}//setCompress()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.web.interfaces.IResponse#getCustomHeader()
|
||||
*/
|
||||
public String getCustomHeader() {
|
||||
return customHeader;
|
||||
}//getCustomHeader()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.web.IResponse#setCustomHeader(java.lang.String)
|
||||
*/
|
||||
public void setCustomHeader(String customHeader) {
|
||||
this.customHeader = customHeader;
|
||||
}//getCustomHeader()//
|
||||
/**
|
||||
* Gets the next response in the chain of responses.
|
||||
* @return The next response to be sent.
|
||||
*/
|
||||
public Response getNextResponse() {
|
||||
return nextResponse;
|
||||
}//getNextResponse()//
|
||||
/**
|
||||
* Sets the next response in the chain of responses.
|
||||
* @param nextResponse The response to send after this one.
|
||||
*/
|
||||
public void setNextResponse(Response nextResponse) {
|
||||
this.nextResponse = nextResponse;
|
||||
}//setNextResponse()//
|
||||
/**
|
||||
* Gets the ordered list of header field names.
|
||||
* @return The optional field names for the header. If provided then the server shouldn't generate a header for the response.
|
||||
*/
|
||||
protected LiteList getHeaderFieldNames() {
|
||||
return headerFieldNames;
|
||||
}//getHeaderFieldNames()//
|
||||
/**
|
||||
* Gets the mapping of header field values by their name.
|
||||
* @return The map of header field name/value pairs. The first header line (the response line) is mapped to a null field name.
|
||||
*/
|
||||
protected LiteHashMap getHeaderFieldMap() {
|
||||
return headerFieldMap;
|
||||
}//getHeaderFieldMap()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.web.interfaces.IResponse#getHeaderFieldValue(java.lang.String)
|
||||
*/
|
||||
public String getHeaderFieldValue(String name) {
|
||||
return (String) (headerFieldMap != null ? headerFieldMap.get(name) : null);
|
||||
}//getHeaderFieldValue()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.web.interfaces.IResponse#setHeader(java.lang.String)
|
||||
*/
|
||||
public void setHeader(String header) {
|
||||
//Parse the header for use when sending the response.//
|
||||
if(header != null) {
|
||||
String[] headerLines;
|
||||
|
||||
//Basic error checking.//
|
||||
if(!header.endsWith("\r\n\r\n")) {
|
||||
throw new RuntimeException("Invalid header: Must end with '\r\n\r\n'.");
|
||||
}//if//
|
||||
|
||||
headerLines = header.substring(0, header.length() - 4).split("\r\n");
|
||||
|
||||
|
||||
headerFieldNames = new LiteList(headerLines.length - 1);
|
||||
headerFieldMap = new LiteHashMap(headerLines.length + 10);
|
||||
//Place the response line (first line in the header).//
|
||||
headerFieldMap.put(null, headerLines[0].trim());
|
||||
|
||||
//Save all other lines in the response header.//
|
||||
if(headerLines.length > 1) {
|
||||
for(int index = 1; index < headerLines.length; index++) {
|
||||
String next = headerLines[index].trim();
|
||||
int colonIndex = next.indexOf(':');
|
||||
String fieldName;
|
||||
|
||||
//Basic error checking.//
|
||||
if(colonIndex < 1 || next.length() <= colonIndex + 1) {
|
||||
throw new RuntimeException("Invalid header: Expecting the format: '{fieldName}: {fieldValue}', received: '" + next + "'. The whole header provided was:\r\n" + header);
|
||||
}//if//
|
||||
|
||||
fieldName = next.substring(0, colonIndex).trim();
|
||||
headerFieldNames.add(fieldName);
|
||||
headerFieldMap.put(fieldName, next.substring(colonIndex + 1).trim());
|
||||
}//for//
|
||||
}//if//
|
||||
}//if//
|
||||
else {
|
||||
//Clear the header information - the server will generate a header.//
|
||||
headerFieldMap = null;
|
||||
headerFieldNames = null;
|
||||
}//else//
|
||||
}//setContentProvider()//
|
||||
}//Response//
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.foundation.web.server;
|
||||
|
||||
import com.common.debug.Debug;
|
||||
import com.foundation.web.interfaces.*;
|
||||
|
||||
/**
|
||||
* A container for the web application, providing access control and locking to enable the ability to reload or unload an application at runtime.
|
||||
*/
|
||||
public class WebApplicationContainer implements IWebApplicationContainer {
|
||||
/** The web application. */
|
||||
private IWebApplication webApplication;
|
||||
/** The number of threads actively accessing the web application. */
|
||||
private int activityCounter = 0;
|
||||
/** The flag indiciating whether the container is, or would like to reload or unload the web application. */
|
||||
private boolean isLoading = false;
|
||||
/** Whether the web application was closed and all requests should fail. */
|
||||
private boolean isClosed = false;
|
||||
/**
|
||||
* WebApplicationContainer constructor.
|
||||
* @param webApplication The web application being contained.
|
||||
*/
|
||||
public WebApplicationContainer(IWebApplication webApplication) {
|
||||
this.webApplication = webApplication;
|
||||
}//WebApplicationContainer()//
|
||||
/**
|
||||
* Gets the contained web application.
|
||||
* <p>Note: Callers must synchronize on this container while accessing the web application and it's contents.
|
||||
* Long running calls, such as processing requests related to the container, must increment the activity counter, and then decrement when done.
|
||||
* This prevents the web application from being unloaded or reloaded while it is being accessed.</p>
|
||||
* @return The web application held by the container. This may be null if the web application no longer exists in the web server.
|
||||
*/
|
||||
public IWebApplication getWebApplication() {
|
||||
return webApplication;
|
||||
}//getWebApplication()//
|
||||
/**
|
||||
* Sets the contained web application.
|
||||
* <p>Note: Callers must synchronize on this container while accessing the web application and it's contents.
|
||||
* Long running calls, such as processing requests related to the container, must increment the activity counter, and then decrement when done.
|
||||
* This prevents the web application from being unloaded or reloaded while it is being accessed.</p>
|
||||
* @param webApplication The web application held by the container. This may be null if the web application no longer exists in the web server.
|
||||
*/
|
||||
public void setWebApplication(IWebApplication webApplication) {
|
||||
this.webApplication = webApplication;
|
||||
}//getWebApplication()//
|
||||
/**
|
||||
* Closes the web application such that all pending requests will fail.
|
||||
* The caller must first call beginLoading() to lock the application and ensure all requests being processed have finished.
|
||||
*/
|
||||
public void close() {
|
||||
isClosed = true;
|
||||
}//close()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.web.interfaces.IWebApplicationContainer#incrementActivityCounter()
|
||||
*/
|
||||
public synchronized boolean incrementActivityCounter() {
|
||||
boolean result = false;
|
||||
|
||||
//Block until the container is no longer marked as loading.//
|
||||
while(isLoading) {
|
||||
try {
|
||||
wait(1000);
|
||||
}//try//
|
||||
catch(Throwable e) {
|
||||
Debug.handle(e);
|
||||
}//catch//
|
||||
}//while//
|
||||
|
||||
if(!isClosed) {
|
||||
activityCounter++;
|
||||
result = true;
|
||||
}//if//
|
||||
|
||||
return result;
|
||||
}//incrementActivityCounter()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.web.interfaces.IWebApplicationContainer#decrementActivityCounter()
|
||||
*/
|
||||
public synchronized void decrementActivityCounter() {
|
||||
activityCounter--;
|
||||
|
||||
//Ensure the beginLoading call wakes up.//
|
||||
if(activityCounter == 0 && isLoading) {
|
||||
notifyAll();
|
||||
}//if//
|
||||
|
||||
//Debug code.//
|
||||
if(activityCounter < 0) {
|
||||
throw new RuntimeException("Failed to have a single decrement for each increment.");
|
||||
}//if//
|
||||
}//decrementActivityCounter()//
|
||||
/**
|
||||
* Begins the sequence to unload/reload the web application safely.
|
||||
* This method may block until all user threads have finished their jobs.
|
||||
*/
|
||||
public synchronized void beginLoading() {
|
||||
if(isLoading) {
|
||||
throw new RuntimeException("Failed to call endLoading before re-calling beginLoading.");
|
||||
}//if//
|
||||
|
||||
isLoading = true;
|
||||
|
||||
//Wait for active use threads.//
|
||||
while(activityCounter != 0) {
|
||||
try {
|
||||
wait(1000);
|
||||
}//try//
|
||||
catch(Throwable e) {
|
||||
Debug.handle(e);
|
||||
}//catch//
|
||||
}//while//
|
||||
}//beginLoading()//
|
||||
public synchronized void endLoading() {
|
||||
if(!isLoading || activityCounter != 0) {
|
||||
throw new RuntimeException("Failed to have a single endLoading call for each beginLoading call.");
|
||||
}//if//
|
||||
|
||||
isLoading = false;
|
||||
//Re-start any threads waiting to use the web application.//
|
||||
notifyAll();
|
||||
}//endLoading()//
|
||||
}//WebApplicationContainer//
|
||||
3063
Foundation Web Core/src/com/foundation/web/server/WebServer.java
Normal file
3063
Foundation Web Core/src/com/foundation/web/server/WebServer.java
Normal file
File diff suppressed because it is too large
Load Diff
730
Foundation Web Core/src/com/foundation/web/view/MainView.java
Normal file
730
Foundation Web Core/src/com/foundation/web/view/MainView.java
Normal file
@@ -0,0 +1,730 @@
|
||||
package com.foundation.web.view;
|
||||
|
||||
/**
|
||||
* MainView
|
||||
*/
|
||||
public class MainView extends com.foundation.view.swt.Window implements com.foundation.view.IAssociationHandler {
|
||||
//Component Names//
|
||||
public static final String CONTROLLER_HOLDER_COMPONENT = "controllerHolder";
|
||||
public static final String SELECTED_LOG_ENTRY_COMPONENT = "selectedLogEntry";
|
||||
public static final String TAB_PANEL_COMPONENT = "tabPanel";
|
||||
public static final String PAGE1_PANEL_COMPONENT = "page1Panel";
|
||||
public static final String REFRESH_ALL_LINK_COMPONENT = "refreshAllLink";
|
||||
public static final String LINK_PANEL_COMPONENT = "linkPanel";
|
||||
public static final String CLEAR_CACHE_LINK_COMPONENT = "clearCacheLink";
|
||||
public static final String RELOAD_LINK_COMPONENT = "reloadLink";
|
||||
public static final String REFRESH_LINK_COMPONENT = "refreshLink";
|
||||
public static final String REMOVE_LINK_COMPONENT = "removeLink";
|
||||
public static final String WEBAPP_BUNDLE_LIST_COMPONENT = "webappBundleList";
|
||||
public static final String INSTRUCTIONS_LABEL_COMPONENT = "instructionsLabel";
|
||||
public static final String PAGE2_PANEL_COMPONENT = "page2Panel";
|
||||
public static final String CARD_PANEL0_COMPONENT = "cardPanel0";
|
||||
public static final String WEBAPP_TABLE_COMPONENT = "webappTable";
|
||||
public static final String CARD_PANEL1_COMPONENT = "cardPanel1";
|
||||
public static final String BACK_LINK_COMPONENT = "backLink";
|
||||
public static final String APP_SASH_COMPONENT = "appSash";
|
||||
public static final String LOG_TABLE_COMPONENT = "logTable";
|
||||
public static final String LOG_TEXT_COMPONENT = "logText";
|
||||
public static final String MAIN_VIEW_COMPONENT = "MainView";
|
||||
|
||||
//Association Identifiers//
|
||||
protected static final int SELECTED_LOG_ENTRY_ASSOCIATION_PARENT_ASSOCIATION_0 = 0;
|
||||
protected static final int WEBAPP_BUNDLE_LIST_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0 = 1;
|
||||
protected static final int WEBAPP_BUNDLE_LIST_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_1 = 2;
|
||||
protected static final int WEBAPP_BUNDLE_LIST_ASSOCIATION_COLLECTION_ASSOCIATION_0 = 3;
|
||||
protected static final int WEBAPP_BUNDLE_LIST_ASSOCIATION_SELECTION_ASSOCIATION_0 = 4;
|
||||
protected static final int WEBAPP_TABLE_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0 = 5;
|
||||
protected static final int WEBAPP_TABLE_ASSOCIATION_ROW_FOREGROUND_COLOR_CUSTOM_ASSOCIATION_0 = 6;
|
||||
protected static final int WEBAPP_TABLE_ASSOCIATION_COLLECTION_ASSOCIATION_0 = 7;
|
||||
protected static final int WEBAPP_TABLE_ASSOCIATION_SELECTION_ASSOCIATION_0 = 8;
|
||||
protected static final int LOG_TABLE_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0 = 9;
|
||||
protected static final int LOG_TABLE_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_FOREGROUND_COLOR_ASSOCIATION_0 = 10;
|
||||
protected static final int LOG_TABLE_ASSOCIATION_COLLECTION_ASSOCIATION_0 = 11;
|
||||
protected static final int LOG_TABLE_ASSOCIATION_SELECTION_ASSOCIATION_0 = 12;
|
||||
protected static final int LOG_TEXT_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0 = 13;
|
||||
protected static final int LAYOUT_PAGE_2_PANEL_ASSOC_TOP_INDEX_ASSOCIATION_0 = 14;
|
||||
|
||||
//Method Association Identifiers//
|
||||
protected static final int THIS_CLOSED_METHOD_ASSOCIATION = 0;
|
||||
protected static final int REFRESH_ALL_LINK_SELECTION_METHOD_ASSOCIATION = 1;
|
||||
protected static final int CLEAR_CACHE_LINK_SELECTION_METHOD_ASSOCIATION = 2;
|
||||
protected static final int RELOAD_LINK_SELECTION_METHOD_ASSOCIATION = 3;
|
||||
protected static final int REFRESH_LINK_SELECTION_METHOD_ASSOCIATION = 4;
|
||||
protected static final int REMOVE_LINK_SELECTION_METHOD_ASSOCIATION = 5;
|
||||
protected static final int WEBAPP_BUNDLE_LIST_DOUBLE_CLICK_METHOD_ASSOCIATION = 6;
|
||||
protected static final int BACK_LINK_SELECTION_METHOD_ASSOCIATION = 7;
|
||||
|
||||
//View Components//
|
||||
private com.foundation.view.swt.ValueHolder controllerHolder = null;
|
||||
private com.foundation.view.swt.ValueHolder selectedLogEntry = null;
|
||||
private com.foundation.view.swt.TabPanel tabPanel = null;
|
||||
private com.foundation.view.swt.Panel page1Panel = null;
|
||||
private com.foundation.view.swt.Link refreshAllLink = null;
|
||||
private com.foundation.view.swt.Panel linkPanel = null;
|
||||
private com.foundation.view.swt.Link clearCacheLink = null;
|
||||
private com.foundation.view.swt.Link reloadLink = null;
|
||||
private com.foundation.view.swt.Link refreshLink = null;
|
||||
private com.foundation.view.swt.Link removeLink = null;
|
||||
private com.foundation.view.swt.SimpleTable webappBundleList = null;
|
||||
private com.foundation.view.swt.Label instructionsLabel = null;
|
||||
private com.foundation.view.swt.Panel page2Panel = null;
|
||||
private com.foundation.view.swt.Panel cardPanel0 = null;
|
||||
private com.foundation.view.swt.SimpleTable webappTable = null;
|
||||
private com.foundation.view.swt.Panel cardPanel1 = null;
|
||||
private com.foundation.view.swt.Link backLink = null;
|
||||
private com.foundation.view.swt.SashForm appSash = null;
|
||||
private com.foundation.view.swt.SimpleTable logTable = null;
|
||||
private com.foundation.view.swt.TextField logText = null;
|
||||
/**
|
||||
* MainView default constructor.
|
||||
* <p>Warning: This constructor is intended for use by the metadata service <b>only</b>. This constructor should <b>never</b> be called by the view's controller.</p>
|
||||
*/
|
||||
public MainView() {
|
||||
}//MainView()//
|
||||
/**
|
||||
* MainView constructor.
|
||||
* @param controller The view controller which will be assigned to the value holder(s) that don't depend on another value holder for their value.
|
||||
*/
|
||||
public MainView(com.foundation.controller.ViewController controller) {
|
||||
super((com.foundation.controller.ViewController) controller.getParent(), MAIN_VIEW_COMPONENT, com.foundation.view.swt.Window.STYLE_SHELL_TRIM, controller.getContext(), controller);
|
||||
|
||||
}//MainView()//
|
||||
public void initializeControllerHolder(com.foundation.view.swt.Container parent) {
|
||||
controllerHolder = new com.foundation.view.swt.ValueHolder(parent, CONTROLLER_HOLDER_COMPONENT, com.foundation.web.view.controller.MainViewController.class);
|
||||
}//initializeControllerHolder()//
|
||||
public void initializeSelectedLogEntry(com.foundation.view.swt.Container parent) {
|
||||
selectedLogEntry = new com.foundation.view.swt.ValueHolder(parent, SELECTED_LOG_ENTRY_COMPONENT, com.foundation.web.server.shared.model.WebappLogEntry.class);
|
||||
selectedLogEntry.setParentAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.foundation.web.view.controller.MainViewController.class, SELECTED_LOG_ENTRY_ASSOCIATION_PARENT_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.foundation.web.view.controller.MainViewController.class, com.foundation.web.view.controller.MainViewController.SELECTED_LOG_ENTRY)}, null,true)}));
|
||||
}//initializeSelectedLogEntry()//
|
||||
public void initializeRefreshAllLink(com.foundation.view.swt.Container parent) {
|
||||
refreshAllLink = new com.foundation.view.swt.Link(parent, REFRESH_ALL_LINK_COMPONENT, 0);
|
||||
|
||||
refreshAllLink.setText("<a>Refresh All Webapps</a>");
|
||||
refreshAllLink.setSelectionMethod(new com.foundation.view.MethodAssociation(this, REFRESH_ALL_LINK_SELECTION_METHOD_ASSOCIATION, refreshAllLink, "controllerHolder", null, null));
|
||||
}//initializeRefreshAllLink()//
|
||||
public void initializeClearCacheLink(com.foundation.view.swt.Container parent) {
|
||||
clearCacheLink = new com.foundation.view.swt.Link(parent, CLEAR_CACHE_LINK_COMPONENT, 0);
|
||||
|
||||
clearCacheLink.setText("<a>Clear Cache</a>");
|
||||
clearCacheLink.setSelectionMethod(new com.foundation.view.MethodAssociation(this, CLEAR_CACHE_LINK_SELECTION_METHOD_ASSOCIATION, clearCacheLink, "controllerHolder", null, null));
|
||||
clearCacheLink.setDefaultToolTipText("Clear's the webapp's cache (if used).");
|
||||
}//initializeClearCacheLink()//
|
||||
public void initializeReloadLink(com.foundation.view.swt.Container parent) {
|
||||
reloadLink = new com.foundation.view.swt.Link(parent, RELOAD_LINK_COMPONENT, 0);
|
||||
|
||||
reloadLink.setText("<a>Reload Webapp</a>");
|
||||
reloadLink.setSelectionMethod(new com.foundation.view.MethodAssociation(this, RELOAD_LINK_SELECTION_METHOD_ASSOCIATION, reloadLink, "controllerHolder", null, null));
|
||||
reloadLink.setDefaultToolTipText("Reloads the webapp without unpacking the latest webapp archive.");
|
||||
}//initializeReloadLink()//
|
||||
public void initializeRefreshLink(com.foundation.view.swt.Container parent) {
|
||||
refreshLink = new com.foundation.view.swt.Link(parent, REFRESH_LINK_COMPONENT, 0);
|
||||
|
||||
refreshLink.setText("<a>Refresh Webapp</a>");
|
||||
refreshLink.setSelectionMethod(new com.foundation.view.MethodAssociation(this, REFRESH_LINK_SELECTION_METHOD_ASSOCIATION, refreshLink, "controllerHolder", null, null));
|
||||
refreshLink.setDefaultToolTipText("Unpacks the webapp archive and reloads the webapp.");
|
||||
}//initializeRefreshLink()//
|
||||
public void initializeRemoveLink(com.foundation.view.swt.Container parent) {
|
||||
removeLink = new com.foundation.view.swt.Link(parent, REMOVE_LINK_COMPONENT, 0);
|
||||
|
||||
removeLink.setText("<a>Remove</a>");
|
||||
removeLink.setSelectionMethod(new com.foundation.view.MethodAssociation(this, REMOVE_LINK_SELECTION_METHOD_ASSOCIATION, removeLink, "controllerHolder", null, null));
|
||||
removeLink.setDefaultToolTipText("Removes the webapp's archive and all related files (except any external files or external settings).");
|
||||
}//initializeRemoveLink()//
|
||||
public void initializeLinkPanel(com.foundation.view.swt.Container parent) {
|
||||
linkPanel = new com.foundation.view.swt.Panel(parent, LINK_PANEL_COMPONENT, 0);
|
||||
|
||||
initializeClearCacheLink(linkPanel);
|
||||
initializeReloadLink(linkPanel);
|
||||
initializeRefreshLink(linkPanel);
|
||||
initializeRemoveLink(linkPanel);
|
||||
com.foundation.view.swt.RowLayout layout = new com.foundation.view.swt.RowLayout(linkPanel);
|
||||
|
||||
layout.setSpacing(10);
|
||||
layout.setMarginWidth(0);
|
||||
layout.setWrap(false);
|
||||
layout.setPack(true);
|
||||
linkPanel.setLayout(layout);
|
||||
linkPanel.setTabOrder(new com.common.util.LiteList(new Object[] {}));
|
||||
}//initializeLinkPanel()//
|
||||
public void initializeWebappBundleList(com.foundation.view.swt.Container parent) {
|
||||
webappBundleList = new com.foundation.view.swt.SimpleTable(parent, WEBAPP_BUNDLE_LIST_COMPONENT, com.foundation.view.swt.SimpleTable.STYLE_BORDER);
|
||||
|
||||
webappBundleList.showHeaders(false);
|
||||
webappBundleList.setAutoFit(true);
|
||||
com.foundation.view.swt.SimpleTable.ColumnData webappBundleListColumnPart0 = webappBundleList.addColumn();
|
||||
webappBundleListColumnPart0.setCellTextAssociation(new com.foundation.view.MultiAssociationContainer(new com.foundation.view.MultiAssociation[] {new com.foundation.view.MultiAssociation(com.foundation.web.server.shared.model.WebappBundle.class, WEBAPP_BUNDLE_LIST_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.foundation.web.server.shared.model.WebappBundle.class, com.foundation.web.server.shared.model.WebappBundle.NAME)}, null,true), new com.foundation.view.MultiAssociation(com.foundation.web.server.shared.model.ServerApp.class, WEBAPP_BUNDLE_LIST_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_1, this, false, null, null, new com.foundation.view.EventAssociation[0], null,true)}));
|
||||
webappBundleList.setAutoSynchronizeSelection(true);
|
||||
webappBundleList.setAutoSynchronizeSelectionDelay(0l);
|
||||
webappBundleList.setAutoValidate(false);
|
||||
webappBundleList.setCollectionAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.foundation.web.view.controller.MainViewController.class, WEBAPP_BUNDLE_LIST_ASSOCIATION_COLLECTION_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.foundation.web.view.controller.MainViewController.class, com.foundation.web.view.controller.MainViewController.WEBAPP_BUNDLES)}, null,true)}));
|
||||
webappBundleList.setSelectionAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.foundation.web.view.controller.MainViewController.class, WEBAPP_BUNDLE_LIST_ASSOCIATION_SELECTION_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.foundation.web.view.controller.MainViewController.class, com.foundation.web.view.controller.MainViewController.SELECTED_BUNDLE)}, null,true)}));
|
||||
webappBundleList.setDoubleClickMethod(new com.foundation.view.MethodAssociation(this, WEBAPP_BUNDLE_LIST_DOUBLE_CLICK_METHOD_ASSOCIATION, webappBundleList, "controllerHolder", null, null));
|
||||
}//initializeWebappBundleList()//
|
||||
public void initializeInstructionsLabel(com.foundation.view.swt.Container parent) {
|
||||
instructionsLabel = new com.foundation.view.swt.Label(parent, INSTRUCTIONS_LABEL_COMPONENT, 0);
|
||||
|
||||
instructionsLabel.setText("Double click to clear the webapp's cache.");
|
||||
instructionsLabel.setDefaultForegroundColor(new com.foundation.view.JefColor("gray"));
|
||||
}//initializeInstructionsLabel()//
|
||||
public void initializePage1Panel(com.foundation.view.swt.Container parent) {
|
||||
page1Panel = new com.foundation.view.swt.Panel(parent, PAGE1_PANEL_COMPONENT, 0);
|
||||
|
||||
initializeRefreshAllLink(page1Panel);
|
||||
initializeLinkPanel(page1Panel);
|
||||
initializeWebappBundleList(page1Panel);
|
||||
initializeInstructionsLabel(page1Panel);
|
||||
com.foundation.view.swt.GridLayout layout = new com.foundation.view.swt.GridLayout(page1Panel);
|
||||
|
||||
layout.setNumColumns(1);
|
||||
layout.setMakeColumnsEqualWidth(false);
|
||||
layout.setMarginHeight(0);
|
||||
layout.setMarginWidth(0);
|
||||
layout.setHorizontalSpacing(2);
|
||||
layout.setVerticalSpacing(2);
|
||||
page1Panel.setLayout(layout);
|
||||
page1Panel.setTabOrder(new com.common.util.LiteList(new Object[] {}));
|
||||
page1Panel.setDefaultContainerTitle("Webapp Management");
|
||||
}//initializePage1Panel()//
|
||||
public void initializeWebappTable(com.foundation.view.swt.Container parent) {
|
||||
webappTable = new com.foundation.view.swt.SimpleTable(parent, WEBAPP_TABLE_COMPONENT, com.foundation.view.swt.SimpleTable.STYLE_BORDER);
|
||||
|
||||
webappTable.showHeaders(true);
|
||||
webappTable.setAutoFit(true);
|
||||
com.foundation.view.swt.SimpleTable.ColumnData webappTableColumnPart0 = webappTable.addColumn();
|
||||
webappTableColumnPart0.setHeaderText("Web Application");
|
||||
webappTableColumnPart0.setCellTextAssociation(new com.foundation.view.MultiAssociationContainer(new com.foundation.view.MultiAssociation[] {new com.foundation.view.MultiAssociation(com.foundation.web.server.shared.model.WebappBundle.class, WEBAPP_TABLE_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.foundation.web.server.shared.model.WebappBundle.class, com.foundation.web.server.shared.model.WebappBundle.NAME)}, null,true)}));
|
||||
webappTable.setRowForegroundColorCustomAssociation(new com.foundation.view.MultiAssociationContainer(new com.foundation.view.MultiAssociation[] {new com.foundation.view.MultiAssociation(com.foundation.web.server.shared.model.BaseApp.class, WEBAPP_TABLE_ASSOCIATION_ROW_FOREGROUND_COLOR_CUSTOM_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(webappTable, null, null, com.foundation.web.server.shared.model.BaseApp.class, com.foundation.web.server.shared.model.BaseApp.ERROR_CHANGE_FLAG), new com.foundation.view.EventAssociation(webappTable, null, null, com.foundation.web.server.shared.model.BaseApp.class, com.foundation.web.server.shared.model.BaseApp.WARNING_CHANGE_FLAG), new com.foundation.view.EventAssociation(webappTable, null, null, com.foundation.web.server.shared.model.BaseApp.class, com.foundation.web.server.shared.model.BaseApp.INFO_CHANGE_FLAG)},"controllerHolder",true)}));
|
||||
webappTable.setAutoSynchronizeSelection(true);
|
||||
webappTable.setAutoSynchronizeSelectionDelay(0l);
|
||||
webappTable.setAutoValidate(false);
|
||||
webappTable.setCollectionAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.foundation.web.view.controller.MainViewController.class, WEBAPP_TABLE_ASSOCIATION_COLLECTION_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.foundation.web.view.controller.MainViewController.class, com.foundation.web.view.controller.MainViewController.APPS)}, null,true)}));
|
||||
webappTable.setSelectionAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.foundation.web.view.controller.MainViewController.class, WEBAPP_TABLE_ASSOCIATION_SELECTION_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.foundation.web.view.controller.MainViewController.class, com.foundation.web.view.controller.MainViewController.SELECTED_APP)}, null,true)}));
|
||||
}//initializeWebappTable()//
|
||||
public void initializeCardPanel0(com.foundation.view.swt.Container parent) {
|
||||
cardPanel0 = new com.foundation.view.swt.Panel(parent, CARD_PANEL0_COMPONENT, 0);
|
||||
|
||||
initializeWebappTable(cardPanel0);
|
||||
com.foundation.view.swt.FillLayout layout = new com.foundation.view.swt.FillLayout(cardPanel0);
|
||||
|
||||
cardPanel0.setLayout(layout);
|
||||
cardPanel0.setTabOrder(new com.common.util.LiteList(new Object[] {}));
|
||||
}//initializeCardPanel0()//
|
||||
public void initializeBackLink(com.foundation.view.swt.Container parent) {
|
||||
backLink = new com.foundation.view.swt.Link(parent, BACK_LINK_COMPONENT, 0);
|
||||
|
||||
backLink.setText("<a>Back to application list...</a>");
|
||||
backLink.setSelectionMethod(new com.foundation.view.MethodAssociation(this, BACK_LINK_SELECTION_METHOD_ASSOCIATION, backLink, "controllerHolder", null, null));
|
||||
}//initializeBackLink()//
|
||||
public void initializeLogTable(com.foundation.view.swt.Container parent) {
|
||||
logTable = new com.foundation.view.swt.SimpleTable(parent, LOG_TABLE_COMPONENT, com.foundation.view.swt.SimpleTable.STYLE_BORDER);
|
||||
|
||||
logTable.showHeaders(false);
|
||||
logTable.setAutoFit(true);
|
||||
com.foundation.view.swt.SimpleTable.ColumnData logTableColumnPart0 = logTable.addColumn();
|
||||
logTableColumnPart0.setCellTextAssociation(new com.foundation.view.MultiAssociationContainer(new com.foundation.view.MultiAssociation[] {new com.foundation.view.MultiAssociation(com.foundation.web.server.shared.model.WebappLogEntry.class, LOG_TABLE_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[0], null,true)}));
|
||||
logTableColumnPart0.setForegroundColorAssociation(new com.foundation.view.MultiAssociationContainer(new com.foundation.view.MultiAssociation[] {new com.foundation.view.MultiAssociation(com.foundation.web.server.shared.model.WebappLogEntry.class, LOG_TABLE_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_FOREGROUND_COLOR_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[0],"controllerHolder",true)}));
|
||||
logTable.setAutoSynchronizeSelection(true);
|
||||
logTable.setAutoSynchronizeSelectionDelay(0l);
|
||||
logTable.setAutoValidate(false);
|
||||
logTable.setCollectionAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.foundation.web.view.controller.MainViewController.class, LOG_TABLE_ASSOCIATION_COLLECTION_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.foundation.web.view.controller.MainViewController.class, com.foundation.web.view.controller.MainViewController.WEBAPP_LOG_ENTRIES)}, null,true)}));
|
||||
logTable.setSelectionAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.foundation.web.view.controller.MainViewController.class, LOG_TABLE_ASSOCIATION_SELECTION_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.foundation.web.view.controller.MainViewController.class, com.foundation.web.view.controller.MainViewController.SELECTED_LOG_ENTRY)}, null,true)}));
|
||||
}//initializeLogTable()//
|
||||
public void initializeLogText(com.foundation.view.swt.Container parent) {
|
||||
logText = new com.foundation.view.swt.TextField(parent, LOG_TEXT_COMPONENT, com.foundation.view.swt.TextField.STYLE_BORDER|com.foundation.view.swt.TextField.STYLE_V_SCROLL|com.foundation.view.swt.TextField.STYLE_H_SCROLL|com.foundation.view.swt.TextField.STYLE_MULTI);
|
||||
|
||||
com.foundation.view.swt.TextField.TextFormat logTextFormat = (com.foundation.view.swt.TextField.TextFormat) logText.initializeFormat(com.foundation.view.swt.TextField.TextFormat.class);
|
||||
logTextFormat.setValueAssociation(new com.foundation.view.SingleAssociationContainer("selectedLogEntry", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.foundation.web.server.shared.model.WebappLogEntry.class, LOG_TEXT_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.foundation.web.server.shared.model.WebappLogEntry.class, com.foundation.web.server.shared.model.WebappLogEntry.TEXT)}, null,true)}));
|
||||
}//initializeLogText()//
|
||||
public void initializeAppSash(com.foundation.view.swt.Container parent) {
|
||||
appSash = new com.foundation.view.swt.SashForm(parent, APP_SASH_COMPONENT, com.foundation.view.swt.SashForm.STYLE_SMOOTH|com.foundation.view.swt.SashForm.STYLE_VERTICAL);
|
||||
|
||||
initializeLogTable(appSash);
|
||||
initializeLogText(appSash);
|
||||
appSash.setTabOrder(new com.common.util.LiteList(new Object[] {}));
|
||||
}//initializeAppSash()//
|
||||
public void initializeCardPanel1(com.foundation.view.swt.Container parent) {
|
||||
cardPanel1 = new com.foundation.view.swt.Panel(parent, CARD_PANEL1_COMPONENT, 0);
|
||||
|
||||
initializeBackLink(cardPanel1);
|
||||
initializeAppSash(cardPanel1);
|
||||
com.foundation.view.swt.GridLayout layout = new com.foundation.view.swt.GridLayout(cardPanel1);
|
||||
|
||||
layout.setNumColumns(1);
|
||||
layout.setMakeColumnsEqualWidth(false);
|
||||
layout.setMarginHeight(0);
|
||||
layout.setMarginWidth(0);
|
||||
layout.setHorizontalSpacing(2);
|
||||
layout.setVerticalSpacing(2);
|
||||
cardPanel1.setLayout(layout);
|
||||
cardPanel1.setTabOrder(new com.common.util.LiteList(new Object[] {}));
|
||||
}//initializeCardPanel1()//
|
||||
public void initializePage2Panel(com.foundation.view.swt.Container parent) {
|
||||
page2Panel = new com.foundation.view.swt.Panel(parent, PAGE2_PANEL_COMPONENT, 0);
|
||||
|
||||
initializeCardPanel0(page2Panel);
|
||||
initializeCardPanel1(page2Panel);
|
||||
com.foundation.view.swt.CardLayout layout = new com.foundation.view.swt.CardLayout(page2Panel);
|
||||
|
||||
layout.setMarginHeight(0);
|
||||
layout.setMarginWidth(0);
|
||||
layout.setTopIndexAssociation(new com.foundation.view.SingleAssociationContainer("controllerHolder", new com.foundation.view.SingleAssociation[] {new com.foundation.view.SingleAssociation(com.foundation.web.view.controller.MainViewController.class, LAYOUT_PAGE_2_PANEL_ASSOC_TOP_INDEX_ASSOCIATION_0, this, false, null, null, new com.foundation.view.EventAssociation[] {new com.foundation.view.EventAssociation(null, null, null, com.foundation.web.view.controller.MainViewController.class, com.foundation.web.view.controller.MainViewController.DISPLAYED_LOG_CARD)}, null,true)}));
|
||||
page2Panel.setLayout(layout);
|
||||
page2Panel.setTabOrder(new com.common.util.LiteList(new Object[] {}));
|
||||
page2Panel.setDefaultContainerTitle("Logs");
|
||||
}//initializePage2Panel()//
|
||||
public void initializeTabPanel(com.foundation.view.swt.Container parent) {
|
||||
tabPanel = new com.foundation.view.swt.TabPanel(parent, TAB_PANEL_COMPONENT, com.foundation.view.swt.TabPanel.STYLE_TOP);
|
||||
|
||||
initializePage1Panel(tabPanel);
|
||||
initializePage2Panel(tabPanel);
|
||||
tabPanel.setTabOrder(new com.common.util.LiteList(new Object[] {}));
|
||||
}//initializeTabPanel()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.IView#internalViewInitialize()
|
||||
*/
|
||||
public void internalViewInitialize() {
|
||||
this.setClosedMethod(new com.foundation.view.MethodAssociation(this, THIS_CLOSED_METHOD_ASSOCIATION, this, "controllerHolder", null, null));
|
||||
initializeControllerHolder(this);
|
||||
initializeSelectedLogEntry(this);
|
||||
initializeTabPanel(this);
|
||||
com.foundation.view.swt.GridLayout layout = new com.foundation.view.swt.GridLayout(this);
|
||||
|
||||
layout.setNumColumns(1);
|
||||
layout.setMakeColumnsEqualWidth(false);
|
||||
layout.setMarginHeight(10);
|
||||
layout.setMarginWidth(10);
|
||||
layout.setHorizontalSpacing(2);
|
||||
layout.setVerticalSpacing(2);
|
||||
this.setLayout(layout);
|
||||
this.setTabOrder(new com.common.util.LiteList(new Object[] {}));
|
||||
this.setDefaultContainerTitle("Brainstorm Web Server");
|
||||
this.setDefaultContainerImage(new com.foundation.view.resource.ResourceReference("res://Application/General/InformationImage"));
|
||||
layoutComponents();
|
||||
super.internalViewInitialize();
|
||||
setupLinkages();
|
||||
}//internalViewInitialize()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.IAssociationHandler#invokeGetMethod(int, Object)
|
||||
*/
|
||||
public Object invokeGetMethod(int associationNumber, Object value) {
|
||||
Object retVal = null;
|
||||
|
||||
switch(associationNumber) {
|
||||
default:
|
||||
com.common.debug.Debug.log("Attribute association broken.");
|
||||
break;
|
||||
}//switch//
|
||||
|
||||
return retVal;
|
||||
}//invokeGetMethod()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.IAssociationHandler#invokeSetMethod(int, Object, Object)
|
||||
*/
|
||||
public void invokeSetMethod(int associationNumber, Object value, Object parameter) {
|
||||
switch(associationNumber) {
|
||||
default:
|
||||
com.common.debug.Debug.log("Attribute association broken.");
|
||||
break;
|
||||
}//switch//
|
||||
}//invokeSetMethod()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.IAssociationHandler#invokeMethod(int, Object, Object[])
|
||||
*/
|
||||
public Object invokeMethod(int associationNumber, Object value, Object[] parameters) {
|
||||
Object retVal = null;
|
||||
|
||||
switch(associationNumber) {
|
||||
case THIS_CLOSED_METHOD_ASSOCIATION:
|
||||
((com.foundation.web.view.controller.MainViewController) value).doClose();
|
||||
break;
|
||||
case REFRESH_ALL_LINK_SELECTION_METHOD_ASSOCIATION:
|
||||
((com.foundation.web.view.controller.MainViewController) value).doRefreshAll();
|
||||
break;
|
||||
case CLEAR_CACHE_LINK_SELECTION_METHOD_ASSOCIATION:
|
||||
((com.foundation.web.view.controller.MainViewController) value).doClearCache();
|
||||
break;
|
||||
case RELOAD_LINK_SELECTION_METHOD_ASSOCIATION:
|
||||
((com.foundation.web.view.controller.MainViewController) value).doReloadWebapp();
|
||||
break;
|
||||
case REFRESH_LINK_SELECTION_METHOD_ASSOCIATION:
|
||||
((com.foundation.web.view.controller.MainViewController) value).doRefreshWebapp();
|
||||
break;
|
||||
case REMOVE_LINK_SELECTION_METHOD_ASSOCIATION:
|
||||
((com.foundation.web.view.controller.MainViewController) value).doRemoveWebapp();
|
||||
break;
|
||||
case WEBAPP_BUNDLE_LIST_DOUBLE_CLICK_METHOD_ASSOCIATION:
|
||||
((com.foundation.web.view.controller.MainViewController) value).doClearCache((com.foundation.web.server.shared.model.BaseApp) parameters[0]);
|
||||
break;
|
||||
case BACK_LINK_SELECTION_METHOD_ASSOCIATION:
|
||||
((com.foundation.web.view.controller.MainViewController) value).doShowWebappList();
|
||||
break;
|
||||
default:
|
||||
com.common.debug.Debug.log("Method association broken.");
|
||||
break;
|
||||
}//switch//
|
||||
|
||||
return retVal;
|
||||
}//invokeMethod()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.view.IAssociationHandler#invokeMethod(int, Object, Object[], byte)
|
||||
*/
|
||||
public Object invokeMethod(int associationNumber, Object value, Object[] parameters, byte flags) {
|
||||
Object result = null;
|
||||
|
||||
if(flags == INVOKE_GETTER_METHOD_FLAG) {
|
||||
switch(associationNumber) {
|
||||
case SELECTED_LOG_ENTRY_ASSOCIATION_PARENT_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.view.controller.MainViewController) value).getSelectedLogEntry();
|
||||
break;
|
||||
case WEBAPP_BUNDLE_LIST_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.server.shared.model.WebappBundle) value).getName();
|
||||
break;
|
||||
case WEBAPP_BUNDLE_LIST_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_1:
|
||||
result = ((com.foundation.web.server.shared.model.ServerApp) value).getName();
|
||||
break;
|
||||
case WEBAPP_BUNDLE_LIST_ASSOCIATION_COLLECTION_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.view.controller.MainViewController) value).getWebappBundles();
|
||||
break;
|
||||
case WEBAPP_BUNDLE_LIST_ASSOCIATION_SELECTION_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.view.controller.MainViewController) value).getSelectedBundle();
|
||||
break;
|
||||
case WEBAPP_TABLE_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.server.shared.model.WebappBundle) value).getName();
|
||||
break;
|
||||
case WEBAPP_TABLE_ASSOCIATION_ROW_FOREGROUND_COLOR_CUSTOM_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.view.controller.MainViewController) value).getWebappRowForeground((com.foundation.web.server.shared.model.BaseApp) parameters[0]);
|
||||
break;
|
||||
case WEBAPP_TABLE_ASSOCIATION_COLLECTION_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.view.controller.MainViewController) value).getApps();
|
||||
break;
|
||||
case WEBAPP_TABLE_ASSOCIATION_SELECTION_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.view.controller.MainViewController) value).getSelectedApp();
|
||||
break;
|
||||
case LOG_TABLE_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.server.shared.model.WebappLogEntry) value).getShortText();
|
||||
break;
|
||||
case LOG_TABLE_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_FOREGROUND_COLOR_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.view.controller.MainViewController) value).getLogEntryColor((com.foundation.web.server.shared.model.WebappLogEntry) parameters[0]);
|
||||
break;
|
||||
case LOG_TABLE_ASSOCIATION_COLLECTION_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.view.controller.MainViewController) value).getWebappLogEntries();
|
||||
break;
|
||||
case LOG_TABLE_ASSOCIATION_SELECTION_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.view.controller.MainViewController) value).getSelectedLogEntry();
|
||||
break;
|
||||
case LOG_TEXT_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.server.shared.model.WebappLogEntry) value).getText();
|
||||
break;
|
||||
case LAYOUT_PAGE_2_PANEL_ASSOC_TOP_INDEX_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.view.controller.MainViewController) value).getDisplayedLogCard();
|
||||
break;
|
||||
default:
|
||||
com.common.debug.Debug.log("Association (getter) broken.");
|
||||
break;
|
||||
}//switch//
|
||||
|
||||
}//if//
|
||||
else if(flags == INVOKE_ORIGINAL_VALUE_GETTER_METHOD_FLAG) {
|
||||
switch(associationNumber) {
|
||||
case SELECTED_LOG_ENTRY_ASSOCIATION_PARENT_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.view.controller.MainViewController) value).getOldAttributeValue(com.foundation.web.view.controller.MainViewController.SELECTED_LOG_ENTRY);
|
||||
break;
|
||||
case WEBAPP_BUNDLE_LIST_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.server.shared.model.WebappBundle) value).getOldAttributeValue(com.foundation.web.server.shared.model.WebappBundle.NAME);
|
||||
break;
|
||||
case WEBAPP_BUNDLE_LIST_ASSOCIATION_COLLECTION_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.view.controller.MainViewController) value).getOldAttributeValue(com.foundation.web.view.controller.MainViewController.WEBAPP_BUNDLES);
|
||||
break;
|
||||
case WEBAPP_BUNDLE_LIST_ASSOCIATION_SELECTION_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.view.controller.MainViewController) value).getOldAttributeValue(com.foundation.web.view.controller.MainViewController.SELECTED_BUNDLE);
|
||||
break;
|
||||
case WEBAPP_TABLE_COLUMN_PART0_ASSOCIATION_COLUMN_CELL_TEXT_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.server.shared.model.WebappBundle) value).getOldAttributeValue(com.foundation.web.server.shared.model.WebappBundle.NAME);
|
||||
break;
|
||||
case WEBAPP_TABLE_ASSOCIATION_COLLECTION_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.view.controller.MainViewController) value).getOldAttributeValue(com.foundation.web.view.controller.MainViewController.APPS);
|
||||
break;
|
||||
case WEBAPP_TABLE_ASSOCIATION_SELECTION_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.view.controller.MainViewController) value).getOldAttributeValue(com.foundation.web.view.controller.MainViewController.SELECTED_APP);
|
||||
break;
|
||||
case LOG_TABLE_ASSOCIATION_COLLECTION_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.view.controller.MainViewController) value).getOldAttributeValue(com.foundation.web.view.controller.MainViewController.WEBAPP_LOG_ENTRIES);
|
||||
break;
|
||||
case LOG_TABLE_ASSOCIATION_SELECTION_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.view.controller.MainViewController) value).getOldAttributeValue(com.foundation.web.view.controller.MainViewController.SELECTED_LOG_ENTRY);
|
||||
break;
|
||||
case LOG_TEXT_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.server.shared.model.WebappLogEntry) value).getOldAttributeValue(com.foundation.web.server.shared.model.WebappLogEntry.TEXT);
|
||||
break;
|
||||
case LAYOUT_PAGE_2_PANEL_ASSOC_TOP_INDEX_ASSOCIATION_0:
|
||||
result = ((com.foundation.web.view.controller.MainViewController) value).getOldAttributeValue(com.foundation.web.view.controller.MainViewController.DISPLAYED_LOG_CARD);
|
||||
break;
|
||||
default:
|
||||
com.common.debug.Debug.log("Association (original value getter) broken.");
|
||||
break;
|
||||
}//switch//
|
||||
|
||||
}//if//
|
||||
else {
|
||||
switch(associationNumber) {
|
||||
case WEBAPP_BUNDLE_LIST_ASSOCIATION_SELECTION_ASSOCIATION_0:
|
||||
((com.foundation.web.view.controller.MainViewController) value).setSelectedBundle((com.foundation.web.server.shared.model.WebappBundle) parameters[0]);
|
||||
break;
|
||||
case WEBAPP_TABLE_ASSOCIATION_SELECTION_ASSOCIATION_0:
|
||||
((com.foundation.web.view.controller.MainViewController) value).setSelectedApp((com.foundation.web.server.shared.model.BaseApp) parameters[0]);
|
||||
break;
|
||||
case LOG_TABLE_ASSOCIATION_SELECTION_ASSOCIATION_0:
|
||||
((com.foundation.web.view.controller.MainViewController) value).setSelectedLogEntry((com.foundation.web.server.shared.model.WebappLogEntry) parameters[0]);
|
||||
break;
|
||||
case LOG_TEXT_FORMAT_FORMAT_ASSOCIATION_TEXT_ASSOCIATION_0:
|
||||
((com.foundation.web.server.shared.model.WebappLogEntry) value).setText((java.lang.String) parameters[0]);
|
||||
break;
|
||||
default:
|
||||
com.common.debug.Debug.log("Association (setter) broken.");
|
||||
break;
|
||||
}//switch//
|
||||
|
||||
}//else//
|
||||
return result;
|
||||
}//invokeMethod()//
|
||||
/**
|
||||
* Lays out the components.
|
||||
*/
|
||||
public void layoutComponents() {
|
||||
{ //tabPanel//
|
||||
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
|
||||
|
||||
layoutData.verticalAlignment = com.foundation.view.swt.layout.GridData.FILL;
|
||||
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.FILL;
|
||||
layoutData.grabExcessHorizontalSpace = true;
|
||||
layoutData.grabExcessVerticalSpace = true;
|
||||
tabPanel.setLayoutData(layoutData);
|
||||
}//block//
|
||||
{ //refreshAllLink//
|
||||
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
|
||||
|
||||
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.BEGINNING;
|
||||
layoutData.grabExcessHorizontalSpace = true;
|
||||
refreshAllLink.setLayoutData(layoutData);
|
||||
}//block//
|
||||
{ //linkPanel//
|
||||
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
|
||||
|
||||
layoutData.verticalAlignment = com.foundation.view.swt.layout.GridData.END;
|
||||
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.BEGINNING;
|
||||
layoutData.verticalIndent = 10;
|
||||
layoutData.grabExcessHorizontalSpace = true;
|
||||
layoutData.grabExcessVerticalSpace = false;
|
||||
linkPanel.setLayoutData(layoutData);
|
||||
}//block//
|
||||
{ //removeLink//
|
||||
com.foundation.view.swt.layout.RowData layoutData = new com.foundation.view.swt.layout.RowData();
|
||||
|
||||
removeLink.setLayoutData(layoutData);
|
||||
}//block//
|
||||
{ //webappBundleList//
|
||||
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
|
||||
|
||||
layoutData.verticalAlignment = com.foundation.view.swt.layout.GridData.FILL;
|
||||
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.FILL;
|
||||
layoutData.minimumWidth = 300;
|
||||
layoutData.widthHint = 300;
|
||||
layoutData.minimumHeight = 200;
|
||||
layoutData.heightHint = 200;
|
||||
layoutData.verticalIndent = 0;
|
||||
layoutData.grabExcessHorizontalSpace = true;
|
||||
layoutData.grabExcessVerticalSpace = true;
|
||||
webappBundleList.setLayoutData(layoutData);
|
||||
}//block//
|
||||
{ //instructionsLabel//
|
||||
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
|
||||
|
||||
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.CENTER;
|
||||
layoutData.grabExcessHorizontalSpace = true;
|
||||
instructionsLabel.setLayoutData(layoutData);
|
||||
}//block//
|
||||
{ //backLink//
|
||||
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
|
||||
|
||||
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.BEGINNING;
|
||||
layoutData.grabExcessHorizontalSpace = true;
|
||||
backLink.setLayoutData(layoutData);
|
||||
}//block//
|
||||
{ //appSash//
|
||||
com.foundation.view.swt.layout.GridData layoutData = new com.foundation.view.swt.layout.GridData();
|
||||
|
||||
layoutData.verticalAlignment = com.foundation.view.swt.layout.GridData.FILL;
|
||||
layoutData.horizontalAlignment = com.foundation.view.swt.layout.GridData.FILL;
|
||||
layoutData.widthHint = 600;
|
||||
layoutData.heightHint = 600;
|
||||
layoutData.grabExcessHorizontalSpace = true;
|
||||
layoutData.grabExcessVerticalSpace = true;
|
||||
appSash.setLayoutData(layoutData);
|
||||
}//block//
|
||||
}//layoutComponents()//
|
||||
/**
|
||||
* Initializes the direct linkages between the components.
|
||||
*/
|
||||
public void setupLinkages() {
|
||||
}//setupLinkages()//
|
||||
/**
|
||||
* Gets the view component.
|
||||
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
|
||||
* @return The view component.
|
||||
*/
|
||||
protected com.foundation.view.swt.ValueHolder getVpControllerHolder() {
|
||||
return controllerHolder;
|
||||
}//getVpControllerHolder()//
|
||||
/**
|
||||
* Gets the view component.
|
||||
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
|
||||
* @return The view component.
|
||||
*/
|
||||
protected com.foundation.view.swt.ValueHolder getVpSelectedLogEntry() {
|
||||
return selectedLogEntry;
|
||||
}//getVpSelectedLogEntry()//
|
||||
/**
|
||||
* Gets the view component.
|
||||
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
|
||||
* @return The view component.
|
||||
*/
|
||||
protected com.foundation.view.swt.TabPanel getVpTabPanel() {
|
||||
return tabPanel;
|
||||
}//getVpTabPanel()//
|
||||
/**
|
||||
* Gets the view component.
|
||||
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
|
||||
* @return The view component.
|
||||
*/
|
||||
protected com.foundation.view.swt.Panel getVpPage1Panel() {
|
||||
return page1Panel;
|
||||
}//getVpPage1Panel()//
|
||||
/**
|
||||
* Gets the view component.
|
||||
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
|
||||
* @return The view component.
|
||||
*/
|
||||
protected com.foundation.view.swt.Link getVpRefreshAllLink() {
|
||||
return refreshAllLink;
|
||||
}//getVpRefreshAllLink()//
|
||||
/**
|
||||
* Gets the view component.
|
||||
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
|
||||
* @return The view component.
|
||||
*/
|
||||
protected com.foundation.view.swt.Panel getVpLinkPanel() {
|
||||
return linkPanel;
|
||||
}//getVpLinkPanel()//
|
||||
/**
|
||||
* Gets the view component.
|
||||
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
|
||||
* @return The view component.
|
||||
*/
|
||||
protected com.foundation.view.swt.Link getVpClearCacheLink() {
|
||||
return clearCacheLink;
|
||||
}//getVpClearCacheLink()//
|
||||
/**
|
||||
* Gets the view component.
|
||||
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
|
||||
* @return The view component.
|
||||
*/
|
||||
protected com.foundation.view.swt.Link getVpReloadLink() {
|
||||
return reloadLink;
|
||||
}//getVpReloadLink()//
|
||||
/**
|
||||
* Gets the view component.
|
||||
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
|
||||
* @return The view component.
|
||||
*/
|
||||
protected com.foundation.view.swt.Link getVpRefreshLink() {
|
||||
return refreshLink;
|
||||
}//getVpRefreshLink()//
|
||||
/**
|
||||
* Gets the view component.
|
||||
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
|
||||
* @return The view component.
|
||||
*/
|
||||
protected com.foundation.view.swt.Link getVpRemoveLink() {
|
||||
return removeLink;
|
||||
}//getVpRemoveLink()//
|
||||
/**
|
||||
* Gets the view component.
|
||||
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
|
||||
* @return The view component.
|
||||
*/
|
||||
protected com.foundation.view.swt.SimpleTable getVpWebappBundleList() {
|
||||
return webappBundleList;
|
||||
}//getVpWebappBundleList()//
|
||||
/**
|
||||
* Gets the view component.
|
||||
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
|
||||
* @return The view component.
|
||||
*/
|
||||
protected com.foundation.view.swt.Label getVpInstructionsLabel() {
|
||||
return instructionsLabel;
|
||||
}//getVpInstructionsLabel()//
|
||||
/**
|
||||
* Gets the view component.
|
||||
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
|
||||
* @return The view component.
|
||||
*/
|
||||
protected com.foundation.view.swt.Panel getVpPage2Panel() {
|
||||
return page2Panel;
|
||||
}//getVpPage2Panel()//
|
||||
/**
|
||||
* Gets the view component.
|
||||
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
|
||||
* @return The view component.
|
||||
*/
|
||||
protected com.foundation.view.swt.Panel getVpCardPanel0() {
|
||||
return cardPanel0;
|
||||
}//getVpCardPanel0()//
|
||||
/**
|
||||
* Gets the view component.
|
||||
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
|
||||
* @return The view component.
|
||||
*/
|
||||
protected com.foundation.view.swt.SimpleTable getVpWebappTable() {
|
||||
return webappTable;
|
||||
}//getVpWebappTable()//
|
||||
/**
|
||||
* Gets the view component.
|
||||
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
|
||||
* @return The view component.
|
||||
*/
|
||||
protected com.foundation.view.swt.Panel getVpCardPanel1() {
|
||||
return cardPanel1;
|
||||
}//getVpCardPanel1()//
|
||||
/**
|
||||
* Gets the view component.
|
||||
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
|
||||
* @return The view component.
|
||||
*/
|
||||
protected com.foundation.view.swt.Link getVpBackLink() {
|
||||
return backLink;
|
||||
}//getVpBackLink()//
|
||||
/**
|
||||
* Gets the view component.
|
||||
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
|
||||
* @return The view component.
|
||||
*/
|
||||
protected com.foundation.view.swt.SashForm getVpAppSash() {
|
||||
return appSash;
|
||||
}//getVpAppSash()//
|
||||
/**
|
||||
* Gets the view component.
|
||||
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
|
||||
* @return The view component.
|
||||
*/
|
||||
protected com.foundation.view.swt.SimpleTable getVpLogTable() {
|
||||
return logTable;
|
||||
}//getVpLogTable()//
|
||||
/**
|
||||
* Gets the view component.
|
||||
* <p>Warning: This accessor to allow for the very rare and highly discouraged derived view class.</p>
|
||||
* @return The view component.
|
||||
*/
|
||||
protected com.foundation.view.swt.TextField getVpLogText() {
|
||||
return logText;
|
||||
}//getVpLogText()//
|
||||
}//MainView//
|
||||
136
Foundation Web Core/src/com/foundation/web/view/MainView.vml
Normal file
136
Foundation Web Core/src/com/foundation/web/view/MainView.vml
Normal file
@@ -0,0 +1,136 @@
|
||||
<?xml version="1.0"?>
|
||||
<vml>
|
||||
<metadata>
|
||||
<platform name="thick:swt"/>
|
||||
</metadata>
|
||||
|
||||
<window name="MainView" style="window trim" container-image="res://Application/General/InformationImage" container-title="Brainstorm Web Server">
|
||||
<grid-layout column-count="1" margin-height="10" margin-width="10" equal-width-columns="false" vertical-spacing="2" horizontal-spacing="2"/>
|
||||
|
||||
<value-holder name="controllerHolder" type="com.foundation.web.view.controller.MainViewController"/>
|
||||
<value-holder name="selectedLogEntry" type="com.foundation.web.server.shared.model.WebappLogEntry">
|
||||
<association function="parent" attribute="selectedLogEntry" value-holder="controllerHolder"/>
|
||||
</value-holder>
|
||||
|
||||
<method function="closed" name="doClose" signature="" value-holder="controllerHolder"/>
|
||||
|
||||
<tab-panel name="tabPanel" style="top">
|
||||
<grid-layout-data horizontal-alignment="fill" horizontal-fill="true" vertical-alignment="fill" vertical-fill="true"/>
|
||||
|
||||
<page name="page1">
|
||||
<panel name="page1Panel" container-title="Webapp Management">
|
||||
<grid-layout column-count="1" margin-height="0" margin-width="0" equal-width-columns="false" vertical-spacing="2" horizontal-spacing="2"/>
|
||||
|
||||
<hyperlink name="refreshAllLink" text="<a>Refresh All Webapps</a>">
|
||||
<grid-layout-data horizontal-alignment="beginning" horizontal-fill="true"/>
|
||||
<method function="selection" name="doRefreshAll" value-holder="controllerHolder"/>
|
||||
</hyperlink>
|
||||
|
||||
<panel name="linkPanel">
|
||||
<grid-layout-data horizontal-alignment="beginning" horizontal-fill="true" vertical-alignment="end" vertical-fill="false" vertical-indent="10"/>
|
||||
<row-layout wrap="false" pack="true" spacing="10" margin-width="0"/>
|
||||
|
||||
<hyperlink name="clearCacheLink" text="<a>Clear Cache</a>" tool-tip-text="Clear's the webapp's cache (if used).">
|
||||
<method function="selection" name="doClearCache" value-holder="controllerHolder"/>
|
||||
</hyperlink>
|
||||
<hyperlink name="reloadLink" text="<a>Reload Webapp</a>" tool-tip-text="Reloads the webapp without unpacking the latest webapp archive.">
|
||||
<method function="selection" name="doReloadWebapp" value-holder="controllerHolder"/>
|
||||
</hyperlink>
|
||||
<hyperlink name="refreshLink" text="<a>Refresh Webapp</a>" tool-tip-text="Unpacks the webapp archive and reloads the webapp.">
|
||||
<method function="selection" name="doRefreshWebapp" value-holder="controllerHolder"/>
|
||||
</hyperlink>
|
||||
<hyperlink name="removeLink" text="<a>Remove</a>" tool-tip-text="Removes the webapp's archive and all related files (except any external files or external settings).">
|
||||
<row-layout-data alignment="end"/>
|
||||
<method function="selection" name="doRemoveWebapp" value-holder="controllerHolder"/>
|
||||
</hyperlink>
|
||||
</panel>
|
||||
<simple-table name="webappBundleList" style="border" auto-fit="true" show-headers="false" auto-synchronize-selection="true" auto-synchronize-selection-delay="0" auto-validate="false">
|
||||
<grid-layout-data horizontal-alignment="fill" horizontal-fill="true" vertical-alignment="fill" vertical-fill="true" minimum-width="300" minimum-height="200" vertical-indent="0"/>
|
||||
<association function="collection" attribute="webappBundles" value-holder="controllerHolder"/>
|
||||
<association function="selection" attribute="selectedBundle" value-holder="controllerHolder"/>
|
||||
|
||||
<method function="double-click" name="doClearCache" signature="Lcom.foundation.web.server.shared.model.BaseApp;" value-holder="controllerHolder"/>
|
||||
|
||||
<columns>
|
||||
<column header-text="">
|
||||
<association-group function="cell-text">
|
||||
<association-target-attribute function="cell-text" attribute="name" row-type="com.foundation.web.server.shared.model.WebappBundle"/>
|
||||
<association-target-method function="cell-text" getter="getName" getter-signature="" row-type="com.foundation.web.server.shared.model.ServerApp"/>
|
||||
</association-group>
|
||||
</column>
|
||||
</columns>
|
||||
</simple-table>
|
||||
<label name="instructionsLabel" text="Double click to clear the webapp's cache." foreground-color="grey">
|
||||
<grid-layout-data horizontal-alignment="center" horizontal-fill="true"/>
|
||||
</label>
|
||||
</panel>
|
||||
</page>
|
||||
<page name="page2">
|
||||
<panel name="page2Panel" container-title="Logs">
|
||||
<card-layout margin-width="0" margin-height="0">
|
||||
<association function="top-index" attribute="displayedLogCard" value-holder="controllerHolder"/>
|
||||
</card-layout>
|
||||
<panel name="cardPanel0">
|
||||
<fill-layout/>
|
||||
|
||||
<simple-table name="webappTable" style="border" auto-fit="true" show-headers="true" auto-synchronize-selection="true" auto-synchronize-selection-delay="0" auto-validate="false">
|
||||
<association function="collection" attribute="apps" value-holder="controllerHolder"/>
|
||||
<association function="selection" attribute="selectedApp" value-holder="controllerHolder"/>
|
||||
|
||||
<association function="row-foreground-color-custom" getter="getWebappRowForeground" getter-signature="Lcom.foundation.web.server.shared.model.BaseApp;" row-type="com.foundation.web.server.shared.model.BaseApp" value-holder="controllerHolder">
|
||||
<association-event event="errorChangeFlag"/>
|
||||
<association-event event="warningChangeFlag"/>
|
||||
<association-event event="infoChangeFlag"/>
|
||||
</association>
|
||||
|
||||
<columns>
|
||||
<column header-text="Web Application">
|
||||
<association-group function="cell-text">
|
||||
<association-target-attribute attribute="name" row-type="com.foundation.web.server.shared.model.WebappBundle"/>
|
||||
</association-group>
|
||||
</column>
|
||||
<!--<column header-text="Error" width="50" minimum-width="50">
|
||||
<association function="cell-text" attribute="errorCount" row-type="com.foundation.web.server.shared.model.BaseApp"/>
|
||||
</column>
|
||||
<column header-text="Warn" width="50" minimum-width="50">
|
||||
<association function="cell-text" attribute="warningCount" row-type="com.foundation.web.server.shared.model.BaseApp"/>
|
||||
</column>
|
||||
<column header-text="Info" width="50" minimum-width="50" cell-background-color="red">
|
||||
<association function="cell-text" attribute="infoCount" row-type="com.foundation.web.server.shared.model.BaseApp"/>
|
||||
</column>-->
|
||||
</columns>
|
||||
</simple-table>
|
||||
</panel>
|
||||
<panel name="cardPanel1">
|
||||
<grid-layout column-count="1" margin-height="0" margin-width="0" equal-width-columns="false" vertical-spacing="2" horizontal-spacing="2"/>
|
||||
|
||||
<hyperlink name="backLink" text="<a>Back to application list...</a>">
|
||||
<grid-layout-data horizontal-alignment="beginning" horizontal-fill="true"/>
|
||||
<method function="selection" name="doShowWebappList" value-holder="controllerHolder"/>
|
||||
</hyperlink>
|
||||
<sash-form name="appSash" style="vertical | smooth">
|
||||
<grid-layout-data horizontal-alignment="fill" horizontal-fill="true" vertical-alignment="fill" vertical-fill="true" default-width="600" default-height="600"/>
|
||||
|
||||
<simple-table name="logTable" style="border" auto-fit="true" show-headers="false" auto-synchronize-selection="true" auto-synchronize-selection-delay="0" auto-validate="false">
|
||||
<association function="collection" attribute="webappLogEntries" value-holder="controllerHolder"/>
|
||||
<association function="selection" attribute="selectedLogEntry" value-holder="controllerHolder"/>
|
||||
|
||||
<columns>
|
||||
<column header-text="">
|
||||
<association function="cell-text" getter="getShortText" getter-signature="" row-type="com.foundation.web.server.shared.model.WebappLogEntry"/>
|
||||
<association function="cell-foreground-color" getter="getLogEntryColor" getter-signature="Lcom.foundation.web.server.shared.model.WebappLogEntry;" row-type="com.foundation.web.server.shared.model.WebappLogEntry" value-holder="controllerHolder"/>
|
||||
</column>
|
||||
</columns>
|
||||
</simple-table>
|
||||
<text name="logText" style="multi line | border | horizontal scroll | vertical scroll">
|
||||
<text-format>
|
||||
<association function="text" attribute="text" value-holder="selectedLogEntry"/>
|
||||
</text-format>
|
||||
</text>
|
||||
</sash-form>
|
||||
</panel>
|
||||
</panel>
|
||||
</page>
|
||||
</tab-panel>
|
||||
</window>
|
||||
</vml>
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.foundation.web.view.controller;
|
||||
|
||||
import com.foundation.application.IApplication;
|
||||
import com.foundation.attribute.ReflectionContext;
|
||||
import com.foundation.controller.ViewController;
|
||||
import com.foundation.view.IViewContext;
|
||||
import com.foundation.web.application.WebServerApplication;
|
||||
|
||||
public abstract class AbstractViewController extends ViewController {
|
||||
/**
|
||||
* AbstractViewController constructor.
|
||||
* @param viewContext The view's context under which it will operate.
|
||||
*/
|
||||
public AbstractViewController(IViewContext viewContext) {
|
||||
super(viewContext);
|
||||
}//AbstractViewController()//
|
||||
/**
|
||||
* AbstractViewController constructor.
|
||||
* @param viewContext The view's context under which it will operate.
|
||||
* @param reflectionContext The reflection context to be used by the view.
|
||||
*/
|
||||
public AbstractViewController(IViewContext context, ReflectionContext reflectionContext) {
|
||||
super(context, reflectionContext);
|
||||
}//AbstractViewController()//
|
||||
/**
|
||||
* AbstractViewController constructor.
|
||||
* @param viewContext The view's context under which it will operate.
|
||||
* @param validateOnOpen Whether the view should perform validation immediately after opening. This is true by default.
|
||||
*/
|
||||
public AbstractViewController(IViewContext viewContext, boolean validateOnOpen) {
|
||||
super(viewContext, validateOnOpen);
|
||||
}//AbstractViewController()//
|
||||
/**
|
||||
* AbstractViewController constructor.
|
||||
* @param viewContext The view's context under which it will operate.
|
||||
* @param reflectionContext The reflection context to be used by the view.
|
||||
* @param validateOnOpen Whether the view should perform validation immediately after opening. This is true by default.
|
||||
*/
|
||||
public AbstractViewController(IViewContext context, ReflectionContext reflectionContext, boolean validateOnOpen) {
|
||||
super(context, reflectionContext, validateOnOpen);
|
||||
}//AbstractViewController()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.common.Entity#getApplication()
|
||||
*/
|
||||
public IApplication getApplication() {
|
||||
return WebServerApplication.getSingleton();
|
||||
}//getApplication()//
|
||||
}//AbstractViewController//
|
||||
@@ -0,0 +1,473 @@
|
||||
package com.foundation.web.view.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.common.debug.Debug;
|
||||
import com.common.thread.IRunnable;
|
||||
import com.common.util.IList;
|
||||
import com.foundation.web.application.WebServerApplication;
|
||||
import com.foundation.web.interfaces.IWebApplication;
|
||||
import com.foundation.web.model.*;
|
||||
import com.foundation.web.server.shared.model.BaseApp;
|
||||
import com.foundation.web.server.shared.model.WebappBundle;
|
||||
import com.foundation.web.server.shared.model.WebappLog;
|
||||
import com.foundation.web.server.shared.model.WebappLogEntry;
|
||||
import com.foundation.web.view.MainView;
|
||||
import com.foundation.util.IManagedList;
|
||||
import com.foundation.util.ManagedList;
|
||||
import com.foundation.view.IViewContext;
|
||||
import com.foundation.view.JefColor;
|
||||
import com.foundation.common.AttributeBinding;
|
||||
import com.foundation.event.IEventEmitter;
|
||||
import com.foundation.event.IEventHandler;
|
||||
import com.foundation.event.model.IModelListenerChangeHandler;
|
||||
import com.foundation.event.model.IModelListenerCollectionHandler;
|
||||
import com.foundation.event.model.ModelListener;
|
||||
import com.foundation.metadata.Attribute;
|
||||
|
||||
/**
|
||||
* Displays the web server's primary view.
|
||||
*/
|
||||
public class MainViewController extends AbstractViewController {
|
||||
private static final JefColor COLOR_ERROR = new JefColor(JefColor.COLOR_DARK_RED);
|
||||
private static final JefColor COLOR_WARNING = new JefColor(JefColor.COLOR_DARK_YELLOW);
|
||||
private static final JefColor COLOR_INFO = new JefColor(JefColor.COLOR_DARK_GRAY);
|
||||
private static final JefColor COLOR_NORMAL = new JefColor(JefColor.COLOR_BLACK);
|
||||
private static final JefColor BACKGROUND_VIEWED = new JefColor(JefColor.COLOR_WHITE);
|
||||
private static final JefColor BACKGROUND_NEW = new JefColor(JefColor.COLOR_YELLOW);
|
||||
|
||||
public static final Attribute APPS = registerAttribute(MainViewController.class, "apps");
|
||||
public static final Attribute WEBAPP_BUNDLES = registerAttribute(MainViewController.class, "webappBundles", AO_REFERENCED | AO_LAZY);
|
||||
public static final Attribute SELECTED_BUNDLE = registerAttribute(MainViewController.class, "selectedBundle");
|
||||
public static final Attribute LOG = registerAttribute(MainViewController.class, "log");
|
||||
public static final Attribute WEBAPP_LOG_ENTRIES = registerAttribute(MainViewController.class, "webappLogEntries");
|
||||
public static final Attribute SELECTED_LOG_ENTRY = registerAttribute(MainViewController.class, "selectedLogEntry");
|
||||
public static final Attribute LOADED_APP = registerAttribute(MainViewController.class, "loadedApp");
|
||||
public static final Attribute DISPLAYED_LOG_CARD = registerAttribute(MainViewController.class, "displayedLogCard", new Integer(0));
|
||||
public static final Attribute SELECTED_APP = registerAttribute(MainViewController.class, "selectedApp");
|
||||
|
||||
/**
|
||||
* A specialized managed list that places the server metadata as the first item in the list, and then maps the webapp bundles into the collection in real time.
|
||||
*/
|
||||
private class RootItems extends ManagedList {
|
||||
ModelListener listener;
|
||||
|
||||
public RootItems() {
|
||||
add(getReflectionManager().createReflection(WebServerApplication.getSingleton().getServerApp()));
|
||||
//Setup a listener to the webapp bundles such that adds and removes are applied to this collection.//
|
||||
listener = new ModelListener(MainViewController.this, null, true);
|
||||
listener.addBinding(new AttributeBinding(MainViewController.class, WEBAPP_BUNDLES, AttributeBinding.FLAG_LAZY_LOAD_ATTRIBUTE, null, new IModelListenerCollectionHandler[] {new IModelListenerCollectionHandler() {
|
||||
public Class getReferenceType() {
|
||||
return null;
|
||||
}//getReferenceType()//
|
||||
public void run(Object object, int flags, IList addedValues, IList removedValues) {
|
||||
addAll(addedValues);
|
||||
removeAll(removedValues);
|
||||
}//run()//
|
||||
}}));
|
||||
listener.initialize();
|
||||
}//RootItems()//
|
||||
/**
|
||||
* Must be called to release the listeners.
|
||||
*/
|
||||
public void release() {
|
||||
listener.release();
|
||||
}//release()//
|
||||
}//RootItems//
|
||||
/**
|
||||
* MainViewController constructor.
|
||||
* @param context The context under which the view is being created. This context manages the threading, resources, and request handling for the view as well as ties together related views.
|
||||
*/
|
||||
public MainViewController(IViewContext context, IManagedList webappBundles) {
|
||||
super(context, true);
|
||||
setWebappBundles((IManagedList) getReflectionManager().createReflection(webappBundles));
|
||||
setApps(new RootItems());
|
||||
setWebappLogEntries(new ManagedList(4000));
|
||||
}//MainViewController()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.controller.AbstractViewController#getViewClass()
|
||||
*/
|
||||
protected Class getViewClass() {
|
||||
return MainView.class;
|
||||
}//getViewClass()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.declarativeengineering.jetson.view.controller.AbstractViewController#validate()
|
||||
*/
|
||||
public boolean validate() {
|
||||
return true;
|
||||
}//validate()//
|
||||
/* (non-Javadoc)
|
||||
* @see com.foundation.controller.AbstractViewController#postClose()
|
||||
*/
|
||||
protected void postClose() {
|
||||
((RootItems) getApps()).release();
|
||||
super.postClose();
|
||||
}//postClose()//
|
||||
/**
|
||||
* Closes the window.
|
||||
*/
|
||||
public void doClose() {
|
||||
getView().setIsVisible(false);
|
||||
setLoadedApp(null);
|
||||
close();
|
||||
WebServerApplication.getSingleton().shutdown();
|
||||
}//doClose()//
|
||||
/**
|
||||
* Displays the second card in the log tab - the list of logs for the selected application.
|
||||
*/
|
||||
public void doShowWebappLogs() {
|
||||
setLoadedApp(getSelectedApp());
|
||||
setDisplayedLogCard(new Integer(1));
|
||||
}//doShowWebappLogs()//
|
||||
/**
|
||||
* Displays the first card in the log tab - the list of all applications and summaries for the logs.
|
||||
*/
|
||||
public void doShowWebappList() {
|
||||
setDisplayedLogCard(new Integer(0));
|
||||
setLoadedApp(null);
|
||||
getSelectedApp().resetLogCountChangeFlags();
|
||||
}//doShowWebappList()//
|
||||
/**
|
||||
* Gets the background color for the row for the application.
|
||||
* @param app The application whose background row color is to be retrieved.
|
||||
* @return The color to use when highlighting the application in the table.
|
||||
*/
|
||||
public JefColor getWebappRowBackground(BaseApp app) {
|
||||
return app.getErrorChangeFlag().booleanValue() ? BACKGROUND_NEW : app.getWarningChangeFlag().booleanValue() ? BACKGROUND_NEW : app.getInfoChangeFlag().booleanValue() ? BACKGROUND_NEW : BACKGROUND_VIEWED;
|
||||
}//getWebappRowBackground()//
|
||||
/**
|
||||
* Gets the background color for the row for the application.
|
||||
* @param app The application whose background row color is to be retrieved.
|
||||
* @return The color to use when highlighting the application in the table.
|
||||
*/
|
||||
public JefColor getWebappRowForeground(BaseApp app) {
|
||||
return app.getErrorChangeFlag().booleanValue() ? COLOR_ERROR : app.getWarningChangeFlag().booleanValue() ? COLOR_WARNING : app.getInfoChangeFlag().booleanValue() ? COLOR_INFO : COLOR_NORMAL;
|
||||
}//getWebappRowForeground()//
|
||||
/**
|
||||
* Gets the background color used for the error value for the given application.
|
||||
* @param app The webapp or serverapp whose error background is to be handled.
|
||||
* @return The color used for the error field background.
|
||||
*/
|
||||
public JefColor getWebappErrorBackground(BaseApp app) {
|
||||
return app.getErrorChangeFlag().booleanValue() ? BACKGROUND_NEW : BACKGROUND_VIEWED;
|
||||
}//getWebappErrorBackground()//
|
||||
/**
|
||||
* Gets the background color used for the warning value for the given application.
|
||||
* @param app The webapp or serverapp whose warning background is to be handled.
|
||||
* @return The color used for the warning field background.
|
||||
*/
|
||||
public JefColor getWebappWarningBackground(BaseApp app) {
|
||||
return app.getWarningChangeFlag().booleanValue() ? BACKGROUND_NEW : BACKGROUND_VIEWED;
|
||||
}//getWebappWarningBackground()//
|
||||
/**
|
||||
* Gets the background color used for the info value for the given application.
|
||||
* @param app The webapp or serverapp whose info background is to be handled.
|
||||
* @return The color used for the info field background.
|
||||
*/
|
||||
public JefColor getWebappInfoBackground(BaseApp app) {
|
||||
return app.getInfoChangeFlag() == null || app.getInfoChangeFlag().booleanValue() ? BACKGROUND_NEW : BACKGROUND_VIEWED;
|
||||
}//getWebappInfoBackground()//
|
||||
/**
|
||||
* Requests the web server test all archive webapps for updates, new bundles, or missing bundles.
|
||||
*/
|
||||
public void doRefreshAll() {
|
||||
WebServerApplication.getSingleton().refreshWebapps();
|
||||
}//doRefreshAll()//
|
||||
/**
|
||||
* Clears the cache for the web app.
|
||||
* @param app The web application whose cache is to be cleared.
|
||||
*/
|
||||
public void doClearCache(IWebApplication app) {
|
||||
app.clearCaches();
|
||||
}//doClearCache()//
|
||||
/**
|
||||
* Clears the cache for the web apps in the given bundle.
|
||||
* @param bundle The bundle of web apps.
|
||||
*/
|
||||
public void doClearCache(BaseApp app) {
|
||||
if(app instanceof WebappBundle) {
|
||||
WebappBundle bundle = (WebappBundle) app;
|
||||
IWebApplication[] apps = bundle.getWebApplications();
|
||||
|
||||
for(int index = 0; index < apps.length; index++) {
|
||||
apps[index].clearCaches();
|
||||
}//for//
|
||||
}//if//
|
||||
else {
|
||||
//TODO: Clear all app bundle caches?
|
||||
}//else//
|
||||
}//doClearCache()//
|
||||
/**
|
||||
* Clears the cache for the currently selected webapp bundle.
|
||||
*/
|
||||
public void doClearCache() {
|
||||
try {
|
||||
if(getSelectedBundle() instanceof WebappBundle) {
|
||||
WebappBundle bundle = (WebappBundle) getSelectedBundle();
|
||||
|
||||
if(bundle != null) {
|
||||
IWebApplication[] apps = bundle.getWebApplications();
|
||||
|
||||
if(apps != null) {
|
||||
for(int index = 0; index < apps.length; index++) {
|
||||
apps[index].clearCaches();
|
||||
}//for//
|
||||
}//if//
|
||||
else {
|
||||
Debug.log(new RuntimeException("The WebappBundle selected: '" + bundle.getName() + "' returned a null array of IWebApplication's."));
|
||||
}//else//
|
||||
}//if//
|
||||
}//if//
|
||||
}//try//
|
||||
catch(Throwable e) {
|
||||
Debug.log(e);
|
||||
}//catch//
|
||||
}//doClearCache()//
|
||||
/**
|
||||
* Refreshes the webapp (unpacks the zip) and restarts it.
|
||||
*/
|
||||
public void doRefreshWebapp() {
|
||||
try {
|
||||
if(getSelectedBundle() instanceof WebappBundle) {
|
||||
WebappBundle bundle = (WebappBundle) getSelectedBundle();
|
||||
|
||||
if(bundle != null) {
|
||||
WebServerApplication.getSingleton().refreshWebapp((WebappBundle) bundle.getReflected());
|
||||
}//if//
|
||||
}//if//
|
||||
}//try//
|
||||
catch(Throwable e) {
|
||||
Debug.log(e);
|
||||
}//catch//
|
||||
}//doRefreshWebapp()//
|
||||
/**
|
||||
* Restarts the webapp without unpacking the zip.
|
||||
*/
|
||||
public void doReloadWebapp() {
|
||||
try {
|
||||
if(getSelectedBundle() instanceof WebappBundle) {
|
||||
WebappBundle bundle = (WebappBundle) getSelectedBundle();
|
||||
|
||||
if(bundle != null) {
|
||||
//Note: Dereflect the webapp bundle since we don't want the app logging via the reflection of the bundle, but rather the actual bundle.//
|
||||
WebServerApplication.getSingleton().reloadWebapp((WebappBundle) bundle.getReflected());
|
||||
}//if//
|
||||
}//if//
|
||||
}//try//
|
||||
catch(Throwable e) {
|
||||
Debug.log(e);
|
||||
}//catch//
|
||||
}//doReloadWebapp()//
|
||||
/**
|
||||
* Restarts the webapp without unpacking the zip.
|
||||
*/
|
||||
public void doRemoveWebapp() {
|
||||
try {
|
||||
if(getSelectedBundle() instanceof WebappBundle) {
|
||||
WebappBundle bundle = (WebappBundle) getSelectedBundle();
|
||||
|
||||
if(bundle != null) {
|
||||
WebServerApplication.getSingleton().removeWebapp((WebappBundle) bundle.getReflected());
|
||||
}//if//
|
||||
}//if//
|
||||
}//try//
|
||||
catch(Throwable e) {
|
||||
Debug.log(e);
|
||||
}//catch//
|
||||
}//doRemoveWebapp()//
|
||||
/**
|
||||
* Gets the BaseApp objects - one for the server as a whole, one one for each web application bundle.
|
||||
* @return The apps hosted by the web server and one for the server its self.
|
||||
*/
|
||||
public IManagedList getApps() {
|
||||
return (IManagedList) getAttributeValue(APPS);
|
||||
}//getApps()//
|
||||
/**
|
||||
* Sets the BaseApp objects - one for the server as a whole, one one for each web application bundle.
|
||||
* @param apps The apps hosted by the web server and one for the server its self.
|
||||
*/
|
||||
protected void setApps(IManagedList apps) {
|
||||
setAttributeValue(APPS, apps);
|
||||
}//setApps()//
|
||||
/**
|
||||
* Gets the webapp bundles.
|
||||
* @return The WebappBundle instances.
|
||||
*/
|
||||
public IManagedList getWebappBundles() {
|
||||
return (IManagedList) getAttributeValue(WEBAPP_BUNDLES);
|
||||
}//getWebappBundles()//
|
||||
/**
|
||||
* Sets the webapp bundles.
|
||||
* @param webappBundles The WebappBundle instances.
|
||||
*/
|
||||
private void setWebappBundles(IManagedList webappBundles) {
|
||||
setAttributeValue(WEBAPP_BUNDLES, webappBundles);
|
||||
}//setWebappBundles()//
|
||||
/**
|
||||
* Gets the selected value which may be one of: Server, WebappBundle, or IWebApplication.
|
||||
* @return The value selected in the tree view.
|
||||
*/
|
||||
public WebappBundle getSelectedBundle() {
|
||||
return (WebappBundle) getAttributeValue(SELECTED_BUNDLE);
|
||||
}//getSelectedBundle()//
|
||||
/**
|
||||
* Sets the selected value which may be one of: Server, WebappBundle, or IWebApplication.
|
||||
* @param selected The value selected in the tree view.
|
||||
*/
|
||||
public void setSelectedBundle(WebappBundle selected) {
|
||||
setAttributeValue(SELECTED_BUNDLE, selected);
|
||||
}//setSelectedBundle()//
|
||||
/**
|
||||
* Gets the color for displaying a log entry.
|
||||
* @param entry
|
||||
* @return
|
||||
*/
|
||||
public JefColor getLogEntryColor(WebappLogEntry entry) {
|
||||
int type = entry == null || entry.getType() == null ? WebappLogEntry.TYPE_INFORMATION : entry.getType().intValue();
|
||||
|
||||
return type == WebappLogEntry.TYPE_INFORMATION ? COLOR_INFO : type == WebappLogEntry.TYPE_WARNING ? COLOR_WARNING : COLOR_ERROR;
|
||||
}//getLogEntryColor()//
|
||||
/**
|
||||
* Gets the log value.
|
||||
* @return The log value.
|
||||
*/
|
||||
public String getLog() {
|
||||
return (String) getAttributeValue(LOG);
|
||||
}//getLog()//
|
||||
/**
|
||||
* Sets the log value.
|
||||
* @param log The log value.
|
||||
*/
|
||||
protected void setLog(String log) {
|
||||
setAttributeValue(LOG, log);
|
||||
}//setLog()//
|
||||
/**
|
||||
* Gets the webappLogEntries value.
|
||||
* @return The webappLogEntries value.
|
||||
*/
|
||||
public IManagedList getWebappLogEntries() {
|
||||
return (IManagedList) getAttributeValue(WEBAPP_LOG_ENTRIES);
|
||||
}//getWebappLogEntries()//
|
||||
/**
|
||||
* Sets the webappLogEntries value.
|
||||
* @param webappLogEntries The webappLogEntries value.
|
||||
*/
|
||||
protected void setWebappLogEntries(IManagedList webappLogEntries) {
|
||||
setAttributeValue(WEBAPP_LOG_ENTRIES, webappLogEntries);
|
||||
}//setWebappLogEntries()//
|
||||
/**
|
||||
* Gets the selectedLogEntry value.
|
||||
* @return The selectedLogEntry value.
|
||||
*/
|
||||
public WebappLogEntry getSelectedLogEntry() {
|
||||
return (WebappLogEntry) getAttributeValue(SELECTED_LOG_ENTRY);
|
||||
}//getSelectedLogEntry()//
|
||||
/**
|
||||
* Sets the selectedLogEntry value.
|
||||
* @param selectedLogEntry The selectedLogEntry value.
|
||||
*/
|
||||
public void setSelectedLogEntry(WebappLogEntry selectedLogEntry) {
|
||||
setAttributeValue(SELECTED_LOG_ENTRY, selectedLogEntry);
|
||||
}//setSelectedLogEntry()//
|
||||
/**
|
||||
* Gets the loaded application.
|
||||
* @return The application whose logs are loaded.
|
||||
*/
|
||||
public BaseApp getLoadedApp() {
|
||||
return (BaseApp) getAttributeValue(LOADED_APP);
|
||||
}//getLoadedApp()//
|
||||
/**
|
||||
* Sets the loaded application.
|
||||
* @param loadedApp The application whose logs are loaded.
|
||||
*/
|
||||
public void setLoadedApp(BaseApp loadedApp) {
|
||||
BaseApp old = getSelectedApp();
|
||||
|
||||
if(old != null) {
|
||||
getEventSupport().unregisterAll(old.getLog(), WebappLog.NEW_ENTRY);
|
||||
}//if//
|
||||
|
||||
getWebappLogEntries().removeAll();
|
||||
|
||||
if(loadedApp != null) {
|
||||
//Synchronize on the log so a new entry isn't added while setting up the listener and gathering the initial entries.//
|
||||
synchronized(loadedApp.getLog()) {
|
||||
int count = loadedApp.getLog().getEntryCount();
|
||||
|
||||
if(count > 0) {
|
||||
//Get the latest 4000 entries.//
|
||||
try {
|
||||
getWebappLogEntries().addAll(loadedApp.getLog().getEntries(count > 4000 ? count - 4000 : 0, count > 4000 ? 4000 : count));
|
||||
}//try//
|
||||
catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}//catch//
|
||||
}//if//
|
||||
|
||||
//Register for new entry events - ensure we run the updating of the controller's models on the view's thread and not the thread firing the event.//
|
||||
getEventSupport().register(loadedApp.getLog(), WebappLog.NEW_ENTRY, new IEventHandler() {
|
||||
public void evaluate(final IEventEmitter eventEmitter, int eventNumber, final Object[] eventParameters, int flags) {
|
||||
//Validate the parameters before going furthor.//
|
||||
if(eventParameters.length == 1 && eventParameters[0] instanceof WebappLogEntry) {
|
||||
try {
|
||||
//Run on the view's thread.//
|
||||
executeAsync(new IRunnable() {
|
||||
public Object run() {
|
||||
//Verify that the event emitter is the current selected BaseApp's log.//
|
||||
if(getSelectedApp().getLog() == eventEmitter) {
|
||||
//Remove the oldest entry so we never have more than 4000 in memory.//
|
||||
if(getWebappLogEntries().getSize() > 4000) {
|
||||
getWebappLogEntries().remove(0);
|
||||
}//if//
|
||||
|
||||
//Add the new entry.//
|
||||
getWebappLogEntries().add(eventParameters[0]);
|
||||
}//if//
|
||||
|
||||
return null;
|
||||
}//run()//
|
||||
});
|
||||
}//try//
|
||||
catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}//catch//
|
||||
}//if//
|
||||
}//evaluate()//
|
||||
public void evaluate(int eventNumber, Object[] eventParameters, int flags) {
|
||||
//Ignored since it will never be called.//
|
||||
}//evaluate()//
|
||||
});
|
||||
}//synchronized//
|
||||
}//if//
|
||||
|
||||
setAttributeValue(LOADED_APP, loadedApp);
|
||||
}//setLoadedApp()//
|
||||
/**
|
||||
* Gets the displayedLogCard value.
|
||||
* @return The displayedLogCard value.
|
||||
*/
|
||||
public Integer getDisplayedLogCard() {
|
||||
return (Integer) getAttributeValue(DISPLAYED_LOG_CARD);
|
||||
}//getDisplayedLogCard()//
|
||||
/**
|
||||
* Sets the displayedLogCard value.
|
||||
* @param displayedLogCard The displayedLogCard value.
|
||||
*/
|
||||
public void setDisplayedLogCard(Integer displayedLogCard) {
|
||||
setAttributeValue(DISPLAYED_LOG_CARD, displayedLogCard);
|
||||
}//setDisplayedLogCard()//
|
||||
/**
|
||||
* Gets the selected app.
|
||||
* @return The app selected in the second tab.
|
||||
*/
|
||||
public BaseApp getSelectedApp() {
|
||||
return (BaseApp) getAttributeValue(SELECTED_APP);
|
||||
}//getSelectedApp()//
|
||||
/**
|
||||
* Sets the selected app.
|
||||
* @param selectedApp The app selected in the second tab.
|
||||
*/
|
||||
public void setSelectedApp(BaseApp selectedApp) {
|
||||
setAttributeValue(SELECTED_APP, selectedApp);
|
||||
}//setSelectedApp()//
|
||||
}//MainViewController//
|
||||
Reference in New Issue
Block a user