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 2010/08/08 18:55:34 UTC

svn commit: r983448 - in /pivot/trunk: core/src/org/apache/pivot/beans/ tests/src/org/apache/pivot/tests/ wtk/src/org/apache/pivot/wtk/

Author: gbrown
Date: Sun Aug  8 16:55:33 2010
New Revision: 983448

URL: http://svn.apache.org/viewvc?rev=983448&view=rev
Log:
Update Accordion, CardPane, and TabPane for PIVOT-548.

Modified:
    pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java
    pivot/trunk/tests/src/org/apache/pivot/tests/panorama_test.bxml
    pivot/trunk/wtk/src/org/apache/pivot/wtk/Accordion.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/CardPane.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPane.java

Modified: pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java?rev=983448&r1=983447&r2=983448&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java Sun Aug  8 16:55:33 2010
@@ -649,7 +649,14 @@ public class BXMLSerializer implements S
                     BeanAdapter beanAdapter = new BeanAdapter(element.value);
 
                     if (beanAdapter.isReadOnly(localName)) {
-                        if (ListenerList.class.isAssignableFrom(beanAdapter.getType(localName))) {
+                        Class<?> propertyType = beanAdapter.getType(localName);
+                        if (propertyType == null) {
+                            throw new SerializationException("\"" + localName
+                                + "\" is not a valid property of element "
+                                + element.name + ".");
+                        }
+
+                        if (ListenerList.class.isAssignableFrom(propertyType)) {
                             elementType = Element.Type.LISTENER_LIST_PROPERTY;
                         } else {
                             elementType = Element.Type.READ_ONLY_PROPERTY;

Modified: pivot/trunk/tests/src/org/apache/pivot/tests/panorama_test.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/panorama_test.bxml?rev=983448&r1=983447&r2=983448&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/panorama_test.bxml (original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/panorama_test.bxml Sun Aug  8 16:55:33 2010
@@ -19,6 +19,12 @@ limitations under the License.
 <TabPane closeable="true" selectedIndex="0"
     xmlns:bxml="http://pivot.apache.org/bxml"
     xmlns="org.apache.pivot.wtk">
+    <tabPaneSelectionListeners>
+    function selectedIndexChanged(tabPane, previousSelectedIndex) {
+        java.lang.System.out.println(tabPane.selectedIndex + ", " + previousSelectedIndex);
+    }
+    </tabPaneSelectionListeners>
+
     <Label TabPane.tabData="Tab 1" TabPane.tooltipText="Tooltip 1" preferredWidth="320" preferredHeight="240" text="Tab 1"/>
     <Label TabPane.tabData="Tab 2" TabPane.tooltipText="Tooltip 2" preferredWidth="320" preferredHeight="240" text="Tab 2"/>
     <Label TabPane.tabData="Tab 3" preferredWidth="320" preferredHeight="240" text="Tab 3"/>

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Accordion.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Accordion.java?rev=983448&r1=983447&r2=983448&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Accordion.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Accordion.java Sun Aug  8 16:55:33 2010
@@ -58,11 +58,19 @@ public class Accordion extends Container
             panels.insert(panel, index);
 
             // Update the selection
+            int previousSelectedIndex = selectedIndex;
+
             if (selectedIndex >= index) {
                 selectedIndex++;
             }
 
+            // Fire insert event
             accordionListeners.panelInserted(Accordion.this, index);
+
+            // Fire selection change event, if necessary
+            if (selectedIndex != previousSelectedIndex) {
+                accordionSelectionListeners.selectedIndexChanged(Accordion.this, selectedIndex);
+            }
         }
 
         @Override
@@ -86,6 +94,8 @@ public class Accordion extends Container
             Sequence<Component> removed = panels.remove(index, count);
 
             // Update the selection
+            int previousSelectedIndex = selectedIndex;
+
             if (selectedIndex >= index) {
                 if (selectedIndex < index + count) {
                     selectedIndex = -1;
@@ -94,6 +104,7 @@ public class Accordion extends Container
                 }
             }
 
+            // Fire remove event
             accordionListeners.panelsRemoved(Accordion.this, index, removed);
 
             // Remove the panels from the component list
@@ -102,6 +113,11 @@ public class Accordion extends Container
                 Accordion.this.remove(panel);
             }
 
+            // Fire selection change event, if necessary
+            if (selectedIndex != previousSelectedIndex) {
+                accordionSelectionListeners.selectedIndexChanged(Accordion.this, selectedIndex);
+            }
+
             return removed;
         }
 

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/CardPane.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/CardPane.java?rev=983448&r1=983447&r2=983448&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/CardPane.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/CardPane.java Sun Aug  8 16:55:33 2010
@@ -104,16 +104,26 @@ public class CardPane extends Container 
     @Override
     public void insert(Component component, int index) {
         // Update the selection
+        int previousSelectedIndex = selectedIndex;
+
         if (selectedIndex >= index) {
             selectedIndex++;
         }
 
+        // Insert the component
         super.insert(component, index);
+
+        // Fire selection change event, if necessary
+        if (selectedIndex != previousSelectedIndex) {
+            cardPaneListeners.selectedIndexChanged(this, selectedIndex);
+        }
     }
 
     @Override
     public Sequence<Component> remove(int index, int count) {
         // Update the selection
+        int previousSelectedIndex = selectedIndex;
+
         if (selectedIndex >= index) {
             if (selectedIndex < index + count) {
                 selectedIndex = -1;
@@ -122,7 +132,15 @@ public class CardPane extends Container 
             }
         }
 
-        return super.remove(index, count);
+        // Remove the components
+        Sequence<Component> removed = super.remove(index, count);
+
+        // Fire selection change event, if necessary
+        if (selectedIndex != previousSelectedIndex) {
+            cardPaneListeners.selectedIndexChanged(this, selectedIndex);
+        }
+
+        return removed;
     }
 
     public ListenerList<CardPaneListener> getCardPaneListeners() {

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPane.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPane.java?rev=983448&r1=983447&r2=983448&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPane.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPane.java Sun Aug  8 16:55:33 2010
@@ -58,11 +58,19 @@ public class TabPane extends Container {
             tabs.insert(tab, index);
 
             // Update the selection
+            int previousSelectedIndex = selectedIndex;
+
             if (selectedIndex >= index) {
                 selectedIndex++;
             }
 
+            // Fire insert event
             tabPaneListeners.tabInserted(TabPane.this, index);
+
+            // Fire selection change event, if necessary
+            if (selectedIndex != previousSelectedIndex) {
+                tabPaneSelectionListeners.selectedIndexChanged(TabPane.this, selectedIndex);
+            }
         }
 
         @Override
@@ -90,6 +98,8 @@ public class TabPane extends Container {
                 removed = tabs.remove(index, count);
 
                 // Update the selection
+                int previousSelectedIndex = selectedIndex;
+
                 if (selectedIndex >= index) {
                     if (selectedIndex < index + count) {
                         selectedIndex = -1;
@@ -98,6 +108,7 @@ public class TabPane extends Container {
                     }
                 }
 
+                // Fire remove event
                 tabPaneListeners.tabsRemoved(TabPane.this, index, removed);
 
                 // Remove the tabs from the component list
@@ -105,6 +116,11 @@ public class TabPane extends Container {
                     Component tab = removed.get(i);
                     TabPane.this.remove(tab);
                 }
+
+                // Fire selection change event, if necessary
+                if (selectedIndex != previousSelectedIndex) {
+                    tabPaneSelectionListeners.selectedIndexChanged(TabPane.this, selectedIndex);
+                }
             } else {
                 removed = null;
                 tabPaneListeners.removeTabsVetoed(TabPane.this, vote);