blob: 4234ee6306368f4eb16e8673a8cfbff47e5ff89d [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2013 EclipseSource and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* EclipseSource - initial API and implementation
******************************************************************************/
package org.eclipse.rap.clientscripting;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.remote.Connection;
import org.eclipse.rap.rwt.remote.RemoteObject;
public class Script {
private static final String REMOTE_TYPE = "rwt.scripting.Script";
private final RemoteObject remoteObject;
/**
* Provisional/Experimental
*/
public Script( String scriptCode ) {
if( scriptCode == null ) {
throw new NullPointerException( "Parameter is null: scriptCode" );
}
Connection connection = RWT.getUISession().getConnection();
remoteObject = connection.createRemoteObject( REMOTE_TYPE );
remoteObject.set( "text", scriptCode );
}
public String getId() {
return remoteObject.getId();
}
public void dispose() {
remoteObject.destroy();
}
}