You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by tv...@apache.org on 2009/03/16 17:16:58 UTC
svn commit: r754926 [11/38] - in /incubator/pivot/tags/v1.0: ./ charts-test/
charts-test/src/ charts-test/src/pivot/ charts-test/src/pivot/charts/
charts-test/src/pivot/charts/test/ charts/ charts/lib/ charts/src/
charts/src/pivot/ charts/src/pivot/cha...
Added: incubator/pivot/tags/v1.0/web/src/pivot/web/server/QueryServlet.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/web/src/pivot/web/server/QueryServlet.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/web/src/pivot/web/server/QueryServlet.java (added)
+++ incubator/pivot/tags/v1.0/web/src/pivot/web/server/QueryServlet.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,663 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.web.server;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.util.Enumeration;
+import java.util.Iterator;
+
+import javax.security.auth.login.LoginException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import pivot.collections.Dictionary;
+import pivot.collections.HashMap;
+import pivot.serialization.JSONSerializer;
+import pivot.serialization.SerializationException;
+import pivot.serialization.Serializer;
+import pivot.util.Base64;
+
+/**
+ * Abstract base class for web query servlets. It is the server counterpart to
+ * {@link pivot.web.Query pivot.web.Query}.
+ *
+ * @author tvolkert
+ */
+public abstract class QueryServlet extends HttpServlet {
+ static final long serialVersionUID = -646654620936816287L;
+
+ /**
+ * The supported HTTP methods.
+ *
+ * @author tvolkert
+ */
+ protected enum Method {
+ GET,
+ POST,
+ PUT,
+ DELETE;
+
+ public static Method decode(String value) {
+ return valueOf(value.toUpperCase());
+ }
+ }
+
+ /**
+ * User credentials, which will be made availale if the servlet's
+ * <tt>authenticationRequired</tt> flag is set to <tt>true</tt>.
+ *
+ * @author tvolkert
+ */
+ public static final class Credentials {
+ private String username;
+ private String password;
+
+ private Credentials(String username, String password) {
+ this.username = username;
+ this.password = password;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+ }
+
+ /**
+ * Arguments dictionary implementation.
+ *
+ * @author tvolkert
+ */
+ public final class ArgumentsDictionary
+ implements Dictionary<String, String>, Iterable<String> {
+ public String get(String key) {
+ return arguments.get(key);
+ }
+
+ public String put(String key, String value) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String remove(String key) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean containsKey(String key) {
+ return arguments.containsKey(key);
+ }
+
+ public boolean isEmpty() {
+ return arguments.isEmpty();
+ }
+
+ public Iterator<String> iterator() {
+ return arguments.iterator();
+ }
+ }
+
+ /**
+ * Request properties dictionary implementation.
+ *
+ * @author tvolkert
+ */
+ public final class RequestPropertiesDictionary
+ implements Dictionary<String, String>, Iterable<String> {
+ public String get(String key) {
+ return requestProperties.get(key);
+ }
+
+ public String put(String key, String value) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String remove(String key) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean containsKey(String key) {
+ return requestProperties.containsKey(key);
+ }
+
+ public boolean isEmpty() {
+ return requestProperties.isEmpty();
+ }
+
+ public Iterator<String> iterator() {
+ return requestProperties.iterator();
+ }
+ }
+
+ /**
+ * Response properties dictionary implementation.
+ *
+ * @author tvolkert
+ */
+ public final class ResponsePropertiesDictionary
+ implements Dictionary<String, String>, Iterable<String> {
+ public String get(String key) {
+ return responseProperties.get(key);
+ }
+
+ public String put(String key, String value) {
+ return responseProperties.put(key, value);
+ }
+
+ public String remove(String key) {
+ return responseProperties.remove(key);
+ }
+
+ public boolean containsKey(String key) {
+ return responseProperties.containsKey(key);
+ }
+
+ public boolean isEmpty() {
+ return responseProperties.isEmpty();
+ }
+
+ public Iterator<String> iterator() {
+ return responseProperties.iterator();
+ }
+ }
+
+ private boolean authenticationRequired = false;
+ private Credentials credentials = null;
+
+ private String hostname;
+ private String contextPath;
+ private String queryPath;
+ private int port;
+ private boolean secure;
+ private Method method;
+
+ private boolean determineContentLength = false;
+
+ private HashMap<String, String> arguments = new HashMap<String, String>();
+ private HashMap<String, String> requestProperties = new HashMap<String, String>();
+ private HashMap<String, String> responseProperties = new HashMap<String, String>();
+
+ private ArgumentsDictionary argumentsDictionary = new ArgumentsDictionary();
+ private RequestPropertiesDictionary requestPropertiesDictionary = new RequestPropertiesDictionary();
+ private ResponsePropertiesDictionary responsePropertiesDictionary = new ResponsePropertiesDictionary();
+
+ private Serializer serializer = new JSONSerializer();
+
+ private static final String BASIC_AUTHENTICATION_TAG = "Basic";
+ private static final String HTTP_PROTOCOL = "http";
+ private static final String HTTPS_PROTOCOL = "https";
+ private static final String URL_ENCODING = "UTF-8";
+
+ /**
+ * Gets the host name that was requested.
+ */
+ public String getHostname() {
+ return hostname;
+ }
+
+ /**
+ * Returns the portion of the request URI that indicates the context of the
+ * request. The context path always comes first in a request URI. The path
+ * starts with a "/" character but does not end with a "/" character. For
+ * servlets in the default (root) context, this method returns "".
+ */
+ public String getContextPath() {
+ return contextPath;
+ }
+
+ /**
+ * Returns the portion of the request URI that occurs after the context
+ * path but preceding the query string. It will start with a "/" character.
+ * For servlets in the default (root) context, this method returns the full
+ * path.
+ */
+ public String getQueryPath() {
+ return queryPath;
+ }
+
+ /**
+ * Returns the Internet Protocol (IP) port number of the interface on which
+ * the request was received.
+ */
+ public int getPort() {
+ return port;
+ }
+
+ /**
+ * Tells whether the request has been ecrypted over HTTPS.
+ */
+ public boolean isSecure() {
+ return secure;
+ }
+
+ /**
+ * Returns the name of the HTTP protocol that the request is using.
+ */
+ public String getProtocol() {
+ return isSecure() ? HTTPS_PROTOCOL : HTTP_PROTOCOL;
+ }
+
+ /**
+ * Gets the HTTP method with which the current request was made.
+ */
+ public Method getMethod() {
+ return method;
+ }
+
+ /**
+ * Tells whether this servlet is configured to always determine the content
+ * length of outgoing responses and set the <tt>Content-Length</tt> HTTP
+ * response header accordingly. If this flag is <tt>false</tt>, it is up to
+ * the servlet's discretion as to when to set the <tt>Content-Length</tt>
+ * header (it will do so if it is trivially easy). If this is set to
+ * <tt>true</tt>, it will force the servlet to always set the header, but
+ * doing so will incur a performance penalty, as the servlet will be unable
+ * to stream the response directly to the HTTP output stream as it gets
+ * serialized.
+ */
+ public boolean isDetermineContentLength() {
+ return determineContentLength;
+ }
+
+ /**
+ * Sets the value of the <tt>determineContentLength</tt> flag.
+ *
+ * @see #isDetermineContentLength()
+ */
+ public void setDetermineContentLength(boolean determineContentLength) {
+ this.determineContentLength = determineContentLength;
+ }
+
+ /**
+ * Tells whether or not this servlet will require authentication data. If
+ * set to <tt>true</tt>, and un-authenticated requests are received, the
+ * servlet will automatically respond with a request for authentication.
+ */
+ public boolean isAuthenticationRequired() {
+ return authenticationRequired;
+ }
+
+ /**
+ * Sets whether or not this servlet will require authentication data. If
+ * set to <tt>true</tt>, and un-authenticated requests are received, the
+ * servlet will automatically respond with a request for authentication.
+ */
+ public void setAuthenticationRequired(boolean authenticationRequired) {
+ this.authenticationRequired = authenticationRequired;
+
+ if (!authenticationRequired) {
+ credentials = null;
+ }
+ }
+
+ /**
+ * Gets the authentication credentials that were extracted from the
+ * request. These are only available if the <tt>authenticationRequired</tt>
+ * flag is set to <tt>true</tt>.
+ */
+ public Credentials getCredentials() {
+ return credentials;
+ }
+
+ /**
+ * Returns the servlet's arguments dictionary, which holds the values
+ * passed in the HTTP request query string.
+ */
+ public ArgumentsDictionary getArguments() {
+ return argumentsDictionary;
+ }
+
+ /**
+ * Returns the servlet's request property dictionary, which holds the HTTP
+ * request headers.
+ */
+ public RequestPropertiesDictionary getRequestProperties() {
+ return requestPropertiesDictionary;
+ }
+
+ /**
+ * Returns the servlet's response property dictionary, which holds the HTTP
+ * response headers that will be sent back to the client.
+ */
+ public ResponsePropertiesDictionary getResponseProperties() {
+ return responsePropertiesDictionary;
+ }
+
+ /**
+ * Returns the serializer used to stream the value passed to or from the
+ * web query. By default, an instance of {@link JSONSerializer} is used.
+ */
+ public Serializer getSerializer() {
+ return serializer;
+ }
+
+ /**
+ * Sets the serializer used to stream the value passed to or from the
+ * web query.
+ *
+ * @param serializer
+ */
+ public void setSerializer(Serializer serializer) {
+ if (serializer == null) {
+ throw new IllegalArgumentException("serializer is null.");
+ }
+
+ this.serializer = serializer;
+ }
+
+ /**
+ *
+ */
+ protected Object doGet() throws ServletException {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ */
+ protected URL doPost(Object value) throws ServletException {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ */
+ protected void doPut(Object value) throws ServletException {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ */
+ protected void doDelete() throws ServletException {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Authorizes the current request, and throws a <tt>LoginException</tt> if
+ * the request is not authorized. This method will only be called if the
+ * <tt>authenticationRequired</tt> flag is set to <tt>true</tt>. Subclasses
+ * wishing to authorize the authenticated user credentials may override
+ * this method to perform that authorization. On the other hand, the
+ * <tt>authorize</tt> method of <tt>QueryServlet</tt> does nothing, so
+ * subclasses that wish to authenticate the request but not authorization
+ * it may simply not override this method.
+ * <p>
+ * This method is guaranteed to be called after the arguments and request
+ * properties have been made available.
+ *
+ * @throws LoginException
+ * Thrown if the request is not authorized
+ */
+ protected void authorize() throws LoginException {
+ // No-op
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ protected void service(HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
+ boolean proceed = true;
+
+ if (authenticationRequired) {
+ String authorization = request.getHeader("Authorization");
+
+ if (authorization == null) {
+ proceed = false;
+ doUnauthorized(request, response);
+ } else {
+ String encodedCredentials = authorization.substring
+ (BASIC_AUTHENTICATION_TAG.length() + 1);
+ String decodedCredentials = new String(Base64.decode(encodedCredentials));
+ String[] credentialsPair = decodedCredentials.split(":");
+
+ String username = credentialsPair.length > 0 ? credentialsPair[0] : "";
+ String password = credentialsPair.length > 1 ? credentialsPair[1] : "";
+
+ if (credentials == null) {
+ credentials = new Credentials(username, password);
+ } else {
+ credentials.username = username;
+ credentials.password = password;
+ }
+ }
+ }
+
+ if (proceed) {
+ // Extract our location context
+ try {
+ URL url = new URL(request.getRequestURL().toString());
+
+ hostname = url.getHost();
+ contextPath = request.getContextPath();
+ queryPath = request.getRequestURI();
+ port = request.getLocalPort();
+ secure = url.getProtocol().equalsIgnoreCase(HTTPS_PROTOCOL);
+ method = Method.decode(request.getMethod());
+
+ if (queryPath.startsWith(contextPath)) {
+ queryPath = queryPath.substring(contextPath.length());
+ }
+ } catch (MalformedURLException ex) {
+ throw new ServletException(ex);
+ }
+
+ // Clear out any remnants of the previous service
+ arguments.clear();
+ requestProperties.clear();
+ responseProperties.clear();
+
+ // Copy the query string into our arguments dictionary
+ String queryString = request.getQueryString();
+ if (queryString != null) {
+ String[] pairs = queryString.split("&");
+
+ for (int i = 0, n = pairs.length; i < n; i++) {
+ String[] pair = pairs[i].split("=");
+
+ String key = URLDecoder.decode(pair[0], URL_ENCODING);
+ String value = URLDecoder.decode((pair.length > 1) ? pair[1] : "", URL_ENCODING);
+
+ arguments.put(key, value);
+ }
+ }
+
+ // Copy the request headers into our request properties dictionary
+ Enumeration<String> headerNames = request.getHeaderNames();
+ while (headerNames.hasMoreElements()) {
+ String headerName = headerNames.nextElement();
+ String headerValue = request.getHeader(headerName);
+
+ requestProperties.put(headerName, headerValue);
+ }
+
+ if (authenticationRequired) {
+ try {
+ authorize();
+ } catch (LoginException ex) {
+ proceed = false;
+ doUnauthorized(request, response);
+ }
+ }
+ }
+
+ if (proceed) {
+ super.service(request, response);
+ }
+ }
+
+ @Override
+ protected final void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
+ try {
+ Object result = doGet();
+
+ response.setStatus(200);
+ setResponseHeaders(response);
+ response.setContentType(serializer.getMIMEType());
+
+ OutputStream responseOutputStream = response.getOutputStream();
+
+ if (determineContentLength) {
+ File tempFile = File.createTempFile("pivot", null);
+
+ // Serialize our result to an intermediary file
+ FileOutputStream fileOutputStream = new FileOutputStream(tempFile);
+ try {
+ serializer.writeObject(result, fileOutputStream);
+ } finally {
+ fileOutputStream.close();
+ }
+
+ // Our content length is the length of the file in bytes
+ response.setHeader("Content-Length", String.valueOf(tempFile.length()));
+
+ // Now write the contents of the file out to our response
+ FileInputStream fileInputStream = new FileInputStream(tempFile);
+ try {
+ byte[] buffer = new byte[1024];
+ int nBytes;
+ do {
+ nBytes = fileInputStream.read(buffer);
+ if (nBytes > 0) {
+ responseOutputStream.write(buffer, 0, nBytes);
+ }
+ } while (nBytes != -1);
+ } finally {
+ fileInputStream.close();
+ }
+ } else {
+ serializer.writeObject(result, responseOutputStream);
+ }
+ } catch (UnsupportedOperationException ex) {
+ doMethodNotAllowed(response);
+ } catch (SerializationException ex) {
+ throw new ServletException(ex);
+ }
+ }
+
+ @Override
+ protected final void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
+ try {
+ Object value = serializer.readObject(request.getInputStream());
+
+ URL url = doPost(value);
+
+ response.setStatus(201);
+ setResponseHeaders(response);
+ response.setHeader("Location", url.toString());
+ response.setContentLength(0);
+ response.flushBuffer();
+ } catch (UnsupportedOperationException ex) {
+ doMethodNotAllowed(response);
+ } catch (SerializationException ex) {
+ throw new ServletException(ex);
+ }
+ }
+
+ @Override
+ protected final void doPut(HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
+ try {
+ Object value = serializer.readObject(request.getInputStream());
+
+ doPut(value);
+
+ response.setStatus(204);
+ setResponseHeaders(response);
+ response.setContentLength(0);
+ response.flushBuffer();
+ } catch (UnsupportedOperationException ex) {
+ doMethodNotAllowed(response);
+ } catch (SerializationException ex) {
+ throw new ServletException(ex);
+ }
+ }
+
+ @Override
+ protected final void doDelete(HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
+ try {
+ doDelete();
+
+ response.setStatus(204);
+ setResponseHeaders(response);
+ response.setContentLength(0);
+ response.flushBuffer();
+ } catch (UnsupportedOperationException ex) {
+ doMethodNotAllowed(response);
+ }
+ }
+
+ @Override
+ protected final void doHead(HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
+ doMethodNotAllowed(response);
+ }
+
+ @Override
+ protected final void doOptions(HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
+ doMethodNotAllowed(response);
+ }
+
+ @Override
+ protected final void doTrace(HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException {
+ doMethodNotAllowed(response);
+ }
+
+ /**
+ *
+ */
+ private void doUnauthorized(HttpServletRequest request, HttpServletResponse response)
+ throws IOException {
+ response.setHeader("WWW-Authenticate", "BASIC realm=\""
+ + request.getServletPath() +"\"");
+ response.setStatus(401);
+ response.setContentLength(0);
+ response.flushBuffer();
+ }
+
+ /**
+ *
+ */
+ private void doMethodNotAllowed(HttpServletResponse response) throws IOException {
+ response.setStatus(405);
+ response.setContentLength(0);
+ response.flushBuffer();
+ }
+
+ /**
+ *
+ */
+ private void setResponseHeaders(HttpServletResponse response) {
+ for (String key : responseProperties) {
+ response.setHeader(key, responseProperties.get(key));
+ }
+ }
+}
Added: incubator/pivot/tags/v1.0/web/src/pivot/web/server/package.html
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/web/src/pivot/web/server/package.html?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/web/src/pivot/web/server/package.html (added)
+++ incubator/pivot/tags/v1.0/web/src/pivot/web/server/package.html Mon Mar 16 16:16:40 2009
@@ -0,0 +1,6 @@
+<html>
+<head></head>
+<body>
+<p>Contains classes to facilitate access to and development of web query services.</p>
+</body>
+</html>
Added: incubator/pivot/tags/v1.0/wtk-test/.classpath
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/.classpath?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/.classpath (added)
+++ incubator/pivot/tags/v1.0/wtk-test/.classpath Mon Mar 16 16:16:40 2009
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/core"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/wtk"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: incubator/pivot/tags/v1.0/wtk-test/.project
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/.project?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/.project (added)
+++ incubator/pivot/tags/v1.0/wtk-test/.project Mon Mar 16 16:16:40 2009
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>wtk-test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/BorderTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/BorderTest.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/BorderTest.java (added)
+++ incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/BorderTest.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,32 @@
+package pivot.wtk.test;
+
+import pivot.collections.Dictionary;
+import pivot.wtk.Application;
+import pivot.wtk.Component;
+import pivot.wtk.Display;
+import pivot.wtk.Frame;
+import pivot.wtkx.WTKXSerializer;
+
+public class BorderTest implements Application {
+ private Frame frame = null;
+
+ public void startup(Display display, Dictionary<String, String> properties)
+ throws Exception {
+ WTKXSerializer wtkxSerializer = new WTKXSerializer();
+ frame = new Frame((Component)wtkxSerializer.readObject(getClass().getResource("border_test.wtkx")));
+ frame.setTitle("Border Test");
+ frame.setPreferredSize(480, 360);
+ frame.open(display);
+ }
+
+ public boolean shutdown(boolean optional) {
+ frame.close();
+ return true;
+ }
+
+ public void suspend() {
+ }
+
+ public void resume() {
+ }
+}
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/DragDropTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/DragDropTest.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/DragDropTest.java (added)
+++ incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/DragDropTest.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.test;
+
+import java.awt.Color;
+
+import pivot.collections.Dictionary;
+import pivot.wtk.Application;
+import pivot.wtk.Component;
+import pivot.wtk.ComponentMouseListener;
+import pivot.wtk.Dimensions;
+import pivot.wtk.Display;
+import pivot.wtk.DragDropManager;
+import pivot.wtk.DragHandler;
+import pivot.wtk.DropAction;
+import pivot.wtk.DropHandler;
+import pivot.wtk.Frame;
+import pivot.wtk.ImageView;
+import pivot.wtk.Visual;
+import pivot.wtk.media.Image;
+
+public class DragDropTest implements Application {
+ private Frame frame1 = new Frame();
+ private Frame frame2 = new Frame();
+
+ private static final Color IMAGE_VIEW_BACKGROUND_COLOR = new Color(0x99, 0x99, 0x99);
+ private static final Color IMAGE_VIEW_DROP_HIGHLIGHT_COLOR = new Color(0xf0, 0xe6, 0x8c);
+
+ private static class ImageDragHandler implements DragHandler {
+ ImageView imageView = null;
+ private Image image = null;
+ private Dimensions offset = null;
+
+ public boolean beginDrag(Component component, int x, int y) {
+ imageView = (ImageView)component;
+ image = imageView.getImage();
+
+ if (image != null) {
+ imageView.setImage((Image)null);
+ offset = new Dimensions(x - (imageView.getWidth() - image.getWidth()) / 2,
+ y - (imageView.getHeight() - image.getHeight()) / 2);
+ }
+
+ return (image != null);
+ }
+
+ public void endDrag(DropAction dropAction) {
+ if (dropAction == null) {
+ imageView.setImage(image);
+ }
+ }
+
+ public Object getContent() {
+ return image;
+ }
+
+ public Visual getRepresentation() {
+ return image;
+ }
+
+ public Dimensions getOffset() {
+ return offset;
+ }
+
+ public int getSupportedDropActions() {
+ return DropAction.MOVE.getMask();
+ }
+ }
+
+ private static class ImageDropHandler implements DropHandler {
+ public DropAction drop(Component component, int x, int y) {
+ DropAction dropAction = null;
+
+ DragDropManager dragDropManager = component.getDisplay().getDragDropManager();
+ Object dragContent = dragDropManager.getContent();
+ if (dragContent instanceof Image) {
+ ImageView imageView = (ImageView)component;
+ imageView.setImage((Image)dragContent);
+ imageView.getStyles().put("backgroundColor", IMAGE_VIEW_BACKGROUND_COLOR);
+ dropAction = DropAction.MOVE;
+ }
+
+ return dropAction;
+ }
+ }
+
+ private static class ImageMouseHandler implements ComponentMouseListener {
+ public boolean mouseMove(Component component, int x, int y) {
+ return false;
+ }
+
+ public void mouseOver(Component component) {
+ DragDropManager dragDropManager = component.getDisplay().getDragDropManager();
+ if (dragDropManager.isActive()) {
+ Object dragContent = dragDropManager.getContent();
+ if (dragContent instanceof Image) {
+ component.getStyles().put("backgroundColor", IMAGE_VIEW_DROP_HIGHLIGHT_COLOR);
+ }
+ }
+ }
+
+ public void mouseOut(Component component) {
+ component.getStyles().put("backgroundColor", IMAGE_VIEW_BACKGROUND_COLOR);
+ }
+ }
+
+ public void startup(Display display, Dictionary<String, String> properties) throws Exception {
+ frame1.setTitle("Frame 1");
+ frame1.setPreferredSize(160, 120);
+ frame1.getStyles().put("resizable", false);
+
+ ImageDragHandler imageDragHandler = new ImageDragHandler();
+ ImageDropHandler imageDropHandler = new ImageDropHandler();
+ ImageMouseHandler imageMouseHandler = new ImageMouseHandler();
+
+ ImageView imageView1 = new ImageView();
+ imageView1.setImage(Image.load(getClass().getResource("go-home.png")));
+ imageView1.setDragHandler(imageDragHandler);
+ imageView1.setDropHandler(imageDropHandler);
+ imageView1.getComponentMouseListeners().add(imageMouseHandler);
+ imageView1.getStyles().put("backgroundColor", IMAGE_VIEW_BACKGROUND_COLOR);
+ frame1.setContent(imageView1);
+ frame1.open(display);
+
+ frame2.setTitle("Frame 2");
+ frame2.setPreferredSize(160, 120);
+ frame2.setLocation(180, 0);
+
+ ImageView imageView2 = new ImageView();
+ imageView2.setDragHandler(imageDragHandler);
+ imageView2.setDropHandler(imageDropHandler);
+ imageView2.getComponentMouseListeners().add(imageMouseHandler);
+ imageView2.getStyles().put("backgroundColor", IMAGE_VIEW_BACKGROUND_COLOR);
+ frame2.setContent(imageView2);
+
+ frame2.open(display);
+ }
+
+ public boolean shutdown(boolean optional) {
+ frame1.close();
+ frame2.close();
+ return true;
+ }
+
+ public void suspend() {
+ }
+
+ public void resume() {
+ }
+}
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/FlowPaneTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/FlowPaneTest.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/FlowPaneTest.java (added)
+++ incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/FlowPaneTest.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.test;
+
+import pivot.collections.Dictionary;
+import pivot.wtk.Application;
+import pivot.wtk.Component;
+import pivot.wtk.Display;
+import pivot.wtk.Frame;
+import pivot.wtkx.WTKXSerializer;
+
+public class FlowPaneTest implements Application {
+ private Frame frame = null;
+
+ public void startup(Display display, Dictionary<String, String> properties)
+ throws Exception {
+ WTKXSerializer wtkxSerializer = new WTKXSerializer();
+ frame = new Frame((Component)wtkxSerializer.readObject(getClass().getResource("flow_pane_test.wtkx")));
+ frame.setTitle("Flow Pane Test");
+ frame.setPreferredSize(480, 360);
+ frame.open(display);
+ }
+
+ public boolean shutdown(boolean optional) {
+ frame.close();
+ return true;
+ }
+
+ public void resume() {
+ }
+
+
+ public void suspend() {
+ }
+}
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/FormTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/FormTest.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/FormTest.java (added)
+++ incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/FormTest.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.test;
+
+import pivot.collections.Dictionary;
+import pivot.wtk.Application;
+import pivot.wtk.Component;
+import pivot.wtk.Display;
+import pivot.wtk.Frame;
+import pivot.wtkx.WTKXSerializer;
+
+public class FormTest implements Application {
+ private Frame frame = null;
+
+ public void startup(Display display, Dictionary<String, String> properties)
+ throws Exception {
+ WTKXSerializer wtkxSerializer = new WTKXSerializer();
+ frame = new Frame((Component)wtkxSerializer.readObject(getClass().getResource("form_test.wtkx")));
+ frame.setTitle("Form Test");
+ frame.setPreferredSize(480, 360);
+ frame.open(display);
+ }
+
+ public boolean shutdown(boolean optional) {
+ frame.close();
+ return true;
+ }
+
+ public void resume() {
+ }
+
+
+ public void suspend() {
+ }
+}
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/IMG_0767_2.jpg
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/IMG_0767_2.jpg?rev=754926&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/IMG_0767_2.jpg
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/IMG_1147.jpg
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/IMG_1147.jpg?rev=754926&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/IMG_1147.jpg
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/LabelTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/LabelTest.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/LabelTest.java (added)
+++ incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/LabelTest.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.test;
+
+import pivot.collections.Dictionary;
+import pivot.wtk.Application;
+import pivot.wtk.Display;
+import pivot.wtk.HorizontalAlignment;
+import pivot.wtk.Label;
+import pivot.wtk.FlowPane;
+import pivot.wtk.Insets;
+import pivot.wtk.Orientation;
+import pivot.wtk.TextDecoration;
+import pivot.wtk.Window;
+
+public class LabelTest implements Application {
+ private Window window = null;
+
+ public void startup(Display display, Dictionary<String, String> properties) throws Exception {
+ window = new Window();
+ window.setTitle("Label Test");
+
+ String line1 = "There's a lady who's sure all that glitters is gold, and "
+ + "she's buying a stairway to heaven. When she gets there she knows, "
+ + "if the stores are closed, with a word she can get what she came "
+ + "for. Woe oh oh oh oh oh and she's buying a stairway to heaven. "
+ + "There's a sign on the wall, but she wants to be sure, and you know "
+ + "sometimes words have two meanings. In a tree by the brook there's "
+ + "a songbird who sings, sometimes all of our thoughts are misgiven. "
+ + "Woe oh oh oh oh oh and she's buying a stairway to heaven.";
+ String line2 = "And as we wind on down the road, our shadows taller than "
+ + "our souls, there walks a lady we all know who shines white light "
+ + "and wants to show how everything still turns to gold; and if you "
+ + "listen very hard the tune will come to you at last when all are "
+ + "one and one is all: to be a rock and not to roll.";
+
+ FlowPane flowPane = new FlowPane(Orientation.HORIZONTAL);
+
+ Label label1 = new Label(line1);
+ label1.getStyles().put("wrapText", true);
+ label1.getStyles().put("horizontalAlignment", HorizontalAlignment.LEFT);
+ flowPane.add(label1);
+
+ Label label2 = new Label(line2);
+ label2.getStyles().put("wrapText", true);
+ label2.getStyles().put("horizontalAlignment", HorizontalAlignment.LEFT);
+ label2.getStyles().put("textDecoration", TextDecoration.UNDERLINE);
+ flowPane.add(label2);
+
+ flowPane.getStyles().put("horizontalAlignment", HorizontalAlignment.JUSTIFY);
+ flowPane.getStyles().put("padding", new Insets(10));
+
+ window.setContent(flowPane);
+ window.setPreferredWidth(200);
+
+ window.open(display);
+ }
+
+ public boolean shutdown(boolean optional) {
+ window.close();
+ return true;
+ }
+
+ public void suspend() {
+ }
+
+ public void resume() {
+ }
+}
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/LinkButtonTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/LinkButtonTest.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/LinkButtonTest.java (added)
+++ incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/LinkButtonTest.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.test;
+
+import pivot.collections.Dictionary;
+import pivot.wtk.Application;
+import pivot.wtk.Component;
+import pivot.wtk.ComponentMouseListener;
+import pivot.wtk.Display;
+import pivot.wtk.FlowPane;
+import pivot.wtk.LinkButton;
+import pivot.wtk.VerticalAlignment;
+import pivot.wtk.Window;
+import pivot.wtk.content.ButtonData;
+import pivot.wtk.media.Image;
+
+public class LinkButtonTest implements Application {
+ private Window window = new Window();
+
+ public void startup(Display display, Dictionary<String, String> properties) throws Exception {
+ FlowPane flowPane = new FlowPane();
+ flowPane.getStyles().put("verticalAlignment", VerticalAlignment.CENTER);
+ flowPane.getStyles().put("spacing", 8);
+ flowPane.getComponentMouseListeners().add(new ComponentMouseListener() {
+ public boolean mouseMove(Component component, int x, int y) {
+ System.out.println("FLOW PANE " + x + ", " + y);
+ return false;
+ }
+
+ public void mouseOver(Component component) {
+ }
+
+ public void mouseOut(Component component) {
+ }
+ });
+
+ Image image = Image.load(getClass().getResource("go-home.png"));
+
+ LinkButton linkButton = null;
+
+ linkButton = new LinkButton("ABCDE");
+ flowPane.add(linkButton);
+ linkButton.getComponentMouseListeners().add(new ComponentMouseListener() {
+ public boolean mouseMove(Component component, int x, int y) {
+ return true;
+ }
+
+ public void mouseOver(Component component) {
+ }
+
+ public void mouseOut(Component component) {
+ }
+ });
+
+ linkButton = new LinkButton(image);
+ flowPane.add(linkButton);
+
+ linkButton = new LinkButton(new ButtonData(image, "12345"));
+ flowPane.add(linkButton);
+
+ window.setContent(flowPane);
+ window.open(display);
+ }
+
+ public boolean shutdown(boolean optional) {
+ window.close();
+ return true;
+ }
+
+ public void suspend() {
+ }
+
+ public void resume() {
+ }
+}
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/ListViewSelectionTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/ListViewSelectionTest.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/ListViewSelectionTest.java (added)
+++ incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/ListViewSelectionTest.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.test;
+
+import pivot.collections.ArrayList;
+import pivot.collections.Dictionary;
+import pivot.collections.List;
+import pivot.wtk.Application;
+import pivot.wtk.Display;
+import pivot.wtk.ListView;
+import pivot.wtk.Span;
+
+public class ListViewSelectionTest implements Application {
+ private ListView listView = new ListView();
+
+ @SuppressWarnings("unchecked")
+ public ListViewSelectionTest() {
+ List<Object> listData = (List<Object>)listView.getListData();
+
+ listData.add("0");
+ listData.add("1");
+ listData.add("2");
+ listData.add("3");
+ listData.add("4");
+ listData.add("5");
+ listData.add("6");
+ listData.add("7");
+ listData.add("8");
+ listData.add("9");
+ listData.add("A");
+ listData.add("B");
+ listData.add("C");
+ listData.add("D");
+ listData.add("E");
+ listData.add("F");
+
+ listView.setSelectMode(ListView.SelectMode.MULTI);
+ }
+
+ public void startup(Display display, Dictionary<String, String> properties) {
+ ArrayList<Span> selectedRanges = new ArrayList<Span>();
+ selectedRanges.add(new Span(0, 0));
+
+ listView.setSelectedRanges(selectedRanges);
+ dumpSelection();
+
+ listView.addSelectedRange(new Span(4, 4));
+ dumpSelection();
+
+ listView.addSelectedRange(new Span(2, 2));
+ dumpSelection();
+
+ listView.addSelectedRange(new Span(0, 4));
+ dumpSelection();
+
+ selectedRanges.clear();
+ selectedRanges.add(new Span(1, 1));
+ selectedRanges.add(new Span(3, 3));
+
+ listView.setSelectedRanges(selectedRanges);
+ dumpSelection();
+
+ listView.addSelectedRange(new Span(0, 4));
+ dumpSelection();
+
+ listView.removeSelectedRange(new Span(2, 2));
+ dumpSelection();
+
+ listView.removeSelectedRange(new Span(4, 4));
+ dumpSelection();
+
+ listView.removeSelectedRange(new Span(0, 0));
+ dumpSelection();
+
+ listView.removeSelectedRange(new Span(1, 3));
+ dumpSelection();
+
+ selectedRanges.clear();
+ selectedRanges.add(new Span(4, 6));
+ listView.setSelectedRanges(selectedRanges);
+ dumpSelection();
+
+ listView.addSelectedRange(new Span(2, 5));
+ dumpSelection();
+
+ listView.addSelectedRange(new Span(4, 8));
+ dumpSelection();
+
+ verifySelection(0);
+ verifySelection(4);
+ verifySelection(6);
+ verifySelection(8);
+
+ listView.removeSelectedRange(new Span(8, 12));
+ dumpSelection();
+ verifySelection(8);
+
+ listView.removeSelectedRange(new Span(0, 4));
+ dumpSelection();
+ verifySelection(4);
+ }
+
+ public boolean shutdown(boolean optional) {
+ return true;
+ }
+
+ public void suspend() {
+ }
+
+ public void resume() {
+ }
+
+ protected void dumpSelection() {
+ System.out.println("Selected " + listView.getSelectedRanges());
+ }
+
+ protected void verifySelection(int index) {
+ System.out.println("Index " + index + " "
+ + (listView.isIndexSelected(index) ? "is" : "is not") + " selected");
+ }
+}
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/MenuTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/MenuTest.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/MenuTest.java (added)
+++ incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/MenuTest.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.test;
+
+import pivot.collections.Dictionary;
+import pivot.wtk.Action;
+import pivot.wtk.Alert;
+import pivot.wtk.Application;
+import pivot.wtk.ApplicationContext;
+import pivot.wtk.Component;
+import pivot.wtk.ComponentMouseButtonListener;
+import pivot.wtk.Display;
+import pivot.wtk.Keyboard;
+import pivot.wtk.Label;
+import pivot.wtk.Menu;
+import pivot.wtk.MenuBar;
+import pivot.wtk.MenuPopup;
+import pivot.wtk.Mouse;
+import pivot.wtk.Window;
+import pivot.wtkx.WTKXSerializer;
+
+public class MenuTest implements Application {
+ private Window window = null;
+ private MenuPopup menuPopup = null;
+
+ public void startup(final Display display, Dictionary<String, String> properties)
+ throws Exception {
+ Action testAction = new Action("testAction") {
+ public String getDescription() {
+ return "Test Action";
+ }
+
+ public void perform() {
+ Alert.alert("Test action performed.", display);
+ }
+ };
+
+ WTKXSerializer wtkxSerializer = new WTKXSerializer();
+ window = new Window((Component)wtkxSerializer.readObject(getClass().getResource("menu_test.wtkx")));
+ final MenuBar menuBar = (MenuBar)wtkxSerializer.getObjectByName("menuBar");
+ Label label = (Label)wtkxSerializer.getObjectByName("label");
+
+ menuPopup = new MenuPopup((Menu)wtkxSerializer.readObject(getClass().getResource("menu_popup.wtkx")));
+ menuPopup.getStyles().put("borderColor", "#00ff00");
+
+ label.getComponentMouseButtonListeners().add(new ComponentMouseButtonListener() {
+ public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
+ if (button == Mouse.Button.RIGHT) {
+ menuPopup.open(display, component.mapPointToAncestor(display, x, y));
+ }
+
+ return false;
+ }
+
+ public boolean mouseUp(Component component, Mouse.Button button, int x, int y) {
+ return false;
+ }
+
+ public void mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
+ }
+ });
+
+ window.getActions().put(new Keyboard.KeyStroke(Keyboard.KeyCode.A,
+ Keyboard.Modifier.META.getMask()), testAction);
+ window.setMaximized(true);
+ window.open(display);
+
+ ApplicationContext.queueCallback(new Runnable() {
+ public void run() {
+ menuBar.requestFocus();
+ }
+ });
+ }
+
+ public boolean shutdown(boolean optional) {
+ window.close();
+ return true;
+ }
+
+ public void suspend() {
+ }
+
+ public void resume() {
+ }
+}
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/PanoramaTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/PanoramaTest.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/PanoramaTest.java (added)
+++ incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/PanoramaTest.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.test;
+
+import pivot.collections.Dictionary;
+import pivot.wtk.Application;
+import pivot.wtk.Component;
+import pivot.wtk.Display;
+import pivot.wtk.Frame;
+import pivot.wtk.ImageView;
+import pivot.wtk.Panorama;
+import pivot.wtkx.WTKXSerializer;
+
+public class PanoramaTest implements Application {
+ private Frame frame1 = null;
+ private Frame frame2 = null;
+
+ public void startup(Display display, Dictionary<String, String> properties)
+ throws Exception {
+ frame1 = new Frame();
+ frame1.setTitle("Panorama Test 1");
+
+ Panorama panorama = new Panorama();
+ frame1.setContent(panorama);
+ frame1.setPreferredSize(240, 320);
+
+ ImageView imageView = new ImageView();
+ imageView.setImage(getClass().getResource("IMG_0767_2.jpg"));
+ panorama.setView(imageView);
+ frame1.open(display);
+
+ WTKXSerializer wtkxSerializer = new WTKXSerializer();
+ frame2 = new Frame((Component)wtkxSerializer.readObject(getClass().getResource("panorama_test.wtkx")));
+ frame2.setTitle("Panorama Test 2");
+ frame2.setPreferredSize(480, 360);
+ frame2.open(display);
+ }
+
+ public boolean shutdown(boolean optional) {
+ frame1.close();
+ frame2.close();
+ return false;
+ }
+
+ public void suspend() {
+ }
+
+ public void resume() {
+ }
+}
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/ReflectionDecoratorTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/ReflectionDecoratorTest.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/ReflectionDecoratorTest.java (added)
+++ incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/ReflectionDecoratorTest.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.test;
+
+import pivot.collections.ArrayList;
+import pivot.collections.Dictionary;
+import pivot.wtk.Alert;
+import pivot.wtk.Application;
+import pivot.wtk.ApplicationContext;
+import pivot.wtk.Dialog;
+import pivot.wtk.DialogCloseListener;
+import pivot.wtk.Display;
+import pivot.wtk.MessageType;
+
+public class ReflectionDecoratorTest implements Application {
+ Display display = null;
+ boolean shutdown = false;
+
+ public void startup(Display display, Dictionary<String, String> properties) {
+ this.display = display;
+ System.out.println("startup()");
+ }
+
+ public boolean shutdown(boolean optional) {
+ System.out.println("shutdown()");
+
+ ArrayList<String> options = new ArrayList<String>();
+ options.add("OK");
+ options.add("Cancel");
+
+ Alert alert = new Alert(MessageType.QUESTION, "Shutdown?", options);
+ alert.open(display, new DialogCloseListener() {
+ public void dialogClosed(Dialog dialog) {
+ Alert alert = (Alert)dialog;
+
+ if (alert.getResult()) {
+ if (alert.getSelectedOption() == 0) {
+ shutdown = true;
+ ApplicationContext.exit();
+ }
+ }
+ }
+ });
+
+ return shutdown;
+ }
+
+ public void suspend() {
+ }
+
+ public void resume() {
+ }
+}
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/SheetTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/SheetTest.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/SheetTest.java (added)
+++ incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/SheetTest.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.test;
+
+import pivot.collections.Dictionary;
+import pivot.util.Vote;
+import pivot.wtk.Application;
+import pivot.wtk.Button;
+import pivot.wtk.ButtonPressListener;
+import pivot.wtk.Display;
+import pivot.wtk.FlowPane;
+import pivot.wtk.Frame;
+import pivot.wtk.HorizontalAlignment;
+import pivot.wtk.Label;
+import pivot.wtk.PushButton;
+import pivot.wtk.Sheet;
+import pivot.wtk.TablePane;
+import pivot.wtk.VerticalAlignment;
+import pivot.wtk.Window;
+import pivot.wtk.WindowStateListener;
+import pivot.wtk.media.Image;
+
+public class SheetTest implements Application {
+ private Frame frame = null;
+ private Sheet sheet = null;
+
+ public void startup(final Display display, Dictionary<String, String> properties)
+ throws Exception {
+ PushButton windowContent = new PushButton(Image.load(getClass().getResource("IMG_0767_2.jpg")));
+ windowContent.setPreferredSize(480, 360);
+
+ frame = new Frame(windowContent);
+ frame.getStyles().put("padding", 0);
+ frame.open(display);
+
+ final TablePane tablePane = new TablePane();
+ tablePane.setPreferredSize(320, 240);
+ tablePane.getColumns().add(new TablePane.Column(1, true));
+ tablePane.getRows().add(new TablePane.Row(1, true));
+ tablePane.getRows().add(new TablePane.Row(-1));
+
+ Label sheetContent = new Label("Sheet Content");
+ sheetContent.getStyles().put("horizontalAlignment", HorizontalAlignment.CENTER);
+ sheetContent.getStyles().put("verticalAlignment", VerticalAlignment.CENTER);
+
+ tablePane.getRows().get(0).add(sheetContent);
+
+ FlowPane flowPane = new FlowPane();
+ tablePane.getRows().get(1).add(flowPane);
+
+ flowPane.getStyles().put("horizontalAlignment", HorizontalAlignment.RIGHT);
+
+ final PushButton closeButton = new PushButton("Close");
+ closeButton.getStyles().put("preferredAspectRatio", 3);
+ flowPane.add(closeButton);
+
+ sheet = new Sheet(tablePane);
+
+ closeButton.getButtonPressListeners().add(new ButtonPressListener() {
+ public void buttonPressed(Button button) {
+ button.getWindow().close();
+ }
+ });
+
+ windowContent.getButtonPressListeners().add(new ButtonPressListener() {
+ public void buttonPressed(Button button) {
+ sheet.open(frame);
+ }
+ });
+
+ sheet.getWindowStateListeners().add(new WindowStateListener() {
+ public Vote previewWindowOpen(Window window, Display display) {
+ return Vote.APPROVE;
+ }
+
+ public void windowOpenVetoed(Window window, Vote reason) {
+ }
+
+ public void windowOpened(Window window) {
+ closeButton.requestFocus();
+ }
+
+ public Vote previewWindowClose(Window window) {
+ return Vote.APPROVE;
+ }
+
+ public void windowCloseVetoed(Window window, Vote reason) {
+ }
+
+ public void windowClosed(Window window, Display display) {
+ }
+ });
+ }
+
+ public boolean shutdown(boolean optional) {
+ frame.close();
+ return true;
+ }
+
+ public void suspend() {
+ }
+
+ public void resume() {
+ }
+}
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/SpinnerFocusTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/SpinnerFocusTest.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/SpinnerFocusTest.java (added)
+++ incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/SpinnerFocusTest.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.test;
+
+import pivot.collections.Dictionary;
+import pivot.wtk.Action;
+import pivot.wtk.Alert;
+import pivot.wtk.Application;
+import pivot.wtk.Component;
+import pivot.wtk.Display;
+import pivot.wtk.Frame;
+import pivot.wtk.Spinner;
+import pivot.wtkx.WTKXSerializer;
+
+public class SpinnerFocusTest implements Application {
+ private Frame frame = null;
+
+ public void startup(Display display, Dictionary<String, String> properties)
+ throws Exception {
+ Action action = new Action("buttonAction") {
+ public String getDescription() {
+ return null;
+ }
+
+ public void perform() {
+ Alert.alert("Foo", frame);
+ }
+ };
+
+ WTKXSerializer wtkxSerializer = new WTKXSerializer();
+ frame = new Frame((Component)wtkxSerializer.readObject(getClass().getResource("spinner_focus_test.wtkx")));
+ frame.setTitle("Spinner Focus Test");
+ frame.open(display);
+
+ Spinner spinner = (Spinner)wtkxSerializer.getObjectByName("spinner");
+ spinner.requestFocus();
+
+ action.setEnabled(false);
+ }
+
+ public boolean shutdown(boolean optional) {
+ frame.close();
+ return true;
+ }
+
+ public void suspend() {
+ }
+
+ public void resume() {
+ }
+}
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/SwingAdapterTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/SwingAdapterTest.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/SwingAdapterTest.java (added)
+++ incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/SwingAdapterTest.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.test;
+
+import pivot.collections.Dictionary;
+import pivot.wtk.Application;
+import pivot.wtk.Display;
+import pivot.wtk.Frame;
+import pivot.wtkx.WTKXSerializer;
+
+public class SwingAdapterTest implements Application {
+ public void startup(Display display, Dictionary<String, String> properties)
+ throws Exception {
+ WTKXSerializer wtkxSerializer;
+ Frame frame;
+
+ wtkxSerializer = new WTKXSerializer();
+ frame = (Frame)wtkxSerializer.readObject(getClass().getResource("swing_adapter_test.wtkx"));
+ frame.open(display);
+
+ wtkxSerializer = new WTKXSerializer();
+ frame = (Frame)wtkxSerializer.readObject(getClass().getResource("swing_adapter_test.wtkx"));
+ frame.open(display);
+ frame.setLocation(20, 20);
+ }
+
+ public boolean shutdown(boolean optional) {
+ return true;
+ }
+
+ public void resume() {
+ }
+
+
+ public void suspend() {
+ }
+}
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/TablePaneTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/TablePaneTest.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/TablePaneTest.java (added)
+++ incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/TablePaneTest.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.test;
+
+import pivot.collections.Dictionary;
+import pivot.wtk.Application;
+import pivot.wtk.Component;
+import pivot.wtk.Display;
+import pivot.wtk.Window;
+import pivot.wtkx.WTKXSerializer;
+
+/**
+ * Demonstrates a layout issue with TablePane. A one-row, two-column table is
+ * created. The row height is set to 1* so it fills the vertical space. Column
+ * 0 is given a default width (-1), and the width of column 1 is set to 1* so
+ * it occupies the remaining horizontal space after column 0 is accounted for.
+ *
+ * When the program is run, column 0 is not visible. If given an explicit width,
+ * column 0 appears, and the other cell is sized appropriately.
+ */
+public class TablePaneTest implements Application {
+ private Window window = null;
+
+ public void startup(Display display, Dictionary<String, String> properties)
+ throws Exception {
+ WTKXSerializer wtkxSerializer = new WTKXSerializer();
+ window = new Window((Component)wtkxSerializer.readObject(getClass().getResource("table_pane_test.wtkx")));
+ window.setTitle("TableView Test");
+ window.setMaximized(true);
+ window.open(display);
+ }
+
+ public boolean shutdown(boolean optional) {
+ window.close();
+ return true;
+ }
+
+ public void suspend() {
+ }
+
+ public void resume() {
+ }
+}
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/WindowTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/WindowTest.java?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/WindowTest.java (added)
+++ incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/WindowTest.java Mon Mar 16 16:16:40 2009
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.wtk.test;
+
+import pivot.collections.Dictionary;
+import pivot.wtk.Application;
+import pivot.wtk.Dialog;
+import pivot.wtk.Display;
+import pivot.wtk.Frame;
+import pivot.wtk.Palette;
+import pivot.wtk.effects.ReflectionDecorator;
+
+public class WindowTest implements Application {
+ private Frame window1 = new Frame();
+
+ public void startup(Display display, Dictionary<String, String> properties) {
+ window1.setTitle("Window 1");
+ window1.setPreferredSize(320, 240);
+ window1.open(display);
+
+ Frame window1a = new Frame();
+ window1a.setTitle("Window 1 A");
+ window1a.setPreferredSize(160, 120);
+ window1a.open(display); // window1);
+
+ Frame window1ai = new Frame();
+ window1ai.setTitle("Window 1 A I");
+ window1ai.setPreferredSize(160, 60);
+ window1ai.open(display); // window1a);
+ window1ai.getDecorators().update(0, new ReflectionDecorator());
+
+ Frame window1aii = new Frame();
+ window1aii.setTitle("Window 1 A II");
+ window1aii.setPreferredSize(160, 60);
+ window1aii.open(window1a);
+
+ Frame window1b = new Frame();
+ window1b.setTitle("Window 1 B");
+ window1b.setPreferredSize(160, 120);
+ window1b.setLocation(20, 20);
+ window1b.open(window1);
+
+ Frame window1bi = new Frame();
+ window1bi.setTitle("Window 1 B I");
+ window1bi.setPreferredSize(160, 60);
+ window1bi.open(window1b);
+
+ Frame window1bii = new Frame();
+ window1bii.setTitle("Window 1 B II");
+ window1bii.setPreferredSize(160, 60);
+ window1bii.open(window1b);
+
+ Palette palette1 = new Palette();
+ palette1.setTitle("Palette 1bii 1");
+ palette1.setPreferredSize(160, 60);
+ palette1.open(window1bii);
+
+ Palette palette2 = new Palette();
+ palette2.setTitle("Palette 1bii 2");
+ palette2.setPreferredSize(160, 60);
+ palette2.open(window1bii);
+
+ Frame dialogOwner = new Frame();
+ dialogOwner.setTitle("Dialog Owner");
+ dialogOwner.setPreferredSize(160, 60);
+ dialogOwner.open(display);
+
+ Dialog dialog = new Dialog();
+ dialog.setTitle("Dialog 1");
+ dialog.setPreferredSize(160, 60);
+ dialog.open(dialogOwner, true);
+
+ Dialog dialog2 = new Dialog();
+ dialog2.setTitle("Dialog 2");
+ dialog2.setPreferredSize(160, 60);
+ dialog2.open(dialog, true);
+ }
+
+ public boolean shutdown(boolean optional) {
+ window1.close();
+ return true;
+ }
+
+ public void suspend() {
+ }
+
+ public void resume() {
+ }
+}
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/border_test.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/border_test.wtkx?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/border_test.wtkx (added)
+++ incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/border_test.wtkx Mon Mar 16 16:16:40 2009
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2008 VMware, Inc.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<Border title="Border Title" styles="{thickness:5, cornerRadii:10, padding:5}"
+ xmlns:wtkx="http://pivot.dev.java.net/wtkx/2008" xmlns="pivot.wtk">
+ <content>
+ <Label text="Some very long text...fill in more here to reproduce fill in more here to reproduce fill in more here to reproduce"
+ styles="{wrapText:true, horizontalAlignment:'center'}" />
+ </content>
+</Border>
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/flow_pane_test.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/flow_pane_test.wtkx?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/flow_pane_test.wtkx (added)
+++ incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/flow_pane_test.wtkx Mon Mar 16 16:16:40 2009
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2008 VMware, Inc.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<FlowPane styles="{horizontalAlignment:'justify', verticalAlignment:'center'}"
+ xmlns:wtkx="http://pivot.dev.java.net/wtkx/2008" xmlns="pivot.wtk">
+ <Label text="Some very long text...fill in more here to reproduce fill in more here to reproduce fill in more here to reproduce"
+ styles="{wrapText:true, horizontalAlignment:'center'}" />
+</FlowPane>
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/form_test.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/form_test.wtkx?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/form_test.wtkx (added)
+++ incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/form_test.wtkx Mon Mar 16 16:16:40 2009
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2008 VMware, Inc.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<Form styles="{rightAlignLabels:true, fieldAlignment:'justify'}"
+ xmlns:wtkx="http://pivot.dev.java.net/wtkx/2008" xmlns="pivot.wtk">
+ <sections>
+ <Form.Section heading="Test Section">
+ <Label Form.name="ABCD" text="Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS..."
+ styles="{wrapText:true}"/>
+ </Form.Section>
+ <Form.Section heading="Test Section">
+ <Label Form.name="ABCD" text="Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS..."
+ styles="{wrapText:true}"/>
+ </Form.Section>
+ <Form.Section heading="Test Section">
+ <Label Form.name="ABCD" text="Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS..."
+ styles="{wrapText:true}"/>
+ </Form.Section>
+ </sections>
+</Form>
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/go-home.png
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/go-home.png?rev=754926&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/go-home.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/menu_bar.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/menu_bar.wtkx?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/menu_bar.wtkx (added)
+++ incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/menu_bar.wtkx Mon Mar 16 16:16:40 2009
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2008 VMware, Inc.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<MenuBar xmlns:wtkx="http://pivot.dev.java.net/wtkx/2008" xmlns="pivot.wtk">
+ <items>
+ <MenuBar.Item buttonData="Menu 1" styles="{popupBorderColor:'#0000ff'}">
+ <menu>
+ <Menu>
+ <sections>
+ <Menu.Section>
+ <Menu.Item buttonData="Option 1.1">
+ <menu>
+ <Menu>
+ <sections>
+ <Menu.Section>
+ <Menu.Item buttonData="Option 1.1.1" action="testAction"/>
+ <Menu.Item buttonData="Option 1.1.2"/>
+ <Menu.Item buttonData="Option 1.1.3"/>
+ </Menu.Section>
+ <Menu.Section>
+ <Menu.Item buttonData="Option 1.1.4"/>
+ <Menu.Item buttonData="Option 1.1.5"/>
+ <Menu.Item buttonData="Option 1.1.6"/>
+ </Menu.Section>
+ </sections>
+ </Menu>
+ </menu>
+ </Menu.Item>
+ </Menu.Section>
+ <Menu.Section>
+ <Menu.Item buttonData="Option 1.4"/>
+ </Menu.Section>
+ </sections>
+ </Menu>
+ </menu>
+ </MenuBar.Item>
+
+ <MenuBar.Item buttonData="Menu 1a" displayable="false">
+ <menu>
+ <Menu>
+ <sections>
+ <Menu.Section>
+ <Menu.Item buttonData="Option 1a.1"/>
+ <Menu.Item buttonData="Option 1a.2"/>
+ </Menu.Section>
+ <Menu.Section>
+ <Menu.Item buttonData="Option 1a.3"/>
+ <Menu.Item buttonData="Option 1a.4"/>
+ <Menu.Item buttonData="Option 1a.5"/>
+ <Menu.Item buttonData="Option 1a.6"/>
+ </Menu.Section>
+ </sections>
+ </Menu>
+ </menu>
+ </MenuBar.Item>
+
+ <MenuBar.Item buttonData="Menu 2">
+ <menu>
+ <Menu>
+ <sections>
+ <Menu.Section>
+ <Menu.Item buttonData="Option 2.1"/>
+ <Menu.Item buttonData="Option 2.2"/>
+ </Menu.Section>
+ <Menu.Section>
+ <Menu.Item buttonData="Option 2.3"/>
+ <Menu.Item buttonData="Option 2.4"/>
+ <Menu.Item buttonData="Option 2.5"/>
+ <Menu.Item buttonData="Option 2.6"/>
+ </Menu.Section>
+ </sections>
+ </Menu>
+ </menu>
+ </MenuBar.Item>
+
+ <MenuBar.Item buttonData="Menu 3">
+ <menu>
+ <Menu>
+ <sections>
+ <Menu.Section>
+ <Menu.Item buttonData="Option 3.1"/>
+ <Menu.Item buttonData="Option 3.2"/>
+ </Menu.Section>
+ <Menu.Section>
+ <Menu.Item buttonData="Option 3.3"/>
+ <Menu.Item buttonData="Option 3.4"/>
+ <Menu.Item buttonData="Option 3.5"/>
+ <Menu.Item buttonData="Option 3.6"/>
+ </Menu.Section>
+ <Menu.Section>
+ <Menu.Item buttonData="Option 3.7"/>
+ <Menu.Item buttonData="Option 3.8"/>
+ </Menu.Section>
+ </sections>
+ </Menu>
+ </menu>
+ </MenuBar.Item>
+ </items>
+</MenuBar>
Added: incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/menu_popup.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/menu_popup.wtkx?rev=754926&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/menu_popup.wtkx (added)
+++ incubator/pivot/tags/v1.0/wtk-test/src/pivot/wtk/test/menu_popup.wtkx Mon Mar 16 16:16:40 2009
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2008 VMware, Inc.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<Menu xmlns:wtkx="http://pivot.dev.java.net/wtkx/2008" xmlns="pivot.wtk">
+ <sections>
+ <Menu.Section>
+ <Menu.Item buttonData="Menu Item 1" styles="{popupBorderColor:'#ff0000'}">
+ <menu>
+ <Menu>
+ <sections>
+ <Menu.Section>
+ <Menu.Item action="testAction">
+ <buttonData text="Menu Item 1A" keyboardShortcut="META-A"/>
+ </Menu.Item>
+ <Menu.Item>
+ <buttonData text="Menu Item 1Ax" keyboardShortcut="CTRL-ALT-X"/>
+ </Menu.Item>
+ <Menu.Item buttonData="Menu Item 1B">
+ <menu>
+ <Menu>
+ <sections>
+ <Menu.Section>
+ <Menu.Item buttonData="Menu Item 1Bi"/>
+ <Menu.Item buttonData="Menu Item 1Bii"/>
+ <Menu.Item buttonData="Menu Item 1Biii"/>
+ </Menu.Section>
+ </sections>
+ </Menu>
+ </menu>
+ </Menu.Item>
+ <Menu.Item buttonData="Menu Item 1C" action="testAction"/>
+ <Menu.Item buttonData="Menu Item 1D">
+ <menu>
+ <Menu>
+ <sections>
+ <Menu.Section>
+ <Menu.Item buttonData="Menu Item 1Di"/>
+ <Menu.Item buttonData="Menu Item 1Dii" displayable="false"/>
+ <Menu.Item buttonData="Menu Item 1Diii"/>
+ </Menu.Section>
+ </sections>
+ </Menu>
+ </menu>
+ </Menu.Item>
+ </Menu.Section>
+ </sections>
+ </Menu>
+ </menu>
+ </Menu.Item>
+ <Menu.Item buttonData="Menu Item 2" toggleButton="true" selected="true"/>
+ </Menu.Section>
+ <Menu.Section>
+ <Menu.Item buttonData="Menu Item 3" toggleButton="true" group="a" selected="true"/>
+ <Menu.Item buttonData="Menu Item 4" toggleButton="true" group="a" />
+ <Menu.Item buttonData="Menu Item 5" toggleButton="true" group="a" />
+ </Menu.Section>
+ <Menu.Section>
+ <Menu.Item buttonData="Menu Item 6">
+ <menu>
+ <Menu>
+ <sections>
+ <Menu.Section>
+ <Menu.Item buttonData="Menu Item 6A"/>
+ <Menu.Item buttonData="Menu Item 6B"/>
+ </Menu.Section>
+ </sections>
+ </Menu>
+ </menu>
+ </Menu.Item>
+ <Menu.Item buttonData="Menu Item 7"/>
+ </Menu.Section>
+ </sections>
+</Menu>