use of com.servoy.j2db.IFormController in project servoy-client by Servoy.
the class NGClient method refreshI18n.
private void refreshI18n() {
if (locale == null) {
return;
}
if (!("".equals(locale.getLanguage()) && "".equals(locale.getCountry()))) {
getWebsocketSession().getClientService(NGClient.APPLICATION_SERVICE).executeAsyncServiceCall("setLocale", new Object[] { locale.getLanguage(), locale.getCountry() });
}
// flush the valuelist cache so that all valuelist are recreated with the new locale keys
ComponentFactory.flushAllValueLists(this, false);
List<IFormController> allControllers = getFormManager().getCachedFormControllers();
for (IFormController fc : allControllers) {
IWebFormUI formUI = (IWebFormUI) fc.getFormUI();
Collection<WebComponent> components = formUI.getComponents();
for (WebComponent component : components) {
if (component instanceof WebFormComponent) {
NGUtils.resetI18NProperties((WebFormComponent) component, component.getSpecification());
}
}
}
}
use of com.servoy.j2db.IFormController in project servoy-client by Servoy.
the class NGRuntimeWindow method hideUI.
@Override
public void hideUI() {
visible = false;
getApplication().getWebsocketSession().getClientService(NGRuntimeWindowManager.WINDOW_SERVICE).executeAsyncServiceCall("hide", new Object[] { getName() });
// assume that just after hiding the window, currentController in js is the main window controller
JSWindow parent = getParent();
IFormController formController = null;
if (parent != null) {
formController = parent.getImpl().getController();
getApplication().getRuntimeWindowManager().setCurrentWindowName(parent.getImpl().getName());
} else if (getApplication().getRuntimeWindowManager().getMainApplicationWindow() != null) {
if (getApplication().getRuntimeWindowManager().getMainApplicationWindow() != null)
formController = getApplication().getRuntimeWindowManager().getMainApplicationWindow().getController();
}
if (formController instanceof IWebFormController)
getApplication().getFormManager().setCurrentControllerJS((IWebFormController) formController);
// resume
if (windowType == JSWindow.MODAL_DIALOG && getApplication().getWebsocketSession().getEventDispatcher() != null) {
final IEventDispatcher eventDispatcher = getApplication().getWebsocketSession().getEventDispatcher();
if (eventDispatcher.isEventDispatchThread()) {
eventDispatcher.resume(this);
} else {
eventDispatcher.addEvent(new Runnable() {
@Override
public void run() {
eventDispatcher.resume(NGRuntimeWindow.this);
}
});
}
}
}
use of com.servoy.j2db.IFormController in project servoy-client by Servoy.
the class RhinoConversion method defaultFromRhino.
/**
* Default conversion used to convert from Rhino property types that do not explicitly implement component <-> Rhino conversions. <BR/><BR/>
* Values of types that don't implement the sablo <-> rhino conversions are by default accessible directly.
*/
@SuppressWarnings("unchecked")
public static // PropertyDescription / IWebObjectContext ... can be made available here if needed
Object defaultFromRhino(// PropertyDescription / IWebObjectContext ... can be made available here if needed
Object propertyValue, // PropertyDescription / IWebObjectContext ... can be made available here if needed
Object oldValue) {
// convert simple values to json values
if (isUndefinedOrNotFound(propertyValue)) {
return null;
}
if (propertyValue instanceof NativeDate) {
return ((NativeDate) propertyValue).unwrap();
}
if (propertyValue instanceof NativeObject) {
Map<String, Object> map = new HashMap<>();
Map<String, Object> oldMap = (oldValue instanceof Map) ? (Map<String, Object>) oldValue : null;
NativeObject no = (NativeObject) propertyValue;
Object[] ids = no.getIds();
for (Object id2 : ids) {
Object value = null;
if (id2 instanceof String) {
value = no.get((String) id2, no);
} else if (id2 instanceof Symbol) {
value = no.get((Symbol) id2, no);
} else if (id2 instanceof Number) {
value = no.get(((Number) id2).intValue(), no);
}
String id = String.valueOf(id2);
map.put(id, defaultFromRhino(value, oldMap != null ? oldMap.get(id) : null));
}
return map;
}
if (propertyValue instanceof NativeArray) {
List<Object> list = new ArrayList<Object>();
List<Object> oldList = (oldValue instanceof List) ? (List<Object>) oldValue : null;
final NativeArray no = (NativeArray) propertyValue;
final long naLength = no.getLength();
for (int id = 0; id < naLength; id++) {
list.add(defaultFromRhino(no.get(id, no), oldList != null && oldList.size() > id ? oldList.get(id) : null));
}
return list;
}
if (propertyValue instanceof FormScope && ((FormScope) propertyValue).getFormController() != null)
return ((FormScope) propertyValue).getFormController().getName();
if (propertyValue instanceof IFormController)
return ((IFormController) propertyValue).getName();
if (propertyValue instanceof JSDataSet) {
return ((JSDataSet) propertyValue).getDataSet();
}
if (propertyValue instanceof RhinoMapOrArrayWrapper) {
return ((RhinoMapOrArrayWrapper) propertyValue).getWrappedValue();
}
if (propertyValue instanceof CharSequence) {
return propertyValue.toString();
}
return propertyValue;
}
use of com.servoy.j2db.IFormController in project servoy-client by Servoy.
the class WebFormController method showNavigator.
@Override
public void showNavigator(List<Runnable> invokeLaterRunnables) {
String parentWindowName = getFormUI().getParentWindowName();
NGRuntimeWindow window = getApplication().getRuntimeWindowManager().getWindow(parentWindowName);
if (window != null && window.getController() == this) {
IFormController currentNavigator = window.getNavigator();
int form_id = form.getNavigatorID();
if (form_id > 0) {
if (// is already there
currentNavigator == null || currentNavigator.getForm().getID() != form_id) {
if (currentNavigator != null) {
currentNavigator.notifyVisible(false, invokeLaterRunnables);
}
Form navigator = application.getFlattenedSolution().getForm(form_id);
if (navigator != null) {
IFormController navigatorController = getApplication().getFormManager().getForm(navigator.getName());
navigatorController.notifyVisible(true, invokeLaterRunnables);
}
} else {
// Try to lease it extra so it will be added to last used screens.
Form navigator = application.getFlattenedSolution().getForm(form_id);
if (navigator != null) {
getBasicFormManager().leaseFormPanel(navigator.getName());
}
}
} else if (form_id != Form.NAVIGATOR_IGNORE) {
if (currentNavigator != null)
currentNavigator.notifyVisible(false, invokeLaterRunnables);
}
window.setNavigator(form_id);
}
}
use of com.servoy.j2db.IFormController in project servoy-client by Servoy.
the class CreationalPrototype method get.
@Override
public Object get(java.lang.String name, Scriptable start) {
if (// $NON-NLS-1$
"allnames".equals(name)) {
ArrayList<String> al = new ArrayList<String>();
IBasicFormManager fm = application.getFormManager();
if (fm == null)
throw new IllegalStateException(// should never happen during normal operation; see case 251716
"Trying to access forms after client was shut down? This JS code was probably running decoupled from client shut down but at the same time.");
Iterator<String> it = fm.getPossibleFormNames();
while (it.hasNext()) {
al.add(it.next());
}
Context.enter();
try {
return new NativeJavaArray(this, al.toArray());
} finally {
Context.exit();
}
}
Object o = super.get(name, start);
if ((o == null || o == Scriptable.NOT_FOUND)) {
IBasicFormManager fm = application.getFormManager();
if (fm == null)
throw new IllegalStateException(// should never happen during normal operation; see case 251716
"Trying to access forms after client was shut down? This JS code was probably running decoupled from client shut down but at the same time.");
if (!fm.isPossibleForm(name)) {
return o;
}
Context.enter();
try {
// $NON-NLS-1$ //$NON-NLS-2$
Debug.trace("CreationalPrototype:get " + name + " scope " + start);
if (!application.isEventDispatchThread()) {
// $NON-NLS-1$ //$NON-NLS-2$
Debug.log("Form " + name + " is not created because it is CreationalPrototype.get(formname) is called outside of the event thread");
// $NON-NLS-1$ //$NON-NLS-2$
return "<Form " + name + " not loaded yet>";
}
IFormController fp = fm.leaseFormPanel(name);
if (fp != null) {
// This registers the object in this scopes, this must called before anything else! (to prevent repeative calls/lookups here)
fp.initForJSUsage(this);
// re-get
o = super.get(name, this);
}
if (o == null)
o = Scriptable.NOT_FOUND;
} finally {
Context.exit();
}
}
if (o instanceof FormScope) {
IFormController fp = ((FormScope) o).getFormController();
fp.setView(fp.getView());
fp.executeOnLoadMethod();
try {
if (!fp.isShowingData()) {
if (fp.wantEmptyFoundSet()) {
if (fp.getFormModel() != null)
fp.getFormModel().clear();
} else {
fp.loadAllRecordsImpl(true);
}
}
} catch (Exception ex) {
Debug.error(ex);
// $NON-NLS-1$
application.handleException(application.getI18NMessage("servoy.formPanel.error.formData"), ex);
}
}
return o;
}
Aggregations