You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by sm...@apache.org on 2011/03/22 01:23:46 UTC
svn commit: r1084040 - in
/pivot/trunk/tests/src/org/apache/pivot/tests/issues: Pivot718.java
pivot_718.bxml
Author: smartini
Date: Tue Mar 22 00:23:46 2011
New Revision: 1084040
URL: http://svn.apache.org/viewvc?rev=1084040&view=rev
Log:
PIVOT-718, test case
Added:
pivot/trunk/tests/src/org/apache/pivot/tests/issues/Pivot718.java
pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot_718.bxml
Added: pivot/trunk/tests/src/org/apache/pivot/tests/issues/Pivot718.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/issues/Pivot718.java?rev=1084040&view=auto
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/issues/Pivot718.java (added)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/issues/Pivot718.java Tue Mar 22 00:23:46 2011
@@ -0,0 +1,148 @@
+/*
+ * 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.
+ */
+package org.apache.pivot.tests.issues;
+
+import org.apache.pivot.beans.BXMLSerializer;
+import org.apache.pivot.collections.List;
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.collections.Sequence;
+import org.apache.pivot.collections.Sequence.Tree.Path;
+import org.apache.pivot.wtk.Application;
+import org.apache.pivot.wtk.Button;
+import org.apache.pivot.wtk.ButtonPressListener;
+import org.apache.pivot.wtk.DesktopApplicationContext;
+import org.apache.pivot.wtk.Display;
+import org.apache.pivot.wtk.ListView;
+import org.apache.pivot.wtk.ListViewSelectionListener;
+import org.apache.pivot.wtk.PushButton;
+import org.apache.pivot.wtk.Span;
+import org.apache.pivot.wtk.TreeView;
+import org.apache.pivot.wtk.TreeViewSelectionListener;
+import org.apache.pivot.wtk.Window;
+
+public class Pivot718 implements Application {
+
+ private Window window = null;
+ private TreeView tree;
+ private PushButton treeDelButton;
+ private ListView list;
+ private PushButton listDelButton;
+
+ public Pivot718() {
+
+ }
+
+ @Override
+ public void startup(Display display, Map<String, String> properties) throws Exception {
+ BXMLSerializer bxmlSerializer = new BXMLSerializer();
+ window = (Window) bxmlSerializer.readObject(Pivot718.class, "pivot_718.bxml");
+
+ controlTree(bxmlSerializer);
+ controlList(bxmlSerializer);
+
+ window.open(display);
+ }
+
+ private void controlList(BXMLSerializer bxmlSerializer) {
+ listDelButton = (PushButton) bxmlSerializer.getNamespace().get("listDelButton");
+ list = (ListView) bxmlSerializer.getNamespace().get("list");
+ list.getListViewSelectionListeners().add(new ListViewSelectionListener() {
+
+ public void selectedRangeAdded(ListView listView, int rangeStart, int rangeEnd) {
+ System.out.println("selectedRangeAdded");
+ }
+
+ public void selectedRangeRemoved(ListView listView, int rangeStart, int rangeEnd) {
+ System.out.println("selectedRangeRemoved");
+ }
+
+ public void selectedRangesChanged(ListView listView,
+ Sequence<Span> previousSelectedRanges) {
+ System.out.println("selectedRangesChanged");
+ }
+
+ public void selectedItemChanged(ListView listView, Object previousSelectedItem) {
+ System.out.println("selectedItemChanged :::" + listView.getSelectedItem());
+ }
+ });
+ listDelButton.getButtonPressListeners().add(new ButtonPressListener() {
+
+ @SuppressWarnings("unchecked")
+ public void buttonPressed(Button button) {
+ Object x = list.getSelectedItem();
+ System.out.println("delete :: " + x);
+ List data = list.getListData();
+ data.remove(x);
+ }
+ });
+ }
+
+ private void controlTree(BXMLSerializer bxmlSerializer) {
+ treeDelButton = (PushButton) bxmlSerializer.getNamespace().get("treeDelButton");
+ tree = (TreeView) bxmlSerializer.getNamespace().get("tree");
+ tree.getTreeViewSelectionListeners().add(new TreeViewSelectionListener() {
+
+ public void selectedPathAdded(TreeView treeView, Path path) {
+ System.out.println("selectedPathAdded");
+ }
+
+ public void selectedPathRemoved(TreeView treeView, Path path) {
+ System.out.println("selectedPathRemoved");
+ }
+
+ public void selectedPathsChanged(TreeView treeView, Sequence<Path> previousSelectedPaths) {
+ System.out.println("selectedPathsChanged");
+ }
+
+ public void selectedNodeChanged(TreeView treeView, Object previousSelectedNode) {
+ System.out.println("selectedNodeChanged");
+ }
+ });
+ treeDelButton.getButtonPressListeners().add(new ButtonPressListener() {
+
+ @SuppressWarnings("unchecked")
+ public void buttonPressed(Button button) {
+ Object x = tree.getSelectedNode();
+ System.out.println("delete :: " + x);
+ List data = tree.getTreeData();
+ data.remove(x);
+ }
+ });
+ }
+
+ @Override
+ public boolean shutdown(boolean optional) {
+ if (window != null) {
+ window.close();
+ }
+
+ return false;
+ }
+
+ @Override
+ public void suspend() {
+ }
+
+ @Override
+ public void resume() {
+ }
+
+ public static void main(String[] args) {
+ DesktopApplicationContext.main(Pivot718.class, args);
+ }
+
+}
Added: pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot_718.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot_718.bxml?rev=1084040&view=auto
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot_718.bxml (added)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot_718.bxml Tue Mar 22 00:23:46 2011
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+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.
+-->
+
+<Window title="Tree Views" maximized="true"
+ xmlns:bxml="http://pivot.apache.org/bxml"
+ xmlns:app="org.apache.pivot.tests.issues"
+ xmlns:content="org.apache.pivot.wtk.content"
+ xmlns="org.apache.pivot.wtk"
+>
+ <Border>
+
+ <BoxPane orientation="horizontal">
+ <BoxPane orientation="vertical">
+ <PushButton bxml:id="treeDelButton" buttonData="delete"/>
+ <ScrollPane horizontalScrollBarPolicy="fill_to_capacity">
+ <TreeView bxml:id="tree" >
+ <treeData>
+ <content:TreeBranch >
+ <content:TreeBranch text="Activity">
+ <content:TreeNode text="Camping" />
+ <content:TreeNode text="Skiing" />
+ </content:TreeBranch>
+ <content:TreeBranch text="Occasion">
+ <content:TreeBranch text="Holidays">
+ <content:TreeNode text="Christmas" />
+ <content:TreeNode text="Independence Day" />
+ <content:TreeNode text="Labor Day" />
+ <content:TreeNode text="New Year's Day" />
+ <content:TreeNode text="President's Day" />
+ <content:TreeNode text="Thanksgiving" />
+ <content:TreeNode text="Valentine's Day" />
+ <content:TreeNode text="Veteran's Day" />
+ </content:TreeBranch>
+ <content:TreeNode text="Anniversary" />
+ <content:TreeNode text="Birthday" />
+ <content:TreeNode text="Wedding" />
+ </content:TreeBranch>
+ <content:TreeBranch text="Sports" >
+ <content:TreeNode text="Baseball" />
+ <content:TreeNode text="Basketball" />
+ <content:TreeNode text="Football" />
+ <content:TreeNode text="Ice Hockey" />
+ <content:TreeNode text="Soccer" />
+ <content:TreeNode text="Softball" />
+ </content:TreeBranch>
+ <content:TreeBranch text="Games">
+ <content:TreeNode text="Foosball" />
+ <content:TreeNode text="Ping Pong" />
+ <content:TreeNode text="Air Hockey" />
+ </content:TreeBranch>
+ </content:TreeBranch>
+ </treeData>
+
+ </TreeView>
+ </ScrollPane>
+ </BoxPane>
+ </BoxPane>
+
+ <BoxPane orientation="vertical">
+ <PushButton bxml:id="listDelButton" buttonData="delete"/>
+ <ScrollPane horizontalScrollBarPolicy="fill_to_capacity">
+ <ListView bxml:id="list" listData="['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten']"/>
+ </ScrollPane>
+ </BoxPane>
+
+ </Border>
+
+</Window>