diff options
author | Marc Englund <marc@vaadin.com> | 2012-10-04 09:34:37 +0300 |
---|---|---|
committer | Marc Englund <marc@vaadin.com> | 2012-10-04 09:34:37 +0300 |
commit | 0f5606dace38d575efcd2e0109390b34aebb05d3 (patch) | |
tree | 5d0a032ebecbec80a33f90971ae2d0a37ab43956 /client | |
parent | 76b0655b29ed8aa4b1287f2b68322ed1f9c58faa (diff) | |
parent | 7fbe0ffd7c967728a1e437d0cbe03722ed9f1b6e (diff) | |
download | vaadin-framework-0f5606dace38d575efcd2e0109390b34aebb05d3.tar.gz vaadin-framework-0f5606dace38d575efcd2e0109390b34aebb05d3.zip |
Merge branch 'master' into sass
Conflicts:
WebContent/VAADIN/themes/base/formlayout/formlayout.scss
WebContent/VAADIN/themes/reindeer/formlayout/formlayout.scss
Change-Id: Ie895a1bbafdcf2fe79d500efb04c6eef3f5a812e
Diffstat (limited to 'client')
8 files changed, 209 insertions, 51 deletions
diff --git a/client/src/com/vaadin/client/BrowserInfo.java b/client/src/com/vaadin/client/BrowserInfo.java index e32e9b65f0..fab393eedc 100644 --- a/client/src/com/vaadin/client/BrowserInfo.java +++ b/client/src/com/vaadin/client/BrowserInfo.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -327,7 +327,7 @@ public class BrowserInfo { * otherwise <code>false</code> */ public boolean requiresOverflowAutoFix() { - return (getWebkitVersion() > 0 || getOperaVersion() >= 11) + return (getWebkitVersion() > 0 || getOperaVersion() >= 11 || isFirefox()) && Util.getNativeScrollbarSize() > 0; } diff --git a/client/src/com/vaadin/client/ComponentLocator.java b/client/src/com/vaadin/client/ComponentLocator.java index 3338147465..e69c55d445 100644 --- a/client/src/com/vaadin/client/ComponentLocator.java +++ b/client/src/com/vaadin/client/ComponentLocator.java @@ -436,8 +436,10 @@ public class ComponentLocator { if (w == null) { return null; } - - if (w instanceof VUI) { + String elementId = w.getElement().getId(); + if (elementId != null && !elementId.isEmpty()) { + return "PID_S" + elementId; + } else if (w instanceof VUI) { return ""; } else if (w instanceof VWindow) { Connector windowConnector = ConnectorMap.get(client) diff --git a/client/src/com/vaadin/client/ui/ShortcutAction.java b/client/src/com/vaadin/client/ui/ShortcutAction.java new file mode 100644 index 0000000000..3209c02203 --- /dev/null +++ b/client/src/com/vaadin/client/ui/ShortcutAction.java @@ -0,0 +1,108 @@ +/* + * Copyright 2011 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.ui; + +import com.vaadin.client.ApplicationConnection; +import com.vaadin.server.KeyMapper; + +public class ShortcutAction { + + private final ShortcutKeyCombination sc; + private final String caption; + private final String key; + private String targetCID; + private String targetAction; + + /** + * Constructor + * + * @param key + * The @link {@link KeyMapper} key of the action. + * @param sc + * The key combination that triggers the action + * @param caption + * The caption of the action + */ + public ShortcutAction(String key, ShortcutKeyCombination sc, String caption) { + this(key, sc, caption, null, null); + } + + /** + * Constructor + * + * @param key + * The @link {@link KeyMapper} key of the action. + * @param sc + * The key combination that triggers the action + * @param caption + * The caption of the action + * @param targetPID + * The pid of the component the action is targeting. We use the + * pid, instead of the actual Paintable here, so we can delay the + * fetching of the Paintable in cases where the Paintable does + * not yet exist when the action is painted. + * @param targetAction + * The target string of the action. The target string is given to + * the targeted Paintable if the paintable implements the + * {@link ShortcutActionTarget} interface. + */ + public ShortcutAction(String key, ShortcutKeyCombination sc, + String caption, String targetCID, String targetAction) { + this.sc = sc; + this.key = key; + this.caption = caption; + this.targetCID = targetCID; + this.targetAction = targetAction; + } + + /** + * Get the key combination that triggers the action + */ + public ShortcutKeyCombination getShortcutCombination() { + return sc; + } + + /** + * Get the caption of the action + */ + public String getCaption() { + return caption; + } + + /** + * Get the {@link KeyMapper} key for the action + */ + public String getKey() { + return key; + } + + /** + * Get the pid of the target of the action. Use + * {@link ApplicationConnection#getPaintable(String)} to get the actual + * Paintable + */ + public String getTargetCID() { + return targetCID; + } + + /** + * Get the target string of the action + */ + public String getTargetAction() { + return targetAction; + } + +}
\ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/ShortcutActionHandler.java b/client/src/com/vaadin/client/ui/ShortcutActionHandler.java index 8dc0d9def7..cd14f14585 100644 --- a/client/src/com/vaadin/client/ui/ShortcutActionHandler.java +++ b/client/src/com/vaadin/client/ui/ShortcutActionHandler.java @@ -30,9 +30,12 @@ import com.google.gwt.user.client.ui.KeyboardListenerCollection; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.BrowserInfo; import com.vaadin.client.ComponentConnector; +import com.vaadin.client.ConnectorMap; import com.vaadin.client.UIDL; import com.vaadin.client.Util; import com.vaadin.client.ui.richtextarea.VRichTextArea; +import com.vaadin.shared.Connector; +import com.vaadin.shared.ui.ShortCutConstants; /** * A helper class to implement keyboard shorcut handling. Keeps a list of owners @@ -108,15 +111,25 @@ public class ShortcutActionHandler { final UIDL action = (UIDL) it.next(); int[] modifiers = null; - if (action.hasAttribute("mk")) { - modifiers = action.getIntArrayAttribute("mk"); + if (action + .hasAttribute(ShortCutConstants.ACTION_MODIFIER_KEYS_ATTRIBUTE)) { + modifiers = action + .getIntArrayAttribute(ShortCutConstants.ACTION_MODIFIER_KEYS_ATTRIBUTE); } final ShortcutKeyCombination kc = new ShortcutKeyCombination( - action.getIntAttribute("kc"), modifiers); - final String key = action.getStringAttribute("key"); - final String caption = action.getStringAttribute("caption"); - actions.add(new ShortcutAction(key, kc, caption)); + action.getIntAttribute(ShortCutConstants.ACTION_SHORTCUT_KEY_ATTRIBUTE), + modifiers); + final String key = action + .getStringAttribute(ShortCutConstants.ACTION_KEY_ATTRIBUTE); + final String caption = action + .getStringAttribute(ShortCutConstants.ACTION_CAPTION_ATTRIBUTE); + final String targetPID = action + .getStringAttribute(ShortCutConstants.ACTION_TARGET_ATTRIBUTE); + final String targetAction = action + .getStringAttribute(ShortCutConstants.ACTION_TARGET_ACTION_ATTRIBUTE); + actions.add(new ShortcutAction(key, kc, caption, targetPID, + targetAction)); } } @@ -171,11 +184,24 @@ public class ShortcutActionHandler { Scheduler.get().scheduleDeferred(new Command() { @Override public void execute() { - if (finalTarget != null) { - client.updateVariable(paintableId, "actiontarget", - finalTarget, false); + Connector shortcutTarget = ConnectorMap.get(client) + .getConnector(a.getTargetCID()); + + boolean handledClientSide = false; + if (shortcutTarget instanceof ShortcutActionTarget) { + handledClientSide = ((ShortcutActionTarget) shortcutTarget) + .handleAction(a); + } + if (!handledClientSide) { + if (finalTarget != null) { + client.updateVariable(paintableId, + ShortCutConstants.ACTION_TARGET_VARIABLE, + finalTarget, false); + } + client.updateVariable(paintableId, + ShortCutConstants.ACTION_TARGET_ACTION_VARIABLE, + a.getKey(), true); } - client.updateVariable(paintableId, "action", a.getKey(), true); } }); } @@ -282,29 +308,3 @@ class ShortcutKeyCombination { return false; } } - -class ShortcutAction { - - private final ShortcutKeyCombination sc; - private final String caption; - private final String key; - - public ShortcutAction(String key, ShortcutKeyCombination sc, String caption) { - this.sc = sc; - this.key = key; - this.caption = caption; - } - - public ShortcutKeyCombination getShortcutCombination() { - return sc; - } - - public String getCaption() { - return caption; - } - - public String getKey() { - return key; - } - -} diff --git a/client/src/com/vaadin/client/ui/ShortcutActionTarget.java b/client/src/com/vaadin/client/ui/ShortcutActionTarget.java new file mode 100644 index 0000000000..617334600e --- /dev/null +++ b/client/src/com/vaadin/client/ui/ShortcutActionTarget.java @@ -0,0 +1,24 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.client.ui; + +/** + * Widgets who wish to be notificed when a shortcut action has been triggered + * with the widget as a target should implement this interface. The + * {@link #handleAction(ShortcutAction)} method will be called just before the + * action is communicated to the server + * + */ +public interface ShortcutActionTarget { + + /** + * Called by the {@link ShortcutActionHandler} just before the shortcut + * action is sent to the server side + * + * @param action + * The action which will be performed on the server side + * @return Returns true if the shortcut was handled + */ + boolean handleAction(ShortcutAction action); +} diff --git a/client/src/com/vaadin/client/ui/button/ButtonConnector.java b/client/src/com/vaadin/client/ui/button/ButtonConnector.java index b15813c99e..546bdecb61 100644 --- a/client/src/com/vaadin/client/ui/button/ButtonConnector.java +++ b/client/src/com/vaadin/client/ui/button/ButtonConnector.java @@ -33,6 +33,8 @@ import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler; import com.vaadin.client.ui.AbstractComponentConnector; import com.vaadin.client.ui.Icon; +import com.vaadin.client.ui.ShortcutAction; +import com.vaadin.client.ui.ShortcutActionTarget; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.communication.FieldRpc.FocusAndBlurServerRpc; import com.vaadin.shared.ui.Connect; @@ -43,7 +45,7 @@ import com.vaadin.ui.Button; @Connect(value = Button.class, loadStyle = LoadStyle.EAGER) public class ButtonConnector extends AbstractComponentConnector implements - BlurHandler, FocusHandler, ClickHandler { + BlurHandler, FocusHandler, ClickHandler, ShortcutActionTarget { private ButtonServerRpc rpc = RpcProxy.create(ButtonServerRpc.class, this); private FocusAndBlurServerRpc focusBlurProxy = RpcProxy.create( @@ -165,4 +167,20 @@ public class ButtonConnector extends AbstractComponentConnector implements rpc.click(details); } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.terminal.gwt.client.ui.ShortcutActionTarget#handleAction(com + * .vaadin.terminal.gwt.client.ui.ShortcutAction) + */ + public boolean handleAction(ShortcutAction action) { + if ("click".equals(action.getTargetAction())) { + getWidget().onClick(); + return true; + } + return false; + } + } diff --git a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java index 15407a16f4..e0863512b4 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java @@ -115,7 +115,7 @@ public abstract class AbstractOrderedLayoutConnector extends if (captionElement == widgetElement) { // Caption element already detached - rmeoveResizeListener(captionElement, slotCaptionResizeListener); + removeResizeListener(captionElement, slotCaptionResizeListener); childCaptionElementHeight.remove(widgetElement); return; } @@ -460,14 +460,14 @@ public abstract class AbstractOrderedLayoutConnector extends Slot slot = getWidget().getSlot(child.getWidget()); // Clear all possible listeners first - rmeoveResizeListener(slot.getWidget().getElement(), + removeResizeListener(slot.getWidget().getElement(), childComponentResizeListener); if (slot.hasCaption()) { - rmeoveResizeListener(slot.getCaptionElement(), + removeResizeListener(slot.getCaptionElement(), slotCaptionResizeListener); } if (slot.hasSpacing()) { - rmeoveResizeListener(slot.getSpacingElement(), + removeResizeListener(slot.getSpacingElement(), spacingResizeListener); } @@ -579,16 +579,16 @@ public abstract class AbstractOrderedLayoutConnector extends for (ComponentConnector child : getChildComponents()) { Slot slot = getWidget().getSlot(child.getWidget()); if (slot.hasCaption()) { - rmeoveResizeListener(slot.getCaptionElement(), + removeResizeListener(slot.getCaptionElement(), slotCaptionResizeListener); } if (slot.getSpacingElement() != null) { - rmeoveResizeListener(slot.getSpacingElement(), + removeResizeListener(slot.getSpacingElement(), spacingResizeListener); } - rmeoveResizeListener(slot.getWidget().getElement(), + removeResizeListener(slot.getWidget().getElement(), childComponentResizeListener); } @@ -613,9 +613,9 @@ public abstract class AbstractOrderedLayoutConnector extends * @param el * The element from where the resize listener should be removed * @param listener - * THe listener to remove + * The listener to remove */ - private void rmeoveResizeListener(Element el, ElementResizeListener listener) { + private void removeResizeListener(Element el, ElementResizeListener listener) { getLayoutManager().removeElementResizeListener(el, listener); } diff --git a/client/src/com/vaadin/client/ui/ui/VUI.java b/client/src/com/vaadin/client/ui/ui/VUI.java index 8d534053ed..096b0b60ba 100644 --- a/client/src/com/vaadin/client/ui/ui/VUI.java +++ b/client/src/com/vaadin/client/ui/ui/VUI.java @@ -37,6 +37,7 @@ import com.vaadin.client.BrowserInfo; import com.vaadin.client.ComponentConnector; import com.vaadin.client.ConnectorMap; import com.vaadin.client.Focusable; +import com.vaadin.client.LayoutManager; import com.vaadin.client.VConsole; import com.vaadin.client.ui.ShortcutActionHandler; import com.vaadin.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; @@ -286,7 +287,12 @@ public class VUI extends SimplePanel implements ResizeHandler, sendClientResized(); - connector.getLayoutManager().layoutNow(); + LayoutManager layoutManager = connector.getLayoutManager(); + if (layoutManager.isLayoutRunning()) { + layoutManager.layoutLater(); + } else { + layoutManager.layoutNow(); + } } } |