import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.ContainerResizedListener;
import com.vaadin.terminal.gwt.client.RenderInformation;
import com.vaadin.terminal.gwt.client.RenderSpace;
private String width = "";
- private HashMap<StackItem, UIDL> lazyUpdateMap = new HashMap<StackItem, UIDL>();
+ HashMap<StackItem, UIDL> lazyUpdateMap = new HashMap<StackItem, UIDL>();
private RenderSpace renderSpace = new RenderSpace(0, 0, true);
- private StackItem openTab = null;
+ StackItem openTab = null;
- private boolean rendering = false;
+ boolean rendering = false;
- private int selectedUIDLItemIndex = -1;
+ int selectedUIDLItemIndex = -1;
- private RenderInformation renderInformation = new RenderInformation();
+ RenderInformation renderInformation = new RenderInformation();
public VAccordion() {
super(CLASSNAME);
}
- @Override
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- rendering = true;
- selectedUIDLItemIndex = -1;
- super.updateFromUIDL(uidl, client);
- /*
- * Render content after all tabs have been created and we know how large
- * the content area is
- */
- if (selectedUIDLItemIndex >= 0) {
- StackItem selectedItem = getStackItem(selectedUIDLItemIndex);
- UIDL selectedTabUIDL = lazyUpdateMap.remove(selectedItem);
- open(selectedUIDLItemIndex);
-
- selectedItem.setContent(selectedTabUIDL);
- } else if (!uidl.getBooleanAttribute("cached") && openTab != null) {
- close(openTab);
- }
-
- iLayout();
- // finally render possible hidden tabs
- if (lazyUpdateMap.size() > 0) {
- for (Iterator iterator = lazyUpdateMap.keySet().iterator(); iterator
- .hasNext();) {
- StackItem item = (StackItem) iterator.next();
- item.setContent(lazyUpdateMap.get(item));
- }
- lazyUpdateMap.clear();
- }
-
- renderInformation.updateSize(getElement());
-
- rendering = false;
- }
-
@Override
protected void renderTab(UIDL tabUidl, int index, boolean selected,
boolean hidden) {
return item;
}
- private void open(int itemIndex) {
+ void open(int itemIndex) {
StackItem item = (StackItem) getWidget(itemIndex);
boolean alreadyOpen = false;
if (openTab != null) {
updateOpenTabSize();
}
- private void close(StackItem item) {
+ void close(StackItem item) {
if (!item.isOpen()) {
return;
}
}
}
- public void updateCaption(VPaintableWidget component, UIDL uidl) {
- /* Accordion does not render its children's captions */
- }
-
public boolean requestLayout(Set<Widget> children) {
if (!isDynamicHeight() && !isDynamicWidth()) {
/*
return null;
}
- private StackItem getStackItem(int index) {
+ StackItem getStackItem(int index) {
return (StackItem) getWidget(index);
}
- public Widget getWidgetForPaintable() {
- return this;
- }
-
}
--- /dev/null
+package com.vaadin.terminal.gwt.client.ui;\r
+\r
+import java.util.Iterator;\r
+\r
+import com.google.gwt.core.client.GWT;\r
+import com.google.gwt.user.client.ui.Widget;\r
+import com.vaadin.terminal.gwt.client.ApplicationConnection;\r
+import com.vaadin.terminal.gwt.client.UIDL;\r
+import com.vaadin.terminal.gwt.client.VPaintableWidget;\r
+import com.vaadin.terminal.gwt.client.ui.VAccordion.StackItem;\r
+\r
+public class VAccordionPaintable extends VTabsheetBasePaintable {\r
+\r
+ @Override\r
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
+ getWidgetForPaintable().rendering = true;\r
+ getWidgetForPaintable().selectedUIDLItemIndex = -1;\r
+ super.updateFromUIDL(uidl, client);\r
+ /*\r
+ * Render content after all tabs have been created and we know how large\r
+ * the content area is\r
+ */\r
+ if (getWidgetForPaintable().selectedUIDLItemIndex >= 0) {\r
+ StackItem selectedItem = getWidgetForPaintable().getStackItem(\r
+ getWidgetForPaintable().selectedUIDLItemIndex);\r
+ UIDL selectedTabUIDL = getWidgetForPaintable().lazyUpdateMap\r
+ .remove(selectedItem);\r
+ getWidgetForPaintable().open(\r
+ getWidgetForPaintable().selectedUIDLItemIndex);\r
+\r
+ selectedItem.setContent(selectedTabUIDL);\r
+ } else if (!uidl.getBooleanAttribute("cached")\r
+ && getWidgetForPaintable().openTab != null) {\r
+ getWidgetForPaintable().close(getWidgetForPaintable().openTab);\r
+ }\r
+\r
+ getWidgetForPaintable().iLayout();\r
+ // finally render possible hidden tabs\r
+ if (getWidgetForPaintable().lazyUpdateMap.size() > 0) {\r
+ for (Iterator iterator = getWidgetForPaintable().lazyUpdateMap\r
+ .keySet().iterator(); iterator.hasNext();) {\r
+ StackItem item = (StackItem) iterator.next();\r
+ item.setContent(getWidgetForPaintable().lazyUpdateMap.get(item));\r
+ }\r
+ getWidgetForPaintable().lazyUpdateMap.clear();\r
+ }\r
+\r
+ getWidgetForPaintable().renderInformation\r
+ .updateSize(getWidgetForPaintable().getElement());\r
+\r
+ getWidgetForPaintable().rendering = false;\r
+ }\r
+\r
+ @Override\r
+ public VAccordion getWidgetForPaintable() {\r
+ return (VAccordion) super.getWidgetForPaintable();\r
+ }\r
+\r
+ @Override\r
+ protected Widget createWidget() {\r
+ return GWT.create(VAccordion.class);\r
+ }\r
+\r
+ public void updateCaption(VPaintableWidget component, UIDL uidl) {\r
+ /* Accordion does not render its children's captions */\r
+ }\r
+\r
+}\r
/**
* Representation of a single "tab" shown in the TabBar
- *
+ *
*/
private static class Tab extends SimplePanel {
private static final String TD_CLASSNAME = CLASSNAME + "-tabitemcell";
if (uidl.hasAttribute(ATTRIBUTE_ERROR)) {
tooltipInfo.setErrorUidl(uidl.getErrors());
}
- client.registerTooltip(getTabsheet(), getElement(), tooltipInfo);
+ client.registerWidgetTooltip(getTabsheet(), getElement(),
+ tooltipInfo);
} else {
- client.registerTooltip(getTabsheet(), getElement(), null);
+ client.registerWidgetTooltip(getTabsheet(), getElement(), null);
}
boolean ret = super.updateCaption(uidl);
if (event.getTypeInt() == Event.ONLOAD) {
getTabsheet().tabSizeMightHaveChanged(getTab());
}
- client.handleTooltipEvent(event, getTabsheet(), getElement());
+ client.handleWidgetTooltipEvent(event, getTabsheet(), getElement());
}
public Tab getTab() {
// Can't use "style" as it's already in use
public static final String TAB_STYLE_NAME = "tabstyle";
- private final Element tabs; // tabbar and 'scroller' container
+ final Element tabs; // tabbar and 'scroller' container
private final Element scroller; // tab-scroller element
private final Element scrollerNext; // tab-scroller next button element
private final Element scrollerPrev; // tab-scroller prev button element
private int scrollerIndex = 0;
private final TabBar tb = new TabBar(this);
- private final VTabsheetPanel tp = new VTabsheetPanel();
+ final VTabsheetPanel tp = new VTabsheetPanel();
private final Element contentNode, deco;
private String height;
private String width;
- private boolean waitingForResponse;
+ boolean waitingForResponse;
- private final RenderInformation renderInformation = new RenderInformation();
+ final RenderInformation renderInformation = new RenderInformation();
/**
* Previous visible widget is set invisible with CSS (not display: none, but
*/
private Widget previousVisibleWidget;
- private boolean rendering = false;
+ boolean rendering = false;
private String currentStyle;
client.updateVariable(id, "close", tabKeys.get(tabIndex), true);
}
- private boolean isDynamicWidth() {
+ boolean isDynamicWidth() {
return width == null || width.equals("");
}
- private boolean isDynamicHeight() {
+ boolean isDynamicHeight() {
return height == null || height.equals("");
}
return scrollerIndex > index;
}
- @Override
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- rendering = true;
-
- if (!uidl.getBooleanAttribute("cached")) {
- // Handle stylename changes before generics (might affect size
- // calculations)
- handleStyleNames(uidl);
- }
-
- super.updateFromUIDL(uidl, client);
- if (cachedUpdate) {
- rendering = false;
- return;
- }
-
- // tabs; push or not
- if (!isDynamicWidth()) {
- // FIXME: This makes tab sheet tabs go to 1px width on every update
- // and then back to original width
- // update width later, in updateTabScroller();
- DOM.setStyleAttribute(tabs, "width", "1px");
- DOM.setStyleAttribute(tabs, "overflow", "hidden");
- } else {
- showAllTabs();
- DOM.setStyleAttribute(tabs, "width", "");
- DOM.setStyleAttribute(tabs, "overflow", "visible");
- updateDynamicWidth();
- }
-
- if (!isDynamicHeight()) {
- // Must update height after the styles have been set
- updateContentNodeHeight();
- updateOpenTabSize();
- }
-
- iLayout();
-
- // Re run relative size update to ensure optimal scrollbars
- // TODO isolate to situation that visible tab has undefined height
- try {
- client.handleComponentRelativeSize(tp.getWidget(tp
- .getVisibleWidget()));
- } catch (Exception e) {
- // Ignore, most likely empty tabsheet
- }
-
- renderInformation.updateSize(getElement());
-
- waitingForResponse = false;
- rendering = false;
- }
-
- private void handleStyleNames(UIDL uidl) {
+ void handleStyleNames(UIDL uidl) {
// Add proper stylenames for all elements (easier to prevent unwanted
// style inheritance)
if (uidl.hasAttribute("style")) {
}
}
- private void updateDynamicWidth() {
+ void updateDynamicWidth() {
// Find width consumed by tabs
TableCellElement spacerCell = ((TableElement) tb.getElement().cast())
.getRows().getItem(0).getCells().getItem(tb.getTabCount());
}
}
- private void updateContentNodeHeight() {
+ void updateContentNodeHeight() {
if (height != null && !"".equals(height)) {
int contentHeight = getOffsetHeight();
contentHeight -= DOM.getElementPropertyInt(deco, "offsetHeight");
* position: absolute (to work around a firefox flickering bug) we must keep
* this up-to-date by hand.
*/
- private void updateOpenTabSize() {
+ void updateOpenTabSize() {
/*
* The overflow=auto element must have a height specified, otherwise it
* will be just as high as the contents and no scrollbars will appear
}
- private void showAllTabs() {
+ void showAllTabs() {
scrollerIndex = tb.getFirstVisibleTab();
for (int i = 0; i < tb.getTabCount(); i++) {
Tab t = tb.getTab(i);
tp.replaceComponent(oldComponent, newComponent);
}
- public void updateCaption(VPaintableWidget component, UIDL uidl) {
- /* Tabsheet does not render its children's captions */
- }
-
public boolean requestLayout(Set<Widget> children) {
if (!isDynamicHeight() && !isDynamicWidth()) {
/*
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
-import com.vaadin.terminal.gwt.client.Container;
import com.vaadin.terminal.gwt.client.UIDL;
-import com.vaadin.terminal.gwt.client.VPaintableMap;
import com.vaadin.terminal.gwt.client.VPaintableWidget;
-abstract class VTabsheetBase extends ComplexPanel implements Container {
+abstract class VTabsheetBase extends ComplexPanel {
String id;
ApplicationConnection client;
setStyleName(classname);
}
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- this.client = client;
-
- // Ensure correct implementation
- cachedUpdate = client.updateComponent(this, uidl, true);
- if (cachedUpdate) {
- return;
- }
-
- // Update member references
- id = uidl.getId();
- disabled = uidl.hasAttribute("disabled");
-
- // Render content
- final UIDL tabs = uidl.getChildUIDL(0);
-
- // Paintables in the TabSheet before update
- ArrayList<Widget> oldWidgets = new ArrayList<Widget>();
- for (Iterator<Widget> iterator = getWidgetIterator(); iterator
- .hasNext();) {
- oldWidgets.add(iterator.next());
- }
-
- // Clear previous values
- tabKeys.clear();
- disabledTabKeys.clear();
-
- int index = 0;
- for (final Iterator<Object> it = tabs.getChildIterator(); it.hasNext();) {
- final UIDL tab = (UIDL) it.next();
- final String key = tab.getStringAttribute("key");
- final boolean selected = tab.getBooleanAttribute("selected");
- final boolean hidden = tab.getBooleanAttribute("hidden");
-
- if (tab.getBooleanAttribute("disabled")) {
- disabledTabKeys.add(key);
- }
-
- tabKeys.add(key);
-
- if (selected) {
- activeTabIndex = index;
- }
- renderTab(tab, index, selected, hidden);
- index++;
- }
-
- int tabCount = getTabCount();
- while (tabCount-- > index) {
- removeTab(index);
- }
-
- for (int i = 0; i < getTabCount(); i++) {
- VPaintableWidget p = getTab(i);
- // During the initial rendering the paintable might be null (this is
- // weird...)
- if (p != null) {
- oldWidgets.remove(p.getWidgetForPaintable());
- }
- }
-
- // Perform unregister for any paintables removed during update
- for (Iterator<Widget> iterator = oldWidgets.iterator(); iterator
- .hasNext();) {
- Widget oldWidget = iterator.next();
- VPaintableWidget oldPaintable = VPaintableMap.get(client)
- .getPaintable(oldWidget);
- if (oldWidget.isAttached()) {
- oldWidget.removeFromParent();
- }
- VPaintableMap.get(client).unregisterPaintable(oldPaintable);
- }
-
- }
-
/**
* @return a list of currently shown Paintables
*
--- /dev/null
+package com.vaadin.terminal.gwt.client.ui;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+\r
+import com.google.gwt.user.client.ui.Widget;\r
+import com.vaadin.terminal.gwt.client.ApplicationConnection;\r
+import com.vaadin.terminal.gwt.client.UIDL;\r
+import com.vaadin.terminal.gwt.client.VPaintableMap;\r
+import com.vaadin.terminal.gwt.client.VPaintableWidget;\r
+\r
+public abstract class VTabsheetBasePaintable extends\r
+ VAbstractPaintableWidgetContainer {\r
+\r
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
+ getWidgetForPaintable().client = client;\r
+\r
+ // Ensure correct implementation\r
+ getWidgetForPaintable().cachedUpdate = client.updateComponent(this,\r
+ uidl, true);\r
+ if (getWidgetForPaintable().cachedUpdate) {\r
+ return;\r
+ }\r
+\r
+ // Update member references\r
+ getWidgetForPaintable().id = uidl.getId();\r
+ getWidgetForPaintable().disabled = uidl.hasAttribute("disabled");\r
+\r
+ // Render content\r
+ final UIDL tabs = uidl.getChildUIDL(0);\r
+\r
+ // Paintables in the TabSheet before update\r
+ ArrayList<Widget> oldWidgets = new ArrayList<Widget>();\r
+ for (Iterator<Widget> iterator = getWidgetForPaintable()\r
+ .getWidgetIterator(); iterator.hasNext();) {\r
+ oldWidgets.add(iterator.next());\r
+ }\r
+\r
+ // Clear previous values\r
+ getWidgetForPaintable().tabKeys.clear();\r
+ getWidgetForPaintable().disabledTabKeys.clear();\r
+\r
+ int index = 0;\r
+ for (final Iterator<Object> it = tabs.getChildIterator(); it.hasNext();) {\r
+ final UIDL tab = (UIDL) it.next();\r
+ final String key = tab.getStringAttribute("key");\r
+ final boolean selected = tab.getBooleanAttribute("selected");\r
+ final boolean hidden = tab.getBooleanAttribute("hidden");\r
+\r
+ if (tab.getBooleanAttribute("disabled")) {\r
+ getWidgetForPaintable().disabledTabKeys.add(key);\r
+ }\r
+\r
+ getWidgetForPaintable().tabKeys.add(key);\r
+\r
+ if (selected) {\r
+ getWidgetForPaintable().activeTabIndex = index;\r
+ }\r
+ getWidgetForPaintable().renderTab(tab, index, selected, hidden);\r
+ index++;\r
+ }\r
+\r
+ int tabCount = getWidgetForPaintable().getTabCount();\r
+ while (tabCount-- > index) {\r
+ getWidgetForPaintable().removeTab(index);\r
+ }\r
+\r
+ for (int i = 0; i < getWidgetForPaintable().getTabCount(); i++) {\r
+ VPaintableWidget p = getWidgetForPaintable().getTab(i);\r
+ // During the initial rendering the paintable might be null (this is\r
+ // weird...)\r
+ if (p != null) {\r
+ oldWidgets.remove(p.getWidgetForPaintable());\r
+ }\r
+ }\r
+\r
+ // Perform unregister for any paintables removed during update\r
+ for (Iterator<Widget> iterator = oldWidgets.iterator(); iterator\r
+ .hasNext();) {\r
+ Widget oldWidget = iterator.next();\r
+ VPaintableWidget oldPaintable = VPaintableMap.get(client)\r
+ .getPaintable(oldWidget);\r
+ if (oldWidget.isAttached()) {\r
+ oldWidget.removeFromParent();\r
+ }\r
+ VPaintableMap.get(client).unregisterPaintable(oldPaintable);\r
+ }\r
+\r
+ }\r
+\r
+ @Override\r
+ public VTabsheetBase getWidgetForPaintable() {\r
+ return (VTabsheetBase) super.getWidgetForPaintable();\r
+ }\r
+\r
+}\r
--- /dev/null
+package com.vaadin.terminal.gwt.client.ui;\r
+\r
+import com.google.gwt.core.client.GWT;\r
+import com.google.gwt.user.client.DOM;\r
+import com.google.gwt.user.client.ui.Widget;\r
+import com.vaadin.terminal.gwt.client.ApplicationConnection;\r
+import com.vaadin.terminal.gwt.client.UIDL;\r
+import com.vaadin.terminal.gwt.client.VPaintableWidget;\r
+\r
+public class VTabsheetPaintable extends VTabsheetBasePaintable {\r
+\r
+ @Override\r
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
+ getWidgetForPaintable().rendering = true;\r
+\r
+ if (!uidl.getBooleanAttribute("cached")) {\r
+ // Handle stylename changes before generics (might affect size\r
+ // calculations)\r
+ getWidgetForPaintable().handleStyleNames(uidl);\r
+ }\r
+\r
+ super.updateFromUIDL(uidl, client);\r
+ if (getWidgetForPaintable().cachedUpdate) {\r
+ getWidgetForPaintable().rendering = false;\r
+ return;\r
+ }\r
+\r
+ // tabs; push or not\r
+ if (!getWidgetForPaintable().isDynamicWidth()) {\r
+ // FIXME: This makes tab sheet tabs go to 1px width on every update\r
+ // and then back to original width\r
+ // update width later, in updateTabScroller();\r
+ DOM.setStyleAttribute(getWidgetForPaintable().tabs, "width", "1px");\r
+ DOM.setStyleAttribute(getWidgetForPaintable().tabs, "overflow",\r
+ "hidden");\r
+ } else {\r
+ getWidgetForPaintable().showAllTabs();\r
+ DOM.setStyleAttribute(getWidgetForPaintable().tabs, "width", "");\r
+ DOM.setStyleAttribute(getWidgetForPaintable().tabs, "overflow",\r
+ "visible");\r
+ getWidgetForPaintable().updateDynamicWidth();\r
+ }\r
+\r
+ if (!getWidgetForPaintable().isDynamicHeight()) {\r
+ // Must update height after the styles have been set\r
+ getWidgetForPaintable().updateContentNodeHeight();\r
+ getWidgetForPaintable().updateOpenTabSize();\r
+ }\r
+\r
+ getWidgetForPaintable().iLayout();\r
+\r
+ // Re run relative size update to ensure optimal scrollbars\r
+ // TODO isolate to situation that visible tab has undefined height\r
+ try {\r
+ client.handleComponentRelativeSize(getWidgetForPaintable().tp\r
+ .getWidget(getWidgetForPaintable().tp.getVisibleWidget()));\r
+ } catch (Exception e) {\r
+ // Ignore, most likely empty tabsheet\r
+ }\r
+\r
+ getWidgetForPaintable().renderInformation\r
+ .updateSize(getWidgetForPaintable().getElement());\r
+\r
+ getWidgetForPaintable().waitingForResponse = false;\r
+ getWidgetForPaintable().rendering = false;\r
+ }\r
+\r
+ @Override\r
+ protected Widget createWidget() {\r
+ return GWT.create(VTabsheet.class);\r
+ }\r
+\r
+ @Override\r
+ public VTabsheet getWidgetForPaintable() {\r
+ return (VTabsheet) super.getWidgetForPaintable();\r
+ }\r
+\r
+ public void updateCaption(VPaintableWidget component, UIDL uidl) {\r
+ /* Tabsheet does not render its children's captions */\r
+ }\r
+\r
+}\r
*/
package com.vaadin.ui;
-import com.vaadin.terminal.gwt.client.ui.VAccordion;
+import com.vaadin.terminal.gwt.client.ui.VAccordionPaintable;
/**
* An accordion is a component similar to a {@link TabSheet}, but with a
*
* @see TabSheet
*/
-@SuppressWarnings("serial")
-@ClientWidget(VAccordion.class)
+@ClientWidget(VAccordionPaintable.class)
public class Accordion extends TabSheet {
}
import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.Resource;
import com.vaadin.terminal.gwt.client.ui.VTabsheet;
+import com.vaadin.terminal.gwt.client.ui.VTabsheetPaintable;
import com.vaadin.terminal.gwt.server.CommunicationManager;
import com.vaadin.ui.themes.Reindeer;
import com.vaadin.ui.themes.Runo;
* @VERSION@
* @since 3.0
*/
-@SuppressWarnings("serial")
-@ClientWidget(VTabsheet.class)
+@ClientWidget(VTabsheetPaintable.class)
public class TabSheet extends AbstractComponentContainer {
/**