1 50 51 package org.openlaszlo.iv.flash.commands; 52 53 import org.openlaszlo.iv.flash.parser.*; 54 import org.openlaszlo.iv.flash.api.*; 55 import org.openlaszlo.iv.flash.util.*; 56 57 import org.openlaszlo.iv.flash.context.*; 58 import java.io.*; 59 60 68 public class SetEnvironmentCommand extends GenericCommand { 69 70 public SetEnvironmentCommand() { 71 } 72 73 public void doCommand( FlashFile file, Context context, Script parent, int frame ) throws IVException { 74 String datasource = getParameter( context, "datasource" ); 75 76 if( datasource != null ) { 77 try { 78 if( context instanceof FakeContext ) { 79 80 Context myContext = ContextFactory.createContext( context.getParent(), datasource, file, false ); 81 82 ((FakeContext)context).setContext( myContext ); 83 84 } else { 85 if( !(context instanceof StandardContext) ) { 90 throw new IVException( Resource.EXPECTSTDCONTEXT ); 91 } 92 93 String [][] data = ContextFactory.readStandardContext( datasource, file ); 95 ContextFactory.setStandardContextData( (StandardContext) context, data ); 96 } 97 } catch( IOException e ) { 98 throw new IVException(Resource.ERRDATAREAD, new Object [] {datasource, getCommandName()}, e); 99 } catch( Exception e ) { 100 throw new IVException(Resource.INVALDATASOURCE, new Object [] {datasource, getCommandName()}, e); 101 } 102 } 103 } 104 105 public boolean isGlobal() { 106 return true; 107 } 108 } 109 | Popular Tags |