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