Author: noelgrandin
Date: Wed May 5 12:14:13 2010
New Revision: 941264
URL: http://svn.apache.org/viewvc?rev=941264&view=rev
Log:
PIVOT-419 Add Ability to Add tooltipText for Tabs in a TabPane.
Modified:
pivot/trunk/ (props changed)
pivot/trunk/tests/src/org/apache/pivot/tests/panorama_test.wtkx
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPane.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPaneAttributeListener.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TablePaneSkin.java
Propchange: pivot/trunk/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed May 5 12:14:13 2010
@@ -0,0 +1,6 @@
+.settings
+.classpath
+.project
+container-child-access.6aug.patch
+bin
+noel
Modified: pivot/trunk/tests/src/org/apache/pivot/tests/panorama_test.wtkx
URL:
http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/panorama_test.wtkx?rev=941264&r1=941263&r2=941264&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/panorama_test.wtkx (original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/panorama_test.wtkx Wed May 5
12:14:13 2010
@@ -20,7 +20,7 @@ limitations under the License.
xmlns:wtkx="http://pivot.apache.org/wtkx"
xmlns="org.apache.pivot.wtk">
<tabs>
- <Label TabPane.label="Tab 1" preferredWidth="320"
preferredHeight="240" text="Tab 1"/>
+ <Label TabPane.tooltipText="Tooltip1" TabPane.label="Tab 1"
preferredWidth="320" preferredHeight="240" text="Tab 1"/>
<Label TabPane.label="Tab 2" preferredWidth="320"
preferredHeight="240" text="Tab 2"/>
<Label TabPane.label="Tab 3" preferredWidth="320"
preferredHeight="240" text="Tab 3"/>
<Label TabPane.label="Tab 4" preferredWidth="320"
preferredHeight="240" text="Tab 4"/>
Modified:
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java?rev=941264&r1=941263&r2=941264&view=diff
==============================================================================
---
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java
(original)
+++
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java
Wed May 5 12:14:13 2010
@@ -1407,4 +1407,13 @@ public class TerraTabPaneSkin extends Co
invalidateComponent();
}
+
+ @Override
+ public void tooltipTextChanged(TabPane tabPane, Component component,
String previousTooltipText) {
+ int i = tabPane.getTabs().indexOf(component);
+ buttonBoxPane.get(i).setTooltipText(TabPane.getTooltipText(component));
+ buttonBoxPane.get(i).invalidate();
+
+ invalidateComponent();
+ }
}
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=941264&r1=941263&r2=941264&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPane.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPane.java Wed May 5 12:14:13
2010
@@ -133,7 +133,8 @@ public class TabPane extends Container {
private enum Attribute {
LABEL,
ICON,
- CLOSEABLE;
+ CLOSEABLE,
+ TOOLTIP;
}
private static class TabPaneListenerList extends
ListenerList<TabPaneListener>
@@ -210,6 +211,13 @@ public class TabPane extends Container {
listener.closeableChanged(tabPane, component);
}
}
+
+ @Override
+ public void tooltipTextChanged(TabPane tabPane, Component component,
String previousTooltipText) {
+ for (TabPaneAttributeListener listener : this) {
+ listener.tooltipTextChanged(tabPane, component,
previousTooltipText);
+ }
+ }
}
private int selectedIndex = -1;
@@ -394,5 +402,35 @@ public class TabPane extends Container {
}
}
}
+
+ /**
+ * Returns the tab component's tooltip text.
+ *
+ * @return
+ * The tab component's tooltip text, or <tt>null</tt> if no tooltip is
+ * specified.
+ */
+ public static String getTooltipText(Component component) {
+ return (String)component.getAttribute(Attribute.TOOLTIP);
+ }
+
+ /**
+ * Sets the tab component's tooltip text.
+ *
+ * @param tooltipText
+ * The tab component's tooltip text, or <tt>null</tt> for no tooltip.
+ */
+ public static void setTooltipText(Component component, String tooltipText)
{
+ String previousTooltipText =
(String)component.setAttribute(Attribute.TOOLTIP, tooltipText);
+
+ if (previousTooltipText != tooltipText) {
+ Container parent = component.getParent();
+
+ if (parent instanceof TabPane) {
+ TabPane tabPane = (TabPane)parent;
+ tabPane.tabPaneAttributeListeners.tooltipTextChanged(tabPane,
component, previousTooltipText);
+ }
+ }
+ }
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPaneAttributeListener.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPaneAttributeListener.java?rev=941264&r1=941263&r2=941264&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPaneAttributeListener.java
(original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPaneAttributeListener.java Wed
May 5 12:14:13 2010
@@ -37,6 +37,11 @@ public interface TabPaneAttributeListene
@Override
public void closeableChanged(TabPane tabPane, Component component) {
}
+
+ @Override
+ public void tooltipTextChanged(TabPane tabPane, Component component,
+ String previousTooltipText) {
+ }
}
/**
@@ -64,4 +69,12 @@ public interface TabPaneAttributeListene
* @param component
*/
public void closeableChanged(TabPane tabPane, Component component);
+
+ /**
+ * Called when a tab's tooltipText attribute has changed.
+ *
+ * @param tabPane
+ * @param component
+ */
+ public void tooltipTextChanged(TabPane tabPane, Component component,
String previousTooltipText);
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TablePaneSkin.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TablePaneSkin.java?rev=941264&r1=941263&r2=941264&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TablePaneSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TablePaneSkin.java Wed May 5
12:14:13 2010
@@ -148,7 +148,7 @@ public class TablePaneSkin extends Conta
int columnSpan = TablePane.getColumnSpan(component);
if (columnSpan > 1) {
- // We might need to adjust column widths to accomodate
+ // We might need to adjust column widths to accommodate
// this spanning cell. First, we find out if any of the
// spanned cells are default width and how much space
// we've allocated thus far for those cells
@@ -1122,14 +1122,24 @@ public class TablePaneSkin extends Conta
int preferredHeight = 0;
- for (int j = 0, n = row.getLength(), m = columns.getLength(); j < n &&
j < m; j++) {
- Component component = row.get(j);
+ int columnIndex = 0;
+ for (int i = 0, n = row.getLength(); i < n; i++) {
+ Component component = row.get(i);
if (component != null
&& component.isVisible()
&& TablePane.getRowSpan(component) == 1) {
+ int colSpan = TablePane.getColumnSpan(component);
+
+ int colSpannedWidth = 0;
+ for (int j = 0; j < colSpan && (columnIndex + j) <
columnWidths.length; j++) {
+ colSpannedWidth += columnWidths[columnIndex + j];
+ }
preferredHeight = Math.max(preferredHeight,
- component.getPreferredHeight(columnWidths[j]));
+ component.getPreferredHeight(colSpannedWidth));
+
+ columnIndex += colSpan;
+ if (columnIndex >= columns.getLength()) break;
}
}
@@ -1239,7 +1249,7 @@ public class TablePaneSkin extends Conta
int columnSpan = TablePane.getColumnSpan(component);
if (columnSpan > 1) {
- // We might need to adjust column widths to accomodate
+ // We might need to adjust column widths to accommodate
// this spanning cell. First, we find out if any of the
// spanned cells are default width and how much space
// we've allocated thus far for those cells