use of org.primefaces.event.organigram.OrganigramNodeDragDropEvent in project primefaces by primefaces.
the class Organigram method queueEvent.
@Override
public void queueEvent(FacesEvent event) {
FacesContext context = getFacesContext();
if (ComponentUtils.isRequestSource(this, context) && event instanceof AjaxBehaviorEvent) {
Map<String, String> params = context.getExternalContext().getRequestParameterMap();
String eventName = params.get(Constants.RequestParams.PARTIAL_BEHAVIOR_EVENT_PARAM);
String clientId = getClientId(context);
FacesEvent wrapperEvent = null;
AjaxBehaviorEvent behaviorEvent = (AjaxBehaviorEvent) event;
if ("expand".equals(eventName)) {
OrganigramNode node = findTreeNode(getValue(), params.get(clientId + "_expandNode"));
node.setExpanded(true);
wrapperEvent = new OrganigramNodeExpandEvent(this, behaviorEvent.getBehavior(), node);
} else if ("collapse".equals(eventName)) {
OrganigramNode node = findTreeNode(getValue(), params.get(clientId + "_collapseNode"));
node.setExpanded(false);
wrapperEvent = new OrganigramNodeCollapseEvent(this, behaviorEvent.getBehavior(), node);
} else if ("select".equals(eventName) || "contextmenu".equals(eventName)) {
OrganigramNode node = findTreeNode(getValue(), params.get(clientId + "_selectNode"));
wrapperEvent = new OrganigramNodeSelectEvent(this, behaviorEvent.getBehavior(), node);
} else if ("dragdrop".equals(eventName)) {
OrganigramNode dragNode = findTreeNode(getValue(), params.get(clientId + "_dragNode"));
OrganigramNode dropNode = findTreeNode(getValue(), params.get(clientId + "_dropNode"));
// remove node from current parent
if (dragNode != null && dropNode != null) {
OrganigramNode sourceNode = dragNode.getParent();
if (sourceNode != null) {
sourceNode.getChildren().remove(dragNode);
}
// set new parent
dragNode.setParent(dropNode);
wrapperEvent = new OrganigramNodeDragDropEvent(this, behaviorEvent.getBehavior(), dragNode, dropNode, sourceNode);
}
}
if (wrapperEvent == null) {
throw new FacesException("Component " + this.getClass().getName() + " does not support event " + eventName + "!");
}
wrapperEvent.setPhaseId(behaviorEvent.getPhaseId());
super.queueEvent(wrapperEvent);
} else {
super.queueEvent(event);
}
}
Aggregations