Skip to content

Commit

Permalink
Fix hiding of overlay if connector is unregistered
Browse files Browse the repository at this point in the history
Update Vaadin to 7.6
Cleanup client side code
  • Loading branch information
jreznot committed Jan 28, 2017
1 parent 5fc6f4c commit 88e87b9
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 135 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.idea/
*.iml
*.iws
*.ipr
WebContent/VAADIN/
WebContent/WEB-INF/lib/
target/
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<groupId>com.haulmont.thirdparty</groupId>
<artifactId>overlays</artifactId>
<packaging>jar</packaging>
<version>1.0.1</version>
<version>1.1.3</version>
<name>Vaadin Overlays Addon</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<vaadin.version>7.1.0</vaadin.version>
<vaadin.version>7.6.0</vaadin.version>
<vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
<jdkVersion>1.7</jdkVersion>
</properties>
Expand Down
21 changes: 1 addition & 20 deletions src/org/vaadin/overlay/widgetset/OverlaysWidgetset.gwt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,6 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.0//EN"
"http://google-web-toolkit.googlecode.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd">
<module>
<!--
Uncomment the following to compile the widgetset for one browser only.
This can reduce the GWT compilation time significantly when debugging.
The line should be commented out before deployment to production
environments.
Multiple browsers can be specified for GWT 1.7 as a comma separated
list. The supported user agents at the moment of writing were:
ie6,ie8,gecko,gecko1_8,safari,opera
The value gecko is used for Firefox 3 and later, gecko1_8 is for
Firefox 2 and safari is used for webkit based browsers including
Google Chrome.
-->
<inherits name="com.vaadin.DefaultWidgetSet"/>
<!--<set-property name="user.agent" value="safari"/>-->
<!--<set-configuration-property name="devModeRedirectEnabled" value="true"/>-->
</module>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,12 @@

package org.vaadin.overlay.widgetset.client;

import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.shared.ui.Connect;
import org.vaadin.overlay.CustomClickableOverlay;

/**
* @author nevinsky
* @version $Id$
*/
@Connect(CustomClickableOverlay.class)
public class CustomClickableOverlayConnector extends CustomOverlayConnector {
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
super.onStateChanged(stateChangeEvent);
}
}
}
41 changes: 16 additions & 25 deletions src/org/vaadin/overlay/widgetset/client/CustomOverlayConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ConnectorHierarchyChangeEvent;
import com.vaadin.client.VConsole;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractComponentContainerConnector;
import com.vaadin.shared.Connector;
Expand All @@ -28,23 +29,10 @@

import java.util.List;

/**
* @author nevinsky
* @version $Id$
*/
@Connect(CustomOverlay.class)
public class CustomOverlayConnector extends AbstractComponentContainerConnector {
private static final long serialVersionUID = -1812155693173030620L;

public CustomOverlayConnector() {
}

@Override
protected Widget createWidget() {
CustomOverlayWidget widget = new CustomOverlayWidget();
return widget;
}

@Override
public CustomOverlayWidget getWidget() {
return (CustomOverlayWidget) super.getWidget();
Expand All @@ -58,7 +46,8 @@ public CustomOverlayState getState() {
@Override
protected void updateWidgetStyleNames() {
super.updateWidgetStyleNames();
String themeName = getConnection().getConfiguration().getThemeName();

String themeName = getConnection().getUIConnector().getActiveTheme();
getWidget().setThemeName(themeName);
}

Expand Down Expand Up @@ -104,21 +93,23 @@ public void onStateChanged(StateChangeEvent stateChangeEvent) {
}

@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent connectorHierarchyChangeEvent) {
// List<ComponentConnector> children = getChildComponents();
// CustomOverlayWidget widget = getWidget();
// widget.clear();
// if (children != null && children.size() > 0) {
// widget.overlay = children.get(0);
// } else {
// widget.overlay = null;
// }
public void onUnregister() {
super.onUnregister();

getWidget().deferredUpdatePosition();
VConsole.log(">> Unregister");

getWidget().hideOverlay();
}

@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent connectorHierarchyChangeEvent) {
if (getState().component != null) {
getWidget().deferredUpdatePosition();
}
}

@Override
public void updateCaption(ComponentConnector connector) {
//No captions for overlays
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

/**
* @author nevinsky
* @version $Id$
*/
public class CustomOverlayState extends AbstractComponentState {
public int x = 0;
Expand Down
72 changes: 10 additions & 62 deletions src/org/vaadin/overlay/widgetset/client/CustomOverlayWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.Util;
import com.vaadin.client.WidgetUtil;
import com.vaadin.shared.ui.AlignmentInfo;

import java.util.logging.Logger;
Expand Down Expand Up @@ -57,7 +57,6 @@ public class CustomOverlayWidget extends SimplePanel {
* then handle any initialization relevant to Vaadin.
*/
public CustomOverlayWidget() {
super();
setWidget(new HTML()); // Seems that we need this one
overlay = new PopupPanel();
overlay.addStyleName(CLASSNAME);
Expand All @@ -66,7 +65,6 @@ public CustomOverlayWidget() {
overlay.setModal(false);

Event.addNativePreviewHandler(new NativePreviewHandler() {

public void onPreviewNativeEvent(NativePreviewEvent event) {
int typeInt = event.getTypeInt();
// We're only listening for these
Expand All @@ -77,62 +75,6 @@ public void onPreviewNativeEvent(NativePreviewEvent event) {
});
}

/**
* Called whenever an update is received from the server
*/
// public void updateFromUIDL(UIDL uidl, final ApplicationConnection client) {
//
// // Custom visibility handling
// if (uidl.getBooleanAttribute("invisible") && overlay != null) {
// overlay.hide();
// }
// if (client.updateComponent(this, uidl, false)) {
// return;
// }
//
// // Find the reference component
// if (uidl.hasAttribute("comp")) {
// Paintable refComp = client.getPaintable(uidl
// .getStringAttribute("comp"));
// if (refComp != null) {
// Widget w = (Widget) refComp;
// if (w instanceof VCustomOverlay) {
// w = ((VCustomOverlay) w).getOverlayWidget();
// }
// refCompEl = w.getElement();
// }
// }
//
//
// // Render the component
// final UIDL child = uidl.getChildUIDL(0);
// if (child != null) {
// Paintable p = client.getPaintable(child);
// Widget w = overlay.getWidget();
// if (p != w && w != null) {
// client.unregisterPaintable((Paintable) w);
// overlay.clear();
// }
// overlay.setWidget((Widget) p);
// overlay.show();
// p.updateFromUIDL(child, client);
// } else {
// overlay.hide();
// }
//
// Widget wgt = getOverlayWidget();
// int w = Util.getRequiredWidth(wgt);
// int h = Util.getRequiredHeight(wgt);
// ApplicationConnection.getConsole().log("PAINT: w=" + w + "h=" + h);
//
// // Position the component
// x = uidl.getIntAttribute("x");
// y = uidl.getIntAttribute("y");
// align = new AlignmentInfo(uidl.getIntAttribute("align"));
// overlayAlign = new AlignmentInfo(uidl.getIntAttribute("overlayAlign"));
//
// deferredUpdatePosition();
// }
protected Widget getOverlayWidget() {
return overlay.getWidget();
}
Expand Down Expand Up @@ -161,8 +103,8 @@ public void setPosition(int offsetWidth, int offsetHeight) {
// Calculate the position based on over component size and
// the alignment point.
Widget wgt = getOverlayWidget();
int w = Util.getRequiredWidth(wgt);
int h = Util.getRequiredHeight(wgt);
int w = WidgetUtil.getRequiredWidth(wgt);
int h = WidgetUtil.getRequiredHeight(wgt);

log.info("POSITION: w=" + w + "h=" + h);

Expand Down Expand Up @@ -207,4 +149,10 @@ protected void onDetach() {
public void setThemeName(String themeName) {
overlay.addStyleName(themeName);
}
}

public void hideOverlay() {
if (overlay != null) {
overlay.hide();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@

/**
* @author nevinsky
* @version $Id$
*/
@Connect(TextOverlay.class)
public class CustomTextOverlayConnector extends CustomOverlayConnector {

@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
super.onStateChanged(stateChangeEvent);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,12 @@

package org.vaadin.overlay.widgetset.client;

import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.shared.ui.Connect;
import org.vaadin.overlay.ImageOverlay;

/**
* @author nevinsky
* @version $Id$
*/
@Connect(ImageOverlay.class)
public class ImageOverlayConnector extends CustomOverlayConnector {

public ImageOverlayConnector() {
}

@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
super.onStateChanged(stateChangeEvent);
}
}
}

0 comments on commit 88e87b9

Please sign in to comment.