Skip to content

Commit

Permalink
Merge pull request #959 from chongma/master
Browse files Browse the repository at this point in the history
Add openstreetmap
  • Loading branch information
TheCoder4eu authored Jul 9, 2018
2 parents cf96ab3 + 84828fd commit 0d9c635
Show file tree
Hide file tree
Showing 9 changed files with 892 additions and 231 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ src-gen
/.apt_generated/
/infer-out/
/mavenResources/META-INF/licenses
/doc/
318 changes: 90 additions & 228 deletions src/main/java/net/bootsfaces/component/ComponentsEnum.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
import javax.faces.component.FacesComponent;

import net.bootsfaces.component.ajax.IAJAXComponent2;
import net.bootsfaces.component.navLink.NavLink;
import net.bootsfaces.component.navCommandLink.NavCommandLink;

/** This class holds the attributes of <b:commandLink />. */
@ListenersFor({ @ListenerFor(systemEventClass = PostAddToViewEvent.class) })
@FacesComponent("net.bootsfaces.component.commandLink.CommandLink")
public class CommandLink extends NavLink implements IAJAXComponent2 {
public class CommandLink extends NavCommandLink implements IAJAXComponent2 {
public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
if (isAutoUpdate()) {
if (FacesContext.getCurrentInstance().isPostback()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/**
* Copyright 2014-2017 Riccardo Massera (TheCoder4.Eu) and Stephan Rauh (http://www.beyondjava.net).
*
* This file is part of BootsFaces.
*
* 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 net.bootsfaces.component.openStreetMap;

import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ComponentSystemEvent;
import javax.faces.event.ListenerFor;
import javax.faces.event.ListenersFor;
import javax.faces.event.PostAddToViewEvent;

import javax.el.ValueExpression;
import javax.faces.component.FacesComponent;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.component.UIViewRoot;
import javax.faces.component.behavior.ClientBehaviorHolder;
import javax.faces.event.FacesEvent;

import net.bootsfaces.C;
import net.bootsfaces.listeners.AddResourcesListener;
import net.bootsfaces.render.Tooltip;
import net.bootsfaces.utils.BsfUtils;

/** This class holds the attributes of <b:openStreetMap />. */
@ListenersFor({ @ListenerFor(systemEventClass = PostAddToViewEvent.class) })
@FacesComponent(OpenStreetMap.COMPONENT_TYPE)
public class OpenStreetMap extends OpenStreetMapCore implements ClientBehaviorHolder {

public static final String COMPONENT_TYPE = C.BSFCOMPONENT + ".openStreetMap.OpenStreetMap";

public static final String COMPONENT_FAMILY = C.BSFCOMPONENT;

public static final String DEFAULT_RENDERER = "net.bootsfaces.component.openStreetMap.OpenStreetMap";

// private static final Collection<String> EVENT_NAMES = Collections.unmodifiableCollection(Arrays.asList("click",
// "dblclick", "dragstart", "dragover", "drop", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup"));

public OpenStreetMap() {
setRendererType(DEFAULT_RENDERER);
Tooltip.addResourceFiles();
// AddResourcesListener.addThemedCSSResource("core.css");
// AddResourcesListener
// .addResourceIfNecessary("https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/images/layers-2x.png");
// AddResourcesListener
// .addResourceIfNecessary("https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/images/layers.png");
// AddResourcesListener.addResourceIfNecessary(
// "https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/images/marker-icon-2x.png");
// AddResourcesListener
// .addResourceIfNecessary("https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/images/marker-icon.png");
// AddResourcesListener.addResourceIfNecessary(
// "https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/images/marker-shadow.png");
AddResourcesListener
.addResourceIfNecessary("https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet-src.js");
AddResourcesListener
.addResourceIfNecessary("https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet-src.js.map");
AddResourcesListener.addResourceIfNecessary("https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet.css");
AddResourcesListener.addResourceIfNecessary("https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet.js");
AddResourcesListener
.addResourceIfNecessary("https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet.js.map");
}

public void setValueExpression(String name, ValueExpression binding) {
name = BsfUtils.snakeCaseToCamelCase(name);
super.setValueExpression(name, binding);
}

@Override
public boolean getRendersChildren() {
return true;
}

// public Collection<String> getEventNames() {
// return EVENT_NAMES;
// }

// public String getDefaultEventName() {
// return "click";
// }

public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
// if (isAutoUpdate()) {
// if (FacesContext.getCurrentInstance().isPostback()) {
// FacesContext.getCurrentInstance().getPartialViewContext().getRenderIds().add(getClientId());
// }
// super.processEvent(event);
// }
}

public String getFamily() {
return COMPONENT_FAMILY;
}

/**
* <p>
* Queue an event for broadcast at the end of the current request processing
* lifecycle phase. The default implementation in {@link UIComponentBase} must
* delegate this call to the <code>queueEvent()</code> method of the parent
* {@link UIComponent}.
* </p>
*
* @param event {@link FacesEvent} to be queued
*
* @throws IllegalStateException if this component is not a descendant of a
* {@link UIViewRoot}
* @throws NullPointerException if <code>event</code> is <code>null</code>
*/
public void queueEvent(FacesEvent event) {
FacesContext context = FacesContext.getCurrentInstance();
String indexes = (String) context.getExternalContext().getRequestParameterMap().get("indexes");
context.getELContext().getELResolver().setValue(context.getELContext(), null, "indexes", indexes);
String typeOfSelection = (String) context.getExternalContext().getRequestParameterMap().get("typeOfSelection");
context.getELContext().getELResolver().setValue(context.getELContext(), null, "typeOfSelection",
typeOfSelection);
try {
int oldIndex = getRowIndex();
int index = Integer.valueOf(indexes);
setRowIndex(index);
super.queueEvent(event);
setRowIndex(oldIndex);
} catch (Exception multipleIndexes) {
super.queueEvent(event);

}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package net.bootsfaces.component.openStreetMap;

import net.bootsfaces.beans.BsfBeanInfo;

/**
* BeanInfo class to provide mapping
* of snake-case attributes to camelCase ones
*
* @author durzod
*/
public class OpenStreetMapBeanInfo extends BsfBeanInfo {
/**
* Get the reference decorated class
*/
@Override
public Class<?> getDecoratedClass() {
return OpenStreetMap.class;
}
}
Loading

0 comments on commit 0d9c635

Please sign in to comment.