use of com.servoy.j2db.dnd.JSDNDEvent in project servoy-client by Servoy.
the class ScrollResponseHeaderContainer method createScriptEvent.
public JSDNDEvent createScriptEvent(EventType type, IComponent dragSource, Point xy, int modifiers) {
JSDNDEvent jsEvent = new JSDNDEvent();
jsEvent.setType(type);
jsEvent.setFormName(getDragFormName());
if (dragSource instanceof IDataRenderer) {
IDataRenderer dr = (IDataRenderer) dragSource;
FormController fct = dr.getDataAdapterList().getFormController();
jsEvent.setSource(fct.getFormScope());
} else {
jsEvent.setSource(dragSource);
if (dragSource != null) {
if (dragSource instanceof Component) {
WebCellBasedViewListItem listItem = ((Component) dragSource).findParent(WebCellBasedViewListItem.class);
if (listItem != null) {
IRecordInternal dragRecord = listItem.getModelObject();
if (dragRecord instanceof Record)
jsEvent.setRecord((Record) dragRecord);
}
}
String dragSourceName = dragSource.getName();
if (dragSourceName == null)
dragSourceName = dragSource.getId();
jsEvent.setElementName(dragSourceName);
}
}
if (xy != null)
jsEvent.setLocation(xy);
jsEvent.setModifiers(modifiers);
return jsEvent;
}
use of com.servoy.j2db.dnd.JSDNDEvent in project servoy-client by Servoy.
the class WebDataRenderer method createScriptEvent.
private JSDNDEvent createScriptEvent(EventType type, IComponent dragSource, Point xy, int modifiers) {
JSDNDEvent jsEvent = new JSDNDEvent();
jsEvent.setType(type);
jsEvent.setFormName(getDragFormName());
IRecordInternal dragRecord = getDragRecord(xy);
if (dragRecord instanceof Record)
jsEvent.setRecord((Record) dragRecord);
if (dragSource instanceof IDataRenderer) {
IDataRenderer dr = (IDataRenderer) dragSource;
FormController fct = dr.getDataAdapterList().getFormController();
jsEvent.setSource(fct.getFormScope());
} else {
jsEvent.setSource(dragSource);
if (dragSource != null) {
String dragSourceName = dragSource.getName();
if (dragSourceName == null)
dragSourceName = dragSource.getId();
jsEvent.setElementName(dragSourceName);
}
}
if (xy != null)
jsEvent.setLocation(xy);
jsEvent.setModifiers(modifiers);
return jsEvent;
}
use of com.servoy.j2db.dnd.JSDNDEvent in project servoy-client by Servoy.
the class WebDataRenderer method addDragNDropBehavior.
private void addDragNDropBehavior() {
DraggableBehavior dragBehavior = new DraggableBehavior() {
private IComponent hoverComponent;
private boolean isHoverAcceptDrop;
@Override
protected void onDragEnd(String id, int x, int y, int m, AjaxRequestTarget ajaxRequestTarget) {
if (getCurrentDragOperation() != DRAGNDROP.NONE) {
JSDNDEvent event = WebDataRenderer.this.createScriptEvent(EventType.onDragEnd, getDragComponent(), null, m);
event.setData(getDragData());
event.setDataMimeType(getDragDataMimeType());
event.setDragResult(getDropResult() ? getCurrentDragOperation() : DRAGNDROP.NONE);
WebDataRenderer.this.onDragEnd(event);
}
super.onDragEnd(id, x, y, m, ajaxRequestTarget);
}
@Override
protected boolean onDragStart(final String id, int x, int y, int m, AjaxRequestTarget ajaxRequestTarget) {
IComponent comp = getBindedComponentChild(id);
JSDNDEvent event = WebDataRenderer.this.createScriptEvent(EventType.onDrag, comp, new Point(x, y), m);
setDropResult(false);
int dragOp = WebDataRenderer.this.onDrag(event);
if (dragOp == DRAGNDROP.NONE)
return false;
setCurrentDragOperation(dragOp);
setDragComponent(comp);
setDragData(event.getData(), event.getDataMimeType());
hoverComponent = null;
isHoverAcceptDrop = false;
return true;
}
@Override
protected void onDrop(String id, final String targetid, int x, int y, int m, AjaxRequestTarget ajaxRequestTarget) {
if (getCurrentDragOperation() != DRAGNDROP.NONE) {
IComponent comp = getBindedComponentChild(targetid);
if (hoverComponent == comp && !isHoverAcceptDrop)
return;
WebDataRenderer renderer = WebDataRenderer.this;
JSDNDEvent event = renderer.createScriptEvent(EventType.onDrop, comp, new Point(x, y), m);
event.setData(getDragData());
event.setDataMimeType(getDragDataMimeType());
setDropResult(renderer.onDrop(event));
}
}
// private ISupportDragNDrop testTarget(ISupportDragNDrop ddComp, JSEvent event)
// {
// if (event.js_getSource() instanceof SpecialTabPanel)
// {
// SpecialTabPanel tabPanel = (SpecialTabPanel)event.js_getSource();
// Component selectedComponent = tabPanel.getEnclosingComponent().getSelectedComponent();
// if (selectedComponent instanceof FormLookupPanel)
// {
// FormController formControler = ((FormLookupPanel)selectedComponent).getFormPanel();
// event.setSource(null);
// event.setFormName(formControler.getName());
// event.setElementName(null);
// return (ISupportDragNDrop)formControler.getViewComponent();
// }
// }
// return ddComp;
// }
@Override
protected void onDropHover(String id, final String targetid, int m, AjaxRequestTarget ajaxRequestTarget) {
if (getCurrentDragOperation() != DRAGNDROP.NONE) {
IComponent comp = getBindedComponentChild(targetid);
JSDNDEvent event = WebDataRenderer.this.createScriptEvent(EventType.onDragOver, comp, null, m);
event.setData(getDragData());
event.setDataMimeType(getDragDataMimeType());
isHoverAcceptDrop = WebDataRenderer.this.onDragOver(event);
hoverComponent = comp;
}
}
@Override
public IComponent getBindedComponentChild(final String childId) {
IComponent comp = super.getBindedComponentChild(childId);
if (comp == null)
comp = WebDataRenderer.this;
return comp;
}
};
dragBehavior.setUseProxy(true);
add(dragBehavior);
}
use of com.servoy.j2db.dnd.JSDNDEvent in project servoy-client by Servoy.
the class JSDNDEventType method fromJSON.
@Override
public JSDNDEvent fromJSON(Object newJSONValue, JSDNDEvent previousSabloValue, PropertyDescription pd, IBrowserConverterContext dataConverterContext, ValueReference<Boolean> returnValueAdjustedIncommingValue) {
JSDNDEvent event = null;
if (newJSONValue instanceof JSONObject) {
JSONObject jsonObject = (JSONObject) newJSONValue;
// $NON-NLS-1$
event = getReference(jsonObject.optString("jseventhash"));
if (event == null) {
BaseWebObject webObject = dataConverterContext.getWebObject();
event = new JSDNDEvent();
JSEventType.fillJSEvent(event, jsonObject, webObject, null);
}
}
return event;
}
use of com.servoy.j2db.dnd.JSDNDEvent in project servoy-client by Servoy.
the class ScrollResponseHeaderContainer method addDragNDropBehavior.
private void addDragNDropBehavior() {
DraggableBehavior compDragBehavior = new DraggableBehavior() {
private IComponent hoverComponent;
private boolean isHoverAcceptDrop;
@Override
protected void onDragEnd(String id, int x, int y, int m, AjaxRequestTarget ajaxRequestTarget) {
if (getCurrentDragOperation() != DRAGNDROP.NONE) {
JSDNDEvent event = WebCellBasedView.this.createScriptEvent(EventType.onDragEnd, getDragComponent(), null, m);
event.setData(getDragData());
event.setDataMimeType(getDragDataMimeType());
event.setDragResult(getDropResult() ? getCurrentDragOperation() : DRAGNDROP.NONE);
WebCellBasedView.this.onDragEnd(event);
}
super.onDragEnd(id, x, y, m, ajaxRequestTarget);
}
@Override
protected boolean onDragStart(final String id, int x, int y, int m, AjaxRequestTarget ajaxRequestTarget) {
IComponent comp = getBindedComponentChild(id);
JSDNDEvent event = WebCellBasedView.this.createScriptEvent(EventType.onDrag, comp, new Point(x, y), m);
int dragOp = WebCellBasedView.this.onDrag(event);
if (dragOp == DRAGNDROP.NONE)
return false;
setCurrentDragOperation(dragOp);
setDragData(event.getData(), event.getDataMimeType());
setDragComponent(comp);
setDropResult(false);
hoverComponent = null;
isHoverAcceptDrop = false;
return true;
}
@Override
protected void onDrop(String id, final String targetid, int x, int y, int m, AjaxRequestTarget ajaxRequestTarget) {
if (getCurrentDragOperation() != DRAGNDROP.NONE) {
IComponent comp = getBindedComponentChild(targetid);
if (hoverComponent == comp && !isHoverAcceptDrop)
return;
JSDNDEvent event = WebCellBasedView.this.createScriptEvent(EventType.onDrop, comp, new Point(x, y), m);
event.setData(getDragData());
event.setDataMimeType(getDragDataMimeType());
setDropResult(WebCellBasedView.this.onDrop(event));
}
}
@Override
protected void onDropHover(String id, final String targetid, int m, AjaxRequestTarget ajaxRequestTarget) {
if (getCurrentDragOperation() != DRAGNDROP.NONE) {
IComponent comp = getBindedComponentChild(targetid);
JSDNDEvent event = WebCellBasedView.this.createScriptEvent(EventType.onDragOver, comp, null, m);
event.setData(getDragData());
event.setDataMimeType(getDragDataMimeType());
isHoverAcceptDrop = WebCellBasedView.this.onDragOver(event);
hoverComponent = comp;
}
}
@Override
public IComponent getBindedComponentChild(final String childId) {
IComponent comp = super.getBindedComponentChild(childId);
if (comp == null)
comp = WebCellBasedView.this;
return comp;
}
};
compDragBehavior.setUseProxy(true);
add(compDragBehavior);
}
Aggregations