-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wicketstuff-openlayers3 fixed to work with bootstrap 3, 4, 5
- Loading branch information
Showing
15 changed files
with
1,064 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You 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. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.wicketstuff</groupId> | ||
<artifactId>openlayers3-parent</artifactId> | ||
<version>9.15.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>wicketstuff-openlayers3-bootstrap4</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>Openlayers3 - Bootstrap</name> | ||
<description>Openlayer3 components that leverage Wicket Bootstrap</description> | ||
|
||
<inceptionYear>2014</inceptionYear> | ||
|
||
<url>http://wicketstuff.org/confluence/display/STUFFWIKI/wicket-contrib-openlayers3-bootstrap</url> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>wicketstuff-openlayers3</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>de.agilecoders.wicket</groupId> | ||
<artifactId>wicket-bootstrap-core</artifactId> | ||
<version>${wicket-bootstrap4-core.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.wicket</groupId> | ||
<artifactId>wicket-util</artifactId> | ||
<version>${wicket.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>de.agilecoders.wicket</groupId> | ||
<artifactId>jquery-selectors</artifactId> | ||
<version>3.0.6</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
273 changes: 273 additions & 0 deletions
273
...openlayers3-bootstrap4/src/main/java/org/wicketstuff/openlayers3/api/overlay/Popover.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,273 @@ | ||
package org.wicketstuff.openlayers3.api.overlay; | ||
|
||
import org.apache.wicket.Component; | ||
import org.apache.wicket.ajax.AjaxRequestTarget; | ||
import org.apache.wicket.model.IModel; | ||
import org.apache.wicket.util.string.Strings; | ||
import org.wicketstuff.openlayers3.api.coordinate.LongLat; | ||
|
||
/** | ||
* Provides an object that models an overlay containing a popover. | ||
*/ | ||
public class Popover extends Overlay { | ||
|
||
/** | ||
* The placement position of the popover relative to the overlay's position. | ||
*/ | ||
private String placement; | ||
|
||
/** | ||
* Flag indicating that the content to be displayed is HTML. | ||
*/ | ||
private boolean html = true; | ||
|
||
/** | ||
* Backing model for this popover's title. | ||
*/ | ||
private IModel<String> titleModel; | ||
|
||
/** | ||
* Backing model for this popover. | ||
*/ | ||
private IModel<String> model; | ||
|
||
/** | ||
* Creates a new instance. | ||
* | ||
* @param component | ||
* Target component for the overlay | ||
*/ | ||
public Popover(Component component, IModel<String> titleModel, IModel<String> model) { | ||
super(component); | ||
this.titleModel = titleModel; | ||
this.model = model; | ||
} | ||
|
||
/** | ||
* Returns the placement of this popover. | ||
* | ||
* @return String with placement value | ||
*/ | ||
public String getPlacement() { | ||
return placement; | ||
} | ||
|
||
/** | ||
* Sets the placement of this popover. | ||
* | ||
* @param placement | ||
* New value | ||
*/ | ||
public void setPlacement(String placement) { | ||
this.placement = placement; | ||
} | ||
|
||
/** | ||
* Sets the placement of this popover. | ||
* | ||
* @param placement | ||
* New value | ||
* @return This instance | ||
*/ | ||
public Popover placement(String placement) { | ||
setPlacement(placement); | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns the value of the HTML flag for this popover. | ||
* | ||
* @return Value of the HTML flag | ||
*/ | ||
public boolean getHtml() { | ||
return html; | ||
} | ||
|
||
/** | ||
* Sets the value of the HTML flag for this popover. | ||
* | ||
* @param html | ||
* New value | ||
*/ | ||
public void setHtml(boolean html) { | ||
this.html = html; | ||
} | ||
|
||
/** | ||
* Sets the value of the HTML flag for this popover. | ||
* | ||
* @param html | ||
* New value | ||
* @return This instance | ||
*/ | ||
public Popover html(boolean html) { | ||
setHtml(html); | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns the model for this popover. | ||
* | ||
* @return Backing model for the popover | ||
*/ | ||
public IModel<String> getModel() { | ||
return model; | ||
} | ||
|
||
/** | ||
* Sets the model for this popover. | ||
* | ||
* @param model | ||
* New value | ||
*/ | ||
public void setModel(IModel<String> model) { | ||
this.model = model; | ||
} | ||
|
||
/** | ||
* Sets the model for this popover. | ||
* | ||
* @param model | ||
* New value | ||
* @return This instance | ||
*/ | ||
public Popover model(IModel<String> model) { | ||
setModel(model); | ||
return this; | ||
} | ||
|
||
/** | ||
* Sets the position of the overlay. | ||
* | ||
* @param position | ||
* Coordinate for the overlay's position | ||
* @return This instance | ||
*/ | ||
@Override | ||
public Popover position(LongLat position) { | ||
setPosition(position); | ||
return this; | ||
} | ||
|
||
/** | ||
* Sets the positioning of this overlay. | ||
* | ||
* @param positioning | ||
* New value | ||
* @return This instance | ||
*/ | ||
@Override | ||
public Popover positioning(Positioning positioning) { | ||
setPositioning(positioning); | ||
return this; | ||
} | ||
|
||
/** | ||
* Sets the element tied to this popover. | ||
* | ||
* @param element | ||
* Wicket component | ||
* @return This instance | ||
*/ | ||
@Override | ||
public Popover element(Component element) { | ||
setElement(element); | ||
return this; | ||
} | ||
|
||
/** | ||
* Sets the stopEvent value. | ||
* | ||
* @param stopEvent | ||
* New value | ||
* @return this instance | ||
*/ | ||
@Override | ||
public Popover stopEvent(Boolean stopEvent) { | ||
setStopEvent(stopEvent); | ||
return this; | ||
} | ||
|
||
/** | ||
* Displays the popover. | ||
* | ||
* @param target | ||
* Ajax request target | ||
* @return This instance | ||
*/ | ||
public Popover show(AjaxRequestTarget target) { | ||
hide(target); | ||
target.appendJavaScript(renderPopoverJs()); | ||
return this; | ||
} | ||
|
||
/** | ||
* Hides this popover. | ||
* | ||
* @param target | ||
* Ajax request target | ||
* @return This instance | ||
*/ | ||
public Popover hide(AjaxRequestTarget target) { | ||
target.appendJavaScript("$(" + getJsId() + ".getElement()).popover('dispose');"); | ||
return this; | ||
} | ||
|
||
@Override | ||
public String getJsId() { | ||
return "popup_" + element.getMarkupId(); | ||
} | ||
|
||
/** | ||
* Renders the Javascript for the popover. | ||
* | ||
* @return String with the rendered Javascript | ||
*/ | ||
private String renderPopoverJs() { | ||
|
||
StringBuilder builder = new StringBuilder(); | ||
|
||
// get a handle on our popup | ||
builder.append("var popup = " + getJsId() + ";"); | ||
builder.append("var element = popup.getElement();"); | ||
|
||
// set the new position of the popup | ||
builder.append("popup.setPosition(" + position.renderJs() + ");"); | ||
|
||
// inital popup settings | ||
builder.append("$(element).popover({"); | ||
builder.append("'trigger': 'manual', 'animation': false,"); | ||
if (titleModel != null) { | ||
builder.append("'title': '" + escapeQuoteJs(titleModel.getObject()) + "',"); | ||
} | ||
if (placement != null) { | ||
builder.append("'placement': '" + placement + "',"); | ||
} | ||
builder.append("'html': " + html + ","); | ||
if (html) { | ||
builder.append("'content': '" + escapeQuoteJs(model.getObject()) + "',"); | ||
} else { | ||
builder.append("'content': '" + Strings.escapeMarkup(model.getObject()) + "',"); | ||
} | ||
builder.append("});"); | ||
|
||
// update popup content | ||
if(titleModel != null) { | ||
builder.append("$(element).data('original-title', '"); | ||
builder.append(escapeQuoteJs(titleModel.getObject())); | ||
builder.append("');"); | ||
} else { | ||
builder.append("$(element).data('original-title', '');"); | ||
} | ||
if (html) { | ||
builder.append("$(element).attr('data-content', '" + escapeQuoteJs(model.getObject()) + "');"); | ||
} else { | ||
builder.append("$(element).attr('data-content', '" + Strings.escapeMarkup(model.getObject()) + "');"); | ||
} | ||
|
||
// show our popup | ||
builder.append("$(element).popover('show');"); | ||
|
||
return builder.toString(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...ers3-bootstrap4/src/main/java/org/wicketstuff/openlayers3/api/overlay/PopoverOverlay.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.wicketstuff.openlayers3.api.overlay; | ||
|
||
import org.wicketstuff.openlayers3.component.MarkerPopover; | ||
|
||
/** | ||
* Provides an object that models a map overlay containing a popover. | ||
*/ | ||
public class PopoverOverlay extends Overlay { | ||
|
||
/** | ||
* Creates a new instance. | ||
* | ||
* @param markerPopover | ||
* The marker and popover linked to this overlay | ||
*/ | ||
public PopoverOverlay(MarkerPopover markerPopover) { | ||
super(markerPopover, markerPopover.getPositionModel().getObject(), DEFAULT_POSITIONING, DEFAULT_STOP_EVENT); | ||
} | ||
|
||
@Override | ||
public String getJsId() { | ||
return "popover_overlay_" + element.getMarkupId(); | ||
} | ||
} |
Oops, something went wrong.