/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.tridium.sys.resource.ResourceReport * javax.baja.agent.AgentList * javax.baja.log.Log * javax.baja.sys.Action * javax.baja.sys.BComplex * javax.baja.sys.BComponent * javax.baja.sys.BIcon * javax.baja.sys.BObject * javax.baja.sys.BValue * javax.baja.sys.Context * javax.baja.sys.Flags * javax.baja.sys.Property * javax.baja.sys.Slot * javax.baja.sys.SlotCursor * javax.baja.sys.Sys * javax.baja.sys.Type */ package com.tridium.program; import com.tridium.program.BProgramAction; import com.tridium.program.BProgramCode; import com.tridium.program.ProgramBase; import com.tridium.program.module.BProgramModule; import com.tridium.sys.resource.ResourceReport; import java.io.File; import javax.baja.agent.AgentList; import javax.baja.log.Log; import javax.baja.sys.Action; import javax.baja.sys.BComplex; import javax.baja.sys.BComponent; import javax.baja.sys.BIcon; import javax.baja.sys.BObject; import javax.baja.sys.BValue; import javax.baja.sys.Context; import javax.baja.sys.Flags; import javax.baja.sys.Property; import javax.baja.sys.Slot; import javax.baja.sys.SlotCursor; import javax.baja.sys.Sys; import javax.baja.sys.Type; /* * Illegal identifiers - consider using --renameillegalidents true */ public class BProgram extends BComponent { public static final Property code = BProgram.newProperty((int)0, (BValue)new BProgramCode(), null); public static final Action execute = BProgram.newAction((int)16, null); public static final Type TYPE; private static final BIcon icon; static final Log log; ProgramBase impl; static /* synthetic */ Class class$com$tridium$program$BProgram; public BProgramCode getCode() { return (BProgramCode)this.get(code); } public void setCode(BProgramCode bProgramCode) { this.set(code, (BValue)bProgramCode, null); } public void execute() { this.invoke(execute, null, null); } public Type getType() { return TYPE; } public void started() { this.loadImpl(); } public void stopped() { this.unloadImpl(); } public void changed(Property property, Context context) { super.changed(property, context); if (!this.isRunning()) { return; } if (property == code) { this.loadImpl(); } else if (Flags.isExecuteOnChange((BComplex)this, (Slot)property)) { this.execute(); } } public void doExecute() { try { this.impl.onExecute(); } catch (Throwable throwable) { this.error("onExecute", throwable); } } private final void loadImpl() { this.unloadImpl(); this.impl = this.getCode().newProgramInstance(); this.impl.program = this; this.updateActionParameters(this.impl); try { this.impl.onStart(); } catch (Throwable throwable) { this.error("onStart", throwable); } } public final void updateActionParameters() { this.impl = this.getCode().newProgramInstance(); this.impl.program = this; this.updateActionParameters(this.impl); } private final void updateActionParameters(ProgramBase programBase) { SlotCursor slotCursor = this.getProperties(); while (slotCursor.nextObject()) { BObject bObject = slotCursor.get(); if (!(bObject instanceof BProgramAction)) continue; ((BProgramAction)bObject).updateParameter(programBase); } } private final void unloadImpl() { try { this.impl.onStop(); } catch (Throwable throwable) { this.error("onStop", throwable); } this.impl = new ProgramBase(); } public void error(String string, Throwable throwable) { log.error("\"" + this.toPathString() + '.' + string + '\"', throwable); } public final Object fw(int n, Object object, Object object2, Object object3, Object object4) { if (n == 21) { ((ResourceReport)object).add("program", 3000); } return super.fw(n, object, object2, object3, object4); } public AgentList getAgents(Context context) { AgentList agentList = super.getAgents(context); agentList.toTop("workbench:PropertySheet"); return agentList; } public BIcon getIcon() { return icon; } public BProgramModule getProgramModule() { BComplex bComplex = this.getParent(); while (bComplex != null) { if (bComplex instanceof BProgramModule) { return (BProgramModule)bComplex; } bComplex = bComplex.getParent(); } return null; } public static boolean isSpecialModule(String string) { File file; File file2 = new File(Sys.getBajaHome(), "bin"); return file2.exists() && (file = new File(file2, string + ".jar")).exists(); } static /* synthetic */ Class class(String string, boolean bl) { try { Class clazz = Class.forName(string); if (!bl) { clazz = clazz.getComponentType(); } return clazz; } catch (ClassNotFoundException classNotFoundException) { throw new NoClassDefFoundError(classNotFoundException.getMessage()); } } private final /* synthetic */ void this() { this.impl = new ProgramBase(); } public BProgram() { this.this(); } static { Class clazz = class$com$tridium$program$BProgram; if (clazz == null) { clazz = class$com$tridium$program$BProgram = BProgram.class("[Lcom.tridium.program.BProgram;", false); } TYPE = Sys.loadType((Class)clazz); icon = BIcon.std((String)"script.png"); log = Log.getLog((String)"sys.program"); } }