From bd94e6ef89a5980ad50b296079f28354e6874d33 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Tue, 25 May 2010 12:34:45 +0000 Subject: #4981 and #4935 TabSheet and Accordion javadoc and one import, no functional change svn changeset:13354/svn branch:6.3 --- src/com/vaadin/ui/Accordion.java | 8 ++ src/com/vaadin/ui/TabSheet.java | 222 ++++++++++++++++++++++++++++----------- 2 files changed, 166 insertions(+), 64 deletions(-) (limited to 'src') diff --git a/src/com/vaadin/ui/Accordion.java b/src/com/vaadin/ui/Accordion.java index 1c0165ed26..9f48fcd9e2 100644 --- a/src/com/vaadin/ui/Accordion.java +++ b/src/com/vaadin/ui/Accordion.java @@ -5,6 +5,14 @@ package com.vaadin.ui; import com.vaadin.terminal.gwt.client.ui.VAccordion; +/** + * An accordion is a component similar to a {@link TabSheet}, but with a + * vertical orientation and the selected component presented between tabs. + * + * Closable tabs are not supported by the accordion. + * + * @see TabSheet + */ @SuppressWarnings("serial") @ClientWidget(VAccordion.class) public class Accordion extends TabSheet { diff --git a/src/com/vaadin/ui/TabSheet.java b/src/com/vaadin/ui/TabSheet.java index a69e89ee17..051004aeee 100644 --- a/src/com/vaadin/ui/TabSheet.java +++ b/src/com/vaadin/ui/TabSheet.java @@ -7,6 +7,7 @@ package com.vaadin.ui; import java.io.Serializable; import java.lang.reflect.Method; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -20,9 +21,32 @@ import com.vaadin.terminal.PaintTarget; import com.vaadin.terminal.Resource; import com.vaadin.terminal.gwt.client.ui.VTabsheet; import com.vaadin.terminal.gwt.server.CommunicationManager; +import com.vaadin.ui.themes.Reindeer; +import com.vaadin.ui.themes.Runo; /** - * Tabsheet component. + * TabSheet component. + * + * Tabs are typically identified by the component contained on the tab (see + * {@link ComponentContainer}), and tab metadata (including caption, icon, + * visibility, enabledness, closability etc.) is kept in separate {@link Tab} + * instances. + * + * Tabs added with {@link #addComponent(Component)} get the caption and the icon + * of the component at the time when the component is created, and these are not + * automatically updated after tab creation. + * + * A tab sheet can have multiple tab selection listeners and one tab close + * handler ({@link CloseHandler}), which by default removes the tab from the + * TabSheet. + * + * The {@link TabSheet} can be styled with the .v-tabsheet, .v-tabsheet-tabs and + * .v-tabsheet-content styles. Themes may also have pre-defined variations of + * the tab sheet presentation, such as {@link Reindeer#TABSHEET_BORDERLESS}, + * {@link Runo#TABSHEET_SMALL} and several other styles in {@link Reindeer}. + * + * The current implementation does not load the tabs to the UI before the first + * time they are shown, but this may change in future releases. * * @author IT Mill Ltd. * @version @@ -34,7 +58,9 @@ import com.vaadin.terminal.gwt.server.CommunicationManager; public class TabSheet extends AbstractComponentContainer { /** - * Linked list of component tabs. + * List of component tabs (tab contents). In addition to being on this list, + * there is a {@link Tab} object in tabs for each tab with meta-data about + * the tab. */ private final LinkedList components = new LinkedList(); @@ -44,23 +70,34 @@ public class TabSheet extends AbstractComponentContainer { private final HashMap tabs = new HashMap(); /** - * Selected tab. + * Selected tab content component. */ private Component selected = null; + /** + * Mapper between server-side component instances (tab contents) and keys + * given to the client that identify tabs. + */ private final KeyMapper keyMapper = new KeyMapper(); /** - * Holds the value of property tabsHIdden. + * When true, the tab selection area is not displayed to the user. */ private boolean tabsHidden; + /** + * Tabs that have been shown to the user (have been painted as selected). + */ private HashSet paintedTabs = new HashSet(); + /** + * Handler to be called when a tab is closed. + */ private CloseHandler closeHandler; /** - * Constructs a new Tabsheet. Tabsheet is immediate by default. + * Constructs a new Tabsheet. Tabsheet is immediate by default, and the + * default close handler removes the tab being closed. */ public TabSheet() { super(); @@ -75,17 +112,20 @@ public class TabSheet extends AbstractComponentContainer { } /** - * Gets the component container iterator for going trough all the components - * in the container. + * Gets the component container iterator for going through all the + * components (tab contents). * - * @return the Iterator of the components inside the container. + * @return the unmodifiable Iterator of the tab content components */ public Iterator getComponentIterator() { - return java.util.Collections.unmodifiableList(components).iterator(); + return Collections.unmodifiableList(components).iterator(); } /** - * Removes the component from this container. + * Removes a component and its corresponding tab. + * + * If the tab was selected, the first eligible (visible and enabled) + * remaining tab is selected. * * @param c * the component to be removed. @@ -111,8 +151,10 @@ public class TabSheet extends AbstractComponentContainer { } /** - * Adds a new tab into TabSheet. Components caption and icon are rendered - * into tab. + * Adds a new tab into TabSheet. Component caption and icon are copied to + * the tab metadata at creation time. + * + * @see #addTab(Component) * * @param c * the component to be added. @@ -125,6 +167,9 @@ public class TabSheet extends AbstractComponentContainer { /** * Adds a new tab into TabSheet. * + * The first tab added to a tab sheet is automatically selected and a tab + * selection event is fired. + * * @param c * the component to be added onto tab. * @param caption @@ -133,7 +178,7 @@ public class TabSheet extends AbstractComponentContainer { * @param icon * the icon to be set for the component and used rendered in tab * bar - * @return the created tab + * @return the created {@link Tab} */ public Tab addTab(Component c, String caption, Resource icon) { if (c != null) { @@ -154,12 +199,12 @@ public class TabSheet extends AbstractComponentContainer { } /** - * Adds a new tab into TabSheet. Components caption and icon are rendered - * into tab. + * Adds a new tab into TabSheet. Component caption and icon are copied to + * the tab metadata at creation time. * * @param c * the component to be added onto tab. - * @return the created tab + * @return the created {@link Tab} */ public Tab addTab(Component c) { if (c != null) { @@ -172,6 +217,9 @@ public class TabSheet extends AbstractComponentContainer { * Moves all components from another container to this container. The * components are removed from the other container. * + * If the source container is a {@link TabSheet}, component captions and + * icons are copied from it. + * * @param source * the container components are removed from. */ @@ -195,8 +243,8 @@ public class TabSheet extends AbstractComponentContainer { /** * Paints the content of this component. * - * @param event - * the Paint Event. + * @param target + * the paint target * @throws PaintException * if the paint operation failed. */ @@ -276,19 +324,19 @@ public class TabSheet extends AbstractComponentContainer { } /** - * Are tabs hidden. + * Are the tab selection parts ("tabs") hidden. * - * @return the Property visibility. + * @return true if the tabs are hidden in the UI */ public boolean areTabsHidden() { return tabsHidden; } /** - * Setter for property tabsHidden. + * Hides or shows the tab selection parts ("tabs"). * * @param tabsHidden - * True if the tabs should be hidden. + * true if the tabs should be hidden */ public void hideTabs(boolean tabsHidden) { this.tabsHidden = tabsHidden; @@ -296,10 +344,10 @@ public class TabSheet extends AbstractComponentContainer { } /** - * Gets the caption for a component. + * Gets tab caption. The tab is identified by the tab content component. * * @param c - * the component. + * the component in the tab * @deprecated Use {@link #getTab(Component)} and {@link Tab#getCaption()} * instead. */ @@ -314,10 +362,10 @@ public class TabSheet extends AbstractComponentContainer { } /** - * Sets tabs captions. + * Sets tab caption. The tab is identified by the tab content component. * * @param c - * the component. + * the component in the tab * @param caption * the caption to set. * @deprecated Use {@link #getTab(Component)} and @@ -333,10 +381,11 @@ public class TabSheet extends AbstractComponentContainer { } /** - * Gets the icon for a component. + * Gets the icon for a tab. The tab is identified by the tab content + * component. * * @param c - * the component. + * the component in the tab * @deprecated Use {@link #getTab(Component)} and {@link Tab#getIcon()} * instead. */ @@ -351,12 +400,11 @@ public class TabSheet extends AbstractComponentContainer { } /** - * Sets icon for the given component. - * - * Normally TabSheet uses icon from component + * Sets icon for the given component. The tab is identified by the tab + * content component. * * @param c - * the component + * the component in the tab * @param icon * the icon to set * @deprecated Use {@link #getTab(Component)} and @@ -372,8 +420,8 @@ public class TabSheet extends AbstractComponentContainer { } /** - * Returns the Tab for the component. The Tab object can be used for setting - * caption,icon, etc for the tab. + * Returns the {@link Tab} (metadata) for a component. The {@link Tab} + * object can be used for setting caption,icon, etc for the tab. * * @param c * the component @@ -384,7 +432,8 @@ public class TabSheet extends AbstractComponentContainer { } /** - * Sets the selected tab. + * Sets the selected tab. The tab is identified by the tab content + * component. * * @param c */ @@ -399,7 +448,9 @@ public class TabSheet extends AbstractComponentContainer { /** * Checks if the current selection is valid, and updates the selection if - * the previously selected component is not visible and enabled. + * the previously selected component is not visible and enabled. The first + * visible and enabled tab is selected if the current selection is empty or + * invalid. * * This method does not fire tab change events, but the caller should do so * if appropriate. @@ -443,20 +494,15 @@ public class TabSheet extends AbstractComponentContainer { } /** - * Gets the selected tab. + * Gets the selected tab content component. * - * @return the selected tab. + * @return the selected tab contents */ public Component getSelectedTab() { return selected; } - /** - * Invoked when the value of a variable has changed. - * - * @see com.vaadin.ui.AbstractComponent#changeVariables(java.lang.Object, - * java.util.Map) - */ + // inherits javadoc @Override public void changeVariables(Object source, Map variables) { if (variables.containsKey("selected")) { @@ -472,7 +518,23 @@ public class TabSheet extends AbstractComponentContainer { } } - /* Documented in superclass */ + /** + * Replaces a component (tab content) with another. This can be used to + * change tab contents or to rearrange tabs. The tab position and some + * metadata are preserved when moving components within the same + * {@link TabSheet}. + * + * If the oldComponent is not present in the tab sheet, the new one is added + * at the end. + * + * If the oldComponent is already in the tab sheet but the newComponent + * isn't, the old tab is replaced with a new one, and the caption and icon + * of the old one are copied to the new tab. + * + * If both old and new components are present, their positions are swapped. + * + * {@inheritDoc} + */ public void replaceComponent(Component oldComponent, Component newComponent) { if (selected == oldComponent) { @@ -574,8 +636,8 @@ public class TabSheet extends AbstractComponentContainer { } /** - * Selected Tab Change event. This event is thrown, when the selected tab in - * the tab sheet is changed. + * Selected tab change event. This event is sent when the selected (shown) + * tab in the tab sheet is changed. * * @author IT Mill Ltd. * @version @@ -605,7 +667,9 @@ public class TabSheet extends AbstractComponentContainer { } /** - * Selected Tab Change Event listener + * Selected tab change event listener. The listener is called whenever + * another tab is selected, including when adding the first tab to a + * tabsheet. * * @author IT Mill Ltd. * @@ -616,16 +680,16 @@ public class TabSheet extends AbstractComponentContainer { public interface SelectedTabChangeListener extends Serializable { /** - * Visible tab in tab sheet has has been changed. + * Selected (shown) tab in tab sheet has has been changed. * * @param event - * the Selected tab change event. + * the selected tab change event. */ public void selectedTabChange(SelectedTabChangeEvent event); } /** - * Adds the selected tab change listener + * Adds a tab selection listener * * @param listener * the Listener to be added. @@ -636,7 +700,7 @@ public class TabSheet extends AbstractComponentContainer { } /** - * Removes the selected tab change listener + * Removes a tab selection listener * * @param listener * the Listener to be removed. @@ -647,7 +711,7 @@ public class TabSheet extends AbstractComponentContainer { } /** - * Emits the options change event. + * Sends an event that the currently selected tab has changed. */ protected void fireSelectedTabChange() { fireEvent(new SelectedTabChangeEvent(this)); @@ -664,18 +728,28 @@ public class TabSheet extends AbstractComponentContainer { } /** - * + * Tab meta-data for a component in a {@link TabSheet}. + * + * The meta-data includes the tab caption, icon, visibility and enabledness, + * closability, description (tooltip) and an optional component error shown + * in the tab. + * + * Tabs are identified by the component contained on them in most cases, and + * the meta-data can be obtained with {@link TabSheet#getTab(Component)}. */ public interface Tab extends Serializable { /** - * Returns the visible status for the tab. + * Returns the visible status for the tab. An invisible tab is not shown + * in the tab bar and cannot be selected. * * @return true for visible, false for hidden */ public boolean isVisible(); /** - * Sets the visible status for the tab. + * Sets the visible status for the tab. An invisible tab is not shown in + * the tab bar and cannot be selected, selection is changed + * automatically when there is an attempt to select an invisible tab. * * @param visible * true for visible, false for hidden @@ -705,14 +779,16 @@ public class TabSheet extends AbstractComponentContainer { public void setClosable(boolean closable); /** - * Returns the enabled status for the tab. + * Returns the enabled status for the tab. A disabled tab is shown as + * such in the tab bar and cannot be selected. * * @return true for enabled, false for disabled */ public boolean isEnabled(); /** - * Sets the enabled status for the tab. + * Sets the enabled status for the tab. A disabled tab is shown as such + * in the tab bar and cannot be selected. * * @param enabled * true for enabled, false for disabled @@ -729,13 +805,11 @@ public class TabSheet extends AbstractComponentContainer { /** * Gets the caption for the tab. - * */ public String getCaption(); /** * Gets the icon for the tab. - * */ public Resource getIcon(); @@ -749,29 +823,49 @@ public class TabSheet extends AbstractComponentContainer { /** * Gets the description for the tab. The description can be used to - * briefly describe the state of the tab to the user. + * briefly describe the state of the tab to the user, and is typically + * shown as a tooltip when hovering over the tab. * * @return the description for the tab */ public String getDescription(); /** - * Sets the description for the tab. + * Sets the description for the tab. The description can be used to + * briefly describe the state of the tab to the user, and is typically + * shown as a tooltip when hovering over the tab. * * @param description * the new description string for the tab. */ public void setDescription(String description); + /** + * Sets an error indicator to be shown in the tab. This can be used e.g. + * to communicate to the user that there is a problem in the contents of + * the tab. + * + * @see AbstractComponent#setComponentError(ErrorMessage) + * + * @param componentError + * error message or null for none + */ public void setComponentError(ErrorMessage componentError); + /** + * Gets the curent error message shown for the tab. + * + * @see AbstractComponent#setComponentError(ErrorMessage) + * + * @param error + * message or null if none + */ public ErrorMessage getComponentError(); } /** - * TabSheet's implementation of Tab - * + * TabSheet's implementation of {@link Tab} - tab metadata. */ public class TabSheetTabImpl implements Tab { -- cgit v1.2.3 From efc5dea2454b116d27a19618967bbc4c9d7aca8d Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Tue, 25 May 2010 12:40:03 +0000 Subject: #4935 minor additions to Accordion javadoc (styling) svn changeset:13355/svn branch:6.3 --- src/com/vaadin/ui/Accordion.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/com/vaadin/ui/Accordion.java b/src/com/vaadin/ui/Accordion.java index 9f48fcd9e2..1f31009f91 100644 --- a/src/com/vaadin/ui/Accordion.java +++ b/src/com/vaadin/ui/Accordion.java @@ -11,6 +11,9 @@ import com.vaadin.terminal.gwt.client.ui.VAccordion; * * Closable tabs are not supported by the accordion. * + * The {@link Accordion} can be styled with the .v-accordion, .v-accordion-item, + * .v-accordion-item-first and .v-accordion-item-caption styles. + * * @see TabSheet */ @SuppressWarnings("serial") -- cgit v1.2.3 From f2928c7054bb0fceba31066438e53c8e085941fc Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 25 May 2010 12:54:13 +0000 Subject: Fix for #4427 - Updating sub-window position information back to server should not call requestRepaint svn changeset:13356/svn branch:6.3 --- src/com/vaadin/ui/Window.java | 47 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/com/vaadin/ui/Window.java b/src/com/vaadin/ui/Window.java index fd4edccb59..ea3d583c4e 100644 --- a/src/com/vaadin/ui/Window.java +++ b/src/com/vaadin/ui/Window.java @@ -941,12 +941,16 @@ public class Window extends Panel implements URIHandler, ParameterHandler { final Integer positionx = (Integer) variables.get("positionx"); if (positionx != null) { final int x = positionx.intValue(); - setPositionX(x < 0 ? -1 : x); + // This is information from the client so it is already using the + // position. No need to repaint. + setPositionX(x < 0 ? -1 : x, false); } final Integer positiony = (Integer) variables.get("positiony"); if (positiony != null) { final int y = positiony.intValue(); - setPositionY(y < 0 ? -1 : y); + // This is information from the client so it is already using the + // position. No need to repaint. + setPositionY(y < 0 ? -1 : y, false); } if (isClosable()) { @@ -1015,9 +1019,26 @@ public class Window extends Panel implements URIHandler, ParameterHandler { * @since 4.0.0 */ public void setPositionX(int positionX) { + setPositionX(positionX, true); + } + + /** + * Sets the distance of Window left border in pixels from left border of the + * containing (main window). + * + * @param positionX + * the Distance of Window left border in pixels from left border + * of the containing (main window). or -1 if unspecified. + * @param repaintRequired + * true if the window needs to be repainted, false otherwise + * @since 6.3.4 + */ + private void setPositionX(int positionX, boolean repaintRequired) { this.positionX = positionX; centerRequested = false; - requestRepaint(); + if (repaintRequired) { + requestRepaint(); + } } /** @@ -1044,9 +1065,27 @@ public class Window extends Panel implements URIHandler, ParameterHandler { * @since 4.0.0 */ public void setPositionY(int positionY) { + setPositionY(positionY, true); + } + + /** + * Sets the distance of Window top border in pixels from top border of the + * containing (main window). + * + * @param positionY + * the Distance of Window top border in pixels from top border of + * the containing (main window). or -1 if unspecified + * @param repaintRequired + * true if the window needs to be repainted, false otherwise + * + * @since 6.3.4 + */ + private void setPositionY(int positionY, boolean repaintRequired) { this.positionY = positionY; centerRequested = false; - requestRepaint(); + if (repaintRequired) { + requestRepaint(); + } } private static final Method WINDOW_CLOSE_METHOD; -- cgit v1.2.3 From 0f9f3a60edc27396876933089051e0d6f88e17e2 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Wed, 26 May 2010 10:29:49 +0000 Subject: #5053 Last ComboBox item may not be shown if null selection enabled: test case and fix svn changeset:13371/svn branch:6.3 --- .../terminal/gwt/client/ui/VFilterSelect.java | 14 +++++---- tests/src/com/vaadin/tests/tickets/Ticket5053.java | 35 ++++++++++++++++++++++ 2 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 tests/src/com/vaadin/tests/tickets/Ticket5053.java (limited to 'src') diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java index 32b2323f95..66e712f4da 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java @@ -200,11 +200,13 @@ public class VFilterSelect extends Composite implements Paintable, Field, topPosition += tb.getOffsetHeight(); setPopupPosition(x, topPosition); - final int first = currentPage * pageLength - + (nullSelectionAllowed && currentPage > 0 ? 0 : 1); - final int last = first + currentSuggestions.size() - 1; - final int matches = totalSuggestions - - (nullSelectionAllowed ? 1 : 0); + int nullOffset = (nullSelectionAllowed ? 1 : 0); + boolean firstPage = (currentPage == 0); + final int first = currentPage * pageLength + 1 + - (firstPage ? 0 : nullOffset); + final int last = first + currentSuggestions.size() - 1 + - (firstPage ? nullOffset : 0); + final int matches = totalSuggestions - nullOffset; if (last > 0) { // nullsel not counted, as requested by user DOM.setInnerText(status, (matches == 0 ? 0 : first) @@ -217,7 +219,7 @@ public class VFilterSelect extends Composite implements Paintable, Field, } // We don't need to show arrows or statusbar if there is only one // page - if (matches <= pageLength) { + if (totalSuggestions <= pageLength) { setPagingEnabled(false); } else { setPagingEnabled(true); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket5053.java b/tests/src/com/vaadin/tests/tickets/Ticket5053.java new file mode 100644 index 0000000000..bbb9a1ebc2 --- /dev/null +++ b/tests/src/com/vaadin/tests/tickets/Ticket5053.java @@ -0,0 +1,35 @@ +package com.vaadin.tests.tickets; + +import com.vaadin.Application; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Window; + +/** + * #5053: Last ComboBox item may not be shown if null selection enabled + */ +public class Ticket5053 extends Application { + + @Override + public void init() { + Window main = new Window(); + setMainWindow(main); + + ComboBox combobox = new ComboBox("My ComboBox"); + + // Enable null selection + combobox.setNullSelectionAllowed(true); + // Add the item that marks 'null' value + String nullitem = "-- none --"; + combobox.addItem(nullitem); + // Designate it was the 'null' value marker + combobox.setNullSelectionItemId(nullitem); + + // Add some other items + for (int i = 0; i < 10; i++) { + combobox.addItem("Item " + i); + } + + main.addComponent(combobox); + } + +} -- cgit v1.2.3 From 5e516e776ecfadf8f343360644ada9fbd1e22ce8 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Wed, 26 May 2010 11:08:15 +0000 Subject: #4641 Adding the same component multiple times to a TabSheet caused NPE svn changeset:13373/svn branch:6.3 --- src/com/vaadin/ui/TabSheet.java | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/com/vaadin/ui/TabSheet.java b/src/com/vaadin/ui/TabSheet.java index 051004aeee..f6dae38372 100644 --- a/src/com/vaadin/ui/TabSheet.java +++ b/src/com/vaadin/ui/TabSheet.java @@ -170,8 +170,12 @@ public class TabSheet extends AbstractComponentContainer { * The first tab added to a tab sheet is automatically selected and a tab * selection event is fired. * + * If the component is already present in the tab sheet, changes its caption + * and icon and returns the corresponding (old) tab, preserving other tab + * metadata. + * * @param c - * the component to be added onto tab. + * the component to be added onto tab - should not be null. * @param caption * the caption to be set for the component and used rendered in * tab bar @@ -181,7 +185,14 @@ public class TabSheet extends AbstractComponentContainer { * @return the created {@link Tab} */ public Tab addTab(Component c, String caption, Resource icon) { - if (c != null) { + if (c == null) { + return null; + } else if (tabs.containsKey(c)) { + Tab tab = tabs.get(c); + tab.setCaption(caption); + tab.setIcon(icon); + return tab; + } else { components.addLast(c); Tab tab = new TabSheetTabImpl(caption, icon); @@ -193,8 +204,6 @@ public class TabSheet extends AbstractComponentContainer { super.addComponent(c); requestRepaint(); return tab; - } else { - return null; } } @@ -202,15 +211,20 @@ public class TabSheet extends AbstractComponentContainer { * Adds a new tab into TabSheet. Component caption and icon are copied to * the tab metadata at creation time. * + * If the tab sheet already contains the component, its tab is returned. + * * @param c - * the component to be added onto tab. + * the component to be added onto tab - should not be null. * @return the created {@link Tab} */ public Tab addTab(Component c) { - if (c != null) { + if (c == null) { + return null; + } else if (tabs.containsKey(c)) { + return tabs.get(c); + } else { return addTab(c, c.getCaption(), c.getIcon()); } - return null; } /** -- cgit v1.2.3 From e2867b081a01f0b419b38ca3539c3756df9736ec Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Wed, 26 May 2010 11:09:50 +0000 Subject: TabSheet: break out of loop earlier when suitable selected component found svn changeset:13374/svn branch:6.3 --- src/com/vaadin/ui/TabSheet.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/com/vaadin/ui/TabSheet.java b/src/com/vaadin/ui/TabSheet.java index f6dae38372..02af64a5fe 100644 --- a/src/com/vaadin/ui/TabSheet.java +++ b/src/com/vaadin/ui/TabSheet.java @@ -495,6 +495,7 @@ public class TabSheet extends AbstractComponentContainer { // it if (tab.isEnabled() && tab.isVisible()) { selected = component; + break; } else { /* * The current selection is not valid but this tab cannot be -- cgit v1.2.3 From 12e5f5e5aa852632b5f0c0783f3d1591354669c8 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 27 May 2010 09:15:05 +0000 Subject: Fixed #4251 - ArithmeticException when changing Select pageLength to 0 svn changeset:13389/svn branch:6.3 --- .../terminal/gwt/client/ui/VFilterSelect.java | 2 +- src/com/vaadin/ui/Select.java | 4 +++- .../tests/components/combobox/Comboboxes.html | 22 ++++++++++++++++++++++ .../tests/components/combobox/Comboboxes.java | 14 ++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java index 66e712f4da..6030236073 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java @@ -219,7 +219,7 @@ public class VFilterSelect extends Composite implements Paintable, Field, } // We don't need to show arrows or statusbar if there is only one // page - if (totalSuggestions <= pageLength) { + if (totalSuggestions <= pageLength || pageLength == 0) { setPagingEnabled(false); } else { setPagingEnabled(true); diff --git a/src/com/vaadin/ui/Select.java b/src/com/vaadin/ui/Select.java index 4e4ab74215..467a21b259 100644 --- a/src/com/vaadin/ui/Select.java +++ b/src/com/vaadin/ui/Select.java @@ -258,7 +258,9 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, */ private List sanitetizeList(List options, boolean needNullSelectOption) { - if (options.size() > pageLength) { + if (pageLength != 0 && options.size() > pageLength) { + // Not all options are visible, find out which ones are on the + // current "page". int first = currentPage * pageLength; int last = first + pageLength; if (needNullSelectOption) { diff --git a/tests/src/com/vaadin/tests/components/combobox/Comboboxes.html b/tests/src/com/vaadin/tests/components/combobox/Comboboxes.html index 8df7ea00ae..6f87903413 100644 --- a/tests/src/com/vaadin/tests/components/combobox/Comboboxes.html +++ b/tests/src/com/vaadin/tests/components/combobox/Comboboxes.html @@ -191,6 +191,28 @@ + + + mouseClick + vaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[9]/VFilterSelect[0]/domChild[1] + 9,13 + + + waitForVaadin + + + + + screenCapture + + pagelength-0-popup-open + + + waitForVaadin + + + + mouseClick vaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0] diff --git a/tests/src/com/vaadin/tests/components/combobox/Comboboxes.java b/tests/src/com/vaadin/tests/components/combobox/Comboboxes.java index f55a252f10..39008f3db5 100644 --- a/tests/src/com/vaadin/tests/components/combobox/Comboboxes.java +++ b/tests/src/com/vaadin/tests/components/combobox/Comboboxes.java @@ -66,6 +66,20 @@ public class Comboboxes extends ComponentTestCase { populate(s, 50); addTestComponent(s); + s = new PageLength0ComboBox(); + s.setImmediate(true); + s.addContainerProperty(CAPTION, String.class, ""); + s.setItemCaptionPropertyId(CAPTION); + s.setCaption("Pagelength 0"); + populate(s, 15); + addTestComponent(s); + } + + public class PageLength0ComboBox extends ComboBox { + public PageLength0ComboBox() { + super(); + pageLength = 0; + } } private void populate(Select s, int nr) { -- cgit v1.2.3 From 8c60fc5fb4a2f2f26a7a2842a79ba57f9976c1ee Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Thu, 27 May 2010 09:16:39 +0000 Subject: #5013 AbstractField did not repaint property read-only status changes immediately svn changeset:13390/svn branch:6.3 --- src/com/vaadin/ui/AbstractField.java | 21 ++++++++ .../AbstractFieldDataSourceReadOnly.html | 42 ++++++++++++++++ .../AbstractFieldDataSourceReadOnly.java | 58 ++++++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 tests/src/com/vaadin/tests/components/abstractfield/AbstractFieldDataSourceReadOnly.html create mode 100644 tests/src/com/vaadin/tests/components/abstractfield/AbstractFieldDataSourceReadOnly.java (limited to 'src') diff --git a/src/com/vaadin/ui/AbstractField.java b/src/com/vaadin/ui/AbstractField.java index 17e82e86e4..f7d1ddd79e 100644 --- a/src/com/vaadin/ui/AbstractField.java +++ b/src/com/vaadin/ui/AbstractField.java @@ -55,6 +55,7 @@ import com.vaadin.terminal.PaintTarget; */ @SuppressWarnings("serial") public abstract class AbstractField extends AbstractComponent implements Field, + Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Action.ShortcutNotifier { /* Private members */ @@ -571,6 +572,12 @@ public abstract class AbstractField extends AbstractComponent implements Field, .isAssignableFrom(dataSource.getClass())) { ((Property.ValueChangeNotifier) dataSource).removeListener(this); } + if (dataSource != null + && Property.ReadOnlyStatusChangeNotifier.class + .isAssignableFrom(dataSource.getClass())) { + ((Property.ReadOnlyStatusChangeNotifier) dataSource) + .removeListener(this); + } // Sets the new data source dataSource = newDataSource; @@ -592,6 +599,10 @@ public abstract class AbstractField extends AbstractComponent implements Field, if (dataSource instanceof Property.ValueChangeNotifier) { ((Property.ValueChangeNotifier) dataSource).addListener(this); } + if (dataSource instanceof Property.ReadOnlyStatusChangeNotifier) { + ((Property.ReadOnlyStatusChangeNotifier) dataSource) + .addListener(this); + } // Copy the validators from the data source if (dataSource instanceof Validatable) { @@ -892,6 +903,16 @@ public abstract class AbstractField extends AbstractComponent implements Field, } } + /** + * React to read only status changes of the property by requesting a + * repaint. + * + * @see Property.ReadOnlyStatusChangeListener + */ + public void readOnlyStatusChange(Property.ReadOnlyStatusChangeEvent event) { + requestRepaint(); + } + /** * An Event object specifying the Property whose read-only * status has changed. diff --git a/tests/src/com/vaadin/tests/components/abstractfield/AbstractFieldDataSourceReadOnly.html b/tests/src/com/vaadin/tests/components/abstractfield/AbstractFieldDataSourceReadOnly.html new file mode 100644 index 0000000000..1e78108e42 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/abstractfield/AbstractFieldDataSourceReadOnly.html @@ -0,0 +1,42 @@ + + + + + + +AbstractFieldDataSourceReadOnly + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AbstractFieldDataSourceReadOnly
open/run/AbstractFieldDataSourceReadOnly
waitForVaadin
clickvaadin=runAbstractFieldDataSourceReadOnly::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
waitForVaadin
screenCapture
+ + diff --git a/tests/src/com/vaadin/tests/components/abstractfield/AbstractFieldDataSourceReadOnly.java b/tests/src/com/vaadin/tests/components/abstractfield/AbstractFieldDataSourceReadOnly.java new file mode 100644 index 0000000000..d439544067 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/abstractfield/AbstractFieldDataSourceReadOnly.java @@ -0,0 +1,58 @@ +package com.vaadin.tests.components.abstractfield; + +import com.vaadin.data.util.ObjectProperty; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.TextField; +import com.vaadin.ui.Component.Event; +import com.vaadin.ui.Component.Listener; + +public class AbstractFieldDataSourceReadOnly extends TestBase { + + private static class StateHolder { + private ObjectProperty textField = new ObjectProperty(""); + + public ObjectProperty getTextField() { + return textField; + } + + public void setTextField(ObjectProperty textField) { + this.textField = textField; + } + + public void buttonClicked() { + textField.setReadOnly(true); + } + } + + @Override + protected void setup() { + final StateHolder stateHolder = new StateHolder(); + + // Button + Button button = new Button("Make data source read-only"); + button.addListener(new Listener() { + public void componentEvent(Event event) { + stateHolder.buttonClicked(); + } + }); + + // Input field + TextField input = new TextField("Field"); + input.setPropertyDataSource(stateHolder.getTextField()); + + addComponent(button); + addComponent(input); + } + + @Override + protected String getDescription() { + return "Read-only status changes in data sources are not rendered immediately"; + } + + @Override + protected Integer getTicketNumber() { + return 5013; + } + +} -- cgit v1.2.3 From 327bf1d1c711941a7bf360fe7d8eb79be7e9f8c1 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 27 May 2010 10:21:43 +0000 Subject: Fix for #5082 - Subwindow width wrong when contents is 100%x100% svn changeset:13392/svn branch:6.3 --- src/com/vaadin/terminal/gwt/client/ui/VWindow.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java index ecb499fdf8..4cf3f5fc80 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java @@ -459,7 +459,7 @@ public class VWindow extends VOverlay implements Container, ScrollListener { */ int h = contents.getOffsetHeight() + getExtraHeight(); - int w = contents.getOffsetWidth(); + int w = getElement().getOffsetWidth(); client.updateVariable(id, "height", h, false); client.updateVariable(id, "width", w, true); -- cgit v1.2.3 From 3051f78452bc7687da48400d670f9baefa1ed1b0 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Thu, 27 May 2010 10:54:52 +0000 Subject: #5053 and #5083: Last ComboBox item may not be shown if null selection enabled, incorrect display of filtered items when null selection is allowed svn changeset:13393/svn branch:6.3 --- src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java | 12 +++++------- src/com/vaadin/ui/Select.java | 11 +++++++---- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java index 6030236073..eb8dc85705 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java @@ -200,20 +200,18 @@ public class VFilterSelect extends Composite implements Paintable, Field, topPosition += tb.getOffsetHeight(); setPopupPosition(x, topPosition); - int nullOffset = (nullSelectionAllowed ? 1 : 0); + int nullOffset = (nullSelectionAllowed && "".equals(lastFilter) ? 1 + : 0); boolean firstPage = (currentPage == 0); final int first = currentPage * pageLength + 1 - (firstPage ? 0 : nullOffset); final int last = first + currentSuggestions.size() - 1 - - (firstPage ? nullOffset : 0); + - (firstPage && "".equals(lastFilter) ? nullOffset : 0); final int matches = totalSuggestions - nullOffset; if (last > 0) { // nullsel not counted, as requested by user - DOM.setInnerText(status, (matches == 0 ? 0 : first) - + "-" - + ("".equals(lastFilter) && nullSelectionAllowed - && currentPage == 0 ? last - 1 : last) + "/" - + matches); + DOM.setInnerText(status, (matches == 0 ? 0 : first) + "-" + + last + "/" + matches); } else { DOM.setInnerText(status, ""); } diff --git a/src/com/vaadin/ui/Select.java b/src/com/vaadin/ui/Select.java index 467a21b259..0f33529714 100644 --- a/src/com/vaadin/ui/Select.java +++ b/src/com/vaadin/ui/Select.java @@ -165,11 +165,14 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, } List options = getFilteredOptions(); - options = sanitetizeList(options, needNullSelectOption); + boolean nullFilteredOut = filterstring != null + && !"".equals(filterstring) + && filteringMode != FILTERINGMODE_OFF; + options = sanitetizeList(options, needNullSelectOption + && !nullFilteredOut); final boolean paintNullSelection = needNullSelectOption - && (currentPage == 0 && (getFilteringMode() == FILTERINGMODE_OFF - || filterstring == null || filterstring.equals(""))); + && currentPage == 0 && !nullFilteredOut; if (paintNullSelection) { target.startTag("so"); @@ -218,7 +221,7 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, + (needNullSelectOption ? 1 : 0)); if (filteredOptions != null) { target.addAttribute("totalMatches", filteredOptions.size() - + (needNullSelectOption ? 1 : 0)); + + (needNullSelectOption && !nullFilteredOut ? 1 : 0)); } // Paint variables -- cgit v1.2.3