summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2009-11-25 19:02:43 +0000
committerArtur Signell <artur.signell@itmill.com>2009-11-25 19:02:43 +0000
commit9881e5603293786fe685839d0b2bc4fe200ceab0 (patch)
tree34cffe7353a211e8f2d4aae7068f6667491cdaae /src
parent64a18bebab112db175996be19f60e5ae5e174395 (diff)
downloadvaadin-framework-9881e5603293786fe685839d0b2bc4fe200ceab0.tar.gz
vaadin-framework-9881e5603293786fe685839d0b2bc4fe200ceab0.zip
Cleaned up code
svn changeset:10044/svn branch:event-framework-3234
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/client/MouseEventDetails.java2
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java36
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VPanel.java54
-rw-r--r--src/com/vaadin/ui/AbsoluteLayout.java2
-rw-r--r--src/com/vaadin/ui/AbstractOrderedLayout.java2
-rw-r--r--src/com/vaadin/ui/Embedded.java2
-rw-r--r--src/com/vaadin/ui/GridLayout.java2
-rw-r--r--src/com/vaadin/ui/Panel.java6
-rw-r--r--src/com/vaadin/ui/Table.java2
-rw-r--r--src/com/vaadin/ui/Tree.java2
10 files changed, 30 insertions, 80 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/MouseEventDetails.java b/src/com/vaadin/terminal/gwt/client/MouseEventDetails.java
index abe332e6df..3a9a64657c 100644
--- a/src/com/vaadin/terminal/gwt/client/MouseEventDetails.java
+++ b/src/com/vaadin/terminal/gwt/client/MouseEventDetails.java
@@ -75,7 +75,7 @@ public class MouseEventDetails {
+ type;
}
- public static MouseEventDetails deserialize(String serializedString) {
+ public static MouseEventDetails deSerialize(String serializedString) {
MouseEventDetails instance = new MouseEventDetails();
String[] fields = serializedString.split(",");
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java
index 8e658d0930..c057135862 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java
@@ -222,26 +222,6 @@ public class VGridLayout extends SimplePanel implements Paintable, Container {
}
- // private HandlerRegistration clickHandlerRegistration;
- //
- // private void handleHandlerRegistration() {
- // // Handle registering/unregistering of click handler depending on if
- // // server side listeners have been added or removed.
- // if (client.hasEventListeners(this, CLICK_EVENT_IDENTIFIER)) {
- // if (clickHandlerRegistration == null) {
- // clickHandlerRegistration = addDomHandler(this, ClickEvent
- // .getType());
- // }
- // } else {
- // if (clickHandlerRegistration != null) {
- // clickHandlerRegistration.removeHandler();
- // clickHandlerRegistration = null;
- //
- // }
- // }
- //
- // }
-
private static int[] cloneArray(int[] toBeCloned) {
int[] clone = new int[toBeCloned.length];
for (int i = 0; i < clone.length; i++) {
@@ -1069,22 +1049,6 @@ public class VGridLayout extends SimplePanel implements Paintable, Container {
return cell;
}
- // public void onClick(ClickEvent event) {
- // // This is only called if there are click listeners registered on server
- // // side
- //
- // Paintable childComponent = getChildComponent((Element) event
- // .getNativeEvent().getEventTarget().cast());
- // final MouseEventDetails details = new MouseEventDetails(event
- // .getNativeEvent());
- //
- // Object[] parameters = new Object[] { details.serialize(),
- // childComponent };
- // client.updateVariable(client.getPid(this), CLICK_EVENT_IDENTIFIER,
- // parameters, true);
- //
- // }
-
private Paintable getComponent(Element element) {
Element rootElement = getElement();
while (element != null && element != rootElement) {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VPanel.java
index d2db9ce572..e6386e7a7c 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VPanel.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VPanel.java
@@ -8,8 +8,8 @@ import java.util.Set;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.DomEvent.Type;
+import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
@@ -19,14 +19,13 @@ import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.Container;
-import com.vaadin.terminal.gwt.client.MouseEventDetails;
import com.vaadin.terminal.gwt.client.Paintable;
import com.vaadin.terminal.gwt.client.RenderInformation;
import com.vaadin.terminal.gwt.client.RenderSpace;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
-public class VPanel extends SimplePanel implements Container, ClickHandler {
+public class VPanel extends SimplePanel implements Container {
public static final String CLICK_EVENT_IDENTIFIER = "click";
public static final String CLASSNAME = "v-panel";
@@ -77,6 +76,22 @@ public class VPanel extends SimplePanel implements Container, ClickHandler {
private String previousStyleName;
+ private ClickEventHandler clickEventHandler = new ClickEventHandler(this,
+ CLICK_EVENT_IDENTIFIER) {
+
+ @Override
+ public ApplicationConnection getApplicationConnection() {
+ return client;
+ }
+
+ @Override
+ protected <H extends EventHandler> HandlerRegistration registerHandler(
+ H handler, Type<H> type) {
+ return addDomHandler(handler, type);
+ }
+
+ };
+
public VPanel() {
super();
DivElement captionWrap = Document.get().createDivElement();
@@ -111,7 +126,7 @@ public class VPanel extends SimplePanel implements Container, ClickHandler {
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
rendering = true;
if (!uidl.hasAttribute("cached")) {
- handleHandlerRegistration();
+ clickEventHandler.handleHandlerRegistration();
// Handle caption displaying and style names, prior generics.
// Affects size
@@ -210,26 +225,6 @@ public class VPanel extends SimplePanel implements Container, ClickHandler {
}
- private HandlerRegistration clickHandlerRegistration;
-
- private void handleHandlerRegistration() {
- // Handle registering/unregistering of click handler depending on if
- // server side listeners have been added or removed.
- if (client.hasEventListeners(this, CLICK_EVENT_IDENTIFIER)) {
- if (clickHandlerRegistration == null) {
- clickHandlerRegistration = addDomHandler(this, ClickEvent
- .getType());
- }
- } else {
- if (clickHandlerRegistration != null) {
- clickHandlerRegistration.removeHandler();
- clickHandlerRegistration = null;
-
- }
- }
-
- }
-
@Override
public void setStyleName(String style) {
if (!style.equals(previousStyleName)) {
@@ -546,13 +541,4 @@ public class VPanel extends SimplePanel implements Container, ClickHandler {
detectContainerBorders();
}
- public void onClick(ClickEvent event) {
- // This is only called if there are click listeners registered on server
- // side
- MouseEventDetails details = new MouseEventDetails(event
- .getNativeEvent());
- client.updateVariable(client.getPid(this), CLICK_EVENT_IDENTIFIER,
- details.serialize(), true);
- }
-
}
diff --git a/src/com/vaadin/ui/AbsoluteLayout.java b/src/com/vaadin/ui/AbsoluteLayout.java
index 6461a64da2..849538b49a 100644
--- a/src/com/vaadin/ui/AbsoluteLayout.java
+++ b/src/com/vaadin/ui/AbsoluteLayout.java
@@ -369,7 +369,7 @@ public class AbsoluteLayout extends AbstractLayout {
private void fireClick(Map<String, Object> parameters) {
MouseEventDetails mouseDetails = MouseEventDetails
- .deserialize((String) parameters.get("mouseDetails"));
+ .deSerialize((String) parameters.get("mouseDetails"));
Component childComponent = (Component) parameters.get("component");
fireEvent(new LayoutClickEvent(this, mouseDetails, childComponent));
diff --git a/src/com/vaadin/ui/AbstractOrderedLayout.java b/src/com/vaadin/ui/AbstractOrderedLayout.java
index 505009bf3d..2a6bd84771 100644
--- a/src/com/vaadin/ui/AbstractOrderedLayout.java
+++ b/src/com/vaadin/ui/AbstractOrderedLayout.java
@@ -324,7 +324,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
private void fireClick(Map<String, Object> parameters) {
MouseEventDetails mouseDetails = MouseEventDetails
- .deserialize((String) parameters.get("mouseDetails"));
+ .deSerialize((String) parameters.get("mouseDetails"));
Component childComponent = (Component) parameters.get("component");
fireEvent(new LayoutClickEvent(this, mouseDetails, childComponent));
diff --git a/src/com/vaadin/ui/Embedded.java b/src/com/vaadin/ui/Embedded.java
index bd4003a231..7d5d7ff144 100644
--- a/src/com/vaadin/ui/Embedded.java
+++ b/src/com/vaadin/ui/Embedded.java
@@ -440,7 +440,7 @@ public class Embedded extends AbstractComponent {
private void fireClick(Map<String, Object> parameters) {
MouseEventDetails mouseDetails = MouseEventDetails
- .deserialize((String) parameters.get("mouseDetails"));
+ .deSerialize((String) parameters.get("mouseDetails"));
fireEvent(new ClickEvent(this, mouseDetails));
}
diff --git a/src/com/vaadin/ui/GridLayout.java b/src/com/vaadin/ui/GridLayout.java
index 599c6a71a9..602703980e 100644
--- a/src/com/vaadin/ui/GridLayout.java
+++ b/src/com/vaadin/ui/GridLayout.java
@@ -1316,7 +1316,7 @@ public class GridLayout extends AbstractLayout implements
private void fireClick(Map<String, Object> parameters) {
MouseEventDetails mouseDetails = MouseEventDetails
- .deserialize((String) parameters.get("mouseDetails"));
+ .deSerialize((String) parameters.get("mouseDetails"));
Component childComponent = (Component) parameters.get("component");
fireEvent(new LayoutClickEvent(this, mouseDetails, childComponent));
diff --git a/src/com/vaadin/ui/Panel.java b/src/com/vaadin/ui/Panel.java
index 7148df9e04..789fca5fea 100644
--- a/src/com/vaadin/ui/Panel.java
+++ b/src/com/vaadin/ui/Panel.java
@@ -331,7 +331,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
super.changeVariables(source, variables);
if (variables.containsKey(CLICK_EVENT)) {
- fireClick(variables.get(CLICK_EVENT));
+ fireClick((Map<String, Object>) variables.get(CLICK_EVENT));
}
// Get new size
@@ -568,9 +568,9 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
* @param object
* The raw "value" of the variable change from the client side.
*/
- private void fireClick(Object object) {
+ private void fireClick(Map<String, Object> parameters) {
MouseEventDetails mouseDetails = MouseEventDetails
- .deserialize((String) object);
+ .deSerialize((String) parameters.get("mouseDetails"));
fireEvent(new ClickEvent(this, mouseDetails));
}
diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java
index 3ee0736154..eb669bc786 100644
--- a/src/com/vaadin/ui/Table.java
+++ b/src/com/vaadin/ui/Table.java
@@ -1966,7 +1966,7 @@ public class Table extends AbstractSelect implements Action.Container,
propertyId = columnIdMap.get(colkey);
}
MouseEventDetails evt = MouseEventDetails
- .deserialize((String) variables.get("clickEvent"));
+ .deSerialize((String) variables.get("clickEvent"));
Item item = getItem(itemId);
if (item != null) {
fireEvent(new ItemClickEvent(this, item, itemId,
diff --git a/src/com/vaadin/ui/Tree.java b/src/com/vaadin/ui/Tree.java
index aad90d4e6d..825318f32b 100644
--- a/src/com/vaadin/ui/Tree.java
+++ b/src/com/vaadin/ui/Tree.java
@@ -333,7 +333,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
Object id = itemIdMapper.get(key);
MouseEventDetails details = MouseEventDetails
- .deserialize((String) variables.get("clickEvent"));
+ .deSerialize((String) variables.get("clickEvent"));
Item item = getItem(id);
if (item != null) {
fireEvent(new ItemClickEvent(this, item, id, null, details));