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/09/29 17:34:04 UTC
svn commit: r819986 - in /incubator/pivot/trunk:
tutorials/src/org/apache/pivot/tutorials/clipboard/clipboard.wtkx
wtk/src/org/apache/pivot/wtk/Button.java
wtk/src/org/apache/pivot/wtk/LocalManifest.java
wtk/src/org/apache/pivot/wtk/RemoteManifest.java
Author: gbrown
Date: Tue Sep 29 15:34:03 2009
New Revision: 819986
URL: http://svn.apache.org/viewvc?rev=819986&view=rev
Log:
Update clipboard tutorial.
Modified:
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/clipboard/clipboard.wtkx
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Button.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/LocalManifest.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/RemoteManifest.java
Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/clipboard/clipboard.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/clipboard/clipboard.wtkx?rev=819986&r1=819985&r2=819986&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/clipboard/clipboard.wtkx (original)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/clipboard/clipboard.wtkx Tue Sep 29 15:34:03 2009
@@ -19,8 +19,48 @@
<Window title="Clipboard" maximized="true"
xmlns:wtkx="http://pivot.apache.org/wtkx"
xmlns="org.apache.pivot.wtk">
+ <wtkx:script>
+ importPackage(org.apache.pivot.wtk);
+
+ function copy() {
+ // Copy the selected image to the clipboard
+ var selectedSourceIndex = sourceImageCardPane.getSelectedIndex();
+ var sourceImageView = sourceImageCardPane.get(selectedSourceIndex);
+ var sourceImage = sourceImageView.getImage();
+
+ var content = new LocalManifest();
+ content.putImage(sourceImage);
+
+ Clipboard.setContent(content);
+ }
+
+ function paste() {
+ // Paste any available image from the clipboard
+ var content = Clipboard.getContent();
+
+ if (content != null) {
+ var image = content.getImage();
+
+ if (image != null) {
+ destinationImageView.setImage(image);
+ }
+ }
+ }
+ </wtkx:script>
+
+ <windowStateListeners>
+ <wtkx:script>
+ <![CDATA[
+ function windowOpened(window) {
+ sourceImageButtonGroup.setSelection(sourceImageButton1);
+ sourceImageButton1.requestFocus();
+ }
+ ]]>
+ </wtkx:script>
+ </windowStateListeners>
+
<content>
- <TablePane styles="{horizontalSpacing:2}">
+ <TablePane styles="{horizontalSpacing:4, verticalSpacing:4}">
<columns>
<TablePane.Column width="1*"/>
<TablePane.Column width="1*"/>
@@ -29,85 +69,67 @@
<TablePane.Row height="1*">
<Border>
<content>
- <TablePane>
- <columns>
- <TablePane.Column width="1*"/>
- </columns>
- <rows>
- <TablePane.Row height="1*">
- <CardPane wtkx:id="copyImageCardPane" styles="{padding:4}">
- <ImageView image="org/apache/pivot/tutorials/IMG_0725_2.jpg"/>
- <ImageView image="org/apache/pivot/tutorials/IMG_0735_2.jpg"/>
- <ImageView image="org/apache/pivot/tutorials/IMG_0767_2.jpg"/>
- </CardPane>
- </TablePane.Row>
- <TablePane.Row height="-1">
- <BoxPane orientation="vertical" styles="{fill:true}">
- <BoxPane wtkx:id="copyImageButtonBoxPane"
- styles="{horizontalAlignment:'center'}">
- <wtkx:define>
- <ButtonGroup wtkx:id="copyImageButtonGroup">
- <buttonGroupListeners>
- <wtkx:script>
- <![CDATA[
- function selectionChanged(buttonGroup, previousSelection) {
- var selection = buttonGroup.getSelection();
- if (selection != null) {
- var index = copyImageButtonBoxPane.indexOf(selection);
- copyImageCardPane.setSelectedIndex(index);
- }
- }
- ]]>
- </wtkx:script>
- </buttonGroupListeners>
- </ButtonGroup>
- </wtkx:define>
-
- <PushButton buttonData="IMG_0725_2.jpg" toggleButton="true"
- buttonGroup="$copyImageButtonGroup"/>
- <PushButton buttonData="IMG_0735_2.jpg" toggleButton="true"
- buttonGroup="$copyImageButtonGroup"/>
- <PushButton buttonData="IMG_0767_2.jpg" toggleButton="true"
- buttonGroup="$copyImageButtonGroup"/>
- </BoxPane>
-
- <wtkx:script>
- <![CDATA[
- copyImageButtonGroup.setSelection(copyImageButtonBoxPane.get(0));
- ]]>
- </wtkx:script>
-
- <BoxPane styles="{horizontalAlignment:'center'}">
- <PushButton wtkx:id="copyButton" buttonData="Copy"/>
- </BoxPane>
- </BoxPane>
- </TablePane.Row>
- </rows>
- </TablePane>
+ <CardPane wtkx:id="sourceImageCardPane" styles="{padding:4}">
+ <ImageView image="org/apache/pivot/tutorials/IMG_0725_2.jpg"/>
+ <ImageView image="org/apache/pivot/tutorials/IMG_0735_2.jpg"/>
+ <ImageView image="org/apache/pivot/tutorials/IMG_0767_2.jpg"/>
+ </CardPane>
</content>
</Border>
<Border>
<content>
- <TablePane>
- <columns>
- <TablePane.Column width="1*"/>
- </columns>
- <rows>
- <TablePane.Row height="1*">
- <BoxPane styles="{padding:4}">
- <ImageView wtkx:id="pasteImageView"/>
- </BoxPane>
- </TablePane.Row>
- <TablePane.Row height="-1">
- <BoxPane styles="{horizontalAlignment:'center'}">
- <PushButton wtkx:id="pasteButton" buttonData="Paste"/>
- </BoxPane>
- </TablePane.Row>
- </rows>
- </TablePane>
+ <CardPane selectedIndex="0" styles="{padding:4}">
+ <ImageView wtkx:id="destinationImageView"/>
+ </CardPane>
</content>
</Border>
</TablePane.Row>
+
+ <TablePane.Row height="-1">
+ <BoxPane orientation="vertical" styles="{fill:true}">
+ <BoxPane wtkx:id="sourceImageButtonBoxPane"
+ styles="{horizontalAlignment:'center', verticalAlignment:'center'}">
+ <wtkx:define>
+ <ButtonGroup wtkx:id="sourceImageButtonGroup">
+ <buttonGroupListeners>
+ <wtkx:script>
+ <![CDATA[
+ function selectionChanged(buttonGroup, previousSelection) {
+ var selection = buttonGroup.getSelection();
+
+ if (selection != null) {
+ var index = sourceImageButtonBoxPane.indexOf(selection);
+ sourceImageCardPane.setSelectedIndex(index);
+ }
+ }
+ ]]>
+ </wtkx:script>
+ </buttonGroupListeners>
+ </ButtonGroup>
+ </wtkx:define>
+
+ <PushButton wtkx:id="sourceImageButton1"
+ buttonData="IMG_0725_2.jpg" toggleButton="true"
+ buttonGroup="$sourceImageButtonGroup"/>
+ <PushButton wtkx:id="sourceImageButton2"
+ buttonData="IMG_0735_2.jpg" toggleButton="true"
+ buttonGroup="$sourceImageButtonGroup"/>
+ <PushButton wtkx:id="sourceImageButton3"
+ buttonData="IMG_0767_2.jpg" toggleButton="true"
+ buttonGroup="$sourceImageButtonGroup"/>
+ </BoxPane>
+
+ <BoxPane styles="{horizontalAlignment:'center'}">
+ <PushButton wtkx:id="copyButton" buttonData="Copy"
+ ButtonPressListener.buttonPressed="copy()"/>
+ </BoxPane>
+ </BoxPane>
+
+ <BoxPane styles="{horizontalAlignment:'center', verticalAlignment:'center'}">
+ <PushButton wtkx:id="pasteButton" buttonData="Paste"
+ ButtonPressListener.buttonPressed="paste()"/>
+ </BoxPane>
+ </TablePane.Row>
</rows>
</TablePane>
</content>
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Button.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Button.java?rev=819986&r1=819985&r2=819986&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Button.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Button.java Tue Sep 29 15:34:03 2009
@@ -513,9 +513,4 @@
public ListenerList<ButtonPressListener> getButtonPressListeners() {
return buttonPressListeners;
}
-
- @Override
- public String toString() {
- return getClass().getName() + ": " + buttonData;
- }
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/LocalManifest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/LocalManifest.java?rev=819986&r1=819985&r2=819986&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/LocalManifest.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/LocalManifest.java Tue Sep 29 15:34:03 2009
@@ -33,11 +33,11 @@
* operation.
*/
public class LocalManifest implements Manifest {
- protected String text = null;
- protected Image image = null;
- protected FileList fileList = null;
- protected URL url = null;
- protected HashMap<String, Object> values = new HashMap<String, Object>();
+ private String text = null;
+ private Image image = null;
+ private FileList fileList = null;
+ private URL url = null;
+ private HashMap<String, Object> values = new HashMap<String, Object>();
@Override
public String getText() {
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/RemoteManifest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/RemoteManifest.java?rev=819986&r1=819985&r2=819986&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/RemoteManifest.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/RemoteManifest.java Tue Sep 29 15:34:03 2009
@@ -74,7 +74,7 @@
try {
text = (String)transferable.getTransferData(textDataFlavor);
} catch(UnsupportedFlavorException exception) {
- exception.printStackTrace(System.err);
+ // No-op
}
return text;
@@ -91,7 +91,7 @@
try {
image = new Picture((BufferedImage)transferable.getTransferData(imageDataFlavor));
} catch(UnsupportedFlavorException exception) {
- exception.printStackTrace(System.err);
+ // No-op
}
return image;
@@ -109,7 +109,7 @@
try {
fileList = new FileList((java.util.List<File>)transferable.getTransferData(fileListDataFlavor));
} catch(UnsupportedFlavorException exception) {
- exception.printStackTrace(System.err);
+ // No-op
}
return fileList;
@@ -126,7 +126,7 @@
try {
url = (URL)transferable.getTransferData(urlDataFlavor);
} catch(UnsupportedFlavorException exception) {
- exception.printStackTrace(System.err);
+ // No-op
}
return url;