use of com.servoy.j2db.server.ngclient.WebFormComponent in project servoy-client by Servoy.
the class TagStringPropertyType method toSabloComponentValue.
@Override
public BasicTagStringTypeSabloValue toSabloComponentValue(Object rhinoValue, BasicTagStringTypeSabloValue previousComponentValue, PropertyDescription pd, IWebObjectContext componentOrService) {
if (rhinoValue != null && !RhinoConversion.isUndefinedOrNotFound(rhinoValue)) {
// this code can interpret the new value as a static one or a a tag-aware one depending on the property's config: USE_PARSED_VALUE_IN_RHINO_CONFIG_OPT
String newDesignValue = rhinoValue instanceof String ? (String) rhinoValue : rhinoValue.toString();
DataAdapterList dal = previousComponentValue != null ? previousComponentValue.getDataAdapterList() : null;
if (dal == null && componentOrService != null && componentOrService.getUnderlyingWebObject() instanceof WebFormComponent) {
dal = (DataAdapterList) ((WebFormComponent) componentOrService.getUnderlyingWebObject()).getDataAdapterList();
}
return createNewTagStringTypeSabloValue(newDesignValue, dal, !((TagStringConfig) pd.getConfig()).useParsedValueInRhino(), true, pd, componentOrService.getUnderlyingWebObject() instanceof WebFormComponent ? ((WebFormComponent) componentOrService.getUnderlyingWebObject()) : null, ((IContextProvider) componentOrService.getUnderlyingWebObject()).getDataConverterContext().getApplication(), false);
}
return null;
}
use of com.servoy.j2db.server.ngclient.WebFormComponent in project servoy-client by Servoy.
the class ValueListTypeSabloValue method filterValuelist.
/**
* Filters the values of the valuelist for type-ahead-like usage.
*/
private void filterValuelist(JSONObject newJSONValue) {
if (!initialized) {
Debug.warn("Trying to send to client an uninitialized valuelist property: " + vlPD + " of " + webObjectContext);
return;
}
this.valuesRequested = true;
this.handledIDForResponse = Long.valueOf(newJSONValue.getLong(ID_KEY));
String filterString = newJSONValue.optString(FILTER);
if (filteredValuelist == null) {
filteredValuelist = createFilteredValueList();
if (filteredValuelist != null) {
filteredValuelist.addListDataListener(new ListDataListener() {
@Override
public void intervalRemoved(ListDataEvent e) {
changeMonitor.markFullyChanged(true);
}
@Override
public void intervalAdded(ListDataEvent e) {
changeMonitor.markFullyChanged(true);
}
@Override
public void contentsChanged(ListDataEvent e) {
changeMonitor.markFullyChanged(true);
}
});
}
}
if (filteredValuelist != null) {
try {
valueList.removeListDataListener(this);
Object realValue = dataAdapterListToUse.getValueObject(dataAdapterListToUse.getRecord(), dataproviderID);
// do mark it as changed but don't notify yet (false arg) because fill below will probably trigger listener above and notify anyway; that would mean that although
// we do call notify after fill that is likely to end up in a NO_OP changesToJSON in case of foundset-linked valuelist properties
changeMonitor.markFullyChanged(false);
boolean useContains = Utils.getAsBoolean(dataAdapterListToUse.getApplication().getClientProperty(IApplication.VALUELIST_CONTAINS_SEARCH));
if (!useContains && webObjectContext != null && webObjectContext.getUnderlyingWebObject() instanceof WebFormComponent) {
WebFormComponent webObject = (WebFormComponent) webObjectContext.getUnderlyingWebObject();
RuntimeWebComponent webComponentElement = dataAdapterListToUse.getForm().getWebComponentElement(webObject.getFormElement().getRawName());
if (webComponentElement != null && webComponentElement.getPrototype() instanceof RuntimeLegacyComponent) {
RuntimeLegacyComponent legacy = (RuntimeLegacyComponent) webComponentElement.getPrototype();
useContains = Utils.getAsBoolean(legacy.getClientProperty(IApplication.VALUELIST_CONTAINS_SEARCH, legacy));
}
}
if (useContains && filterString != null)
filterString = '%' + filterString;
filteredValuelist.fill(dataAdapterListToUse.getRecord(), dataproviderID, filterString, realValue, false);
// in case fill really somehow did not result in the filteredValuelist listener doing a notify
changeMonitor.notifyOfChange();
valueList.addListDataListener(this);
} catch (ServoyException e) {
Debug.error(e);
}
}
}
use of com.servoy.j2db.server.ngclient.WebFormComponent in project servoy-client by Servoy.
the class RuntimeWebGroup method setLocation.
private void setLocation(int x, int y) {
Rectangle bounds = getBounds();
int dx = x - bounds.x;
int dy = y - bounds.y;
for (RuntimeWebComponent obj : runtimeWebComponents) {
WebFormComponent component = obj.getComponent();
Point location = (Point) component.getProperty("location");
putProperty("location", new Object[] { location.x + dx, location.y + dy }, component);
}
}
use of com.servoy.j2db.server.ngclient.WebFormComponent in project servoy-client by Servoy.
the class RuntimeWebGroup method setSize.
private void setSize(int width, int height) {
Rectangle bounds = getBounds();
float scalew = ((float) width) / bounds.width;
float scaleh = ((float) height) / bounds.height;
for (RuntimeWebComponent obj : runtimeWebComponents) {
WebFormComponent component = obj.getComponent();
Point location = (Point) component.getProperty("location");
putProperty("location", new Object[] { bounds.x + (int) Math.floor(scalew * (location.x - bounds.x)), bounds.y + (int) Math.floor(scaleh * (location.y - bounds.y)) }, component);
Dimension size = (Dimension) component.getProperty("size");
putProperty("size", new Object[] { (int) Math.floor(scalew * size.width), (int) Math.floor(scaleh * size.height) }, component);
}
}
use of com.servoy.j2db.server.ngclient.WebFormComponent in project servoy-client by Servoy.
the class WebFormController method notifyVisible.
@Override
public boolean notifyVisible(boolean visible, List<Runnable> invokeLaterRunnables) {
if (isFormVisible == visible)
return true;
if (!visible && destroyOnHide) {
Runnable run = new Runnable() {
public void run() {
destroy();
}
};
invokeLaterRunnables.add(run);
}
boolean notifyVisibleSuccess = super.notifyVisible(visible, invokeLaterRunnables);
if (notifyVisibleSuccess) {
for (WebComponent comp : getFormUI().getComponents()) {
RuntimeWebComponent runtimeComponent = getFormUI().getRuntimeWebComponent(comp.getName());
if (runtimeComponent != null) {
WebObjectFunctionDefinition function = null;
if (visible)
function = comp.getSpecification().getInternalApiFunction("onShow");
else
function = comp.getSpecification().getInternalApiFunction("onHide");
if (function != null) {
runtimeComponent.executeScopeFunction(function, new Object[0]);
}
}
}
}
if (visible && !isFormVisible) {
// note: the show operation (visible = true in if above) of a form cannot be denied, so we can update things before the call to super.notifyVisible below
for (WebComponent comp : getFormUI().getComponents()) {
if ((comp instanceof WebFormComponent) && ((WebFormComponent) comp).getFormElement().getPersistIfAvailable() instanceof TabPanel) {
Object visibleTabPanel = comp.getProperty("visible");
if (visibleTabPanel instanceof Boolean && !((Boolean) visibleTabPanel).booleanValue())
continue;
Object tabIndex = comp.getProperty("tabIndex");
Object tabs = comp.getProperty("tabs");
if (tabs instanceof List && ((List) tabs).size() > 0) {
List tabsList = (List) tabs;
TabPanel tabpanel = (TabPanel) ((WebFormComponent) comp).getFormElement().getPersistIfAvailable();
if (tabpanel.getTabOrientation() == TabPanel.SPLIT_HORIZONTAL || tabpanel.getTabOrientation() == TabPanel.SPLIT_VERTICAL) {
for (Object element : tabsList) {
Map<String, Object> tab = (Map<String, Object>) element;
if (tab != null) {
String relationName = tab.get("relationName") != null ? tab.get("relationName").toString() : null;
Object tabForm = tab.get("containsFormId");
if (tabForm != null) {
getFormUI().getDataAdapterList().addVisibleChildForm(getApplication().getFormManager().getForm(tabForm.toString()), relationName, true);
}
}
}
} else {
Map<String, Object> visibleTab = null;
if (tabIndex instanceof Number && tabsList.size() > 0 && ((Number) tabIndex).intValue() <= tabsList.size()) {
int index = ((Number) tabIndex).intValue() - 1;
if (index < 0) {
index = 0;
}
visibleTab = (Map<String, Object>) (tabsList.get(index));
} else if (tabIndex instanceof String || tabIndex instanceof CharSequence) {
for (Object element : tabsList) {
Map<String, Object> tab = (Map<String, Object>) element;
if (Utils.equalObjects(tabIndex, tab.get("name"))) {
visibleTab = tab;
break;
}
}
}
if (visibleTab != null) {
String relationName = visibleTab.get("relationName") != null ? visibleTab.get("relationName").toString() : null;
Object tabForm = visibleTab.get("containsFormId");
if (tabForm != null) {
getFormUI().getDataAdapterList().addVisibleChildForm(getApplication().getFormManager().getForm(tabForm.toString()), relationName, true);
}
}
}
}
}
}
}
// TODO should notifyVisibleSuccess be altered here? See WebFormUI/WebFormComponent notifyVisible calls.
if (notifyVisibleSuccess)
notifyVisibleOnChildren(visible, invokeLaterRunnables);
return notifyVisibleSuccess;
}
Aggregations