use of com.servoy.j2db.IBasicFormManager in project servoy-client by Servoy.
the class RuntimeWindow method showObject.
public void showObject(Object form) throws ServoyException {
String f = null;
if (form instanceof BasicFormController) {
f = ((BasicFormController) form).getName();
} else if (form instanceof FormScope) {
f = ((FormScope) form).getFormController().getName();
} else if (form instanceof FormController.JSForm) {
f = ((FormController.JSForm) form).getFormPanel().getName();
} else if (form instanceof String) {
f = (String) form;
} else if (form instanceof JSForm) {
f = ((JSForm) form).getName();
}
if (f != null) {
Form frm = application.getFlattenedSolution().getForm(f);
IBasicFormManager fm = application.getFormManager();
if (frm == null && fm.isPossibleForm(f))
frm = fm.getPossibleForm(f);
if (!application.getFlattenedSolution().formCanBeInstantiated(frm)) {
// abstract form
throw new ApplicationException(ServoyException.ABSTRACT_FORM, new Object[] { f });
}
show(f);
}
}
use of com.servoy.j2db.IBasicFormManager 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;
}
use of com.servoy.j2db.IBasicFormManager in project servoy-client by Servoy.
the class CreationalPrototype method getInitializedIds.
/**
* @see org.eclipse.dltk.rhino.dbgp.LazyInitScope#getInitializedIds()
*/
public Object[] getInitializedIds() {
ArrayList<String> al = new ArrayList<String>();
// $NON-NLS-1$
al.add("allnames");
// $NON-NLS-1$
al.add("length");
IBasicFormManager fm = application.getFormManager();
if (fm == null)
return new Object[0];
Iterator<String> it = fm.getPossibleFormNames();
while (it.hasNext()) {
String form = it.next();
Object o = super.get(form, this);
if (o != null && o != Scriptable.NOT_FOUND) {
if (o instanceof FormScope) {
IFormController fp = ((FormScope) o).getFormController();
if (!fp.isShowingData())
continue;
}
al.add(form);
}
}
return al.toArray();
}
Aggregations