link start!

This commit is contained in:
cherubin
2026-03-17 13:31:18 -07:00
commit 08abe87cfb
5910 changed files with 386288 additions and 0 deletions
@@ -0,0 +1,329 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.sys.Nre
* com.tridium.sys.module.ModuleClassLoader
* com.tridium.sys.module.NModule
* javax.baja.log.Log
* javax.baja.naming.SlotPath
* javax.baja.nre.util.Array
* javax.baja.security.BPermissions
* javax.baja.sys.BBlob
* javax.baja.sys.BModule
* javax.baja.sys.BValue
* javax.baja.sys.BVector
* javax.baja.sys.Context
* javax.baja.sys.Property
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.util.BUuid
*/
package com.tridium.program;
import com.tridium.program.BProgram;
import com.tridium.program.BProgramService;
import com.tridium.sys.Nre;
import com.tridium.sys.module.ModuleClassLoader;
import com.tridium.sys.module.NModule;
import java.security.SecureClassLoader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;
import javax.baja.log.Log;
import javax.baja.naming.SlotPath;
import javax.baja.nre.util.Array;
import javax.baja.security.BPermissions;
import javax.baja.sys.BBlob;
import javax.baja.sys.BModule;
import javax.baja.sys.BValue;
import javax.baja.sys.BVector;
import javax.baja.sys.Context;
import javax.baja.sys.Property;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.util.BUuid;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class BCode
extends BVector {
public static final Property className = BCode.newProperty((int)1, (String)"", null);
public static final Property classFile = BCode.newProperty((int)1, (BValue)BBlob.DEFAULT, null);
public static final Property dependencies = BCode.newProperty((int)1, (String)"", null);
public static final Type TYPE;
public static final Log log;
static Object loadLock;
static ProgramClassLoader classLoader;
static HashMap loadClassFiles;
static HashMap loadDependsMap;
static ModuleClassLoader[] loadDepends;
static /* synthetic */ Class class$com$tridium$program$BCode;
static /* synthetic */ Class class$com$tridium$program$BCode$ProgramClassEntry;
static /* synthetic */ Class class$javax$baja$sys$BBlob;
public String getClassName() {
return this.getString(className);
}
public void setClassName(String string) {
this.setString(className, string, null);
}
public BBlob getClassFile() {
return (BBlob)this.get(classFile);
}
public void setClassFile(BBlob bBlob) {
this.set(classFile, (BValue)bBlob, null);
}
public String getDependencies() {
return this.getString(dependencies);
}
public void setDependencies(String string) {
this.setString(dependencies, string, null);
}
public Type getType() {
return TYPE;
}
/*
* Unable to fully structure code
*/
public Object newInstance() throws Exception {
var1_1 = this.getClassName();
if (var1_1.length() == 0) {
throw new IllegalStateException("Empty className");
}
if (var1_1.equals("ProgramImpl") || var1_1.equals("RobotImpl")) {
throw new IllegalStateException("Must run programs thru program:com.tridium.program.RecompileTool");
}
var2_2 = this.getClassFile();
if (var2_2.length() == 0) {
throw new IllegalStateException("Empty classFile");
}
var3_3 = this.resolveDependencies();
v0 = BCode.class$com$tridium$program$BCode$ProgramClassEntry;
if (v0 == null) {
v0 = BCode.class$com$tridium$program$BCode$ProgramClassEntry = BCode.class("[Lcom.tridium.program.BCode$ProgramClassEntry;", false);
}
var4_4 = new Array(v0);
var5_5 = this.getProperties();
if (true) ** GOTO lbl20
do {
if (var5_5.property().isDynamic()) {
var4_4.add((Object)new ProgramClassEntry(SlotPath.unescape((String)var5_5.property().getName()), ((BBlob)var5_5.get()).copyBytes()));
}
lbl20:
// 4 sources
if ((v1 = BCode.class$javax$baja$sys$BBlob) != null) continue;
v1 = BCode.class("[Ljavax.baja.sys.BBlob;", false);
} while (var5_5.next(v1));
var5_5 = BCode.loadClass(var1_1, var2_2.copyBytes(), (ProgramClassEntry[])var4_4.trim(), var3_3);
return var5_5.newInstance();
}
public String[] parseDependencies() {
ArrayList<String> arrayList = new ArrayList<String>();
StringTokenizer stringTokenizer = new StringTokenizer(this.getDependencies(), ";");
while (stringTokenizer.hasMoreTokens()) {
String string = stringTokenizer.nextToken().trim();
if (string.length() <= 0 || BProgram.isSpecialModule(string)) continue;
arrayList.add(string);
}
return arrayList.toArray(new String[arrayList.size()]);
}
private final ModuleClassLoader[] resolveDependencies() throws Exception {
ArrayList<ModuleClassLoader> arrayList = new ArrayList<ModuleClassLoader>();
String[] stringArray = this.parseDependencies();
int n = 0;
while (n < stringArray.length) {
BModule bModule = Sys.loadModule((String)stringArray[n]);
NModule nModule = Nre.moduleManager.loadModule(bModule.getModuleName());
ModuleClassLoader moduleClassLoader = nModule.getClassLoader();
if (moduleClassLoader != null) {
arrayList.add(moduleClassLoader);
}
++n;
}
return arrayList.toArray(new ModuleClassLoader[arrayList.size()]);
}
/*
* Unable to fully structure code
*/
public void clearInnerClassFiles() {
var1_1 = this.getProperties();
if (true) ** GOTO lbl6
do {
if (var1_1.property().isDynamic()) {
this.remove(var1_1.property());
}
lbl6:
// 4 sources
if ((v0 = BCode.class$javax$baja$sys$BBlob) != null) continue;
v0 = BCode.class("[Ljavax.baja.sys.BBlob;", false);
} while (var1_1.next(v0));
}
public void addInnerClassFile(String string, BBlob bBlob) throws Exception {
String string2 = SlotPath.escape((String)string);
Property property = this.getProperty(string2);
if (property == null) {
this.add(string2, (BValue)bBlob, 1);
} else {
this.set(string2, (BValue)bBlob);
}
}
public static String generateClassName() {
BUuid bUuid = BUuid.make();
return "Prog_" + Long.toHexString(bUuid.getMostSignificant()) + Long.toHexString(bUuid.getLeastSignificant());
}
static Class loadClass(String string, byte[] byArray, ModuleClassLoader[] moduleClassLoaderArray) throws ClassNotFoundException {
return BCode.loadClass(string, byArray, null, moduleClassLoaderArray);
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Unable to fully structure code
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
static Class loadClass(String var0, byte[] var1_1, ProgramClassEntry[] var2_2, ModuleClassLoader[] var3_3) throws ClassNotFoundException {
var4_4 = BCode.loadLock;
synchronized (var4_4) {
block7: {
if (BCode.classLoader == null) {
BCode.classLoader = new ProgramClassLoader();
BCode.loadDependsMap = new HashMap<K, V>();
BCode.loadClassFiles = new HashMap<K, V>();
}
var7_5 = 0;
while (true) {
block8: {
if (var7_5 < var3_3.length) break block8;
BCode.loadDepends = BCode.loadDependsMap.values().toArray(new ModuleClassLoader[BCode.loadDependsMap.size()]);
BCode.loadClassFiles.put(var0, var1_1);
if (var2_2 == null) break block7;
var7_5 = 0;
if (true) ** GOTO lbl32
}
var8_6 = var3_3[var7_5];
var9_7 = var8_6.module.getModuleName();
if (BCode.loadDependsMap.get(var9_7) == null) {
BCode.loadDependsMap.put(var9_7, var8_6);
}
++var7_5;
}
do {
BCode.loadClassFiles.put(var2_2[var7_5].name, var2_2[var7_5].classFile);
++var7_5;
lbl32:
// 2 sources
} while (var7_5 < var2_2.length);
}
return BCode.classLoader.loadClass(var0);
}
}
public final BPermissions getPermissions(Context context) {
BPermissions bPermissions = super.getPermissions(context);
if (BProgramService.REQUIRE_SUPER_USER_PERMISSION && context != null && context.getUser() != null && !context.getUser().getPermissions().isSuperUser()) {
int n = 0;
if (bPermissions.hasOperatorRead()) {
n |= 1;
}
if (bPermissions.hasAdminRead()) {
n |= 0x10;
}
bPermissions = BPermissions.make((int)n);
}
return bPermissions;
}
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());
}
}
static {
Class clazz = class$com$tridium$program$BCode;
if (clazz == null) {
clazz = class$com$tridium$program$BCode = BCode.class("[Lcom.tridium.program.BCode;", false);
}
TYPE = Sys.loadType((Class)clazz);
log = Log.getLog((String)"sys.program");
loadLock = new Object();
}
static class ProgramClassEntry {
String name;
byte[] classFile;
public ProgramClassEntry(String string, byte[] byArray) {
this.name = string;
this.classFile = byArray;
}
}
static class ProgramClassLoader
extends SecureClassLoader {
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public Class findClass(String string) throws ClassNotFoundException {
ModuleClassLoader[] moduleClassLoaderArray;
block7: {
byte[] byArray = null;
moduleClassLoaderArray = null;
Object object = loadLock;
synchronized (object) {
byArray = (byte[])loadClassFiles.get(string);
if (byArray != null) {
loadClassFiles.remove(string);
} else {
moduleClassLoaderArray = (ModuleClassLoader[])loadDepends.clone();
}
// MONITOREXIT @DISABLED, blocks:[0, 1] lbl12 : MonitorExitStatement: MONITOREXIT : var4_4
if (byArray == null) break block7;
return this.defineClass(string, byArray, 0, byArray.length);
}
}
int n = 0;
while (n < moduleClassLoaderArray.length) {
Class clazz = moduleClassLoaderArray[n].nload(string, false);
if (clazz != null) {
return clazz;
}
++n;
}
throw new ClassNotFoundException(string);
}
ProgramClassLoader() {
}
}
}
@@ -0,0 +1,211 @@
/*
* 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");
}
}
@@ -0,0 +1,265 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.sys.schema.Utils
* javax.baja.nre.util.TextUtil
* javax.baja.sys.BAction
* javax.baja.sys.BBoolean
* javax.baja.sys.BComplex
* javax.baja.sys.BComponent
* javax.baja.sys.BDouble
* javax.baja.sys.BFloat
* javax.baja.sys.BInteger
* javax.baja.sys.BLong
* javax.baja.sys.BString
* javax.baja.sys.BValue
* javax.baja.sys.BajaRuntimeException
* javax.baja.sys.Property
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.util.BTypeSpec
*/
package com.tridium.program;
import com.tridium.program.BProgram;
import com.tridium.program.ProgramBase;
import com.tridium.sys.schema.Utils;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.baja.nre.util.TextUtil;
import javax.baja.sys.BAction;
import javax.baja.sys.BBoolean;
import javax.baja.sys.BComplex;
import javax.baja.sys.BComponent;
import javax.baja.sys.BDouble;
import javax.baja.sys.BFloat;
import javax.baja.sys.BInteger;
import javax.baja.sys.BLong;
import javax.baja.sys.BString;
import javax.baja.sys.BValue;
import javax.baja.sys.BajaRuntimeException;
import javax.baja.sys.Property;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.util.BTypeSpec;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class BProgramAction
extends BAction {
public static final Property parameterTypeSpec = BProgramAction.newProperty((int)0, (BValue)BTypeSpec.NULL, null);
public static final Property returnTypeSpec = BProgramAction.newProperty((int)0, (BValue)BTypeSpec.NULL, null);
public static final Type TYPE;
static Object[] noArgs;
ProgramBase cachedImpl;
Method cachedMethod;
static /* synthetic */ Class class$com$tridium$program$BProgramAction;
public BTypeSpec getParameterTypeSpec() {
return (BTypeSpec)this.get(parameterTypeSpec);
}
public void setParameterTypeSpec(BTypeSpec bTypeSpec) {
this.set(parameterTypeSpec, (BValue)bTypeSpec, null);
}
public BTypeSpec getReturnTypeSpec() {
return (BTypeSpec)this.get(returnTypeSpec);
}
public void setReturnTypeSpec(BTypeSpec bTypeSpec) {
this.set(returnTypeSpec, (BValue)bTypeSpec, null);
}
public Type getType() {
return TYPE;
}
public final BProgram getProgram() {
return (BProgram)this.getParent();
}
public Type getParameterType() {
try {
BTypeSpec bTypeSpec = this.getParameterTypeSpec();
if (bTypeSpec.isNull()) {
return null;
}
return this.getParameterTypeSpec().getResolvedType();
}
catch (Exception exception) {
exception.printStackTrace();
return null;
}
}
public BValue getParameterDefault() {
try {
BTypeSpec bTypeSpec = this.getParameterTypeSpec();
if (bTypeSpec.isNull()) {
return null;
}
return (BValue)this.getParameterTypeSpec().getResolvedType().getInstance();
}
catch (Throwable throwable) {
throwable.printStackTrace();
return null;
}
}
public BValue invoke(BComponent bComponent, BValue bValue) {
block15: {
try {
BComplex bComplex = this.getParent();
if (!(bComplex instanceof BProgram)) break block15;
BProgram bProgram = (BProgram)bComplex;
ProgramBase programBase = bProgram.impl;
if (programBase == null) break block15;
if (programBase != this.cachedImpl) {
this.resolveCache(programBase);
}
if (this.cachedMethod == null) break block15;
if (this.cachedMethod.getParameterTypes().length == 1) {
Object[] objectArray;
try {
switch (Utils.getTypeAccess(this.cachedMethod.getParameterTypes()[0])) {
case 0: {
objectArray = new Object[]{new Boolean(((BBoolean)bValue).getBoolean())};
break;
}
case 2: {
objectArray = new Object[]{new Integer(((BInteger)bValue).getInt())};
break;
}
case 3: {
objectArray = new Object[]{new Long(((BLong)bValue).getLong())};
break;
}
case 4: {
objectArray = new Object[]{new Float(((BFloat)bValue).getFloat())};
break;
}
case 5: {
objectArray = new Object[]{new Double(((BDouble)bValue).getDouble())};
break;
}
case 6: {
objectArray = new Object[]{((BString)bValue).getString()};
break;
}
default: {
objectArray = new Object[]{bValue};
break;
}
}
}
catch (ClassCastException classCastException) {
throw new BajaRuntimeException("Value of type " + bValue.getType() + " not compatible with action parameter " + this.cachedMethod.getParameterTypes()[0]);
}
return (BValue)this.cachedMethod.invoke((Object)programBase, objectArray);
}
return (BValue)this.cachedMethod.invoke((Object)programBase, noArgs);
}
catch (InvocationTargetException invocationTargetException) {
invocationTargetException.getTargetException().printStackTrace();
}
catch (Throwable throwable) {
throwable.printStackTrace();
}
}
return null;
}
public Type getReturnType() {
try {
BTypeSpec bTypeSpec = this.getReturnTypeSpec();
if (bTypeSpec.isNull()) {
return null;
}
return bTypeSpec.getResolvedType();
}
catch (Exception exception) {
exception.printStackTrace();
return null;
}
}
void updateParameter(ProgramBase programBase) {
Class<?> clazz = null;
Class<?> clazz2 = null;
this.resolveCache(programBase);
if (this.cachedMethod == null) {
this.setParameterTypeSpec(BTypeSpec.NULL);
this.setReturnTypeSpec(BTypeSpec.NULL);
} else {
Type type;
try {
type = this.cachedMethod.getParameterTypes();
if (((Class<?>[])type).length == 0) {
this.setParameterTypeSpec(BTypeSpec.NULL);
} else {
clazz = type[0];
Type type2 = Sys.getType(clazz);
this.setParameterTypeSpec(type2.getTypeSpec());
}
}
catch (Exception exception) {
System.out.println("ERROR: Invalid parameter class " + this.getName() + ' ' + clazz);
exception.printStackTrace();
}
try {
clazz2 = this.cachedMethod.getReturnType();
if (clazz2 == Void.TYPE || clazz2 == null) {
this.setReturnTypeSpec(BTypeSpec.NULL);
} else {
type = Sys.getType(clazz2);
this.setReturnTypeSpec(type.getTypeSpec());
}
}
catch (Exception exception) {
System.out.println("ERROR: Invalid return class " + this.getName() + ' ' + clazz2);
exception.printStackTrace();
}
}
}
private final void resolveCache(ProgramBase programBase) {
this.cachedImpl = programBase;
this.cachedMethod = null;
String string = "on" + TextUtil.capitalize((String)this.getName());
Method[] methodArray = programBase.getClass().getMethods();
int n = 0;
while (n < methodArray.length) {
if (methodArray[n].getName().equals(string)) {
this.cachedMethod = methodArray[n];
break;
}
++n;
}
}
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());
}
}
static {
Class clazz = class$com$tridium$program$BProgramAction;
if (clazz == null) {
clazz = class$com$tridium$program$BProgramAction = BProgramAction.class("[Lcom.tridium.program.BProgramAction;", false);
}
TYPE = Sys.loadType((Class)clazz);
noArgs = new Object[0];
}
}
@@ -0,0 +1,95 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.sys.Property
* javax.baja.sys.Sys
* javax.baja.sys.Type
*/
package com.tridium.program;
import com.tridium.program.BCode;
import com.tridium.program.BProgram;
import com.tridium.program.ProgramBase;
import javax.baja.sys.Property;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class BProgramCode
extends BCode {
public static final Property className = BProgramCode.newProperty((int)BCode.className.getDefaultFlags(), (String)"ProgramImpl");
public static final Property checksum = BProgramCode.newProperty((int)1, (int)0, null);
public static final Property source = BProgramCode.newProperty((int)1, (String)"", null);
public static final Property userDefinedImports = BProgramCode.newProperty((int)1, (String)"", null);
public static final Type TYPE;
static /* synthetic */ Class class$com$tridium$program$BProgramCode;
public int getChecksum() {
return this.getInt(checksum);
}
public void setChecksum(int n) {
this.setInt(checksum, n, null);
}
public String getSource() {
return this.getString(source);
}
public void setSource(String string) {
this.setString(source, string, null);
}
public String getUserDefinedImports() {
return this.getString(userDefinedImports);
}
public void setUserDefinedImports(String string) {
this.setString(userDefinedImports, string, null);
}
public Type getType() {
return TYPE;
}
public final BProgram getProgram() {
return (BProgram)this.getParent();
}
public ProgramBase newProgramInstance() {
if (this.getClassFile().length() > 0) {
try {
return (ProgramBase)this.newInstance();
}
catch (Throwable throwable) {
log.error("Cannot load program code: " + this.toPathString(), throwable);
}
}
return new ProgramBase();
}
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());
}
}
static {
Class clazz = class$com$tridium$program$BProgramCode;
if (clazz == null) {
clazz = class$com$tridium$program$BProgramCode = BProgramCode.class("[Lcom.tridium.program.BProgramCode;", false);
}
TYPE = Sys.loadType((Class)clazz);
}
}
@@ -0,0 +1,111 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.util.ThrowableUtil
* javax.baja.security.PermissionException
* javax.baja.sys.Action
* javax.baja.sys.BComponent
* javax.baja.sys.BIService
* javax.baja.sys.BIcon
* javax.baja.sys.BValue
* javax.baja.sys.Context
* javax.baja.sys.Sys
* javax.baja.sys.Type
*/
package com.tridium.program;
import com.tridium.program.BRobotCode;
import com.tridium.program.BRobotResult;
import com.tridium.program.BatchRobot;
import com.tridium.program.Robot;
import com.tridium.util.ThrowableUtil;
import javax.baja.security.PermissionException;
import javax.baja.sys.Action;
import javax.baja.sys.BComponent;
import javax.baja.sys.BIService;
import javax.baja.sys.BIcon;
import javax.baja.sys.BValue;
import javax.baja.sys.Context;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class BProgramService
extends BComponent
implements BIService {
public static final Action runRobot = BProgramService.newAction((int)0, (BValue)new BRobotCode(), null);
public static final Type TYPE;
private static final BIcon icon;
public static final boolean REQUIRE_SUPER_USER_PERMISSION;
static /* synthetic */ Class class$com$tridium$program$BProgramService;
public BRobotResult runRobot(BRobotCode bRobotCode) {
return (BRobotResult)this.invoke(runRobot, (BValue)bRobotCode, null);
}
public Type getType() {
return TYPE;
}
public Type[] getServiceTypes() {
return new Type[]{TYPE};
}
public void serviceStarted() {
}
public void serviceStopped() {
}
public BRobotResult doRunRobot(BRobotCode bRobotCode, Context context) throws Exception {
try {
Robot robot = (Robot)bRobotCode.newInstance();
if (REQUIRE_SUPER_USER_PERMISSION && context != null && context.getUser() != null && !(robot instanceof BatchRobot) && !context.getUser().getPermissions().isSuperUser()) {
throw new PermissionException("Run Robot not allowed by this user.");
}
try {
robot.context = context;
robot.run();
}
catch (Exception exception) {
exception.printStackTrace(robot.log);
}
return robot.toResult();
}
catch (Throwable throwable) {
String string = "Failed: runRobot\n" + ThrowableUtil.dumpToString((Throwable)throwable);
return new BRobotResult(string);
}
}
public BIcon getIcon() {
return icon;
}
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());
}
}
static {
Class clazz = class$com$tridium$program$BProgramService;
if (clazz == null) {
clazz = class$com$tridium$program$BProgramService = BProgramService.class("[Lcom.tridium.program.BProgramService;", false);
}
TYPE = Sys.loadType((Class)clazz);
icon = BIcon.std((String)"script.png");
REQUIRE_SUPER_USER_PERMISSION = Boolean.valueOf(System.getProperty("niagara.program.requireSuperUser", "true"));
}
}
@@ -0,0 +1,47 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.sys.Sys
* javax.baja.sys.Type
*/
package com.tridium.program;
import com.tridium.program.BCode;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class BRobotCode
extends BCode {
public static final Type TYPE;
static /* synthetic */ Class class$com$tridium$program$BRobotCode;
public Type getType() {
return TYPE;
}
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());
}
}
static {
Class clazz = class$com$tridium$program$BRobotCode;
if (clazz == null) {
clazz = class$com$tridium$program$BRobotCode = BRobotCode.class("[Lcom.tridium.program.BRobotCode;", false);
}
TYPE = Sys.loadType((Class)clazz);
}
}
@@ -0,0 +1,66 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.sys.BComponent
* javax.baja.sys.Property
* javax.baja.sys.Sys
* javax.baja.sys.Type
*/
package com.tridium.program;
import javax.baja.sys.BComponent;
import javax.baja.sys.Property;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class BRobotResult
extends BComponent {
public static final Property log = BRobotResult.newProperty((int)0, (String)"", null);
public static final Type TYPE;
static /* synthetic */ Class class$com$tridium$program$BRobotResult;
public String getLog() {
return this.getString(log);
}
public void setLog(String string) {
this.setString(log, string, null);
}
public Type getType() {
return TYPE;
}
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());
}
}
public BRobotResult(String string) {
this.setLog(string);
}
public BRobotResult() {
}
static {
Class clazz = class$com$tridium$program$BRobotResult;
if (clazz == null) {
clazz = class$com$tridium$program$BRobotResult = BRobotResult.class("[Lcom.tridium.program.BRobotResult;", false);
}
TYPE = Sys.loadType((Class)clazz);
}
}
@@ -0,0 +1,249 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.data.BIDataValue
* javax.baja.io.ValueDocDecoder
* javax.baja.naming.BOrd
* javax.baja.nre.util.TextUtil
* javax.baja.security.PermissionException
* javax.baja.sys.BComplex
* javax.baja.sys.BComponent
* javax.baja.sys.BFacets
* 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.Sys
* javax.baja.user.BUser
* javax.baja.util.BTypeSpec
*/
package com.tridium.program;
import com.tridium.program.Robot;
import java.util.ArrayList;
import javax.baja.data.BIDataValue;
import javax.baja.io.ValueDocDecoder;
import javax.baja.naming.BOrd;
import javax.baja.nre.util.TextUtil;
import javax.baja.security.PermissionException;
import javax.baja.sys.BComplex;
import javax.baja.sys.BComponent;
import javax.baja.sys.BFacets;
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.Sys;
import javax.baja.user.BUser;
import javax.baja.util.BTypeSpec;
public class BatchRobot
extends Robot {
public void run() throws Exception {
}
public void componentRename(BOrd bOrd, String string, String string2, boolean bl, boolean bl2) {
BComponent bComponent = bOrd.get((BObject)Sys.getStation()).asComponent();
BComponent bComponent2 = (BComponent)bComponent.getParent();
if (bl2) {
if (bl) {
if (bComponent.getName().equals(string)) {
bComponent2.rename(bComponent.getPropertyInParent(), string2, this.context);
}
} else if (bComponent.getName().equalsIgnoreCase(string)) {
bComponent2.rename(bComponent.getPropertyInParent(), string2, this.context);
}
} else if (bl && bComponent.getName().indexOf(string) != -1) {
int n = bComponent.getName().indexOf(string);
String string3 = bComponent.getName().substring(0, n) + string2 + bComponent.getName().substring(n + string.length());
bComponent2.rename(bComponent.getPropertyInParent(), string3, this.context);
this.log.println("[RENAME] " + bOrd + " -> " + string3);
} else if (!bl && bComponent.getName().toUpperCase().indexOf(string.toUpperCase()) != -1) {
int n = bComponent.getName().toUpperCase().indexOf(string.toUpperCase());
String string4 = bComponent.getName().substring(0, n) + string2 + bComponent.getName().substring(n + string.length());
bComponent2.rename(bComponent.getPropertyInParent(), string4, this.context);
this.log.println("[RENAME] " + bOrd + " -> " + string4);
}
}
public void add(BOrd bOrd, String string, String string2, String string3, boolean bl) throws Exception {
BValue bValue = (BValue)BTypeSpec.make((String)string2).getInstance();
bValue = ValueDocDecoder.unmarshal((String)string3);
BComponent bComponent = bOrd.get((BObject)Sys.getStation()).asComponent();
if (bComponent.getProperty(string) != null && bl) {
if (Flags.isReadonly((BComplex)bComponent, (Slot)bComponent.getProperty(string))) {
this.log.println("[SET] Skipping readonly slot: " + bOrd + '.' + string);
return;
}
if (bComponent.get(string).getType() != bValue.getType()) {
return;
}
if (bValue instanceof BFacets) {
bValue = this.mergeFacets((BFacets)bComponent.get(string), (BFacets)bValue);
}
bComponent.set(string, bValue);
this.log.println("[SET] " + bOrd + '.' + string + " -> " + string3);
} else if (bComponent.getProperty(string) == null) {
bComponent.add(string, bValue, this.context);
this.log.println("[ADD] " + bOrd + '.' + string + " -> " + bValue);
}
}
public void set(BOrd bOrd, String string, String string2, String string3, boolean bl, boolean bl2) throws Exception {
BValue bValue = (BValue)BTypeSpec.make((String)string2).getInstance();
bValue = ValueDocDecoder.unmarshal((String)string3);
String[] stringArray = TextUtil.split((String)string, (char)'.');
BComponent bComponent = bOrd.get((BObject)Sys.getStation()).asComponent();
Property property = null;
int n = stringArray.length;
int n2 = 0;
while (n2 < n - 1) {
property = bComponent.getProperty(stringArray[n2]);
if ((bComponent = (BComplex)bComponent.get(property)) == null) {
this.log.println("[SET][ERROR] " + bOrd + '.' + string + " does not exist!");
return;
}
++n2;
}
Property[] propertyArray = this.findProperties((BComplex)bComponent, stringArray[n - 1], bl, bl2);
int n3 = 0;
while (n3 < propertyArray.length) {
block10: {
if (bComponent instanceof BUser) {
try {
BUser bUser = (BUser)bComponent;
bUser.checkWrite((BComponent)bUser, (Slot)propertyArray[n3]);
}
catch (PermissionException permissionException) {
this.log.println("[SET] Insufficient permissions to change slot: " + bOrd + '.' + propertyArray[n3].getName());
break block10;
}
}
if (Flags.isReadonly((BComplex)bComponent, (Slot)propertyArray[n3])) {
this.log.println("[SET] Skipping readonly slot: " + bOrd + '.' + propertyArray[n3].getName());
} else if (bValue.getType() == bComponent.get(propertyArray[n3]).getType()) {
if (bValue instanceof BFacets) {
bValue = this.mergeFacets((BFacets)bComponent.get(propertyArray[n3]), (BFacets)bValue);
}
bComponent.set(propertyArray[n3], bValue, this.context);
this.log.println("[SET] " + bOrd + '.' + propertyArray[n3].getName() + " -> " + bValue);
}
}
++n3;
}
}
public void setFlag(BOrd bOrd, String string, int n, boolean bl, boolean bl2) throws Exception {
BComponent bComponent = bOrd.get((BObject)Sys.getStation()).asComponent();
if (bl) {
BComplex bComplex = bComponent.getParent();
Property property = bComponent.getPropertyInParent();
if (bComplex != null && property != null) {
int n2;
int n3 = n2 = bComplex.getFlags((Slot)property);
n3 = bl2 ? n2 | n : n2 & ~n;
bComplex.setFlags((Slot)property, n3, this.context);
this.log.println("[SET FLAGS] " + bOrd + ' ' + Flags.toDisplayString((int)n2, (Context)this.context) + " -> " + Flags.toDisplayString((int)n3, (Context)this.context));
} else {
this.log.println("[SET FLAGS][ERROR] " + bOrd + " cannot have slot flags edited!");
}
} else {
Slot slot = bComponent.getSlot(string);
if (slot != null) {
int n4;
int n5 = n4 = bComponent.getFlags(slot);
n5 = bl2 ? n4 | n : n4 & ~n;
bComponent.setFlags(slot, n5, this.context);
this.log.println("[SET FLAGS] " + bOrd + '.' + string + ' ' + Flags.toDisplayString((int)n4, (Context)this.context) + " -> " + Flags.toDisplayString((int)n5, (Context)this.context));
} else {
this.log.println("[SET FLAGS][ERROR] " + bOrd + '.' + string + " cannot have slot flags edited!");
}
}
}
public void rename(BOrd bOrd, String string, String string2, boolean bl, boolean bl2) {
BComponent bComponent = bOrd.get((BObject)Sys.getStation()).asComponent();
Property[] propertyArray = this.findProperties((BComplex)bComponent, string, bl, bl2);
String string3 = "";
String string4 = "";
int n = 0;
while (n < propertyArray.length) {
string3 = propertyArray[n].getName();
if (propertyArray[n].isFrozen()) {
this.log.println("[RENAME] Skipping frozen slot: " + string3);
} else if (Flags.isReadonly((BComplex)bComponent, (Slot)propertyArray[n])) {
this.log.println("[RENAME] Skipping readonly slot: " + bOrd + '.' + propertyArray[n].getName());
} else {
if (bl2) {
string4 = string2;
} else {
int n2 = bl ? string3.indexOf(string) : string3.toUpperCase().indexOf(string.toUpperCase());
string4 = string3.substring(0, n2) + string2 + string3.substring(n2 + string.length());
}
bComponent.rename(propertyArray[n], string4, this.context);
this.log.println("[RENAME] " + bOrd + '.' + string3 + " -> " + string4);
}
++n;
}
}
public void remove(BOrd bOrd, String string, boolean bl, boolean bl2) {
BComponent bComponent = bOrd.get((BObject)Sys.getStation()).asComponent();
Property[] propertyArray = this.findProperties((BComplex)bComponent, string, bl, bl2);
int n = 0;
while (n < propertyArray.length) {
if (Flags.isReadonly((BComplex)bComponent, (Slot)propertyArray[n])) {
this.log.println("[REMOVE] Skipping readonly slot: " + bOrd + '.' + propertyArray[n].getName());
} else {
bComponent.remove(propertyArray[n], this.context);
this.log.println("[REMOVE] " + bOrd + '.' + propertyArray[n].getName() + " -> Removed");
}
++n;
}
}
public Property[] findProperties(BComplex bComplex, String string, boolean bl, boolean bl2) {
ArrayList<Property> arrayList = new ArrayList<Property>();
Property[] propertyArray = bComplex.getPropertiesArray();
int n = 0;
while (n < propertyArray.length) {
if (bl2) {
if (bl) {
if (propertyArray[n].getName().equals(string)) {
arrayList.add(propertyArray[n]);
}
} else if (propertyArray[n].getName().equalsIgnoreCase(string)) {
arrayList.add(propertyArray[n]);
}
} else if (bl) {
if (propertyArray[n].getName().indexOf(string) != -1) {
arrayList.add(propertyArray[n]);
}
} else if (propertyArray[n].getName().toUpperCase().indexOf(string.toUpperCase()) != -1) {
arrayList.add(propertyArray[n]);
}
++n;
}
return arrayList.toArray(new Property[arrayList.size()]);
}
public BFacets mergeFacets(BFacets bFacets, BFacets bFacets2) {
String[] stringArray = bFacets2.list();
int n = 0;
while (n < stringArray.length) {
String string = stringArray[n];
if (bFacets.get(string) != null) {
bFacets = BFacets.makeRemove((BFacets)bFacets, (String)string);
}
bFacets = BFacets.make((BFacets)bFacets, (String)string, (BIDataValue)((BIDataValue)bFacets2.get(string)));
++n;
}
return bFacets;
}
}
@@ -0,0 +1,184 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.sys.Action
* javax.baja.sys.BComponent
* javax.baja.sys.BObject
* javax.baja.sys.BValue
* javax.baja.sys.Property
* javax.baja.sys.Slot
*/
package com.tridium.program;
import com.tridium.program.BProgram;
import javax.baja.sys.Action;
import javax.baja.sys.BComponent;
import javax.baja.sys.BObject;
import javax.baja.sys.BValue;
import javax.baja.sys.Property;
import javax.baja.sys.Slot;
public class ProgramBase
implements Runnable {
BProgram program;
public final BProgram getProgram() {
return this.program;
}
public final BComponent getComponent() {
return this.program;
}
public final Slot getSlot(String string) {
return this.program.getSlot(string);
}
public final Property getProperty(String string) {
return this.program.getProperty(string);
}
public final Action getAction(String string) {
return this.program.getAction(string);
}
public BObject get(Property property) {
return this.program.get(property);
}
public boolean getBoolean(Property property) {
return this.program.getBoolean(property);
}
public int getInt(Property property) {
return this.program.getInt(property);
}
public float getFloat(Property property) {
return this.program.getFloat(property);
}
public double getDouble(Property property) {
return this.program.getDouble(property);
}
public long getLong(Property property) {
return this.program.getLong(property);
}
public String getString(Property property) {
return this.program.getString(property);
}
public BObject get(String string) {
return this.program.get(string);
}
public boolean getBoolean(String string) {
return this.program.getBoolean(this.getProperty(string));
}
public int getInt(String string) {
return this.program.getInt(this.getProperty(string));
}
public float getFloat(String string) {
return this.program.getFloat(this.getProperty(string));
}
public double getDouble(String string) {
return this.program.getDouble(this.getProperty(string));
}
public long getLong(String string) {
return this.program.getLong(this.getProperty(string));
}
public String getString(String string) {
return this.program.getString(this.getProperty(string));
}
public void set(Property property, BValue bValue) {
this.program.set(property, bValue);
}
public void setBoolean(Property property, boolean bl) {
this.program.setBoolean(property, bl);
}
public void setInt(Property property, int n) {
this.program.setInt(property, n);
}
public void setFloat(Property property, float f) {
this.program.setFloat(property, f);
}
public void setDouble(Property property, double d) {
this.program.setDouble(property, d);
}
public void setLong(Property property, long l) {
this.program.setLong(property, l);
}
public void setString(Property property, String string) {
this.program.setString(property, string);
}
public void set(String string, BValue bValue) {
this.program.set(this.getProperty(string), bValue);
}
public void setBoolean(String string, boolean bl) {
this.program.setBoolean(this.getProperty(string), bl);
}
public void setInt(String string, int n) {
this.program.setInt(this.getProperty(string), n);
}
public void setFloat(String string, float f) {
this.program.setFloat(this.getProperty(string), f);
}
public void setDouble(String string, double d) {
this.program.setDouble(this.getProperty(string), d);
}
public void setLong(String string, long l) {
this.program.setLong(this.getProperty(string), l);
}
public void setString(String string, String string2) {
this.program.setString(this.getProperty(string), string2);
}
public void run() {
System.out.println("ProgramBase.run");
}
public void print(String string) {
System.out.print(string);
System.out.flush();
}
public void println(String string) {
System.out.println(string);
}
public String toString() {
return "ProgramImpl for " + (Object)((Object)this.program);
}
public void onStart() throws Throwable {
}
public void onStop() throws Throwable {
}
public void onExecute() throws Throwable {
}
}
@@ -0,0 +1,123 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.io.ValueDocDecoder
* javax.baja.io.ValueDocEncoder
* javax.baja.nre.util.Array
* javax.baja.sys.BComponent
* javax.baja.sys.BObject
* javax.baja.sys.BValue
*/
package com.tridium.program;
import com.tridium.program.BCode;
import com.tridium.program.BProgram;
import com.tridium.program.BProgramCode;
import com.tridium.program.ui.BProgramEditor;
import com.tridium.program.ui.Compiler;
import com.tridium.program.ui.SourceWriter;
import java.io.File;
import javax.baja.io.ValueDocDecoder;
import javax.baja.io.ValueDocEncoder;
import javax.baja.nre.util.Array;
import javax.baja.sys.BComponent;
import javax.baja.sys.BObject;
import javax.baja.sys.BValue;
public class RecompileTool {
public static void main(String[] stringArray) throws Exception {
if (stringArray.length < 1) {
System.out.println("usage: RecompileTool <dir|bogfile>");
return;
}
File file = new File(stringArray[0]);
if (!file.exists()) {
System.out.println("File not found: " + file);
return;
}
RecompileTool.process(file);
System.exit(0);
}
public static void process(File file) throws Exception {
if (file.isDirectory()) {
File[] fileArray = file.listFiles();
int n = 0;
while (fileArray != null && n < fileArray.length) {
RecompileTool.process(fileArray[n]);
++n;
}
return;
}
if (file.getName().endsWith(".bog")) {
RecompileTool.processBog(file);
}
}
public static void processBog(File file) throws Exception {
System.out.println("--- Processing " + file + "...");
try {
ValueDocDecoder valueDocDecoder = new ValueDocDecoder(file);
BComponent bComponent = (BComponent)valueDocDecoder.decodeDocument();
boolean bl = valueDocDecoder.isZipped();
valueDocDecoder.close();
RecompileTool.process(bComponent);
ValueDocEncoder valueDocEncoder = new ValueDocEncoder(file);
valueDocEncoder.setZipped(bl);
valueDocEncoder.encodeDocument((BValue)bComponent);
valueDocEncoder.close();
System.out.println("--- Processed " + file + '!');
}
catch (Exception exception) {
System.out.println("ERROR: Cannot process " + file);
exception.printStackTrace();
}
}
public static void process(BComponent bComponent) throws Exception {
if (bComponent instanceof BProgram) {
System.out.println(" Recompiling " + RecompileTool.toString(bComponent));
try {
RecompileTool.recompile((BProgram)bComponent);
}
catch (Exception exception) {
System.out.println("ERROR Recompiling " + RecompileTool.toString(bComponent));
exception.printStackTrace();
}
}
BComponent[] bComponentArray = bComponent.getChildComponents();
int n = 0;
while (n < bComponentArray.length) {
RecompileTool.process(bComponentArray[n]);
++n;
}
}
public static void recompile(BProgram bProgram) throws Exception {
String string = BCode.generateClassName();
BProgramEditor bProgramEditor = new BProgramEditor();
bProgramEditor.loadValue((BObject)bProgram);
char[] cArray = SourceWriter.generateToCharArray(bProgramEditor, string);
BProgramCode bProgramCode = bProgram.getCode();
Compiler compiler = new Compiler(null);
compiler.compile(string, bProgramCode, new String(cArray));
}
static String toString(BComponent bComponent) {
Object object;
Array array = new Array();
while ((object = bComponent.getPropertyInParent()) != null) {
array.add(0, (Object)object.getName());
bComponent = (BComponent)bComponent.getParent();
}
object = new StringBuffer();
int n = 0;
while (n < array.size()) {
((StringBuffer)object).append("/").append(array.get(n));
++n;
}
return ((StringBuffer)object).toString();
}
}
@@ -0,0 +1,34 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.sys.Context
*/
package com.tridium.program;
import com.tridium.program.BRobotResult;
import java.io.PrintWriter;
import java.io.StringWriter;
import javax.baja.sys.Context;
public abstract class Robot {
public final PrintWriter log;
public Context context;
private StringWriter logOut = new StringWriter();
public abstract void run() throws Exception;
public BRobotResult toResult() {
return new BRobotResult(this.logToString());
}
public String logToString() {
this.log.flush();
return this.logOut.toString();
}
public Robot() {
this.log = new PrintWriter(this.logOut);
}
}
@@ -0,0 +1,570 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.workbench.console.BConsole
* com.tridium.workbench.console.BConsole$ExecCallback
* com.tridium.workbench.shell.BNiagaraWbShell
* javax.baja.file.FileUtil
* javax.baja.nre.util.SortUtil
* javax.baja.nre.util.TextUtil
* javax.baja.registry.ModuleInfo
* javax.baja.sys.BAbsTime
* javax.baja.sys.BComponent
* javax.baja.sys.BFacets
* javax.baja.sys.BIcon
* javax.baja.sys.BValue
* javax.baja.sys.Property
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BWidget
* javax.baja.util.BFolder
* javax.baja.util.BNameMap
* javax.baja.util.Lexicon
* javax.baja.xml.XContent
* javax.baja.xml.XElem
* javax.baja.xml.XWriter
*/
package com.tridium.program.module;
import com.tridium.program.BProgram;
import com.tridium.program.module.BuildException;
import com.tridium.program.module.BuildStep;
import com.tridium.program.module.ComponentWriter;
import com.tridium.program.module.IBuildListener;
import com.tridium.program.module.ValidateModel;
import com.tridium.workbench.console.BConsole;
import com.tridium.workbench.shell.BNiagaraWbShell;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import javax.baja.file.FileUtil;
import javax.baja.nre.util.SortUtil;
import javax.baja.nre.util.TextUtil;
import javax.baja.registry.ModuleInfo;
import javax.baja.sys.BAbsTime;
import javax.baja.sys.BComponent;
import javax.baja.sys.BFacets;
import javax.baja.sys.BIcon;
import javax.baja.sys.BValue;
import javax.baja.sys.Property;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BWidget;
import javax.baja.util.BFolder;
import javax.baja.util.BNameMap;
import javax.baja.util.Lexicon;
import javax.baja.xml.XContent;
import javax.baja.xml.XElem;
import javax.baja.xml.XWriter;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public final class BProgramModule
extends BComponent {
public static final Property moduleName = BProgramModule.newProperty((int)8, (String)"", (BFacets)BFacets.make((String)"mustBeSlotName", (boolean)true));
public static final Property description = BProgramModule.newProperty((int)0, (String)"", (BFacets)BFacets.make((String)"max", (int)100));
public static final Property vendor = BProgramModule.newProperty((int)0, (String)"", null);
public static final Property vendorVersion = BProgramModule.newProperty((int)0, (String)"0", (BFacets)BFacets.make((String)"validator", (String)"baja:VersionValidator"));
public static final Property dependencies = BProgramModule.newProperty((int)4, (BValue)BNameMap.DEFAULT, null);
public static final Property programs = BProgramModule.newProperty((int)4, (BValue)new BFolder(), null);
public static final Type TYPE;
private static final BIcon icon;
private static final Lexicon lex;
private static final String packageName = "autogen";
private static BuildStep[] buildSteps;
private File buildRoot;
HashMap typeMap;
static /* synthetic */ Class class$com$tridium$program$module$BProgramModule;
static /* synthetic */ Class class$com$tridium$program$BProgram;
public final String getModuleName() {
return this.getString(moduleName);
}
public final void setModuleName(String string) {
this.setString(moduleName, string, null);
}
public final String getDescription() {
return this.getString(description);
}
public final void setDescription(String string) {
this.setString(description, string, null);
}
public final String getVendor() {
return this.getString(vendor);
}
public final void setVendor(String string) {
this.setString(vendor, string, null);
}
public final String getVendorVersion() {
return this.getString(vendorVersion);
}
public final void setVendorVersion(String string) {
this.setString(vendorVersion, string, null);
}
public final BNameMap getDependencies() {
return (BNameMap)this.get(dependencies);
}
public final void setDependencies(BNameMap bNameMap) {
this.set(dependencies, (BValue)bNameMap, null);
}
public final BFolder getPrograms() {
return (BFolder)this.get(programs);
}
public final void setPrograms(BFolder bFolder) {
this.set(programs, (BValue)bFolder, null);
}
public final Type getType() {
return TYPE;
}
public static final String toTypeName(BProgram bProgram) {
return bProgram.getDisplayName(null);
}
public static final String toComponentName(BProgram bProgram) {
if (bProgram.getParent() == null) {
throw new IllegalStateException("Must be parented.");
}
String string = BProgramModule.toTypeName(bProgram);
if (!Character.isUpperCase(string.charAt(0))) {
return null;
}
StringBuffer stringBuffer = new StringBuffer("B").append(string.charAt(0));
int n = 1;
while (n < string.length()) {
char c = string.charAt(n);
if (!Character.isLetterOrDigit(c)) {
return null;
}
stringBuffer.append(c);
++n;
}
return stringBuffer.toString();
}
public static final BNameMap rationalizeDependecies(BProgramModule bProgramModule) {
HashSet<String> hashSet = new HashSet<String>();
BNameMap bNameMap = bProgramModule.getDependencies();
String[] stringArray = bNameMap.list();
int n = 0;
while (n < stringArray.length) {
if (!BProgram.isSpecialModule(stringArray[n])) {
hashSet.add(stringArray[n]);
}
++n;
}
BProgram[] bProgramArray = bProgramModule.listPrograms();
int n2 = 0;
while (n2 < bProgramArray.length) {
String[] stringArray2 = TextUtil.split((String)bProgramArray[n2].getCode().getDependencies(), (char)';');
int n3 = 0;
while (n3 < stringArray2.length) {
String string = stringArray2[n3];
if (bNameMap.get(string) == null && !BProgram.isSpecialModule(string)) {
bNameMap = BNameMap.make((BNameMap)bNameMap, (String)string, (String)Sys.getRegistry().getModule(string).getVendorVersion().toString(2));
}
hashSet.remove(string);
++n3;
}
++n2;
}
Object[] objectArray = hashSet.toArray();
int n4 = 0;
while (n4 < objectArray.length) {
bNameMap = BNameMap.remove((BNameMap)bNameMap, (String)((String)objectArray[n4]));
++n4;
}
return bNameMap;
}
public final void buildModule(IBuildListener iBuildListener) throws BuildException {
if (iBuildListener == null) {
iBuildListener = new IBuildListener(){
public final void updateDesc(String string) {
}
public final void setNumBuildSteps(int n) {
}
public final void nextStep(String string) {
}
public final BWidget getOwner() {
return null;
}
};
}
iBuildListener.setNumBuildSteps(buildSteps.length + this.listPrograms().length);
iBuildListener.updateDesc(lex.getText("programModule.build", new Object[]{this.getModuleName()}));
int n = 0;
while (n < buildSteps.length) {
buildSteps[n].runStep(this, iBuildListener);
++n;
}
}
public final BProgram[] listPrograms() {
BFolder bFolder = this.getPrograms();
Class clazz = class$com$tridium$program$BProgram;
if (clazz == null) {
clazz = class$com$tridium$program$BProgram = BProgramModule.class("[Lcom.tridium.program.BProgram;", false);
}
return (BProgram[])bFolder.getChildren(clazz);
}
final File getBuildRoot() {
return this.buildRoot;
}
final void setBuildRoot(File file) {
this.buildRoot = file;
}
final String getPreferredSymbol() {
return this.getModuleName();
}
public final BIcon getIcon() {
return icon;
}
static final /* synthetic */ String access$1() {
return packageName;
}
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());
}
}
static {
Class clazz = class$com$tridium$program$module$BProgramModule;
if (clazz == null) {
clazz = class$com$tridium$program$module$BProgramModule = BProgramModule.class("[Lcom.tridium.program.module.BProgramModule;", false);
}
TYPE = Sys.loadType((Class)clazz);
icon = BIcon.make((BIcon)BIcon.std((String)"module.png"), (BIcon)BIcon.std((String)"badges/script.png"));
Class clazz2 = class$com$tridium$program$module$BProgramModule;
if (clazz2 == null) {
clazz2 = class$com$tridium$program$module$BProgramModule = BProgramModule.class("[Lcom.tridium.program.module.BProgramModule;", false);
}
lex = Lexicon.make((Class)clazz2);
buildSteps = new BuildStep[]{new ValidateStep(), new InitStep(), new WriteComponentsStep(), new WriteBuildXmlStep(), new WriteModuleIncludeStep(), new WritePaletteStep(), new WriteLexiconStep(), new NiagaraBuildStep()};
}
static class ValidateStep
extends BuildStep {
private String modOrd;
public void doStep() throws Exception {
this.interest.nextStep(lex.getText("programModule.validate"));
this.modOrd = this.module.getNavOrd().toString();
boolean bl = false;
ValidateModel validateModel = ValidateModel.make(this.module);
if (validateModel.getErrCount() > 0) {
bl = true;
this.appendErrOrdLines(null, validateModel);
}
BProgram[] bProgramArray = this.module.listPrograms();
int n = 0;
while (n < bProgramArray.length) {
validateModel = ValidateModel.make(bProgramArray[n]);
if (validateModel.getErrCount() > 0) {
bl = true;
this.appendErrOrdLines(bProgramArray[n], validateModel);
}
++n;
}
if (bl) {
throw new BuildException(lex.getText("programModule.validate.failed"));
}
}
private final void appendErrOrdLines(BProgram bProgram, ValidateModel validateModel) {
StringBuffer stringBuffer = new StringBuffer().append(this.modOrd).append("|view:program:ProgramModuleBuilder");
if (bProgram != null) {
stringBuffer.append("?program=").append(BProgramModule.toTypeName(bProgram));
}
int n = validateModel.getErrCount();
String string = stringBuffer.toString();
int n2 = 0;
while (n2 < n) {
this.interest.updateDesc(string + "|| " + validateModel.getValueAt(n2, 0));
++n2;
}
}
ValidateStep() {
}
}
static class InitStep
extends BuildStep {
File temp;
File buildDir;
public void doStep() throws Exception {
this.interest.nextStep(lex.getText("programModule.init"));
this.temp = new File(Sys.getBajaHome(), "temp");
this.buildDir = new File(this.temp, this.module.getModuleName());
FileUtil.delete((File)this.buildDir);
this.buildDir.mkdirs();
this.module.setBuildRoot(this.buildDir);
this.module.typeMap = new HashMap();
}
InitStep() {
}
}
static class WriteComponentsStep
extends BuildStep {
File packageDir;
public void doStep() throws Exception {
this.interest.nextStep(lex.getText("programModule.convert"));
File file = new File(this.module.getBuildRoot(), "src");
this.packageDir = new File(file, BProgramModule.packageName);
if (!this.packageDir.mkdirs()) {
throw new BuildException(lex.getText("programModule.convert.failPkg", new Object[]{this.packageDir}));
}
BProgram[] bProgramArray = this.module.listPrograms();
int n = 0;
while (n < bProgramArray.length) {
String string = BProgramModule.toComponentName(bProgramArray[n]);
String string2 = string + ".java";
this.interest.nextStep(lex.getText("programModule.convert.write", new Object[]{string}));
this.module.typeMap.put(BProgramModule.toTypeName(bProgramArray[n]), "autogen." + string);
FileWriter fileWriter = new FileWriter(new File(this.packageDir, string2));
new ComponentWriter(fileWriter, bProgramArray[n], BProgramModule.packageName).generate();
++n;
}
}
WriteComponentsStep() {
}
}
static class WriteBuildXmlStep
extends BuildStep {
public void doStep() throws Exception {
this.interest.nextStep(lex.getText("programModule.buildXML"));
File file = new File(this.module.getBuildRoot(), "build.xml");
XWriter xWriter = new XWriter(file);
xWriter.prolog();
this.writeComments(xWriter);
this.writeModule(xWriter);
xWriter.close();
}
private final void writeComments(XWriter xWriter) throws IOException {
StringBuffer stringBuffer = new StringBuffer().append("<!--").append("\n").append(" - Module Build File").append("\n").append(" - Auto-generated by the Program Module-Builder.").append("\n").append(" - Date: ").append(BAbsTime.now()).append("\n").append(" -->").append("\n\n");
xWriter.write(stringBuffer.toString());
}
private final void writeModule(XWriter xWriter) throws IOException {
XElem xElem = new XElem("module");
String string = this.module.getVendorVersion();
if (string.length() == 0) {
string = "0";
}
xElem.addAttr("name", this.module.getModuleName()).addAttr("bajaVersion", "0").addAttr("preferredSymbol", this.module.getPreferredSymbol()).addAttr("description", this.module.getDescription()).addAttr("vendor", this.module.getVendor()).addAttr("vendorVersion", string);
this.addDependencies(xElem);
this.addPackages(xElem);
xElem.write(xWriter);
}
private final void addDependencies(XElem xElem) {
BNameMap bNameMap = BProgramModule.rationalizeDependecies(this.module);
this.module.setDependencies(bNameMap);
Object[] objectArray = bNameMap.list();
SortUtil.sort((Object[])objectArray);
int n = 0;
while (n < objectArray.length) {
Object object = objectArray[n];
String string = bNameMap.get((String)object).getFormat();
ModuleInfo moduleInfo = Sys.getRegistry().getModule((String)object);
xElem.addContent((XContent)new XElem("dependency").addAttr("name", (String)object).addAttr("vendor", moduleInfo.getVendor()).addAttr("vendorVersion", string));
++n;
}
}
private final void addPackages(XElem xElem) {
xElem.addContent((XContent)new XElem("package").addAttr("name", BProgramModule.packageName));
}
WriteBuildXmlStep() {
}
}
static class WriteModuleIncludeStep
extends BuildStep {
public void doStep() throws Exception {
this.interest.nextStep(lex.getText("programModule.include"));
File file = new File(this.module.getBuildRoot(), "module-include.xml");
try {
XWriter xWriter = new XWriter(file);
xWriter.prolog();
this.writeComments(xWriter);
this.writeTypes(xWriter);
xWriter.close();
}
catch (Exception exception) {
throw new BuildException(lex.getText("programModule.include.fail"), exception);
}
}
private final void writeComments(XWriter xWriter) throws IOException {
StringBuffer stringBuffer = new StringBuffer().append("<!--").append("\n").append(" - Module Include File").append("\n").append(" - Auto-generated by the Program Module-Builder.").append("\n").append(" - Date: ").append(BAbsTime.now()).append("\n").append(" -->").append("\n\n");
xWriter.write(stringBuffer.toString());
}
private final void writeTypes(XWriter xWriter) throws IOException {
XElem xElem = new XElem("types");
Iterator iterator = this.module.typeMap.keySet().iterator();
while (iterator.hasNext()) {
String string = (String)iterator.next();
String string2 = (String)this.module.typeMap.get(string);
XElem xElem2 = new XElem("type").addAttr("name", string).addAttr("class", string2);
xElem.addContent((XContent)xElem2);
}
xElem.write(xWriter);
}
WriteModuleIncludeStep() {
}
}
static class WritePaletteStep
extends BuildStep {
protected void doStep() throws Exception {
this.interest.nextStep(lex.getText("programModule.palette"));
File file = new File(this.module.getBuildRoot(), "module.palette");
XWriter xWriter = new XWriter(file);
xWriter.prolog();
XElem xElem = new XElem("bajaObjectGraph").addAttr("version", "1.0");
XElem xElem2 = new XElem("p").addAttr("m", "b=baja").addAttr("t", "b:UnrestrictedFolder");
BProgram[] bProgramArray = this.module.listPrograms();
SortUtil.sort((Object[])bProgramArray, (Object[])bProgramArray, (Comparator)new Comparator(){
public final int compare(Object object, Object object2) {
String string = BProgramModule.toTypeName((BProgram)((Object)object));
String string2 = BProgramModule.toTypeName((BProgram)((Object)object2));
return string.compareTo(string2);
}
});
int n = 0;
while (n < bProgramArray.length) {
xElem2.addContent((XContent)new XElem("p").addAttr("n", BProgramModule.toTypeName(bProgramArray[n])).addAttr("m", this.module.getPreferredSymbol() + '=' + this.module.getModuleName()).addAttr("t", this.module.getPreferredSymbol() + ':' + BProgramModule.toTypeName(bProgramArray[n])));
++n;
}
xElem.addContent((XContent)xElem2);
xElem.write(xWriter);
xWriter.close();
}
WritePaletteStep() {
}
}
static class WriteLexiconStep
extends BuildStep {
/*
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
protected void doStep() throws Exception {
this.interest.nextStep(lex.getText("programModule.lexicon"));
File file = new File(this.module.getBuildRoot(), "module.lexicon");
PrintStream printStream = new PrintStream(new FileOutputStream(file));
try {
printStream.println("#");
printStream.println("# Lexicon auto-generated by the Program Module-Builder");
printStream.println("#");
}
catch (Throwable throwable) {
Object var4_4 = null;
printStream.close();
throw throwable;
}
{
Object var4_5 = null;
printStream.close();
return;
}
}
WriteLexiconStep() {
}
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
static class NiagaraBuildStep
extends BuildStep
implements BConsole.ExecCallback {
String cmd;
int exitCode;
protected synchronized void doStep() throws Exception {
this.interest.nextStep(lex.getText("programModule.nbuild"));
this.cmd = "build \"" + this.module.getBuildRoot() + '\"';
BWidget bWidget = this.interest.getOwner();
if (bWidget != null) {
((BNiagaraWbShell)bWidget.getShell()).openConsole().exec(this.cmd, (BConsole.ExecCallback)this);
this.wait();
if (this.exitCode != 0) {
throw new BuildException(lex.getText("programModule.nbuild.fail"));
}
} else {
throw new IllegalStateException("must be in workbench.");
}
}
public synchronized void consoleExecDone(BConsole bConsole, int n) {
this.exitCode = n;
this.notify();
}
private final /* synthetic */ void this() {
this.exitCode = -1;
}
NiagaraBuildStep() {
this.this();
}
}
}
@@ -0,0 +1,28 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.sys.BajaRuntimeException
*/
package com.tridium.program.module;
import javax.baja.sys.BajaRuntimeException;
public class BuildException
extends BajaRuntimeException {
public BuildException() {
}
public BuildException(Throwable throwable) {
super(throwable);
}
public BuildException(String string) {
super(string);
}
public BuildException(String string, Throwable throwable) {
super(string, throwable);
}
}
@@ -0,0 +1,30 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.program.module;
import com.tridium.program.module.BProgramModule;
import com.tridium.program.module.BuildException;
import com.tridium.program.module.IBuildListener;
public abstract class BuildStep {
protected BProgramModule module;
protected IBuildListener interest;
public final void runStep(BProgramModule bProgramModule, IBuildListener iBuildListener) throws BuildException {
this.module = bProgramModule;
this.interest = iBuildListener;
try {
this.doStep();
}
catch (BuildException buildException) {
throw buildException;
}
catch (Exception exception) {
throw new BuildException("Build failed. " + exception.getMessage(), exception);
}
}
protected abstract void doStep() throws Exception;
}
@@ -0,0 +1,588 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.TextUtil
* javax.baja.sys.Action
* javax.baja.sys.BAction
* javax.baja.sys.BBoolean
* javax.baja.sys.BComplex
* javax.baja.sys.BDouble
* javax.baja.sys.BFloat
* javax.baja.sys.BInteger
* javax.baja.sys.BLink
* javax.baja.sys.BLong
* javax.baja.sys.BString
* javax.baja.sys.BTopic
* javax.baja.sys.BValue
* javax.baja.sys.BajaRuntimeException
* javax.baja.sys.Flags
* javax.baja.sys.Property
* javax.baja.sys.Slot
* javax.baja.sys.SlotCursor
* javax.baja.util.BWsAnnotation
* org.apache.oro.text.perl.Perl5Util
*/
package com.tridium.program.module;
import com.tridium.program.BProgram;
import com.tridium.program.module.BProgramModule;
import com.tridium.program.module.BuildException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.Writer;
import java.util.HashSet;
import javax.baja.nre.util.TextUtil;
import javax.baja.sys.Action;
import javax.baja.sys.BAction;
import javax.baja.sys.BBoolean;
import javax.baja.sys.BComplex;
import javax.baja.sys.BDouble;
import javax.baja.sys.BFloat;
import javax.baja.sys.BInteger;
import javax.baja.sys.BLink;
import javax.baja.sys.BLong;
import javax.baja.sys.BString;
import javax.baja.sys.BTopic;
import javax.baja.sys.BValue;
import javax.baja.sys.BajaRuntimeException;
import javax.baja.sys.Flags;
import javax.baja.sys.Property;
import javax.baja.sys.Slot;
import javax.baja.sys.SlotCursor;
import javax.baja.util.BWsAnnotation;
import org.apache.oro.text.perl.Perl5Util;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class ComponentWriter
extends PrintWriter {
private static final int tabWidth = 2;
private String[] predefinedImports;
private BProgram program;
private Class programClass;
private String packageName;
private String compName;
static /* synthetic */ Class class$java$lang$String;
private final void init(BProgram bProgram, String string) {
this.program = bProgram;
try {
this.programClass = bProgram.getCode().newInstance().getClass();
}
catch (Exception exception) {
exception.printStackTrace();
throw new BajaRuntimeException((Throwable)exception);
}
this.packageName = string;
this.compName = BProgramModule.toComponentName(bProgram);
}
public void generate() {
this.writeHeader();
this.writeImports();
this.writeClass();
this.flush();
this.close();
}
protected void writeHeader() {
this.wl("/* Auto-generated by the Program Module-Builder. */");
this.w("package ").w(this.packageName).wl(";");
this.nl();
}
protected void writeImports() {
Object object;
HashSet<String> hashSet = new HashSet<String>();
int n = 0;
while (n < this.predefinedImports.length) {
hashSet.add(this.predefinedImports[n]);
++n;
}
String string = this.program.getCode().getUserDefinedImports();
String[] stringArray = TextUtil.split((String)string, (char)';');
int n2 = 0;
while (n2 < stringArray.length) {
hashSet.add(TextUtil.split((String)stringArray[n2], (char)':')[1] + ".*;");
++n2;
}
SlotCursor slotCursor = this.program.getProperties();
while (slotCursor.next()) {
if (!slotCursor.property().isDynamic()) continue;
object = slotCursor.get().getClass();
hashSet.add(TextUtil.getPackageName((Class)object) + ".*;");
}
object = hashSet.toArray(new String[hashSet.size()]);
int n3 = 0;
while (n3 < ((String[])object).length) {
this.w("import ").wl(object[n3]);
++n3;
}
this.nl();
}
protected void writeClass() {
this.w("public class ").wl(this.compName);
this.tab().wl("extends BComponent implements Runnable");
this.wl("{");
this.writeProperties();
this.writeActions();
this.writeBComponentOverrides();
this.writeRunnable();
this.writeAccess();
this.writeUtils();
this.writeStubs();
this.writeCode();
this.writeType();
this.wl("}");
}
protected void writeType() {
this.section("Type");
this.tab().wl("public Type getType() { return TYPE; }");
this.tab().w("public static final Type TYPE = Sys.loadType(").w(this.compName).w(".class);");
this.nl().nl();
}
protected void writeProperties() {
SlotCursor slotCursor = this.program.getProperties();
while (slotCursor.next()) {
BValue bValue;
Property property = slotCursor.property();
if (property.isFrozen() || (bValue = slotCursor.get().asValue()) instanceof BWsAnnotation || bValue instanceof BLink || bValue instanceof BAction || bValue instanceof BTopic) continue;
if (bValue instanceof BDouble || bValue instanceof BLong) {
throw new BuildException("Property slot type not supported: " + bValue.getType());
}
this.section("Property \"" + property.getName() + '\"');
this.writeNewProperty(property, bValue.isSimple());
this.writeGetSet(property);
}
}
protected final void writeNewProperty(Property property, boolean bl) {
String string = "B" + property.getType().getTypeName();
String string2 = bl ? "(BValue)" + string + ".TYPE.getInstance()" : "new " + string + "()";
this.tab().w("public static final Property ").w(property.getName()).w(" = newProperty(").w(this.flags((Slot)property)).w(", ").w(string2).w(", ").w(this.facets((Slot)property)).w(");").nl().nl();
}
protected final void writeGetSet(Property property) {
CompProperty compProperty = new CompProperty(property);
this.tab().w("public ").w(compProperty.type).w(" ").w(compProperty.getter()).w("() ").w("{ return ").w(compProperty.cast).w("get" + compProperty.postfix).w("(" + compProperty.name() + "); }").nl().nl();
this.tab().w("public void ").w(compProperty.setter()).w("(" + compProperty.type + " v)").w(" { set" + compProperty.postfix + '(' + compProperty.name() + ", v, null); }").nl().nl();
}
protected void writeActions() {
SlotCursor slotCursor = this.program.getActions();
while (slotCursor.next()) {
Action action = slotCursor.action();
CompAction compAction = new CompAction(slotCursor.action());
if (action.isFrozen() && !compAction.name().equals("execute")) continue;
this.section("Action \"" + compAction.name() + '\"');
this.tab().w("public static final Action ").w(compAction.name()).w(" = newAction(").w(this.flags((Slot)action)).w(", ").w(compAction.paramDefault()).w(", ").w(this.facets((Slot)action)).w(");").nl().nl();
this.writeActionInvoke(action);
this.writeActionDelegate(action);
}
}
protected void writeActionInvoke(Action action) {
CompAction compAction = new CompAction(action);
StringBuffer stringBuffer = new StringBuffer().append("public ").append(compAction.returnType()).append(" ").append(compAction.name()).append("(").append(compAction.parameter()).append(")").append("{ ").append(compAction.returnStmt()).append("invoke(").append(compAction.name()).append(", ").append(compAction.invokeParam()).append(", null); }");
this.tab().wl(stringBuffer.toString()).nl();
}
protected void writeActionDelegate(Action action) {
CompAction compAction = new CompAction(action);
this.tab().wl("/** Autogenerated delegate for \"" + compAction.getOn() + "\" */");
this.tab().w("public ").w(compAction.returnType()).w(" " + compAction.getDo()).w("(" + compAction.parameter() + ") throws Exception").nl().tab().wl("{").tab(2).w("try { ").w(compAction.returnStmt()).w(compAction.getOn()).w("(" + compAction.actualParam() + "); }").nl().tab(2).w("catch (Throwable t) { throw new Exception(t); }").nl().tab().wl("}").nl();
}
protected void writeBComponentOverrides() {
this.section("BComponent Overrides");
this.tab().wl("public void started() throws Exception { try { onStart(); } catch(Throwable t) { throw new Exception(t); } }").nl();
this.tab().wl("public void stopped() throws Exception { try { onStop(); } catch(Throwable t) { throw new Exception(t); } }").nl();
this.writeChanged();
}
protected void writeChanged() {
this.tab(1).wl("public void changed(Property prop, Context cx)").tab(1).wl("{").tab(2).wl("super.changed(prop, cx);").tab(2).wl("if (!isRunning()) return;").tab(2).wl("if (Flags.isExecuteOnChange(this, prop)) execute();").tab(1).wl("}").nl();
}
protected final void writeRunnable() {
if (!this.programDeclares("run", null)) {
this.section("Runnable");
this.tab().wl("public void run() { System.out.println(\"Source BProgram did not override run(). Exiting thread.\"); }").nl();
}
}
protected final void writeAccess() {
this.section("Access");
this.tab().wl("public final BComponent getComponent() { return this; }").nl();
this.tab().wl("public final BComponent getProgram() { return this; }").nl();
}
protected final void writeUtils() {
String string = this.program.getCode().getSource();
this.section("Utils");
Class[] classArray = new Class[1];
Class clazz = class$java$lang$String;
if (clazz == null) {
clazz = classArray[0] = (class$java$lang$String = ComponentWriter.class("[Ljava.lang.String;", false));
}
if (!this.programDeclares("print", classArray)) {
this.tab().wl("/** Print a string to standard out without a trailing new-line. */");
this.tab().wl("public void print(String s) { System.out.print(s); System.out.flush(); }").nl();
} else {
this.tab().wl("// print(String s) is overridden by program source.").nl();
}
Class[] classArray2 = new Class[1];
Class clazz2 = class$java$lang$String;
if (clazz2 == null) {
clazz2 = classArray2[0] = (class$java$lang$String = ComponentWriter.class("[Ljava.lang.String;", false));
}
if (!this.programDeclares("println", classArray2)) {
this.tab().wl("/** Print a string to standard out with a trailing new-line. */");
this.tab().wl("public void println(String s) { System.out.println(s); }").nl();
} else {
this.tab().wl("// println(String s) is overridden by program souce.").nl();
}
}
protected final void writeStubs() {
String string = this.program.getCode().getSource();
this.section("ProgramBase Stubs");
if (!this.programDeclares("onStart", null)) {
this.tab().wl("public void onStart() throws Throwable {}").nl();
}
if (!this.programDeclares("onStop", null)) {
this.tab().wl("public void onStop() throws Throwable {}").nl();
}
if (!this.programDeclares("onExecute", null)) {
this.tab().wl("public void onExecute() throws Throwable {}").nl();
}
}
protected void writeCode() {
Perl5Util perl5Util = new Perl5Util();
String string = this.program.getCode().getSource();
StringBuffer stringBuffer = new StringBuffer();
string = perl5Util.substitute("s/BProgram\\./" + this.compName + "./g", string);
this.section("BProgram Source Code");
this.writeSourceLines(string);
}
protected boolean programDeclares(String string, Class[] classArray) {
try {
this.programClass.getDeclaredMethod(string, classArray);
return true;
}
catch (NoSuchMethodException noSuchMethodException) {
return false;
}
}
protected final void writeSourceLines(String string) {
try {
String string2;
BufferedReader bufferedReader = new BufferedReader(new StringReader(string));
while ((string2 = bufferedReader.readLine()) != null) {
this.tab().wl(string2);
}
this.nl();
}
catch (IOException iOException) {
throw new IllegalStateException();
}
}
protected void section(String string) {
this.nl();
this.wl("////////////////////////////////////////////////////////////////");
this.wl("// " + string);
this.wl("////////////////////////////////////////////////////////////////");
this.nl();
}
protected final String flags(Slot slot) {
StringBuffer stringBuffer = new StringBuffer("0");
if (Flags.isAsync((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.ASYNC");
}
if (Flags.isComposite((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.COMPOSITE");
}
if (Flags.isConfirmRequired((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.CONFIRM_REQUIRED");
}
if (Flags.isDefaultOnClone((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.DEFAULT_ON_CLONE");
}
if (Flags.isExecuteOnChange((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.EXECUTE_ON_CHANGE");
}
if (Flags.isFanIn((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.FAN_IN");
}
if (Flags.isHidden((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.HIDDEN");
}
if (Flags.isNoAudit((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.NO_AUDIT");
}
if (Flags.isNoRun((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.NO_RUN");
}
if (Flags.isOperator((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.OPERATOR");
}
if (Flags.isReadonly((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.READONLY");
}
if (Flags.isSummary((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.SUMMARY");
}
if (Flags.isTransient((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.TRANSIENT");
}
if (Flags.isUserDefined1((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.USER_DEFINED_1");
}
if (Flags.isUserDefined2((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.USER_DEFINED_2");
}
if (Flags.isUserDefined3((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.USER_DEFINED_3");
}
if (Flags.isUserDefined4((BComplex)this.program, (Slot)slot)) {
stringBuffer.append("|Flags.USER_DEFINED_4");
}
return stringBuffer.toString();
}
protected final String facets(Slot slot) {
try {
return slot.getFacets().isNull() ? "null" : "BFacets.tryMake(\"" + slot.getFacets().encodeToString() + "\")";
}
catch (Exception exception) {
throw new BuildException("Failed to create facets. ", exception);
}
}
protected ComponentWriter w(String string) {
this.print(string);
return this;
}
protected ComponentWriter wl(String string) {
this.print(string);
this.print('\n');
return this;
}
protected ComponentWriter nl() {
this.print('\n');
return this;
}
protected ComponentWriter tab() {
return this.tab(1);
}
protected ComponentWriter tab(int n) {
return this.w(TextUtil.getSpaces((int)(n * 2)));
}
protected ComponentWriter sp(int n) {
return this.w(TextUtil.getSpaces((int)n));
}
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.predefinedImports = new String[]{"java.util.*;", "javax.baja.sys.*;", "javax.baja.status.*;", "javax.baja.util.*;", "javax.baja.security.*;"};
}
public ComponentWriter(Writer writer, BProgram bProgram, String string) {
super(writer);
this.this();
this.init(bProgram, string);
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public static class CompProperty {
public Property prop;
String cast;
String postfix;
String type;
String bname;
Class[] setParams;
static /* synthetic */ Class class$java$lang$String;
public String name() {
return this.prop.getName();
}
public String getter() {
return "get" + TextUtil.capitalize((String)this.name());
}
public String setter() {
return "set" + TextUtil.capitalize((String)this.name());
}
public String cast() {
return this.cast;
}
public String postfix() {
return this.postfix;
}
public String type() {
return this.type;
}
public String typeName() {
return this.bname;
}
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.cast = "";
this.postfix = "";
}
public CompProperty(Property property) {
this.this();
this.prop = property;
BValue bValue = property.getDefaultValue();
this.type = this.bname = "B" + bValue.getType().getTypeName();
if (bValue.isSimple()) {
if (bValue instanceof BString) {
this.postfix = "String";
this.type = "String";
Class[] classArray = new Class[1];
Class clazz = class$java$lang$String;
if (clazz == null) {
clazz = class$java$lang$String = CompProperty.class("[Ljava.lang.String;", false);
}
classArray[0] = clazz;
this.setParams = classArray;
} else if (bValue instanceof BBoolean) {
this.type = "boolean";
this.postfix = "Boolean";
this.setParams = new Class[]{Boolean.TYPE};
} else if (bValue instanceof BInteger) {
this.type = "int";
this.postfix = "Int";
this.setParams = new Class[]{Integer.TYPE};
} else if (bValue instanceof BFloat) {
this.type = "float";
this.postfix = "Float";
this.setParams = new Class[]{Float.TYPE};
} else {
this.cast = "(" + this.type + ')';
this.setParams = new Class[]{bValue.getClass()};
}
} else if (bValue.isValue()) {
this.cast = "(" + this.type + ')';
this.setParams = new Class[]{bValue.getClass()};
} else {
throw new IllegalStateException(this.bname + ", " + bValue.getType());
}
}
}
public static class CompAction {
public static final String ACTUAL_PARAM_VAR = "v";
public Action action;
public String name() {
return this.action.getName();
}
public String returnType() {
return this.action.getReturnType() == null ? "void" : "B" + this.action.getReturnType().getTypeName();
}
public String parameter() {
return this.action.getParameterDefault() == null ? "" : this.paramType() + " v";
}
public String paramType() {
return this.action.getParameterType() == null ? null : "B" + this.action.getParameterType().getTypeName();
}
public Class[] paramTypeArray() {
if (this.action.getParameterType() == null) {
return null;
}
return new Class[]{this.action.getParameterType().getInstance().getClass()};
}
public String paramDefault() {
BValue bValue = this.action.getParameterDefault();
if (bValue == null) {
return "null";
}
String string = this.paramType();
if (bValue.isSimple()) {
return "(BValue)" + string + ".TYPE.getInstance()";
}
return "new " + string + "()";
}
public String returnStmt() {
return this.action.getReturnType() == null ? "" : "return (" + this.returnType() + ')';
}
public String invokeParam() {
return this.paramType() == null ? "null" : ACTUAL_PARAM_VAR;
}
public String actualParam() {
return this.action.getParameterType() == null ? "" : ACTUAL_PARAM_VAR;
}
public String getDo() {
return "do" + TextUtil.capitalize((String)this.name());
}
public String getOn() {
return "on" + TextUtil.capitalize((String)this.name());
}
public CompAction(Action action) {
this.action = action;
}
}
}
@@ -0,0 +1,20 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.ui.BWidget
*/
package com.tridium.program.module;
import javax.baja.ui.BWidget;
public interface IBuildListener {
public void setNumBuildSteps(int var1);
public void nextStep(String var1);
public void updateDesc(String var1);
public BWidget getOwner();
}
@@ -0,0 +1,141 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.sys.Property
*/
package com.tridium.program.module;
import com.tridium.program.module.ComponentWriter;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.HashSet;
import javax.baja.sys.Property;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class ReflectUtil {
public static final int OK = 0;
public static final int WARN = 1;
public static final int ERR = 2;
HashMap methodMap = new HashMap();
static /* synthetic */ Class class$javax$baja$sys$BComponent;
public static ReflectUtil getInstance() {
return ReflectUtilHolder.INSTANCE;
}
public int getOverrideStatus(Method method) {
if (!this.isAccessible(method)) {
return 0;
}
return this.getOverrideStatus(method.getName(), method.getParameterTypes());
}
public int getPropertyStatus(Property property) {
ComponentWriter.CompProperty compProperty = new ComponentWriter.CompProperty(property);
if (this.getOverrideStatus(compProperty.getter(), new Class[0]) != 0) {
return 2;
}
if (this.getOverrideStatus(compProperty.setter(), compProperty.setParams) != 0) {
return 2;
}
return 0;
}
public int getOverrideStatus(String string, Class[] classArray) {
HashSet hashSet = (HashSet)this.methodMap.get(string);
if (hashSet == null) {
return 0;
}
Method[] methodArray = hashSet.toArray(new Method[hashSet.size()]);
int n = 0;
while (n < methodArray.length) {
if (this.isSameParameters(classArray, methodArray[n].getParameterTypes())) {
return Modifier.isFinal(methodArray[n].getModifiers()) + 1;
}
++n;
}
return 0;
}
public Class getDeclaringClass(Method method) {
Class[] classArray = method.getParameterTypes();
HashSet hashSet = (HashSet)this.methodMap.get(method.getName());
Method[] methodArray = hashSet.toArray(new Method[hashSet.size()]);
int n = 0;
while (n < methodArray.length) {
if (this.isSameParameters(classArray, methodArray[n].getParameterTypes())) {
return methodArray[n].getDeclaringClass();
}
++n;
}
return null;
}
private final boolean isSameParameters(Class[] classArray, Class[] classArray2) {
if (classArray.length != classArray2.length) {
return false;
}
int n = 0;
while (n < classArray.length) {
if (!classArray[n].equals(classArray2[n])) {
return false;
}
++n;
}
return true;
}
private final boolean isAccessible(Method method) {
int n = method.getModifiers();
boolean bl = false;
if (!Modifier.isStatic(n) && (Modifier.isPublic(n) || Modifier.isProtected(n))) {
bl = true;
}
return bl;
}
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());
}
}
protected ReflectUtil() {
Class clazz = class$javax$baja$sys$BComponent;
if (clazz == null) {
clazz = class$javax$baja$sys$BComponent = ReflectUtil.class("[Ljavax.baja.sys.BComponent;", false);
}
Method[] methodArray = clazz.getMethods();
int n = 0;
while (n < methodArray.length) {
String string = methodArray[n].getName();
if (this.isAccessible(methodArray[n])) {
if (this.methodMap.get(string) == null) {
this.methodMap.put(string, new HashSet());
}
HashSet hashSet = (HashSet)this.methodMap.get(string);
hashSet.add(methodArray[n]);
}
++n;
}
}
private static class ReflectUtilHolder {
private static final ReflectUtil INSTANCE = new ReflectUtil();
private ReflectUtilHolder() {
}
}
}
@@ -0,0 +1,329 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.gx.BImage
* javax.baja.naming.SlotPath
* javax.baja.nre.util.Array
* javax.baja.sys.Action
* javax.baja.sys.BDouble
* javax.baja.sys.BIcon
* javax.baja.sys.BLong
* javax.baja.sys.BObject
* javax.baja.sys.BValue
* javax.baja.sys.Property
* javax.baja.ui.table.TableModel
* javax.baja.util.Lexicon
* javax.baja.util.Version
*/
package com.tridium.program.module;
import com.tridium.program.BProgram;
import com.tridium.program.ProgramBase;
import com.tridium.program.module.BProgramModule;
import com.tridium.program.module.ComponentWriter;
import com.tridium.program.module.ReflectUtil;
import com.tridium.program.ui.BProgramEditor;
import java.lang.reflect.Method;
import javax.baja.gx.BImage;
import javax.baja.naming.SlotPath;
import javax.baja.nre.util.Array;
import javax.baja.sys.Action;
import javax.baja.sys.BDouble;
import javax.baja.sys.BIcon;
import javax.baja.sys.BLong;
import javax.baja.sys.BObject;
import javax.baja.sys.BValue;
import javax.baja.sys.Property;
import javax.baja.ui.table.TableModel;
import javax.baja.util.Lexicon;
import javax.baja.util.Version;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public abstract class ValidateModel
extends TableModel {
protected static final Lexicon lex;
public static final BImage okProgramIcon;
public static final BImage errProgramIcon;
public static final BImage warnProgramIcon;
protected static final BImage errIcon;
protected static final BImage warnIcon;
protected Array errs = new Array();
protected Array warns = new Array();
static /* synthetic */ Class class$com$tridium$program$module$BProgramModule;
public static ValidateModel make(BProgram bProgram) {
ValidateProgram validateProgram = new ValidateProgram(bProgram);
((ValidateModel)validateProgram).validate();
return validateProgram;
}
public static ValidateModel make(BProgramModule bProgramModule) {
ValidateModule validateModule = new ValidateModule(bProgramModule);
((ValidateModel)validateModule).validate();
return validateModule;
}
public BImage getProgramStatusIcon() {
if (this.getErrCount() > 0) {
return errProgramIcon;
}
if (this.getWarnCount() > 0) {
return warnProgramIcon;
}
return okProgramIcon;
}
public final int getErrCount() {
return this.errs.size();
}
public final int getWarnCount() {
return this.warns.size();
}
protected abstract void validate();
public void err(String string) {
if (!this.errs.contains((Object)string)) {
this.errs.add((Object)string);
}
}
public void warn(String string) {
if (!this.warns.contains((Object)string)) {
this.warns.add((Object)string);
}
}
public int getColumnCount() {
return 1;
}
public int getRowCount() {
return this.errs.size() + this.warns.size();
}
public Object getValueAt(int n, int n2) {
int n3 = this.getErrCount();
if (n < n3) {
return this.errs.get(n);
}
return this.warns.get(n - n3);
}
public BImage getRowIcon(int n) {
return n < this.getErrCount() ? errIcon : warnIcon;
}
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());
}
}
static {
Class clazz = class$com$tridium$program$module$BProgramModule;
if (clazz == null) {
clazz = class$com$tridium$program$module$BProgramModule = ValidateModel.class("[Lcom.tridium.program.module.BProgramModule;", false);
}
lex = Lexicon.make((Class)clazz);
okProgramIcon = BImage.make((BIcon)new BProgram().getIcon());
errProgramIcon = BImage.make((BIcon)BIcon.make((BIcon)new BProgram().getIcon(), (BIcon)BIcon.std((String)"badges/error.png")));
warnProgramIcon = BImage.make((BIcon)BIcon.make((BIcon)new BProgram().getIcon(), (BIcon)BIcon.std((String)"badges/warning.png")));
errIcon = BImage.make((BIcon)BIcon.std((String)"stop.png"));
warnIcon = BImage.make((BIcon)BIcon.std((String)"warning.png"));
}
private static class ValidateProgram
extends ValidateModel {
private static final BProgramEditor pe = new BProgramEditor();
BProgram program;
public String getColumnName(int n) {
return lex.getText("vprogram.col");
}
protected void validate() {
this.checkCompileStatus();
this.checkName();
this.checkLongAndDoubleSlots();
this.checkPropertySlots();
this.checkActionDelegates();
this.checkReflection();
}
public void err(String string) {
super.err("[" + BProgramModule.toTypeName(this.program) + "] " + string);
}
public void warn(String string) {
super.warn("[" + BProgramModule.toTypeName(this.program) + "] " + string);
}
private final void checkCompileStatus() {
pe.loadValue((BObject)this.program);
int n = this.program.getCode().getChecksum();
if (n == 0 || n != pe.computeChecksum(this.program.getCode().getSource())) {
this.err(lex.getText("vprogram.err.outofdate"));
}
}
private final void checkName() {
if (BProgramModule.toComponentName(this.program) == null) {
this.err(lex.getText("vprogram.err.name"));
}
}
private final void checkLongAndDoubleSlots() {
Property[] propertyArray = this.program.getPropertiesArray();
int n = 0;
while (n < propertyArray.length) {
BValue bValue = propertyArray[n].getDefaultValue();
if (bValue instanceof BDouble) {
this.err(lex.getText("vprogram.err.double", new Object[]{propertyArray[n].getName()}));
} else if (bValue instanceof BLong) {
this.err(lex.getText("vprogram.err.long", new Object[]{propertyArray[n].getName()}));
}
++n;
}
}
private final void checkPropertySlots() {
Property[] propertyArray = this.program.getPropertiesArray();
int n = 0;
while (n < propertyArray.length) {
if (ReflectUtil.getInstance().getPropertyStatus(propertyArray[n]) != 0) {
this.err(lex.getText("vprogram.err.getset", new Object[]{propertyArray[n].getName()}));
}
++n;
}
}
private final void checkActionDelegates() {
Class<?> clazz = null;
try {
clazz = this.program.getCode().newInstance().getClass();
}
catch (Exception exception) {
return;
}
Action[] actionArray = this.program.getActionsArray();
int n = 0;
while (n < actionArray.length) {
ComponentWriter.CompAction compAction = new ComponentWriter.CompAction(actionArray[n]);
if (!"onExecute".equals(compAction.getOn())) {
String string = compAction.paramType() == null ? "" : compAction.paramType();
String string2 = compAction.getOn() + '(' + string + ')';
Object[] objectArray = new Object[]{compAction.name(), string2};
try {
Method method = clazz.getDeclaredMethod(compAction.getOn(), compAction.paramTypeArray());
if ((method.getModifiers() & 1) == 0) {
this.err(lex.getText("vprogram.err.delegate.public", objectArray));
}
}
catch (NoSuchMethodException noSuchMethodException) {
this.err(lex.getText("vprogram.err.delegate", objectArray));
}
}
++n;
}
}
private final void checkReflection() {
ProgramBase programBase = this.program.getCode().newProgramInstance();
Method[] methodArray = programBase.getClass().getDeclaredMethods();
ReflectUtil reflectUtil = ReflectUtil.getInstance();
int n = 0;
while (n < methodArray.length) {
switch (reflectUtil.getOverrideStatus(methodArray[n])) {
case 2: {
this.err(lex.getText("vprogram.err.override", new Object[]{this.toMethodDef(methodArray[n])}));
break;
}
case 1: {
if ("toString".equals(methodArray[n].getName())) break;
this.warn(lex.getText("vprogram.warn.override", new Object[]{this.toMethodDef(methodArray[n])}));
break;
}
}
++n;
}
}
private final String toMethodDef(Method method) {
StringBuffer stringBuffer = new StringBuffer().append(ReflectUtil.getInstance().getDeclaringClass(method).getName()).append(".").append(method.getName()).append("(");
Class<?>[] classArray = method.getParameterTypes();
int n = 0;
while (n < classArray.length) {
if (n > 0) {
stringBuffer.append(",");
}
stringBuffer.append(classArray[n].getName());
++n;
}
stringBuffer.append(")");
return stringBuffer.toString();
}
public ValidateProgram(BProgram bProgram) {
this.program = bProgram;
}
}
private static class ValidateModule
extends ValidateModel {
BProgramModule module;
public String getColumnName(int n) {
return lex.getText("vmodule.col");
}
protected void validate() {
this.checkName();
this.checkVendor();
this.checkVersion();
if (this.module.listPrograms().length == 0) {
this.warn(lex.getText("vmodule.warn.noPrograms"));
}
}
private final void checkName() {
if (!SlotPath.isValidName((String)this.module.getModuleName())) {
this.err(lex.getText("vmodule.err.name", new Object[]{this.module.getModuleName()}));
}
}
private final void checkVendor() {
if (this.module.getVendor().length() == 0) {
this.err(lex.getText("vmodule.err.vendor"));
}
}
private final void checkVersion() {
try {
Version version = new Version(this.module.getVendorVersion());
if (version.toString().length() == 0) {
this.err(lex.getText("vmodule.err.verRequired"));
}
}
catch (Exception exception) {
this.err(lex.getText("vmodule.err.version", new Object[]{this.module.getVendorVersion()}));
}
}
public ValidateModule(BProgramModule bProgramModule) {
this.module = bProgramModule;
}
}
}
@@ -0,0 +1,88 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.space.Mark
* javax.baja.sys.BObject
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.CommandArtifact
* javax.baja.ui.transfer.TransferContext
* javax.baja.ui.transfer.TransferFormat
* javax.baja.ui.transfer.UnsupportedFormatException
* javax.baja.ui.util.UiLexicon
* javax.baja.workbench.mgr.BMgrTable
* javax.baja.workbench.mgr.MgrModel
*/
package com.tridium.program.ui;
import com.tridium.program.BProgram;
import javax.baja.space.Mark;
import javax.baja.sys.BObject;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.CommandArtifact;
import javax.baja.ui.transfer.TransferContext;
import javax.baja.ui.transfer.TransferFormat;
import javax.baja.ui.transfer.UnsupportedFormatException;
import javax.baja.ui.util.UiLexicon;
import javax.baja.workbench.mgr.BMgrTable;
import javax.baja.workbench.mgr.MgrModel;
public class BBuilderTable
extends BMgrTable {
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$BBuilderTable == null ? (class$com$tridium$program$ui$BBuilderTable = BBuilderTable.class$("com.tridium.program.ui.BBuilderTable")) : class$com$tridium$program$ui$BBuilderTable));
static /* synthetic */ Class class$com$tridium$program$ui$BBuilderTable;
public Type getType() {
return TYPE;
}
public BBuilderTable(MgrModel mgrModel) {
super(mgrModel);
}
public int getRowOfProgram(String string) {
int n = this.getModel().getRowCount();
for (int i = 0; i < n; ++i) {
if (!this.getComponentAt(i).getDisplayName(null).equals(string)) continue;
return i;
}
return -1;
}
public int dragOver(TransferContext transferContext) {
return this.isAllPrograms(transferContext) ? super.dragOver(transferContext) : 0;
}
public boolean isPasteSpecialEnabled() {
return false;
}
public CommandArtifact insertTransferData(TransferContext transferContext) throws Exception {
if (!this.isAllPrograms(transferContext)) {
throw new UnsupportedFormatException(UiLexicon.bajaui().getText("command.paste.unsupportedFormat"));
}
return this.drop(transferContext);
}
private boolean isAllPrograms(TransferContext transferContext) {
Mark mark = (Mark)transferContext.getEnvelope().getData(TransferFormat.mark);
BObject[] bObjectArray = mark.getValues();
for (int i = 0; i < bObjectArray.length; ++i) {
if (bObjectArray[i] instanceof BProgram) continue;
return false;
}
return true;
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
}
@@ -0,0 +1,256 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.gx.BColor
* javax.baja.gx.BImage
* javax.baja.gx.Graphics
* javax.baja.nre.util.Array
* javax.baja.nre.util.TextUtil
* 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.BasicContext
* javax.baja.sys.Context
* javax.baja.sys.Flags
* javax.baja.sys.Property
* javax.baja.sys.Slot
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BLabel
* javax.baja.ui.BWidget
* javax.baja.ui.event.BWidgetEvent
* javax.baja.workbench.BWbEditor
* javax.baja.workbench.CannotSaveException
* javax.baja.workbench.fieldeditor.BWbFieldEditor
*/
package com.tridium.program.ui;
import javax.baja.gx.BColor;
import javax.baja.gx.BImage;
import javax.baja.gx.Graphics;
import javax.baja.nre.util.Array;
import javax.baja.nre.util.TextUtil;
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.BasicContext;
import javax.baja.sys.Context;
import javax.baja.sys.Flags;
import javax.baja.sys.Property;
import javax.baja.sys.Slot;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BLabel;
import javax.baja.ui.BWidget;
import javax.baja.ui.event.BWidgetEvent;
import javax.baja.workbench.BWbEditor;
import javax.baja.workbench.CannotSaveException;
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
public class BFieldSheet
extends BWbEditor {
public static final Property labelMargin = BFieldSheet.newProperty((int)0, (double)10.0, null);
public static final Property rowGap = BFieldSheet.newProperty((int)0, (double)8.0, null);
public static final Property indent = BFieldSheet.newProperty((int)0, (double)0.0, null);
public static final Action handleEditorModified = BFieldSheet.newAction((int)0, (BValue)new BWidgetEvent(), null);
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$BFieldSheet == null ? (class$com$tridium$program$ui$BFieldSheet = BFieldSheet.class$("com.tridium.program.ui.BFieldSheet")) : class$com$tridium$program$ui$BFieldSheet));
public static final String FORCE_SHOW = "fieldSheetShow";
static final BColor dividerColor = BColor.make((int)0xBBBBBB);
static BImage defaultIcon = BImage.make((String)"module://icons/x16/object.png");
boolean showModified;
private Array fields;
private double[] divs;
static /* synthetic */ Class class$com$tridium$program$ui$BFieldSheet;
static /* synthetic */ Class class$com$tridium$program$ui$BFieldSheet$Field;
public double getLabelMargin() {
return this.getDouble(labelMargin);
}
public void setLabelMargin(double d) {
this.setDouble(labelMargin, d, null);
}
public double getRowGap() {
return this.getDouble(rowGap);
}
public void setRowGap(double d) {
this.setDouble(rowGap, d, null);
}
public double getIndent() {
return this.getDouble(indent);
}
public void setIndent(double d) {
this.setDouble(indent, d, null);
}
public void handleEditorModified(BWidgetEvent bWidgetEvent) {
this.invoke(handleEditorModified, (BValue)bWidgetEvent, null);
}
public Type getType() {
return TYPE;
}
public BFieldSheet() {
this(true);
}
public BFieldSheet(boolean bl) {
this.showModified = bl;
}
public void doLoadValue(BObject bObject, Context context) {
BComponent bComponent = (BComponent)bObject;
Property[] propertyArray = bComponent.getPropertiesArray();
this.fields = new Array(class$com$tridium$program$ui$BFieldSheet$Field == null ? (class$com$tridium$program$ui$BFieldSheet$Field = BFieldSheet.class$("com.tridium.program.ui.BFieldSheet$Field")) : class$com$tridium$program$ui$BFieldSheet$Field, propertyArray.length);
for (int i = 0; i < propertyArray.length; ++i) {
Property property = propertyArray[i];
if (Flags.isHidden((BComplex)bComponent, (Slot)property) || property.isDynamic() && !property.getFacets().getb(FORCE_SHOW, false)) continue;
BValue bValue = bComponent.get(property);
BWbFieldEditor bWbFieldEditor = BWbFieldEditor.makeFor((BObject)bValue, (Context)property.getFacets());
bWbFieldEditor.setReadonly((property.getDefaultFlags() & 1) != 0);
bWbFieldEditor.loadValue((BObject)bValue, (Context)new BasicContext(context, property.getFacets()));
String string = null;
BImage bImage = null;
string = property.getFacets().gets("iconOverride", null);
bImage = string != null ? BImage.make((BIcon)BIcon.make((String)string)) : BImage.make((BIcon)bValue.getIcon());
if (bImage == null) {
bImage = defaultIcon;
}
Field field = new Field(property, new BLabel(bImage, TextUtil.toFriendly((String)property.getName())), bWbFieldEditor);
field.icon = bImage;
this.add("label" + i, (BValue)field.label);
this.add("editor" + i, (BValue)field.editor);
this.linkTo((BComponent)field.editor, (Slot)BWbFieldEditor.setModified, (Slot)setModified);
this.linkTo((BComponent)field.editor, (Slot)BWbFieldEditor.setModified, (Slot)handleEditorModified);
this.fields.add((Object)field);
}
this.divs = new double[this.fields.size()];
}
public BObject doSaveValue(BObject bObject, Context context) throws CannotSaveException, Exception {
int n;
BComponent bComponent = (BComponent)bObject;
int n2 = this.fields.size();
for (n = 0; n < n2; ++n) {
Field field = (Field)this.fields.get(n);
if (!field.editor.isModified()) continue;
bComponent.set(field.prop, (BValue)field.editor.saveValue((BObject)bComponent.get(field.prop), context));
}
for (n = 0; n < n2; ++n) {
((Field)this.fields.get((int)n)).editor.clearModified();
}
this.handleEditorModified(null);
this.clearModified();
return bComponent;
}
public void computePreferredSize() {
if (this.fields == null) {
this.setPreferredSize(0.0, 0.0);
return;
}
double d = 0.0;
double d2 = 0.0;
double d3 = 0.0;
int n = this.fields.size();
for (int i = 0; i < n; ++i) {
Field field = (Field)this.fields.get(i);
field.label.computePreferredSize();
field.editor.computePreferredSize();
if (i == 0) {
d = field.label.getPreferredWidth();
d2 = field.editor.getPreferredWidth();
} else {
d = Math.max(d, field.label.getPreferredWidth());
d2 = Math.max(d2, field.editor.getPreferredWidth());
}
if (i != 0) {
d3 += this.getRowGap();
}
d3 += Math.max(field.label.getPreferredHeight(), field.editor.getPreferredHeight());
}
this.setPreferredSize(this.getIndent() + d + d2 + this.getLabelMargin(), d3);
}
public void doLayout(BWidget[] bWidgetArray) {
if (this.fields == null) {
return;
}
double d = 0.0;
int n = this.fields.size();
for (int i = 0; i < n; ++i) {
Field field = (Field)this.fields.get(i);
field.label.computePreferredSize();
field.editor.computePreferredSize();
d = i == 0 ? field.label.getPreferredWidth() : Math.max(d, field.label.getPreferredWidth());
}
double d2 = 0.0;
double d3 = this.getIndent();
for (int i = 0; i < n; ++i) {
Field field = (Field)this.fields.get(i);
double d4 = Math.max(field.label.getPreferredHeight(), field.editor.getPreferredHeight());
field.label.setBounds(d3, d2 + (d4 - field.label.getPreferredHeight()) / 2.0, field.label.getPreferredWidth(), d4);
field.editor.setBounds(d3 + d + this.getLabelMargin(), d2 + (d4 - field.editor.getPreferredHeight()) / 2.0, field.editor.getPreferredWidth(), d4);
this.divs[i] = d2 += d4 + this.getRowGap();
}
}
public void paint(Graphics graphics) {
this.paintChildren(graphics);
for (int i = 0; i < this.divs.length; ++i) {
double d = this.divs[i] - this.getRowGap() / 2.0;
graphics.setBrush(dividerColor);
graphics.strokeLine(0.0, d, this.getWidth(), d);
}
}
public void doHandleEditorModified(BWidgetEvent bWidgetEvent) {
if (!this.showModified) {
return;
}
for (int i = 0; i < this.fields.size(); ++i) {
Field field = (Field)this.fields.get(i);
if (field.editor.isModified()) {
field.label.setImage(field.icon.getHighlightedImage());
continue;
}
field.label.setImage(field.icon);
}
this.repaint();
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
private class Field {
public Property prop;
public BLabel label;
public BWbFieldEditor editor;
public BImage icon;
public Field(Property property, BLabel bLabel, BWbFieldEditor bWbFieldEditor) {
this.prop = property;
this.label = bLabel;
this.editor = bWbFieldEditor;
}
}
}
@@ -0,0 +1,396 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.workbench.console.BConsole$HyperlinkInterceptor
* com.tridium.workbench.shell.BNiagaraWbShell
* com.tridium.workbench.slotsheet.BSlotSheet
* javax.baja.gx.BImage
* javax.baja.naming.BOrd
* javax.baja.naming.SlotPath
* javax.baja.sys.Action
* javax.baja.sys.BComponent
* javax.baja.sys.BComponentEvent
* javax.baja.sys.BObject
* javax.baja.sys.BValue
* javax.baja.sys.Context
* javax.baja.sys.Property
* javax.baja.sys.Slot
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BButton
* javax.baja.ui.BLabel
* javax.baja.ui.BMenu
* javax.baja.ui.BToolBar
* javax.baja.ui.BWidget
* javax.baja.ui.CommandArtifact
* javax.baja.ui.enums.BHalign
* javax.baja.ui.pane.BBorderPane
* javax.baja.ui.pane.BEdgePane
* javax.baja.ui.pane.BGridPane
* javax.baja.ui.pane.BTabbedPane
* javax.baja.ui.pane.BTextEditorPane
* javax.baja.ui.text.BTextEditor
* javax.baja.ui.text.Position
* javax.baja.ui.text.TextParser
* javax.baja.ui.text.parsers.JavaParser
* javax.baja.ui.transfer.BTransferWidget
* javax.baja.ui.util.UiLexicon
* javax.baja.workbench.view.BWbComponentView
*/
package com.tridium.program.ui;
import com.tridium.program.BProgram;
import com.tridium.program.BProgramCode;
import com.tridium.program.module.BProgramModule;
import com.tridium.program.ui.Imports;
import com.tridium.program.ui.ProgramCompiler;
import com.tridium.program.ui.ProgramEditorCommands;
import com.tridium.program.ui.SourceWriter;
import com.tridium.workbench.console.BConsole;
import com.tridium.workbench.shell.BNiagaraWbShell;
import com.tridium.workbench.slotsheet.BSlotSheet;
import java.io.File;
import javax.baja.gx.BImage;
import javax.baja.naming.BOrd;
import javax.baja.naming.SlotPath;
import javax.baja.sys.Action;
import javax.baja.sys.BComponent;
import javax.baja.sys.BComponentEvent;
import javax.baja.sys.BObject;
import javax.baja.sys.BValue;
import javax.baja.sys.Context;
import javax.baja.sys.Property;
import javax.baja.sys.Slot;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BButton;
import javax.baja.ui.BLabel;
import javax.baja.ui.BMenu;
import javax.baja.ui.BToolBar;
import javax.baja.ui.BWidget;
import javax.baja.ui.CommandArtifact;
import javax.baja.ui.enums.BHalign;
import javax.baja.ui.pane.BBorderPane;
import javax.baja.ui.pane.BEdgePane;
import javax.baja.ui.pane.BGridPane;
import javax.baja.ui.pane.BTabbedPane;
import javax.baja.ui.pane.BTextEditorPane;
import javax.baja.ui.text.BTextEditor;
import javax.baja.ui.text.Position;
import javax.baja.ui.text.TextParser;
import javax.baja.ui.text.parsers.JavaParser;
import javax.baja.ui.transfer.BTransferWidget;
import javax.baja.ui.util.UiLexicon;
import javax.baja.workbench.view.BWbComponentView;
public class BProgramEditor
extends BWbComponentView
implements BConsole.HyperlinkInterceptor {
public static final Action codeTextModified = BProgramEditor.newAction((int)0, null);
public static final Action tabSelectionModified = BProgramEditor.newAction((int)0, null);
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$BProgramEditor == null ? (class$com$tridium$program$ui$BProgramEditor = BProgramEditor.class$("com.tridium.program.ui.BProgramEditor")) : class$com$tridium$program$ui$BProgramEditor));
static UiLexicon lex = UiLexicon.bajaui;
static String statusOk = lex.getText("programEditor.status.ok");
static String statusNeedsCompile = lex.getText("programEditor.status.needsCompile");
static String statusError = lex.getText("programEditor.status.error");
static BImage statusOkIcon = BImage.make((String)"module://icons/x16/shapes/circleGreen.png");
static BImage statusNeedsCompileIcon = BImage.make((String)"module://icons/x16/shapes/circleGold.png");
static BImage statusErrorIcon = BImage.make((String)"module://icons/x16/shapes/circleRed.png");
static BImage editIcon = BImage.make((String)"module://icons/x16/edit.png");
static BImage slotsIcon = BImage.make((String)"module://icons/x16/page.png");
static BImage importsIcon = BImage.make((String)"module://icons/x16/module.png");
static BImage sourceIcon = BImage.make((String)"module://icons/x16/script.png");
static BImage addIcon = BImage.make((String)"module://icons/x16/add.png");
static BImage removeIcon = BImage.make((String)"module://icons/x16/delete.png");
static final String boilerPlate = "public void onStart() throws Exception\n{\n // start up code here\n}\n\npublic void onExecute() throws Exception\n{\n // execute code (set executeOnChange flag on inputs)\n}\n\npublic void onStop() throws Exception\n{\n // shutdown code here\n}\n\n";
ProgramEditorCommands commands = new ProgramEditorCommands(this);
ProgramCompiler compiler = new ProgramCompiler(this);
int sourceLine;
BProgram program;
BProgramCode code;
BTabbedPane tabs;
boolean modified = false;
BWidget statusPane;
BLabel status;
BWidget editTab;
BTextEditor editText;
BWidget slotTab;
BSlotSheet slotSheet;
Imports imports = new Imports(this);
BWidget importsTab;
BWidget sourceTab;
BTextEditor sourceText;
static /* synthetic */ Class class$com$tridium$program$ui$BProgramEditor;
public void codeTextModified() {
this.invoke(codeTextModified, null, null);
}
public void tabSelectionModified() {
this.invoke(tabSelectionModified, null, null);
}
public Type getType() {
return TYPE;
}
public BProgramEditor() {
this.autoRegisterForComponentEvents = false;
this.setContent((BWidget)new BLabel("ProgramEditor"));
this.initStatusPane();
this.initEditPane();
this.initSlotPane();
this.initImportsPane();
this.initSourcePane();
this.tabs = new BTabbedPane();
this.tabs.addPane(lex.getText("programEditor.edit"), editIcon, this.editTab);
this.tabs.addPane(lex.getText("programEditor.slots"), slotsIcon, this.slotTab);
this.tabs.addPane(lex.getText("programEditor.imports"), importsIcon, this.importsTab);
this.tabs.addPane(lex.getText("programEditor.source"), sourceIcon, this.sourceTab);
this.linkTo(null, (BComponent)this.editText, (Slot)BTextEditor.textModified, (Slot)codeTextModified);
this.linkTo(null, (BComponent)this.tabs, (Slot)BTabbedPane.selectionModified, (Slot)tabSelectionModified);
BEdgePane bEdgePane = new BEdgePane();
bEdgePane.setTop(this.statusPane);
bEdgePane.setCenter((BWidget)this.tabs);
this.setContent((BWidget)bEdgePane);
}
private void initStatusPane() {
this.status = new BLabel("status not initialized");
this.status.setHalign(BHalign.left);
this.statusPane = new BBorderPane((BWidget)this.status, 5.0, 0.0, 10.0, 0.0);
}
private void initEditPane() {
this.editText = new BTextEditor();
this.editText.setParser((TextParser)new JavaParser());
BTextEditorPane bTextEditorPane = new BTextEditorPane(this.editText);
this.editTab = bTextEditorPane;
}
private void initSlotPane() {
this.slotSheet = new BSlotSheet();
this.slotTab = this.slotSheet;
}
private void initImportsPane() {
BGridPane bGridPane = new BGridPane(3);
bGridPane.add(null, (BValue)new BButton(this.commands.importType));
bGridPane.add(null, (BValue)new BButton(this.commands.importPackage));
bGridPane.add(null, (BValue)new BButton(this.commands.removeImport));
bGridPane.setUniformColumnWidth(true);
bGridPane.setColumnAlign(BHalign.fill);
BEdgePane bEdgePane = new BEdgePane();
bEdgePane.setCenter((BWidget)this.imports.table);
bEdgePane.setBottom((BWidget)new BBorderPane((BWidget)bGridPane));
this.importsTab = bEdgePane;
}
private void initSourcePane() {
this.sourceText = new BTextEditor();
this.sourceText.setEditable(false);
this.sourceText.setParser((TextParser)new JavaParser());
BTextEditorPane bTextEditorPane = new BTextEditorPane(this.sourceText);
this.sourceTab = bTextEditorPane;
}
public BMenu[] getViewMenus() {
return this.commands.getViewMenus();
}
public BToolBar getViewToolBar() {
return this.commands.getViewToolBar();
}
public void doLoadValue(BObject bObject, Context context) {
this.program = (BProgram)bObject;
this.registerForComponentEvents(this.program, 1);
this.code = (BProgramCode)this.program.getCode().newCopy();
this.loadCode();
this.imports.load(this.code);
this.slotSheet.doLoadValue((BObject)this.program, context);
this.updateStatus();
this.tabs.selectPane(this.editTab);
}
public BObject doSaveValue(BObject bObject, Context context) throws Exception {
this.saveCode();
this.imports.save(this.code);
this.program.setCode(this.code);
this.program.updateActionParameters();
this.modified = false;
this.updateStatus();
return this.program;
}
public CommandArtifact invokeCommand(int n) throws Exception {
BTextEditor bTextEditor = this.getActiveTextEditor();
if (bTextEditor == null) {
return null;
}
switch (n) {
case 6: {
return bTextEditor.doFind();
}
case 8: {
return bTextEditor.doFindNext();
}
case 7: {
return bTextEditor.doFindPrev();
}
case 9: {
return bTextEditor.doReplace();
}
case 10: {
return bTextEditor.doGoto();
}
}
return super.invokeCommand(n);
}
public BTextEditor getActiveTextEditor() {
BWidget bWidget = this.tabs.getSelectedPane();
if (bWidget == this.editTab) {
return this.editText;
}
if (bWidget == this.sourceTab) {
return this.sourceText;
}
return null;
}
public void updateEditorCommands() {
BTextEditor bTextEditor = this.getActiveTextEditor();
if (bTextEditor != null) {
bTextEditor.updateEnableStates();
}
this.setTransferWidget((BTransferWidget)bTextEditor);
boolean bl = bTextEditor != null;
this.setCommandEnabled(6, bl);
this.setCommandEnabled(8, bl);
this.setCommandEnabled(7, bl);
this.setCommandEnabled(9, bl && bTextEditor.isEditable());
this.setCommandEnabled(10, bl);
}
public boolean consoleHyperlink(File file, int n, int n2, int n3, int n4) {
if (!file.equals(this.compiler.java)) {
BOrd bOrd = BOrd.make((String)SlotPath.unescape((String)file.getName()));
BObject bObject = bOrd.get();
if (bObject instanceof BProgramModule || bObject instanceof BProgram) {
((BNiagaraWbShell)this.getWbShell()).hyperlink(bOrd);
return true;
}
return false;
}
this.highlight(n, n2, n3, n4);
return true;
}
public void highlight(int n, int n2, int n3, int n4) {
this.tabs.selectPane(this.editTab);
this.highlight(this.editText, n -= this.sourceLine, n2 -= 2, n3 -= this.sourceLine, n4 -= 2);
}
void highlight(BTextEditor bTextEditor, int n, int n2, int n3, int n4) {
Position position = bTextEditor.getModel().getEndPosition();
Position position2 = new Position(n - 1, n2 - 1);
Position position3 = new Position(n3 - 1, n4);
if (position2.compareTo((Object)position) > 0) {
position2 = position;
}
if (position3.compareTo((Object)position) > 0) {
position3 = position;
}
bTextEditor.getSelection().select(position2, position3);
bTextEditor.moveCaretPosition(position3);
bTextEditor.requestFocus();
}
public void updateStatus() {
if (this.modified || this.computeChecksum(this.editText.getText()) != this.program.getCode().getChecksum()) {
this.status.setText(statusNeedsCompile);
this.status.setImage(statusNeedsCompileIcon);
} else {
this.status.setText(statusOk);
this.status.setImage(statusOkIcon);
}
}
public void updateProgramCode() {
this.program.setCode(this.code);
}
public void updateStatusToError() {
this.status.setText(statusError);
this.status.setImage(statusErrorIcon);
}
public void updateSource() {
char[] cArray = SourceWriter.generateToCharArray(this, "ProgramImpl");
this.sourceText.getModel().read(cArray);
}
public void saveCode() {
String string = this.editText.getText();
this.code.setSource(string);
this.imports.updateImports();
}
public void loadCode() {
String string = this.code.getSource();
if (string.length() == 0) {
string = boilerPlate;
}
this.editText.setText(string);
}
public int computeChecksum(String string) {
int n = string.hashCode();
Property[] propertyArray = this.program.getPropertiesArray();
for (int i = 0; i < propertyArray.length; ++i) {
Property property = propertyArray[i];
if (property.isFrozen()) continue;
n ^= property.getName().hashCode();
n ^= property.getType().getTypeName().hashCode();
}
return n;
}
public void doCodeTextModified() {
if (!this.isModifiedStateLocked()) {
this.setModified();
this.modified = true;
this.updateStatus();
}
}
public void doTabSelectionModified() {
this.updateEditorCommands();
this.saveCode();
this.updateSource();
}
public void handleComponentEvent(BComponentEvent bComponentEvent) {
this.slotSheet.handleComponentEvent(bComponentEvent);
this.imports.updateImports();
switch (bComponentEvent.getId()) {
case 1:
case 2:
case 3: {
this.updateStatus();
}
}
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
}
@@ -0,0 +1,622 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.ui.theme.Theme
* com.tridium.workbench.console.BConsole
* com.tridium.workbench.transfer.TransferUtil
* javax.baja.gx.BFont
* javax.baja.gx.BImage
* javax.baja.gx.BInsets
* javax.baja.gx.Graphics
* javax.baja.naming.BOrd
* javax.baja.naming.ViewQuery
* javax.baja.nre.util.SortUtil
* javax.baja.sys.Action
* javax.baja.sys.BComponent
* javax.baja.sys.BComponentEvent
* javax.baja.sys.BFacets
* javax.baja.sys.BIcon
* javax.baja.sys.BObject
* javax.baja.sys.BString
* javax.baja.sys.BValue
* javax.baja.sys.BVector
* javax.baja.sys.Context
* javax.baja.sys.Property
* javax.baja.sys.Slot
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BDialog
* javax.baja.ui.BLabel
* javax.baja.ui.BNullWidget
* javax.baja.ui.BProgressDialog
* javax.baja.ui.BProgressDialog$Worker
* javax.baja.ui.BToolBar
* javax.baja.ui.BWidget
* javax.baja.ui.CommandArtifact
* javax.baja.ui.enums.BOrientation
* javax.baja.ui.enums.BScrollBarPolicy
* javax.baja.ui.event.BMouseEvent
* javax.baja.ui.pane.BBorderPane
* javax.baja.ui.pane.BEdgePane
* javax.baja.ui.pane.BExpandablePane
* javax.baja.ui.pane.BScrollPane
* javax.baja.ui.pane.BSplitPane
* javax.baja.ui.table.BTable
* javax.baja.ui.table.TableCellRenderer
* javax.baja.ui.table.TableCellRenderer$Cell
* javax.baja.ui.table.TableModel
* javax.baja.ui.transfer.TransferContext
* javax.baja.util.BFolder
* javax.baja.util.BNameMap
* javax.baja.util.Lexicon
* javax.baja.workbench.BWbShell
* javax.baja.workbench.CannotSaveException
* javax.baja.workbench.component.table.BComponentTable
* javax.baja.workbench.component.table.ComponentTableCellRenderer
* javax.baja.workbench.mgr.BAbstractManager
* javax.baja.workbench.mgr.BMgrTable
* javax.baja.workbench.mgr.MgrColumn
* javax.baja.workbench.mgr.MgrColumn$Name
* javax.baja.workbench.mgr.MgrController
* javax.baja.workbench.mgr.MgrController$IMgrCommand
* javax.baja.workbench.mgr.MgrController$MgrCommand
* javax.baja.workbench.mgr.MgrModel
* javax.baja.workbench.mgr.folder.BFolderManager
* javax.baja.workbench.mgr.folder.FolderController
* javax.baja.workbench.mgr.folder.FolderModel
*/
package com.tridium.program.ui;
import com.tridium.program.BCode;
import com.tridium.program.BProgram;
import com.tridium.program.module.BProgramModule;
import com.tridium.program.module.IBuildListener;
import com.tridium.program.module.ValidateModel;
import com.tridium.program.ui.BBuilderTable;
import com.tridium.program.ui.BFieldSheet;
import com.tridium.program.ui.BProgramEditor;
import com.tridium.program.ui.Compiler;
import com.tridium.program.ui.SourceWriter;
import com.tridium.ui.theme.Theme;
import com.tridium.workbench.console.BConsole;
import com.tridium.workbench.transfer.TransferUtil;
import java.io.FileWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Iterator;
import javax.baja.gx.BFont;
import javax.baja.gx.BImage;
import javax.baja.gx.BInsets;
import javax.baja.gx.Graphics;
import javax.baja.naming.BOrd;
import javax.baja.naming.ViewQuery;
import javax.baja.nre.util.SortUtil;
import javax.baja.sys.Action;
import javax.baja.sys.BComponent;
import javax.baja.sys.BComponentEvent;
import javax.baja.sys.BFacets;
import javax.baja.sys.BIcon;
import javax.baja.sys.BObject;
import javax.baja.sys.BString;
import javax.baja.sys.BValue;
import javax.baja.sys.BVector;
import javax.baja.sys.Context;
import javax.baja.sys.Property;
import javax.baja.sys.Slot;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BDialog;
import javax.baja.ui.BLabel;
import javax.baja.ui.BNullWidget;
import javax.baja.ui.BProgressDialog;
import javax.baja.ui.BToolBar;
import javax.baja.ui.BWidget;
import javax.baja.ui.CommandArtifact;
import javax.baja.ui.enums.BOrientation;
import javax.baja.ui.enums.BScrollBarPolicy;
import javax.baja.ui.event.BMouseEvent;
import javax.baja.ui.pane.BBorderPane;
import javax.baja.ui.pane.BEdgePane;
import javax.baja.ui.pane.BExpandablePane;
import javax.baja.ui.pane.BScrollPane;
import javax.baja.ui.pane.BSplitPane;
import javax.baja.ui.table.BTable;
import javax.baja.ui.table.TableCellRenderer;
import javax.baja.ui.table.TableModel;
import javax.baja.ui.transfer.TransferContext;
import javax.baja.util.BFolder;
import javax.baja.util.BNameMap;
import javax.baja.util.Lexicon;
import javax.baja.workbench.BWbShell;
import javax.baja.workbench.CannotSaveException;
import javax.baja.workbench.component.table.BComponentTable;
import javax.baja.workbench.component.table.ComponentTableCellRenderer;
import javax.baja.workbench.mgr.BAbstractManager;
import javax.baja.workbench.mgr.BMgrTable;
import javax.baja.workbench.mgr.MgrColumn;
import javax.baja.workbench.mgr.MgrController;
import javax.baja.workbench.mgr.MgrModel;
import javax.baja.workbench.mgr.folder.BFolderManager;
import javax.baja.workbench.mgr.folder.FolderController;
import javax.baja.workbench.mgr.folder.FolderModel;
public class BProgramModuleBuilder
extends BFolderManager {
public static final Action handleSelection = BProgramModuleBuilder.newAction((int)4, null);
public static final Action handleModified = BProgramModuleBuilder.newAction((int)4, null);
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$BProgramModuleBuilder == null ? (class$com$tridium$program$ui$BProgramModuleBuilder = BProgramModuleBuilder.class$("com.tridium.program.ui.BProgramModuleBuilder")) : class$com$tridium$program$ui$BProgramModuleBuilder));
Lexicon lex = Lexicon.make((Class)(class$com$tridium$program$ui$BProgramModuleBuilder == null ? (class$com$tridium$program$ui$BProgramModuleBuilder = BProgramModuleBuilder.class$("com.tridium.program.ui.BProgramModuleBuilder")) : class$com$tridium$program$ui$BProgramModuleBuilder));
static final BImage CHECK = BImage.make((BIcon)BIcon.std((String)"check.png"));
static final BImage BLANK = BImage.make((BIcon)BIcon.std((String)"blank.png"));
BProgramModule module;
BSplitPane split;
BFieldSheet sheet = new BFieldSheet();
HashMap verify;
static /* synthetic */ Class class$com$tridium$program$ui$BProgramModuleBuilder;
public void handleSelection() {
this.invoke(handleSelection, null, null);
}
public void handleModified() {
this.invoke(handleModified, null, null);
}
public Type getType() {
return TYPE;
}
public void doLoadValue(BObject bObject, Context context) {
this.module = (BProgramModule)bObject;
this.verify = new HashMap();
this.verify.put(this.module, ValidateModel.make(this.module));
super.doLoadValue(bObject, context);
}
protected void init() {
super.init();
ViewQuery viewQuery = this.getWbShell().getActiveOrdTarget().getViewQuery();
if (viewQuery != null) {
try {
String string = viewQuery.getParameter("program");
int n = ((BBuilderTable)this.getModel().getTable()).getRowOfProgram(string);
this.getModel().getTable().getSelection().select(n);
}
catch (Exception exception) {
// empty catch block
}
}
}
public void handleComponentEvent(BComponentEvent bComponentEvent) {
super.handleComponentEvent(bComponentEvent);
BComponent bComponent = bComponentEvent.getSourceComponent();
BValue bValue = bComponentEvent.getValue();
if (bComponent == this.module) {
this.verify.put(this.module, ValidateModel.make(this.module));
} else if (bComponentEvent.getId() == 3) {
this.verify.put(this.getSelectedProgram(), ValidateModel.make(this.getSelectedProgram()));
this.handleSelection();
} else if (bValue instanceof BProgram) {
switch (bComponentEvent.getId()) {
case 0:
case 1: {
this.verify.put(bValue, ValidateModel.make((BProgram)bValue));
this.handleSelection();
break;
}
case 2: {
if (bValue == this.getSelectedProgram()) {
this.getModel().getTable().getSelection().deselectAll();
}
this.verify.remove(bValue);
}
}
this.verify.put(this.module, ValidateModel.make(this.module));
}
super.handleComponentEvent(bComponentEvent);
}
protected BObject doSaveValue(BObject bObject, Context context) throws CannotSaveException, Exception {
try {
this.sheet.saveValue((BObject)this.module, context);
this.verify.put(this.module, ValidateModel.make(this.module));
}
catch (Exception exception) {
((ValidateModel)((Object)this.verify.get((Object)this.module))).err(exception.getMessage());
throw exception;
}
finally {
this.getModel().getTable().getSelection().select(-1);
}
return this.module;
}
public void doHandleModified() {
if (this.sheet.isModified()) {
this.getController().updateCommands();
}
}
protected MgrModel makeModel() {
return new BuilderModel(this);
}
protected MgrController makeController() {
return new Controller(this);
}
public void doHandleSelection() {
ValidateModel validateModel = (ValidateModel)((Object)this.verify.get((Object)this.module));
BProgram bProgram = this.getSelectedProgram();
if (bProgram != null) {
validateModel = (ValidateModel)((Object)this.verify.get((Object)bProgram));
}
if (validateModel.getTable() != null) {
validateModel.setTable(null);
}
this.split.setWidget2((BWidget)new BTable((TableModel)validateModel));
if (this.split.getDividerPosition() > 75.0) {
this.split.setDividerPosition(75.0);
this.split.relayout();
}
}
private BProgram getSelectedProgram() {
return (BProgram)this.getModel().getTable().getSelectedComponent();
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
class BuilderModel
extends FolderModel {
MgrColumn colProgramName = new ProgName(1);
MgrColumn colComp = new CompName();
MgrColumn[] columns = new MgrColumn[]{this.colProgramName, this.colComp};
public BuilderModel(BFolderManager bFolderManager) {
super(bFolderManager);
}
protected BMgrTable makeTable() {
BBuilderTable bBuilderTable = new BBuilderTable((MgrModel)this);
BProgramModuleBuilder.this.linkTo((BComponent)bBuilderTable, (Slot)BTable.selectionModified, (Slot)handleSelection);
return bBuilderTable;
}
public Type getFolderType() {
return BFolder.TYPE;
}
public Type[] getIncludeTypes() {
return new Type[]{BProgram.TYPE};
}
public boolean accept(BComponent bComponent) {
if (bComponent.getParent().equals((Object)BProgramModuleBuilder.this.module.getPrograms())) {
BProgramModuleBuilder.this.verify.put(bComponent, ValidateModel.make((BProgram)bComponent));
return true;
}
return false;
}
public int getSubscribeDepth() {
return 2;
}
protected String makeTableTitle() {
return BProgramModuleBuilder.this.lex.getText("modBuilder.title");
}
public BWidget makePane() {
BProgramModuleBuilder.this.sheet = new BFieldSheet();
BProgramModuleBuilder.this.sheet.loadValue((BObject)BProgramModuleBuilder.this.module, BProgramModuleBuilder.this.getCurrentContext());
BProgramModuleBuilder.this.linkTo((BComponent)BProgramModuleBuilder.this.sheet, (Slot)BFieldSheet.pluginModified, (Slot)BAbstractManager.setModified);
BProgramModuleBuilder.this.linkTo((BComponent)BProgramModuleBuilder.this.sheet, (Slot)BFieldSheet.pluginModified, (Slot)handleModified);
BExpandablePane bExpandablePane = new BExpandablePane();
BEdgePane bEdgePane = new BEdgePane();
bEdgePane.setCenter((BWidget)BProgramModuleBuilder.this.sheet);
bExpandablePane.setSummary((BWidget)new BLabel(BProgramModuleBuilder.this.lex.getText("modBuilder.settings")));
bExpandablePane.setExpansion((BWidget)new BBorderPane((BWidget)bEdgePane, 0.0, 0.0, 5.0, 0.0));
bExpandablePane.setExpanded(true);
BWidget bWidget = super.makePane();
BProgramModuleBuilder.this.split = new BSplitPane(BOrientation.vertical, 75.0);
BProgramModuleBuilder.this.split.setWidget1(bWidget);
BProgramModuleBuilder.this.split.setWidget2((BWidget)new BNullWidget());
BEdgePane bEdgePane2 = new BEdgePane();
bEdgePane2.setTop((BWidget)bExpandablePane);
bEdgePane2.setCenter((BWidget)BProgramModuleBuilder.this.split);
return bEdgePane2;
}
protected MgrColumn[] makeColumns() {
return this.columns;
}
protected class CompName
extends MgrColumn {
public CompName() {
super("BComponent Name", 6);
}
public Object get(Object object) {
return BProgramModule.toComponentName((BProgram)((Object)object));
}
}
protected class ProgName
extends MgrColumn.Name {
private CellRenderer rend = new CellRenderer();
public ProgName(int n) {
super(n);
}
public TableCellRenderer getCellRenderer() {
return this.rend;
}
private class CellRenderer
extends ComponentTableCellRenderer {
private CellRenderer() {
}
public double getPreferredCellWidth(TableCellRenderer.Cell cell) {
return 20.0 + this.getFont(cell).width("VeryLongBProgramNameExample");
}
public void paintCell(Graphics graphics, TableCellRenderer.Cell cell) {
this.paintCellBackground(graphics, cell);
double d = 2.0;
double d2 = (cell.height - 16.0) / 2.0;
ValidateModel validateModel = (ValidateModel)((Object)((BuilderModel)((ProgName)ProgName.this).BuilderModel.this).BProgramModuleBuilder.this.verify.get(this.getComponentTable().getComponentAt(cell.row)));
graphics.drawImage(validateModel.getProgramStatusIcon(), d, d2);
String string = (String)cell.value;
BFont bFont = this.getFont(cell);
graphics.setFont(bFont);
graphics.drawString(string, d += 20.0, (cell.height + bFont.getAscent() - bFont.getDescent()) / 2.0);
}
protected BComponentTable getComponentTable() {
return ProgName.this.getManager().getModel().getTable();
}
}
}
}
class Controller
extends FolderController {
CompileCommand compileCmd;
BuildCommand buildCmd;
EditDepends dependsCmd;
public Controller(BFolderManager bFolderManager) {
super(bFolderManager);
this.compileCmd = new CompileCommand((BWidget)bFolderManager);
this.buildCmd = new BuildCommand((BWidget)bFolderManager);
this.dependsCmd = new EditDepends((BWidget)bFolderManager);
}
protected MgrController.IMgrCommand[] makeCommands() {
this.allDescendants.setSelected(true);
return new MgrController.IMgrCommand[]{this.edit, this.compileCmd, this.buildCmd, this.dependsCmd};
}
public void cellDoubleClicked(BMgrTable bMgrTable, BMouseEvent bMouseEvent, int n, int n2) {
BProgram bProgram = (BProgram)bMgrTable.getComponentAt(n);
BWbShell bWbShell = bMgrTable.getManager().getWbShell();
bWbShell.hyperlink(BOrd.make((BOrd)bProgram.getNavOrd(), (String)"view:program:ProgramEditor"));
}
public BToolBar makeToolBar() {
return super.makeToolBar();
}
public void updateCommands() {
super.updateCommands();
boolean bl = true;
Iterator iterator = BProgramModuleBuilder.this.verify.values().iterator();
while (iterator.hasNext()) {
if (((ValidateModel)((Object)iterator.next())).getErrCount() <= 0) continue;
bl = false;
break;
}
if (BProgramModuleBuilder.this.sheet != null && BProgramModuleBuilder.this.sheet.isModified()) {
bl = false;
}
this.buildCmd.setEnabled(bl);
this.dependsCmd.setEnabled(bl);
this.compileCmd.setEnabled(!bl && !BProgramModuleBuilder.this.sheet.isModified());
}
public CommandArtifact drop(BMgrTable bMgrTable, TransferContext transferContext) throws Exception {
return TransferUtil.insert((BWidget)BProgramModuleBuilder.this, (TransferContext)transferContext, (BObject)BProgramModuleBuilder.this.module.getPrograms(), null);
}
protected class EditDepends
extends MgrController.MgrCommand {
public EditDepends(BWidget bWidget) {
super(bWidget, ((Controller)Controller.this).BProgramModuleBuilder.this.lex, "modBuilder.cmd.editDepends");
this.setFlags(3);
}
public CommandArtifact doInvoke() throws Exception {
BVector bVector = new BVector();
BFieldSheet bFieldSheet = this.makeDependsSheet(bVector);
BScrollPane bScrollPane = new BScrollPane((BWidget)new BBorderPane((BWidget)bFieldSheet, BInsets.make((double)10.0)));
bScrollPane.setVpolicy(BScrollBarPolicy.always);
bScrollPane.setViewportBackground(Theme.widget().getControlBackground());
while (true) {
if (2 == BDialog.open((BWidget)BProgramModuleBuilder.this, (String)((Controller)Controller.this).BProgramModuleBuilder.this.lex.getText("modBuilder.cmd.editDepends.title"), (Object)bScrollPane, (int)3)) {
return null;
}
try {
bFieldSheet.saveValue((BObject)bVector, null);
}
catch (Exception exception) {
BDialog.error((BWidget)BProgramModuleBuilder.this, (String)"Error", (Object)exception.getMessage(), (Throwable)exception);
continue;
}
break;
}
BNameMap bNameMap = BNameMap.DEFAULT;
Property[] propertyArray = bVector.getPropertiesArray();
for (int i = 0; i < propertyArray.length; ++i) {
String string = propertyArray[i].getName();
String string2 = bVector.getString(propertyArray[i]);
bNameMap = BNameMap.make((BNameMap)bNameMap, (String)string, (String)string2);
}
((Controller)Controller.this).BProgramModuleBuilder.this.module.setDependencies(bNameMap);
return null;
}
private BFieldSheet makeDependsSheet(BVector bVector) {
BFieldSheet bFieldSheet = new BFieldSheet(true);
BFacets bFacets = BFacets.make((String)"validator", (String)"baja:VersionValidator");
bFacets = BFacets.make((BFacets)bFacets, (BFacets)BFacets.make((String)"fieldSheetShow", (boolean)true));
bFacets = BFacets.make((BFacets)bFacets, (BFacets)BFacets.make((String)"iconOverride", (String)"module://icons/x16/module.png"));
BNameMap bNameMap = BProgramModule.rationalizeDependecies(((Controller)Controller.this).BProgramModuleBuilder.this.module);
Object[] objectArray = bNameMap.list();
SortUtil.sort((Object[])objectArray);
for (int i = 0; i < objectArray.length; ++i) {
bVector.add((String)objectArray[i], (BValue)BString.make((String)bNameMap.get((String)objectArray[i]).getFormat()));
bVector.setFacets(bVector.getSlot((String)objectArray[i]), bFacets);
}
bFieldSheet.loadValue((BObject)bVector);
return bFieldSheet;
}
}
protected class BuildCommand
extends MgrController.MgrCommand {
public BuildCommand(BWidget bWidget) {
super(bWidget, ((Controller)Controller.this).BProgramModuleBuilder.this.lex, "modBuilder.cmd.build");
this.setFlags(7);
}
public CommandArtifact doInvoke() throws Exception {
BProgramModuleBuilder.this.saveValue();
BProgressDialog.open((BWidget)this.getOwner(), (String)((Controller)Controller.this).BProgramModuleBuilder.this.lex.getText("modBuilder.cmd.build.title"), (BProgressDialog.Worker)new BuildWorker());
return null;
}
class BuildWorker
extends BProgressDialog.Worker
implements IBuildListener {
int curStep = 0;
BuildWorker() {
}
public void setNumBuildSteps(int n) {
this.getDialog().getProgressBar().setMax((double)n);
}
public void nextStep(String string) {
this.getDialog().getProgressBar().setValue((double)(++this.curStep));
this.updateDesc(string);
}
public void updateDesc(String string) {
this.getDialog().getMessageLabel().setText(string);
}
public BWidget getOwner() {
return BProgramModuleBuilder.this;
}
public void doCancel() throws Exception {
}
public void doRun() throws Exception {
try {
((Controller)((BuildCommand)BuildCommand.this).Controller.this).BProgramModuleBuilder.this.module.buildModule(this);
}
catch (Exception exception) {
BDialog.error((BWidget)this.getDialog(), (String)((Controller)((BuildCommand)BuildCommand.this).Controller.this).BProgramModuleBuilder.this.lex.getText("programModule.nbuild.fail"), (Object)exception.getMessage(), (Throwable)exception);
}
}
}
}
protected class CompileCommand
extends MgrController.MgrCommand {
public CompileCommand(BWidget bWidget) {
super(bWidget, ((Controller)Controller.this).BProgramModuleBuilder.this.lex, "modBuilder.cmd.compile");
this.setFlags(7);
}
public CommandArtifact doInvoke() throws Exception {
BProgram[] bProgramArray = ((Controller)Controller.this).BProgramModuleBuilder.this.module.listPrograms();
for (int i = 0; i < bProgramArray.length; ++i) {
if (((ValidateModel)((Object)((Controller)Controller.this).BProgramModuleBuilder.this.verify.get((Object)bProgramArray[i]))).getErrCount() == 0) continue;
try {
PCompiler pCompiler = new PCompiler(this.getOwner(), bProgramArray[i]);
pCompiler.compile(BCode.generateClassName(), bProgramArray[i].getCode(), null);
continue;
}
catch (Exception exception) {
exception.printStackTrace();
}
}
return null;
}
private class PCompiler
extends Compiler {
BProgram program;
BProgramEditor pe;
public PCompiler(BWidget bWidget, BProgram bProgram) {
super(bWidget);
this.program = bProgram;
this.pe = new BProgramEditor();
this.pe.loadValue((BObject)bProgram);
}
public void writeSource(FileWriter fileWriter, String string) throws Exception {
SourceWriter sourceWriter = new SourceWriter((Writer)fileWriter, this.pe);
sourceWriter.generate(this.className);
}
public synchronized void compile(String string, BCode bCode, String string2) throws Exception {
super.compile(string, bCode, string2);
this.wait();
}
public synchronized void consoleExecDone(BConsole bConsole, int n) {
try {
super.consoleExecDone(bConsole, n);
}
finally {
this.notifyAll();
}
}
public void compileFailed(BConsole bConsole) throws Exception {
bConsole.cls();
((ValidateModel)((Object)((Controller)((CompileCommand)CompileCommand.this).Controller.this).BProgramModuleBuilder.this.verify.get((Object)this.program))).err(((Controller)((CompileCommand)CompileCommand.this).Controller.this).BProgramModuleBuilder.this.lex.getText("vprogram.err.compile"));
}
public void compileSuccess(BConsole bConsole) throws Exception {
super.compileSuccess(bConsole);
int n = this.program.getCode().getChecksum();
int n2 = this.pe.computeChecksum(this.program.getCode().getSource());
if (n != n2) {
this.program.getCode().setChecksum(n2);
BProgramModuleBuilder.this.handleComponentEvent(new BComponentEvent(0, (BComponent)((Controller)((CompileCommand)CompileCommand.this).Controller.this).BProgramModuleBuilder.this.module.getPrograms(), null, (BValue)this.program));
}
}
}
}
}
}
@@ -0,0 +1,242 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.workbench.console.BConsole
* com.tridium.workbench.console.BConsole$HyperlinkInterceptor
* javax.baja.nre.util.TextUtil
* javax.baja.registry.DependencyInfo
* javax.baja.sys.BObject
* javax.baja.sys.Context
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BDialog
* javax.baja.ui.BMenu
* javax.baja.ui.BToolBar
* javax.baja.ui.BWidget
* javax.baja.ui.CommandArtifact
* javax.baja.ui.pane.BTextEditorPane
* javax.baja.ui.text.BTextEditor
* javax.baja.ui.text.Position
* javax.baja.ui.text.TextParser
* javax.baja.ui.text.parsers.JavaParser
* javax.baja.ui.transfer.BTransferWidget
* javax.baja.ui.util.UiLexicon
* javax.baja.workbench.view.BWbComponentView
*/
package com.tridium.program.ui;
import com.tridium.program.BCode;
import com.tridium.program.BProgram;
import com.tridium.program.BProgramService;
import com.tridium.program.BRobotCode;
import com.tridium.program.BRobotResult;
import com.tridium.program.ui.Compiler;
import com.tridium.program.ui.RobotEditorCommands;
import com.tridium.workbench.console.BConsole;
import java.io.File;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.StringTokenizer;
import javax.baja.nre.util.TextUtil;
import javax.baja.registry.DependencyInfo;
import javax.baja.sys.BObject;
import javax.baja.sys.Context;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BDialog;
import javax.baja.ui.BMenu;
import javax.baja.ui.BToolBar;
import javax.baja.ui.BWidget;
import javax.baja.ui.CommandArtifact;
import javax.baja.ui.pane.BTextEditorPane;
import javax.baja.ui.text.BTextEditor;
import javax.baja.ui.text.Position;
import javax.baja.ui.text.TextParser;
import javax.baja.ui.text.parsers.JavaParser;
import javax.baja.ui.transfer.BTransferWidget;
import javax.baja.ui.util.UiLexicon;
import javax.baja.workbench.view.BWbComponentView;
public class BRobotEditor
extends BWbComponentView
implements BConsole.HyperlinkInterceptor {
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$BRobotEditor == null ? (class$com$tridium$program$ui$BRobotEditor = BRobotEditor.class$("com.tridium.program.ui.BRobotEditor")) : class$com$tridium$program$ui$BRobotEditor));
static String defaultDepends = "baja; program";
static String defaultCode = "// depends: " + defaultDepends + "\n" + "\n" + "import javax.baja.sys.*;\n" + "import com.tridium.program.*;\n" + "\n" + "public class RobotImpl\n" + " extends Robot\n" + "{\n" + "\n" + " public void run()\n" + " throws Exception\n" + " {\n" + " process(Sys.getStation());\n" + " }\n" + "\n" + " public void process(BComponent c)\n" + " throws Exception\n" + " {\n" + " // do something here\n" + " log.println(c.toPathString() + \" [\" + c.getType() + \"]\");\n" + " \n" + " // recurse\n" + " BComponent[] kids = c.getChildComponents();\n" + " for(int i=0; i<kids.length; ++i)\n" + " process(kids[i]);\n" + " }\n" + "\n" + "}\n";
static UiLexicon lex = UiLexicon.bajaui;
RobotEditorCommands commands = new RobotEditorCommands(this);
BProgramService service;
BTextEditor editor;
RobotCompiler compiler = new RobotCompiler(this);
BRobotCode robotCode = new BRobotCode();
static /* synthetic */ Class class$com$tridium$program$ui$BRobotEditor;
public Type getType() {
return TYPE;
}
public BRobotEditor() {
this.editor = new BTextEditor();
this.editor.setParser((TextParser)new JavaParser());
this.editor.setText(defaultCode);
this.setTransferWidget((BTransferWidget)this.editor);
this.setCommandEnabled(6, true);
this.setCommandEnabled(8, true);
this.setCommandEnabled(7, true);
this.setCommandEnabled(9, true);
this.setCommandEnabled(10, true);
BTextEditorPane bTextEditorPane = new BTextEditorPane(this.editor);
this.setContent((BWidget)bTextEditorPane);
}
public BMenu[] getViewMenus() {
return this.commands.getViewMenus();
}
public BToolBar getViewToolBar() {
return this.commands.getViewToolBar();
}
public void doLoadValue(BObject bObject, Context context) {
this.service = (BProgramService)bObject;
}
public void deactivated() {
super.deactivated();
defaultCode = this.editor.getText();
}
public CommandArtifact invokeCommand(int n) throws Exception {
switch (n) {
case 6: {
return this.editor.doFind();
}
case 8: {
return this.editor.doFindNext();
}
case 7: {
return this.editor.doFindPrev();
}
case 9: {
return this.editor.doReplace();
}
case 10: {
return this.editor.doGoto();
}
}
return super.invokeCommand(n);
}
public boolean consoleHyperlink(File file, int n, int n2, int n3, int n4) {
if (!file.equals(this.compiler.java)) {
return false;
}
this.highlight(n, n2, n3, n4);
return true;
}
public void highlight(int n, int n2, int n3, int n4) {
this.highlight(this.editor, n, n2, n3, n4);
}
void highlight(BTextEditor bTextEditor, int n, int n2, int n3, int n4) {
Position position = bTextEditor.getModel().getEndPosition();
Position position2 = new Position(n - 1, n2 - 1);
Position position3 = new Position(n3 - 1, n4);
if (position2.compareTo((Object)position) > 0) {
position2 = position;
}
if (position3.compareTo((Object)position) > 0) {
position3 = position;
}
bTextEditor.getSelection().select(position2, position3);
bTextEditor.moveCaretPosition(position3);
bTextEditor.requestFocus();
}
public void run() {
BRobotResult bRobotResult = this.service.runRobot(this.robotCode);
BTextEditor bTextEditor = new BTextEditor(bRobotResult.getLog(), false);
BTextEditorPane bTextEditorPane = new BTextEditorPane(bTextEditor, 20, 80);
BDialog.open((BWidget)this, (String)"Log Output", (Object)bTextEditorPane, (int)1);
}
public String parseDepends(String string) throws Exception {
if (string.startsWith("// depends:")) {
int n = string.indexOf(58);
int n2 = string.indexOf(10);
if (n >= 0 && n2 >= 0) {
CharSequence charSequence;
HashSet hashSet = new HashSet();
StringTokenizer stringTokenizer = new StringTokenizer(string.trim().substring(n + 1, n2), ";");
while (stringTokenizer.hasMoreTokens()) {
charSequence = stringTokenizer.nextToken().trim();
if (((String)charSequence).length() <= 0 || BProgram.isSpecialModule((String)charSequence)) continue;
this.accumDepends(hashSet, (String)charSequence);
}
charSequence = new StringBuffer();
Iterator iterator = hashSet.iterator();
while (iterator.hasNext()) {
if (((StringBuffer)charSequence).length() > 0) {
((StringBuffer)charSequence).append("; ");
}
((StringBuffer)charSequence).append(iterator.next().toString());
}
return ((StringBuffer)charSequence).toString();
}
}
return defaultDepends;
}
protected void accumDepends(Set set, String string) throws Exception {
if (set.contains(string)) {
return;
}
set.add(string);
DependencyInfo[] dependencyInfoArray = Sys.getRegistry().getModule(string).getDependencies();
for (int i = 0; i < dependencyInfoArray.length; ++i) {
this.accumDepends(set, dependencyInfoArray[i].getModuleName());
}
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
class RobotCompiler
extends Compiler {
boolean runOnSuccess;
RobotCompiler(BRobotEditor bRobotEditor2) {
super((BWidget)bRobotEditor2);
}
public void compile(boolean bl) throws Exception {
this.runOnSuccess = bl;
String string = BRobotEditor.this.editor.getText();
String string2 = BCode.generateClassName();
int n = string.indexOf("RobotImpl");
if (n < 0) {
throw new Exception("Class name must be RobotImpl");
}
string = TextUtil.replace((String)string, (String)"RobotImpl", (String)string2);
BRobotEditor.this.robotCode.setDependencies(BRobotEditor.this.parseDepends(string));
this.compile(string2, BRobotEditor.this.robotCode, string);
}
public void compileSuccess(BConsole bConsole) throws Exception {
super.compileSuccess(bConsole);
if (this.runOnSuccess) {
BRobotEditor.this.run();
}
}
}
}
@@ -0,0 +1,293 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.nsh.NShell
* com.tridium.workbench.console.BConsole
* com.tridium.workbench.console.BConsole$ExecCallback
* com.tridium.workbench.shell.BNiagaraWbShell
* javax.baja.naming.BOrd
* javax.baja.nre.util.Array
* javax.baja.registry.DependencyInfo
* javax.baja.sys.BBlob
* javax.baja.sys.BString
* javax.baja.sys.BValue
* javax.baja.sys.Sys
* javax.baja.ui.BWidget
* javax.baja.workbench.BWbEditor
*/
package com.tridium.program.ui;
import com.tridium.nsh.NShell;
import com.tridium.program.BCode;
import com.tridium.program.BProgramService;
import com.tridium.workbench.console.BConsole;
import com.tridium.workbench.shell.BNiagaraWbShell;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.FilenameFilter;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Set;
import javax.baja.naming.BOrd;
import javax.baja.nre.util.Array;
import javax.baja.registry.DependencyInfo;
import javax.baja.sys.BBlob;
import javax.baja.sys.BString;
import javax.baja.sys.BValue;
import javax.baja.sys.Sys;
import javax.baja.ui.BWidget;
import javax.baja.workbench.BWbEditor;
public class Compiler
implements BConsole.ExecCallback {
BWidget owner;
public String className;
File temp;
File java;
File classFile;
File[] innerClassFiles;
BCode code;
static /* synthetic */ Class class$java$io$File;
static /* synthetic */ Class class$java$lang$String;
static /* synthetic */ Class class$java$lang$Object;
public Compiler(BWidget bWidget) {
this.owner = bWidget;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public void compile(String string, BCode bCode, String string2) throws Exception {
this.className = string;
this.temp = new File(Sys.getBajaHome(), "temp");
this.java = new File(this.temp, string + ".java");
this.classFile = new File(this.temp, string + ".class");
this.innerClassFiles = null;
this.code = bCode;
if (!this.temp.exists()) {
this.temp.mkdirs();
}
FileWriter fileWriter = new FileWriter(this.java);
try {
this.writeSource(fileWriter, string2);
}
finally {
fileWriter.close();
}
String string3 = Compiler.getDevkitTargetEdition(this.owner, null);
String string4 = File.separator;
String string5 = File.pathSeparator;
StringBuffer stringBuffer = new StringBuffer();
String string6 = Sys.getBajaHome() + string4 + "lib" + string4 + "editions" + string4 + (string3.startsWith("javac.") ? string3.substring(6) : string3) + string4;
File file = new File(string6);
String[] stringArray = file.list();
if (stringArray != null) {
for (int i = 0; i < stringArray.length; ++i) {
stringBuffer.append(string6 + stringArray[i] + string5);
}
}
File file2 = new File(Sys.getBajaHome(), "bin");
String[] stringArray2 = file2.list(new JarFilenameFilter());
String string7 = string5 + Sys.getBajaHome() + string4 + "bin" + string4;
for (int i = 0; i < stringArray2.length; ++i) {
stringBuffer.append(string7).append(stringArray2[i]).append(string5);
}
stringBuffer.append(Sys.getBajaHome() + string4 + "modules" + string4 + "baja.jar");
String[] stringArray3 = this.parseDependencies(bCode);
String string8 = string5 + Sys.getBajaHome() + string4 + "modules" + string4;
for (int i = 0; i < stringArray3.length; ++i) {
if (stringArray3[i].equals("baja")) continue;
stringBuffer.append(string8).append(stringArray3[i]).append(".jar");
}
String string9 = null;
try {
string9 = Compiler.getCompileJavaCommand(string3, stringBuffer.toString(), this.temp.toString(), this.java.toString());
}
catch (Exception exception) {
System.out.println("Problem loading '" + string3 + "' command from devkit.properties.");
exception.printStackTrace();
string9 = "jikes +E -classpath \"" + stringBuffer + "\" \"" + this.java + "\"";
}
this.exec(string9);
}
protected String[] parseDependencies(BCode bCode) throws Exception {
HashSet hashSet = new HashSet();
String[] stringArray = bCode.parseDependencies();
for (int i = 0; i < stringArray.length; ++i) {
this.accumDependencies(hashSet, stringArray[i]);
}
return hashSet.toArray(new String[hashSet.size()]);
}
protected void accumDependencies(Set set, String string) throws Exception {
if (set.contains(string)) {
return;
}
set.add(string);
DependencyInfo[] dependencyInfoArray = Sys.getRegistry().getModule(string).getDependencies();
for (int i = 0; i < dependencyInfoArray.length; ++i) {
this.accumDependencies(set, dependencyInfoArray[i].getModuleName());
}
}
public void writeSource(FileWriter fileWriter, String string) throws Exception {
fileWriter.write(string);
}
public void exec(String string) throws Exception {
if (this.owner != null) {
this.openConsole().exec(string, (BConsole.ExecCallback)this);
return;
}
NShell nShell = new NShell(System.out);
nShell.exec(string);
nShell.execWaitUntilDone();
this.compileSuccess(null);
this.cleanup();
}
public BConsole openConsole() {
return ((BNiagaraWbShell)this.owner.getShell()).openConsole();
}
public void consoleExecDone(BConsole bConsole, int n) {
try {
if (n == 0) {
this.compileSuccess(bConsole);
} else {
this.compileFailed(bConsole);
}
}
catch (Throwable throwable) {
throwable.printStackTrace();
}
this.cleanup();
}
public void compileSuccess(BConsole bConsole) throws Exception {
byte[] byArray = new byte[(int)this.classFile.length()];
DataInputStream dataInputStream = new DataInputStream(new BufferedInputStream(new FileInputStream(this.classFile)));
dataInputStream.readFully(byArray);
dataInputStream.close();
this.code.setClassName(this.className);
this.code.setClassFile(BBlob.make((byte[])byArray));
File[] fileArray = this.classFile.getParentFile().listFiles();
this.code.clearInnerClassFiles();
Array array = new Array(class$java$io$File == null ? (class$java$io$File = Compiler.class$("java.io.File")) : class$java$io$File);
for (int i = 0; i < fileArray.length; ++i) {
if (!fileArray[i].getName().startsWith(this.className + '$')) continue;
array.add((Object)fileArray[i]);
String string = fileArray[i].getName();
string = string.substring(0, string.length() - 6);
byArray = new byte[(int)fileArray[i].length()];
dataInputStream = new DataInputStream(new BufferedInputStream(new FileInputStream(fileArray[i])));
dataInputStream.readFully(byArray);
dataInputStream.close();
this.code.addInnerClassFile(string, BBlob.make((byte[])byArray));
}
this.innerClassFiles = (File[])array.trim();
}
public void compileFailed(BConsole bConsole) throws Exception {
bConsole.next();
}
public void cleanup() {
this.classFile.delete();
if (this.innerClassFiles != null) {
for (int i = 0; i < this.innerClassFiles.length; ++i) {
this.innerClassFiles[i].delete();
}
}
this.java.delete();
}
public static String getDevkitTargetEdition(BWidget bWidget, String string) {
try {
if (bWidget instanceof BWbEditor) {
BProgramService bProgramService = (BProgramService)BOrd.make((String)"service:program:ProgramService").resolve(((BWbEditor)bWidget).getCurrentValue()).get();
bProgramService.lease();
BValue bValue = bProgramService.get("devkitTargetEdition");
if (bValue instanceof BString) {
return bValue.toString();
}
}
}
catch (Exception exception) {
// empty catch block
}
return string == null ? "javac.j2me" : string;
}
public static String getCompileJavaCommand(String string, String string2, String string3, String string4) throws Exception {
int n;
if (!string4.startsWith("\"")) {
string4 = "\"" + string4;
}
if (!string4.endsWith("\"")) {
string4 = string4 + "\"";
}
Class<?> clazz = Class.forName("com.tridium.build.Env");
Method method = clazz.getMethod("initEnv", class$java$lang$String == null ? (class$java$lang$String = Compiler.class$("java.lang.String")) : class$java$lang$String, class$java$lang$String == null ? (class$java$lang$String = Compiler.class$("java.lang.String")) : class$java$lang$String);
method.invoke(null, null, "jar");
Object object = clazz.getField("props").get(null);
clazz = Class.forName("com.tridium.build.MacroProperties");
method = clazz.getMethod("copy", null);
object = method.invoke(object, null);
method = clazz.getMethod("put", class$java$lang$Object == null ? (class$java$lang$Object = Compiler.class$("java.lang.Object")) : class$java$lang$Object, class$java$lang$Object == null ? (class$java$lang$Object = Compiler.class$("java.lang.Object")) : class$java$lang$Object);
method.invoke(object, "javac.classpath", string2);
method.invoke(object, "javac.out", string3);
method.invoke(object, "javac.src", string4);
Method method2 = clazz.getMethod("getProperty", class$java$lang$String == null ? (class$java$lang$String = Compiler.class$("java.lang.String")) : class$java$lang$String, class$java$lang$String == null ? (class$java$lang$String = Compiler.class$("java.lang.String")) : class$java$lang$String);
if (((String)method2.invoke(object, "debug", "false")).equalsIgnoreCase("true")) {
method.invoke(object, "javac.debug", "-g");
} else {
method.invoke(object, "javac.debug", "");
}
method = clazz.getMethod("resolve", class$java$lang$String == null ? (class$java$lang$String = Compiler.class$("java.lang.String")) : class$java$lang$String);
String string5 = (String)method.invoke(object, string);
if (!string5.endsWith(string4)) {
n = string5.lastIndexOf(string4);
string5 = n > -1 ? string5.substring(0, n) : string5 + " ";
string5 = string5 + string4;
}
if (!string5.startsWith("\"")) {
n = string5.indexOf(32);
while (n >= 0) {
String string6 = string5.substring(0, n);
File file = new File(string6);
if (file.exists() && !file.isDirectory()) {
string5 = "\"" + string6 + "\"" + string5.substring(n);
break;
}
if ((n = string5.indexOf(32, n + 1)) >= 0 || !(file = new File(string5)).exists() || file.isDirectory()) continue;
string5 = "\"" + string5 + "\"";
break;
}
}
return string5;
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
public static class JarFilenameFilter
implements FilenameFilter {
public boolean accept(File file, String string) {
return string.endsWith(".jar");
}
}
}
@@ -0,0 +1,324 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.gx.BImage
* javax.baja.nre.util.SortUtil
* javax.baja.nre.util.TextUtil
* javax.baja.sys.BModule
* javax.baja.sys.SlotCursor
* javax.baja.sys.Sys
* javax.baja.ui.BMenu
* javax.baja.ui.BWidget
* javax.baja.ui.event.BMouseEvent
* javax.baja.ui.table.BTable
* javax.baja.ui.table.TableController
* javax.baja.ui.table.TableModel
* javax.baja.ui.util.UiLexicon
*/
package com.tridium.program.ui;
import com.tridium.program.BProgramCode;
import com.tridium.program.ui.BProgramEditor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.StringTokenizer;
import javax.baja.gx.BImage;
import javax.baja.nre.util.SortUtil;
import javax.baja.nre.util.TextUtil;
import javax.baja.sys.BModule;
import javax.baja.sys.SlotCursor;
import javax.baja.sys.Sys;
import javax.baja.ui.BMenu;
import javax.baja.ui.BWidget;
import javax.baja.ui.event.BMouseEvent;
import javax.baja.ui.table.BTable;
import javax.baja.ui.table.TableController;
import javax.baja.ui.table.TableModel;
import javax.baja.ui.util.UiLexicon;
public class Imports
extends TableModel {
static final int PREDEFINED = 0;
static final int USER_DEFINED = 1;
static final int BY_PROPERTY = 2;
static Import[] predefined = new Import[]{new Import("java", "java.util", 0), new Import("baja", "javax.baja.sys", 0), new Import("baja", "javax.baja.status", 0), new Import("baja", "javax.baja.util", 0), new Import("program", "com.tridium.program", 0)};
static UiLexicon lex = UiLexicon.bajaui;
static String lexModule = lex.getText("programEditor.module");
static String lexPackage = lex.getText("programEditor.package");
static String lexDefinition = lex.getText("programEditor.definition");
static BImage importIcon = BImage.make((String)"module://icons/x16/module.png");
final BProgramEditor editor;
BTable table;
private ArrayList list = new ArrayList();
private HashMap map = new HashMap();
Imports(BProgramEditor bProgramEditor) {
this.editor = bProgramEditor;
this.table = new BTable((TableModel)this);
this.table.setController((TableController)new Controller());
}
public Import[] getAll() {
return this.list.toArray(new Import[this.list.size()]);
}
public String[] getDependencies() {
Object object;
Hashtable<String, String> hashtable = new Hashtable<String, String>(13);
hashtable.put("baja", "baja");
hashtable.put("program", "program");
for (int i = 0; i < this.list.size(); ++i) {
object = (Import)this.list.get(i);
if (((Import)object).moduleName.equals("java")) continue;
hashtable.put(((Import)object).moduleName, ((Import)object).moduleName);
}
String[] stringArray = new String[hashtable.size()];
object = hashtable.keys();
int n = 0;
while (object.hasMoreElements()) {
stringArray[n] = (String)object.nextElement();
++n;
}
return stringArray;
}
public void updateImports() {
Object object;
int n;
ArrayList<Import> arrayList = new ArrayList<Import>();
HashMap<Object, Object> hashMap = new HashMap<Object, Object>();
for (n = 0; n < predefined.length; ++n) {
arrayList.add(predefined[n]);
hashMap.put(predefined[n], predefined[n]);
}
for (n = 0; n < this.list.size(); ++n) {
object = (Import)this.list.get(n);
if (((Import)object).definition != 1 || hashMap.get(object) != null) continue;
arrayList.add((Import)object);
hashMap.put(object, object);
}
SlotCursor slotCursor = this.editor.program.getProperties();
while (slotCursor.next()) {
if (!slotCursor.property().isDynamic()) continue;
object = slotCursor.get().getClass();
String string = TextUtil.getPackageName((Class)object);
BModule bModule = Sys.getModuleForClass((Class)object);
Import import_ = new Import(bModule.getModuleName(), string, 2);
if (hashMap.get(import_) != null) continue;
arrayList.add(import_);
hashMap.put(import_, import_);
}
this.list = arrayList;
this.map = hashMap;
this.updateTable();
}
void add(Import import_) {
Import import_2 = (Import)this.map.get(import_);
if (import_2 != null) {
if (import_2.definition > import_.definition) {
import_2.definition = import_.definition;
}
} else {
this.list.add(import_);
this.map.put(import_, import_);
}
this.updateTable();
this.editor.setModified();
}
void remove(Import import_) {
this.list.remove(import_);
this.map.remove(import_);
this.updateTable();
this.editor.setModified();
}
void removeSelection() {
int n;
int[] nArray = this.table.getSelection().getRows();
if (nArray == null || nArray.length == 0) {
return;
}
boolean bl = false;
Import[] importArray = this.getAll();
for (n = 0; n < nArray.length; ++n) {
int n2 = nArray[n];
if (importArray[n2].definition != 1) continue;
importArray[n2] = null;
bl = true;
}
if (!bl) {
return;
}
this.list.clear();
this.map.clear();
for (n = 0; n < importArray.length; ++n) {
if (importArray[n] == null) continue;
this.list.add(importArray[n]);
this.map.put(importArray[n], importArray[n]);
}
this.updateTable();
this.editor.setModified();
}
public void save(BProgramCode bProgramCode) {
String[] stringArray;
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < this.list.size(); ++i) {
stringArray = (String[])this.list.get(i);
if (stringArray.definition != 1) continue;
if (stringBuffer.length() > 0) {
stringBuffer.append(';');
}
stringBuffer.append(stringArray.moduleName).append(':').append(stringArray.packageName);
}
bProgramCode.setUserDefinedImports(stringBuffer.toString());
StringBuffer stringBuffer2 = new StringBuffer();
stringArray = this.getDependencies();
for (int i = 0; i < stringArray.length; ++i) {
if (stringBuffer2.length() > 0) {
stringBuffer2.append(';');
}
stringBuffer2.append(stringArray[i]);
}
bProgramCode.setDependencies(stringBuffer2.toString());
}
public void load(BProgramCode bProgramCode) {
this.list.clear();
this.map.clear();
String string = bProgramCode.getUserDefinedImports();
StringTokenizer stringTokenizer = new StringTokenizer(string, ";");
while (stringTokenizer.hasMoreTokens()) {
String string2 = stringTokenizer.nextToken();
int n = string2.indexOf(58);
String string3 = string2.substring(0, n);
String string4 = string2.substring(n + 1);
this.add(new Import(string3, string4, 1));
}
this.updateImports();
}
public int getRowCount() {
return this.list.size();
}
public int getColumnCount() {
return 3;
}
public String getColumnName(int n) {
switch (n) {
case 0: {
return lexModule;
}
case 1: {
return lexPackage;
}
case 2: {
return lexDefinition;
}
}
return "???";
}
public Object getValueAt(int n, int n2) {
Import import_ = (Import)this.list.get(n);
switch (n2) {
case 0: {
return import_.moduleName;
}
case 1: {
return import_.packageName;
}
case 2: {
return import_.definitionToString();
}
}
return "???";
}
public BImage getRowIcon(int n) {
return importIcon;
}
public boolean isColumnSortable(int n) {
return true;
}
public void sortByColumn(int n, boolean bl) {
Object[] objectArray = this.list.toArray(new Import[this.list.size()]);
Object[] objectArray2 = new Object[objectArray.length];
for (int i = 0; i < objectArray2.length; ++i) {
objectArray2[i] = this.getValueAt(i, n).toString();
}
SortUtil.sort((Object[])objectArray2, (Object[])objectArray, (boolean)bl);
ArrayList<Object> arrayList = new ArrayList<Object>();
for (int i = 0; i < objectArray.length; ++i) {
arrayList.add(objectArray[i]);
}
this.list = arrayList;
}
static class Import {
public final String moduleName;
public final String packageName;
public int definition;
public Import(String string, String string2, int n) {
this.moduleName = string;
this.packageName = string2;
this.definition = n;
}
public int hashCode() {
return this.moduleName.hashCode() ^ this.packageName.hashCode();
}
public boolean equals(Object object) {
Import import_ = (Import)object;
return this.moduleName.equals(import_.moduleName) && this.packageName.equals(import_.packageName);
}
public String definitionToString() {
switch (this.definition) {
case 0: {
return "Predefined";
}
case 1: {
return "User Defined";
}
case 2: {
return "By Property";
}
}
return "???";
}
}
class Controller
extends TableController {
Controller() {
}
public void cellPopup(BMouseEvent bMouseEvent, int n, int n2) {
this.popup(bMouseEvent);
}
public void backgroundPopup(BMouseEvent bMouseEvent) {
this.popup(bMouseEvent);
}
public void popup(BMouseEvent bMouseEvent) {
BMenu bMenu = new BMenu();
bMenu.add(null, Imports.this.editor.commands.importType);
bMenu.add(null, Imports.this.editor.commands.importPackage);
bMenu.add(null, Imports.this.editor.commands.removeImport);
bMenu.open((BWidget)Imports.this.table, bMouseEvent.getX(), bMouseEvent.getY());
}
}
}
@@ -0,0 +1,111 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.workbench.console.BConsole
* javax.baja.ui.BWidget
*/
package com.tridium.program.ui;
import com.tridium.program.BProgramCode;
import com.tridium.program.module.BProgramModule;
import com.tridium.program.module.BuildException;
import com.tridium.program.module.IBuildListener;
import com.tridium.program.ui.BProgramEditor;
import com.tridium.program.ui.Compiler;
import com.tridium.program.ui.SourceWriter;
import com.tridium.workbench.console.BConsole;
import java.io.FileWriter;
import java.io.Writer;
import javax.baja.ui.BWidget;
public class ProgramCompiler
extends Compiler {
BProgramEditor editor;
boolean saveOnSuccess;
boolean buildOnSuccess;
public ProgramCompiler(BProgramEditor bProgramEditor) {
super((BWidget)bProgramEditor);
this.editor = bProgramEditor;
}
public void compile(String string, boolean bl) throws Exception {
this.compile(string, bl, false);
}
public void compile(String string, boolean bl, boolean bl2) throws Exception {
this.saveOnSuccess = bl;
this.buildOnSuccess = bl2;
this.editor.saveCode();
this.editor.imports.updateImports();
this.editor.imports.save(this.editor.code);
this.editor.updateSource();
this.compile(string, this.editor.code, null);
}
public void writeSource(FileWriter fileWriter, String string) throws Exception {
SourceWriter sourceWriter = new SourceWriter((Writer)fileWriter, this.editor);
sourceWriter.generate(this.className);
}
public void compileSuccess(BConsole bConsole) throws Exception {
super.compileSuccess(bConsole);
BProgramCode bProgramCode = this.editor.code;
bProgramCode.setChecksum(this.editor.computeChecksum(bProgramCode.getSource()));
this.editor.updateProgramCode();
this.editor.updateStatus();
if (this.saveOnSuccess) {
this.editor.getWbShell().getSaveCommand().invoke();
}
if (this.buildOnSuccess) {
this.buildProgramModule(bConsole);
}
}
public void compileFailed(BConsole bConsole) throws Exception {
this.editor.setModified();
this.editor.code.setChecksum(0);
this.editor.updateStatusToError();
super.compileFailed(bConsole);
}
private void buildProgramModule(BConsole bConsole) {
BProgramModule bProgramModule = this.editor.program.getProgramModule();
if (bProgramModule == null) {
return;
}
try {
bConsole.appendBreak();
bProgramModule.buildModule(new BuildConsoleListener(bConsole));
}
catch (BuildException buildException) {
bConsole.appendLine(buildException.getMessage());
}
}
private class BuildConsoleListener
implements IBuildListener {
private BConsole console;
public BuildConsoleListener(BConsole bConsole) {
this.console = bConsole;
}
public BWidget getOwner() {
return this.console;
}
public void nextStep(String string) {
this.console.appendLine(string);
}
public void setNumBuildSteps(int n) {
}
public void updateDesc(String string) {
this.console.appendLine(string);
}
}
}
@@ -0,0 +1,262 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.workbench.fieldeditors.BTypeSpecFE
* com.tridium.workbench.shell.BNiagaraWbShell
* javax.baja.data.BIDataValue
* javax.baja.gx.BImage
* javax.baja.nre.util.SortUtil
* javax.baja.nre.util.TextUtil
* javax.baja.registry.ModuleInfo
* javax.baja.sys.BBoolean
* javax.baja.sys.BFacets
* javax.baja.sys.BObject
* javax.baja.sys.BValue
* javax.baja.sys.Context
* javax.baja.sys.Sys
* javax.baja.ui.BDialog
* javax.baja.ui.BLabel
* javax.baja.ui.BListDropDown
* javax.baja.ui.BMenu
* javax.baja.ui.BSeparator
* javax.baja.ui.BTextField
* javax.baja.ui.BToolBar
* javax.baja.ui.BWidget
* javax.baja.ui.Command
* javax.baja.ui.CommandArtifact
* javax.baja.ui.enums.BHalign
* javax.baja.ui.pane.BGridPane
* javax.baja.ui.util.UiLexicon
* javax.baja.util.BTypeSpec
* javax.baja.util.Lexicon
*/
package com.tridium.program.ui;
import com.tridium.program.BCode;
import com.tridium.program.ui.BProgramEditor;
import com.tridium.program.ui.Compiler;
import com.tridium.program.ui.Imports;
import com.tridium.workbench.fieldeditors.BTypeSpecFE;
import com.tridium.workbench.shell.BNiagaraWbShell;
import java.io.File;
import javax.baja.data.BIDataValue;
import javax.baja.gx.BImage;
import javax.baja.nre.util.SortUtil;
import javax.baja.nre.util.TextUtil;
import javax.baja.registry.ModuleInfo;
import javax.baja.sys.BBoolean;
import javax.baja.sys.BFacets;
import javax.baja.sys.BObject;
import javax.baja.sys.BValue;
import javax.baja.sys.Context;
import javax.baja.sys.Sys;
import javax.baja.ui.BDialog;
import javax.baja.ui.BLabel;
import javax.baja.ui.BListDropDown;
import javax.baja.ui.BMenu;
import javax.baja.ui.BSeparator;
import javax.baja.ui.BTextField;
import javax.baja.ui.BToolBar;
import javax.baja.ui.BWidget;
import javax.baja.ui.Command;
import javax.baja.ui.CommandArtifact;
import javax.baja.ui.enums.BHalign;
import javax.baja.ui.pane.BGridPane;
import javax.baja.ui.util.UiLexicon;
import javax.baja.util.BTypeSpec;
import javax.baja.util.Lexicon;
public class ProgramEditorCommands {
static UiLexicon lex = UiLexicon.bajaui;
public final BProgramEditor editor;
public Command importType;
public Command importPackage;
public Command removeImport;
public Command saveAndCompile;
public Command compile;
public Command build;
static /* synthetic */ Class class$com$tridium$program$ui$BProgramEditor;
public ProgramEditorCommands(BProgramEditor bProgramEditor) {
this.editor = bProgramEditor;
this.importType = new ImportTypeCommand();
this.importPackage = new ImportPackageCommand();
this.removeImport = new RemoveImportCommand();
this.saveAndCompile = new SaveAndCompileCommand();
this.compile = new CompileCommand();
this.build = new BuildCommand();
}
public BMenu[] getViewMenus() {
BMenu bMenu = UiLexicon.bajaui.buildMenu("programEditor.menu.label");
bMenu.add("importType", this.importType);
bMenu.add("importPackage", this.importPackage);
bMenu.add("importRemove", this.removeImport);
bMenu.add("sep0", (BValue)new BSeparator());
bMenu.add("addSlot", (Command)this.editor.slotSheet.commands.add);
bMenu.add("deleteSlot", (Command)this.editor.slotSheet.commands.delete);
bMenu.add("renameSlot", (Command)this.editor.slotSheet.commands.rename);
bMenu.add("reorderSlots", (Command)this.editor.slotSheet.commands.reorder);
bMenu.add("sep1", (BValue)new BSeparator());
bMenu.add("saveAndCompile", this.saveAndCompile);
bMenu.add("compile", this.compile);
return new BMenu[]{bMenu};
}
public BToolBar getViewToolBar() {
BNiagaraWbShell bNiagaraWbShell = (BNiagaraWbShell)this.editor.getShell();
BToolBar bToolBar = new BToolBar();
bToolBar.add("find", bNiagaraWbShell.commands.find);
bToolBar.add("replace", bNiagaraWbShell.commands.replace);
bToolBar.add("sep2", (BValue)new BSeparator());
if (this.editor.program.getProgramModule() != null) {
bToolBar.add("build", this.build);
}
bToolBar.add("saveAndCompile", this.saveAndCompile);
bToolBar.add("compile", this.compile);
bToolBar.add("consolePrev", bNiagaraWbShell.commands.consolePrev);
bToolBar.add("consoleNext", bNiagaraWbShell.commands.consoleNext);
return bToolBar;
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
public class BuildCommand
extends Command {
public BuildCommand() {
super((BWidget)ProgramEditorCommands.this.editor, Lexicon.make((Class)(class$com$tridium$program$ui$BProgramEditor == null ? (class$com$tridium$program$ui$BProgramEditor = ProgramEditorCommands.class$("com.tridium.program.ui.BProgramEditor")) : class$com$tridium$program$ui$BProgramEditor)), "programEditor.build");
}
public CommandArtifact doInvoke() throws Exception {
ProgramEditorCommands.this.editor.compiler.compile(BCode.generateClassName(), true, true);
return null;
}
}
public class SaveAndCompileCommand
extends ProgramEditorCommand {
public SaveAndCompileCommand() {
super("programEditor.saveAndCompile");
}
public CommandArtifact doInvoke() throws Exception {
ProgramEditorCommands.this.editor.compiler.compile(BCode.generateClassName(), true);
return null;
}
}
public class CompileCommand
extends ProgramEditorCommand {
public CompileCommand() {
super("programEditor.compile");
}
public CommandArtifact doInvoke() throws Exception {
ProgramEditorCommands.this.editor.compiler.compile(BCode.generateClassName(), false);
return null;
}
}
public class RemoveImportCommand
extends ProgramEditorCommand {
public RemoveImportCommand() {
super("programEditor.removeImport");
}
public CommandArtifact doInvoke() throws Exception {
ProgramEditorCommands.this.editor.imports.removeSelection();
return null;
}
}
public class ImportPackageCommand
extends ProgramEditorCommand {
public ImportPackageCommand() {
super("programEditor.importPackage");
}
public CommandArtifact doInvoke() throws Exception {
int n;
BListDropDown bListDropDown = new BListDropDown();
ModuleInfo[] moduleInfoArray = Sys.getRegistry().getModules();
File file = new File(Sys.getBajaHome(), "bin");
String[] stringArray = file.list(new Compiler.JarFilenameFilter());
Object[] objectArray = new String[moduleInfoArray.length + stringArray.length];
for (n = 0; n < moduleInfoArray.length; ++n) {
objectArray[n] = moduleInfoArray[n].getModuleName();
}
for (n = 0; n < stringArray.length; ++n) {
objectArray[moduleInfoArray.length + n] = stringArray[n].substring(0, stringArray[n].length() - 4);
}
SortUtil.sort((Object[])objectArray);
bListDropDown.getList().addItem((Object)"java");
for (n = 0; n < objectArray.length; ++n) {
bListDropDown.getList().addItem(objectArray[n]);
}
bListDropDown.setSelectedItem((Object)"baja");
BTextField bTextField = new BTextField("", 25);
BGridPane bGridPane = new BGridPane(2);
bGridPane.setColumnAlign(BHalign.fill);
bGridPane.add(null, (BValue)new BLabel(lex.getText("programEditor.module")));
bGridPane.add(null, (BValue)bListDropDown);
bGridPane.add(null, (BValue)new BLabel(lex.getText("programEditor.package")));
bGridPane.add(null, (BValue)bTextField);
int n2 = BDialog.open((BWidget)ProgramEditorCommands.this.editor, (String)this.getLabel(), (Object)bGridPane, (int)3, (BImage)BDialog.QUESTION_ICON);
if (n2 == 2) {
return null;
}
String string = (String)bListDropDown.getSelectedItem();
String string2 = bTextField.getText();
if (string2.equals("")) {
return null;
}
ProgramEditorCommands.this.editor.imports.add(new Imports.Import(string, string2, 1));
return null;
}
}
public class ImportTypeCommand
extends ProgramEditorCommand {
public ImportTypeCommand() {
super("programEditor.importType");
}
public CommandArtifact doInvoke() throws Exception {
BTypeSpecFE bTypeSpecFE = new BTypeSpecFE();
bTypeSpecFE.loadValue((BObject)BTypeSpec.make((String)"baja", (String)"String"), (Context)BFacets.make((String)"allowNull", (BIDataValue)BBoolean.FALSE));
int n = BDialog.open((BWidget)ProgramEditorCommands.this.editor, (String)this.getLabel(), (Object)bTypeSpecFE, (int)3, (BImage)BDialog.QUESTION_ICON);
if (n == 2) {
return null;
}
BTypeSpec bTypeSpec = (BTypeSpec)bTypeSpecFE.saveValue();
if (bTypeSpec.getTypeName().equals("")) {
return null;
}
String string = bTypeSpec.getResolvedType().getTypeClass().getName();
String string2 = TextUtil.getPackageName((String)string);
ProgramEditorCommands.this.editor.imports.add(new Imports.Import(bTypeSpec.getModuleName(), string2, 1));
return null;
}
}
public class ProgramEditorCommand
extends Command {
public ProgramEditorCommand(String string) {
super((BWidget)ProgramEditorCommands.this.editor, UiLexicon.bajaui.module, string);
}
public CommandArtifact doInvoke() throws Exception {
BDialog.message((BWidget)ProgramEditorCommands.this.editor, (Object)("Incomplete: " + this.getLabel()));
return null;
}
}
}
@@ -0,0 +1,99 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.workbench.shell.BNiagaraWbShell
* javax.baja.sys.BValue
* javax.baja.ui.BDialog
* javax.baja.ui.BMenu
* javax.baja.ui.BSeparator
* javax.baja.ui.BToolBar
* javax.baja.ui.BWidget
* javax.baja.ui.Command
* javax.baja.ui.CommandArtifact
* javax.baja.ui.util.UiLexicon
*/
package com.tridium.program.ui;
import com.tridium.program.ui.BRobotEditor;
import com.tridium.workbench.shell.BNiagaraWbShell;
import javax.baja.sys.BValue;
import javax.baja.ui.BDialog;
import javax.baja.ui.BMenu;
import javax.baja.ui.BSeparator;
import javax.baja.ui.BToolBar;
import javax.baja.ui.BWidget;
import javax.baja.ui.Command;
import javax.baja.ui.CommandArtifact;
import javax.baja.ui.util.UiLexicon;
public class RobotEditorCommands {
static UiLexicon lex = UiLexicon.bajaui;
public final BRobotEditor editor;
public final Command compile;
public final Command compileAndRun;
public RobotEditorCommands(BRobotEditor bRobotEditor) {
this.editor = bRobotEditor;
this.compileAndRun = new CompileAndRunCommand();
this.compile = new CompileCommand();
}
public BMenu[] getViewMenus() {
BMenu bMenu = UiLexicon.bajaui.buildMenu("robotEditor.menu.label");
bMenu.add("compile", this.compile);
bMenu.add("run", this.compileAndRun);
return new BMenu[]{bMenu};
}
public BToolBar getViewToolBar() {
BNiagaraWbShell bNiagaraWbShell = (BNiagaraWbShell)this.editor.getShell();
BToolBar bToolBar = new BToolBar();
bToolBar.add("find", bNiagaraWbShell.commands.find);
bToolBar.add("replace", bNiagaraWbShell.commands.replace);
bToolBar.add("sep1", (BValue)new BSeparator());
bToolBar.add("compile", this.compile);
bToolBar.add("run", this.compileAndRun);
bToolBar.add("sep2", (BValue)new BSeparator());
bToolBar.add("consolePrev", bNiagaraWbShell.commands.consolePrev);
bToolBar.add("consoleNext", bNiagaraWbShell.commands.consoleNext);
return bToolBar;
}
public class CompileAndRunCommand
extends RobotEditorCommand {
public CompileAndRunCommand() {
super("robotEditor.compileAndRun");
}
public CommandArtifact doInvoke() throws Exception {
RobotEditorCommands.this.editor.compiler.compile(true);
return null;
}
}
public class CompileCommand
extends RobotEditorCommand {
public CompileCommand() {
super("robotEditor.compile");
}
public CommandArtifact doInvoke() throws Exception {
RobotEditorCommands.this.editor.compiler.compile(false);
return null;
}
}
public class RobotEditorCommand
extends Command {
public RobotEditorCommand(String string) {
super((BWidget)RobotEditorCommands.this.editor, UiLexicon.bajaui.module, string);
}
public CommandArtifact doInvoke() throws Exception {
BDialog.message((BWidget)RobotEditorCommands.this.editor, (Object)("Incomplete: " + this.getLabel()));
return null;
}
}
}
@@ -0,0 +1,300 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.TextUtil
* javax.baja.sys.BAction
* javax.baja.sys.BBoolean
* javax.baja.sys.BDouble
* javax.baja.sys.BFloat
* javax.baja.sys.BInteger
* javax.baja.sys.BLink
* javax.baja.sys.BLong
* javax.baja.sys.BModule
* javax.baja.sys.BObject
* javax.baja.sys.BString
* javax.baja.sys.BTopic
* javax.baja.sys.BValue
* javax.baja.sys.Property
* javax.baja.sys.SlotCursor
* javax.baja.sys.Sys
* javax.baja.util.BWsAnnotation
*/
package com.tridium.program.ui;
import com.tridium.program.BProgram;
import com.tridium.program.BProgramCode;
import com.tridium.program.ui.BProgramEditor;
import com.tridium.program.ui.Imports;
import java.io.BufferedReader;
import java.io.CharArrayWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.Writer;
import java.util.ArrayList;
import javax.baja.nre.util.TextUtil;
import javax.baja.sys.BAction;
import javax.baja.sys.BBoolean;
import javax.baja.sys.BDouble;
import javax.baja.sys.BFloat;
import javax.baja.sys.BInteger;
import javax.baja.sys.BLink;
import javax.baja.sys.BLong;
import javax.baja.sys.BModule;
import javax.baja.sys.BObject;
import javax.baja.sys.BString;
import javax.baja.sys.BTopic;
import javax.baja.sys.BValue;
import javax.baja.sys.Property;
import javax.baja.sys.SlotCursor;
import javax.baja.sys.Sys;
import javax.baja.util.BWsAnnotation;
public class SourceWriter
extends PrintWriter {
public BProgramEditor editor;
public BProgram program;
public BProgramCode code;
public Imports.Import[] imports;
private Property[] accessProps;
private int line;
public int sourceLine;
public static char[] generateToCharArray(BProgramEditor bProgramEditor, String string) {
CharArrayWriter charArrayWriter = new CharArrayWriter();
new SourceWriter((Writer)charArrayWriter, bProgramEditor).generate(string);
return charArrayWriter.toCharArray();
}
public SourceWriter(Writer writer, BProgramEditor bProgramEditor) {
super(writer);
this.init(bProgramEditor);
}
public SourceWriter(OutputStream outputStream, BProgramEditor bProgramEditor) {
super(outputStream);
this.init(bProgramEditor);
}
private void init(BProgramEditor bProgramEditor) {
this.editor = bProgramEditor;
this.program = bProgramEditor.program;
this.code = bProgramEditor.code;
this.sourceLine = 0;
this.imports = bProgramEditor.imports.getAll();
this.accessProps = this.getAccessProperties();
}
private Property[] getAccessProperties() {
ArrayList<Property> arrayList = new ArrayList<Property>();
SlotCursor slotCursor = this.program.getProperties();
while (slotCursor.next()) {
BObject bObject;
Property property = slotCursor.property();
if (property.isFrozen() || (bObject = slotCursor.get()) instanceof BWsAnnotation || bObject instanceof BLink || bObject instanceof BAction || bObject instanceof BTopic) continue;
arrayList.add(property);
}
return arrayList.toArray(new Property[arrayList.size()]);
}
public void generate(String string) {
this.generateHeader(string);
this.generateGetters();
this.generateSetters();
this.generateSource();
this.generateFooter();
this.editor.sourceLine = this.sourceLine;
this.flush();
}
private void generateHeader(String string) {
BModule bModule = Sys.getModuleForClass(this.getClass());
this.w("/* Auto-generated ProgramImpl Code */");
this.w("");
for (int i = 0; i < this.imports.length; ++i) {
this.x("import ");
this.x(TextUtil.pad((String)(this.imports[i].packageName + ".*;"), (int)25));
this.x(" /* ");
this.x(this.imports[i].moduleName);
this.x(" ");
this.x(this.imports[i].definitionToString());
this.w("*/");
}
this.w("");
this.w("public class " + string);
this.w(" extends com.tridium.program.ProgramBase");
this.w("{");
}
private void generateGetters() {
if (this.accessProps.length == 0) {
return;
}
this.header("Getters");
for (int i = 0; i < this.accessProps.length; ++i) {
Property property = this.accessProps[i];
String string = property.getName();
BValue bValue = this.program.get(property);
if (bValue.getType() == BBoolean.TYPE) {
this.x(" public boolean get");
this.x(SourceWriter.capitalize(string));
this.x("() { return getBoolean(\"");
this.x(string);
this.x("\"); }");
} else if (bValue.getType() == BInteger.TYPE) {
this.x(" public int get");
this.x(SourceWriter.capitalize(string));
this.x("() { return getInt(\"");
this.x(string);
this.x("\"); }");
} else if (bValue.getType() == BFloat.TYPE) {
this.x(" public float get");
this.x(SourceWriter.capitalize(string));
this.x("() { return getFloat(\"");
this.x(string);
this.x("\"); }");
} else if (bValue.getType() == BString.TYPE) {
this.x(" public String get");
this.x(SourceWriter.capitalize(string));
this.x("() { return getString(\"");
this.x(string);
this.x("\"); }");
} else if (bValue.getType() == BDouble.TYPE) {
this.x(" public double get");
this.x(SourceWriter.capitalize(string));
this.x("() { return getDouble(\"");
this.x(string);
this.x("\"); }");
} else if (bValue.getType() == BLong.TYPE) {
this.x(" public long get");
this.x(SourceWriter.capitalize(string));
this.x("() { return getLong(\"");
this.x(string);
this.x("\"); }");
} else {
String string2 = TextUtil.getClassName(bValue.getClass());
this.x(" public ");
this.x(string2);
this.x(" get");
this.x(SourceWriter.capitalize(string));
this.x("() { return (");
this.x(string2);
this.x(")get(\"");
this.x(string);
this.x("\"); }");
}
this.w("");
}
}
private void generateSetters() {
if (this.accessProps.length == 0) {
return;
}
this.header("Setters");
for (int i = 0; i < this.accessProps.length; ++i) {
Property property = this.accessProps[i];
String string = property.getName();
BValue bValue = this.program.get(property);
if (bValue.getType() == BBoolean.TYPE) {
this.x(" public void set");
this.x(SourceWriter.capitalize(string));
this.x("(boolean v) { setBoolean(\"");
this.x(string);
this.x("\", v); }");
} else if (bValue.getType() == BInteger.TYPE) {
this.x(" public void set");
this.x(SourceWriter.capitalize(string));
this.x("(int v) { setInt(\"");
this.x(string);
this.x("\", v); }");
} else if (bValue.getType() == BFloat.TYPE) {
this.x(" public void set");
this.x(SourceWriter.capitalize(string));
this.x("(float v) { setFloat(\"");
this.x(string);
this.x("\", v); }");
} else if (bValue.getType() == BString.TYPE) {
this.x(" public void set");
this.x(SourceWriter.capitalize(string));
this.x("(String v) { setString(\"");
this.x(string);
this.x("\", v); }");
} else if (bValue.getType() == BDouble.TYPE) {
this.x(" public void set");
this.x(SourceWriter.capitalize(string));
this.x("(double v) { setDouble(\"");
this.x(string);
this.x("\", v); }");
} else if (bValue.getType() == BLong.TYPE) {
this.x(" public void set");
this.x(SourceWriter.capitalize(string));
this.x("(long v) { setLong(\"");
this.x(string);
this.x("\", v); }");
} else {
this.x(" public void set");
this.x(SourceWriter.capitalize(string));
this.x("(");
this.x(bValue.getClass().getName());
this.x(" v) { set(\"");
this.x(string);
this.x("\", v); }");
}
this.w("");
}
}
private void generateSource() {
this.header("Program Source");
this.sourceLine = this.line;
this.writeCode(this.code.getSource(), 2);
}
private void generateFooter() {
this.w("}");
}
static String capitalize(String string) {
return TextUtil.capitalize((String)string);
}
static String decapitalize(String string) {
return TextUtil.decapitalize((String)string);
}
private void header(String string) {
this.w("");
this.w("////////////////////////////////////////////////////////////////");
this.w("// " + string);
this.w("////////////////////////////////////////////////////////////////");
this.w("");
}
private void writeCode(String string, int n) {
try {
String string2;
BufferedReader bufferedReader = new BufferedReader(new StringReader(string));
while ((string2 = bufferedReader.readLine()) != null) {
this.x(TextUtil.getSpaces((int)n));
this.w(string2);
}
}
catch (IOException iOException) {
throw new IllegalStateException();
}
}
private void x(String string) {
this.print(string);
}
private void w(String string) {
this.print(string);
this.print('\n');
++this.line;
}
}
@@ -0,0 +1,195 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.ui.BOptionDialog
* com.tridium.ui.theme.Theme
* com.tridium.workbench.fieldeditors.BTypeSpecFE
* javax.baja.data.BIDataValue
* javax.baja.gx.BBrush
* javax.baja.io.ValueDocEncoder
* javax.baja.naming.SlotPath
* javax.baja.sys.Action
* javax.baja.sys.BBoolean
* javax.baja.sys.BComponent
* javax.baja.sys.BFacets
* javax.baja.sys.BObject
* javax.baja.sys.BValue
* javax.baja.sys.Context
* javax.baja.sys.Slot
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BCheckBox
* javax.baja.ui.BDialog
* javax.baja.ui.BLabel
* javax.baja.ui.BNullWidget
* javax.baja.ui.BTextField
* javax.baja.ui.BWidget
* javax.baja.ui.enums.BHalign
* javax.baja.ui.enums.BScrollBarPolicy
* javax.baja.ui.enums.BValign
* javax.baja.ui.pane.BBorderPane
* javax.baja.ui.pane.BEdgePane
* javax.baja.ui.pane.BGridPane
* javax.baja.ui.pane.BScrollPane
* javax.baja.util.BTypeSpec
* javax.baja.util.Lexicon
* javax.baja.workbench.fieldeditor.BWbFieldEditor
*/
package com.tridium.program.ui.batch;
import com.tridium.program.ui.batch.BBatchEditor;
import com.tridium.ui.BOptionDialog;
import com.tridium.ui.theme.Theme;
import com.tridium.workbench.fieldeditors.BTypeSpecFE;
import javax.baja.data.BIDataValue;
import javax.baja.gx.BBrush;
import javax.baja.io.ValueDocEncoder;
import javax.baja.naming.SlotPath;
import javax.baja.sys.Action;
import javax.baja.sys.BBoolean;
import javax.baja.sys.BComponent;
import javax.baja.sys.BFacets;
import javax.baja.sys.BObject;
import javax.baja.sys.BValue;
import javax.baja.sys.Context;
import javax.baja.sys.Slot;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BCheckBox;
import javax.baja.ui.BDialog;
import javax.baja.ui.BLabel;
import javax.baja.ui.BNullWidget;
import javax.baja.ui.BTextField;
import javax.baja.ui.BWidget;
import javax.baja.ui.enums.BHalign;
import javax.baja.ui.enums.BScrollBarPolicy;
import javax.baja.ui.enums.BValign;
import javax.baja.ui.pane.BBorderPane;
import javax.baja.ui.pane.BEdgePane;
import javax.baja.ui.pane.BGridPane;
import javax.baja.ui.pane.BScrollPane;
import javax.baja.util.BTypeSpec;
import javax.baja.util.Lexicon;
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
public class BAddDialog
extends BOptionDialog {
public static final Action typeChanged = BAddDialog.newAction((int)0, null, null);
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$batch$BAddDialog == null ? (class$com$tridium$program$ui$batch$BAddDialog = BAddDialog.class$("com.tridium.program.ui.batch.BAddDialog")) : class$com$tridium$program$ui$batch$BAddDialog));
private static Lexicon lex = Lexicon.make((String)"program");
private BTextField name = new BTextField("", 30);
private BTypeSpecFE type;
private BWbFieldEditor editor;
private BCheckBox setIfExists = new BCheckBox(lex.getText("batchEditor.setIfExists"));
private BBorderPane content;
static /* synthetic */ Class class$com$tridium$program$ui$batch$BAddDialog;
public void typeChanged() {
this.invoke(typeChanged, null, null);
}
public Type getType() {
return TYPE;
}
public static String open(BBatchEditor bBatchEditor) {
BAddDialog bAddDialog = new BAddDialog(bBatchEditor);
bAddDialog.setBoundsCenteredOnOwner();
bAddDialog.open();
if (bAddDialog.getResult() == 1) {
try {
if (SlotPath.isValidName((String)bAddDialog.name.getText())) {
String string = bAddDialog.name.getText();
BValue bValue = (BValue)bAddDialog.editor.saveValue();
boolean bl = bAddDialog.setIfExists.isSelected();
String string2 = ValueDocEncoder.marshal((BValue)bValue);
string2 = string2.replaceAll("\"", "'");
string2 = string2.replaceAll("\n", "");
StringBuffer stringBuffer = new StringBuffer("add(ord, ");
stringBuffer.append("\"").append(string).append("\", ");
stringBuffer.append("\"").append(bValue.getType().getTypeSpec()).append("\", ");
stringBuffer.append("\"").append(string2).append("\", ");
stringBuffer.append(bl ? "true" : "false").append(");");
return stringBuffer.toString();
}
BDialog.error((BWidget)bBatchEditor, (String)lex.getText("batchEditor.commands.slotAdd.label"), (Object)lex.getText("batchEditor.invalidName"));
}
catch (Exception exception) {
BDialog.error((BWidget)bBatchEditor, (String)"Error", (Object)"Failed", (Throwable)exception);
}
}
return null;
}
private BAddDialog(BBatchEditor bBatchEditor) {
super((BWidget)bBatchEditor, lex.getText("batchEditor.commands.slotAdd.label"), (BWidget)new BNullWidget(), 3, null, null);
BFacets bFacets = BFacets.make((String)"allowNull", (BIDataValue)BBoolean.FALSE);
bFacets = BFacets.make((BFacets)bFacets, (String)"showAbstract", (BIDataValue)BBoolean.FALSE);
this.type = new BTypeSpecFE();
this.linkTo("link", (BComponent)this.type, (Slot)BTypeSpecFE.pluginModified, (Slot)typeChanged);
this.type.loadValue((BObject)BComponent.TYPE.getTypeSpec(), (Context)bFacets);
this.setIfExists.setSelected(true);
this.editor = this.make(BComponent.TYPE);
BGridPane bGridPane = new BGridPane(1);
bGridPane.setValign(BValign.top);
bGridPane.setHalign(BHalign.left);
this.content = new BBorderPane((BWidget)this.editor, 1.0, 1.0, 1.0, 1.0);
bGridPane.add(null, (BValue)this.content);
BGridPane bGridPane2 = new BGridPane(2);
bGridPane2.add(null, (BValue)new BLabel(lex.getText("batchEditor.newName")));
bGridPane2.add(null, (BValue)this.name);
bGridPane2.add(null, (BValue)new BLabel(lex.getText("batchEditor.newType")));
bGridPane2.add(null, (BValue)this.type);
BGridPane bGridPane3 = new BGridPane(1);
bGridPane3.setHalign(BHalign.left);
bGridPane3.add(null, (BValue)bGridPane2);
bGridPane3.add(null, (BValue)this.setIfExists);
BEdgePane bEdgePane = new BEdgePane();
bEdgePane.setTop((BWidget)new BBorderPane((BWidget)bGridPane3, 0.0, 0.0, 10.0, 0.0));
BBrush bBrush = Theme.scrollPane().getControlBackground();
BScrollPane bScrollPane = new BScrollPane((BWidget)new BBorderPane((BWidget)bGridPane, lex.getText("batchEditor.newValue")));
bScrollPane.setBorderPolicy(BScrollBarPolicy.asNeeded);
bScrollPane.setViewportBackground(bBrush);
bEdgePane.setCenter((BWidget)bScrollPane);
this.setContent((BWidget)new BBorderPane((BWidget)bEdgePane, 10.0, 10.0, 10.0, 10.0));
}
private BWbFieldEditor make(Type type) {
BObject bObject = type.getInstance();
BWbFieldEditor bWbFieldEditor = BWbFieldEditor.makeFor((BObject)bObject);
bWbFieldEditor.loadValue(bObject);
return bWbFieldEditor;
}
public void computePreferredSize() {
super.computePreferredSize();
double d = Math.max(500.0, this.getPreferredWidth());
double d2 = Math.max(300.0, this.getPreferredHeight());
this.setPreferredSize(d, d2);
}
public void doTypeChanged() {
try {
BObject bObject = ((BTypeSpec)this.type.saveValue()).getInstance();
this.editor = this.make(bObject.getType());
this.content.setContent((BWidget)this.editor);
this.computePreferredSize();
this.setSize(this.getPreferredWidth(), this.getPreferredHeight());
this.setBoundsCenteredOnOwner();
}
catch (Exception exception) {
exception.printStackTrace();
}
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
}
@@ -0,0 +1,124 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.gx.BInsets
* javax.baja.sys.BObject
* javax.baja.sys.BValue
* javax.baja.sys.Context
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BBorder
* javax.baja.ui.BButton
* javax.baja.ui.BMenu
* javax.baja.ui.BSeparator
* javax.baja.ui.BToolBar
* javax.baja.ui.BWidget
* javax.baja.ui.Command
* javax.baja.ui.enums.BHalign
* javax.baja.ui.pane.BBorderPane
* javax.baja.ui.pane.BEdgePane
* javax.baja.ui.pane.BGridPane
* javax.baja.ui.transfer.BTransferWidget
* javax.baja.workbench.view.BWbView
*/
package com.tridium.program.ui.batch;
import com.tridium.program.BProgramService;
import com.tridium.program.ui.batch.BBatchTable;
import com.tridium.program.ui.batch.BatchCommands;
import javax.baja.gx.BInsets;
import javax.baja.sys.BObject;
import javax.baja.sys.BValue;
import javax.baja.sys.Context;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BBorder;
import javax.baja.ui.BButton;
import javax.baja.ui.BMenu;
import javax.baja.ui.BSeparator;
import javax.baja.ui.BToolBar;
import javax.baja.ui.BWidget;
import javax.baja.ui.Command;
import javax.baja.ui.enums.BHalign;
import javax.baja.ui.pane.BBorderPane;
import javax.baja.ui.pane.BEdgePane;
import javax.baja.ui.pane.BGridPane;
import javax.baja.ui.transfer.BTransferWidget;
import javax.baja.workbench.view.BWbView;
public class BBatchEditor
extends BWbView {
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$batch$BBatchEditor == null ? (class$com$tridium$program$ui$batch$BBatchEditor = BBatchEditor.class$("com.tridium.program.ui.batch.BBatchEditor")) : class$com$tridium$program$ui$batch$BBatchEditor));
private static BBatchTable.Model model;
BBatchTable table = new BBatchTable(this);
BatchCommands commands;
BProgramService service;
static /* synthetic */ Class class$com$tridium$program$ui$batch$BBatchEditor;
public Type getType() {
return TYPE;
}
public BBatchEditor() {
if (model != null) {
this.table.setModel(model.makeCopy());
}
this.commands = new BatchCommands(this);
BGridPane bGridPane = new BGridPane(4);
bGridPane.setColumnAlign(BHalign.fill);
bGridPane.add(null, (BValue)new BButton((Command)this.commands.findObjects));
bGridPane.add(null, (BValue)new BButton((Command)this.commands.clearAll));
bGridPane.add(null, (BValue)new BButton((Command)this.commands.rename));
bGridPane.add(null, (BValue)new BButton((Command)this.commands.slotAdd));
bGridPane.add(null, (BValue)new BButton((Command)this.commands.slotEdit));
bGridPane.add(null, (BValue)new BButton((Command)this.commands.slotRename));
bGridPane.add(null, (BValue)new BButton((Command)this.commands.slotRemove));
bGridPane.add(null, (BValue)new BButton((Command)this.commands.slotFlags));
BEdgePane bEdgePane = new BEdgePane();
bEdgePane.setCenter((BWidget)new BBorderPane((BWidget)this.table, BBorder.inset, BInsets.make((double)0.0, (double)0.0, (double)0.0, (double)0.0)));
bEdgePane.setBottom((BWidget)new BBorderPane((BWidget)bGridPane, 5.0, 0.0, 0.0, 0.0));
this.setContent((BWidget)bEdgePane);
this.setTransferWidget((BTransferWidget)this.table);
}
public BMenu[] getViewMenus() {
return new BMenu[]{this.commands.buildMenu()};
}
public BToolBar getViewToolBar() {
BToolBar bToolBar = new BToolBar();
bToolBar.add(null, (Command)this.commands.findObjects);
bToolBar.add(null, (Command)this.commands.clear);
bToolBar.add(null, (Command)this.commands.selectCols);
bToolBar.add(null, (BValue)new BSeparator());
bToolBar.add(null, (Command)this.commands.rename);
bToolBar.add(null, (Command)this.commands.slotAdd);
bToolBar.add(null, (Command)this.commands.slotEdit);
bToolBar.add(null, (Command)this.commands.slotRename);
bToolBar.add(null, (Command)this.commands.slotRemove);
bToolBar.add(null, (Command)this.commands.slotFlags);
return bToolBar;
}
protected void doLoadValue(BObject bObject, Context context) throws Exception {
this.service = (BProgramService)bObject;
this.table.refresh();
this.commands.updateCommands();
}
public void deactivated() {
super.deactivated();
model = this.table.model;
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
}
@@ -0,0 +1,292 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.script.PropertyField
* com.tridium.script.ScriptField
* com.tridium.script.ScriptUtil
* com.tridium.workbench.user.BPermissionsMapFE
* javax.baja.gx.BImage
* javax.baja.naming.SlotPath
* javax.baja.space.Mark
* javax.baja.sys.BComponent
* javax.baja.sys.BIcon
* javax.baja.sys.BObject
* javax.baja.sys.BValue
* javax.baja.sys.Context
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BMenu
* javax.baja.ui.BWidget
* javax.baja.ui.CommandArtifact
* javax.baja.ui.event.BKeyEvent
* javax.baja.ui.event.BMouseEvent
* javax.baja.ui.table.BTable
* javax.baja.ui.table.TableController
* javax.baja.ui.table.TableModel
* javax.baja.ui.table.TableSelection
* javax.baja.ui.transfer.TransferContext
* javax.baja.ui.transfer.TransferFormat
* javax.baja.util.Lexicon
* javax.baja.workbench.fieldeditor.BWbFieldEditor
*/
package com.tridium.program.ui.batch;
import com.tridium.program.ui.batch.BBatchEditor;
import com.tridium.program.ui.batch.BatchCommands;
import com.tridium.script.PropertyField;
import com.tridium.script.ScriptField;
import com.tridium.script.ScriptUtil;
import com.tridium.workbench.user.BPermissionsMapFE;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import javax.baja.gx.BImage;
import javax.baja.naming.SlotPath;
import javax.baja.space.Mark;
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.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BMenu;
import javax.baja.ui.BWidget;
import javax.baja.ui.CommandArtifact;
import javax.baja.ui.event.BKeyEvent;
import javax.baja.ui.event.BMouseEvent;
import javax.baja.ui.table.BTable;
import javax.baja.ui.table.TableController;
import javax.baja.ui.table.TableModel;
import javax.baja.ui.table.TableSelection;
import javax.baja.ui.transfer.TransferContext;
import javax.baja.ui.transfer.TransferFormat;
import javax.baja.util.Lexicon;
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
public class BBatchTable
extends BTable {
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$batch$BBatchTable == null ? (class$com$tridium$program$ui$batch$BBatchTable = BBatchTable.class$("com.tridium.program.ui.batch.BBatchTable")) : class$com$tridium$program$ui$batch$BBatchTable));
private Lexicon lex = Lexicon.make((String)"program");
BBatchEditor editor;
Model model;
static /* synthetic */ Class class$com$tridium$program$ui$batch$BBatchTable;
public Type getType() {
return TYPE;
}
public BBatchTable(BBatchEditor bBatchEditor) {
this.editor = bBatchEditor;
this.model = new Model();
this.setModel(this.model);
this.setSelection(new Selection());
this.setController(new Controller());
this.setPasteEnabled(true);
}
public void refresh() {
BatchCommands.lease(this.model.kids.toArray(new BComponent[this.model.kids.size()]));
this.relayout();
}
public void setModel(TableModel tableModel) {
super.setModel(tableModel);
if (tableModel instanceof Model) {
this.model = (Model)tableModel;
}
}
public int dragOver(TransferContext transferContext) {
Mark mark = (Mark)transferContext.getEnvelope().getData(TransferFormat.mark);
BObject[] bObjectArray = mark.getValues();
for (int i = 0; i < bObjectArray.length; ++i) {
if (!(bObjectArray[i] instanceof BComponent)) continue;
return 16;
}
return 0;
}
public CommandArtifact drop(TransferContext transferContext) throws Exception {
Mark mark = (Mark)transferContext.getEnvelope().getData(TransferFormat.mark);
BObject[] bObjectArray = mark.getValues();
ArrayList<BObject> arrayList = new ArrayList<BObject>();
for (int i = 0; i < bObjectArray.length; ++i) {
if (!(bObjectArray[i] instanceof BComponent) || this.model.kids.contains(bObjectArray[i])) continue;
arrayList.add(bObjectArray[i]);
this.model.kids.add(bObjectArray[i]);
}
BatchCommands.lease(arrayList.toArray(new BComponent[arrayList.size()]));
this.sizeColumnsToFit();
this.relayout();
this.editor.commands.updateCommands();
return null;
}
public CommandArtifact insertTransferData(TransferContext transferContext) throws Exception {
return this.drop(transferContext);
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
class Controller
extends TableController {
Controller() {
}
public void keyPressed(BKeyEvent bKeyEvent) {
if (bKeyEvent.getKeyCode() == 127) {
bKeyEvent.consume();
BBatchTable.this.editor.commands.clear.invoke();
} else {
super.keyPressed(bKeyEvent);
}
}
protected void cellPopup(BMouseEvent bMouseEvent, int n, int n2) {
BMenu bMenu = BBatchTable.this.editor.commands.buildMenu();
bMenu.open((BWidget)this.getTable(), bMouseEvent.getX(), bMouseEvent.getY());
}
protected void backgroundPopup(BMouseEvent bMouseEvent) {
BMenu bMenu = BBatchTable.this.editor.commands.buildMenu();
bMenu.open((BWidget)this.getTable(), bMouseEvent.getX(), bMouseEvent.getY());
}
}
class Selection
extends TableSelection {
Selection() {
}
public void updateTable() {
super.updateTable();
BBatchTable.this.editor.commands.updateCommands();
}
}
class Model
extends TableModel {
ArrayList cols = new ArrayList();
ArrayList kids = new ArrayList();
HashMap hash = new HashMap();
private Model() {
this.cols.add(BBatchTable.this.lex.getText("batchEditor.object"));
}
public int getColumnCount() {
return this.cols.size();
}
public String getColumnName(int n) {
return (String)this.cols.get(n);
}
public int getRowCount() {
return this.kids.size();
}
public Object getValueAt(int n, int n2) {
BComponent bComponent = (BComponent)this.kids.get(n);
if (n2 == 0) {
return SlotPath.unescape((String)bComponent.getSlotPath().getBody());
}
BValue bValue = bComponent.get((String)this.cols.get(n2));
return bValue == null ? "n/a" : String.valueOf(bValue);
}
public BImage getRowIcon(int n) {
BImage bImage = (BImage)this.hash.get(this.kids.get(n));
if (bImage == null) {
Object e = this.kids.get(n);
bImage = BImage.make((BIcon)((BObject)e).getIcon());
this.hash.put(e, bImage);
}
return bImage;
}
public String[] getAllColumns() {
return this.getAllColumns(true);
}
public String[] getAllColumns(boolean bl) {
ArrayList<String> arrayList = new ArrayList<String>();
for (int i = 0; i < this.kids.size(); ++i) {
ScriptField[] scriptFieldArray = ScriptUtil.scriptFields(this.kids.get(i));
for (int j = 0; j < scriptFieldArray.length; ++j) {
boolean bl2;
if (!scriptFieldArray[j].isProperty() || arrayList.contains(scriptFieldArray[j].scriptName()) || (scriptFieldArray[j].scriptFlags(this.kids.get(i)) & 1) != 0 || (scriptFieldArray[j].scriptType().getModifiers() & 0x400) != 0) continue;
boolean bl3 = bl2 = scriptFieldArray[j].isProperty() && ((PropertyField)scriptFieldArray[j]).getProperty().isFrozen();
if (!bl && (bl || bl2)) continue;
arrayList.add(scriptFieldArray[j].scriptName());
}
}
Object[] objectArray = arrayList.toArray(new String[arrayList.size()]);
Arrays.sort(objectArray);
return objectArray;
}
public Class getColumnType(String string) {
for (int i = 0; i < this.kids.size(); ++i) {
ScriptField[] scriptFieldArray = ScriptUtil.scriptFields(this.kids.get(i));
for (int j = 0; j < scriptFieldArray.length; ++j) {
if (!string.equals(scriptFieldArray[j].scriptName())) continue;
return scriptFieldArray[j].scriptType();
}
}
return null;
}
public BWbFieldEditor getColumnEditor(String string) {
for (int i = 0; i < this.kids.size(); ++i) {
ScriptField[] scriptFieldArray = ScriptUtil.scriptFields(this.kids.get(i));
for (int j = 0; j < scriptFieldArray.length; ++j) {
BWbFieldEditor bWbFieldEditor;
if (!string.equals(scriptFieldArray[j].scriptName())) continue;
Context context = null;
BObject bObject = null;
if (this.kids.get(i) instanceof BComponent && (bWbFieldEditor = ((BComponent)this.kids.get(i)).getSlot(scriptFieldArray[j].scriptName())) != null && bWbFieldEditor.isProperty()) {
context = bWbFieldEditor.asProperty().getFacets();
bObject = bWbFieldEditor.asProperty().getDefaultValue();
}
if (bObject == null) {
bObject = Sys.getType((Class)scriptFieldArray[j].scriptType()).getInstance();
}
if ((bWbFieldEditor = BWbFieldEditor.makeFor(bObject, context)) instanceof BPermissionsMapFE && (context == null || context.getFacets().isNull())) {
context = BBatchTable.this.editor.getCurrentContext();
}
bWbFieldEditor.loadValue(bObject, context);
return bWbFieldEditor;
}
}
return null;
}
public Model makeCopy() {
int n;
ArrayList<BComponent> arrayList = new ArrayList<BComponent>();
Model model = new Model();
for (n = 1; n < this.cols.size(); ++n) {
model.cols.add(this.cols.get(n));
}
for (n = 0; n < this.kids.size(); ++n) {
BComponent bComponent = (BComponent)this.kids.get(n);
if (!bComponent.isMounted()) continue;
arrayList.add(bComponent);
model.kids.add(bComponent);
}
BatchCommands.lease(arrayList.toArray(new BComponent[arrayList.size()]));
return model;
}
}
}
@@ -0,0 +1,84 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.ui.BOptionDialog
* javax.baja.sys.BValue
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BDialog
* javax.baja.ui.BLabel
* javax.baja.ui.BListDropDown
* javax.baja.ui.BNullWidget
* javax.baja.ui.BWidget
* javax.baja.ui.pane.BBorderPane
* javax.baja.ui.pane.BGridPane
* javax.baja.util.Lexicon
*/
package com.tridium.program.ui.batch;
import com.tridium.program.ui.batch.BBatchEditor;
import com.tridium.ui.BOptionDialog;
import javax.baja.sys.BValue;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BDialog;
import javax.baja.ui.BLabel;
import javax.baja.ui.BListDropDown;
import javax.baja.ui.BNullWidget;
import javax.baja.ui.BWidget;
import javax.baja.ui.pane.BBorderPane;
import javax.baja.ui.pane.BGridPane;
import javax.baja.util.Lexicon;
public class BRemoveDialog
extends BOptionDialog {
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$batch$BRemoveDialog == null ? (class$com$tridium$program$ui$batch$BRemoveDialog = BRemoveDialog.class$("com.tridium.program.ui.batch.BRemoveDialog")) : class$com$tridium$program$ui$batch$BRemoveDialog));
private static Lexicon lex = Lexicon.make((String)"program");
BListDropDown dropDown = new BListDropDown();
static /* synthetic */ Class class$com$tridium$program$ui$batch$BRemoveDialog;
public Type getType() {
return TYPE;
}
public static String open(BBatchEditor bBatchEditor) {
BRemoveDialog bRemoveDialog = new BRemoveDialog(bBatchEditor);
bRemoveDialog.setBoundsCenteredOnOwner();
bRemoveDialog.open();
if (bRemoveDialog.getResult() == 1) {
try {
String string = (String)bRemoveDialog.dropDown.getSelectedItem();
StringBuffer stringBuffer = new StringBuffer("remove(ord, ");
stringBuffer.append("\"").append(string).append("\", true, true);");
return stringBuffer.toString();
}
catch (Exception exception) {
BDialog.error((BWidget)bBatchEditor, (String)"Error", (Object)"Failed", (Throwable)exception);
}
}
return null;
}
private BRemoveDialog(BBatchEditor bBatchEditor) {
super((BWidget)bBatchEditor, lex.getText("batchEditor.commands.slotRemove.label"), (BWidget)new BNullWidget(), 3, null, null);
String[] stringArray = bBatchEditor.table.model.getAllColumns(false);
for (int i = 0; i < stringArray.length; ++i) {
this.dropDown.getList().addItem((Object)stringArray[i]);
}
BGridPane bGridPane = new BGridPane(2);
bGridPane.add(null, (BValue)new BLabel(lex.getText("batchEditor.property")));
bGridPane.add(null, (BValue)this.dropDown);
this.setContent((BWidget)new BBorderPane((BWidget)bGridPane, 10.0, 10.0, 10.0, 10.0));
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
}
@@ -0,0 +1,100 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.ui.BOptionDialog
* javax.baja.naming.SlotPath
* javax.baja.sys.BValue
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BCheckBox
* javax.baja.ui.BDialog
* javax.baja.ui.BLabel
* javax.baja.ui.BNullWidget
* javax.baja.ui.BTextField
* javax.baja.ui.BWidget
* javax.baja.ui.pane.BBorderPane
* javax.baja.ui.pane.BGridPane
* javax.baja.util.Lexicon
*/
package com.tridium.program.ui.batch;
import com.tridium.program.ui.batch.BBatchEditor;
import com.tridium.ui.BOptionDialog;
import javax.baja.naming.SlotPath;
import javax.baja.sys.BValue;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BCheckBox;
import javax.baja.ui.BDialog;
import javax.baja.ui.BLabel;
import javax.baja.ui.BNullWidget;
import javax.baja.ui.BTextField;
import javax.baja.ui.BWidget;
import javax.baja.ui.pane.BBorderPane;
import javax.baja.ui.pane.BGridPane;
import javax.baja.util.Lexicon;
public class BRenameDialog
extends BOptionDialog {
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$batch$BRenameDialog == null ? (class$com$tridium$program$ui$batch$BRenameDialog = BRenameDialog.class$("com.tridium.program.ui.batch.BRenameDialog")) : class$com$tridium$program$ui$batch$BRenameDialog));
private static Lexicon lex = Lexicon.make((String)"program");
private BTextField find = new BTextField("", 30);
private BTextField replace = new BTextField("", 30);
private BCheckBox matchCase = new BCheckBox(lex.getText("batchEditor.matchCase"));
private BCheckBox matchWord = new BCheckBox(lex.getText("batchEditor.matchWord"));
static /* synthetic */ Class class$com$tridium$program$ui$batch$BRenameDialog;
public Type getType() {
return TYPE;
}
public static String open(BBatchEditor bBatchEditor, boolean bl) {
BRenameDialog bRenameDialog = new BRenameDialog(bBatchEditor, bl);
bRenameDialog.setBoundsCenteredOnOwner();
bRenameDialog.open();
if (bRenameDialog.getResult() == 1) {
try {
String string = SlotPath.escape((String)bRenameDialog.find.getText());
String string2 = SlotPath.escape((String)bRenameDialog.replace.getText());
StringBuffer stringBuffer = new StringBuffer(bl ? "rename" : "componentRename");
stringBuffer.append("(ord, ");
stringBuffer.append("\"").append(string).append("\", ");
stringBuffer.append("\"").append(string2).append("\", ");
stringBuffer.append(bRenameDialog.matchCase.isSelected() ? "true" : "false").append(", ");
stringBuffer.append(bRenameDialog.matchWord.isSelected() ? "true" : "false").append(");");
return stringBuffer.toString();
}
catch (Exception exception) {
BDialog.error((BWidget)bBatchEditor, (String)"Error", (Object)"Failed", (Throwable)exception);
}
}
return null;
}
private BRenameDialog(BBatchEditor bBatchEditor, boolean bl) {
super((BWidget)bBatchEditor, lex.getText(bl ? "batchEditor.commands.slotRename.label" : "batchEditor.commands.rename.label"), (BWidget)new BNullWidget(), 3, null, null);
BGridPane bGridPane = new BGridPane(2);
bGridPane.add(null, (BValue)new BLabel(lex.getText("batchEditor.find")));
bGridPane.add(null, (BValue)this.find);
bGridPane.add(null, (BValue)new BLabel(lex.getText("batchEditor.replace")));
bGridPane.add(null, (BValue)this.replace);
BGridPane bGridPane2 = new BGridPane(1);
bGridPane2.add(null, (BValue)this.matchCase);
bGridPane2.add(null, (BValue)this.matchWord);
BGridPane bGridPane3 = new BGridPane(1);
bGridPane3.add(null, (BValue)bGridPane);
bGridPane3.add(null, (BValue)bGridPane2);
this.setContent((BWidget)new BBorderPane((BWidget)bGridPane3, 10.0, 10.0, 10.0, 10.0));
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
}
@@ -0,0 +1,177 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.ui.BOptionDialog
* com.tridium.ui.theme.Theme
* javax.baja.gx.BBrush
* javax.baja.io.ValueDocEncoder
* javax.baja.sys.Action
* javax.baja.sys.BComponent
* javax.baja.sys.BObject
* javax.baja.sys.BValue
* javax.baja.sys.Slot
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BCheckBox
* javax.baja.ui.BDialog
* javax.baja.ui.BLabel
* javax.baja.ui.BListDropDown
* javax.baja.ui.BNullWidget
* javax.baja.ui.BWidget
* javax.baja.ui.enums.BHalign
* javax.baja.ui.enums.BScrollBarPolicy
* javax.baja.ui.enums.BValign
* javax.baja.ui.pane.BBorderPane
* javax.baja.ui.pane.BEdgePane
* javax.baja.ui.pane.BGridPane
* javax.baja.ui.pane.BScrollPane
* javax.baja.util.Lexicon
* javax.baja.workbench.fieldeditor.BWbFieldEditor
*/
package com.tridium.program.ui.batch;
import com.tridium.program.ui.batch.BBatchEditor;
import com.tridium.ui.BOptionDialog;
import com.tridium.ui.theme.Theme;
import javax.baja.gx.BBrush;
import javax.baja.io.ValueDocEncoder;
import javax.baja.sys.Action;
import javax.baja.sys.BComponent;
import javax.baja.sys.BObject;
import javax.baja.sys.BValue;
import javax.baja.sys.Slot;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BCheckBox;
import javax.baja.ui.BDialog;
import javax.baja.ui.BLabel;
import javax.baja.ui.BListDropDown;
import javax.baja.ui.BNullWidget;
import javax.baja.ui.BWidget;
import javax.baja.ui.enums.BHalign;
import javax.baja.ui.enums.BScrollBarPolicy;
import javax.baja.ui.enums.BValign;
import javax.baja.ui.pane.BBorderPane;
import javax.baja.ui.pane.BEdgePane;
import javax.baja.ui.pane.BGridPane;
import javax.baja.ui.pane.BScrollPane;
import javax.baja.util.Lexicon;
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
public class BSetDialog
extends BOptionDialog {
public static final Action propertyChanged = BSetDialog.newAction((int)0, null, null);
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$batch$BSetDialog == null ? (class$com$tridium$program$ui$batch$BSetDialog = BSetDialog.class$("com.tridium.program.ui.batch.BSetDialog")) : class$com$tridium$program$ui$batch$BSetDialog));
private static Lexicon lex = Lexicon.make((String)"program");
private BBatchEditor parent;
private BListDropDown dropDown;
private BWbFieldEditor editor;
private BCheckBox add;
private BBorderPane content;
static /* synthetic */ Class class$com$tridium$program$ui$batch$BSetDialog;
public void propertyChanged() {
this.invoke(propertyChanged, null, null);
}
public Type getType() {
return TYPE;
}
public static String open(BBatchEditor bBatchEditor) {
BSetDialog bSetDialog = new BSetDialog(bBatchEditor);
bSetDialog.setBoundsCenteredOnOwner();
bSetDialog.open();
if (bSetDialog.getResult() == 1) {
try {
String string = (String)bSetDialog.dropDown.getList().getSelectedItem();
BValue bValue = (BValue)bSetDialog.editor.saveValue();
String string2 = ValueDocEncoder.marshal((BValue)bValue);
string2 = string2.replaceAll("\"", "'");
string2 = string2.replaceAll("\n", "");
StringBuffer stringBuffer = new StringBuffer("set(ord, ");
stringBuffer.append("\"").append(string).append("\", ");
stringBuffer.append("\"").append(bValue.getType().getTypeSpec()).append("\", ");
stringBuffer.append("\"").append(string2).append("\", true, true);");
return stringBuffer.toString();
}
catch (Exception exception) {
BDialog.error((BWidget)bBatchEditor, (String)"Error", (Object)"Failed", (Throwable)exception);
}
}
return null;
}
private BSetDialog(BBatchEditor bBatchEditor) {
super((BWidget)bBatchEditor, lex.getText("batchEditor.commands.slotEdit.label"), (BWidget)new BNullWidget(), 3, null, null);
this.parent = bBatchEditor;
this.editor = this.make(BComponent.TYPE);
this.add = new BCheckBox(lex.getText("batchEditor.addIfNotExist"));
this.add.setSelected(true);
this.dropDown = new BListDropDown();
String[] stringArray = bBatchEditor.table.model.getAllColumns();
for (int i = 0; i < stringArray.length; ++i) {
this.dropDown.getList().addItem((Object)stringArray[i]);
}
this.linkTo((BComponent)this.dropDown, (Slot)BListDropDown.listActionPerformed, (Slot)propertyChanged);
BGridPane bGridPane = new BGridPane(2);
bGridPane.setHalign(BHalign.left);
bGridPane.add(null, (BValue)new BLabel(lex.getText("batchEditor.property")));
bGridPane.add(null, (BValue)this.dropDown);
BGridPane bGridPane2 = new BGridPane(1);
bGridPane2.setValign(BValign.top);
bGridPane2.setHalign(BHalign.left);
this.content = new BBorderPane((BWidget)this.editor, 1.0, 1.0, 1.0, 1.0);
bGridPane2.add(null, (BValue)this.content);
BEdgePane bEdgePane = new BEdgePane();
bEdgePane.setTop((BWidget)new BBorderPane((BWidget)bGridPane, 0.0, 0.0, 10.0, 0.0));
BBrush bBrush = Theme.scrollPane().getControlBackground();
BScrollPane bScrollPane = new BScrollPane((BWidget)new BBorderPane((BWidget)bGridPane2, lex.getText("batchEditor.newValue")));
bScrollPane.setBorderPolicy(BScrollBarPolicy.asNeeded);
bScrollPane.setViewportBackground(bBrush);
bEdgePane.setCenter((BWidget)bScrollPane);
this.setContent((BWidget)new BBorderPane((BWidget)bEdgePane, 10.0, 10.0, 10.0, 10.0));
this.dropDown.getList().setSelectedIndex(0);
this.doPropertyChanged();
}
private BWbFieldEditor make(Type type) {
BObject bObject = type.getInstance();
BWbFieldEditor bWbFieldEditor = BWbFieldEditor.makeFor((BObject)bObject);
bWbFieldEditor.loadValue(bObject);
return bWbFieldEditor;
}
public void computePreferredSize() {
super.computePreferredSize();
double d = Math.max(500.0, this.getPreferredWidth());
double d2 = Math.max(300.0, this.getPreferredHeight());
this.setPreferredSize(d, d2);
}
public void doPropertyChanged() {
try {
String string = (String)this.dropDown.getList().getSelectedItem();
this.editor = this.parent.table.model.getColumnEditor(string);
this.content.setContent((BWidget)this.editor);
this.editor.loadValue(this.editor.getCurrentValue(), this.editor.getCurrentContext());
this.computePreferredSize();
this.setSize(this.getPreferredWidth(), this.getPreferredHeight());
this.setBoundsCenteredOnOwner();
}
catch (Exception exception) {
exception.printStackTrace();
}
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
}
@@ -0,0 +1,333 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.ui.BOptionDialog
* com.tridium.workbench.util.BFlagConfig
* javax.baja.sys.Action
* javax.baja.sys.BComponent
* javax.baja.sys.BIPropertyContainer
* javax.baja.sys.BValue
* javax.baja.sys.Flags
* javax.baja.sys.Flags$Flag
* javax.baja.sys.Property
* javax.baja.sys.Slot
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BCheckBox
* javax.baja.ui.BDialog
* javax.baja.ui.BLabel
* javax.baja.ui.BListDropDown
* javax.baja.ui.BNullWidget
* javax.baja.ui.BRadioButton
* javax.baja.ui.BWidget
* javax.baja.ui.CommandArtifact
* javax.baja.ui.ToggleCommand
* javax.baja.ui.ToggleCommandGroup
* javax.baja.ui.enums.BHalign
* javax.baja.ui.pane.BBorderPane
* javax.baja.ui.pane.BGridPane
* javax.baja.util.Lexicon
*/
package com.tridium.program.ui.batch;
import com.tridium.program.ui.batch.BBatchEditor;
import com.tridium.ui.BOptionDialog;
import com.tridium.workbench.util.BFlagConfig;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;
import javax.baja.sys.Action;
import javax.baja.sys.BComponent;
import javax.baja.sys.BIPropertyContainer;
import javax.baja.sys.BValue;
import javax.baja.sys.Flags;
import javax.baja.sys.Property;
import javax.baja.sys.Slot;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BCheckBox;
import javax.baja.ui.BDialog;
import javax.baja.ui.BLabel;
import javax.baja.ui.BListDropDown;
import javax.baja.ui.BNullWidget;
import javax.baja.ui.BRadioButton;
import javax.baja.ui.BWidget;
import javax.baja.ui.CommandArtifact;
import javax.baja.ui.ToggleCommand;
import javax.baja.ui.ToggleCommandGroup;
import javax.baja.ui.enums.BHalign;
import javax.baja.ui.pane.BBorderPane;
import javax.baja.ui.pane.BGridPane;
import javax.baja.util.Lexicon;
public class BSetFlagsDialog
extends BOptionDialog {
public static final Action propertyChanged = BSetFlagsDialog.newAction((int)0, null, null);
public static final Action useSelectionChanged = BSetFlagsDialog.newAction((int)0, null, null);
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$batch$BSetFlagsDialog == null ? (class$com$tridium$program$ui$batch$BSetFlagsDialog = BSetFlagsDialog.class$("com.tridium.program.ui.batch.BSetFlagsDialog")) : class$com$tridium$program$ui$batch$BSetFlagsDialog));
private static Lexicon lex = Lexicon.make((String)"program");
private static final FlagWrapper[] FLAGS;
private static final Object USE_SELECTED_COMPONENTS;
private BBatchEditor parent;
private BListDropDown dropDown;
private BListDropDown flagDropDown;
private BCheckBox useSelection = new BCheckBox(lex.getText("batchEditor.setFlagsOnSelectedObjects"));
private SetFlag setFlag;
private RemoveFlag removeFlag;
private Hashtable validFlags;
static /* synthetic */ Class class$com$tridium$program$ui$batch$BSetFlagsDialog;
public void propertyChanged() {
this.invoke(propertyChanged, null, null);
}
public void useSelectionChanged() {
this.invoke(useSelectionChanged, null, null);
}
public Type getType() {
return TYPE;
}
public static String open(BBatchEditor bBatchEditor) {
BSetFlagsDialog bSetFlagsDialog = new BSetFlagsDialog(bBatchEditor);
bSetFlagsDialog.setBoundsCenteredOnOwner();
bSetFlagsDialog.open();
if (bSetFlagsDialog.getResult() == 1) {
try {
boolean bl = bSetFlagsDialog.useSelection.isSelected();
String string = bl ? "null" : (String)bSetFlagsDialog.dropDown.getList().getSelectedItem();
int n = ((FlagWrapper)bSetFlagsDialog.flagDropDown.getList().getSelectedItem()).flag.getMask();
boolean bl2 = bSetFlagsDialog.setFlag.isSelected();
StringBuffer stringBuffer = new StringBuffer("setFlag(ord, ");
stringBuffer.append("\"").append(string).append("\", ").append(n);
stringBuffer.append(bl ? ", true" : ", false");
stringBuffer.append(bl2 ? ", true);" : ", false);");
return stringBuffer.toString();
}
catch (Exception exception) {
BDialog.error((BWidget)bBatchEditor, (String)"Error", (Object)"Failed", (Throwable)exception);
}
}
return null;
}
private BSetFlagsDialog(BBatchEditor bBatchEditor) {
super((BWidget)bBatchEditor, lex.getText("batchEditor.commands.slotFlags.label"), (BWidget)new BNullWidget(), 3, null, null);
Object object;
Object object2;
Object object3;
this.useSelection.setSelected(false);
this.linkTo((BComponent)this.useSelection, (Slot)BCheckBox.actionPerformed, (Slot)useSelectionChanged);
int n = bBatchEditor.table.model.kids.size();
this.validFlags = new Hashtable();
String string = null;
for (int i = 0; i < n; ++i) {
Object object4;
Slot slot;
Property property;
object3 = (BComponent)bBatchEditor.table.model.kids.get(i);
object2 = object3.getParent();
if (object2 instanceof BComponent && (property = object3.getPropertyInParent()) != null) {
int n2;
slot = new BFlagConfig((BIPropertyContainer)((BComponent)object2), new Slot[]{property});
object4 = (boolean[])this.validFlags.get(USE_SELECTED_COMPONENTS);
if (object4 == null) {
object4 = new boolean[FLAGS.length];
for (n2 = 0; n2 < FLAGS.length; ++n2) {
object4[n2] = slot.isEnabled(BSetFlagsDialog.FLAGS[n2].flag);
}
} else {
for (n2 = 0; n2 < FLAGS.length; ++n2) {
object4[n2] = object4[n2] != false && slot.isEnabled(BSetFlagsDialog.FLAGS[n2].flag);
}
}
this.validFlags.put(USE_SELECTED_COMPONENTS, object4);
}
property = object3.getSlots();
while (property.next()) {
int n3;
slot = property.slot();
object4 = slot.getName();
if (string == null) {
string = object4;
}
BFlagConfig bFlagConfig = new BFlagConfig((BIPropertyContainer)object3, new Slot[]{slot});
object = (boolean[])this.validFlags.get(object4);
if (object == null) {
object = new boolean[FLAGS.length];
for (n3 = 0; n3 < FLAGS.length; ++n3) {
object[n3] = bFlagConfig.isEnabled(BSetFlagsDialog.FLAGS[n3].flag);
}
} else {
for (n3 = 0; n3 < FLAGS.length; ++n3) {
object[n3] = object[n3] && bFlagConfig.isEnabled(BSetFlagsDialog.FLAGS[n3].flag);
}
}
this.validFlags.put(object4, object);
}
}
this.dropDown = new BListDropDown();
ArrayList<String> arrayList = new ArrayList<String>();
object3 = this.validFlags.keys();
while (object3.hasMoreElements()) {
object2 = object3.nextElement();
if (object2 == USE_SELECTED_COMPONENTS) continue;
arrayList.add((String)object2);
}
object2 = arrayList.toArray(new String[arrayList.size()]);
Arrays.sort((Object[])object2);
for (int i = 0; i < ((Object[])object2).length; ++i) {
this.dropDown.getList().addItem(object2[i]);
}
if (((Object[])object2).length > 0) {
this.dropDown.getList().setSelectedIndex(0);
}
this.linkTo((BComponent)this.dropDown, (Slot)BListDropDown.listActionPerformed, (Slot)propertyChanged);
this.flagDropDown = new BListDropDown();
if (string != null) {
boolean[] blArray = (boolean[])this.validFlags.get(string);
boolean bl = false;
for (int i = 0; i < FLAGS.length; ++i) {
if (!blArray[i]) continue;
this.flagDropDown.getList().addItem((Object)FLAGS[i]);
bl = true;
}
if (bl) {
this.flagDropDown.getList().setSelectedIndex(0);
}
}
BGridPane bGridPane = new BGridPane(1);
bGridPane.setHalign(BHalign.left);
bGridPane.add(null, (BValue)this.useSelection);
BGridPane bGridPane2 = new BGridPane(2);
bGridPane2.setHalign(BHalign.left);
bGridPane2.add(null, (BValue)new BLabel(lex.getText("batchEditor.slot")));
bGridPane2.add(null, (BValue)this.dropDown);
bGridPane2.add(null, (BValue)new BLabel(lex.getText("batchEditor.flag")));
bGridPane2.add(null, (BValue)this.flagDropDown);
ToggleCommandGroup toggleCommandGroup = new ToggleCommandGroup();
this.setFlag = new SetFlag((BWidget)this);
toggleCommandGroup.add((ToggleCommand)this.setFlag);
this.removeFlag = new RemoveFlag((BWidget)this);
toggleCommandGroup.add((ToggleCommand)this.removeFlag);
this.setFlag.setSelected(true);
BGridPane bGridPane3 = new BGridPane(2);
bGridPane3.setHalign(BHalign.left);
bGridPane3.add(null, (BValue)new BRadioButton((ToggleCommand)this.setFlag));
bGridPane3.add(null, (BValue)new BRadioButton((ToggleCommand)this.removeFlag));
object = new BGridPane(1);
object.setHalign(BHalign.left);
object.add(null, (BValue)bGridPane);
object.add(null, (BValue)bGridPane2);
object.add(null, (BValue)bGridPane3);
this.setContent((BWidget)new BBorderPane((BWidget)object, 10.0, 10.0, 10.0, 10.0));
}
public void doPropertyChanged() {
try {
String string = (String)this.dropDown.getList().getSelectedItem();
if (string == null) {
this.flagDropDown.getList().removeAllItems();
this.flagDropDown.getList().setSelectedIndex(0);
return;
}
boolean[] blArray = (boolean[])this.validFlags.get(string);
Object object = this.flagDropDown.getSelectedItem();
FlagWrapper flagWrapper = null;
this.flagDropDown.getList().removeAllItems();
for (int i = 0; i < FLAGS.length; ++i) {
if (!blArray[i]) continue;
this.flagDropDown.getList().addItem((Object)FLAGS[i]);
if (FLAGS[i] != object) continue;
flagWrapper = FLAGS[i];
}
if (flagWrapper != null) {
this.flagDropDown.getList().setSelectedItem(flagWrapper);
} else {
this.flagDropDown.getList().setSelectedIndex(0);
}
}
catch (Exception exception) {
exception.printStackTrace();
}
}
public void doUseSelectionChanged() {
boolean bl = !this.useSelection.isSelected();
this.dropDown.setEnabled(bl);
if (!bl) {
boolean[] blArray = (boolean[])this.validFlags.get(USE_SELECTED_COMPONENTS);
Object object = this.flagDropDown.getSelectedItem();
FlagWrapper flagWrapper = null;
this.flagDropDown.getList().removeAllItems();
for (int i = 0; i < FLAGS.length; ++i) {
if (!blArray[i]) continue;
this.flagDropDown.getList().addItem((Object)FLAGS[i]);
if (FLAGS[i] != object) continue;
flagWrapper = FLAGS[i];
}
if (flagWrapper != null) {
this.flagDropDown.getList().setSelectedItem(flagWrapper);
} else {
this.flagDropDown.getList().setSelectedIndex(0);
}
} else {
this.doPropertyChanged();
}
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
static {
Flags.Flag[] flagArray = Flags.getFlags();
FLAGS = new FlagWrapper[flagArray.length];
for (int i = 0; i < flagArray.length; ++i) {
BSetFlagsDialog.FLAGS[i] = new FlagWrapper(flagArray[i]);
}
USE_SELECTED_COMPONENTS = new Object();
}
static class RemoveFlag
extends ToggleCommand {
RemoveFlag(BWidget bWidget) {
super(bWidget, lex.getText("batchEditor.removeFlag"));
}
public CommandArtifact doInvoke() {
return null;
}
}
static class SetFlag
extends ToggleCommand {
SetFlag(BWidget bWidget) {
super(bWidget, lex.getText("batchEditor.setFlag"));
}
public CommandArtifact doInvoke() {
return null;
}
}
static class FlagWrapper {
Flags.Flag flag;
public FlagWrapper(Flags.Flag flag) {
this.flag = flag;
}
public String toString() {
return this.flag.getDisplayName(null);
}
}
}
@@ -0,0 +1,441 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.bql.BSelect
* com.tridium.bql.SelectQuery
* com.tridium.bql.expression.BPath
* com.tridium.workbench.bql.builder.BBqlQueryBuilder
* javax.baja.collection.BICollection
* javax.baja.collection.BITable
* javax.baja.collection.ColumnList
* javax.baja.gx.BInsets
* javax.baja.naming.BOrd
* javax.baja.naming.OrdQuery
* javax.baja.query.BExpression
* javax.baja.query.BProjectionColumn
* javax.baja.query.util.Columns
* javax.baja.sys.BComponent
* javax.baja.sys.BModule
* javax.baja.sys.BObject
* javax.baja.sys.BValue
* javax.baja.sys.Sys
* javax.baja.ui.BBorder
* javax.baja.ui.BDialog
* javax.baja.ui.BMenu
* javax.baja.ui.BSeparator
* javax.baja.ui.BWidget
* javax.baja.ui.Command
* javax.baja.ui.CommandArtifact
* javax.baja.ui.commands.PasteCommand
* javax.baja.ui.list.BCheckList
* javax.baja.ui.pane.BBorderPane
* javax.baja.ui.pane.BConstrainedPane
* javax.baja.ui.transfer.BTransferWidget
* javax.baja.util.Lexicon
*/
package com.tridium.program.ui.batch;
import com.tridium.bql.BSelect;
import com.tridium.bql.SelectQuery;
import com.tridium.bql.expression.BPath;
import com.tridium.program.ui.batch.BAddDialog;
import com.tridium.program.ui.batch.BBatchEditor;
import com.tridium.program.ui.batch.BBatchTable;
import com.tridium.program.ui.batch.BRemoveDialog;
import com.tridium.program.ui.batch.BRenameDialog;
import com.tridium.program.ui.batch.BSetDialog;
import com.tridium.program.ui.batch.BSetFlagsDialog;
import com.tridium.program.ui.batch.BatchCompiler;
import com.tridium.workbench.bql.builder.BBqlQueryBuilder;
import java.util.ArrayList;
import javax.baja.collection.BICollection;
import javax.baja.collection.BITable;
import javax.baja.collection.ColumnList;
import javax.baja.gx.BInsets;
import javax.baja.naming.BOrd;
import javax.baja.naming.OrdQuery;
import javax.baja.query.BExpression;
import javax.baja.query.BProjectionColumn;
import javax.baja.query.util.Columns;
import javax.baja.sys.BComponent;
import javax.baja.sys.BModule;
import javax.baja.sys.BObject;
import javax.baja.sys.BValue;
import javax.baja.sys.Sys;
import javax.baja.ui.BBorder;
import javax.baja.ui.BDialog;
import javax.baja.ui.BMenu;
import javax.baja.ui.BSeparator;
import javax.baja.ui.BWidget;
import javax.baja.ui.Command;
import javax.baja.ui.CommandArtifact;
import javax.baja.ui.commands.PasteCommand;
import javax.baja.ui.list.BCheckList;
import javax.baja.ui.pane.BBorderPane;
import javax.baja.ui.pane.BConstrainedPane;
import javax.baja.ui.transfer.BTransferWidget;
import javax.baja.util.Lexicon;
public class BatchCommands {
private static BModule module = Sys.getModuleForClass((Class)(class$com$tridium$program$ui$batch$BBatchEditor == null ? (class$com$tridium$program$ui$batch$BBatchEditor = BatchCommands.class$("com.tridium.program.ui.batch.BBatchEditor")) : class$com$tridium$program$ui$batch$BBatchEditor));
private static Lexicon lex = Lexicon.make((String)"program");
private BBatchEditor editor;
private BBqlQueryBuilder builder;
FindObjects findObjects;
Clear clear;
ClearAll clearAll;
SelectColumns selectCols;
Rename rename;
SlotAdd slotAdd;
SlotEdit slotEdit;
SlotRename slotRename;
SlotRemove slotRemove;
SlotFlags slotFlags;
Hyperlink hyperlink;
static /* synthetic */ Class class$com$tridium$program$ui$batch$BBatchEditor;
public BatchCommands(BBatchEditor bBatchEditor) {
this.editor = bBatchEditor;
this.findObjects = new FindObjects();
this.clear = new Clear();
this.clearAll = new ClearAll();
this.selectCols = new SelectColumns();
this.rename = new Rename();
this.slotAdd = new SlotAdd();
this.slotEdit = new SlotEdit();
this.slotRename = new SlotRename();
this.slotRemove = new SlotRemove();
this.slotFlags = new SlotFlags();
this.hyperlink = new Hyperlink();
}
public void updateCommands() {
boolean bl = this.editor.table.getModel().getRowCount() > 0;
boolean bl2 = this.editor.table.getSelection().getRows().length > 0;
boolean bl3 = this.editor.table.getSelection().getRows().length == 1;
this.clear.setEnabled(bl && bl2);
this.clearAll.setEnabled(bl);
this.selectCols.setEnabled(bl);
this.rename.setEnabled(bl);
this.slotAdd.setEnabled(bl);
this.slotEdit.setEnabled(bl);
this.slotRename.setEnabled(bl);
this.slotRemove.setEnabled(bl);
this.slotFlags.setEnabled(bl);
this.hyperlink.setEnabled(bl && bl3);
}
public BMenu buildMenu() {
BMenu bMenu = new BMenu(lex.getText("batchEditor"));
bMenu.add(null, (Command)this.findObjects);
bMenu.add(null, (Command)this.clear);
bMenu.add(null, (Command)this.clearAll);
bMenu.add(null, (Command)this.selectCols);
bMenu.add(null, (BValue)new BSeparator());
bMenu.add(null, (Command)new PasteCommand((BTransferWidget)this.editor.table));
bMenu.add(null, (BValue)new BSeparator());
bMenu.add(null, (Command)this.rename);
bMenu.add(null, (Command)this.slotAdd);
bMenu.add(null, (Command)this.slotEdit);
bMenu.add(null, (Command)this.slotRename);
bMenu.add(null, (Command)this.slotRemove);
bMenu.add(null, (Command)this.slotFlags);
bMenu.add(null, (BValue)new BSeparator());
bMenu.add(null, (Command)this.hyperlink);
return bMenu;
}
static void lease(BComponent[] bComponentArray) {
try {
BComponent.lease((BComponent[])bComponentArray, (int)0, (long)60000L);
}
catch (Throwable throwable) {
System.out.println("Error leasing Components...");
throwable.printStackTrace();
for (int i = 0; i < bComponentArray.length; ++i) {
try {
bComponentArray[i].lease(0, 60000L);
continue;
}
catch (Throwable throwable2) {
// empty catch block
}
}
}
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
class Hyperlink
extends BatchCommand {
public Hyperlink() {
super("hyperlink");
}
public CommandArtifact doInvoke() {
int[] nArray = ((BatchCommands)BatchCommands.this).editor.table.getSelection().getRows();
BComponent bComponent = (BComponent)((BatchCommands)BatchCommands.this).editor.table.model.kids.get(nArray[0]);
BOrd bOrd = BOrd.make((String)("station:|" + bComponent.getSlotPath()));
BatchCommands.this.editor.getWbShell().hyperlink(bOrd);
return null;
}
}
class SlotFlags
extends BatchCommand {
public SlotFlags() {
super("slotFlags");
}
public CommandArtifact doInvoke() {
String string = BSetFlagsDialog.open(BatchCommands.this.editor);
if (string != null) {
try {
BatchCompiler batchCompiler = new BatchCompiler(BatchCommands.this.editor, string);
batchCompiler.compile();
}
catch (Exception exception) {
BDialog.error((BWidget)BatchCommands.this.editor, (String)"Error", (Object)"Commit Failed", (Throwable)exception);
}
}
return null;
}
}
class SlotRemove
extends BatchCommand {
public SlotRemove() {
super("slotRemove");
}
public CommandArtifact doInvoke() {
String string = BRemoveDialog.open(BatchCommands.this.editor);
if (string != null) {
try {
BatchCompiler batchCompiler = new BatchCompiler(BatchCommands.this.editor, string);
batchCompiler.compile();
}
catch (Exception exception) {
BDialog.error((BWidget)BatchCommands.this.editor, (String)"Error", (Object)"Commit Failed", (Throwable)exception);
}
}
return null;
}
}
class SlotRename
extends BatchCommand {
public SlotRename() {
super("slotRename");
}
public CommandArtifact doInvoke() {
String string = BRenameDialog.open(BatchCommands.this.editor, true);
if (string != null) {
try {
BatchCompiler batchCompiler = new BatchCompiler(BatchCommands.this.editor, string);
batchCompiler.compile();
}
catch (Exception exception) {
BDialog.error((BWidget)BatchCommands.this.editor, (String)"Error", (Object)"Commit Failed", (Throwable)exception);
}
}
return null;
}
}
class SlotEdit
extends BatchCommand {
public SlotEdit() {
super("slotEdit");
}
public CommandArtifact doInvoke() {
String string = BSetDialog.open(BatchCommands.this.editor);
if (string != null) {
try {
BatchCompiler batchCompiler = new BatchCompiler(BatchCommands.this.editor, string);
batchCompiler.compile();
}
catch (Exception exception) {
BDialog.error((BWidget)BatchCommands.this.editor, (String)"Error", (Object)"Commit Failed", (Throwable)exception);
}
}
return null;
}
}
class SlotAdd
extends BatchCommand {
public SlotAdd() {
super("slotAdd");
}
public CommandArtifact doInvoke() {
String string = BAddDialog.open(BatchCommands.this.editor);
if (string != null) {
try {
BatchCompiler batchCompiler = new BatchCompiler(BatchCommands.this.editor, string);
batchCompiler.compile();
}
catch (Exception exception) {
BDialog.error((BWidget)BatchCommands.this.editor, (String)"Error", (Object)"Commit Failed", (Throwable)exception);
}
}
return null;
}
}
class Rename
extends BatchCommand {
public Rename() {
super("rename");
}
public CommandArtifact doInvoke() {
String string = BRenameDialog.open(BatchCommands.this.editor, false);
if (string != null) {
try {
BatchCompiler batchCompiler = new BatchCompiler(BatchCommands.this.editor, string);
batchCompiler.compile();
}
catch (Exception exception) {
BDialog.error((BWidget)BatchCommands.this.editor, (String)"Error", (Object)"Commit Failed", (Throwable)exception);
}
}
return null;
}
}
class SelectColumns
extends BatchCommand {
public SelectColumns() {
super("selectColumns");
}
public CommandArtifact doInvoke() {
int n;
BBatchTable.Model model = ((BatchCommands)BatchCommands.this).editor.table.model;
BCheckList bCheckList = new BCheckList();
String[] stringArray = model.getAllColumns();
for (n = 0; n < stringArray.length; ++n) {
bCheckList.getModel().addItem((Object)stringArray[n]);
}
for (n = 1; n < model.cols.size(); ++n) {
int n2 = bCheckList.indexOfItem(model.cols.get(n));
if (n2 < 0) continue;
bCheckList.getSelection().select(n2);
}
BConstrainedPane bConstrainedPane = new BConstrainedPane((BWidget)new BBorderPane((BWidget)bCheckList, BBorder.inset, BInsets.make((double)0.0, (double)0.0, (double)0.0, (double)0.0)));
bConstrainedPane.setMinWidth(300.0);
bConstrainedPane.setMaxWidth(300.0);
bConstrainedPane.setMinHeight(300.0);
bConstrainedPane.setMaxHeight(400.0);
if (1 == BDialog.open((BWidget)BatchCommands.this.editor, (String)lex.getText("batchEditor.commands.selectColumns.label"), (Object)bConstrainedPane, (int)3)) {
String string = (String)((BatchCommands)BatchCommands.this).editor.table.model.cols.get(0);
model.cols.clear();
model.cols.add(string);
int[] nArray = bCheckList.getSelection().getItems();
for (int i = 0; i < nArray.length; ++i) {
model.cols.add(bCheckList.getItem(nArray[i]));
}
((BatchCommands)BatchCommands.this).editor.table.sizeColumnsToFit();
((BatchCommands)BatchCommands.this).editor.table.relayout();
}
return null;
}
}
class ClearAll
extends BatchCommand {
public ClearAll() {
super("clearAll");
}
public CommandArtifact doInvoke() {
while (!((BatchCommands)BatchCommands.this).editor.table.model.kids.isEmpty()) {
((BatchCommands)BatchCommands.this).editor.table.model.kids.remove(0);
}
BatchCommands.this.updateCommands();
return null;
}
}
class Clear
extends BatchCommand {
public Clear() {
super("clear");
}
public CommandArtifact doInvoke() {
int[] nArray = ((BatchCommands)BatchCommands.this).editor.table.getSelection().getRows();
((BatchCommands)BatchCommands.this).editor.table.getSelection().deselectAll();
for (int i = 0; i < nArray.length; ++i) {
((BatchCommands)BatchCommands.this).editor.table.getSelection().deselectAll();
((BatchCommands)BatchCommands.this).editor.table.model.kids.remove(nArray[i] - i);
}
BatchCommands.this.updateCommands();
return null;
}
}
class FindObjects
extends BatchCommand {
public FindObjects() {
super("findObjects");
}
public CommandArtifact doInvoke() {
BOrd bOrd;
if (BatchCommands.this.builder == null) {
BatchCommands.this.builder = new BBqlQueryBuilder((BObject)((BatchCommands)BatchCommands.this).editor.service, BOrd.NULL, false);
}
if ((bOrd = BatchCommands.this.builder.open((BWidget)BatchCommands.this.editor)) != null && !bOrd.isNull()) {
OrdQuery[] ordQueryArray = bOrd.parse();
SelectQuery selectQuery = (SelectQuery)ordQueryArray[ordQueryArray.length - 1];
BSelect bSelect = selectQuery.getSelect();
BPath bPath = new BPath("toPathString");
if (bSelect.hasProjection() && bSelect.getProjection().isDistinct()) {
bSelect.select(Columns.distinctProjection().add(Columns.make((BExpression)bPath)));
} else {
bSelect.select(Columns.projection((BProjectionColumn)Columns.make((BExpression)bPath)));
}
ordQueryArray[ordQueryArray.length - 1] = new SelectQuery(bSelect);
bOrd = BOrd.make((OrdQuery[])ordQueryArray);
BICollection bICollection = (BICollection)bOrd.resolve((BObject)((BatchCommands)BatchCommands.this).editor.service).get();
BITable bITable = bICollection.toTable();
ColumnList columnList = bITable.getColumns();
ArrayList<BObject> arrayList = new ArrayList<BObject>();
for (int i = 0; i < bITable.size(); ++i) {
BOrd bOrd2 = BOrd.make((String)("station:|slot:" + bITable.get(i, columnList.get(0))));
bOrd2 = BOrd.make((BOrd)BatchCommands.this.editor.getWbShell().getActiveOrd(), (BOrd)bOrd2).normalize();
BObject bObject = bOrd2.resolve().get();
if (!(bObject instanceof BComponent) || ((BatchCommands)BatchCommands.this).editor.table.model.kids.contains(bObject)) continue;
arrayList.add(bObject);
((BatchCommands)BatchCommands.this).editor.table.model.kids.add(bObject);
}
BatchCommands.lease(arrayList.toArray(new BComponent[arrayList.size()]));
((BatchCommands)BatchCommands.this).editor.table.sizeColumnsToFit();
((BatchCommands)BatchCommands.this).editor.table.relayout();
BatchCommands.this.updateCommands();
}
return null;
}
}
abstract class BatchCommand
extends Command {
public BatchCommand(String string) {
super((BWidget)BatchCommands.this.editor, module, "batchEditor.commands." + string);
}
}
}
@@ -0,0 +1,81 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.workbench.console.BConsole
* com.tridium.workbench.shell.BNiagaraWbShell
* javax.baja.sys.BComponent
* javax.baja.ui.BDialog
* javax.baja.ui.BWidget
* javax.baja.ui.pane.BTextEditorPane
* javax.baja.ui.text.BTextEditor
*/
package com.tridium.program.ui.batch;
import com.tridium.program.BCode;
import com.tridium.program.BRobotCode;
import com.tridium.program.BRobotResult;
import com.tridium.program.ui.Compiler;
import com.tridium.program.ui.batch.BBatchEditor;
import com.tridium.workbench.console.BConsole;
import com.tridium.workbench.shell.BNiagaraWbShell;
import javax.baja.sys.BComponent;
import javax.baja.ui.BDialog;
import javax.baja.ui.BWidget;
import javax.baja.ui.pane.BTextEditorPane;
import javax.baja.ui.text.BTextEditor;
class BatchCompiler
extends Compiler {
private BBatchEditor editor;
private String method;
private BRobotCode code = new BRobotCode();
String source;
BatchCompiler(BBatchEditor bBatchEditor, String string) {
super((BWidget)bBatchEditor);
this.editor = bBatchEditor;
this.method = string;
}
public void generateCode(String string) throws Exception {
String string2 = "import java.util.*;\nimport javax.baja.data.*;\nimport javax.baja.io.*;\nimport javax.baja.naming.*;\nimport javax.baja.sys.*;\nimport javax.baja.util.*;\nimport com.tridium.program.*;\nimport com.tridium.program.ui.batch.*;\n\npublic class " + string + "\n" + " extends BatchRobot\n" + "{\n" + "\n" + " public void run()\n" + " throws Exception\n" + " {\n" + " for (int i=0; i<ords.length; i++)\n" + " {\n" + " BOrd ord = BOrd.make(ords[i]);\n";
string2 = string2 + this.method + "\n";
string2 = string2 + " }\n }\n\n String[] ords = {\n";
int n = this.editor.table.model.getRowCount();
for (int i = 0; i < n; ++i) {
BComponent bComponent = (BComponent)this.editor.table.model.kids.get(i);
string2 = string2 + " \"station:|slot:" + bComponent.getSlotPath().getBody() + "\"";
if (i < n - 1) {
string2 = string2 + ",";
}
string2 = string2 + "\n";
}
this.source = string2 = string2 + " };\n}\n";
}
public void compile() throws Exception {
String string = BCode.generateClassName();
this.generateCode(string);
this.code.setDependencies("baja;program");
this.compile(string, this.code, this.source);
}
public BConsole openConsole() {
return ((BNiagaraWbShell)this.editor.getShell()).getConsole();
}
public void compileSuccess(BConsole bConsole) throws Exception {
super.compileSuccess(bConsole);
this.run();
}
public void run() {
BRobotResult bRobotResult = this.editor.service.runRobot(this.code);
this.editor.table.refresh();
BTextEditor bTextEditor = new BTextEditor(bRobotResult.getLog(), false);
BTextEditorPane bTextEditorPane = new BTextEditorPane(bTextEditor, 20, 100);
BDialog.open((BWidget)this.editor, (String)"BatchEditor Results", (Object)bTextEditorPane, (int)1);
}
}