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/08/07 19:36:38 UTC
svn commit: r802099 - in /incubator/pivot/trunk/wtk:
src/org/apache/pivot/wtk/skin/terra/ test/org/apache/pivot/wtk/test/
Author: gbrown
Date: Fri Aug 7 17:36:38 2009
New Revision: 802099
URL: http://svn.apache.org/viewvc?rev=802099&view=rev
Log:
Frame out file browser sheet UI.
Modified:
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.json
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/terra_file_browser_sheet_skin.wtkx
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/terra_file_browser_skin.wtkx
incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/FileBrowserTest.java
incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/file_browser_test.wtkx
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.java?rev=802099&r1=802098&r2=802099&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.java Fri Aug 7 17:36:38 2009
@@ -17,13 +17,20 @@
package org.apache.pivot.wtk.skin.terra;
import java.io.File;
+import java.io.IOException;
import org.apache.pivot.collections.Sequence;
import org.apache.pivot.io.Folder;
+import org.apache.pivot.serialization.SerializationException;
import org.apache.pivot.util.Filter;
+import org.apache.pivot.util.Resources;
+import org.apache.pivot.wtk.Button;
+import org.apache.pivot.wtk.ButtonPressListener;
import org.apache.pivot.wtk.Component;
import org.apache.pivot.wtk.FileBrowserSheet;
import org.apache.pivot.wtk.FileBrowserSheetListener;
+import org.apache.pivot.wtk.PushButton;
+import org.apache.pivot.wtkx.WTKXSerializer;
/**
* Terra file browser sheet skin.
@@ -31,23 +38,61 @@
* @author gbrown
*/
public class TerraFileBrowserSheetSkin extends TerraSheetSkin implements FileBrowserSheetListener {
+ private PushButton okButton = null;
+ private PushButton cancelButton = null;
+
@Override
public void install(Component component) {
super.install(component);
- FileBrowserSheet fileBrowserSheet = (FileBrowserSheet)component;
- fileBrowserSheet.getFileBrowserSheetListeners().add(this);
+ final FileBrowserSheet fileBrowserSheet = (FileBrowserSheet)component;
- // TODO Set content component
+ Resources resources;
+ try {
+ resources = new Resources(this);
+ } catch (IOException exception) {
+ throw new RuntimeException(exception);
+ } catch (SerializationException exception) {
+ throw new RuntimeException(exception);
+ }
+
+ WTKXSerializer wtkxSerializer = new WTKXSerializer(resources);
+
+ Component content;
+ try {
+ content = (Component)wtkxSerializer.readObject(this, "terra_file_browser_sheet_skin.wtkx");
+ } catch (IOException exception) {
+ throw new RuntimeException(exception);
+ } catch (SerializationException exception) {
+ throw new RuntimeException(exception);
+ }
+
+ fileBrowserSheet.setContent(content);
+
+ okButton = (PushButton)wtkxSerializer.get("okButton");
+ okButton.getButtonPressListeners().add(new ButtonPressListener() {
+ public void buttonPressed(Button button) {
+ fileBrowserSheet.close(true);
+ }
+ });
+
+ cancelButton = (PushButton)wtkxSerializer.get("cancelButton");
+ cancelButton.getButtonPressListeners().add(new ButtonPressListener() {
+ public void buttonPressed(Button button) {
+ fileBrowserSheet.close(false);
+ }
+ });
+
+ fileBrowserSheet.getFileBrowserSheetListeners().add(this);
}
@Override
public void uninstall() {
FileBrowserSheet fileBrowserSheet = (FileBrowserSheet)getComponent();
- fileBrowserSheet.getFileBrowserSheetListeners().remove(this);
-
fileBrowserSheet.setContent(null);
+ fileBrowserSheet.getFileBrowserSheetListeners().remove(this);
+
super.uninstall();
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.json
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.json?rev=802099&r1=802098&r2=802099&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.json (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSheetSkin.json Fri Aug 7 17:36:38 2009
@@ -1,6 +1,7 @@
{ openFile: "Open File",
openFiles: "Open Files",
saveFile: "Save File",
+ saveAs: "Save as:",
saveTo: "Save To",
ok: "OK",
cancel: "Cancel"
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java?rev=802099&r1=802098&r2=802099&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFileBrowserSkin.java Fri Aug 7 17:36:38 2009
@@ -25,6 +25,7 @@
import org.apache.pivot.util.Filter;
import org.apache.pivot.util.Resources;
import org.apache.pivot.wtk.Component;
+import org.apache.pivot.wtk.Dimensions;
import org.apache.pivot.wtk.FileBrowser;
import org.apache.pivot.wtk.skin.FileBrowserSkin;
import org.apache.pivot.wtkx.WTKXSerializer;
@@ -75,10 +76,26 @@
}
@Override
+ public int getPreferredWidth(int height) {
+ return content.getPreferredWidth(height);
+ }
+
+ @Override
+ public int getPreferredHeight(int width) {
+ return content.getPreferredHeight(width);
+ }
+
+ @Override
+ public Dimensions getPreferredSize() {
+ return content.getPreferredSize();
+ }
+
+ @Override
public void layout() {
int width = getWidth();
int height = getHeight();
+ content.setLocation(0, 0);
content.setSize(width, height);
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/terra_file_browser_sheet_skin.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/terra_file_browser_sheet_skin.wtkx?rev=802099&r1=802098&r2=802099&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/terra_file_browser_sheet_skin.wtkx (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/terra_file_browser_sheet_skin.wtkx Fri Aug 7 17:36:38 2009
@@ -16,17 +16,39 @@
limitations under the License.
-->
-<TablePane xmlns:wtkx="http://pivot.apache.org/wtkx"
+<BoxPane styles="{verticalAlignment:'bottom'}"
+ xmlns:wtkx="http://pivot.apache.org/wtkx"
xmlns="org.apache.pivot.wtk">
- <columns>
- <TablePane.Column width="1*"/>
- </columns>
- <rows>
- <TablePane.Row height="-1">
- </TablePane.Row>
- <TablePane.Row height="1*">
- </TablePane.Row>
- <TablePane.Row height="-1">
- </TablePane.Row>
- </rows>
-</TablePane>
+ <Border styles="{padding:10}">
+ <content>
+ <TablePane styles="{verticalSpacing:8}">
+ <columns>
+ <TablePane.Column width="1*"/>
+ </columns>
+ <rows>
+ <TablePane.Row height="-1">
+ <BoxPane styles="{verticalAlignment:'center'}">
+ <Label text="%saveAs"/>
+ <TextInput wtkx:id="saveAsTextInput"/>
+ </BoxPane>
+ </TablePane.Row>
+ <TablePane.Row>
+ <Separator styles="{padding:2}"/>
+ </TablePane.Row>
+ <TablePane.Row height="1*">
+ <FileBrowser wtkx:id="fileBrowser"
+ preferredWidth="420" preferredHeight="220"/>
+ </TablePane.Row>
+ <TablePane.Row height="-1">
+ <BoxPane styles="{horizontalAlignment:'right', verticalAlignment:'center'}">
+ <PushButton wtkx:id="okButton" buttonData="%ok"
+ styles="{minimumPreferredAspectRatio:3}"/>
+ <PushButton wtkx:id="cancelButton" buttonData="%cancel"
+ styles="{minimumPreferredAspectRatio:3}"/>
+ </BoxPane>
+ </TablePane.Row>
+ </rows>
+ </TablePane>
+ </content>
+ </Border>
+</BoxPane>
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/terra_file_browser_skin.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/terra_file_browser_skin.wtkx?rev=802099&r1=802098&r2=802099&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/terra_file_browser_skin.wtkx (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/terra_file_browser_skin.wtkx Fri Aug 7 17:36:38 2009
@@ -16,7 +16,7 @@
limitations under the License.
-->
-<TablePane styles="{verticalSpacing:6, showHorizontalGridLines:true}"
+<TablePane styles="{verticalSpacing:6}"
xmlns:wtkx="http://pivot.apache.org/wtkx"
xmlns:collections="org.apache.pivot.collections"
xmlns:content="org.apache.pivot.wtk.content"
Modified: incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/FileBrowserTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/FileBrowserTest.java?rev=802099&r1=802098&r2=802099&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/FileBrowserTest.java (original)
+++ incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/FileBrowserTest.java Fri Aug 7 17:36:38 2009
@@ -20,6 +20,7 @@
import org.apache.pivot.wtk.Application;
import org.apache.pivot.wtk.DesktopApplicationContext;
import org.apache.pivot.wtk.Display;
+import org.apache.pivot.wtk.FileBrowserSheet;
import org.apache.pivot.wtk.Frame;
import org.apache.pivot.wtkx.WTKXSerializer;
@@ -29,6 +30,10 @@
public void startup(Display display, Map<String, String> properties)
throws Exception {
WTKXSerializer wtkxSerializer = new WTKXSerializer();
+
+ FileBrowserSheet fileOpenSheet = new FileBrowserSheet(FileBrowserSheet.Mode.OPEN);
+ wtkxSerializer.put("fileOpenSheet", fileOpenSheet);
+
frame = (Frame)wtkxSerializer.readObject(getClass().getResource("file_browser_test.wtkx"));
frame.open(display);
}
Modified: incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/file_browser_test.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/file_browser_test.wtkx?rev=802099&r1=802098&r2=802099&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/file_browser_test.wtkx (original)
+++ incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/file_browser_test.wtkx Fri Aug 7 17:36:38 2009
@@ -16,14 +16,24 @@
limitations under the License.
-->
-<Frame title="File Browser Test" icon="@applications-games.png"
- preferredWidth="480" preferredHeight="360"
+<Frame wtkx:id="frame" title="File Browser Test" icon="@applications-games.png"
+ preferredWidth="640" preferredHeight="480"
xmlns:wtkx="http://pivot.apache.org/wtkx"
xmlns="org.apache.pivot.wtk">
<content>
<Border>
<content>
- <FileBrowser/>
+ <BoxPane styles="{horizontalAlignment:'center', verticalAlignment:'center'}">
+ <PushButton buttonData="Open">
+ <buttonPressListeners>
+ <wtkx:script>
+ function buttonPressed(button) {
+ fileOpenSheet.open(frame);
+ }
+ </wtkx:script>
+ </buttonPressListeners>
+ </PushButton>
+ </BoxPane>
</content>
</Border>
</content>