diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/EmbeddedConnector.java | 1 | ||||
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java | 15 | ||||
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java | 96 | ||||
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/dd/VDragAndDropManager.java | 4 | ||||
-rw-r--r-- | src/com/vaadin/ui/Button.java | 15 | ||||
-rw-r--r-- | src/com/vaadin/ui/Embedded.java | 33 |
6 files changed, 122 insertions, 42 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/EmbeddedConnector.java b/src/com/vaadin/terminal/gwt/client/ui/EmbeddedConnector.java index d57f56d9ef..b724e8fe9e 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/EmbeddedConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/EmbeddedConnector.java @@ -27,6 +27,7 @@ import com.vaadin.terminal.gwt.client.VTooltip; public class EmbeddedConnector extends AbstractComponentConnector { public static final String CLICK_EVENT_IDENTIFIER = "click"; + public static final String ALTERNATE_TEXT = "alt"; @Override public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java b/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java index 71240d9c1d..26b45d10e1 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java @@ -152,6 +152,11 @@ public class VEmbedded extends HTML { // End embed tag html.append("></embed>"); + if (uidl.hasAttribute(EmbeddedConnector.ALTERNATE_TEXT)) { + html.append(uidl + .getStringAttribute(EmbeddedConnector.ALTERNATE_TEXT)); + } + // End object tag html.append("</object>"); @@ -207,8 +212,14 @@ public class VEmbedded extends HTML { // Force browser to fire unload event when component is detached // from the view (IE doesn't do this automatically) if (browserElement != null) { - DOM.setElementAttribute(browserElement, "src", - "javascript:false"); + /* + * src was previously set to javascript:false, but this was not + * enough to overcome a bug when detaching an iframe with a pdf + * loaded in IE9. about:blank seems to cause the adobe reader + * plugin to unload properly before the iframe is removed. See + * #7855 + */ + DOM.setElementAttribute(browserElement, "src", "about:blank"); } } super.onDetach(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java index c375648bed..a68f313c20 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java @@ -760,7 +760,7 @@ public class VMenuBar extends SimpleFocusablePanel implements } public void setSelected(boolean selected) { - if (selected && !isSeparator) { + if (selected && isSelectable()) { addStyleDependentName("selected"); // needed for IE6 to have a single style name to match for an // element @@ -941,6 +941,15 @@ public class VMenuBar extends SimpleFocusablePanel implements return menubar; } + /** + * Checks if the item can be selected. + * + * @return true if it is possible to select this item, false otherwise + */ + public boolean isSelectable() { + return !isSeparator() && isEnabled(); + } + } /** @@ -1163,11 +1172,11 @@ public class VMenuBar extends SimpleFocusablePanel implements if (getSelected() == null) { // If nothing is selected then select the last item setSelected(items.get(items.size() - 1)); - if (getSelected().isSeparator() || !getSelected().isEnabled()) { + if (!getSelected().isSelectable()) { handleNavigation(keycode, ctrl, shift); } } else if (visibleChildMenu == null && getParentMenu() == null) { - // If this is the root menu then move to the right + // If this is the root menu then move to the left int idx = items.indexOf(getSelected()); if (idx > 0) { setSelected(items.get(idx - 1)); @@ -1175,7 +1184,7 @@ public class VMenuBar extends SimpleFocusablePanel implements setSelected(items.get(items.size() - 1)); } - if (getSelected().isSeparator() || !getSelected().isEnabled()) { + if (!getSelected().isSelectable()) { handleNavigation(keycode, ctrl, shift); } } else if (visibleChildMenu != null) { @@ -1183,8 +1192,7 @@ public class VMenuBar extends SimpleFocusablePanel implements visibleChildMenu.handleNavigation(keycode, ctrl, shift); } else if (getParentMenu().getParentMenu() == null) { - - // Get the root menu + // Inside a sub menu, whose parent is a root menu item VMenuBar root = getParentMenu(); root.getSelected().getSubMenu().setSelected(null); @@ -1201,12 +1209,7 @@ public class VMenuBar extends SimpleFocusablePanel implements } root.setSelected(selected); - root.showChildMenu(selected); - VMenuBar submenu = selected.getSubMenu(); - - // Select the first item in the newly open submenu - submenu.setSelected(submenu.getItems().get(0)); - + openMenuAndFocusFirstIfPossible(selected); } else { getParentMenu().getSelected().getSubMenu().setSelected(null); getParentMenu().hideChildren(); @@ -1219,7 +1222,7 @@ public class VMenuBar extends SimpleFocusablePanel implements if (getSelected() == null) { // If nothing is selected then select the first item setSelected(items.get(0)); - if (getSelected().isSeparator() || !getSelected().isEnabled()) { + if (!getSelected().isSelectable()) { handleNavigation(keycode, ctrl, shift); } } else if (visibleChildMenu == null && getParentMenu() == null) { @@ -1232,7 +1235,7 @@ public class VMenuBar extends SimpleFocusablePanel implements setSelected(items.get(0)); } - if (getSelected().isSeparator() || !getSelected().isEnabled()) { + if (!getSelected().isSelectable()) { handleNavigation(keycode, ctrl, shift); } } else if (visibleChildMenu == null @@ -1264,12 +1267,7 @@ public class VMenuBar extends SimpleFocusablePanel implements } root.setSelected(selected); - root.showChildMenu(selected); - VMenuBar submenu = selected.getSubMenu(); - - // Select the first item in the newly open submenu - submenu.setSelected(submenu.getItems().get(0)); - + openMenuAndFocusFirstIfPossible(selected); } else if (visibleChildMenu != null) { // Redirect all navigation to the submenu visibleChildMenu.handleNavigation(keycode, ctrl, shift); @@ -1282,7 +1280,7 @@ public class VMenuBar extends SimpleFocusablePanel implements if (getSelected() == null) { // If nothing is selected then select the last item setSelected(items.get(items.size() - 1)); - if (getSelected().isSeparator() || !getSelected().isEnabled()) { + if (!getSelected().isSelectable()) { handleNavigation(keycode, ctrl, shift); } } else if (visibleChildMenu != null) { @@ -1297,7 +1295,7 @@ public class VMenuBar extends SimpleFocusablePanel implements setSelected(items.get(items.size() - 1)); } - if (getSelected().isSeparator() || !getSelected().isEnabled()) { + if (!getSelected().isSelectable()) { handleNavigation(keycode, ctrl, shift); } } @@ -1308,16 +1306,11 @@ public class VMenuBar extends SimpleFocusablePanel implements if (getSelected() == null) { // If nothing is selected then select the first item - setSelected(items.get(0)); - if (getSelected().isSeparator() || !getSelected().isEnabled()) { - handleNavigation(keycode, ctrl, shift); - } + selectFirstItem(); } else if (visibleChildMenu == null && getParentMenu() == null) { // If this is the root menu the show the child menu with arrow - // down - showChildMenu(getSelected()); - menuVisible = true; - visibleChildMenu.handleNavigation(keycode, ctrl, shift); + // down, if there is a child menu + openMenuAndFocusFirstIfPossible(getSelected()); } else if (visibleChildMenu != null) { // Redirect all navigation to the submenu visibleChildMenu.handleNavigation(keycode, ctrl, shift); @@ -1330,7 +1323,7 @@ public class VMenuBar extends SimpleFocusablePanel implements setSelected(items.get(0)); } - if (getSelected().isSeparator() || !getSelected().isEnabled()) { + if (!getSelected().isSelectable()) { handleNavigation(keycode, ctrl, shift); } } @@ -1342,17 +1335,18 @@ public class VMenuBar extends SimpleFocusablePanel implements menuVisible = false; } else if (keycode == getNavigationSelectKey()) { - if (visibleChildMenu != null) { + if (getSelected() == null) { + // If nothing is selected then select the first item + selectFirstItem(); + } else if (visibleChildMenu != null) { // Redirect all navigation to the submenu visibleChildMenu.handleNavigation(keycode, ctrl, shift); menuVisible = false; } else if (visibleChildMenu == null && getSelected().getSubMenu() != null) { - // If the item has a submenu then show it and move the selection - // there - showChildMenu(getSelected()); - menuVisible = true; - visibleChildMenu.handleNavigation(keycode, ctrl, shift); + // If the item has a sub menu then show it and move the + // selection there + openMenuAndFocusFirstIfPossible(getSelected()); } else { Command command = getSelected().getCommand(); if (command != null) { @@ -1367,6 +1361,34 @@ public class VMenuBar extends SimpleFocusablePanel implements return false; } + private void selectFirstItem() { + for (int i = 0; i < items.size(); i++) { + CustomMenuItem item = items.get(i); + if (!item.isSelectable()) { + continue; + } + + setSelected(item); + break; + } + } + + private void openMenuAndFocusFirstIfPossible(CustomMenuItem menuItem) { + VMenuBar subMenu = menuItem.getSubMenu(); + if (subMenu == null) { + // No child menu? Nothing to do + return; + } + + VMenuBar parentMenu = menuItem.getParentMenu(); + parentMenu.showChildMenu(menuItem); + + menuVisible = true; + // Select the first item in the newly open submenu + subMenu.setSelected(subMenu.getItems().get(0)); + + } + /* * (non-Javadoc) * diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/VDragAndDropManager.java b/src/com/vaadin/terminal/gwt/client/ui/dd/VDragAndDropManager.java index c96f955870..004e8dc078 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/dd/VDragAndDropManager.java +++ b/src/com/vaadin/terminal/gwt/client/ui/dd/VDragAndDropManager.java @@ -168,6 +168,8 @@ public class VDragAndDropManager { // ApplicationConnection.getConsole().log( // "DropHandler now" // + currentDropHandler.getPaintable()); + currentDrag + .setElementOver((com.google.gwt.user.client.Element) targetElement); target.dragEnter(currentDrag); } else if (target == null && currentDropHandler != null) { // ApplicationConnection.getConsole().log("Invalid state!?"); @@ -198,6 +200,8 @@ public class VDragAndDropManager { case Event.ONMOUSEMOVE: case Event.ONTOUCHMOVE: if (currentDropHandler != null) { + currentDrag + .setElementOver((com.google.gwt.user.client.Element) targetElement); currentDropHandler.dragOver(currentDrag); } nativeEvent.preventDefault(); diff --git a/src/com/vaadin/ui/Button.java b/src/com/vaadin/ui/Button.java index 2e23d4ae74..dbebd9200c 100644 --- a/src/com/vaadin/ui/Button.java +++ b/src/com/vaadin/ui/Button.java @@ -311,6 +311,17 @@ public class Button extends AbstractComponent implements } /** + * Simulates a button click, notifying all server-side listeners. + * + * No action is taken is the button is disabled. + */ + public void click() { + if (isEnabled() && !isReadOnly()) { + fireClick(); + } + } + + /** * Fires a click event to all listeners without any event details. * * In subclasses, override {@link #fireClick(MouseEventDetails)} instead of @@ -445,9 +456,7 @@ public class Button extends AbstractComponent implements @Override public void handleAction(Object sender, Object target) { - if (button.isEnabled() && !button.isReadOnly()) { - button.fireClick(); - } + button.click(); } } diff --git a/src/com/vaadin/ui/Embedded.java b/src/com/vaadin/ui/Embedded.java index bc4c2a3ff4..906f1ca1ed 100644 --- a/src/com/vaadin/ui/Embedded.java +++ b/src/com/vaadin/ui/Embedded.java @@ -78,6 +78,8 @@ public class Embedded extends AbstractComponent { private String archive = null; + private String altText; + /** * Creates a new empty Embedded object. */ @@ -146,6 +148,9 @@ public class Embedded extends AbstractComponent { if (archive != null && !"".equals(archive)) { target.addAttribute("archive", archive); } + if (altText != null && !"".equals(altText)) { + target.addAttribute(EmbeddedConnector.ALTERNATE_TEXT, altText); + } // Params for (final Iterator<String> i = getParameterNames(); i.hasNext();) { @@ -158,6 +163,34 @@ public class Embedded extends AbstractComponent { } /** + * Sets this component's "alt-text", that is, an alternate text that can be + * presented instead of this component's normal content, for accessibility + * purposes. Does not work when {@link #setType(int)} has been called with + * {@link #TYPE_BROWSER}. + * + * @param altText + * A short, human-readable description of this component's + * content. + * @since 6.8 + */ + public void setAlternateText(String altText) { + if (altText != this.altText + || (altText != null && !altText.equals(this.altText))) { + this.altText = altText; + requestRepaint(); + } + } + + /** + * Gets this component's "alt-text". + * + * @see #setAlternateText(String) + */ + public String getAlternateText() { + return altText; + } + + /** * Sets an object parameter. Parameters are optional information, and they * are passed to the instantiated object. Parameters are are stored as name * value pairs. This overrides the previous value assigned to this |