You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/06/19 16:38:39 UTC
svn commit: r786520 - in /incubator/pivot/trunk:
demos/src/org/apache/pivot/demos/itunes/ demos/www/
wtk/src/org/apache/pivot/wtk/ wtk/src/org/apache/pivot/wtk/effects/
wtk/src/org/apache/pivot/wtkx/
Author: gbrown
Date: Fri Jun 19 14:38:39 2009
New Revision: 786520
URL: http://svn.apache.org/viewvc?rev=786520&view=rev
Log:
Update iTunes Search demo; add open(String) overload to ApplicationContext; allow repeating Transitions to be reversed.
Added:
incubator/pivot/trunk/demos/www/itunes_search.template.html
Modified:
incubator/pivot/trunk/demos/src/org/apache/pivot/demos/itunes/SearchDemo.java
incubator/pivot/trunk/demos/src/org/apache/pivot/demos/itunes/search_demo.wtkx
incubator/pivot/trunk/demos/www/index.html
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Transition.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java
Modified: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/itunes/SearchDemo.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/itunes/SearchDemo.java?rev=786520&r1=786519&r2=786520&view=diff
==============================================================================
--- incubator/pivot/trunk/demos/src/org/apache/pivot/demos/itunes/SearchDemo.java (original)
+++ incubator/pivot/trunk/demos/src/org/apache/pivot/demos/itunes/SearchDemo.java Fri Jun 19 14:38:39 2009
@@ -51,6 +51,7 @@
@WTKX private FlowPane activityIndicatorFlowPane;
@WTKX private ActivityIndicator activityIndicator;
@WTKX private ImageView artworkImageView;
+ @WTKX private PushButton previewButton;
private GetQuery getQuery = null;
@@ -238,6 +239,8 @@
}
}));
}
+
+ previewButton.setEnabled(artworkImageView.getImage() != null);
}
public static void main(String[] args) {
Modified: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/itunes/search_demo.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/itunes/search_demo.wtkx?rev=786520&r1=786519&r2=786520&view=diff
==============================================================================
--- incubator/pivot/trunk/demos/src/org/apache/pivot/demos/itunes/search_demo.wtkx (original)
+++ incubator/pivot/trunk/demos/src/org/apache/pivot/demos/itunes/search_demo.wtkx Fri Jun 19 14:38:39 2009
@@ -121,11 +121,28 @@
<view>
<TableView wtkx:id="resultsTableView">
<columns>
- <TableView.Column name="itemName" width="3*" headerData="Name"/>
- <TableView.Column name="itemParentName" width="3*" headerData="Album"/>
- <TableView.Column name="artistName" width="3*" headerData="Artist"/>
- <TableView.Column name="mediaType" width="2*" headerData="Kind"/>
+ <TableView.Column name="itemName" width="1*" headerData="Name"/>
+ <TableView.Column name="itemParentName" width="1*" headerData="Album"/>
+ <TableView.Column name="artistName" width="1*" headerData="Artist"/>
</columns>
+ <componentMouseButtonListeners>
+ <wtkx:script>
+ <![CDATA[
+ importPackage(org.apache.pivot.wtk);
+ var selectedResult;
+
+ function mouseClick(component, button, x, y, count) {
+ if (count == 1) {
+ selectedResult = resultsTableView.getSelectedRow();
+ } else if (count == 2) {
+ if (selectedResult == resultsTableView.getSelectedRow()) {
+ ApplicationContext.open(selectedResult.get("previewUrl"));
+ }
+ }
+ }
+ ]]>
+ </wtkx:script>
+ </componentMouseButtonListeners>
<tableViewSelectionListeners>
<wtkx:script>
@@ -164,13 +181,28 @@
</FlowPane>
</StackPane>
- <FlowPane orientation="vertical">
+ <FlowPane orientation="vertical" styles="{horizontalAlignment:'justify'}">
<Border styles="{padding:0}">
<content>
<ImageView wtkx:id="artworkImageView"
preferredWidth="120" preferredHeight="120"/>
</content>
</Border>
+ <FlowPane styles="{horizontalAlignment:'center'}">
+ <PushButton wtkx:id="previewButton" buttonData="Preview" enabled="false">
+ <buttonPressListeners>
+ <wtkx:script>
+ <![CDATA[
+ importPackage(org.apache.pivot.wtk);
+ function buttonPressed(button) {
+ var selectedResult = resultsTableView.getSelectedRow();
+ ApplicationContext.open(selectedResult.get("previewUrl"));
+ }
+ ]]>
+ </wtkx:script>
+ </buttonPressListeners>
+ </PushButton>
+ </FlowPane>
</FlowPane>
</TablePane.Row>
</rows>
Modified: incubator/pivot/trunk/demos/www/index.html
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/www/index.html?rev=786520&r1=786519&r2=786520&view=diff
==============================================================================
--- incubator/pivot/trunk/demos/www/index.html (original)
+++ incubator/pivot/trunk/demos/www/index.html Fri Jun 19 14:38:39 2009
@@ -20,58 +20,76 @@
<title>Index of Pivot Demos</title>
</head>
<body>
+
<p>
<a href="kitchen_sink.html">"Kitchen Sink"</a><br>
Demonstrates a number of commonly used Pivot components.<br>
</p>
+
<p>
<a href="stock_tracker.html">Stock Tracker</a><br>
An example of a simple but practical "real world" application built using
Pivot. Monitors stock quotes provided by
<a href="http://finance.yahoo.com/">Yahoo! Finance</a>.<br>
</p>
+
<p>
<a href="scripting.html">Scripting</a><br>
Simple example of a Pivot application written using JavaScript and Groovy.<br>
</p>
+
+<p>
+<a href="file_browser.html">File Browser</a><br>
+Simple application that allows a user to run search queries against the
+iTunes Music Store and presents the results in a table view.<br>
+</p>
+
<p>
<a href="file_browser.html">File Browser</a><br>
Demonstrates a file system browser built with Pivot.<br>
</p>
+
<p>
<a href="file_drag_drop.html">File Drag & Drop</a><br>
Demonstrates Pivot's support for drag and drop.<br>
</p>
+
<p>
<a href="table_row_editor.html">Table Row Editor</a><br>
Example of a table row editor that uses a "Family Feud"-like flip effect to
edit rows.<br>
</p>
+
<p>
<a href="animated_clock.html">Animated Clock</a><br>
Demonstrates Pivot's MovieView component, which is used to present a clock
constructed using Pivot's drawing API.<br>
</p>
+
<p>
<a href="large_data.html">Large Data Sets</a><br>
Demonstrates Pivot's ability to handle large data sets of up to 1,000,000
rows.<br>
</p>
+
<p>
<a href="rss_feed.html">RSS Feed</a><br>
Demonstrates how to build a simple RSS client in Pivot (requires Java 6
Update 10 or later).<br>
</p>
+
<p>
<a href="dom_interaction.html">DOM Interaction</a><br>
Demonstrates Pivot's support for bi-directional communication between a Pivot
application and the browser DOM.<br>
</p>
+
<p>
<a href="push_client.html">Push Client</a><br>
Shows how the Jabber instant-messaging protocol can be used to implement a
"push"-style application in Pivot.<br>
</p>
+
<p>
<a href="decorators.html">Decorators</a><br>
Demonstrates the use of "decorators" in Pivot. Decorators allow a developer to
@@ -79,10 +97,12 @@
image effects, etc. This example shows a window with a reflection decorator and
a frame with a fade decorator.<br>
</p>
+
<p>
<a href="fixed_column_table.html">Fixed Column Table</a><br>
Explains how to create a table with fixed columns in Pivot. Fixed columns are
handy when displaying tables with many columns.<br>
</p>
+
</body>
</html>
Added: incubator/pivot/trunk/demos/www/itunes_search.template.html
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/www/itunes_search.template.html?rev=786520&view=auto
==============================================================================
--- incubator/pivot/trunk/demos/www/itunes_search.template.html (added)
+++ incubator/pivot/trunk/demos/www/itunes_search.template.html Fri Jun 19 14:38:39 2009
@@ -0,0 +1,37 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you 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.
+-->
+
+<html>
+<head>
+<title>Pivot iTunes Search Demo</title>
+</head>
+<body>
+<p>Simple application that allows a user to run search queries against the
+iTunes Music Store and presents the results in a table view.</p>
+
+<script src="http://java.com/js/deployJava.js"></script>
+<script>
+var attributes = {code:"org.apache.pivot.wtk.BrowserApplicationContext$HostApplet",
+ archive:"lib/@project_name@-core-@version@.jar,lib/@project_name@-wtk-@version@.jar,lib/@project_name@-wtk-@version@.terra.jar,lib/@project_name@-demos-@version@.jar",
+ width:800, height:600};
+var parameters = {applicationClassName:"org.apache.pivot.demos.itunes.SearchDemo",
+ codebase_lookup:false};
+var version = "1.6";
+deployJava.runApplet(attributes, parameters, version);
+</script>
+</body>
+</html>
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java?rev=786520&r1=786519&r2=786520&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java Fri Jun 19 14:38:39 2009
@@ -43,6 +43,7 @@
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import java.util.Timer;
@@ -1241,6 +1242,15 @@
*
* @param location
*/
+ public static void open(String location) throws MalformedURLException {
+ open(new URL(location));
+ }
+
+ /**
+ * Opens the resource at the given location.
+ *
+ * @param location
+ */
public static void open(URL location) {
Desktop desktop = Desktop.getDesktop();
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Transition.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Transition.java?rev=786520&r1=786519&r2=786520&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Transition.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Transition.java Fri Jun 19 14:38:39 2009
@@ -28,7 +28,7 @@
public abstract class Transition {
private int duration;
private int rate;
- private boolean repeat;
+ private boolean repeating;
private boolean reversed = false;
@@ -44,7 +44,7 @@
long endTime = startTime + duration;
if (currentTime >= endTime) {
- if (repeat) {
+ if (repeating) {
startTime = endTime;
} else {
currentTime = endTime;
@@ -82,11 +82,11 @@
* @param rate
* Transition rate, in frames per second.
*
- * @param repeat
+ * @param repeating
* <tt>true</tt> if the transition should repeat; <tt>false</tt>, otherwise.
*/
- public Transition(int duration, int rate, boolean repeat) {
- this(duration, rate, repeat, false);
+ public Transition(int duration, int rate, boolean repeating) {
+ this(duration, rate, repeating, false);
}
/**
@@ -101,14 +101,14 @@
* @param repeat
* <tt>true</tt> if the transition should repeat; <tt>false</tt>, otherwise.
*/
- public Transition(int duration, int rate, boolean repeat, boolean reversed) {
+ public Transition(int duration, int rate, boolean repeating, boolean reversed) {
if (duration <= 0) {
throw new IllegalArgumentException("duration must be positive.");
}
this.duration = duration;
this.rate = rate;
- this.repeat = repeat;
+ this.repeating = repeating;
this.reversed = reversed;
}
@@ -322,6 +322,10 @@
*/
protected abstract void update();
+ public boolean isRepeating() {
+ return repeating;
+ }
+
/**
* Reverses the transition with no listener.
*
@@ -346,10 +350,6 @@
this.transitionListener = transitionListener;
- if (repeat) {
- throw new IllegalStateException("Transition is repeating.");
- }
-
long repeatDuration = currentTime - startTime;
long endTime = currentTime + repeatDuration;
startTime = endTime - duration;
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java?rev=786520&r1=786519&r2=786520&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java Fri Jun 19 14:38:39 2009
@@ -780,9 +780,9 @@
InvocationHandler handler = new InvocationHandler() {
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
- Object result;
- String methodName = method.getName();
+ Object result = null;
+ String methodName = method.getName();
Bindings bindings = scriptEngine.getBindings(ScriptContext.ENGINE_SCOPE);
if (bindings.containsKey(methodName)) {
Invocable invocable;
@@ -793,16 +793,16 @@
}
result = invocable.invokeFunction(methodName, args);
- } else {
- Class<?> returnType = method.getReturnType();
+ }
- if (returnType == Vote.class) {
- result = Vote.APPROVE;
- } else if (returnType == Boolean.TYPE) {
- result = false;
- } else {
- result = null;
- }
+ // If the function didn't return a value, return the default
+ Class<?> returnType = method.getReturnType();
+ if (returnType == Vote.class
+ && result == null) {
+ result = Vote.APPROVE;
+ } else if (returnType == Boolean.TYPE
+ && result == null) {
+ result = false;
}
return result;