Search in sources :

Example 16 with JavaScriptExecutor

use of org.eclipse.rap.rwt.client.service.JavaScriptExecutor in project rap by entirej.

the class RWTUtils method patchClient.

public static void patchClient(String conext, String timeoutPage) {
    // https://github.com/eclipse/rap/blob/master/bundles/org.eclipse.rap.rwt/js/rwt/runtime/ErrorHandler.js
    JavaScriptExecutor executor = RWT.getClient().getService(JavaScriptExecutor.class);
    StringBuilder builder = new StringBuilder();
    builder.append("(function() {");
    builder.append("console.log('patchClient');");
    builder.append(" var errorHandler = rwt.runtime.ErrorHandler;");
    builder.append(" var origShowErrorBox = rwt.util.Functions.bind(errorHandler.showErrorBox, errorHandler );");
    builder.append(" errorHandler.showErrorBox = function( errorType,freeze, errorDetails ) {");
    builder.append("console.log(errorType +' - '+errorDetails);");
    // enable if IE issue with connections
    // builder.append(" if( errorType === \"connection error\" ) {");
    // builder.append(" settimeout( function() {");
    // builder.append(" rwt.remote.Connection.getInstance()._retry();");
    // builder.append(" }, 100 );} else");
    builder.append(" if( errorType === \"session timeout\" || errorType === \"client error\" ) {");
    if (timeoutPage == null || timeoutPage.isEmpty())
        builder.append(" parent.window.location.href = this._getRestartURL();");
    else
        builder.append(" parent.window.location.href = \"").append(timeoutPage).append("\";");
    builder.append("                                            ");
    builder.append("                                            ");
    builder.append("                                            ");
    builder.append("                                            ");
    builder.append(" } else {");
    builder.append(" origShowErrorBox( errorType, freeze,errorDetails );");
    builder.append(" }");
    builder.append(" };");
    builder.append("}() );");
    // System.err.println(builder.toString());
    executor.execute(builder.toString());
}
Also used : JavaScriptExecutor(org.eclipse.rap.rwt.client.service.JavaScriptExecutor)

Example 17 with JavaScriptExecutor

use of org.eclipse.rap.rwt.client.service.JavaScriptExecutor in project rap by entirej.

the class EJRwtSpringAuthUtil method logout.

public static void logout() {
    StringBuffer url = new StringBuffer();
    url.append(RWT.getRequest().getContextPath());
    String encodeURL = RWT.getResponse().encodeURL(url.toString());
    if (encodeURL.contains("jsessionid")) {
        encodeURL = encodeURL.substring(0, encodeURL.indexOf("jsessionid"));
    }
    encodeURL += "logout";
    String browserText = MessageFormat.format("parent.window.location.href = \"{0}\";", encodeURL);
    JavaScriptExecutor executor = RWT.getClient().getService(JavaScriptExecutor.class);
    if (executor != null) {
        executor.execute(browserText);
    }
}
Also used : JavaScriptExecutor(org.eclipse.rap.rwt.client.service.JavaScriptExecutor)

Aggregations

JavaScriptExecutor (org.eclipse.rap.rwt.client.service.JavaScriptExecutor)17 File (java.io.File)3 IOException (java.io.IOException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 NXCSession (org.netxms.client.NXCSession)2 RandomAccessFile (java.io.RandomAccessFile)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Properties (java.util.Properties)1 UUID (java.util.UUID)1 NotDefinedException (org.eclipse.core.commands.common.NotDefinedException)1 IStatus (org.eclipse.core.runtime.IStatus)1 BindingManager (org.eclipse.jface.bindings.BindingManager)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 Window (org.eclipse.jface.window.Window)1 CBanner (org.eclipse.swt.custom.CBanner)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 MouseListener (org.eclipse.swt.events.MouseListener)1 GridData (org.eclipse.swt.layout.GridData)1