use of com.servoy.j2db.IServiceProvider in project servoy-client by Servoy.
the class SessionClient method executeMethod.
/*
* _______________________________________________________________________________
*/
public synchronized Object executeMethod(String visibleFormName, String methodName, Object[] arguments) throws Exception {
Object retval = null;
IServiceProvider prev = testThreadLocals();
try {
String formName = visibleFormName;
if (formName == null && ((FormManager) getFormManager()).getCurrentForm() != null) {
formName = ((FormManager) getFormManager()).getCurrentForm().getName();
}
if (formName != null) {
FormController fp = ((FormManager) getFormManager()).leaseFormPanel(formName);
if (fp != null && fp.isFormVisible()) {
return fp.executeFunction(methodName, arguments, true, null, false, null);
} else {
// $NON-NLS-1$
throw new IllegalStateException("Cannot call method on non visible form " + formName);
}
} else {
// $NON-NLS-1$
throw new IllegalArgumentException("No current visible form specified");
}
} catch (IllegalStateException e1) {
throw e1;
} catch (IllegalArgumentException e2) {
throw e2;
} catch (Exception e) {
Debug.error(e);
} finally {
unsetThreadLocals(prev);
}
return retval;
}
use of com.servoy.j2db.IServiceProvider in project servoy-client by Servoy.
the class SessionClient method loadSolution.
@Override
protected void loadSolution(SolutionMetaData solutionMeta) throws RepositoryException {
IServiceProvider prev = testThreadLocals();
try {
// make sure a new one in started if a new solution is loaded
performanceData = null;
loadSolutionsAndModules(solutionMeta);
setAjaxUsage(solutionMeta.getName());
enableAnchors(solutionMeta.getName());
getScriptEngine();
} finally {
unsetThreadLocals(prev);
}
// Note that getSolution() may return null at this point if the security.closeSolution() or security.logout() was called in onSolutionOpen
}
use of com.servoy.j2db.IServiceProvider in project servoy-client by Servoy.
the class FormCssResource method getResourceStream.
/**
* @see org.apache.wicket.Resource#getResourceStream()
*/
@Override
public IResourceStream getResourceStream() {
String css = "";
ValueMap params = getParameters();
Long time = null;
if (params.size() == 1) {
Iterator iterator = params.entrySet().iterator();
if (iterator.hasNext()) {
Map.Entry entry = (Entry) iterator.next();
String solutionName = (String) entry.getKey();
Pair<String, Long> filterTime = filterTime((String) entry.getValue());
String formInstanceName = filterTime.getLeft();
time = filterTime.getRight();
// $NON-NLS-1$
String solutionAndForm = solutionName + "/" + formInstanceName;
// $NON-NLS-1$
String templateDir = "default";
IServiceProvider sp = null;
Solution solution = null;
Form form = null;
if (Session.exists()) {
sp = WebClientSession.get().getWebClient();
if (sp != null) {
IForm fc = ((WebClient) sp).getFormManager().getForm(formInstanceName);
if (fc instanceof FormController) {
FlattenedSolution clientSolution = sp.getFlattenedSolution();
form = clientSolution.getForm(((FormController) fc).getForm().getName());
}
}
templateDir = WebClientSession.get().getTemplateDirectoryName();
}
final String fullpath = "/servoy-webclient/templates/" + templateDir + "/" + solutionAndForm + ".css";
try {
URL url = context.getResource(fullpath);
if (url != null) {
return new NullUrlResourceStream(url);
}
} catch (Exception e) {
Debug.error(e);
}
try {
IApplicationServerSingleton as = ApplicationServerRegistry.get();
RootObjectMetaData sd = as.getLocalRepository().getRootObjectMetaData(solutionName, IRepository.SOLUTIONS);
if (sd != null) {
solution = (Solution) as.getLocalRepository().getActiveRootObject(sd.getRootObjectId());
if (form == null) {
form = solution.getForm(formInstanceName);
}
}
if (form != null) {
Pair<String, String> formHTMLAndCSS = TemplateGenerator.getFormHTMLAndCSS(solution, form, sp, formInstanceName);
css = formHTMLAndCSS.getRight();
}
} catch (Exception e) {
Debug.error(e);
}
}
}
// $NON-NLS-1$
StringResourceStream stream = new StringResourceStream(css, "text/css");
stream.setLastModified(time != null ? Time.valueOf(time.longValue()) : null);
return stream;
}
use of com.servoy.j2db.IServiceProvider in project servoy-client by Servoy.
the class ServoyDebugger method getFrame.
/**
* @see org.eclipse.dltk.rhino.dbgp.DBGPDebugger#getFrame(org.mozilla.javascript.Context, org.mozilla.javascript.debug.DebuggableScript)
*/
@Override
public DebugFrame getFrame(Context cx, DebuggableScript fnOrScript) {
final IServiceProvider client = J2DBGlobals.getServiceProvider();
if (profilelisteners.size() > 0) {
ProfileInfo info = profileInfo.get();
return new ServoyDebugFrame(cx, fnOrScript, this, info != null ? info.peek() : null);
}
return new DBGPDebugFrame(cx, fnOrScript, this) {
@Override
public Object eval(String value) {
if (client != null && J2DBGlobals.getServiceProvider() == null) {
J2DBGlobals.setServiceProvider(client);
}
boolean reset = false;
try {
if (client instanceof NGClient && !CurrentWindow.exists()) {
// make sure that for an NGClient the current window is set.
CurrentWindow.set(new NGClientWebsocketSessionWindows(((NGClient) client).getWebsocketSession()));
reset = true;
}
return super.eval(value);
} finally {
if (reset)
CurrentWindow.set(null);
}
}
};
}
use of com.servoy.j2db.IServiceProvider in project servoy-client by Servoy.
the class ScriptVariableScope method evalValue.
private Object evalValue(String name, String str, String sourceName, int lineNumber) {
Object retValue = null;
Context cx = Context.enter();
boolean debug = cx.isGeneratingDebug();
int level = cx.getOptimizationLevel();
Debugger debugger = cx.getDebugger();
Object debuggerContextData = cx.getDebuggerContextData();
try {
cx.setGeneratingDebug(lineNumber != -1);
if (// flag should only be used in rich client //$NON-NLS-1$
lineNumber != -1 || Utils.getAsBoolean(System.getProperty(ScriptEngine.SERVOY_DISABLE_SCRIPT_COMPILE_PROPERTY, "false"))) {
cx.setOptimizationLevel(-1);
} else {
cx.setOptimizationLevel(9);
}
// cx.setDebugger(null, null);
Object o = cx.evaluateString(this, str, sourceName, lineNumber == -1 ? 0 : lineNumber, null);
if (o instanceof Wrapper && !(o instanceof NativeArray) && !(o instanceof NativeJavaClass)) {
o = ((Wrapper) o).unwrap();
}
if (o == Scriptable.NOT_FOUND || o == Undefined.instance) {
o = null;
}
retValue = o;
Integer previousType = null;
if (retValue instanceof Date) {
// this is really an instance of Date so the type should be reset to that.
previousType = nameType.put(name, new Integer(IColumnTypes.DATETIME));
} else if (retValue instanceof XMLObject) {
previousType = nameType.put(name, new Integer(Types.OTHER));
} else if (retValue instanceof Number) {
Integer prevType = nameType.get(name);
if (prevType == null || !(prevType.intValue() == IColumnTypes.NUMBER || prevType.intValue() == IColumnTypes.INTEGER)) {
previousType = nameType.put(name, new Integer(IColumnTypes.NUMBER));
}
} else if (!(retValue instanceof String) && !(retValue == null && nameType.get(name) != null)) {
// this is not an instanceof a String and a Date so make it a
previousType = nameType.put(name, new Integer(IColumnTypes.MEDIA));
}
if (previousType != null) {
if (replacedNameType == null) {
replacedNameType = new HashMap<String, Integer>(3);
replacedNameType.put(name, previousType);
} else if (!replacedNameType.containsKey(name)) {
replacedNameType.put(name, previousType);
}
}
} catch (Exception ex) {
IServiceProvider serviceProvider = J2DBGlobals.getServiceProvider();
if (serviceProvider != null) {
serviceProvider.reportJSError("cant parse variable '" + name + '\'', ex);
} else {
// $NON-NLS-1$
Debug.log("cant parse variable '" + name + '\'', ex);
}
} finally {
try {
cx.setGeneratingDebug(debug);
cx.setOptimizationLevel(level);
cx.setDebugger(debugger, debuggerContextData);
} finally {
Context.exit();
}
}
return retValue;
}
Aggregations