link start!
This commit is contained in:
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import com.ice.tar.InvalidHeaderException;
|
||||
import com.ice.tar.TarEntry;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class FastTarStream {
|
||||
private boolean debug;
|
||||
private boolean hasHitEOF;
|
||||
private TarEntry currEntry;
|
||||
private InputStream inStream;
|
||||
private int recordSize;
|
||||
|
||||
public void setDebug(boolean bl) {
|
||||
this.debug = bl;
|
||||
}
|
||||
|
||||
public TarEntry getNextEntry() throws IOException {
|
||||
int n;
|
||||
int n2;
|
||||
if (this.hasHitEOF) {
|
||||
return null;
|
||||
}
|
||||
if (this.currEntry != null && this.currEntry.getSize() > 0L && (n2 = ((int)this.currEntry.getSize() + (this.recordSize - 1)) / this.recordSize) > 0) {
|
||||
this.inStream.skip(n2 * this.recordSize);
|
||||
}
|
||||
byte[] byArray = new byte[this.recordSize];
|
||||
int n3 = 0;
|
||||
int n4 = this.recordSize;
|
||||
while (n4 > 0) {
|
||||
n = this.inStream.read(byArray, n3, n4);
|
||||
if (n == -1) {
|
||||
this.hasHitEOF = true;
|
||||
break;
|
||||
}
|
||||
n3 += n;
|
||||
n4 -= n;
|
||||
}
|
||||
if (!this.hasHitEOF) {
|
||||
this.hasHitEOF = true;
|
||||
n4 = 0;
|
||||
while (n4 < byArray.length) {
|
||||
if (byArray[n4] != 0) {
|
||||
this.hasHitEOF = false;
|
||||
break;
|
||||
}
|
||||
++n4;
|
||||
}
|
||||
}
|
||||
if (this.hasHitEOF) {
|
||||
this.currEntry = null;
|
||||
} else {
|
||||
try {
|
||||
this.currEntry = new TarEntry(byArray);
|
||||
if (this.debug) {
|
||||
byte[] byArray2 = new byte[byArray.length];
|
||||
n = 0;
|
||||
while (n < byArray.length) {
|
||||
byArray2[n] = byArray[n] == 0 ? 20 : byArray[n];
|
||||
++n;
|
||||
}
|
||||
String string = new String(byArray2);
|
||||
System.out.println("\n" + string);
|
||||
}
|
||||
if (byArray[257] != 117 || byArray[258] != 115 || byArray[259] != 116 || byArray[260] != 97 || byArray[261] != 114) {
|
||||
throw new InvalidHeaderException("header magic is not'ustar', but '" + byArray[257] + byArray[258] + byArray[259] + byArray[260] + byArray[261] + "', or (dec) " + byArray[257] + ", " + byArray[258] + ", " + byArray[259] + ", " + byArray[260] + ", " + byArray[261]);
|
||||
}
|
||||
}
|
||||
catch (InvalidHeaderException invalidHeaderException) {
|
||||
this.currEntry = null;
|
||||
throw invalidHeaderException;
|
||||
}
|
||||
}
|
||||
return this.currEntry;
|
||||
}
|
||||
|
||||
public static void main(String[] stringArray) {
|
||||
boolean bl = false;
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
TarEntry tarEntry;
|
||||
int n = 0;
|
||||
if (stringArray.length > 0) {
|
||||
if (stringArray[n].equals("-d")) {
|
||||
bl = true;
|
||||
++n;
|
||||
}
|
||||
inputStream = stringArray[n].endsWith(".gz") || stringArray[n].endsWith(".tgz") ? new GZIPInputStream(new FileInputStream(stringArray[n])) : new FileInputStream(stringArray[n]);
|
||||
} else {
|
||||
inputStream = System.in;
|
||||
}
|
||||
FastTarStream fastTarStream = new FastTarStream(inputStream);
|
||||
fastTarStream.setDebug(bl);
|
||||
int n2 = 56;
|
||||
int n3 = 9;
|
||||
int n4 = 8;
|
||||
StringBuffer stringBuffer = new StringBuffer(128);
|
||||
while ((tarEntry = fastTarStream.getNextEntry()) != null) {
|
||||
if (tarEntry.isDirectory()) {
|
||||
System.out.print("D ");
|
||||
stringBuffer.setLength(0);
|
||||
stringBuffer.append(tarEntry.getName());
|
||||
stringBuffer.setLength(stringBuffer.length() - 1);
|
||||
if (stringBuffer.length() > n2) {
|
||||
stringBuffer.setLength(n2);
|
||||
}
|
||||
while (stringBuffer.length() < n2) {
|
||||
stringBuffer.append('_');
|
||||
}
|
||||
stringBuffer.append('_');
|
||||
System.out.print(stringBuffer.toString());
|
||||
stringBuffer.setLength(0);
|
||||
while (stringBuffer.length() < n3) {
|
||||
stringBuffer.insert(0, '_');
|
||||
}
|
||||
stringBuffer.append(' ');
|
||||
System.out.print(stringBuffer.toString());
|
||||
stringBuffer.setLength(0);
|
||||
stringBuffer.append(tarEntry.getUserName());
|
||||
if (stringBuffer.length() > n4) {
|
||||
stringBuffer.setLength(n4);
|
||||
}
|
||||
while (stringBuffer.length() < n4) {
|
||||
stringBuffer.append(' ');
|
||||
}
|
||||
System.out.print(stringBuffer.toString());
|
||||
} else {
|
||||
System.out.print("F ");
|
||||
stringBuffer.setLength(0);
|
||||
stringBuffer.append(tarEntry.getName());
|
||||
if (stringBuffer.length() > n2) {
|
||||
stringBuffer.setLength(n2);
|
||||
}
|
||||
while (stringBuffer.length() < n2) {
|
||||
stringBuffer.append(' ');
|
||||
}
|
||||
stringBuffer.append(' ');
|
||||
System.out.print(stringBuffer.toString());
|
||||
stringBuffer.setLength(0);
|
||||
stringBuffer.append(tarEntry.getSize());
|
||||
if (stringBuffer.length() > n3) {
|
||||
stringBuffer.setLength(n3);
|
||||
}
|
||||
while (stringBuffer.length() < n3) {
|
||||
stringBuffer.insert(0, ' ');
|
||||
}
|
||||
stringBuffer.append(' ');
|
||||
System.out.print(stringBuffer.toString());
|
||||
stringBuffer.setLength(0);
|
||||
stringBuffer.append(tarEntry.getUserName());
|
||||
if (stringBuffer.length() > n4) {
|
||||
stringBuffer.setLength(n4);
|
||||
}
|
||||
while (stringBuffer.length() < n4) {
|
||||
stringBuffer.append(' ');
|
||||
}
|
||||
System.out.print(stringBuffer.toString());
|
||||
}
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
iOException.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.debug = false;
|
||||
this.hasHitEOF = false;
|
||||
this.currEntry = null;
|
||||
this.inStream = null;
|
||||
this.recordSize = 512;
|
||||
}
|
||||
|
||||
public FastTarStream(InputStream inputStream) {
|
||||
this(inputStream, 512);
|
||||
}
|
||||
|
||||
public FastTarStream(InputStream inputStream, int n) {
|
||||
this.this();
|
||||
this.inStream = inputStream;
|
||||
this.hasHitEOF = false;
|
||||
this.currEntry = null;
|
||||
this.recordSize = n;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class InvalidHeaderException
|
||||
extends IOException {
|
||||
public InvalidHeaderException() {
|
||||
}
|
||||
|
||||
public InvalidHeaderException(String string) {
|
||||
super(string);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,285 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import com.ice.tar.InvalidHeaderException;
|
||||
import com.ice.tar.TarEntry;
|
||||
import com.ice.tar.TarInputStream;
|
||||
import com.ice.tar.TarOutputStream;
|
||||
import com.ice.tar.TarProgressDisplay;
|
||||
import com.ice.tar.TarTransFileTyper;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
public class TarArchive {
|
||||
protected boolean verbose;
|
||||
protected boolean debug;
|
||||
protected boolean keepOldFiles;
|
||||
protected boolean asciiTranslate;
|
||||
protected int userId;
|
||||
protected String userName;
|
||||
protected int groupId;
|
||||
protected String groupName;
|
||||
protected String rootPath;
|
||||
protected String tempPath;
|
||||
protected String pathPrefix;
|
||||
protected int recordSize;
|
||||
protected byte[] recordBuf;
|
||||
protected TarInputStream tarIn;
|
||||
protected TarOutputStream tarOut;
|
||||
protected TarTransFileTyper transTyper;
|
||||
protected TarProgressDisplay progressDisplay;
|
||||
|
||||
private final void initialize(int n) {
|
||||
this.recordSize = n;
|
||||
this.rootPath = null;
|
||||
this.pathPrefix = null;
|
||||
this.tempPath = System.getProperty("user.dir");
|
||||
this.userId = 0;
|
||||
this.userName = "";
|
||||
this.groupId = 0;
|
||||
this.groupName = "";
|
||||
this.debug = false;
|
||||
this.verbose = false;
|
||||
this.keepOldFiles = false;
|
||||
this.progressDisplay = null;
|
||||
this.recordBuf = new byte[this.getRecordSize()];
|
||||
}
|
||||
|
||||
public void setDebug(boolean bl) {
|
||||
this.debug = bl;
|
||||
if (this.tarIn != null) {
|
||||
this.tarIn.setDebug(bl);
|
||||
} else if (this.tarOut != null) {
|
||||
this.tarOut.setDebug(bl);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isVerbose() {
|
||||
return this.verbose;
|
||||
}
|
||||
|
||||
public void setVerbose(boolean bl) {
|
||||
this.verbose = bl;
|
||||
}
|
||||
|
||||
public void setTarProgressDisplay(TarProgressDisplay tarProgressDisplay) {
|
||||
this.progressDisplay = tarProgressDisplay;
|
||||
}
|
||||
|
||||
public void setKeepOldFiles(boolean bl) {
|
||||
this.keepOldFiles = bl;
|
||||
}
|
||||
|
||||
public void setAsciiTranslation(boolean bl) {
|
||||
this.asciiTranslate = bl;
|
||||
}
|
||||
|
||||
public void setTransFileTyper(TarTransFileTyper tarTransFileTyper) {
|
||||
this.transTyper = tarTransFileTyper;
|
||||
}
|
||||
|
||||
public void setUserInfo(int n, String string, int n2, String string2) {
|
||||
this.userId = n;
|
||||
this.userName = string;
|
||||
this.groupId = n2;
|
||||
this.groupName = string2;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return this.userName;
|
||||
}
|
||||
|
||||
public int getGroupId() {
|
||||
return this.groupId;
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return this.groupName;
|
||||
}
|
||||
|
||||
public String getTempDirectory() {
|
||||
return this.tempPath;
|
||||
}
|
||||
|
||||
public void setTempDirectory(String string) {
|
||||
this.tempPath = string;
|
||||
}
|
||||
|
||||
public int getRecordSize() {
|
||||
if (this.tarIn != null) {
|
||||
return this.tarIn.getRecordSize();
|
||||
}
|
||||
if (this.tarOut != null) {
|
||||
return this.tarOut.getRecordSize();
|
||||
}
|
||||
return 512;
|
||||
}
|
||||
|
||||
public void closeArchive() throws IOException {
|
||||
if (this.tarIn != null) {
|
||||
this.tarIn.close();
|
||||
} else if (this.tarOut != null) {
|
||||
this.tarOut.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void listContents() throws IOException, InvalidHeaderException {
|
||||
while (true) {
|
||||
TarEntry tarEntry;
|
||||
if ((tarEntry = this.tarIn.getNextEntry()) == null) {
|
||||
if (!this.debug) break;
|
||||
System.err.println("READ EOF RECORD");
|
||||
break;
|
||||
}
|
||||
if (this.progressDisplay == null) continue;
|
||||
this.progressDisplay.showTarProgressMessage(tarEntry.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void extractContents(File file) throws IOException, InvalidHeaderException {
|
||||
while (true) {
|
||||
TarEntry tarEntry;
|
||||
if ((tarEntry = this.tarIn.getNextEntry()) == null) {
|
||||
if (!this.debug) break;
|
||||
System.err.println("READ EOF RECORD");
|
||||
break;
|
||||
}
|
||||
this.extractEntry(file, tarEntry);
|
||||
}
|
||||
}
|
||||
|
||||
private final void extractEntry(File file, TarEntry tarEntry) throws IOException {
|
||||
if (this.verbose && this.progressDisplay != null) {
|
||||
this.progressDisplay.showTarProgressMessage(tarEntry.getName());
|
||||
}
|
||||
String string = tarEntry.getName();
|
||||
string = string.replace('/', File.separatorChar);
|
||||
File file2 = new File(file, string);
|
||||
if (tarEntry.isDirectory()) {
|
||||
if (!file2.exists() && !file2.mkdirs()) {
|
||||
throw new IOException("error making directory path '" + file2.getPath() + '\'');
|
||||
}
|
||||
} else {
|
||||
File file3 = new File(file2.getParent());
|
||||
if (!file3.exists() && !file3.mkdirs()) {
|
||||
throw new IOException("error making directory path '" + file3.getPath() + '\'');
|
||||
}
|
||||
if (this.keepOldFiles && file2.exists()) {
|
||||
if (this.verbose && this.progressDisplay != null) {
|
||||
this.progressDisplay.showTarProgressMessage("not overwriting " + tarEntry.getName());
|
||||
}
|
||||
} else {
|
||||
int n;
|
||||
boolean bl = false;
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(file2);
|
||||
PrintWriter printWriter = null;
|
||||
if (bl) {
|
||||
printWriter = new PrintWriter(fileOutputStream);
|
||||
}
|
||||
byte[] byArray = new byte[32768];
|
||||
while ((n = this.tarIn.read(byArray)) != -1) {
|
||||
if (bl && printWriter != null) {
|
||||
int n2 = 0;
|
||||
int n3 = 0;
|
||||
while (n3 < n) {
|
||||
if (byArray[n3] == 10) {
|
||||
String string2 = new String(byArray, n2, n3 - n2);
|
||||
printWriter.println(string2);
|
||||
n2 = n3 + 1;
|
||||
}
|
||||
++n3;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
fileOutputStream.write(byArray, 0, n);
|
||||
}
|
||||
if (bl && printWriter != null) {
|
||||
printWriter.close();
|
||||
} else {
|
||||
fileOutputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeEntry(TarEntry tarEntry, boolean bl) throws IOException {
|
||||
boolean bl2 = tarEntry.isUnixTarFormat();
|
||||
File file = tarEntry.getFile();
|
||||
TarEntry tarEntry2 = (TarEntry)tarEntry.clone();
|
||||
if (this.verbose && this.progressDisplay != null) {
|
||||
this.progressDisplay.showTarProgressMessage(tarEntry2.getName());
|
||||
}
|
||||
String string = null;
|
||||
if (this.rootPath != null && tarEntry2.getName().startsWith(this.rootPath)) {
|
||||
string = tarEntry2.getName().substring(this.rootPath.length() + 1);
|
||||
}
|
||||
if (this.pathPrefix != null) {
|
||||
String string2 = string = string == null ? this.pathPrefix + '/' + tarEntry2.getName() : this.pathPrefix + '/' + string;
|
||||
}
|
||||
if (string != null) {
|
||||
tarEntry2.setName(string);
|
||||
}
|
||||
this.tarOut.putNextEntry(tarEntry2);
|
||||
if (tarEntry2.isDirectory()) {
|
||||
if (bl) {
|
||||
TarEntry[] tarEntryArray = tarEntry2.getDirectoryEntries();
|
||||
int n = 0;
|
||||
while (n < tarEntryArray.length) {
|
||||
TarEntry tarEntry3 = tarEntryArray[n];
|
||||
if (bl2) {
|
||||
tarEntry3.setUnixTarFormat();
|
||||
}
|
||||
this.writeEntry(tarEntry3, bl);
|
||||
++n;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int n;
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
byte[] byArray = new byte[32768];
|
||||
while ((n = fileInputStream.read(byArray, 0, byArray.length)) != -1) {
|
||||
this.tarOut.write(byArray, 0, n);
|
||||
}
|
||||
fileInputStream.close();
|
||||
this.tarOut.closeEntry();
|
||||
}
|
||||
}
|
||||
|
||||
public TarArchive(InputStream inputStream) {
|
||||
this(inputStream, 10240);
|
||||
}
|
||||
|
||||
public TarArchive(InputStream inputStream, int n) {
|
||||
this(inputStream, n, 512);
|
||||
}
|
||||
|
||||
public TarArchive(InputStream inputStream, int n, int n2) {
|
||||
this.tarIn = new TarInputStream(inputStream, n, n2);
|
||||
this.initialize(n2);
|
||||
}
|
||||
|
||||
public TarArchive(OutputStream outputStream) {
|
||||
this(outputStream, 10240);
|
||||
}
|
||||
|
||||
public TarArchive(OutputStream outputStream, int n) {
|
||||
this(outputStream, n, 512);
|
||||
}
|
||||
|
||||
public TarArchive(OutputStream outputStream, int n, int n2) {
|
||||
this.tarOut = new TarOutputStream(outputStream, n, n2);
|
||||
this.initialize(n2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class TarBuffer {
|
||||
public static final int DEFAULT_RCDSIZE = 512;
|
||||
public static final int DEFAULT_BLKSIZE = 10240;
|
||||
private InputStream inStream;
|
||||
private OutputStream outStream;
|
||||
private byte[] blockBuffer;
|
||||
private int currBlkIdx;
|
||||
private int currRecIdx;
|
||||
private int blockSize;
|
||||
private int recordSize;
|
||||
private int recsPerBlock;
|
||||
private boolean debug;
|
||||
|
||||
private final void initialize(int n, int n2) {
|
||||
this.debug = false;
|
||||
this.blockSize = n;
|
||||
this.recordSize = n2;
|
||||
this.recsPerBlock = this.blockSize / this.recordSize;
|
||||
this.blockBuffer = new byte[this.blockSize];
|
||||
if (this.inStream != null) {
|
||||
this.currBlkIdx = -1;
|
||||
this.currRecIdx = this.recsPerBlock;
|
||||
} else {
|
||||
this.currBlkIdx = 0;
|
||||
this.currRecIdx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int getBlockSize() {
|
||||
return this.blockSize;
|
||||
}
|
||||
|
||||
public int getRecordSize() {
|
||||
return this.recordSize;
|
||||
}
|
||||
|
||||
public void setDebug(boolean bl) {
|
||||
this.debug = bl;
|
||||
}
|
||||
|
||||
public boolean isEOFRecord(byte[] byArray) {
|
||||
int n = 0;
|
||||
int n2 = this.getRecordSize();
|
||||
while (n < n2) {
|
||||
if (byArray[n] != 0) {
|
||||
return false;
|
||||
}
|
||||
++n;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void skipRecord() throws IOException {
|
||||
if (this.debug) {
|
||||
System.err.println("SkipRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx);
|
||||
}
|
||||
if (this.inStream == null) {
|
||||
throw new IOException("reading (via skip) from an output buffer");
|
||||
}
|
||||
if (this.currRecIdx >= this.recsPerBlock && !this.readBlock()) {
|
||||
return;
|
||||
}
|
||||
++this.currRecIdx;
|
||||
}
|
||||
|
||||
public byte[] readRecord() throws IOException {
|
||||
if (this.debug) {
|
||||
System.err.println("ReadRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx);
|
||||
}
|
||||
if (this.inStream == null) {
|
||||
throw new IOException("reading from an output buffer");
|
||||
}
|
||||
if (this.currRecIdx >= this.recsPerBlock && !this.readBlock()) {
|
||||
return null;
|
||||
}
|
||||
byte[] byArray = new byte[this.recordSize];
|
||||
System.arraycopy(this.blockBuffer, this.currRecIdx * this.recordSize, byArray, 0, this.recordSize);
|
||||
++this.currRecIdx;
|
||||
return byArray;
|
||||
}
|
||||
|
||||
private final boolean readBlock() throws IOException {
|
||||
if (this.debug) {
|
||||
System.err.println("ReadBlock: blkIdx = " + this.currBlkIdx);
|
||||
}
|
||||
if (this.inStream == null) {
|
||||
throw new IOException("reading from an output buffer");
|
||||
}
|
||||
this.currRecIdx = 0;
|
||||
int n = 0;
|
||||
int n2 = this.blockSize;
|
||||
while (n2 > 0) {
|
||||
long l = this.inStream.read(this.blockBuffer, n, n2);
|
||||
if (l == (long)-1) break;
|
||||
n = (int)((long)n + l);
|
||||
n2 = (int)((long)n2 - l);
|
||||
if (l == (long)this.blockSize || !this.debug) continue;
|
||||
System.err.println("ReadBlock: INCOMPLETE READ " + l + " of " + this.blockSize + " bytes read.");
|
||||
}
|
||||
++this.currBlkIdx;
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getCurrentBlockNum() {
|
||||
return this.currBlkIdx;
|
||||
}
|
||||
|
||||
public int getCurrentRecordNum() {
|
||||
return this.currRecIdx - 1;
|
||||
}
|
||||
|
||||
public void writeRecord(byte[] byArray) throws IOException {
|
||||
if (this.debug) {
|
||||
System.err.println("WriteRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx);
|
||||
}
|
||||
if (this.outStream == null) {
|
||||
throw new IOException("writing to an input buffer");
|
||||
}
|
||||
if (byArray.length != this.recordSize) {
|
||||
throw new IOException("record to write has length '" + byArray.length + "' which is not the record size of '" + this.recordSize + '\'');
|
||||
}
|
||||
if (this.currRecIdx >= this.recsPerBlock) {
|
||||
this.writeBlock();
|
||||
}
|
||||
System.arraycopy(byArray, 0, this.blockBuffer, this.currRecIdx * this.recordSize, this.recordSize);
|
||||
++this.currRecIdx;
|
||||
}
|
||||
|
||||
public void writeRecord(byte[] byArray, int n) throws IOException {
|
||||
if (this.debug) {
|
||||
System.err.println("WriteRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx);
|
||||
}
|
||||
if (this.outStream == null) {
|
||||
throw new IOException("writing to an input buffer");
|
||||
}
|
||||
if (n + this.recordSize > byArray.length) {
|
||||
throw new IOException("record has length '" + byArray.length + "' with offset '" + n + "' which is less than the record size of '" + this.recordSize + '\'');
|
||||
}
|
||||
if (this.currRecIdx >= this.recsPerBlock) {
|
||||
this.writeBlock();
|
||||
}
|
||||
System.arraycopy(byArray, n, this.blockBuffer, this.currRecIdx * this.recordSize, this.recordSize);
|
||||
++this.currRecIdx;
|
||||
}
|
||||
|
||||
private final void writeBlock() throws IOException {
|
||||
if (this.debug) {
|
||||
System.err.println("WriteBlock: blkIdx = " + this.currBlkIdx);
|
||||
}
|
||||
if (this.outStream == null) {
|
||||
throw new IOException("writing to an input buffer");
|
||||
}
|
||||
this.outStream.write(this.blockBuffer, 0, this.blockSize);
|
||||
this.outStream.flush();
|
||||
this.currRecIdx = 0;
|
||||
++this.currBlkIdx;
|
||||
}
|
||||
|
||||
private final void flushBlock() throws IOException {
|
||||
if (this.debug) {
|
||||
System.err.println("TarBuffer.flushBlock() called.");
|
||||
}
|
||||
if (this.outStream == null) {
|
||||
throw new IOException("writing to an input buffer");
|
||||
}
|
||||
if (this.currRecIdx > 0) {
|
||||
int n = this.currRecIdx * this.recordSize;
|
||||
byte[] byArray = new byte[this.blockSize - n];
|
||||
System.arraycopy(byArray, 0, this.blockBuffer, n, byArray.length);
|
||||
this.writeBlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
if (this.debug) {
|
||||
System.err.println("TarBuffer.closeBuffer().");
|
||||
}
|
||||
if (this.outStream != null) {
|
||||
this.flushBlock();
|
||||
if (this.outStream != System.out && this.outStream != System.err) {
|
||||
this.outStream.close();
|
||||
this.outStream = null;
|
||||
}
|
||||
} else if (this.inStream != null && this.inStream != System.in) {
|
||||
this.inStream.close();
|
||||
this.inStream = null;
|
||||
}
|
||||
}
|
||||
|
||||
public TarBuffer(InputStream inputStream) {
|
||||
this(inputStream, 10240);
|
||||
}
|
||||
|
||||
public TarBuffer(InputStream inputStream, int n) {
|
||||
this(inputStream, n, 512);
|
||||
}
|
||||
|
||||
public TarBuffer(InputStream inputStream, int n, int n2) {
|
||||
this.inStream = inputStream;
|
||||
this.outStream = null;
|
||||
this.initialize(n, n2);
|
||||
}
|
||||
|
||||
public TarBuffer(OutputStream outputStream) {
|
||||
this(outputStream, 10240);
|
||||
}
|
||||
|
||||
public TarBuffer(OutputStream outputStream, int n) {
|
||||
this(outputStream, n, 512);
|
||||
}
|
||||
|
||||
public TarBuffer(OutputStream outputStream, int n, int n2) {
|
||||
this.inStream = null;
|
||||
this.outStream = outputStream;
|
||||
this.initialize(n, n2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,389 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import com.ice.tar.InvalidHeaderException;
|
||||
import com.ice.tar.TarHeader;
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
|
||||
public class TarEntry
|
||||
implements Cloneable {
|
||||
protected File file;
|
||||
protected TarHeader header;
|
||||
protected boolean unixFormat;
|
||||
protected boolean ustarFormat;
|
||||
protected boolean gnuFormat;
|
||||
|
||||
private final void initialize() {
|
||||
this.file = null;
|
||||
this.header = new TarHeader();
|
||||
this.gnuFormat = false;
|
||||
this.ustarFormat = true;
|
||||
this.unixFormat = false;
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
TarEntry tarEntry = null;
|
||||
try {
|
||||
tarEntry = (TarEntry)super.clone();
|
||||
if (this.header != null) {
|
||||
tarEntry.header = (TarHeader)this.header.clone();
|
||||
}
|
||||
if (this.file != null) {
|
||||
tarEntry.file = new File(this.file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
catch (CloneNotSupportedException cloneNotSupportedException) {
|
||||
cloneNotSupportedException.printStackTrace(System.err);
|
||||
}
|
||||
return tarEntry;
|
||||
}
|
||||
|
||||
public boolean isUSTarFormat() {
|
||||
return this.ustarFormat;
|
||||
}
|
||||
|
||||
public void setUSTarFormat() {
|
||||
this.ustarFormat = true;
|
||||
this.gnuFormat = false;
|
||||
this.unixFormat = false;
|
||||
}
|
||||
|
||||
public boolean isGNUTarFormat() {
|
||||
return this.gnuFormat;
|
||||
}
|
||||
|
||||
public void setGNUTarFormat() {
|
||||
this.gnuFormat = true;
|
||||
this.ustarFormat = false;
|
||||
this.unixFormat = false;
|
||||
}
|
||||
|
||||
public boolean isUnixTarFormat() {
|
||||
return this.unixFormat;
|
||||
}
|
||||
|
||||
public void setUnixTarFormat() {
|
||||
this.unixFormat = true;
|
||||
this.ustarFormat = false;
|
||||
this.gnuFormat = false;
|
||||
}
|
||||
|
||||
public boolean equals(TarEntry tarEntry) {
|
||||
return this.header.name.toString().equals(tarEntry.header.name.toString());
|
||||
}
|
||||
|
||||
public boolean isDescendent(TarEntry tarEntry) {
|
||||
return tarEntry.header.name.toString().startsWith(this.header.name.toString());
|
||||
}
|
||||
|
||||
public TarHeader getHeader() {
|
||||
return this.header;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.header.name.toString();
|
||||
}
|
||||
|
||||
public void setName(String string) {
|
||||
this.header.name = new StringBuffer(string);
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return this.header.userId;
|
||||
}
|
||||
|
||||
public void setUserId(int n) {
|
||||
this.header.userId = n;
|
||||
}
|
||||
|
||||
public int getGroupId() {
|
||||
return this.header.groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(int n) {
|
||||
this.header.groupId = n;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return this.header.userName.toString();
|
||||
}
|
||||
|
||||
public void setUserName(String string) {
|
||||
this.header.userName = new StringBuffer(string);
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return this.header.groupName.toString();
|
||||
}
|
||||
|
||||
public void setGroupName(String string) {
|
||||
this.header.groupName = new StringBuffer(string);
|
||||
}
|
||||
|
||||
public void setIds(int n, int n2) {
|
||||
this.setUserId(n);
|
||||
this.setGroupId(n2);
|
||||
}
|
||||
|
||||
public void setNames(String string, String string2) {
|
||||
this.setUserName(string);
|
||||
this.setGroupName(string2);
|
||||
}
|
||||
|
||||
public void setModTime(long l) {
|
||||
this.header.modTime = l / 1000L;
|
||||
}
|
||||
|
||||
public void setModTime(Date date) {
|
||||
this.header.modTime = date.getTime() / 1000L;
|
||||
}
|
||||
|
||||
public Date getModTime() {
|
||||
return new Date(this.header.modTime * 1000L);
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return this.file;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return this.header.size;
|
||||
}
|
||||
|
||||
public void setSize(long l) {
|
||||
this.header.size = l;
|
||||
}
|
||||
|
||||
public boolean isDirectory() {
|
||||
if (this.file != null) {
|
||||
return this.file.isDirectory();
|
||||
}
|
||||
if (this.header != null) {
|
||||
if (this.header.linkFlag == 53) {
|
||||
return true;
|
||||
}
|
||||
if (this.header.name.toString().endsWith("/")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void getFileTarHeader(TarHeader tarHeader, File file) throws InvalidHeaderException {
|
||||
this.file = file;
|
||||
String string = file.getPath();
|
||||
String string2 = System.getProperty("os.name");
|
||||
if (string2 != null) {
|
||||
String string3 = "windows";
|
||||
if (string2.toLowerCase().startsWith(string3) && string.length() > 2) {
|
||||
char c = string.charAt(0);
|
||||
char c2 = string.charAt(1);
|
||||
if (c2 == ':' && (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')) {
|
||||
string = string.substring(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
string = string.replace(File.separatorChar, '/');
|
||||
while (string.startsWith("/")) {
|
||||
string = string.substring(1);
|
||||
}
|
||||
tarHeader.linkName = new StringBuffer("");
|
||||
tarHeader.name = new StringBuffer(string);
|
||||
if (file.isDirectory()) {
|
||||
tarHeader.size = 0L;
|
||||
tarHeader.mode = 16877;
|
||||
tarHeader.linkFlag = (byte)53;
|
||||
if (tarHeader.name.charAt(tarHeader.name.length() - 1) != '/') {
|
||||
tarHeader.name.append("/");
|
||||
}
|
||||
} else {
|
||||
tarHeader.size = file.length();
|
||||
tarHeader.mode = 33188;
|
||||
tarHeader.linkFlag = (byte)48;
|
||||
}
|
||||
tarHeader.modTime = file.lastModified() / 1000L;
|
||||
tarHeader.checkSum = 0;
|
||||
tarHeader.devMajor = 0;
|
||||
tarHeader.devMinor = 0;
|
||||
}
|
||||
|
||||
public TarEntry[] getDirectoryEntries() throws InvalidHeaderException {
|
||||
if (this.file == null || !this.file.isDirectory()) {
|
||||
return new TarEntry[0];
|
||||
}
|
||||
String[] stringArray = this.file.list();
|
||||
TarEntry[] tarEntryArray = new TarEntry[stringArray.length];
|
||||
int n = 0;
|
||||
while (n < stringArray.length) {
|
||||
tarEntryArray[n] = new TarEntry(new File(this.file, stringArray[n]));
|
||||
++n;
|
||||
}
|
||||
return tarEntryArray;
|
||||
}
|
||||
|
||||
public long computeCheckSum(byte[] byArray) {
|
||||
long l = 0L;
|
||||
int n = 0;
|
||||
while (n < byArray.length) {
|
||||
l += (long)(0xFF & byArray[n]);
|
||||
++n;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
public void writeEntryHeader(byte[] byArray) throws InvalidHeaderException {
|
||||
int n = 0;
|
||||
if (this.isUnixTarFormat() && this.header.name.length() > 100) {
|
||||
throw new InvalidHeaderException("file path is greater than 100 characters, " + this.header.name);
|
||||
}
|
||||
n = TarHeader.getFileNameBytes(this.header.name.toString(), byArray);
|
||||
n = TarHeader.getOctalBytes(this.header.mode, byArray, n, 8);
|
||||
n = TarHeader.getOctalBytes(this.header.userId, byArray, n, 8);
|
||||
n = TarHeader.getOctalBytes(this.header.groupId, byArray, n, 8);
|
||||
long l = this.header.size;
|
||||
n = TarHeader.getLongOctalBytes(l, byArray, n, 12);
|
||||
int n2 = n = TarHeader.getLongOctalBytes(this.header.modTime, byArray, n, 12);
|
||||
int n3 = 0;
|
||||
while (n3 < 8) {
|
||||
byArray[n++] = 32;
|
||||
++n3;
|
||||
}
|
||||
byArray[n++] = this.header.linkFlag;
|
||||
n = TarHeader.getNameBytes(this.header.linkName, byArray, n, 100);
|
||||
if (this.unixFormat) {
|
||||
n3 = 0;
|
||||
while (n3 < 8) {
|
||||
byArray[n++] = 0;
|
||||
++n3;
|
||||
}
|
||||
} else {
|
||||
n = TarHeader.getNameBytes(this.header.magic, byArray, n, 8);
|
||||
}
|
||||
n = TarHeader.getNameBytes(this.header.userName, byArray, n, 32);
|
||||
n = TarHeader.getNameBytes(this.header.groupName, byArray, n, 32);
|
||||
n = TarHeader.getOctalBytes(this.header.devMajor, byArray, n, 8);
|
||||
n = TarHeader.getOctalBytes(this.header.devMinor, byArray, n, 8);
|
||||
while (n < byArray.length) {
|
||||
byArray[n++] = 0;
|
||||
}
|
||||
long l2 = this.computeCheckSum(byArray);
|
||||
TarHeader.getCheckSumOctalBytes(l2, byArray, n2, 8);
|
||||
}
|
||||
|
||||
public void parseTarHeader(TarHeader tarHeader, byte[] byArray) throws InvalidHeaderException {
|
||||
int n = 0;
|
||||
if (byArray[257] == 0 && byArray[258] == 0 && byArray[259] == 0 && byArray[260] == 0 && byArray[261] == 0) {
|
||||
this.unixFormat = true;
|
||||
this.ustarFormat = false;
|
||||
this.gnuFormat = false;
|
||||
} else if (byArray[257] == 117 && byArray[258] == 115 && byArray[259] == 116 && byArray[260] == 97 && byArray[261] == 114 && byArray[262] == 0) {
|
||||
this.ustarFormat = true;
|
||||
this.gnuFormat = false;
|
||||
this.unixFormat = false;
|
||||
} else if (byArray[257] == 117 && byArray[258] == 115 && byArray[259] == 116 && byArray[260] == 97 && byArray[261] == 114 && byArray[262] != 0 && byArray[263] != 0) {
|
||||
this.gnuFormat = true;
|
||||
this.unixFormat = false;
|
||||
this.ustarFormat = false;
|
||||
} else {
|
||||
StringBuffer stringBuffer = new StringBuffer(128);
|
||||
stringBuffer.append("header magic is not 'ustar' or unix-style zeros, it is '");
|
||||
stringBuffer.append(byArray[257]);
|
||||
stringBuffer.append(byArray[258]);
|
||||
stringBuffer.append(byArray[259]);
|
||||
stringBuffer.append(byArray[260]);
|
||||
stringBuffer.append(byArray[261]);
|
||||
stringBuffer.append(byArray[262]);
|
||||
stringBuffer.append(byArray[263]);
|
||||
stringBuffer.append("', or (dec) ");
|
||||
stringBuffer.append(byArray[257]);
|
||||
stringBuffer.append(", ");
|
||||
stringBuffer.append(byArray[258]);
|
||||
stringBuffer.append(", ");
|
||||
stringBuffer.append(byArray[259]);
|
||||
stringBuffer.append(", ");
|
||||
stringBuffer.append(byArray[260]);
|
||||
stringBuffer.append(", ");
|
||||
stringBuffer.append(byArray[261]);
|
||||
stringBuffer.append(", ");
|
||||
stringBuffer.append(byArray[262]);
|
||||
stringBuffer.append(", ");
|
||||
stringBuffer.append(byArray[263]);
|
||||
throw new InvalidHeaderException(stringBuffer.toString());
|
||||
}
|
||||
tarHeader.name = TarHeader.parseFileName(byArray);
|
||||
n = 100;
|
||||
tarHeader.mode = (int)TarHeader.parseOctal(byArray, n, 8);
|
||||
tarHeader.userId = (int)TarHeader.parseOctal(byArray, n += 8, 8);
|
||||
tarHeader.groupId = (int)TarHeader.parseOctal(byArray, n += 8, 8);
|
||||
tarHeader.size = TarHeader.parseOctal(byArray, n += 8, 12);
|
||||
tarHeader.modTime = TarHeader.parseOctal(byArray, n += 12, 12);
|
||||
tarHeader.checkSum = (int)TarHeader.parseOctal(byArray, n += 12, 8);
|
||||
n += 8;
|
||||
tarHeader.linkFlag = byArray[n++];
|
||||
tarHeader.linkName = TarHeader.parseName(byArray, n, 100);
|
||||
n += 100;
|
||||
if (this.ustarFormat) {
|
||||
tarHeader.magic = TarHeader.parseName(byArray, n, 8);
|
||||
tarHeader.userName = TarHeader.parseName(byArray, n += 8, 32);
|
||||
tarHeader.groupName = TarHeader.parseName(byArray, n += 32, 32);
|
||||
tarHeader.devMajor = (int)TarHeader.parseOctal(byArray, n += 32, 8);
|
||||
tarHeader.devMinor = (int)TarHeader.parseOctal(byArray, n += 8, 8);
|
||||
} else {
|
||||
tarHeader.devMajor = 0;
|
||||
tarHeader.devMinor = 0;
|
||||
tarHeader.magic = new StringBuffer("");
|
||||
tarHeader.userName = new StringBuffer("");
|
||||
tarHeader.groupName = new StringBuffer("");
|
||||
}
|
||||
}
|
||||
|
||||
public void nameTarHeader(TarHeader tarHeader, String string) {
|
||||
boolean bl = string.endsWith("/");
|
||||
this.gnuFormat = false;
|
||||
this.ustarFormat = true;
|
||||
this.unixFormat = false;
|
||||
tarHeader.checkSum = 0;
|
||||
tarHeader.devMajor = 0;
|
||||
tarHeader.devMinor = 0;
|
||||
tarHeader.name = new StringBuffer(string);
|
||||
tarHeader.mode = bl ? 16877 : 33188;
|
||||
tarHeader.userId = 0;
|
||||
tarHeader.groupId = 0;
|
||||
tarHeader.size = 0L;
|
||||
tarHeader.checkSum = 0;
|
||||
tarHeader.modTime = new Date().getTime() / 1000L;
|
||||
tarHeader.linkFlag = (byte)(bl ? 53 : 48);
|
||||
tarHeader.linkName = new StringBuffer("");
|
||||
tarHeader.userName = new StringBuffer("");
|
||||
tarHeader.groupName = new StringBuffer("");
|
||||
tarHeader.devMajor = 0;
|
||||
tarHeader.devMinor = 0;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer stringBuffer = new StringBuffer(128);
|
||||
return stringBuffer.append("[TarEntry name=").append(this.getName()).append(", isDir=").append(this.isDirectory()).append(", size=").append(this.getSize()).append(", userId=").append(this.getUserId()).append(", user=").append(this.getUserName()).append(", groupId=").append(this.getGroupId()).append(", group=").append(this.getGroupName()).append("]").toString();
|
||||
}
|
||||
|
||||
protected TarEntry() {
|
||||
}
|
||||
|
||||
public TarEntry(String string) {
|
||||
this.initialize();
|
||||
this.nameTarHeader(this.header, string);
|
||||
}
|
||||
|
||||
public TarEntry(File file) throws InvalidHeaderException {
|
||||
this.initialize();
|
||||
this.getFileTarHeader(this.header, file);
|
||||
}
|
||||
|
||||
public TarEntry(byte[] byArray) throws InvalidHeaderException {
|
||||
this.initialize();
|
||||
this.parseTarHeader(this.header, byArray);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import com.ice.tar.TarEntry;
|
||||
import com.ice.tar.TarInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class TarEntryEnumerator
|
||||
implements Enumeration {
|
||||
private TarInputStream tis;
|
||||
private boolean eof;
|
||||
private TarEntry readAhead;
|
||||
|
||||
public Object nextElement() throws NoSuchElementException {
|
||||
if (this.eof && this.readAhead == null) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
TarEntry tarEntry = null;
|
||||
if (this.readAhead != null) {
|
||||
tarEntry = this.readAhead;
|
||||
this.readAhead = null;
|
||||
} else {
|
||||
tarEntry = this.getNext();
|
||||
}
|
||||
return tarEntry;
|
||||
}
|
||||
|
||||
public boolean hasMoreElements() {
|
||||
if (this.eof) {
|
||||
return false;
|
||||
}
|
||||
boolean bl = false;
|
||||
this.readAhead = this.getNext();
|
||||
if (this.readAhead != null) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
private final TarEntry getNext() {
|
||||
TarEntry tarEntry = null;
|
||||
try {
|
||||
tarEntry = this.tis.getNextEntry();
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
iOException.printStackTrace();
|
||||
}
|
||||
if (tarEntry == null) {
|
||||
this.eof = true;
|
||||
}
|
||||
return tarEntry;
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.tis = null;
|
||||
this.eof = false;
|
||||
this.readAhead = null;
|
||||
}
|
||||
|
||||
public TarEntryEnumerator(TarInputStream tarInputStream) {
|
||||
this.this();
|
||||
this.tis = tarInputStream;
|
||||
this.eof = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import com.ice.tar.TarEntry;
|
||||
import com.ice.tar.TarOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class TarGzOutputStream
|
||||
extends TarOutputStream {
|
||||
private TarOutputStream tos;
|
||||
private GZIPOutputStream gzip;
|
||||
private ByteArrayOutputStream bos;
|
||||
private TarEntry currentEntry;
|
||||
|
||||
public void setDebug(boolean bl) {
|
||||
this.tos.setDebug(bl);
|
||||
}
|
||||
|
||||
public void setBufferDebug(boolean bl) {
|
||||
this.tos.setBufferDebug(bl);
|
||||
}
|
||||
|
||||
public void finish() throws IOException {
|
||||
if (this.currentEntry != null) {
|
||||
this.closeEntry();
|
||||
}
|
||||
this.tos.finish();
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
this.tos.close();
|
||||
this.gzip.finish();
|
||||
}
|
||||
|
||||
public int getRecordSize() {
|
||||
return this.tos.getRecordSize();
|
||||
}
|
||||
|
||||
public void putNextEntry(TarEntry tarEntry) throws IOException {
|
||||
if (tarEntry.getSize() != 0L) {
|
||||
this.tos.putNextEntry(tarEntry);
|
||||
} else {
|
||||
this.currentEntry = tarEntry;
|
||||
}
|
||||
}
|
||||
|
||||
public void closeEntry() throws IOException {
|
||||
if (this.currentEntry == null) {
|
||||
this.tos.closeEntry();
|
||||
} else {
|
||||
this.currentEntry.setSize(this.bos.size());
|
||||
this.tos.putNextEntry(this.currentEntry);
|
||||
this.bos.writeTo(this.tos);
|
||||
this.tos.closeEntry();
|
||||
this.currentEntry = null;
|
||||
this.bos = new ByteArrayOutputStream();
|
||||
}
|
||||
}
|
||||
|
||||
public void write(int n) throws IOException {
|
||||
if (this.currentEntry == null) {
|
||||
this.tos.write(n);
|
||||
} else {
|
||||
this.bos.write(n);
|
||||
}
|
||||
}
|
||||
|
||||
public void write(byte[] byArray) throws IOException {
|
||||
if (this.currentEntry == null) {
|
||||
this.tos.write(byArray);
|
||||
} else {
|
||||
this.bos.write(byArray);
|
||||
}
|
||||
}
|
||||
|
||||
public void write(byte[] byArray, int n, int n2) throws IOException {
|
||||
if (this.currentEntry == null) {
|
||||
this.tos.write(byArray, n, n2);
|
||||
} else {
|
||||
this.bos.write(byArray, n, n2);
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.tos = null;
|
||||
this.gzip = null;
|
||||
this.bos = null;
|
||||
this.currentEntry = null;
|
||||
}
|
||||
|
||||
public TarGzOutputStream(OutputStream outputStream) throws IOException {
|
||||
super(null);
|
||||
this.this();
|
||||
this.gzip = new GZIPOutputStream(outputStream);
|
||||
this.tos = new TarOutputStream(this.gzip);
|
||||
this.bos = new ByteArrayOutputStream();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import com.ice.tar.InvalidHeaderException;
|
||||
|
||||
public class TarHeader
|
||||
implements Cloneable {
|
||||
public static final int NAMELEN = 100;
|
||||
public static final int NAMEOFFSET = 0;
|
||||
public static final int PREFIXLEN = 155;
|
||||
public static final int PREFIXOFFSET = 345;
|
||||
public static final int MODELEN = 8;
|
||||
public static final int UIDLEN = 8;
|
||||
public static final int GIDLEN = 8;
|
||||
public static final int CHKSUMLEN = 8;
|
||||
public static final int SIZELEN = 12;
|
||||
public static final int MAGICLEN = 8;
|
||||
public static final int MODTIMELEN = 12;
|
||||
public static final int UNAMELEN = 32;
|
||||
public static final int GNAMELEN = 32;
|
||||
public static final int DEVLEN = 8;
|
||||
public static final byte LF_OLDNORM = 0;
|
||||
public static final byte LF_NORMAL = 48;
|
||||
public static final byte LF_LINK = 49;
|
||||
public static final byte LF_SYMLINK = 50;
|
||||
public static final byte LF_CHR = 51;
|
||||
public static final byte LF_BLK = 52;
|
||||
public static final byte LF_DIR = 53;
|
||||
public static final byte LF_FIFO = 54;
|
||||
public static final byte LF_CONTIG = 55;
|
||||
public static final String TMAGIC = "ustar";
|
||||
public static final String GNU_TMAGIC = "ustar ";
|
||||
public StringBuffer name;
|
||||
public int mode;
|
||||
public int userId;
|
||||
public int groupId;
|
||||
public long size;
|
||||
public long modTime;
|
||||
public int checkSum;
|
||||
public byte linkFlag;
|
||||
public StringBuffer linkName;
|
||||
public StringBuffer magic = new StringBuffer("ustar");
|
||||
public StringBuffer userName;
|
||||
public StringBuffer groupName;
|
||||
public int devMajor;
|
||||
public int devMinor;
|
||||
|
||||
public Object clone() {
|
||||
TarHeader tarHeader = null;
|
||||
try {
|
||||
tarHeader = (TarHeader)super.clone();
|
||||
tarHeader.name = this.name == null ? null : new StringBuffer(this.name.toString());
|
||||
tarHeader.mode = this.mode;
|
||||
tarHeader.userId = this.userId;
|
||||
tarHeader.groupId = this.groupId;
|
||||
tarHeader.size = this.size;
|
||||
tarHeader.modTime = this.modTime;
|
||||
tarHeader.checkSum = this.checkSum;
|
||||
tarHeader.linkFlag = this.linkFlag;
|
||||
tarHeader.linkName = this.linkName == null ? null : new StringBuffer(this.linkName.toString());
|
||||
tarHeader.magic = this.magic == null ? null : new StringBuffer(this.magic.toString());
|
||||
tarHeader.userName = this.userName == null ? null : new StringBuffer(this.userName.toString());
|
||||
tarHeader.groupName = this.groupName == null ? null : new StringBuffer(this.groupName.toString());
|
||||
tarHeader.devMajor = this.devMajor;
|
||||
tarHeader.devMinor = this.devMinor;
|
||||
}
|
||||
catch (CloneNotSupportedException cloneNotSupportedException) {
|
||||
cloneNotSupportedException.printStackTrace(System.err);
|
||||
}
|
||||
return tarHeader;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name.toString();
|
||||
}
|
||||
|
||||
public static long parseOctal(byte[] byArray, int n, int n2) throws InvalidHeaderException {
|
||||
long l = 0L;
|
||||
boolean bl = true;
|
||||
int n3 = n + n2;
|
||||
int n4 = n;
|
||||
while (n4 < n3) {
|
||||
if (byArray[n4] == 0) break;
|
||||
if (byArray[n4] == 32 || byArray[n4] == 48) {
|
||||
if (!bl) {
|
||||
if (byArray[n4] == 32) break;
|
||||
}
|
||||
} else {
|
||||
bl = false;
|
||||
l = (l << 3) + (long)(byArray[n4] - 48);
|
||||
}
|
||||
++n4;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
public static StringBuffer parseFileName(byte[] byArray) {
|
||||
int n;
|
||||
StringBuffer stringBuffer = new StringBuffer(256);
|
||||
if (byArray[345] != 0) {
|
||||
n = 345;
|
||||
while (n < 500 && byArray[n] != 0) {
|
||||
stringBuffer.append((char)byArray[n]);
|
||||
++n;
|
||||
}
|
||||
stringBuffer.append("/");
|
||||
}
|
||||
n = 0;
|
||||
while (n < 100 && byArray[n] != 0) {
|
||||
stringBuffer.append((char)byArray[n]);
|
||||
++n;
|
||||
}
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
public static StringBuffer parseName(byte[] byArray, int n, int n2) throws InvalidHeaderException {
|
||||
StringBuffer stringBuffer = new StringBuffer(n2);
|
||||
int n3 = n + n2;
|
||||
int n4 = n;
|
||||
while (n4 < n3) {
|
||||
if (byArray[n4] == 0) break;
|
||||
stringBuffer.append((char)byArray[n4]);
|
||||
++n4;
|
||||
}
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
public static int getFileNameBytes(String string, byte[] byArray) throws InvalidHeaderException {
|
||||
if (string.length() > 100) {
|
||||
int n = string.indexOf("/", string.length() - 100);
|
||||
if (n == -1) {
|
||||
throw new InvalidHeaderException("file name is greater than 100 characters, " + string);
|
||||
}
|
||||
String string2 = string.substring(n + 1);
|
||||
String string3 = string.substring(0, n);
|
||||
if (string3.length() > 155) {
|
||||
throw new InvalidHeaderException("file prefix is greater than 155 characters");
|
||||
}
|
||||
TarHeader.getNameBytes(new StringBuffer(string2), byArray, 0, 100);
|
||||
TarHeader.getNameBytes(new StringBuffer(string3), byArray, 345, 155);
|
||||
} else {
|
||||
TarHeader.getNameBytes(new StringBuffer(string), byArray, 0, 100);
|
||||
}
|
||||
return 100;
|
||||
}
|
||||
|
||||
public static int getNameBytes(StringBuffer stringBuffer, byte[] byArray, int n, int n2) {
|
||||
int n3 = 0;
|
||||
while (n3 < n2 && n3 < stringBuffer.length()) {
|
||||
byArray[n + n3] = (byte)stringBuffer.charAt(n3);
|
||||
++n3;
|
||||
}
|
||||
while (n3 < n2) {
|
||||
byArray[n + n3] = 0;
|
||||
++n3;
|
||||
}
|
||||
return n + n2;
|
||||
}
|
||||
|
||||
public static int getOctalBytes(long l, byte[] byArray, int n, int n2) {
|
||||
int n3 = n2 - 1;
|
||||
byArray[n + n3] = 0;
|
||||
byArray[n + --n3] = 32;
|
||||
--n3;
|
||||
if (l == 0L) {
|
||||
byArray[n + n3] = 48;
|
||||
--n3;
|
||||
} else {
|
||||
long l2 = l;
|
||||
while (n3 >= 0 && l2 > 0L) {
|
||||
byArray[n + n3] = (byte)(48 + (byte)(l2 & 7L));
|
||||
l2 >>= 3;
|
||||
--n3;
|
||||
}
|
||||
}
|
||||
while (n3 >= 0) {
|
||||
byArray[n + n3] = 32;
|
||||
--n3;
|
||||
}
|
||||
return n + n2;
|
||||
}
|
||||
|
||||
public static int getLongOctalBytes(long l, byte[] byArray, int n, int n2) {
|
||||
byte[] byArray2 = new byte[n2 + 1];
|
||||
TarHeader.getOctalBytes(l, byArray2, 0, n2 + 1);
|
||||
System.arraycopy(byArray2, 0, byArray, n, n2);
|
||||
return n + n2;
|
||||
}
|
||||
|
||||
public static int getCheckSumOctalBytes(long l, byte[] byArray, int n, int n2) {
|
||||
TarHeader.getOctalBytes(l, byArray, n, n2);
|
||||
byArray[n + n2 - 1] = 32;
|
||||
byArray[n + n2 - 2] = 0;
|
||||
return n + n2;
|
||||
}
|
||||
|
||||
public TarHeader() {
|
||||
this.name = new StringBuffer();
|
||||
this.linkName = new StringBuffer();
|
||||
String string = System.getProperty("user.name", "");
|
||||
if (string.length() > 31) {
|
||||
string = string.substring(0, 31);
|
||||
}
|
||||
this.userId = 0;
|
||||
this.groupId = 0;
|
||||
this.userName = new StringBuffer(string);
|
||||
this.groupName = new StringBuffer("");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import com.ice.tar.InvalidHeaderException;
|
||||
import com.ice.tar.TarBuffer;
|
||||
import com.ice.tar.TarEntry;
|
||||
import java.io.File;
|
||||
import java.io.FilterInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class TarInputStream
|
||||
extends FilterInputStream {
|
||||
protected boolean debug;
|
||||
protected boolean hasHitEOF;
|
||||
protected long entrySize;
|
||||
protected long entryOffset;
|
||||
protected byte[] oneBuf;
|
||||
protected byte[] readBuf;
|
||||
protected TarBuffer buffer;
|
||||
protected TarEntry currEntry;
|
||||
protected EntryFactory eFactory;
|
||||
|
||||
public void setDebug(boolean bl) {
|
||||
this.debug = bl;
|
||||
}
|
||||
|
||||
public void setEntryFactory(EntryFactory entryFactory) {
|
||||
this.eFactory = entryFactory;
|
||||
}
|
||||
|
||||
public void setBufferDebug(boolean bl) {
|
||||
this.buffer.setDebug(bl);
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
this.buffer.close();
|
||||
}
|
||||
|
||||
public int getRecordSize() {
|
||||
return this.buffer.getRecordSize();
|
||||
}
|
||||
|
||||
public int available() throws IOException {
|
||||
return (int)(this.entrySize - this.entryOffset);
|
||||
}
|
||||
|
||||
public long skip(long l) throws IOException {
|
||||
byte[] byArray = new byte[8192];
|
||||
long l2 = l;
|
||||
while (l2 > 0L) {
|
||||
int n = this.read(byArray, 0, l2 > (long)byArray.length ? byArray.length : (int)l2);
|
||||
if (n == -1) break;
|
||||
l2 -= (long)n;
|
||||
}
|
||||
return l - l2;
|
||||
}
|
||||
|
||||
public boolean markSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void mark(int n) {
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
public long getEntryPosition() {
|
||||
return this.entryOffset;
|
||||
}
|
||||
|
||||
public long getStreamPosition() {
|
||||
return this.buffer.getBlockSize() * this.buffer.getCurrentBlockNum() + this.buffer.getCurrentRecordNum();
|
||||
}
|
||||
|
||||
public TarEntry getNextEntry() throws IOException {
|
||||
byte[] byArray;
|
||||
if (this.hasHitEOF) {
|
||||
return null;
|
||||
}
|
||||
if (this.currEntry != null) {
|
||||
long l = this.entrySize - this.entryOffset;
|
||||
if (this.debug) {
|
||||
System.err.println("TarInputStream: SKIP currENTRY '" + this.currEntry.getName() + "' SZ " + this.entrySize + " OFF " + this.entryOffset + " skipping " + l + " bytes");
|
||||
}
|
||||
if (l > 0L) {
|
||||
this.skip(l);
|
||||
}
|
||||
this.readBuf = null;
|
||||
}
|
||||
if ((byArray = this.buffer.readRecord()) == null) {
|
||||
if (this.debug) {
|
||||
System.err.println("READ NULL RECORD");
|
||||
}
|
||||
this.hasHitEOF = true;
|
||||
} else if (this.buffer.isEOFRecord(byArray)) {
|
||||
if (this.debug) {
|
||||
System.err.println("READ EOF RECORD");
|
||||
}
|
||||
this.hasHitEOF = true;
|
||||
}
|
||||
if (this.hasHitEOF) {
|
||||
this.currEntry = null;
|
||||
} else {
|
||||
try {
|
||||
this.currEntry = this.eFactory == null ? new TarEntry(byArray) : this.eFactory.createEntry(byArray);
|
||||
if (this.debug) {
|
||||
System.err.println("TarInputStream: SET CURRENTRY '" + this.currEntry.getName() + "' size = " + this.currEntry.getSize());
|
||||
}
|
||||
this.entryOffset = 0L;
|
||||
this.entrySize = this.currEntry.getSize();
|
||||
}
|
||||
catch (InvalidHeaderException invalidHeaderException) {
|
||||
this.entrySize = 0L;
|
||||
this.entryOffset = 0L;
|
||||
this.currEntry = null;
|
||||
throw new InvalidHeaderException("bad header in block " + this.buffer.getCurrentBlockNum() + " record " + this.buffer.getCurrentRecordNum() + ", " + invalidHeaderException.getMessage());
|
||||
}
|
||||
}
|
||||
return this.currEntry;
|
||||
}
|
||||
|
||||
public int read() throws IOException {
|
||||
int n = this.read(this.oneBuf, 0, 1);
|
||||
if (n == -1) {
|
||||
return n;
|
||||
}
|
||||
return this.oneBuf[0];
|
||||
}
|
||||
|
||||
public int read(byte[] byArray) throws IOException {
|
||||
return this.read(byArray, 0, byArray.length);
|
||||
}
|
||||
|
||||
public int read(byte[] byArray, int n, int n2) throws IOException {
|
||||
int n3;
|
||||
int n4 = 0;
|
||||
if (this.entryOffset >= this.entrySize) {
|
||||
return -1;
|
||||
}
|
||||
if ((long)n2 + this.entryOffset > this.entrySize) {
|
||||
n2 = (int)(this.entrySize - this.entryOffset);
|
||||
}
|
||||
if (this.readBuf != null) {
|
||||
int n5 = n2 > this.readBuf.length ? this.readBuf.length : n2;
|
||||
System.arraycopy(this.readBuf, 0, byArray, n, n5);
|
||||
if (n5 >= this.readBuf.length) {
|
||||
this.readBuf = null;
|
||||
} else {
|
||||
n3 = this.readBuf.length - n5;
|
||||
byte[] byArray2 = new byte[n3];
|
||||
System.arraycopy(this.readBuf, n5, byArray2, 0, n3);
|
||||
this.readBuf = byArray2;
|
||||
}
|
||||
n4 += n5;
|
||||
n2 -= n5;
|
||||
n += n5;
|
||||
}
|
||||
while (n2 > 0) {
|
||||
byte[] byArray3 = this.buffer.readRecord();
|
||||
if (byArray3 == null) {
|
||||
throw new IOException("unexpected EOF with " + n2 + " bytes unread");
|
||||
}
|
||||
int n6 = byArray3.length;
|
||||
n3 = n2;
|
||||
if (n6 > n3) {
|
||||
System.arraycopy(byArray3, 0, byArray, n, n3);
|
||||
this.readBuf = new byte[n6 - n3];
|
||||
System.arraycopy(byArray3, n3, this.readBuf, 0, n6 - n3);
|
||||
} else {
|
||||
n3 = n6;
|
||||
System.arraycopy(byArray3, 0, byArray, n, n6);
|
||||
}
|
||||
n4 += n3;
|
||||
n2 -= n3;
|
||||
n += n3;
|
||||
}
|
||||
this.entryOffset += (long)n4;
|
||||
return n4;
|
||||
}
|
||||
|
||||
public void copyEntryContents(OutputStream outputStream) throws IOException {
|
||||
int n;
|
||||
byte[] byArray = new byte[32768];
|
||||
while ((n = this.read(byArray, 0, byArray.length)) != -1) {
|
||||
outputStream.write(byArray, 0, n);
|
||||
}
|
||||
}
|
||||
|
||||
public TarInputStream(InputStream inputStream) {
|
||||
this(inputStream, 10240, 512);
|
||||
}
|
||||
|
||||
public TarInputStream(InputStream inputStream, int n) {
|
||||
this(inputStream, n, 512);
|
||||
}
|
||||
|
||||
public TarInputStream(InputStream inputStream, int n, int n2) {
|
||||
super(inputStream);
|
||||
this.buffer = new TarBuffer(inputStream, n, n2);
|
||||
this.readBuf = null;
|
||||
this.oneBuf = new byte[1];
|
||||
this.debug = false;
|
||||
this.hasHitEOF = false;
|
||||
this.eFactory = null;
|
||||
}
|
||||
|
||||
public static interface EntryFactory {
|
||||
public TarEntry createEntry(String var1);
|
||||
|
||||
public TarEntry createEntry(File var1) throws InvalidHeaderException;
|
||||
|
||||
public TarEntry createEntry(byte[] var1) throws InvalidHeaderException;
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class EntryAdapter
|
||||
implements EntryFactory {
|
||||
public TarEntry createEntry(String string) {
|
||||
return new TarEntry(string);
|
||||
}
|
||||
|
||||
public TarEntry createEntry(File file) throws InvalidHeaderException {
|
||||
return new TarEntry(file);
|
||||
}
|
||||
|
||||
public TarEntry createEntry(byte[] byArray) throws InvalidHeaderException {
|
||||
return new TarEntry(byArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import com.ice.tar.InvalidHeaderException;
|
||||
import com.ice.tar.TarBuffer;
|
||||
import com.ice.tar.TarEntry;
|
||||
import java.io.FilterOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class TarOutputStream
|
||||
extends FilterOutputStream {
|
||||
protected boolean debug;
|
||||
protected long currSize;
|
||||
protected long currBytes;
|
||||
protected byte[] oneBuf;
|
||||
protected byte[] recordBuf;
|
||||
protected int assemLen;
|
||||
protected byte[] assemBuf;
|
||||
protected TarBuffer buffer;
|
||||
|
||||
public void setDebug(boolean bl) {
|
||||
this.debug = bl;
|
||||
}
|
||||
|
||||
public void setBufferDebug(boolean bl) {
|
||||
this.buffer.setDebug(bl);
|
||||
}
|
||||
|
||||
public void finish() throws IOException {
|
||||
this.writeEOFRecord();
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
this.finish();
|
||||
this.buffer.close();
|
||||
}
|
||||
|
||||
public int getRecordSize() {
|
||||
return this.buffer.getRecordSize();
|
||||
}
|
||||
|
||||
public void putNextEntry(TarEntry tarEntry) throws IOException {
|
||||
StringBuffer stringBuffer = tarEntry.getHeader().name;
|
||||
if (tarEntry.isUnixTarFormat() && stringBuffer.length() > 100 || !tarEntry.isUnixTarFormat() && stringBuffer.length() > 255) {
|
||||
throw new InvalidHeaderException("file name '" + stringBuffer + "' is too long ( " + stringBuffer.length() + " > " + (tarEntry.isUnixTarFormat() ? 100 : 255) + " bytes )");
|
||||
}
|
||||
tarEntry.writeEntryHeader(this.recordBuf);
|
||||
this.buffer.writeRecord(this.recordBuf);
|
||||
this.currBytes = 0L;
|
||||
this.currSize = tarEntry.isDirectory() ? 0L : tarEntry.getSize();
|
||||
}
|
||||
|
||||
public void closeEntry() throws IOException {
|
||||
if (this.assemLen > 0) {
|
||||
int n = this.assemLen;
|
||||
while (n < this.assemBuf.length) {
|
||||
this.assemBuf[n] = 0;
|
||||
++n;
|
||||
}
|
||||
this.buffer.writeRecord(this.assemBuf);
|
||||
this.currBytes += (long)this.assemLen;
|
||||
this.assemLen = 0;
|
||||
}
|
||||
if (this.currBytes < this.currSize) {
|
||||
throw new IOException("entry closed at '" + this.currBytes + "' before the '" + this.currSize + "' bytes specified in the header were written");
|
||||
}
|
||||
}
|
||||
|
||||
public void write(int n) throws IOException {
|
||||
this.oneBuf[0] = (byte)n;
|
||||
this.write(this.oneBuf, 0, 1);
|
||||
}
|
||||
|
||||
public void write(byte[] byArray) throws IOException {
|
||||
this.write(byArray, 0, byArray.length);
|
||||
}
|
||||
|
||||
public void write(byte[] byArray, int n, int n2) throws IOException {
|
||||
if (this.currBytes + (long)n2 > this.currSize) {
|
||||
throw new IOException("request to write '" + n2 + "' bytes exceeds size in header of '" + this.currSize + "' bytes");
|
||||
}
|
||||
if (this.assemLen > 0) {
|
||||
if (this.assemLen + n2 >= this.recordBuf.length) {
|
||||
int n3 = this.recordBuf.length - this.assemLen;
|
||||
System.arraycopy(this.assemBuf, 0, this.recordBuf, 0, this.assemLen);
|
||||
System.arraycopy(byArray, n, this.recordBuf, this.assemLen, n3);
|
||||
this.buffer.writeRecord(this.recordBuf);
|
||||
this.currBytes += (long)this.recordBuf.length;
|
||||
n += n3;
|
||||
n2 -= n3;
|
||||
this.assemLen = 0;
|
||||
} else {
|
||||
System.arraycopy(byArray, n, this.assemBuf, this.assemLen, n2);
|
||||
n += n2;
|
||||
this.assemLen += n2;
|
||||
n2 -= n2;
|
||||
}
|
||||
}
|
||||
while (n2 > 0) {
|
||||
if (n2 < this.recordBuf.length) {
|
||||
System.arraycopy(byArray, n, this.assemBuf, this.assemLen, n2);
|
||||
this.assemLen += n2;
|
||||
break;
|
||||
}
|
||||
this.buffer.writeRecord(byArray, n);
|
||||
long l = this.recordBuf.length;
|
||||
this.currBytes += l;
|
||||
n2 = (int)((long)n2 - l);
|
||||
n = (int)((long)n + l);
|
||||
}
|
||||
}
|
||||
|
||||
private final void writeEOFRecord() throws IOException {
|
||||
int n = 0;
|
||||
while (n < this.recordBuf.length) {
|
||||
this.recordBuf[n] = 0;
|
||||
++n;
|
||||
}
|
||||
this.buffer.writeRecord(this.recordBuf);
|
||||
}
|
||||
|
||||
public TarOutputStream(OutputStream outputStream) {
|
||||
this(outputStream, 10240, 512);
|
||||
}
|
||||
|
||||
public TarOutputStream(OutputStream outputStream, int n) {
|
||||
this(outputStream, n, 512);
|
||||
}
|
||||
|
||||
public TarOutputStream(OutputStream outputStream, int n, int n2) {
|
||||
super(outputStream);
|
||||
this.buffer = new TarBuffer(outputStream, n, n2);
|
||||
this.debug = false;
|
||||
this.assemLen = 0;
|
||||
this.assemBuf = new byte[n2];
|
||||
this.recordBuf = new byte[n2];
|
||||
this.oneBuf = new byte[1];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
public interface TarProgressDisplay {
|
||||
public void showTarProgressMessage(String var1);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class TarTransFileTyper {
|
||||
public boolean isAsciiFile(File file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isAsciiFile(String string) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,312 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import com.ice.tar.InvalidHeaderException;
|
||||
import com.ice.tar.TarArchive;
|
||||
import com.ice.tar.TarEntry;
|
||||
import com.ice.tar.TarProgressDisplay;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
public class tar
|
||||
implements TarProgressDisplay {
|
||||
private boolean debug = false;
|
||||
private boolean verbose = false;
|
||||
private boolean compressed = false;
|
||||
private boolean listingArchive = false;
|
||||
private boolean writingArchive = true;
|
||||
private boolean unixArchiveFormat = false;
|
||||
private boolean keepOldFiles = false;
|
||||
private boolean asciiTranslate = false;
|
||||
private String archiveName = null;
|
||||
private int blockSize = 10240;
|
||||
private int userId;
|
||||
private String userName;
|
||||
private int groupId;
|
||||
private String groupName;
|
||||
|
||||
public static void main(String[] stringArray) {
|
||||
tar tar2 = new tar();
|
||||
tar2.instanceMain(stringArray);
|
||||
}
|
||||
|
||||
public void instanceMain(String[] stringArray) {
|
||||
Object object;
|
||||
Object object2;
|
||||
TarArchive tarArchive = null;
|
||||
int n = this.processArguments(stringArray);
|
||||
if (this.writingArchive) {
|
||||
object2 = System.out;
|
||||
if (this.archiveName != null && !this.archiveName.equals("-")) {
|
||||
try {
|
||||
object2 = new FileOutputStream(this.archiveName);
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
object2 = null;
|
||||
iOException.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
if (object2 != null) {
|
||||
if (this.compressed) {
|
||||
try {
|
||||
object2 = new GZIPOutputStream((OutputStream)object2);
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
object2 = null;
|
||||
iOException.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
tarArchive = new TarArchive((OutputStream)object2, this.blockSize);
|
||||
}
|
||||
} else {
|
||||
object2 = System.in;
|
||||
if (this.archiveName != null && !this.archiveName.equals("-")) {
|
||||
try {
|
||||
object2 = new FileInputStream(this.archiveName);
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
object2 = null;
|
||||
iOException.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
if (object2 != null) {
|
||||
if (this.compressed) {
|
||||
try {
|
||||
object2 = new GZIPInputStream((InputStream)object2);
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
object2 = null;
|
||||
iOException.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
tarArchive = new TarArchive((InputStream)object2, this.blockSize);
|
||||
}
|
||||
}
|
||||
if (tarArchive != null) {
|
||||
tarArchive.setDebug(this.debug);
|
||||
tarArchive.setVerbose(this.verbose);
|
||||
tarArchive.setTarProgressDisplay(this);
|
||||
tarArchive.setKeepOldFiles(this.keepOldFiles);
|
||||
tarArchive.setAsciiTranslation(this.asciiTranslate);
|
||||
tarArchive.setUserInfo(this.userId, this.userName, this.groupId, this.groupName);
|
||||
}
|
||||
if (tarArchive == null) {
|
||||
System.err.println("no processing due to errors");
|
||||
} else if (this.writingArchive) {
|
||||
while (n < stringArray.length) {
|
||||
try {
|
||||
object2 = new File(stringArray[n]);
|
||||
object = new TarEntry((File)object2);
|
||||
if (this.unixArchiveFormat) {
|
||||
((TarEntry)object).setUnixTarFormat();
|
||||
} else {
|
||||
((TarEntry)object).setUSTarFormat();
|
||||
}
|
||||
tarArchive.writeEntry((TarEntry)object, true);
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
iOException.printStackTrace(System.err);
|
||||
}
|
||||
++n;
|
||||
}
|
||||
} else if (this.listingArchive) {
|
||||
try {
|
||||
tarArchive.listContents();
|
||||
}
|
||||
catch (InvalidHeaderException invalidHeaderException) {
|
||||
invalidHeaderException.printStackTrace(System.err);
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
iOException.printStackTrace(System.err);
|
||||
}
|
||||
} else {
|
||||
object2 = System.getProperty("user.dir", null);
|
||||
object = new File((String)object2);
|
||||
if (!((File)object).exists()) {
|
||||
if (!((File)object).mkdirs()) {
|
||||
Throwable throwable = new Throwable("ERROR, mkdirs() on '" + ((File)object).getPath() + "' returned false.");
|
||||
throwable.printStackTrace(System.err);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
tarArchive.extractContents((File)object);
|
||||
}
|
||||
catch (InvalidHeaderException invalidHeaderException) {
|
||||
invalidHeaderException.printStackTrace(System.err);
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
iOException.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tarArchive != null) {
|
||||
try {
|
||||
tarArchive.closeArchive();
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
iOException.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final int processArguments(String[] stringArray) {
|
||||
int n = 0;
|
||||
boolean bl = false;
|
||||
while (n < stringArray.length) {
|
||||
String string = stringArray[n];
|
||||
if (!string.startsWith("-")) break;
|
||||
if (string.startsWith("--")) {
|
||||
if (string.equals("--usage")) {
|
||||
this.usage();
|
||||
System.exit(1);
|
||||
} else if (string.equals("--version")) {
|
||||
this.version();
|
||||
System.exit(1);
|
||||
} else {
|
||||
System.err.println("unknown option: " + string);
|
||||
this.usage();
|
||||
System.exit(1);
|
||||
}
|
||||
} else {
|
||||
int n2 = 1;
|
||||
while (n2 < string.length()) {
|
||||
char c = string.charAt(n2);
|
||||
if (c == '?') {
|
||||
this.usage();
|
||||
System.exit(1);
|
||||
} else if (c == 'f') {
|
||||
this.archiveName = stringArray[++n];
|
||||
} else if (c == 'z') {
|
||||
this.compressed = true;
|
||||
} else if (c == 'c') {
|
||||
bl = true;
|
||||
this.writingArchive = true;
|
||||
this.listingArchive = false;
|
||||
} else if (c == 'x') {
|
||||
bl = true;
|
||||
this.writingArchive = false;
|
||||
this.listingArchive = false;
|
||||
} else if (c == 't') {
|
||||
bl = true;
|
||||
this.writingArchive = false;
|
||||
this.listingArchive = true;
|
||||
} else if (c == 'k') {
|
||||
this.keepOldFiles = true;
|
||||
} else if (c == 'o') {
|
||||
this.unixArchiveFormat = true;
|
||||
} else if (c == 'b') {
|
||||
try {
|
||||
int n3 = Integer.parseInt(stringArray[++n]);
|
||||
this.blockSize = n3 * 512;
|
||||
}
|
||||
catch (NumberFormatException numberFormatException) {
|
||||
numberFormatException.printStackTrace(System.err);
|
||||
}
|
||||
} else if (c == 'u') {
|
||||
this.userName = stringArray[++n];
|
||||
} else if (c == 'U') {
|
||||
String string2 = stringArray[++n];
|
||||
try {
|
||||
this.userId = Integer.parseInt(string2);
|
||||
}
|
||||
catch (NumberFormatException numberFormatException) {
|
||||
this.userId = 0;
|
||||
numberFormatException.printStackTrace(System.err);
|
||||
}
|
||||
} else if (c == 'g') {
|
||||
this.groupName = stringArray[++n];
|
||||
} else if (c == 'G') {
|
||||
String string3 = stringArray[++n];
|
||||
try {
|
||||
this.groupId = Integer.parseInt(string3);
|
||||
}
|
||||
catch (NumberFormatException numberFormatException) {
|
||||
this.groupId = 0;
|
||||
numberFormatException.printStackTrace(System.err);
|
||||
}
|
||||
} else if (c == 'v') {
|
||||
this.verbose = true;
|
||||
} else if (c == 'D') {
|
||||
this.debug = true;
|
||||
} else {
|
||||
System.err.println("unknown option: " + c);
|
||||
this.usage();
|
||||
System.exit(1);
|
||||
}
|
||||
++n2;
|
||||
}
|
||||
}
|
||||
++n;
|
||||
}
|
||||
if (!bl) {
|
||||
System.err.println("you must specify an operation option (c, x, or t)");
|
||||
this.usage();
|
||||
System.exit(1);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
public void showTarProgressMessage(String string) {
|
||||
System.out.println(string);
|
||||
}
|
||||
|
||||
private final void version() {
|
||||
System.err.println("Release 2.4 - $Revision: 3$ $Name: $");
|
||||
}
|
||||
|
||||
private final void usage() {
|
||||
System.err.println("usage: com.ice.tar.tar has three basic modes:");
|
||||
System.err.println(" com.ice.tar -c [options] archive files...");
|
||||
System.err.println(" Create new archive containing files.");
|
||||
System.err.println(" com.ice.tar -t [options] archive");
|
||||
System.err.println(" List contents of tar archive");
|
||||
System.err.println(" com.ice.tar -x [options] archive");
|
||||
System.err.println(" Extract contents of tar archive.");
|
||||
System.err.println("");
|
||||
System.err.println("options:");
|
||||
System.err.println(" -f file, use 'file' as the tar archive");
|
||||
System.err.println(" -v, verbose mode");
|
||||
System.err.println(" -z, use GZIP compression");
|
||||
System.err.println(" -D, debug archive and buffer operation");
|
||||
System.err.println(" -b blks, set blocking size to (blks * 512) bytes");
|
||||
System.err.println(" -o, write a V7 format archive rather than ANSI");
|
||||
System.err.println(" -u name, set user name to 'name'");
|
||||
System.err.println(" -U id, set user id to 'id'");
|
||||
System.err.println(" -g name, set group name to 'name'");
|
||||
System.err.println(" -G id, set group id to 'id'");
|
||||
System.err.println(" -?, print usage information");
|
||||
System.err.println(" --trans, translate 'text/*' files");
|
||||
System.err.println(" --mime file, use this mime types file and translate");
|
||||
System.err.println(" --usage, print usage information");
|
||||
System.err.println(" --version, print version information");
|
||||
System.err.println("");
|
||||
System.err.println("The translation options will translate from local line");
|
||||
System.err.println("endings to UNIX line endings of '\\n' when writing tar");
|
||||
System.err.println("archives, and from UNIX line endings into local line endings");
|
||||
System.err.println("when extracting archives.");
|
||||
System.err.println("");
|
||||
System.err.println("Written by Tim Endres");
|
||||
System.err.println("");
|
||||
System.err.println("This software has been placed into the public domain.");
|
||||
System.err.println("");
|
||||
this.version();
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
public tar() {
|
||||
String string = System.getProperty("user.name");
|
||||
this.userId = 0;
|
||||
this.userName = string == null ? "" : string;
|
||||
this.groupId = 0;
|
||||
this.groupName = "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.BajaRuntimeException
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.ServiceNotFoundException
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.ICoalesceable
|
||||
* javax.baja.util.IFuture
|
||||
* javax.baja.util.Invocation
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import com.tridium.alarm.CoalesceUuidOnlyInvocation;
|
||||
import javax.baja.alarm.BAlarmClass;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.BajaRuntimeException;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.ServiceNotFoundException;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.ICoalesceable;
|
||||
import javax.baja.util.IFuture;
|
||||
import javax.baja.util.Invocation;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class AlarmClassRouteAlarmInvocation
|
||||
extends Invocation
|
||||
implements IFuture {
|
||||
protected Exception exception;
|
||||
protected boolean finished;
|
||||
|
||||
public static AlarmClassRouteAlarmInvocation make(BComponent bComponent, Action action, BAlarmRecord bAlarmRecord, Context context) {
|
||||
try {
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
if (bAlarmService.getCoalesceAlarms()) {
|
||||
return new AlarmClassRouteAlarmInvocation(bComponent, action, bAlarmRecord, context);
|
||||
}
|
||||
return new CoalesceUuidOnlyInvocation(bComponent, action, bAlarmRecord, context);
|
||||
}
|
||||
catch (ServiceNotFoundException serviceNotFoundException) {
|
||||
return new AlarmClassRouteAlarmInvocation(bComponent, action, bAlarmRecord, context);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean equals(Object object) {
|
||||
if (object instanceof AlarmClassRouteAlarmInvocation) {
|
||||
AlarmClassRouteAlarmInvocation alarmClassRouteAlarmInvocation = (AlarmClassRouteAlarmInvocation)((Object)object);
|
||||
if (this.argument != null) {
|
||||
boolean bl = false;
|
||||
if (this.instance == alarmClassRouteAlarmInvocation.instance && this.action == alarmClassRouteAlarmInvocation.action && ((BAlarmRecord)this.argument).getUuid().equals((Object)((BAlarmRecord)alarmClassRouteAlarmInvocation.argument).getUuid())) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
boolean bl = false;
|
||||
if (this.instance == alarmClassRouteAlarmInvocation.instance && this.action == alarmClassRouteAlarmInvocation.action) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ICoalesceable coalesce(ICoalesceable iCoalesceable) {
|
||||
this.finished = true;
|
||||
return iCoalesceable;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
public void run() throws BajaRuntimeException {
|
||||
try {
|
||||
try {
|
||||
if (this.action != BAlarmClass.routeAlarm) {
|
||||
super.run();
|
||||
Object var2_1 = null;
|
||||
this.finished = true;
|
||||
return;
|
||||
}
|
||||
((BAlarmClass)this.instance).doRouteAlarm((BAlarmRecord)this.argument);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (exception instanceof BajaRuntimeException) {
|
||||
this.exception = (Exception)((BajaRuntimeException)exception).getCause();
|
||||
throw (BajaRuntimeException)exception;
|
||||
}
|
||||
this.exception = exception;
|
||||
throw new BajaRuntimeException((Throwable)exception);
|
||||
}
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
Object var2_2 = null;
|
||||
this.finished = true;
|
||||
throw throwable;
|
||||
}
|
||||
{
|
||||
Object var2_3 = null;
|
||||
this.finished = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFinished() {
|
||||
return this.finished;
|
||||
}
|
||||
|
||||
public boolean success() throws Exception {
|
||||
if (!this.finished) {
|
||||
throw new Exception("Invocation not finished");
|
||||
}
|
||||
boolean bl = false;
|
||||
if (this.exception == null) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public Exception getException() {
|
||||
return this.exception;
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.exception = null;
|
||||
this.finished = false;
|
||||
}
|
||||
|
||||
public AlarmClassRouteAlarmInvocation(BAlarmClass bAlarmClass, BAlarmRecord bAlarmRecord, Context context) {
|
||||
this(bAlarmClass, BAlarmClass.routeAlarm, bAlarmRecord, context);
|
||||
}
|
||||
|
||||
public AlarmClassRouteAlarmInvocation(BComponent bComponent, Action action, BAlarmRecord bAlarmRecord, Context context) {
|
||||
super(bComponent, action, (BValue)bAlarmRecord, context);
|
||||
this.this();
|
||||
if (bAlarmRecord != null) {
|
||||
this.hashCode ^= bAlarmRecord.getUuid().hashCode();
|
||||
}
|
||||
this.finished = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BFacets
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import javax.baja.sys.BFacets;
|
||||
|
||||
public class AlarmColumnSpec {
|
||||
public final String name;
|
||||
public final String displayName;
|
||||
public final BFacets facets;
|
||||
|
||||
public void write(DataOutput dataOutput) throws IOException {
|
||||
dataOutput.writeUTF(this.name);
|
||||
dataOutput.writeUTF(this.displayName);
|
||||
if (this.facets.isNull()) {
|
||||
dataOutput.writeBoolean(false);
|
||||
} else {
|
||||
dataOutput.writeBoolean(true);
|
||||
dataOutput.writeUTF(this.facets.encodeToString());
|
||||
}
|
||||
}
|
||||
|
||||
public static AlarmColumnSpec read(DataInput dataInput) throws IOException {
|
||||
String string = dataInput.readUTF();
|
||||
String string2 = dataInput.readUTF();
|
||||
boolean bl = dataInput.readBoolean();
|
||||
BFacets bFacets = null;
|
||||
if (bl) {
|
||||
bFacets = (BFacets)BFacets.DEFAULT.decodeFromString(dataInput.readUTF());
|
||||
}
|
||||
return new AlarmColumnSpec(string, string2, bFacets);
|
||||
}
|
||||
|
||||
public AlarmColumnSpec(String string, String string2, BFacets bFacets) {
|
||||
this.name = string;
|
||||
this.displayName = string2;
|
||||
this.facets = bFacets == null ? BFacets.NULL : bFacets;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class AlarmInput {
|
||||
private DataInput in;
|
||||
private BAlarmRecord rec;
|
||||
private boolean unique;
|
||||
|
||||
public void setUniqueRecords(boolean bl) {
|
||||
this.unique = bl;
|
||||
}
|
||||
|
||||
public BAlarmRecord read() throws IOException {
|
||||
BAlarmRecord bAlarmRecord = null;
|
||||
boolean bl = this.in.readBoolean();
|
||||
if (!bl) {
|
||||
return null;
|
||||
}
|
||||
if (this.unique) {
|
||||
bAlarmRecord = new BAlarmRecord();
|
||||
} else {
|
||||
if (this.rec == null) {
|
||||
this.rec = new BAlarmRecord();
|
||||
}
|
||||
bAlarmRecord = this.rec;
|
||||
}
|
||||
try {
|
||||
bAlarmRecord.read(this.in);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
System.out.println("? end of input ?");
|
||||
exception.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return bAlarmRecord;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (this.in instanceof InputStream) {
|
||||
try {
|
||||
((InputStream)((Object)this.in)).close();
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.unique = true;
|
||||
}
|
||||
|
||||
public AlarmInput(DataInput dataInput) throws IOException {
|
||||
this.this();
|
||||
this.in = dataInput;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import com.tridium.alarm.AlarmInput;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class AlarmInputCursor
|
||||
implements Cursor {
|
||||
private Context cx;
|
||||
private AlarmInput in;
|
||||
private boolean init;
|
||||
private BAlarmRecord rec;
|
||||
private boolean closeOnComplete;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
|
||||
public void setCloseOnComplete(boolean bl) {
|
||||
this.closeOnComplete = bl;
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
return this.cx;
|
||||
}
|
||||
|
||||
public BObject get() {
|
||||
if (this.init) {
|
||||
throw new IllegalStateException("get() before next()");
|
||||
}
|
||||
return this.rec;
|
||||
}
|
||||
|
||||
public boolean next() {
|
||||
this.init = false;
|
||||
try {
|
||||
this.rec = this.in.read();
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
if (this.closeOnComplete && this.rec == null) {
|
||||
this.in.close();
|
||||
}
|
||||
boolean bl = false;
|
||||
if (this.rec != null) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public boolean nextComponent() {
|
||||
if (this.closeOnComplete) {
|
||||
this.in.close();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean next(Class clazz) {
|
||||
Class clazz2 = class$javax$baja$alarm$BAlarmRecord;
|
||||
if (clazz2 == null) {
|
||||
clazz2 = class$javax$baja$alarm$BAlarmRecord = AlarmInputCursor.class("[Ljavax.baja.alarm.BAlarmRecord;", false);
|
||||
}
|
||||
if (clazz2.isAssignableFrom(clazz)) {
|
||||
return this.next();
|
||||
}
|
||||
if (this.closeOnComplete) {
|
||||
this.in.close();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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.init = true;
|
||||
this.closeOnComplete = true;
|
||||
}
|
||||
|
||||
public AlarmInputCursor(AlarmInput alarmInput, Context context) {
|
||||
this.this();
|
||||
this.in = alarmInput;
|
||||
this.cx = context;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.collection.BITable
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.collection.BITable;
|
||||
|
||||
public class AlarmOutput {
|
||||
private DataOutputStream out;
|
||||
|
||||
public void write(BAlarmRecord bAlarmRecord) throws IOException {
|
||||
this.out.writeBoolean(true);
|
||||
bAlarmRecord.write(this.out);
|
||||
}
|
||||
|
||||
public void flush() throws IOException {
|
||||
this.out.flush();
|
||||
}
|
||||
|
||||
public void close() {
|
||||
try {
|
||||
this.out.writeBoolean(false);
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
try {
|
||||
this.out.close();
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
}
|
||||
|
||||
public AlarmOutput(BITable bITable, DataOutputStream dataOutputStream) {
|
||||
this.out = dataOutputStream;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.bql.collection.BqlColumn
|
||||
* javax.baja.collection.BITable
|
||||
* javax.baja.collection.Column
|
||||
* javax.baja.collection.TableCursor
|
||||
* javax.baja.nre.util.IFilter
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import com.tridium.bql.collection.BqlColumn;
|
||||
import javax.baja.collection.BITable;
|
||||
import javax.baja.collection.Column;
|
||||
import javax.baja.collection.TableCursor;
|
||||
import javax.baja.nre.util.IFilter;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
|
||||
public class AlarmTableCursor
|
||||
implements TableCursor {
|
||||
private BITable table;
|
||||
private Cursor inner;
|
||||
private IFilter filter;
|
||||
private Context context;
|
||||
|
||||
/*
|
||||
* Unable to fully structure code
|
||||
*/
|
||||
public boolean next() {
|
||||
if (this.filter != null) ** GOTO lbl6
|
||||
return this.inner.next();
|
||||
lbl-1000:
|
||||
// 1 sources
|
||||
|
||||
{
|
||||
var1_1 = this.inner.get();
|
||||
if (!this.filter.accept((Object)var1_1)) continue;
|
||||
return true;
|
||||
lbl6:
|
||||
// 2 sources
|
||||
|
||||
** while (this.inner.next())
|
||||
}
|
||||
lbl7:
|
||||
// 1 sources
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unable to fully structure code
|
||||
*/
|
||||
public boolean next(Class var1_1) {
|
||||
if (this.filter != null) ** GOTO lbl6
|
||||
return this.inner.next(var1_1);
|
||||
lbl-1000:
|
||||
// 1 sources
|
||||
|
||||
{
|
||||
var2_2 = this.inner.get();
|
||||
if (!this.filter.accept((Object)var2_2)) continue;
|
||||
return true;
|
||||
lbl6:
|
||||
// 2 sources
|
||||
|
||||
** while (this.inner.next((Class)var1_1))
|
||||
}
|
||||
lbl7:
|
||||
// 1 sources
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unable to fully structure code
|
||||
*/
|
||||
public boolean nextComponent() {
|
||||
if (this.filter != null) ** GOTO lbl6
|
||||
return this.inner.nextComponent();
|
||||
lbl-1000:
|
||||
// 1 sources
|
||||
|
||||
{
|
||||
var1_1 = this.inner.get();
|
||||
if (!this.filter.accept((Object)var1_1)) continue;
|
||||
return true;
|
||||
lbl6:
|
||||
// 2 sources
|
||||
|
||||
** while (this.inner.nextComponent())
|
||||
}
|
||||
lbl7:
|
||||
// 1 sources
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public BITable getTable() {
|
||||
return this.table;
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
return this.inner.getContext();
|
||||
}
|
||||
|
||||
public BObject get() {
|
||||
return this.inner.get();
|
||||
}
|
||||
|
||||
public BObject get(Column column) {
|
||||
return ((BqlColumn)column).get(this.inner.get());
|
||||
}
|
||||
|
||||
public String getString(Column column) {
|
||||
return ((BqlColumn)column).getString(this.inner.get());
|
||||
}
|
||||
|
||||
public float getFloat(Column column) {
|
||||
return ((BqlColumn)column).getFloat(this.inner.get());
|
||||
}
|
||||
|
||||
public double getDouble(Column column) {
|
||||
return ((BqlColumn)column).getDouble(this.inner.get());
|
||||
}
|
||||
|
||||
public int getInt(Column column) {
|
||||
return ((BqlColumn)column).getInt(this.inner.get());
|
||||
}
|
||||
|
||||
public long getLong(Column column) {
|
||||
return ((BqlColumn)column).getLong(this.inner.get());
|
||||
}
|
||||
|
||||
public boolean getBoolean(Column column) {
|
||||
return ((BqlColumn)column).getBoolean(this.inner.get());
|
||||
}
|
||||
|
||||
public int getFlags(Column column) {
|
||||
return ((BqlColumn)column).getFlags(this.inner.get());
|
||||
}
|
||||
|
||||
public BFacets getFacets(Column column) {
|
||||
return ((BqlColumn)column).getFacets(this.inner.get());
|
||||
}
|
||||
|
||||
public AlarmTableCursor(BITable bITable, Cursor cursor) {
|
||||
this.table = bITable;
|
||||
this.inner = cursor;
|
||||
}
|
||||
|
||||
public AlarmTableCursor(BITable bITable, Cursor cursor, IFilter iFilter) {
|
||||
this.table = bITable;
|
||||
this.inner = cursor;
|
||||
this.filter = iFilter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.nre.util.SortUtil
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.util.BObjectArrayCursor
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmSource;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.nre.util.SortUtil;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.util.BObjectArrayCursor;
|
||||
|
||||
public class AlarmsToSourcesCursor
|
||||
implements Cursor {
|
||||
private Cursor alarms;
|
||||
private Cursor sources;
|
||||
|
||||
public BObject get() {
|
||||
return this.sources.get();
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
return this.alarms.getContext();
|
||||
}
|
||||
|
||||
public boolean next() {
|
||||
if (this.sources == null) {
|
||||
this.sources = this.load();
|
||||
}
|
||||
return this.sources.next();
|
||||
}
|
||||
|
||||
private final Cursor load() {
|
||||
BObject[] bObjectArray;
|
||||
HashMap<BOrdList, BAlarmSource> hashMap = new HashMap<BOrdList, BAlarmSource>();
|
||||
while (this.alarms.next()) {
|
||||
bObjectArray = (BObject[])this.alarms.get();
|
||||
BOrdList bOrdList = bObjectArray.getSource();
|
||||
BAlarmSource bAlarmSource = (BAlarmSource)((Object)hashMap.get(bOrdList));
|
||||
if (bAlarmSource == null) {
|
||||
bAlarmSource = new BAlarmSource(bOrdList, (BAlarmRecord)bObjectArray.newCopy(true));
|
||||
hashMap.put(bOrdList, bAlarmSource);
|
||||
continue;
|
||||
}
|
||||
if (!bObjectArray.getTimestamp().isAfter(bAlarmSource.getCurrentAlarm().getTimestamp())) continue;
|
||||
bAlarmSource.setCurrentAlarm((BAlarmRecord)bObjectArray.newCopy(true));
|
||||
}
|
||||
bObjectArray = hashMap.values().toArray(new BAlarmSource[hashMap.size()]);
|
||||
SortUtil.sort((Object[])bObjectArray, (Object[])bObjectArray, (Comparator)new BAlarmSource.SourceComparator());
|
||||
return new BObjectArrayCursor(bObjectArray, this.alarms.getContext());
|
||||
}
|
||||
|
||||
public boolean next(Class clazz) {
|
||||
while (this.next()) {
|
||||
BObject bObject = this.get();
|
||||
if (!clazz.isInstance(bObject)) continue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean nextComponent() {
|
||||
while (this.next()) {
|
||||
BObject bObject = this.get();
|
||||
if (!bObject.isComponent()) continue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public AlarmsToSourcesCursor(Cursor cursor) {
|
||||
this.alarms = cursor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,455 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.fox.message.FoxMessage
|
||||
* com.tridium.fox.message.FoxTuple
|
||||
* com.tridium.fox.session.FoxRequest
|
||||
* com.tridium.fox.session.FoxResponse
|
||||
* com.tridium.fox.session.InvalidCommandException
|
||||
* com.tridium.fox.sys.BFoxChannel
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.nre.util.Array
|
||||
* javax.baja.security.BIProtected
|
||||
* javax.baja.security.BPermissions
|
||||
* javax.baja.security.PermissionException
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.ServiceNotFoundException
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.user.BUser
|
||||
* javax.baja.util.IFuture
|
||||
* javax.baja.util.Invocation
|
||||
* javax.baja.util.Queue
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import com.tridium.alarm.BConsoleRecipient;
|
||||
import com.tridium.alarm.fox.FoxAlarmCodec;
|
||||
import com.tridium.fox.message.FoxMessage;
|
||||
import com.tridium.fox.message.FoxTuple;
|
||||
import com.tridium.fox.session.FoxRequest;
|
||||
import com.tridium.fox.session.FoxResponse;
|
||||
import com.tridium.fox.session.InvalidCommandException;
|
||||
import com.tridium.fox.sys.BFoxChannel;
|
||||
import javax.baja.alarm.BAckState;
|
||||
import javax.baja.alarm.BAlarmClass;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.nre.util.Array;
|
||||
import javax.baja.security.BIProtected;
|
||||
import javax.baja.security.BPermissions;
|
||||
import javax.baja.security.PermissionException;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.ServiceNotFoundException;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.user.BUser;
|
||||
import javax.baja.util.IFuture;
|
||||
import javax.baja.util.Invocation;
|
||||
import javax.baja.util.Queue;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BAlarmConsoleChannel
|
||||
extends BFoxChannel {
|
||||
public static final Action routeAlarmAcks = BAlarmConsoleChannel.newAction((int)4, null);
|
||||
public static final Type TYPE;
|
||||
public static final Object channelMutex;
|
||||
Array newList;
|
||||
Array ackList;
|
||||
Worker worker;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$BAlarmConsoleChannel;
|
||||
static /* synthetic */ Class class$com$tridium$fox$message$FoxMessage;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
static /* synthetic */ Class class$java$lang$String;
|
||||
|
||||
public void routeAlarmAcks() {
|
||||
this.invoke(routeAlarmAcks, null, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public void startWorker() throws Exception {
|
||||
try {
|
||||
if (this.getConnection() != null && this.getConnection().getParentStation() == null && this.worker == null) {
|
||||
this.worker = new Worker();
|
||||
this.worker.start();
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
}
|
||||
|
||||
public void stopWorker() throws Exception {
|
||||
if (this.worker != null) {
|
||||
this.worker.kill();
|
||||
}
|
||||
this.worker = null;
|
||||
}
|
||||
|
||||
public void stopped() throws Exception {
|
||||
this.stopWorker();
|
||||
}
|
||||
|
||||
public FoxResponse process(FoxRequest foxRequest) throws Exception {
|
||||
String string = foxRequest.command;
|
||||
if (this.isTraceOn()) {
|
||||
this.trace("AlarmConsoleChannel: command = " + string);
|
||||
}
|
||||
if (string == "ack") {
|
||||
return this.ackAlarms(foxRequest);
|
||||
}
|
||||
if (string == "updateAlarm") {
|
||||
return this.updateAlarm(foxRequest);
|
||||
}
|
||||
if (string == "getInitialAlarmQuery") {
|
||||
return this.getInitialAlarmQuery(foxRequest);
|
||||
}
|
||||
if (string == "unregister") {
|
||||
return this.unregister(foxRequest);
|
||||
}
|
||||
throw new InvalidCommandException(string);
|
||||
}
|
||||
|
||||
public void newAlarm(BConsoleRecipient bConsoleRecipient, BAlarmRecord bAlarmRecord) throws Exception {
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
BAlarmClass bAlarmClass = bAlarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass == null) {
|
||||
bAlarmClass = bAlarmService.getDefaultAlarmClass();
|
||||
}
|
||||
BUser bUser = this.getSessionContext().getUser();
|
||||
bUser.check((BIProtected)bAlarmClass, BPermissions.operatorRead);
|
||||
FoxMessage foxMessage = new FoxMessage("alarmRec");
|
||||
foxMessage.add("alarm", FoxAlarmCodec.encodeAlarm(bAlarmRecord));
|
||||
String string = bConsoleRecipient.getOrdInSession().encodeToString();
|
||||
foxMessage.add("ord", string);
|
||||
this.newList.add((Object)foxMessage);
|
||||
}
|
||||
|
||||
private final FoxResponse ackAlarms(FoxRequest foxRequest) throws Exception {
|
||||
BAlarmService bAlarmService;
|
||||
if (this.isTraceOn()) {
|
||||
this.trace("received: ack");
|
||||
}
|
||||
FoxResponse foxResponse = new FoxResponse(foxRequest);
|
||||
BUser bUser = this.getSessionContext().getUser();
|
||||
try {
|
||||
bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
}
|
||||
catch (ServiceNotFoundException serviceNotFoundException) {
|
||||
return null;
|
||||
}
|
||||
FoxTuple[] foxTupleArray = foxRequest.list("alarm");
|
||||
Class clazz = class$java$lang$String;
|
||||
if (clazz == null) {
|
||||
clazz = class$java$lang$String = BAlarmConsoleChannel.class("[Ljava.lang.String;", false);
|
||||
}
|
||||
Array array = new Array(clazz);
|
||||
int n = 0;
|
||||
while (n < foxTupleArray.length) {
|
||||
BAlarmRecord bAlarmRecord = null;
|
||||
try {
|
||||
bAlarmRecord = FoxAlarmCodec.decodeAlarm((FoxMessage)foxTupleArray[n]);
|
||||
BAlarmClass bAlarmClass = bAlarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass == null) {
|
||||
bAlarmClass = bAlarmService.getDefaultAlarmClass();
|
||||
}
|
||||
bUser.check((BIProtected)bAlarmClass, BPermissions.operatorWrite);
|
||||
this.ackList.add((Object)bAlarmRecord);
|
||||
}
|
||||
catch (PermissionException permissionException) {
|
||||
bAlarmRecord.setAckState(BAckState.unacked);
|
||||
FoxMessage foxMessage = new FoxMessage("alarmRec");
|
||||
foxMessage.add("alarm", FoxAlarmCodec.encodeAlarm(bAlarmRecord));
|
||||
foxMessage.add("ord", foxRequest.getString("ord"));
|
||||
this.newList.add((Object)foxMessage);
|
||||
if (!array.contains((Object)bAlarmRecord.getAlarmClass())) {
|
||||
array.add((Object)bAlarmRecord.getAlarmClass());
|
||||
this.error(foxRequest.getString("ord"), "Cannot ack alarms from Alarm Class: " + bAlarmRecord.getAlarmClass(), (Throwable)permissionException);
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
++n;
|
||||
}
|
||||
this.routeAlarmAcks();
|
||||
return null;
|
||||
}
|
||||
|
||||
public IFuture post(Action action, BValue bValue, Context context) {
|
||||
if (action == routeAlarmAcks) {
|
||||
Queue queue = (Queue)((BAlarmService)Sys.getService((Type)BAlarmService.TYPE)).fw(601);
|
||||
queue.enqueue((Object)new Invocation((BComponent)this, action, bValue, context));
|
||||
return null;
|
||||
}
|
||||
return super.post(action, bValue, context);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
public void doRouteAlarmAcks() {
|
||||
var1_1 = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
var2_2 = new BAlarmRecord[]{};
|
||||
var3_3 = this.ackList;
|
||||
synchronized (var3_3) {
|
||||
var2_2 = (BAlarmRecord[])this.ackList.trim();
|
||||
this.ackList.clear();
|
||||
// MONITOREXIT @DISABLED, blocks:[0, 2] lbl8 : MonitorExitStatement: MONITOREXIT : var3_3
|
||||
var5_4 = 0;
|
||||
if (true) ** GOTO lbl34
|
||||
}
|
||||
do {
|
||||
var6_5 = var2_2[var5_4];
|
||||
try {
|
||||
if (this.isTraceOn()) {
|
||||
this.trace("BAlarmChannel: ack -> routeAlarm: " + var6_5.getTimestamp() + ' ');
|
||||
}
|
||||
if ((var7_6 = var1_1.getAlarmDb().getRecord(var6_5.getUuid())) == null || var7_6.getAckState() != BAckState.acked) {
|
||||
var6_5.setLastUpdate(BAbsTime.now());
|
||||
var8_8 = var6_5.getAlarmData();
|
||||
if (var7_6 != null) {
|
||||
var8_8 = BFacets.make((BFacets)var6_5.getAlarmData(), (BFacets)var7_6.getAlarmData());
|
||||
}
|
||||
if ((var9_9 = var6_5.getAlarmData().gets("notes", null)) != null) {
|
||||
var8_8 = BFacets.make((BFacets)var8_8, (BFacets)BFacets.make((String)"notes", (String)var9_9));
|
||||
}
|
||||
var6_5.setAlarmData(var8_8);
|
||||
if (var7_6 != null && var6_5.getNormalTime().isBefore(var7_6.getNormalTime())) {
|
||||
var6_5.setNormalTime(var7_6.getNormalTime());
|
||||
}
|
||||
var1_1.getAlarmDb().update(var6_5);
|
||||
}
|
||||
var1_1.doAckAlarm(var6_5);
|
||||
}
|
||||
catch (Exception var7_7) {
|
||||
var7_7.printStackTrace();
|
||||
}
|
||||
++var5_4;
|
||||
lbl34:
|
||||
// 2 sources
|
||||
|
||||
} while (var5_4 < var2_2.length);
|
||||
}
|
||||
|
||||
private final FoxResponse getInitialAlarmQuery(FoxRequest foxRequest) throws Exception {
|
||||
BConsoleRecipient bConsoleRecipient;
|
||||
Object object;
|
||||
FoxResponse foxResponse = new FoxResponse(foxRequest);
|
||||
try {
|
||||
object = (BOrd)BOrd.DEFAULT.decodeFromString(foxRequest.getString("ord"));
|
||||
bConsoleRecipient = (BConsoleRecipient)object.resolve().get();
|
||||
bConsoleRecipient.registerAlarmChannel(this);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
foxResponse.add("error", exception.toString());
|
||||
return foxResponse;
|
||||
}
|
||||
object = bConsoleRecipient.getInitialAlarmQuery(this.getSessionContext().getUser());
|
||||
foxResponse.add("query", ((String)object).toString());
|
||||
return foxResponse;
|
||||
}
|
||||
|
||||
public void error(BConsoleRecipient bConsoleRecipient, String string, Throwable throwable) throws Exception {
|
||||
String string2 = bConsoleRecipient.getOrdInSession().encodeToString();
|
||||
this.error(string2, string, throwable);
|
||||
}
|
||||
|
||||
private final void error(String string, String string2, Throwable throwable) throws Exception {
|
||||
FoxRequest foxRequest = this.makeRequest("error");
|
||||
foxRequest.add("msg", string2);
|
||||
foxRequest.add("error", throwable.toString());
|
||||
foxRequest.add("ord", string);
|
||||
this.sendAsync(foxRequest);
|
||||
}
|
||||
|
||||
private final FoxResponse unregister(FoxRequest foxRequest) throws Exception {
|
||||
FoxResponse foxResponse = new FoxResponse(foxRequest);
|
||||
try {
|
||||
BOrd bOrd = (BOrd)BOrd.DEFAULT.decodeFromString(foxRequest.getString("ord"));
|
||||
BConsoleRecipient bConsoleRecipient = (BConsoleRecipient)bOrd.resolve().get();
|
||||
bConsoleRecipient.unregisterAlarmChannel(this);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
foxResponse.add("error", exception.toString());
|
||||
}
|
||||
return foxResponse;
|
||||
}
|
||||
|
||||
private final FoxResponse updateAlarm(FoxRequest foxRequest) throws Exception {
|
||||
BAlarmService bAlarmService;
|
||||
if (this.isTraceOn()) {
|
||||
this.trace("received: updateAlarm");
|
||||
}
|
||||
FoxResponse foxResponse = new FoxResponse(foxRequest);
|
||||
try {
|
||||
bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
}
|
||||
catch (ServiceNotFoundException serviceNotFoundException) {
|
||||
foxResponse.add("error", "Could not find AlarmService");
|
||||
return foxResponse;
|
||||
}
|
||||
String string = "";
|
||||
try {
|
||||
BAlarmRecord bAlarmRecord = FoxAlarmCodec.decodeAlarm(foxRequest.getMessage("alarm"));
|
||||
BAlarmClass bAlarmClass = bAlarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass == null) {
|
||||
bAlarmClass = bAlarmService.getDefaultAlarmClass();
|
||||
}
|
||||
BUser bUser = this.getSessionContext().getUser();
|
||||
bUser.check((BIProtected)bAlarmClass, BPermissions.operatorWrite);
|
||||
if (this.isTraceOn()) {
|
||||
this.trace("BAlarmChannel: ack -> updateAlarm: " + bAlarmRecord.getTimestamp() + ' ' + (Object)((Object)bAlarmRecord.getSourceState()) + ' ' + bAlarmRecord.getAlarmClass());
|
||||
}
|
||||
bAlarmRecord.setLastUpdate(BAbsTime.now());
|
||||
bAlarmService.routeAlarm(bAlarmRecord);
|
||||
bAlarmService.doRouteToSource((BAlarmRecord)bAlarmRecord.newCopy());
|
||||
}
|
||||
catch (PermissionException permissionException) {
|
||||
foxResponse.add("error", "Invalid Permissions: " + (Object)((Object)permissionException));
|
||||
this.error(foxRequest.getString("ord"), "Cannot update alarms from Alarm Class: " + string, (Throwable)permissionException);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
foxResponse.add("error", "Could Not Route Alarm Update Request");
|
||||
}
|
||||
return foxResponse;
|
||||
}
|
||||
|
||||
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 BAlarmConsoleChannel() {
|
||||
this("alarmui");
|
||||
}
|
||||
|
||||
protected BAlarmConsoleChannel(String string) {
|
||||
super(string);
|
||||
Class clazz = class$com$tridium$fox$message$FoxMessage;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$fox$message$FoxMessage = BAlarmConsoleChannel.class("[Lcom.tridium.fox.message.FoxMessage;", false);
|
||||
}
|
||||
this.newList = new Array(clazz);
|
||||
Class clazz2 = class$javax$baja$alarm$BAlarmRecord;
|
||||
if (clazz2 == null) {
|
||||
clazz2 = class$javax$baja$alarm$BAlarmRecord = BAlarmConsoleChannel.class("[Ljavax.baja.alarm.BAlarmRecord;", false);
|
||||
}
|
||||
this.ackList = new Array(clazz2);
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$BAlarmConsoleChannel;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$BAlarmConsoleChannel = BAlarmConsoleChannel.class("[Lcom.tridium.alarm.BAlarmConsoleChannel;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
channelMutex = new Object();
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class Worker
|
||||
implements Runnable {
|
||||
public static final int WORKER_SLEEP = 1000;
|
||||
private boolean isAlive;
|
||||
private Thread thread;
|
||||
|
||||
public void start() {
|
||||
this.isAlive = true;
|
||||
this.thread = new Thread(this, "AlarmConsoleChannel:Worker");
|
||||
this.thread.start();
|
||||
}
|
||||
|
||||
public void kill() {
|
||||
this.isAlive = false;
|
||||
if (this.thread != null) {
|
||||
this.thread.interrupt();
|
||||
}
|
||||
this.thread = null;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
while (this.isAlive) {
|
||||
try {
|
||||
int n;
|
||||
Thread.sleep(1000L);
|
||||
FoxMessage[] foxMessageArray = this.getNewAlarms();
|
||||
int n2 = 100;
|
||||
int n3 = 0;
|
||||
int n4 = n = n2 < foxMessageArray.length ? n2 : foxMessageArray.length;
|
||||
if (foxMessageArray.length <= 0) continue;
|
||||
while (n3 < foxMessageArray.length) {
|
||||
FoxRequest foxRequest = BAlarmConsoleChannel.this.makeRequest("new");
|
||||
int n5 = n3;
|
||||
while (n5 < n) {
|
||||
foxRequest.add("alarmRec", foxMessageArray[n5]);
|
||||
++n5;
|
||||
}
|
||||
BAlarmConsoleChannel.this.sendAsync(foxRequest);
|
||||
n3 = n;
|
||||
int n6 = n = (n += n2) < foxMessageArray.length ? n : foxMessageArray.length;
|
||||
}
|
||||
}
|
||||
catch (InterruptedException interruptedException) {
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
private final synchronized FoxMessage[] getNewAlarms() {
|
||||
FoxMessage[] foxMessageArray = new FoxMessage[]{};
|
||||
Array array = BAlarmConsoleChannel.this.newList;
|
||||
synchronized (array) {
|
||||
foxMessageArray = (FoxMessage[])BAlarmConsoleChannel.this.newList.trim();
|
||||
BAlarmConsoleChannel.this.newList.clear();
|
||||
return foxMessageArray;
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.isAlive = true;
|
||||
}
|
||||
|
||||
Worker() {
|
||||
this.this();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.job.BJob
|
||||
* javax.baja.job.BJobState
|
||||
* javax.baja.job.JobCancelException
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BVector
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.alarm.BAlarmTransitionBits;
|
||||
import javax.baja.alarm.ext.BAlarmSourceExt;
|
||||
import javax.baja.job.BJob;
|
||||
import javax.baja.job.BJobState;
|
||||
import javax.baja.job.JobCancelException;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BVector;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BAlarmExtStatusJob
|
||||
extends BJob {
|
||||
public static final Type TYPE;
|
||||
private static final int BATCH_SIZE = 20;
|
||||
BAlarmService alarmService;
|
||||
BVector extOrds;
|
||||
BAlarmTransitionBits bits;
|
||||
boolean enableExt;
|
||||
boolean canceled;
|
||||
JobThread thread;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$BAlarmExtStatusJob;
|
||||
static /* synthetic */ Class class$javax$baja$naming$BOrd;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public void doRun(Context context) {
|
||||
this.thread = new JobThread(this.toPathString(), context);
|
||||
this.thread.start();
|
||||
}
|
||||
|
||||
/*
|
||||
* Unable to fully structure code
|
||||
*/
|
||||
public void run(Context var1_1) throws Exception {
|
||||
if (this.alarmService == null) {
|
||||
throw new IllegalStateException("Must submit thru AlarmService.enable/disableExtensions()");
|
||||
}
|
||||
if (this.canceled) {
|
||||
throw new JobCancelException();
|
||||
}
|
||||
var2_2 = true;
|
||||
var3_3 = this.enableExt != false ? "Enabling" : "Disabling";
|
||||
this.log().start(var3_3 + " Selected Alarm Extensions");
|
||||
var4_4 = 0;
|
||||
var5_5 = this.extOrds.getSlotCount();
|
||||
if (var5_5 <= 0) {
|
||||
var5_5 = 1;
|
||||
}
|
||||
var6_6 = this.extOrds.getProperties();
|
||||
if (true) ** GOTO lbl28
|
||||
do {
|
||||
if (var4_4 % 20 == 0) {
|
||||
this.progress((int)((float)var4_4 / (float)var5_5 * 100.0f));
|
||||
}
|
||||
++var4_4;
|
||||
var7_7 = (BOrd)var6_6.get();
|
||||
var8_8 = null;
|
||||
try {
|
||||
var8_8 = (BAlarmSourceExt)var7_7.resolve((BObject)this.alarmService).get();
|
||||
var8_8.setAlarmEnable(BAlarmTransitionBits.make(var8_8.getAlarmEnable(), this.bits, this.enableExt));
|
||||
}
|
||||
catch (Exception var9_9) {
|
||||
this.log().failed(" Encountered Problem " + var3_3 + ' ' + (var8_8 != null ? var8_8.getName() : "an unknown alarm extension. "), (Throwable)var9_9);
|
||||
var2_2 = false;
|
||||
}
|
||||
if (this.canceled) break;
|
||||
lbl28:
|
||||
// 2 sources
|
||||
|
||||
if ((v0 = BAlarmExtStatusJob.class$javax$baja$naming$BOrd) != null) continue;
|
||||
v0 = BAlarmExtStatusJob.class("[Ljavax.baja.naming.BOrd;", false);
|
||||
} while (var6_6.next(v0));
|
||||
if (this.canceled) {
|
||||
throw new JobCancelException();
|
||||
}
|
||||
if (var2_2) {
|
||||
this.log().success(var3_3 + " Selected Alarm Extensions Complete");
|
||||
} else {
|
||||
this.log().failed("Encountered Problems " + var3_3 + " Selected Alarm Extensions");
|
||||
}
|
||||
}
|
||||
|
||||
public void doCancel(Context context) {
|
||||
this.canceled = true;
|
||||
if (this.getJobState().isRunning()) {
|
||||
this.setJobState(BJobState.canceling);
|
||||
if (this.thread != null) {
|
||||
this.thread.interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.canceled = false;
|
||||
}
|
||||
|
||||
public BAlarmExtStatusJob(BAlarmService bAlarmService, BVector bVector, BAlarmTransitionBits bAlarmTransitionBits, boolean bl) {
|
||||
this.this();
|
||||
this.alarmService = bAlarmService;
|
||||
this.extOrds = bVector;
|
||||
this.enableExt = bl;
|
||||
this.bits = bAlarmTransitionBits;
|
||||
}
|
||||
|
||||
public BAlarmExtStatusJob() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$BAlarmExtStatusJob;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$BAlarmExtStatusJob = BAlarmExtStatusJob.class("[Lcom.tridium.alarm.BAlarmExtStatusJob;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
class JobThread
|
||||
extends Thread {
|
||||
Context cx;
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
BAlarmExtStatusJob.this.run(this.cx);
|
||||
BAlarmExtStatusJob.this.success();
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
BAlarmExtStatusJob.this.failed(throwable);
|
||||
}
|
||||
}
|
||||
|
||||
JobThread(String string, Context context) {
|
||||
super(string);
|
||||
this.cx = context;
|
||||
this.setPriority(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,289 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.bql.collection.BqlColumn
|
||||
* com.tridium.bql.collection.BqlColumnList
|
||||
* com.tridium.bql.collection.PropertyColumn
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.collection.BIList
|
||||
* javax.baja.collection.BITable
|
||||
* javax.baja.collection.Column
|
||||
* javax.baja.collection.ColumnList
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.IFilter
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import com.tridium.alarm.AlarmColumnSpec;
|
||||
import com.tridium.alarm.AlarmInput;
|
||||
import com.tridium.alarm.AlarmInputCursor;
|
||||
import com.tridium.alarm.AlarmTableCursor;
|
||||
import com.tridium.bql.collection.BqlColumn;
|
||||
import com.tridium.bql.collection.BqlColumnList;
|
||||
import com.tridium.bql.collection.PropertyColumn;
|
||||
import java.util.ArrayList;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.collection.BIList;
|
||||
import javax.baja.collection.BITable;
|
||||
import javax.baja.collection.Column;
|
||||
import javax.baja.collection.ColumnList;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.IFilter;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BAlarmInputTable
|
||||
extends BObject
|
||||
implements BITable {
|
||||
public static final Type TYPE;
|
||||
private AlarmColumnSpec[] projection;
|
||||
private ColumnList columns;
|
||||
private AlarmInput in;
|
||||
private ArrayList recs;
|
||||
private boolean gotCursor;
|
||||
private BFacets tableFacets;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$BAlarmInputTable;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
|
||||
public Cursor cursor() {
|
||||
Object object = null;
|
||||
if (this.gotCursor && this.recs == null) {
|
||||
throw new IllegalStateException("Cursor has already been used.");
|
||||
}
|
||||
if (!this.gotCursor) {
|
||||
this.gotCursor = true;
|
||||
object = new AlarmInputCursor(this.in, null);
|
||||
} else {
|
||||
object = new RecCursor(this.recs, null);
|
||||
}
|
||||
return new AlarmTableCursor(this, (Cursor)object);
|
||||
}
|
||||
|
||||
public BIList toList() {
|
||||
this.load();
|
||||
return this;
|
||||
}
|
||||
|
||||
public BITable toTable() {
|
||||
this.load();
|
||||
return this;
|
||||
}
|
||||
|
||||
public BICollection filter(IFilter iFilter) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
this.load();
|
||||
return this.recs.size();
|
||||
}
|
||||
|
||||
public BObject[] list() {
|
||||
this.load();
|
||||
return this.recs.toArray(new BObject[this.recs.size()]);
|
||||
}
|
||||
|
||||
public BObject[] list(BObject[] bObjectArray) {
|
||||
this.load();
|
||||
return this.recs.toArray(bObjectArray);
|
||||
}
|
||||
|
||||
public BObject get(int n) {
|
||||
return (BObject)this.recs.get(n);
|
||||
}
|
||||
|
||||
public ColumnList getColumns() {
|
||||
if (this.columns == null) {
|
||||
if (this.projection != null) {
|
||||
BqlColumn[] bqlColumnArray = new BqlColumn[this.projection.length];
|
||||
int n = 0;
|
||||
while (n < bqlColumnArray.length) {
|
||||
BAlarmRecord bAlarmRecord = new BAlarmRecord();
|
||||
bqlColumnArray[n] = new PropertyColumn(bAlarmRecord.getProperty(this.projection[n].name));
|
||||
++n;
|
||||
}
|
||||
return new BqlColumnList((Column[])bqlColumnArray);
|
||||
}
|
||||
BAlarmRecord bAlarmRecord = new BAlarmRecord();
|
||||
Property[] propertyArray = bAlarmRecord.getPropertiesArray();
|
||||
BqlColumn[] bqlColumnArray = new BqlColumn[propertyArray.length];
|
||||
int n = 0;
|
||||
while (n < propertyArray.length) {
|
||||
Property property = propertyArray[n];
|
||||
Object var6_9 = null;
|
||||
bqlColumnArray[n] = new PropertyColumn(propertyArray[n]);
|
||||
++n;
|
||||
}
|
||||
this.columns = new BqlColumnList((Column[])bqlColumnArray);
|
||||
}
|
||||
return this.columns;
|
||||
}
|
||||
|
||||
public BObject get(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).get((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public String getString(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getString((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public float getFloat(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getFloat((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public double getDouble(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getDouble((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public int getInt(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getInt((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public long getLong(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getLong((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public boolean getBoolean(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getBoolean((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public int getFlags(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getFlags((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public BFacets getFacets(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getFacets((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public BFacets getTableFacets() {
|
||||
return this.tableFacets;
|
||||
}
|
||||
|
||||
private final void load() {
|
||||
if (this.recs != null) {
|
||||
return;
|
||||
}
|
||||
this.recs = new ArrayList(1000);
|
||||
Cursor cursor = this.cursor();
|
||||
while (cursor.next()) {
|
||||
this.recs.add(cursor.get());
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.gotCursor = false;
|
||||
this.tableFacets = BFacets.NULL;
|
||||
}
|
||||
|
||||
public BAlarmInputTable(AlarmColumnSpec[] alarmColumnSpecArray, AlarmInput alarmInput) {
|
||||
this.this();
|
||||
this.projection = alarmColumnSpecArray;
|
||||
this.in = alarmInput;
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$BAlarmInputTable;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$BAlarmInputTable = BAlarmInputTable.class("[Lcom.tridium.alarm.BAlarmInputTable;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class RecCursor
|
||||
implements Cursor {
|
||||
ArrayList recs;
|
||||
Context cx;
|
||||
int index;
|
||||
|
||||
public Context getContext() {
|
||||
return this.cx;
|
||||
}
|
||||
|
||||
public BObject get() {
|
||||
if (this.index == -1) {
|
||||
throw new IllegalStateException("get() before next()");
|
||||
}
|
||||
return (BObject)this.recs.get(this.index);
|
||||
}
|
||||
|
||||
public boolean next() {
|
||||
if (this.index == this.recs.size()) {
|
||||
return false;
|
||||
}
|
||||
++this.index;
|
||||
boolean bl = false;
|
||||
if (this.index != this.recs.size()) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public boolean nextComponent() {
|
||||
this.index = this.recs.size();
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean next(Class clazz) {
|
||||
Class clazz2 = class$javax$baja$alarm$BAlarmRecord;
|
||||
if (clazz2 == null) {
|
||||
clazz2 = class$javax$baja$alarm$BAlarmRecord = BAlarmInputTable.class("[Ljavax.baja.alarm.BAlarmRecord;", false);
|
||||
}
|
||||
if (clazz2.isAssignableFrom(clazz)) {
|
||||
return this.next();
|
||||
}
|
||||
this.index = this.recs.size();
|
||||
return false;
|
||||
}
|
||||
|
||||
public RecCursor(ArrayList arrayList, Context context) {
|
||||
this.recs = arrayList;
|
||||
this.cx = context;
|
||||
this.index = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,338 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.bql.util.BDynamicTimeRange
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.log.Log
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.SlotPath
|
||||
* javax.baja.nre.util.Array
|
||||
* javax.baja.security.BIProtected
|
||||
* javax.baja.security.BPermissions
|
||||
* javax.baja.security.PermissionException
|
||||
* javax.baja.sys.BBoolean
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BIcon
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.user.BUser
|
||||
* javax.baja.user.BUserService
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import com.tridium.alarm.AlarmsToSourcesCursor;
|
||||
import com.tridium.alarm.BAlarmConsoleChannel;
|
||||
import com.tridium.bql.util.BDynamicTimeRange;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.baja.alarm.BAlarmClass;
|
||||
import javax.baja.alarm.BAlarmRecipient;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.alarm.BAlarmTransitionBits;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.SlotPath;
|
||||
import javax.baja.nre.util.Array;
|
||||
import javax.baja.security.BIProtected;
|
||||
import javax.baja.security.BPermissions;
|
||||
import javax.baja.security.PermissionException;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BIcon;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.user.BUser;
|
||||
import javax.baja.user.BUserService;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BConsoleRecipient
|
||||
extends BAlarmRecipient {
|
||||
public static final Property transitions = BConsoleRecipient.newProperty((int)0, (BValue)BAlarmTransitionBits.ALL, (BFacets)BFacets.make((String[])new String[]{"showNormal"}, (BIDataValue[])new BBoolean[]{BBoolean.FALSE}));
|
||||
public static final Property routeAcks = BConsoleRecipient.newProperty((int)1, (boolean)true, null);
|
||||
public static final Property defaultTimeRange = BConsoleRecipient.newProperty((int)0, (BValue)BDynamicTimeRange.DEFAULT, null);
|
||||
public static final Type TYPE;
|
||||
public static final Log logger;
|
||||
private static final BIcon icon;
|
||||
Array channels;
|
||||
private Map channelUsageCounts;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$BConsoleRecipient;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$BAlarmConsoleChannel;
|
||||
static /* synthetic */ Class class$javax$baja$user$BUser;
|
||||
|
||||
public BAlarmTransitionBits getTransitions() {
|
||||
return (BAlarmTransitionBits)this.get(transitions);
|
||||
}
|
||||
|
||||
public void setTransitions(BAlarmTransitionBits bAlarmTransitionBits) {
|
||||
this.set(transitions, (BValue)bAlarmTransitionBits, null);
|
||||
}
|
||||
|
||||
public boolean getRouteAcks() {
|
||||
return this.getBoolean(routeAcks);
|
||||
}
|
||||
|
||||
public void setRouteAcks(boolean bl) {
|
||||
this.setBoolean(routeAcks, bl, null);
|
||||
}
|
||||
|
||||
public BDynamicTimeRange getDefaultTimeRange() {
|
||||
return (BDynamicTimeRange)this.get(defaultTimeRange);
|
||||
}
|
||||
|
||||
public void setDefaultTimeRange(BDynamicTimeRange bDynamicTimeRange) {
|
||||
this.set(defaultTimeRange, (BValue)bDynamicTimeRange, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public void handleAlarm(BAlarmRecord bAlarmRecord) {
|
||||
logger.trace("BConsoleRecipient.handleAlarm: " + (Object)((Object)bAlarmRecord.getSourceState()));
|
||||
int n = 0;
|
||||
while (n < this.channels.size()) {
|
||||
try {
|
||||
BAlarmConsoleChannel bAlarmConsoleChannel = (BAlarmConsoleChannel)((Object)this.channels.get(n));
|
||||
bAlarmConsoleChannel.newAlarm(this, bAlarmRecord);
|
||||
}
|
||||
catch (PermissionException permissionException) {
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public void registerAlarmChannel(BAlarmConsoleChannel bAlarmConsoleChannel) {
|
||||
block6: {
|
||||
Map map = this.channelUsageCounts;
|
||||
synchronized (map) {
|
||||
Integer n;
|
||||
block5: {
|
||||
n = (Integer)this.channelUsageCounts.get((Object)bAlarmConsoleChannel);
|
||||
if (n != null) break block5;
|
||||
this.channelUsageCounts.put(bAlarmConsoleChannel, new Integer(1));
|
||||
break block6;
|
||||
}
|
||||
n = new Integer(n + 1);
|
||||
this.channelUsageCounts.put(bAlarmConsoleChannel, n);
|
||||
}
|
||||
}
|
||||
if (this.channels.contains((Object)bAlarmConsoleChannel)) return;
|
||||
this.channels.add((Object)bAlarmConsoleChannel);
|
||||
try {
|
||||
bAlarmConsoleChannel.startWorker();
|
||||
return;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public void unregisterAlarmChannel(BAlarmConsoleChannel bAlarmConsoleChannel) {
|
||||
try {
|
||||
Map map = this.channelUsageCounts;
|
||||
synchronized (map) {
|
||||
block6: {
|
||||
Integer n;
|
||||
block5: {
|
||||
n = (Integer)this.channelUsageCounts.get((Object)bAlarmConsoleChannel);
|
||||
if (n == null) return;
|
||||
if ((n = new Integer(n - 1)) != 0) break block5;
|
||||
this.channelUsageCounts.remove((Object)bAlarmConsoleChannel);
|
||||
this.channels.remove((Object)bAlarmConsoleChannel);
|
||||
bAlarmConsoleChannel.stopWorker();
|
||||
break block6;
|
||||
}
|
||||
this.channelUsageCounts.put(bAlarmConsoleChannel, n);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Cursor getOpenAlarmSources(Context context) {
|
||||
return new AlarmsToSourcesCursor(this.getOpenAlarms(context));
|
||||
}
|
||||
|
||||
public Cursor getOpenAlarms(Context context) {
|
||||
String string = this.getInitialAlarmQuery(context);
|
||||
return ((BICollection)BOrd.make((String)string).resolve((BObject)this).get()).cursor();
|
||||
}
|
||||
|
||||
public String getInitialAlarmQuery(Context context) {
|
||||
BUserService bUserService;
|
||||
BUser bUser = null;
|
||||
if (context != null) {
|
||||
bUser = context.getUser();
|
||||
}
|
||||
if (bUser == null && !(bUser = (bUserService = (BUserService)Sys.getService((Type)BUserService.TYPE)).getAdmin()).getEnabled()) {
|
||||
Class clazz = class$javax$baja$user$BUser;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$user$BUser = BConsoleRecipient.class("[Ljavax.baja.user.BUser;", false);
|
||||
}
|
||||
BUser[] bUserArray = (BUser[])bUserService.getChildren(clazz);
|
||||
int n = 0;
|
||||
while (n < bUserArray.length) {
|
||||
if (bUserArray[n].getEnabled() && bUserArray[n].getPermissions().isSuperUser()) {
|
||||
bUser = bUserArray[n];
|
||||
break;
|
||||
}
|
||||
++n;
|
||||
}
|
||||
}
|
||||
return this.getInitialAlarmQuery(bUser);
|
||||
}
|
||||
|
||||
public String getInitialAlarmQuery(BUser bUser) {
|
||||
String string;
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
String[] stringArray = this.getSubscribedAlarmClasses();
|
||||
StringBuffer stringBuffer = new StringBuffer("alarm:|bql:select * from openAlarms");
|
||||
int n = 0;
|
||||
StringBuffer stringBuffer2 = new StringBuffer();
|
||||
int n2 = 0;
|
||||
while (n2 < stringArray.length) {
|
||||
try {
|
||||
string = stringArray[n2];
|
||||
bUser.check((BIProtected)bAlarmService.lookupAlarmClass(string), BPermissions.operatorRead);
|
||||
if (n > 0) {
|
||||
stringBuffer2.append(" or ");
|
||||
} else {
|
||||
stringBuffer2.append("(");
|
||||
}
|
||||
++n;
|
||||
stringBuffer2.append("alarmClass = '" + SlotPath.escape((String)string) + '\'');
|
||||
}
|
||||
catch (PermissionException permissionException) {}
|
||||
++n2;
|
||||
}
|
||||
if (n > 0) {
|
||||
stringBuffer2.append(")");
|
||||
}
|
||||
stringArray = this.getSubscribedEscalatedAlarmClasses(1);
|
||||
n2 = 0;
|
||||
while (n2 < stringArray.length) {
|
||||
try {
|
||||
string = stringArray[n2];
|
||||
bUser.check((BIProtected)bAlarmService.lookupAlarmClass(string), BPermissions.operatorRead);
|
||||
if (n > 0) {
|
||||
stringBuffer2.append(" or ");
|
||||
}
|
||||
stringBuffer2.append("(alarmClass = '" + SlotPath.escape((String)string) + "' and (alarmData." + BAlarmClass.ESCALATED + " != null and alarmData." + BAlarmClass.ESCALATED + " = '" + BAlarmClass.LEVEL_3 + "' or alarmData." + BAlarmClass.ESCALATED + " = '" + BAlarmClass.LEVEL_2 + "' or alarmData." + BAlarmClass.ESCALATED + " = '" + BAlarmClass.LEVEL_1 + "'))");
|
||||
++n;
|
||||
}
|
||||
catch (PermissionException permissionException) {}
|
||||
++n2;
|
||||
}
|
||||
stringArray = this.getSubscribedEscalatedAlarmClasses(2);
|
||||
n2 = 0;
|
||||
while (n2 < stringArray.length) {
|
||||
try {
|
||||
string = stringArray[n2];
|
||||
bUser.check((BIProtected)bAlarmService.lookupAlarmClass(string), BPermissions.operatorRead);
|
||||
if (n > 0) {
|
||||
stringBuffer2.append(" or ");
|
||||
}
|
||||
stringBuffer2.append("(alarmClass = '" + SlotPath.escape((String)string) + "' and (alarmData." + BAlarmClass.ESCALATED + " != null and alarmData." + BAlarmClass.ESCALATED + " = '" + BAlarmClass.LEVEL_3 + "' or alarmData." + BAlarmClass.ESCALATED + " = '" + BAlarmClass.LEVEL_2 + "'))");
|
||||
++n;
|
||||
}
|
||||
catch (PermissionException permissionException) {}
|
||||
++n2;
|
||||
}
|
||||
stringArray = this.getSubscribedEscalatedAlarmClasses(3);
|
||||
n2 = 0;
|
||||
while (n2 < stringArray.length) {
|
||||
try {
|
||||
string = stringArray[n2];
|
||||
bUser.check((BIProtected)bAlarmService.lookupAlarmClass(string), BPermissions.operatorRead);
|
||||
if (n > 0) {
|
||||
stringBuffer2.append(" or ");
|
||||
}
|
||||
stringBuffer2.append("(alarmClass = '" + SlotPath.escape((String)string) + "' and alarmData." + BAlarmClass.ESCALATED + " != null and alarmData." + BAlarmClass.ESCALATED + " = '" + BAlarmClass.LEVEL_3 + "')");
|
||||
++n;
|
||||
}
|
||||
catch (PermissionException permissionException) {}
|
||||
++n2;
|
||||
}
|
||||
if (stringBuffer2.length() > 0) {
|
||||
stringBuffer.append(" where (");
|
||||
stringBuffer.append(stringBuffer2.toString() + ')');
|
||||
} else {
|
||||
stringBuffer.append(" where alarmClass = 'null'");
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
Class clazz = class$com$tridium$alarm$BAlarmConsoleChannel;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$BAlarmConsoleChannel = BConsoleRecipient.class("[Lcom.tridium.alarm.BAlarmConsoleChannel;", false);
|
||||
}
|
||||
this.channels = new Array(clazz);
|
||||
this.channelUsageCounts = new HashMap();
|
||||
}
|
||||
|
||||
public BConsoleRecipient() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$BConsoleRecipient;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$BConsoleRecipient = BConsoleRecipient.class("[Lcom.tridium.alarm.BConsoleRecipient;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
logger = Log.getLog((String)"alarm");
|
||||
icon = BIcon.make((BIcon)BIcon.std((String)"computer.png"), (BIcon)BIcon.std((String)"badges/alarm.png"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BIAlarmSource;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
public interface BIUpdatableAlarmSource
|
||||
extends BIAlarmSource {
|
||||
public static final Type TYPE;
|
||||
|
||||
public void updateAlarm(BAlarmRecord var1);
|
||||
|
||||
static {
|
||||
Class clazz = 1.class$com$tridium$alarm$BIUpdatableAlarmSource;
|
||||
if (clazz == null) {
|
||||
clazz = 1.class$com$tridium$alarm$BIUpdatableAlarmSource = 1.class("[Lcom.tridium.alarm.BIUpdatableAlarmSource;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.units.BDimension
|
||||
* javax.baja.units.BUnit
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import com.tridium.alarm.db.memory.BMemoryAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.units.BDimension;
|
||||
import javax.baja.units.BUnit;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BMemoryAlarmService
|
||||
extends BAlarmService {
|
||||
public static final Property capacity = BMemoryAlarmService.newProperty((int)0, (int)500, (BFacets)BFacets.makeInt((BUnit)BUnit.make((String)"records", (BDimension)BDimension.DEFAULT), (int)1, (int)5000));
|
||||
public static final Type TYPE;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$BMemoryAlarmService;
|
||||
|
||||
public int getCapacity() {
|
||||
return this.getInt(capacity);
|
||||
}
|
||||
|
||||
public void setCapacity(int n) {
|
||||
this.setInt(capacity, n, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
protected BAlarmDatabase createAlarmDb() {
|
||||
return new BMemoryAlarmDatabase();
|
||||
}
|
||||
|
||||
public void changed(Property property, Context context) {
|
||||
if (property.equals((Object)capacity)) {
|
||||
BAlarmDatabase bAlarmDatabase = this.getAlarmDb();
|
||||
if (bAlarmDatabase != null && bAlarmDatabase instanceof BMemoryAlarmDatabase) {
|
||||
try {
|
||||
((BMemoryAlarmDatabase)bAlarmDatabase).setCapacity(this.getCapacity());
|
||||
}
|
||||
catch (Exception exception) {
|
||||
logger.error("Cannot change database capacity to " + this.getCapacity() + '.', (Throwable)exception);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
super.changed(property, context);
|
||||
}
|
||||
}
|
||||
|
||||
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$alarm$BMemoryAlarmService;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$BMemoryAlarmService = BMemoryAlarmService.class("[Lcom.tridium.alarm.BMemoryAlarmService;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.fox.sys.NiagaraNetwork
|
||||
* com.tridium.fox.sys.NiagaraStation
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.log.Log
|
||||
* javax.baja.sys.BBoolean
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BIcon
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.Lexicon
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import com.tridium.fox.sys.NiagaraNetwork;
|
||||
import com.tridium.fox.sys.NiagaraStation;
|
||||
import javax.baja.alarm.BAlarmRecipient;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmTransitionBits;
|
||||
import javax.baja.alarm.BIRemoteAlarmRecipient;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BIcon;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.Lexicon;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BStationRecipient
|
||||
extends BAlarmRecipient {
|
||||
public static final Property transitions = BStationRecipient.newProperty((int)0, (BValue)BAlarmTransitionBits.ALL, (BFacets)BFacets.make((String[])new String[]{"showNormal"}, (BIDataValue[])new BBoolean[]{BBoolean.FALSE}));
|
||||
public static final Property routeAcks = BStationRecipient.newProperty((int)1, (boolean)true, null);
|
||||
public static final Property remoteStation = BStationRecipient.newProperty((int)0, (String)"", (BFacets)BFacets.make((String)"fieldEditor", (BIDataValue)BString.make((String)"alarm:RemoteStationFE")));
|
||||
public static final Type TYPE;
|
||||
public static final Lexicon lex;
|
||||
private static final BIcon icon;
|
||||
private static final Log log;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$BStationRecipient;
|
||||
|
||||
public BAlarmTransitionBits getTransitions() {
|
||||
return (BAlarmTransitionBits)this.get(transitions);
|
||||
}
|
||||
|
||||
public void setTransitions(BAlarmTransitionBits bAlarmTransitionBits) {
|
||||
this.set(transitions, (BValue)bAlarmTransitionBits, null);
|
||||
}
|
||||
|
||||
public boolean getRouteAcks() {
|
||||
return this.getBoolean(routeAcks);
|
||||
}
|
||||
|
||||
public void setRouteAcks(boolean bl) {
|
||||
this.setBoolean(routeAcks, bl, null);
|
||||
}
|
||||
|
||||
public String getRemoteStation() {
|
||||
return this.getString(remoteStation);
|
||||
}
|
||||
|
||||
public void setRemoteStation(String string) {
|
||||
this.setString(remoteStation, string, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public void handleAlarm(BAlarmRecord bAlarmRecord) {
|
||||
try {
|
||||
BIRemoteAlarmRecipient bIRemoteAlarmRecipient = this.getAlarmDeviceExt();
|
||||
if (bIRemoteAlarmRecipient == null) {
|
||||
return;
|
||||
}
|
||||
bIRemoteAlarmRecipient.routeAlarm(bAlarmRecord);
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
}
|
||||
|
||||
private final NiagaraStation getStation() throws Exception {
|
||||
Type type = Sys.getType((String)"niagaraDriver:NiagaraNetwork");
|
||||
NiagaraNetwork niagaraNetwork = (NiagaraNetwork)Sys.getService((Type)type);
|
||||
BComponent bComponent = (BComponent)niagaraNetwork.getStation(this.getRemoteStation());
|
||||
if (bComponent == null) {
|
||||
log.error(this.getName() + ": Station '" + this.getRemoteStation() + "' not Configured in the Database");
|
||||
throw new Exception("Station '" + this.getRemoteStation() + "' not Configured in the Database");
|
||||
}
|
||||
return (NiagaraStation)bComponent;
|
||||
}
|
||||
|
||||
private final BIRemoteAlarmRecipient getAlarmDeviceExt() throws Exception {
|
||||
BComponent bComponent = (BComponent)this.getStation();
|
||||
if (!((BBoolean)bComponent.get("enabled")).getBoolean()) {
|
||||
return null;
|
||||
}
|
||||
return (BIRemoteAlarmRecipient)bComponent.get("alarms");
|
||||
}
|
||||
|
||||
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$alarm$BStationRecipient;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$BStationRecipient = BStationRecipient.class("[Lcom.tridium.alarm.BStationRecipient;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
lex = Lexicon.make((String)"baja");
|
||||
icon = BIcon.make((BIcon)BIcon.std((String)"device.png"), (BIcon)BIcon.std((String)"badges/alarm.png"));
|
||||
log = Log.getLog((String)"alarm");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BFormat
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import com.tridium.alarm.BTextOp;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BFormat;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BTextCustomizer
|
||||
extends BComponent {
|
||||
public static final Property op = BTextCustomizer.newProperty((int)0, (BValue)BTextOp.useExisting, null);
|
||||
public static final Property text = BTextCustomizer.newProperty((int)0, (BValue)BFormat.make((String)""), null);
|
||||
public static final Type TYPE;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$BTextCustomizer;
|
||||
|
||||
public BTextOp getOp() {
|
||||
return (BTextOp)this.get(op);
|
||||
}
|
||||
|
||||
public void setOp(BTextOp bTextOp) {
|
||||
this.set(op, (BValue)bTextOp, null);
|
||||
}
|
||||
|
||||
public BFormat getText() {
|
||||
return (BFormat)this.get(text);
|
||||
}
|
||||
|
||||
public void setText(BFormat bFormat) {
|
||||
this.set(text, (BValue)bFormat, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public String customize(String string) {
|
||||
switch (this.getOp().getOrdinal()) {
|
||||
case 1: {
|
||||
return this.getText().format((Object)this) + string;
|
||||
}
|
||||
case 2: {
|
||||
return string + this.getText().format((Object)this);
|
||||
}
|
||||
case 3: {
|
||||
return this.getText().format((Object)this);
|
||||
}
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
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 BTextCustomizer() {
|
||||
}
|
||||
|
||||
public BTextCustomizer(BTextOp bTextOp, BFormat bFormat) {
|
||||
this.setOp(bTextOp);
|
||||
this.setText(bFormat);
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$BTextCustomizer;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$BTextCustomizer = BTextCustomizer.class("[Lcom.tridium.alarm.BTextCustomizer;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BFrozenEnum
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import javax.baja.sys.BFrozenEnum;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class BTextOp
|
||||
extends BFrozenEnum {
|
||||
public static final int USE_EXISTING = 0;
|
||||
public static final int PREPEND = 1;
|
||||
public static final int APPEND = 2;
|
||||
public static final int REPLACE = 3;
|
||||
public static final BTextOp useExisting = new BTextOp(0);
|
||||
public static final BTextOp prepend = new BTextOp(1);
|
||||
public static final BTextOp append = new BTextOp(2);
|
||||
public static final BTextOp replace = new BTextOp(3);
|
||||
public static final Type TYPE;
|
||||
public static final BTextOp DEFAULT;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$BTextOp;
|
||||
|
||||
public final Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static final BTextOp make(int n) {
|
||||
return (BTextOp)useExisting.getRange().get(n, false);
|
||||
}
|
||||
|
||||
public static final BTextOp make(String string) {
|
||||
return (BTextOp)useExisting.getRange().get(string);
|
||||
}
|
||||
|
||||
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 BTextOp(int n) {
|
||||
super(n);
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$BTextOp;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$BTextOp = BTextOp.class("[Lcom.tridium.alarm.BTextOp;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
DEFAULT = useExisting;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.Context
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import com.tridium.alarm.AlarmClassRouteAlarmInvocation;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.Context;
|
||||
|
||||
class CoalesceUuidOnlyInvocation
|
||||
extends AlarmClassRouteAlarmInvocation {
|
||||
public boolean equals(Object object) {
|
||||
if (object instanceof CoalesceUuidOnlyInvocation) {
|
||||
CoalesceUuidOnlyInvocation coalesceUuidOnlyInvocation = (CoalesceUuidOnlyInvocation)((Object)object);
|
||||
if (this.argument != null) {
|
||||
boolean bl = false;
|
||||
if (this.instance == coalesceUuidOnlyInvocation.instance && this.action == coalesceUuidOnlyInvocation.action && ((BAlarmRecord)this.argument).getUuid().equals((Object)((BAlarmRecord)coalesceUuidOnlyInvocation.argument).getUuid()) && ((BAlarmRecord)this.argument).getSourceState().equals((Object)((BAlarmRecord)coalesceUuidOnlyInvocation.argument).getSourceState())) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
boolean bl = false;
|
||||
if (this.instance == coalesceUuidOnlyInvocation.instance && this.action == coalesceUuidOnlyInvocation.action) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public CoalesceUuidOnlyInvocation(BComponent bComponent, Action action, BAlarmRecord bAlarmRecord, Context context) {
|
||||
super(bComponent, action, bAlarmRecord, context);
|
||||
if (bAlarmRecord != null) {
|
||||
this.hashCode ^= bAlarmRecord.getSourceState().hashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.nre.util.IFilter
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import javax.baja.nre.util.IFilter;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
|
||||
public class FilterCursor
|
||||
implements Cursor {
|
||||
private IFilter filter;
|
||||
private Cursor inner;
|
||||
|
||||
public Context getContext() {
|
||||
return this.inner.getContext();
|
||||
}
|
||||
|
||||
public BObject get() {
|
||||
return this.inner.get();
|
||||
}
|
||||
|
||||
/*
|
||||
* Unable to fully structure code
|
||||
*/
|
||||
public boolean next() {
|
||||
if (this.filter != null) ** GOTO lbl5
|
||||
return this.inner.next();
|
||||
lbl-1000:
|
||||
// 1 sources
|
||||
|
||||
{
|
||||
if (!this.filter.accept((Object)this.inner.get())) continue;
|
||||
return true;
|
||||
lbl5:
|
||||
// 2 sources
|
||||
|
||||
** while (this.inner.next())
|
||||
}
|
||||
lbl6:
|
||||
// 1 sources
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean next(Class clazz) {
|
||||
return this.inner.next(clazz);
|
||||
}
|
||||
|
||||
public boolean nextComponent() {
|
||||
return this.inner.nextComponent();
|
||||
}
|
||||
|
||||
public FilterCursor(IFilter iFilter, Cursor cursor) {
|
||||
this.filter = iFilter;
|
||||
this.inner = cursor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,417 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.collection.BITable
|
||||
* javax.baja.log.Log
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.SlotPath
|
||||
* javax.baja.nre.util.Array
|
||||
* javax.baja.status.BIStatus
|
||||
* javax.baja.status.BStatus
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Clock
|
||||
* javax.baja.sys.Clock$Ticket
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Topic
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
* javax.baja.util.IFuture
|
||||
* javax.baja.util.Invocation
|
||||
* javax.baja.util.Queue
|
||||
* javax.baja.util.Worker
|
||||
* javax.baja.util.Worker$ITodo
|
||||
*/
|
||||
package com.tridium.alarm.ack;
|
||||
|
||||
import javax.baja.alarm.BAckState;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.collection.BITable;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.SlotPath;
|
||||
import javax.baja.nre.util.Array;
|
||||
import javax.baja.status.BIStatus;
|
||||
import javax.baja.status.BStatus;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Clock;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Topic;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
import javax.baja.util.IFuture;
|
||||
import javax.baja.util.Invocation;
|
||||
import javax.baja.util.Queue;
|
||||
import javax.baja.util.Worker;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public abstract class BAlarmAcknowledger
|
||||
extends BComponent
|
||||
implements BIStatus {
|
||||
public static final Property status = BAlarmAcknowledger.newProperty((int)2051, (BValue)BStatus.ok, null);
|
||||
public static final Property enabled = BAlarmAcknowledger.newProperty((int)0, (boolean)true, null);
|
||||
public static final Property ackAlarmsFromSameSource = BAlarmAcknowledger.newProperty((int)0, (boolean)true, null);
|
||||
public static final Property lastAlarmAcked = BAlarmAcknowledger.newProperty((int)2115, (String)"", null);
|
||||
public static final Property lastAlarmAckedTime = BAlarmAcknowledger.newProperty((int)2115, (BValue)BAbsTime.NULL, null);
|
||||
public static final Property lastAlarmAckedFailureTime = BAlarmAcknowledger.newProperty((int)2115, (BValue)BAbsTime.NULL, null);
|
||||
public static final Property lastAlarmAckedFailureCause = BAlarmAcknowledger.newProperty((int)2115, (String)"", null);
|
||||
public static final Property totalAlarmsAckedToday = BAlarmAcknowledger.newProperty((int)2115, (int)0, null);
|
||||
public static final Property totalAlarmAckedFailures = BAlarmAcknowledger.newProperty((int)2115, (int)0, null);
|
||||
public static final Property totalMessagesReceivedToday = BAlarmAcknowledger.newProperty((int)2115, (int)0, null);
|
||||
public static final Action resetTotals = BAlarmAcknowledger.newAction((int)20, null);
|
||||
public static final Topic alarmAcked = BAlarmAcknowledger.newTopic((int)0, null);
|
||||
public static final Type TYPE;
|
||||
protected static final String UUID_TEXT = "UUID:";
|
||||
protected static final int UUID_LENGTH = 36;
|
||||
protected static final Log log;
|
||||
private static Worker worker;
|
||||
private static final Object compRefCountMonitor;
|
||||
private static int compRefCount;
|
||||
private Clock.Ticket resetTicket;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ack$BAlarmAcknowledger;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
|
||||
public BStatus getStatus() {
|
||||
return (BStatus)this.get(status);
|
||||
}
|
||||
|
||||
public void setStatus(BStatus bStatus) {
|
||||
this.set(status, (BValue)bStatus, null);
|
||||
}
|
||||
|
||||
public boolean getEnabled() {
|
||||
return this.getBoolean(enabled);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean bl) {
|
||||
this.setBoolean(enabled, bl, null);
|
||||
}
|
||||
|
||||
public boolean getAckAlarmsFromSameSource() {
|
||||
return this.getBoolean(ackAlarmsFromSameSource);
|
||||
}
|
||||
|
||||
public void setAckAlarmsFromSameSource(boolean bl) {
|
||||
this.setBoolean(ackAlarmsFromSameSource, bl, null);
|
||||
}
|
||||
|
||||
public String getLastAlarmAcked() {
|
||||
return this.getString(lastAlarmAcked);
|
||||
}
|
||||
|
||||
public void setLastAlarmAcked(String string) {
|
||||
this.setString(lastAlarmAcked, string, null);
|
||||
}
|
||||
|
||||
public BAbsTime getLastAlarmAckedTime() {
|
||||
return (BAbsTime)this.get(lastAlarmAckedTime);
|
||||
}
|
||||
|
||||
public void setLastAlarmAckedTime(BAbsTime bAbsTime) {
|
||||
this.set(lastAlarmAckedTime, (BValue)bAbsTime, null);
|
||||
}
|
||||
|
||||
public BAbsTime getLastAlarmAckedFailureTime() {
|
||||
return (BAbsTime)this.get(lastAlarmAckedFailureTime);
|
||||
}
|
||||
|
||||
public void setLastAlarmAckedFailureTime(BAbsTime bAbsTime) {
|
||||
this.set(lastAlarmAckedFailureTime, (BValue)bAbsTime, null);
|
||||
}
|
||||
|
||||
public String getLastAlarmAckedFailureCause() {
|
||||
return this.getString(lastAlarmAckedFailureCause);
|
||||
}
|
||||
|
||||
public void setLastAlarmAckedFailureCause(String string) {
|
||||
this.setString(lastAlarmAckedFailureCause, string, null);
|
||||
}
|
||||
|
||||
public int getTotalAlarmsAckedToday() {
|
||||
return this.getInt(totalAlarmsAckedToday);
|
||||
}
|
||||
|
||||
public void setTotalAlarmsAckedToday(int n) {
|
||||
this.setInt(totalAlarmsAckedToday, n, null);
|
||||
}
|
||||
|
||||
public int getTotalAlarmAckedFailures() {
|
||||
return this.getInt(totalAlarmAckedFailures);
|
||||
}
|
||||
|
||||
public void setTotalAlarmAckedFailures(int n) {
|
||||
this.setInt(totalAlarmAckedFailures, n, null);
|
||||
}
|
||||
|
||||
public int getTotalMessagesReceivedToday() {
|
||||
return this.getInt(totalMessagesReceivedToday);
|
||||
}
|
||||
|
||||
public void setTotalMessagesReceivedToday(int n) {
|
||||
this.setInt(totalMessagesReceivedToday, n, null);
|
||||
}
|
||||
|
||||
public void resetTotals() {
|
||||
this.invoke(resetTotals, null, null);
|
||||
}
|
||||
|
||||
public void fireAlarmAcked(BAlarmRecord bAlarmRecord) {
|
||||
this.fire(alarmAcked, (BValue)bAlarmRecord, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public final Object fw(int n, Object object, Object object2, Object object3, Object object4) {
|
||||
switch (n) {
|
||||
case 11: {
|
||||
this.fwStarted();
|
||||
break;
|
||||
}
|
||||
case 12: {
|
||||
this.fwStopped();
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
this.fwChanged((Property)object);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return super.fw(n, object, object2, object3, object4);
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
private final void fwStarted() {
|
||||
block4: {
|
||||
this.setStatus(this.getEnabled() ? BStatus.ok : BStatus.disabled);
|
||||
Object object = compRefCountMonitor;
|
||||
synchronized (object) {
|
||||
int n = ++compRefCount;
|
||||
// MONITOREXIT @DISABLED, blocks:[0, 1] lbl6 : MonitorExitStatement: MONITOREXIT : var2_1
|
||||
if (n != 1) break block4;
|
||||
}
|
||||
if (log.isTraceOn()) {
|
||||
log.trace("Starting Alarm Acknowledger Worker");
|
||||
}
|
||||
worker = new Worker((Worker.ITodo)new Queue(512));
|
||||
worker.start("alarmAcknowledger");
|
||||
}
|
||||
this.startMidnightReset();
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
private final void fwStopped() {
|
||||
block5: {
|
||||
if (this.resetTicket != null) {
|
||||
this.resetTicket.cancel();
|
||||
this.resetTicket = null;
|
||||
}
|
||||
Object object = compRefCountMonitor;
|
||||
synchronized (object) {
|
||||
int n = --compRefCount;
|
||||
// MONITOREXIT @DISABLED, blocks:[0, 1] lbl8 : MonitorExitStatement: MONITOREXIT : var2_1
|
||||
if (n > 0) break block5;
|
||||
}
|
||||
if (log.isTraceOn()) {
|
||||
log.trace("Stopping Alarm Acknowledger Worker");
|
||||
}
|
||||
worker.stop();
|
||||
worker = null;
|
||||
}
|
||||
}
|
||||
|
||||
private final void fwChanged(Property property) {
|
||||
if (this.isRunning() && property == enabled) {
|
||||
this.setStatus(this.getEnabled() ? BStatus.ok : BStatus.disabled);
|
||||
}
|
||||
}
|
||||
|
||||
public IFuture post(Action action, BValue bValue, Context context) {
|
||||
if (action == resetTotals) {
|
||||
this.post((Runnable)new Invocation((BComponent)this, action, bValue, context));
|
||||
return null;
|
||||
}
|
||||
return super.post(action, bValue, context);
|
||||
}
|
||||
|
||||
private final void incTotalAlarmsAckedToday() {
|
||||
int n = this.getTotalAlarmsAckedToday();
|
||||
if (++n >= Integer.MAX_VALUE) {
|
||||
n = 0;
|
||||
}
|
||||
this.setTotalAlarmsAckedToday(n);
|
||||
}
|
||||
|
||||
protected final void incTotalAlarmAckedFailures() {
|
||||
int n = this.getTotalAlarmAckedFailures();
|
||||
if (++n >= Integer.MAX_VALUE) {
|
||||
n = 0;
|
||||
}
|
||||
this.setTotalAlarmAckedFailures(n);
|
||||
}
|
||||
|
||||
protected final void incTotalMessagesReceivedToday() {
|
||||
int n = this.getTotalMessagesReceivedToday();
|
||||
if (++n >= Integer.MAX_VALUE) {
|
||||
n = 0;
|
||||
}
|
||||
this.setTotalMessagesReceivedToday(n);
|
||||
}
|
||||
|
||||
public final void doResetTotals() {
|
||||
this.setTotalAlarmsAckedToday(0);
|
||||
this.setTotalAlarmAckedFailures(0);
|
||||
this.setTotalMessagesReceivedToday(0);
|
||||
this.startMidnightReset();
|
||||
}
|
||||
|
||||
protected final void doFail(String string) {
|
||||
this.setLastAlarmAckedFailureCause(string);
|
||||
this.setLastAlarmAckedFailureTime(BAbsTime.now());
|
||||
this.incTotalAlarmAckedFailures();
|
||||
}
|
||||
|
||||
protected final void ackAlarm(BUuid bUuid, String string) {
|
||||
try {
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
BAlarmRecord bAlarmRecord = (BAlarmRecord)bAlarmService.getAlarmDb().getRecord(bUuid).newCopy(true);
|
||||
if (bAlarmRecord == null) {
|
||||
this.doFail("Could not find alarm record to ack (" + this.getType() + ')');
|
||||
return;
|
||||
}
|
||||
if (!bAlarmRecord.isAcknowledged()) {
|
||||
bAlarmRecord.ackAlarm(string);
|
||||
bAlarmRecord.setAckState(BAckState.ackPending);
|
||||
bAlarmService.getAlarmDb().update(bAlarmRecord);
|
||||
this.setLastAlarmAcked(bAlarmRecord.getUuid().encodeToString());
|
||||
bAlarmService.ackAlarm(bAlarmRecord);
|
||||
this.fireAlarmAcked(bAlarmRecord);
|
||||
this.incTotalAlarmsAckedToday();
|
||||
this.setLastAlarmAckedTime(BAbsTime.now());
|
||||
if (log.isTraceOn()) {
|
||||
log.trace(this.getType() + " acknowledged " + bAlarmRecord.getUuid());
|
||||
}
|
||||
} else if (log.isTraceOn()) {
|
||||
log.trace(this.getType() + " already acknowledged " + bAlarmRecord.getUuid());
|
||||
}
|
||||
if (this.getAckAlarmsFromSameSource()) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("alarm:|bql:select from openAlarms where ackState != 'acked' and source='");
|
||||
stringBuffer.append(SlotPath.escape((String)bAlarmRecord.getSource().encodeToString()));
|
||||
stringBuffer.append("'");
|
||||
BITable bITable = (BITable)BOrd.make((String)stringBuffer.toString()).get((BObject)this);
|
||||
Cursor cursor = bITable.cursor();
|
||||
Class clazz = class$javax$baja$alarm$BAlarmRecord;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$alarm$BAlarmRecord = BAlarmAcknowledger.class("[Ljavax.baja.alarm.BAlarmRecord;", false);
|
||||
}
|
||||
Array array = new Array(clazz);
|
||||
while (cursor.next()) {
|
||||
array.add((Object)cursor.get().asValue().newCopy(true));
|
||||
}
|
||||
boolean bl = false;
|
||||
BAlarmRecord[] bAlarmRecordArray = (BAlarmRecord[])array.trim();
|
||||
int n = 0;
|
||||
while (n < bAlarmRecordArray.length) {
|
||||
BAlarmRecord bAlarmRecord2 = (BAlarmRecord)bAlarmRecordArray[n].newCopy(true);
|
||||
bAlarmRecord2.ackAlarm(string);
|
||||
bAlarmRecord2.setAckState(BAckState.ackPending);
|
||||
bAlarmService.getAlarmDb().update(bAlarmRecord2);
|
||||
bAlarmService.ackAlarm(bAlarmRecord2);
|
||||
this.fireAlarmAcked(bAlarmRecord2);
|
||||
this.setLastAlarmAcked(bAlarmRecordArray[n].getUuid().encodeToString());
|
||||
this.incTotalAlarmsAckedToday();
|
||||
bl = true;
|
||||
if (log.isTraceOn()) {
|
||||
log.trace(this.getType() + " also acknowledged " + bAlarmRecordArray[n].getUuid());
|
||||
}
|
||||
++n;
|
||||
}
|
||||
if (bl) {
|
||||
this.setLastAlarmAckedTime(BAbsTime.now());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
String string2 = "Failure to acknowledge alarm (" + this.getType() + ')';
|
||||
log.error(string2, (Throwable)exception);
|
||||
this.doFail(string2);
|
||||
}
|
||||
}
|
||||
|
||||
protected final void post(Runnable runnable) {
|
||||
((Queue)worker.getTodo()).enqueue((Object)runnable);
|
||||
}
|
||||
|
||||
private final void startMidnightReset() {
|
||||
if (this.resetTicket != null) {
|
||||
this.resetTicket.cancel();
|
||||
}
|
||||
BAbsTime bAbsTime = BAbsTime.now();
|
||||
BAbsTime bAbsTime2 = bAbsTime.nextDay();
|
||||
BAbsTime bAbsTime3 = bAbsTime2.timeOfDay(0, 0, 0, 0);
|
||||
this.resetTicket = Clock.schedule((BComponent)this, (BAbsTime)bAbsTime3, (Action)resetTotals, null);
|
||||
}
|
||||
|
||||
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.resetTicket = null;
|
||||
}
|
||||
|
||||
public BAlarmAcknowledger() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$ack$BAlarmAcknowledger;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$ack$BAlarmAcknowledger = BAlarmAcknowledger.class("[Lcom.tridium.alarm.ack.BAlarmAcknowledger;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
log = Log.getLog((String)"alarm.acknowledger");
|
||||
worker = null;
|
||||
compRefCountMonitor = new Object();
|
||||
compRefCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.naming.OrdQuery
|
||||
* javax.baja.naming.OrdQueryList
|
||||
* javax.baja.naming.SyntaxException
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import java.util.HashMap;
|
||||
import javax.baja.naming.OrdQuery;
|
||||
import javax.baja.naming.OrdQueryList;
|
||||
import javax.baja.naming.SyntaxException;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
public class AlarmQuery
|
||||
implements OrdQuery {
|
||||
private String query;
|
||||
private HashMap paramMap;
|
||||
|
||||
public boolean isHost() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isSession() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void normalize(OrdQueryList ordQueryList, int n) {
|
||||
ordQueryList.shiftToSession(n);
|
||||
}
|
||||
|
||||
public String getScheme() {
|
||||
return "alarm";
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return this.query;
|
||||
}
|
||||
|
||||
public boolean isDbQuery() {
|
||||
this.parse();
|
||||
boolean bl = false;
|
||||
if (this.paramMap.size() == 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public BUuid getUuid() {
|
||||
String string = (String)this.paramMap.get("uuid");
|
||||
if (string != null) {
|
||||
return BUuid.make((String)string);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getQueryParameter(String string, String string2) {
|
||||
this.parse();
|
||||
String string3 = (String)this.paramMap.get(string);
|
||||
if (string3 == null) {
|
||||
return string2;
|
||||
}
|
||||
return string3;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "alarm:" + this.query;
|
||||
}
|
||||
|
||||
public void parse() {
|
||||
if (this.paramMap != null) {
|
||||
return;
|
||||
}
|
||||
this.paramMap = new HashMap();
|
||||
if (this.query == null || this.query.length() == 0) {
|
||||
return;
|
||||
}
|
||||
int n = 0;
|
||||
int n2 = this.query.indexOf(61);
|
||||
while (n2 != -1) {
|
||||
String string = null;
|
||||
String string2 = null;
|
||||
int n3 = this.query.indexOf(59, n2);
|
||||
string = this.query.substring(n, n2);
|
||||
string2 = n3 == -1 ? this.query.substring(n2 + 1) : this.query.substring(n2 + 1, n3);
|
||||
this.paramMap.put(string, string2);
|
||||
if (n3 == -1) break;
|
||||
n = n3 + 1;
|
||||
n2 = this.query.indexOf(61, n);
|
||||
if (n2 != -1 || n == this.query.length()) continue;
|
||||
throw new SyntaxException("Expecting =");
|
||||
}
|
||||
}
|
||||
|
||||
public AlarmQuery(String string) {
|
||||
this.query = string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.bql.BSelect
|
||||
* com.tridium.bql.SelectQuery
|
||||
* com.tridium.util.EmptyCursor
|
||||
* javax.baja.bql.BqlQuery
|
||||
* javax.baja.bql.Queryable
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.naming.OrdTarget
|
||||
* javax.baja.query.BExpression
|
||||
* javax.baja.query.util.Exprs
|
||||
* javax.baja.query.util.Predicates
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BSimple
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.IFilter
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import com.tridium.alarm.db.BAlarmDbQueryResult;
|
||||
import com.tridium.alarm.db.BAlarmTable;
|
||||
import com.tridium.bql.BSelect;
|
||||
import com.tridium.bql.SelectQuery;
|
||||
import com.tridium.util.EmptyCursor;
|
||||
import javax.baja.alarm.BAckState;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.bql.BqlQuery;
|
||||
import javax.baja.bql.Queryable;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.naming.OrdTarget;
|
||||
import javax.baja.query.BExpression;
|
||||
import javax.baja.query.util.Exprs;
|
||||
import javax.baja.query.util.Predicates;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BSimple;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.IFilter;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BAckPendingAlarmTable
|
||||
extends BAlarmTable
|
||||
implements Queryable {
|
||||
public static final Type TYPE;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$BAckPendingAlarmTable;
|
||||
|
||||
public Cursor inner() {
|
||||
try {
|
||||
return this.getAlarmDb().getAckPendingAlarms();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
return new EmptyCursor(null);
|
||||
}
|
||||
}
|
||||
|
||||
public BICollection filter(IFilter iFilter) {
|
||||
return new BAckPendingAlarmTable(this.getAlarmDb(), iFilter);
|
||||
}
|
||||
|
||||
public BObject bqlQuery(OrdTarget ordTarget, BqlQuery bqlQuery) {
|
||||
BExpression bExpression = Predicates.eq((String)BAlarmRecord.ackState.getName(), (BSimple)BAckState.ackPending);
|
||||
BSelect bSelect = ((SelectQuery)bqlQuery).getSelect();
|
||||
if (bSelect.hasPredicate()) {
|
||||
bSelect.where(Exprs.builder((BExpression)bSelect.getPredicate().getPredicateExpr()).and(bExpression).getExpression());
|
||||
} else {
|
||||
bSelect.where(bExpression);
|
||||
}
|
||||
return new BAlarmDbQueryResult(this.getAlarmDb(), (BqlQuery)new SelectQuery(bSelect));
|
||||
}
|
||||
|
||||
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 BAckPendingAlarmTable(BAlarmDatabase bAlarmDatabase) {
|
||||
super(bAlarmDatabase);
|
||||
}
|
||||
|
||||
public BAckPendingAlarmTable(BAlarmDatabase bAlarmDatabase, IFilter iFilter) {
|
||||
super(bAlarmDatabase, iFilter);
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$BAckPendingAlarmTable;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$BAckPendingAlarmTable = BAckPendingAlarmTable.class("[Lcom.tridium.alarm.db.BAckPendingAlarmTable;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.util.EmptyCursor
|
||||
* javax.baja.bql.BqlQuery
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.IFilter
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import com.tridium.alarm.db.BAlarmTable;
|
||||
import com.tridium.util.EmptyCursor;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.bql.BqlQuery;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.IFilter;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BAlarmDbQueryResult
|
||||
extends BAlarmTable {
|
||||
public static final Type TYPE;
|
||||
private BqlQuery query;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$BAlarmDbQueryResult;
|
||||
|
||||
protected Cursor inner() {
|
||||
try {
|
||||
return this.getAlarmDb().doBqlQuery(this.query);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
return new EmptyCursor(null);
|
||||
}
|
||||
}
|
||||
|
||||
public BICollection filter(IFilter iFilter) {
|
||||
return new BAlarmDbQueryResult(this.getAlarmDb(), this.query, iFilter);
|
||||
}
|
||||
|
||||
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 BAlarmDbQueryResult(BAlarmDatabase bAlarmDatabase, BqlQuery bqlQuery) {
|
||||
super(bAlarmDatabase);
|
||||
this.query = bqlQuery;
|
||||
}
|
||||
|
||||
public BAlarmDbQueryResult(BAlarmDatabase bAlarmDatabase, BqlQuery bqlQuery, IFilter iFilter) {
|
||||
super(bAlarmDatabase, iFilter);
|
||||
this.query = bqlQuery;
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$BAlarmDbQueryResult;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$BAlarmDbQueryResult = BAlarmDbQueryResult.class("[Lcom.tridium.alarm.db.BAlarmDbQueryResult;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.bql.collection.BqlColumn
|
||||
* com.tridium.bql.collection.BqlColumnList
|
||||
* com.tridium.bql.collection.PropertyColumn
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.collection.BIList
|
||||
* javax.baja.collection.BITable
|
||||
* javax.baja.collection.Column
|
||||
* javax.baja.collection.ColumnList
|
||||
* javax.baja.nre.util.IFilter
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.IFilter
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import com.tridium.alarm.AlarmTableCursor;
|
||||
import com.tridium.bql.collection.BqlColumn;
|
||||
import com.tridium.bql.collection.BqlColumnList;
|
||||
import com.tridium.bql.collection.PropertyColumn;
|
||||
import java.util.ArrayList;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.collection.BIList;
|
||||
import javax.baja.collection.BITable;
|
||||
import javax.baja.collection.Column;
|
||||
import javax.baja.collection.ColumnList;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.IFilter;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public abstract class BAlarmTable
|
||||
extends BObject
|
||||
implements BITable {
|
||||
public static final Type TYPE;
|
||||
private BAlarmDatabase db;
|
||||
private IFilter filter;
|
||||
private Context context;
|
||||
private BqlColumnList columns;
|
||||
private ArrayList recs;
|
||||
private BFacets tableFacets;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$BAlarmTable;
|
||||
|
||||
public BAlarmDatabase getAlarmDb() {
|
||||
return this.db;
|
||||
}
|
||||
|
||||
public Cursor cursor() {
|
||||
return new AlarmTableCursor(this, this.inner(), (javax.baja.nre.util.IFilter)this.filter);
|
||||
}
|
||||
|
||||
protected abstract Cursor inner();
|
||||
|
||||
public BIList toList() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public BITable toTable() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public abstract BICollection filter(IFilter var1);
|
||||
|
||||
public int size() {
|
||||
this.load();
|
||||
return this.recs.size();
|
||||
}
|
||||
|
||||
public BObject get(int n) {
|
||||
return (BObject)this.recs.get(n);
|
||||
}
|
||||
|
||||
public BObject[] list() {
|
||||
this.load();
|
||||
return this.recs.toArray(new BObject[this.recs.size()]);
|
||||
}
|
||||
|
||||
public BObject[] list(BObject[] bObjectArray) {
|
||||
this.load();
|
||||
return this.recs.toArray(bObjectArray);
|
||||
}
|
||||
|
||||
public ColumnList getColumns() {
|
||||
if (this.columns == null) {
|
||||
BAlarmRecord bAlarmRecord = new BAlarmRecord();
|
||||
Property[] propertyArray = bAlarmRecord.getPropertiesArray();
|
||||
BqlColumn[] bqlColumnArray = new BqlColumn[propertyArray.length];
|
||||
int n = 0;
|
||||
while (n < propertyArray.length) {
|
||||
Property property = propertyArray[n];
|
||||
Object var6_6 = null;
|
||||
bqlColumnArray[n] = new PropertyColumn(propertyArray[n]);
|
||||
++n;
|
||||
}
|
||||
this.columns = new BqlColumnList((Column[])bqlColumnArray);
|
||||
}
|
||||
return this.columns;
|
||||
}
|
||||
|
||||
public BObject get(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).get((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public String getString(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getString((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public float getFloat(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getFloat((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public double getDouble(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getDouble((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public int getInt(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getInt((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public long getLong(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getLong((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public boolean getBoolean(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getBoolean((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public int getFlags(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getFlags((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public BFacets getFacets(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getFacets((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public BFacets getTableFacets() {
|
||||
return this.tableFacets;
|
||||
}
|
||||
|
||||
private final void load() {
|
||||
if (this.recs != null) {
|
||||
return;
|
||||
}
|
||||
this.recs = new ArrayList(1000);
|
||||
Cursor cursor = this.cursor();
|
||||
while (cursor.next()) {
|
||||
this.recs.add((BAlarmRecord)((BAlarmRecord)cursor.get()).newCopy());
|
||||
}
|
||||
}
|
||||
|
||||
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 BAlarmTable(BAlarmDatabase bAlarmDatabase) {
|
||||
this(bAlarmDatabase, null);
|
||||
}
|
||||
|
||||
public BAlarmTable(BAlarmDatabase bAlarmDatabase, IFilter iFilter) {
|
||||
this.db = bAlarmDatabase;
|
||||
this.filter = iFilter;
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$BAlarmTable;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$BAlarmTable = BAlarmTable.class("[Lcom.tridium.alarm.db.BAlarmTable;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.naming.BISession
|
||||
* javax.baja.naming.OrdTarget
|
||||
* javax.baja.sys.BInterface
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import com.tridium.alarm.db.AlarmQuery;
|
||||
import javax.baja.naming.BISession;
|
||||
import javax.baja.naming.OrdTarget;
|
||||
import javax.baja.sys.BInterface;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
public interface BIAlarmResolver
|
||||
extends BInterface {
|
||||
public static final Type TYPE;
|
||||
|
||||
public OrdTarget resolve(BISession var1, OrdTarget var2, AlarmQuery var3);
|
||||
|
||||
static {
|
||||
Class clazz = 1.class$com$tridium$alarm$db$BIAlarmResolver;
|
||||
if (clazz == null) {
|
||||
clazz = 1.class$com$tridium$alarm$db$BIAlarmResolver = 1.class("[Lcom.tridium.alarm.db.BIAlarmResolver;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.agent.BIAgent
|
||||
* javax.baja.naming.BISession
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.OrdTarget
|
||||
* javax.baja.naming.UnresolvedException
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BSingleton
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import com.tridium.alarm.db.AlarmQuery;
|
||||
import com.tridium.alarm.db.BIAlarmResolver;
|
||||
import javax.baja.agent.BIAgent;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.naming.BISession;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.OrdTarget;
|
||||
import javax.baja.naming.UnresolvedException;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BSingleton;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class BLocalAlarmResolver
|
||||
extends BSingleton
|
||||
implements BIAlarmResolver,
|
||||
BIAgent {
|
||||
public static final BLocalAlarmResolver INSTANCE = new BLocalAlarmResolver();
|
||||
public static final Type TYPE;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$BLocalAlarmResolver;
|
||||
|
||||
public final OrdTarget resolve(BISession bISession, OrdTarget ordTarget, AlarmQuery alarmQuery) {
|
||||
BOrd bOrd = BOrd.make((String)"service:alarm:AlarmService");
|
||||
BAlarmService bAlarmService = (BAlarmService)bOrd.resolve(ordTarget.get()).get();
|
||||
try {
|
||||
if (alarmQuery.isDbQuery()) {
|
||||
return new OrdTarget(ordTarget, (BObject)bAlarmService.getAlarmDb());
|
||||
}
|
||||
String string = alarmQuery.getQueryParameter("uuid", null);
|
||||
if (string != null) {
|
||||
BAlarmRecord bAlarmRecord = bAlarmService.getAlarmDb().getRecord(BUuid.make((String)string));
|
||||
if (bAlarmRecord == null) {
|
||||
throw new UnresolvedException(string);
|
||||
}
|
||||
return new OrdTarget(ordTarget, (BObject)bAlarmRecord);
|
||||
}
|
||||
throw new UnresolvedException("Invalid alarm query: " + alarmQuery);
|
||||
}
|
||||
catch (UnresolvedException unresolvedException) {
|
||||
throw unresolvedException;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new UnresolvedException("Cannot access alarm database.", (Throwable)exception);
|
||||
}
|
||||
}
|
||||
|
||||
public final 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());
|
||||
}
|
||||
}
|
||||
|
||||
private BLocalAlarmResolver() {
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$BLocalAlarmResolver;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$BLocalAlarmResolver = BLocalAlarmResolver.class("[Lcom.tridium.alarm.db.BLocalAlarmResolver;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.bql.BSelect
|
||||
* com.tridium.bql.SelectQuery
|
||||
* com.tridium.util.EmptyCursor
|
||||
* javax.baja.bql.BqlQuery
|
||||
* javax.baja.bql.Queryable
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.naming.OrdTarget
|
||||
* javax.baja.query.BExpression
|
||||
* javax.baja.query.util.Exprs
|
||||
* javax.baja.query.util.Predicates
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BSimple
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.IFilter
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import com.tridium.alarm.db.BAlarmDbQueryResult;
|
||||
import com.tridium.alarm.db.BAlarmTable;
|
||||
import com.tridium.bql.BSelect;
|
||||
import com.tridium.bql.SelectQuery;
|
||||
import com.tridium.util.EmptyCursor;
|
||||
import javax.baja.alarm.BAckState;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BSourceState;
|
||||
import javax.baja.bql.BqlQuery;
|
||||
import javax.baja.bql.Queryable;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.naming.OrdTarget;
|
||||
import javax.baja.query.BExpression;
|
||||
import javax.baja.query.util.Exprs;
|
||||
import javax.baja.query.util.Predicates;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BSimple;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.IFilter;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BOpenAlarmTable
|
||||
extends BAlarmTable
|
||||
implements Queryable {
|
||||
public static final Type TYPE;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$BOpenAlarmTable;
|
||||
|
||||
public Cursor inner() {
|
||||
try {
|
||||
return this.getAlarmDb().getOpenAlarms();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
return new EmptyCursor(null);
|
||||
}
|
||||
}
|
||||
|
||||
public BICollection filter(IFilter iFilter) {
|
||||
return new BOpenAlarmTable(this.getAlarmDb(), iFilter);
|
||||
}
|
||||
|
||||
public BObject bqlQuery(OrdTarget ordTarget, BqlQuery bqlQuery) {
|
||||
BExpression bExpression = Predicates.and((BExpression)Predicates.not((BExpression)Predicates.and((BExpression)Predicates.eq((String)BAlarmRecord.ackState.getName(), (BSimple)BAckState.acked), (BExpression)Predicates.eq((String)BAlarmRecord.sourceState.getName(), (BSimple)BSourceState.normal))), (BExpression)Predicates.not((BExpression)Predicates.and((BExpression)Predicates.eq((String)BAlarmRecord.ackState.getName(), (BSimple)BAckState.acked), (BExpression)Predicates.eq((String)BAlarmRecord.sourceState.getName(), (BSimple)BSourceState.normal))));
|
||||
BSelect bSelect = ((SelectQuery)bqlQuery).getSelect();
|
||||
if (bSelect.hasPredicate()) {
|
||||
bSelect.where(Exprs.builder((BExpression)bSelect.getPredicate().getPredicateExpr()).and(bExpression).getExpression());
|
||||
} else {
|
||||
bSelect.where(bExpression);
|
||||
}
|
||||
return new BAlarmDbQueryResult(this.getAlarmDb(), (BqlQuery)new SelectQuery(bSelect));
|
||||
}
|
||||
|
||||
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 BOpenAlarmTable(BAlarmDatabase bAlarmDatabase) {
|
||||
super(bAlarmDatabase);
|
||||
}
|
||||
|
||||
public BOpenAlarmTable(BAlarmDatabase bAlarmDatabase, IFilter iFilter) {
|
||||
super(bAlarmDatabase, iFilter);
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$BOpenAlarmTable;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$BOpenAlarmTable = BOpenAlarmTable.class("[Lcom.tridium.alarm.db.BOpenAlarmTable;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.sys.BBoolean
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.Context
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.IndexEntry;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.Context;
|
||||
|
||||
public class AckPendingIndex {
|
||||
private static final BFacets showSecs = BFacets.make((String)"showSeconds", (BIDataValue)BBoolean.TRUE);
|
||||
private IndexEntry first = null;
|
||||
private IndexEntry last = null;
|
||||
private int size = 0;
|
||||
|
||||
public int getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public IndexEntry getFirstEntry() {
|
||||
return this.first;
|
||||
}
|
||||
|
||||
public void add(IndexEntry indexEntry) {
|
||||
if (indexEntry.isAckPending()) {
|
||||
return;
|
||||
}
|
||||
indexEntry.setAckPending(true);
|
||||
indexEntry.nextAckPending = null;
|
||||
indexEntry.prevAckPending = null;
|
||||
if (this.size == 0) {
|
||||
this.first = this.last = indexEntry;
|
||||
} else {
|
||||
IndexEntry indexEntry2 = indexEntry.prevTimestamp;
|
||||
while (indexEntry2 != null && !indexEntry2.isAckPending()) {
|
||||
indexEntry2 = indexEntry2.prevTimestamp;
|
||||
}
|
||||
if (indexEntry2 == null) {
|
||||
if (this.first == null) {
|
||||
this.first = this.last = indexEntry;
|
||||
} else {
|
||||
indexEntry.nextAckPending = this.first;
|
||||
this.first.prevAckPending = indexEntry;
|
||||
this.first = indexEntry;
|
||||
}
|
||||
} else {
|
||||
indexEntry.nextAckPending = indexEntry2.nextAckPending;
|
||||
indexEntry.prevAckPending = indexEntry2;
|
||||
if (indexEntry2.nextAckPending != null) {
|
||||
indexEntry2.nextAckPending.prevAckPending = indexEntry;
|
||||
}
|
||||
indexEntry2.nextAckPending = indexEntry;
|
||||
if (indexEntry.prevAckPending == this.last) {
|
||||
this.last = indexEntry;
|
||||
}
|
||||
}
|
||||
}
|
||||
++this.size;
|
||||
}
|
||||
|
||||
public void remove(IndexEntry indexEntry) {
|
||||
if (this.size == 0 || indexEntry == null) {
|
||||
return;
|
||||
}
|
||||
if (!indexEntry.isAckPending()) {
|
||||
return;
|
||||
}
|
||||
indexEntry.setAckPending(false);
|
||||
if (indexEntry.prevAckPending != null) {
|
||||
indexEntry.prevAckPending.nextAckPending = indexEntry.nextAckPending;
|
||||
}
|
||||
if (indexEntry.nextAckPending != null) {
|
||||
indexEntry.nextAckPending.prevAckPending = indexEntry.prevAckPending;
|
||||
}
|
||||
if (indexEntry == this.first) {
|
||||
this.first = indexEntry.nextAckPending;
|
||||
}
|
||||
if (indexEntry == this.last) {
|
||||
this.last = indexEntry.prevAckPending;
|
||||
}
|
||||
indexEntry.nextAckPending = null;
|
||||
indexEntry.prevAckPending = null;
|
||||
--this.size;
|
||||
}
|
||||
|
||||
public void dump() {
|
||||
IndexEntry indexEntry = this.first;
|
||||
int n = 0;
|
||||
while (indexEntry != null) {
|
||||
System.out.println(n++ + ") " + indexEntry.timestamp.toString((Context)showSecs) + " ackPending=" + indexEntry.isAckPending());
|
||||
indexEntry = indexEntry.nextAckPending;
|
||||
}
|
||||
}
|
||||
|
||||
public void verify() {
|
||||
IndexEntry indexEntry = null;
|
||||
IndexEntry indexEntry2 = this.first;
|
||||
int n = 0;
|
||||
while (indexEntry2 != null) {
|
||||
++n;
|
||||
if (indexEntry != null && indexEntry.timestamp.isAfter(indexEntry2.timestamp)) {
|
||||
throw new IllegalStateException("Invalid ascending order. " + indexEntry2.timestamp.toString((Context)showSecs) + " is before " + indexEntry.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
if (!indexEntry2.isAckPending()) {
|
||||
throw new IllegalStateException("Cleared alarm in ackPending index, ascending. " + indexEntry2.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = indexEntry2.nextAckPending;
|
||||
}
|
||||
if (this.size != n) {
|
||||
throw new IllegalStateException("Invalid ascending count. size=" + this.size + ", count=" + n);
|
||||
}
|
||||
indexEntry = null;
|
||||
indexEntry2 = this.last;
|
||||
n = 0;
|
||||
while (indexEntry2 != null) {
|
||||
++n;
|
||||
if (indexEntry != null && indexEntry.timestamp.isBefore(indexEntry2.timestamp)) {
|
||||
throw new IllegalStateException("Invalid descending order. " + indexEntry2.timestamp.toString((Context)showSecs) + " is after " + indexEntry.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
if (!indexEntry2.isAckPending()) {
|
||||
throw new IllegalStateException("Cleared alarm in ackPending index, descending. " + indexEntry2.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = indexEntry2.prevAckPending;
|
||||
}
|
||||
if (this.size != n) {
|
||||
throw new IllegalStateException("Invalid descending count. size=" + this.size + ", count=" + n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BBoolean
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.Context
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.IndexEntry;
|
||||
import com.tridium.alarm.db.file.SkipList;
|
||||
import java.util.HashMap;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.Context;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class AlarmSourceIndex {
|
||||
private static final BFacets showSecs = BFacets.make((String)"showSeconds", (BIDataValue)BBoolean.TRUE);
|
||||
private HashMap table;
|
||||
private double probability;
|
||||
private int maxSizePerSource;
|
||||
|
||||
public synchronized IndexEntry getListForSource(BOrdList bOrdList) {
|
||||
SourceList sourceList = (SourceList)this.table.get(bOrdList);
|
||||
if (sourceList == null) {
|
||||
return null;
|
||||
}
|
||||
return sourceList.getFirstEntry();
|
||||
}
|
||||
|
||||
public synchronized void add(BOrdList bOrdList, IndexEntry indexEntry) {
|
||||
SourceList sourceList = (SourceList)this.table.get(bOrdList);
|
||||
if (sourceList == null) {
|
||||
sourceList = new SourceList(this.probability, this.maxSizePerSource);
|
||||
this.table.put(bOrdList, sourceList);
|
||||
sourceList.add(indexEntry);
|
||||
} else {
|
||||
sourceList.add(indexEntry);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void remove(BOrdList bOrdList, IndexEntry indexEntry) {
|
||||
SourceList sourceList = (SourceList)this.table.get(bOrdList);
|
||||
if (sourceList == null) {
|
||||
return;
|
||||
}
|
||||
sourceList.remove(indexEntry);
|
||||
}
|
||||
|
||||
public IndexEntry getNext(IndexEntry indexEntry) {
|
||||
return indexEntry.nextSource[0];
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.table = new HashMap(1001);
|
||||
}
|
||||
|
||||
public AlarmSourceIndex(double d, int n) {
|
||||
this.this();
|
||||
this.probability = d;
|
||||
this.maxSizePerSource = n;
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class SourceList
|
||||
extends SkipList {
|
||||
public int compare(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
int n = indexEntry.timestamp.compareTo((Object)indexEntry2.timestamp);
|
||||
if (n == 0) {
|
||||
return indexEntry.pageIndex - indexEntry2.pageIndex;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
public int compareToKey(IndexEntry indexEntry, Object object) {
|
||||
return indexEntry.timestamp.compareTo((Object)((BAbsTime)object));
|
||||
}
|
||||
|
||||
public int getLevel(IndexEntry indexEntry) {
|
||||
return indexEntry.nextSource.length;
|
||||
}
|
||||
|
||||
public void setLevel(IndexEntry indexEntry, int n) {
|
||||
indexEntry.nextSource = new IndexEntry[n];
|
||||
}
|
||||
|
||||
public IndexEntry getNext(IndexEntry indexEntry, int n) {
|
||||
return indexEntry.nextSource[n];
|
||||
}
|
||||
|
||||
public void setNext(IndexEntry indexEntry, int n, IndexEntry indexEntry2) {
|
||||
indexEntry.nextSource[n] = indexEntry2;
|
||||
}
|
||||
|
||||
public IndexEntry getPrev(IndexEntry indexEntry) {
|
||||
return indexEntry.prevSource;
|
||||
}
|
||||
|
||||
public void setPrev(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
indexEntry.prevSource = indexEntry2;
|
||||
}
|
||||
|
||||
public String entryToString(IndexEntry indexEntry) {
|
||||
return indexEntry.timestamp.toString((Context)BAlarmRecord.TIMESTAMP_FACETS) + " => " + indexEntry.pageIndex;
|
||||
}
|
||||
|
||||
public SourceList(double d, int n) {
|
||||
super(d, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,794 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.io.ByteBuffer
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Clock
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AckPendingIndex;
|
||||
import com.tridium.alarm.db.file.AlarmSourceIndex;
|
||||
import com.tridium.alarm.db.file.AlarmStoreHeader;
|
||||
import com.tridium.alarm.db.file.Block;
|
||||
import com.tridium.alarm.db.file.BlockCache;
|
||||
import com.tridium.alarm.db.file.FreePageMap;
|
||||
import com.tridium.alarm.db.file.IndexEntry;
|
||||
import com.tridium.alarm.db.file.OpenIndex;
|
||||
import com.tridium.alarm.db.file.Page;
|
||||
import com.tridium.alarm.db.file.PageReader;
|
||||
import com.tridium.alarm.db.file.TimestampIndex;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import javax.baja.alarm.BAlarmClass;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.io.ByteBuffer;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Clock;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class AlarmStore {
|
||||
private static final int BLOCK_CACHE_SIZE = 10;
|
||||
private static final int MAX_SIZE = 250000;
|
||||
private static final int MAX_SIZE_PER_SOURCE = 10000;
|
||||
private File alarmFile;
|
||||
private RandomAccessFile io;
|
||||
private int capacity;
|
||||
private AlarmStoreHeader header;
|
||||
private FreePageMap freeMap;
|
||||
private BlockCache blockCache;
|
||||
private ByteBuffer writeBuf;
|
||||
private PageReader reader;
|
||||
private int[] recPages;
|
||||
private HashMap byUuid;
|
||||
private TimestampIndex timestampIndex;
|
||||
private AlarmSourceIndex sourceIndex;
|
||||
private OpenIndex openIndex;
|
||||
private AckPendingIndex ackPendingIndex;
|
||||
private BAlarmRecord trimRec;
|
||||
private BAlarmService alarmService;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmClass;
|
||||
|
||||
public AlarmStoreHeader getHeader() {
|
||||
return this.header;
|
||||
}
|
||||
|
||||
public void setCapacity(int n) {
|
||||
this.capacity = n;
|
||||
}
|
||||
|
||||
public synchronized void open() throws IOException {
|
||||
this.byUuid = new HashMap();
|
||||
this.timestampIndex = new TimestampIndex(0.5, 250000);
|
||||
this.sourceIndex = new AlarmSourceIndex(0.5, 10000);
|
||||
this.openIndex = new OpenIndex();
|
||||
this.ackPendingIndex = new AckPendingIndex();
|
||||
this.blockCache = new BlockCache(this, 10);
|
||||
this.io = new RandomAccessFile(this.alarmFile, "rw");
|
||||
try {
|
||||
if (this.io.length() == 0L) {
|
||||
this.create();
|
||||
} else {
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
this.io.close();
|
||||
this.io = null;
|
||||
throw iOException;
|
||||
}
|
||||
catch (RuntimeException runtimeException) {
|
||||
this.io.close();
|
||||
this.io = null;
|
||||
throw runtimeException;
|
||||
}
|
||||
this.writeBuf = new ByteBuffer(this.header.getPageSize());
|
||||
}
|
||||
|
||||
private final void create() throws IOException {
|
||||
this.header = new AlarmStoreHeader(new BAlarmRecord().getSerialVersionId());
|
||||
this.io.seek(0L);
|
||||
this.header.write(this.io);
|
||||
this.freeMap = new FreePageMap();
|
||||
BAlarmDatabase.log.message("Created");
|
||||
}
|
||||
|
||||
private final void init() throws IOException {
|
||||
BAlarmDatabase.log.message("Loading...");
|
||||
this.header = new AlarmStoreHeader();
|
||||
this.io.seek(0L);
|
||||
this.header.read(this.io);
|
||||
int n = new BAlarmRecord().getSerialVersionId();
|
||||
if (this.header.getRecordVersion() != n) {
|
||||
throw new IOException("Incompatible record versions. (expected=" + n + ", actual=" + this.header.getRecordVersion() + ')');
|
||||
}
|
||||
this.freeMap = new FreePageMap();
|
||||
int n2 = (int)((this.io.length() - this.header.getDataOffset()) / (long)this.header.getPageSize());
|
||||
BAlarmRecord bAlarmRecord = new BAlarmRecord();
|
||||
BAlarmRecord bAlarmRecord2 = new BAlarmRecord();
|
||||
long l = Clock.ticks();
|
||||
int n3 = 0;
|
||||
int n4 = 0;
|
||||
while (n4 < n2) {
|
||||
block11: {
|
||||
block13: {
|
||||
block12: {
|
||||
Page page = this.readPage(n4);
|
||||
if (page.getPageOfRecord() != 0) break block11;
|
||||
if ((bAlarmRecord = this.readRecord(n4, bAlarmRecord, this.freeMap)) != null) break block12;
|
||||
if (++n3 == 20) {
|
||||
throw new IOException("Alarm database is invalid. Too many invalid records read during init.");
|
||||
}
|
||||
break block11;
|
||||
}
|
||||
IndexEntry indexEntry = (IndexEntry)this.byUuid.get(bAlarmRecord.getUuid());
|
||||
if (indexEntry == null) break block13;
|
||||
if ((bAlarmRecord2 = this.readRecord(indexEntry.pageIndex, bAlarmRecord2, null)).getLastUpdate().isAfter(bAlarmRecord.getLastUpdate())) break block11;
|
||||
this.freePageRun(indexEntry.pageIndex);
|
||||
}
|
||||
this.addToIndices(bAlarmRecord, n4);
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass.getName().equals(bAlarmRecord.getAlarmClass())) {
|
||||
bAlarmClass.setTotalAlarmCount(bAlarmClass.getTotalAlarmCount() + 1);
|
||||
if (!bAlarmRecord.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() + 1);
|
||||
}
|
||||
if (bAlarmRecord.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() + 1);
|
||||
}
|
||||
if (!bAlarmRecord.isNormal()) {
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
++n4;
|
||||
}
|
||||
long l2 = Clock.ticks();
|
||||
BAlarmDatabase.log.message("Loaded [" + (l2 - l) + "ms, " + this.getRecordCount() + " alarms, " + n2 + " pages]");
|
||||
}
|
||||
|
||||
public synchronized void close() {
|
||||
if (this.io != null) {
|
||||
try {
|
||||
this.io.close();
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
this.io = null;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void append(BAlarmRecord bAlarmRecord) throws IOException {
|
||||
if (!this.byUuid.containsKey(bAlarmRecord.getUuid())) {
|
||||
this.append(bAlarmRecord, false);
|
||||
this.trimToCapacity();
|
||||
} else {
|
||||
this.update(bAlarmRecord);
|
||||
}
|
||||
}
|
||||
|
||||
private final synchronized void append(BAlarmRecord bAlarmRecord, boolean bl) throws IOException {
|
||||
Object object;
|
||||
this.writeBuf.reset();
|
||||
bAlarmRecord.write((DataOutput)this.writeBuf);
|
||||
bAlarmRecord.getUuid().encode((DataOutput)this.writeBuf);
|
||||
byte[] byArray = this.writeBuf.getBytes();
|
||||
int n = this.writeBuf.getLength();
|
||||
int n2 = 0;
|
||||
int n3 = this.header.getPageSize() - 12;
|
||||
int n4 = n / n3;
|
||||
if (n % n3 != 0) {
|
||||
++n4;
|
||||
}
|
||||
int[] nArray = this.takePages(n4);
|
||||
if (!bl) {
|
||||
object = this.alarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (object.getName().equals(bAlarmRecord.getAlarmClass())) {
|
||||
object.setTotalAlarmCount(object.getTotalAlarmCount() + 1);
|
||||
if (!bAlarmRecord.isAcknowledged()) {
|
||||
object.setUnackedAlarmCount(object.getUnackedAlarmCount() + 1);
|
||||
}
|
||||
if (bAlarmRecord.isOpen()) {
|
||||
object.setOpenAlarmCount(object.getOpenAlarmCount() + 1);
|
||||
}
|
||||
if (!bAlarmRecord.isNormal()) {
|
||||
object.setInAlarmCount(object.getInAlarmCount() + 1);
|
||||
}
|
||||
}
|
||||
this.addToIndices(bAlarmRecord, nArray[0]);
|
||||
} else {
|
||||
object = (IndexEntry)this.byUuid.get(bAlarmRecord.getUuid());
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
BAlarmRecord bAlarmRecord2 = this.readRecord(((IndexEntry)object).pageIndex, null);
|
||||
if (bAlarmClass.getName().equals(bAlarmRecord.getAlarmClass())) {
|
||||
if (!((IndexEntry)object).isAcked() && bAlarmRecord.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() - 1);
|
||||
} else if (((IndexEntry)object).isAcked() && !bAlarmRecord.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() + 1);
|
||||
}
|
||||
if (!((IndexEntry)object).isOpen() && bAlarmRecord.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() + 1);
|
||||
}
|
||||
if (((IndexEntry)object).isOpen() && !bAlarmRecord.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() - 1);
|
||||
}
|
||||
if (((IndexEntry)object).isNormal() && !bAlarmRecord.isNormal()) {
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() + 1);
|
||||
}
|
||||
if (!((IndexEntry)object).isNormal() && bAlarmRecord.isNormal()) {
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() - 1);
|
||||
}
|
||||
}
|
||||
this.updateIndices(bAlarmRecord, bAlarmRecord2, nArray[0]);
|
||||
}
|
||||
int n5 = 0;
|
||||
while (n5 < n4) {
|
||||
int n6 = nArray[n5];
|
||||
int n7 = n5 == n4 - 1 ? -1 : nArray[n5 + 1];
|
||||
Page page = this.readPage(n6);
|
||||
int n8 = Math.min(n - n2, n3);
|
||||
page.write(n5, n4, n7, byArray, n2, n8);
|
||||
n2 += n8;
|
||||
++n5;
|
||||
}
|
||||
if (n2 != n) {
|
||||
throw new IOException("Write error: " + n2 + " of " + n + " bytes written.");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void update(BAlarmRecord bAlarmRecord) throws IOException {
|
||||
IndexEntry indexEntry = (IndexEntry)this.byUuid.get(bAlarmRecord.getUuid());
|
||||
int n = -1;
|
||||
if (indexEntry != null) {
|
||||
n = indexEntry.pageIndex;
|
||||
}
|
||||
boolean bl = false;
|
||||
if (indexEntry != null) {
|
||||
bl = true;
|
||||
}
|
||||
this.append(bAlarmRecord, bl);
|
||||
if (n != -1) {
|
||||
this.freePageRun(n);
|
||||
}
|
||||
}
|
||||
|
||||
private final synchronized void remove(IndexEntry indexEntry, BAlarmRecord bAlarmRecord) throws IOException {
|
||||
if (indexEntry == null && bAlarmRecord == null) {
|
||||
return;
|
||||
}
|
||||
if (indexEntry == null && (indexEntry = (IndexEntry)this.byUuid.get(bAlarmRecord.getUuid())) == null) {
|
||||
return;
|
||||
}
|
||||
bAlarmRecord = this.readRecord(indexEntry.pageIndex, bAlarmRecord, null);
|
||||
this.byUuid.remove(bAlarmRecord.getUuid());
|
||||
this.timestampIndex.remove(indexEntry);
|
||||
this.sourceIndex.remove(bAlarmRecord.getSource(), indexEntry);
|
||||
if (indexEntry.isOpen()) {
|
||||
this.openIndex.remove(indexEntry);
|
||||
}
|
||||
if (indexEntry.isAckPending()) {
|
||||
this.ackPendingIndex.remove(indexEntry);
|
||||
}
|
||||
this.freePageRun(indexEntry.pageIndex);
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass.getName().equals(bAlarmRecord.getAlarmClass())) {
|
||||
bAlarmClass.setTotalAlarmCount(bAlarmClass.getTotalAlarmCount() - 1);
|
||||
if (!bAlarmRecord.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() - 1);
|
||||
}
|
||||
if (bAlarmRecord.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() - 1);
|
||||
}
|
||||
if (!bAlarmRecord.isNormal()) {
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() - 1);
|
||||
}
|
||||
}
|
||||
indexEntry.nextTimestamp = null;
|
||||
indexEntry.prevTimestamp = null;
|
||||
indexEntry.nextSource = null;
|
||||
indexEntry.prevSource = null;
|
||||
indexEntry = null;
|
||||
}
|
||||
|
||||
private final synchronized void addToIndices(BAlarmRecord bAlarmRecord, int n) {
|
||||
IndexEntry indexEntry = new IndexEntry(bAlarmRecord, n);
|
||||
this.byUuid.put(bAlarmRecord.getUuid(), indexEntry);
|
||||
this.timestampIndex.add(indexEntry);
|
||||
this.sourceIndex.add(bAlarmRecord.getSource(), indexEntry);
|
||||
if (bAlarmRecord.isOpen()) {
|
||||
this.openIndex.add(indexEntry);
|
||||
}
|
||||
if (bAlarmRecord.isAckPending()) {
|
||||
this.ackPendingIndex.add(indexEntry);
|
||||
}
|
||||
indexEntry.setAcked(bAlarmRecord.isAcknowledged());
|
||||
indexEntry.setNormal(bAlarmRecord.isNormal());
|
||||
indexEntry.setAckPending(bAlarmRecord.isAckPending());
|
||||
}
|
||||
|
||||
private final synchronized void updateIndices(BAlarmRecord bAlarmRecord, BAlarmRecord bAlarmRecord2, int n) {
|
||||
IndexEntry indexEntry = (IndexEntry)this.byUuid.get(bAlarmRecord.getUuid());
|
||||
if (indexEntry != null) {
|
||||
this.byUuid.remove(bAlarmRecord.getUuid());
|
||||
this.timestampIndex.remove(indexEntry);
|
||||
this.sourceIndex.remove(bAlarmRecord2.getSource(), indexEntry);
|
||||
if (indexEntry.isOpen()) {
|
||||
this.openIndex.remove(indexEntry);
|
||||
}
|
||||
if (indexEntry.isAckPending()) {
|
||||
this.ackPendingIndex.remove(indexEntry);
|
||||
}
|
||||
}
|
||||
this.addToIndices(bAlarmRecord, n);
|
||||
}
|
||||
|
||||
public synchronized void flush() throws IOException {
|
||||
this.blockCache.flush();
|
||||
}
|
||||
|
||||
public synchronized int getRecordCount() {
|
||||
return this.timestampIndex.getSize();
|
||||
}
|
||||
|
||||
public synchronized BAlarmRecord getRecord(BUuid bUuid) throws IOException {
|
||||
IndexEntry indexEntry = (IndexEntry)this.byUuid.get(bUuid);
|
||||
if (indexEntry != null) {
|
||||
return this.readRecord(indexEntry.pageIndex, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public synchronized Cursor scan() {
|
||||
return new TimestampCursor(this, this.timestampIndex.getFirstEntry(), null);
|
||||
}
|
||||
|
||||
public synchronized Cursor timeQuery(BAbsTime bAbsTime, BAbsTime bAbsTime2) {
|
||||
IndexEntry indexEntry = null;
|
||||
if (bAbsTime == null || bAbsTime.isNull()) {
|
||||
indexEntry = this.timestampIndex.getFirstEntry();
|
||||
} else {
|
||||
indexEntry = this.timestampIndex.find(bAbsTime);
|
||||
if (indexEntry != null) {
|
||||
indexEntry = indexEntry.nextTimestamp[0];
|
||||
}
|
||||
}
|
||||
return new TimestampCursor(this, indexEntry, bAbsTime2);
|
||||
}
|
||||
|
||||
public synchronized Cursor getAlarmsForSource(BOrdList bOrdList) throws IOException {
|
||||
IndexEntry indexEntry = this.sourceIndex.getListForSource(bOrdList);
|
||||
return new SourceCursor(this, indexEntry, null);
|
||||
}
|
||||
|
||||
public synchronized Cursor getOpenAlarms() throws IOException {
|
||||
IndexEntry indexEntry = this.openIndex.getFirstEntry();
|
||||
return new OpenCursor(this, indexEntry, null);
|
||||
}
|
||||
|
||||
public synchronized Cursor getAckPendingAlarms() throws IOException {
|
||||
IndexEntry indexEntry = this.ackPendingIndex.getFirstEntry();
|
||||
return new AckPendingCursor(this, indexEntry, null);
|
||||
}
|
||||
|
||||
private final synchronized int[] takePages(int n) throws IOException {
|
||||
if (this.recPages == null || this.recPages.length < n) {
|
||||
this.recPages = new int[n];
|
||||
}
|
||||
int n2 = 0;
|
||||
while (n2 < n) {
|
||||
this.recPages[n2] = this.nextFreePage();
|
||||
this.freeMap.setFree(this.recPages[n2], false);
|
||||
++n2;
|
||||
}
|
||||
return this.recPages;
|
||||
}
|
||||
|
||||
private final synchronized void freePageRun(int n) throws IOException {
|
||||
int n2 = n;
|
||||
do {
|
||||
Page page;
|
||||
if ((page = this.readPage(n2)) == null) {
|
||||
return;
|
||||
}
|
||||
this.freeMap.setFree(n2, true);
|
||||
n2 = page.getNextPage();
|
||||
page.clear();
|
||||
} while (n2 != -1);
|
||||
}
|
||||
|
||||
private final synchronized int nextFreePage() throws IOException {
|
||||
int n = this.freeMap.getFreePage();
|
||||
if (n == -1) {
|
||||
this.grow();
|
||||
}
|
||||
if ((n = this.freeMap.getFreePage()) == -1) {
|
||||
throw new IOException("Cannot allocate a new page.");
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
public synchronized Page readPage(int n) throws IOException {
|
||||
int n2 = this.header.getPagesPerBlock();
|
||||
int n3 = n / n2;
|
||||
int n4 = n - n3 * n2;
|
||||
return this.getBlock(n3).getPage(n4);
|
||||
}
|
||||
|
||||
private final synchronized void grow() throws IOException {
|
||||
int n = this.header.getPageSize();
|
||||
int n2 = this.header.getPagesPerBlock();
|
||||
int n3 = n * n2;
|
||||
int n4 = (int)((this.io.length() - this.header.getDataOffset()) / (long)n3);
|
||||
Block block = new Block(this, n4);
|
||||
block.clear();
|
||||
this.io.seek(this.io.length());
|
||||
block.write(this.io);
|
||||
this.freeMap.addFreePages(this.header.getPagesPerBlock());
|
||||
}
|
||||
|
||||
synchronized Block getBlock(int n) throws IOException {
|
||||
Block block = this.blockCache.getBlock(n);
|
||||
if (block == null) {
|
||||
block = this.readBlock(n);
|
||||
this.blockCache.add(block);
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
||||
synchronized Block readBlock(int n) throws IOException {
|
||||
Block block = new Block(this, n);
|
||||
long l = this.header.getDataOffset() + (long)(n * block.getSize());
|
||||
this.io.seek(l);
|
||||
block.read(this.io);
|
||||
return block;
|
||||
}
|
||||
|
||||
synchronized void writeBlock(Block block) throws IOException {
|
||||
if (!block.isDirty()) {
|
||||
return;
|
||||
}
|
||||
int n = block.getIndex();
|
||||
long l = this.header.getDataOffset() + (long)(n * block.getSize());
|
||||
this.io.seek(l);
|
||||
block.write(this.io);
|
||||
}
|
||||
|
||||
public BAlarmRecord readRecord(int n, BAlarmRecord bAlarmRecord) throws IOException {
|
||||
return this.readRecord(n, bAlarmRecord, null);
|
||||
}
|
||||
|
||||
public synchronized BAlarmRecord readRecord(int n, BAlarmRecord bAlarmRecord, FreePageMap freePageMap) throws IOException {
|
||||
if (bAlarmRecord == null) {
|
||||
bAlarmRecord = new BAlarmRecord();
|
||||
}
|
||||
if (this.reader == null) {
|
||||
this.reader = new PageReader(this, n);
|
||||
} else {
|
||||
this.reader.init(n);
|
||||
}
|
||||
try {
|
||||
bAlarmRecord.read(this.reader);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BAlarmDatabase.log.error("Unable to read record", (Throwable)exception);
|
||||
return null;
|
||||
}
|
||||
BUuid bUuid = (BUuid)BUuid.DEFAULT.decode((DataInput)this.reader);
|
||||
if (!bAlarmRecord.getUuid().equals((Object)bUuid)) {
|
||||
return null;
|
||||
}
|
||||
if (freePageMap != null) {
|
||||
int n2 = this.reader.getPageCount();
|
||||
int n3 = 0;
|
||||
while (n3 < n2) {
|
||||
freePageMap.setFree(this.reader.getPageIndex(n3), false);
|
||||
++n3;
|
||||
}
|
||||
}
|
||||
return bAlarmRecord;
|
||||
}
|
||||
|
||||
public synchronized void trimToCapacity() throws IOException {
|
||||
if (this.timestampIndex.getSize() > this.capacity) {
|
||||
if (this.trimRec == null) {
|
||||
this.trimRec = new BAlarmRecord();
|
||||
}
|
||||
while (this.timestampIndex.getSize() > this.capacity) {
|
||||
this.remove(this.timestampIndex.getFirstEntry(), this.trimRec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void clearAllRecords(Context context) throws IOException {
|
||||
this.close();
|
||||
Class clazz = class$javax$baja$alarm$BAlarmClass;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$alarm$BAlarmClass = AlarmStore.class("[Ljavax.baja.alarm.BAlarmClass;", false);
|
||||
}
|
||||
BAlarmClass[] bAlarmClassArray = (BAlarmClass[])this.alarmService.getChildren(clazz);
|
||||
int n = 0;
|
||||
while (n < bAlarmClassArray.length) {
|
||||
bAlarmClassArray[n].setTotalAlarmCount(0);
|
||||
bAlarmClassArray[n].setUnackedAlarmCount(0);
|
||||
bAlarmClassArray[n].setOpenAlarmCount(0);
|
||||
bAlarmClassArray[n].setInAlarmCount(0);
|
||||
++n;
|
||||
}
|
||||
if (!this.alarmFile.delete()) {
|
||||
this.open();
|
||||
throw new IOException("Cannot delete alarm history file: " + this.alarmFile.getAbsolutePath());
|
||||
}
|
||||
this.open();
|
||||
}
|
||||
|
||||
public synchronized void clearOldRecords(BAbsTime bAbsTime, Context context) throws IOException {
|
||||
if (this.timestampIndex.getSize() == 0) {
|
||||
return;
|
||||
}
|
||||
BAlarmRecord bAlarmRecord = new BAlarmRecord();
|
||||
while (this.timestampIndex.getSize() > 0) {
|
||||
IndexEntry indexEntry = this.timestampIndex.getFirstEntry();
|
||||
if (!indexEntry.timestamp.isBefore(bAbsTime)) break;
|
||||
this.remove(indexEntry, bAlarmRecord);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void clearRecord(BUuid bUuid, Context context) throws IOException {
|
||||
if (this.byUuid.size() == 0) {
|
||||
return;
|
||||
}
|
||||
BAlarmRecord bAlarmRecord = new BAlarmRecord();
|
||||
IndexEntry indexEntry = (IndexEntry)this.byUuid.get(bUuid);
|
||||
if (indexEntry != null) {
|
||||
this.remove(indexEntry, bAlarmRecord);
|
||||
}
|
||||
}
|
||||
|
||||
public void analyze(PrintStream printStream) {
|
||||
DecimalFormat decimalFormat = new DecimalFormat("###,###,###,###");
|
||||
DecimalFormat decimalFormat2 = new DecimalFormat("###,###,###.##");
|
||||
DecimalFormat decimalFormat3 = new DecimalFormat("###,###,###");
|
||||
printStream.println("db file : " + this.alarmFile.getAbsolutePath());
|
||||
printStream.println("file size : " + decimalFormat.format(this.alarmFile.length()));
|
||||
printStream.println("capacity : " + this.capacity);
|
||||
printStream.println("record count: " + this.timestampIndex.getSize());
|
||||
printStream.println("free map : " + decimalFormat3.format(this.freeMap.getSizeInBytes()) + " bytes");
|
||||
this.timestampIndex.analyze("timestamp index", printStream);
|
||||
printStream.println();
|
||||
int n = this.timestampIndex.getSize() * 21;
|
||||
printStream.println("non-list entry ram: " + decimalFormat2.format((double)n / 1024.0 / 1024.0) + " MB");
|
||||
}
|
||||
|
||||
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 AlarmStore(File file, int n) {
|
||||
this.alarmFile = file;
|
||||
this.capacity = n;
|
||||
this.alarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
}
|
||||
|
||||
private static class TimestampCursor
|
||||
extends AlarmStoreCursor {
|
||||
public IndexEntry nextEntry(IndexEntry indexEntry) {
|
||||
if (indexEntry.nextTimestamp == null) {
|
||||
return null;
|
||||
}
|
||||
return indexEntry.nextTimestamp[0];
|
||||
}
|
||||
|
||||
public TimestampCursor(AlarmStore alarmStore, IndexEntry indexEntry, BAbsTime bAbsTime) {
|
||||
super(alarmStore, indexEntry, bAbsTime);
|
||||
}
|
||||
}
|
||||
|
||||
private static class SourceCursor
|
||||
extends AlarmStoreCursor {
|
||||
public IndexEntry nextEntry(IndexEntry indexEntry) {
|
||||
if (indexEntry.nextSource == null) {
|
||||
return null;
|
||||
}
|
||||
return indexEntry.nextSource[0];
|
||||
}
|
||||
|
||||
public SourceCursor(AlarmStore alarmStore, IndexEntry indexEntry, BAbsTime bAbsTime) {
|
||||
super(alarmStore, indexEntry, bAbsTime);
|
||||
}
|
||||
}
|
||||
|
||||
private static class OpenCursor
|
||||
extends AlarmStoreCursor {
|
||||
public IndexEntry nextEntry(IndexEntry indexEntry) {
|
||||
return indexEntry.nextOpen;
|
||||
}
|
||||
|
||||
public OpenCursor(AlarmStore alarmStore, IndexEntry indexEntry, BAbsTime bAbsTime) {
|
||||
super(alarmStore, indexEntry, bAbsTime);
|
||||
}
|
||||
}
|
||||
|
||||
private static class AckPendingCursor
|
||||
extends AlarmStoreCursor {
|
||||
public IndexEntry nextEntry(IndexEntry indexEntry) {
|
||||
return indexEntry.nextAckPending;
|
||||
}
|
||||
|
||||
public AckPendingCursor(AlarmStore alarmStore, IndexEntry indexEntry, BAbsTime bAbsTime) {
|
||||
super(alarmStore, indexEntry, bAbsTime);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private static abstract class AlarmStoreCursor
|
||||
implements Cursor {
|
||||
boolean init = true;
|
||||
AlarmStore store;
|
||||
IndexEntry entry;
|
||||
BAlarmRecord rec;
|
||||
BAbsTime endTime;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
|
||||
public Context getContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public BObject get() {
|
||||
if (this.init) {
|
||||
throw new IllegalStateException("get() before next()");
|
||||
}
|
||||
if (this.entry != null) {
|
||||
return this.rec;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
* Converted monitor instructions to comments
|
||||
* Lifted jumps to return sites
|
||||
*/
|
||||
public boolean next() {
|
||||
if (this.entry == null) {
|
||||
return false;
|
||||
}
|
||||
if (this.init) {
|
||||
this.init = false;
|
||||
try {
|
||||
AlarmStore alarmStore = this.store;
|
||||
// MONITORENTER : alarmStore
|
||||
if (this.store.io == null) {
|
||||
throw new IllegalStateException("Alarm database is closed.");
|
||||
}
|
||||
if (-1 == this.store.readPage(this.entry.pageIndex).getPageOfRecord()) {
|
||||
// MONITOREXIT : alarmStore
|
||||
return false;
|
||||
}
|
||||
if (!this.store.readRecord(this.entry.pageIndex, this.rec).getTimestamp().equals((Object)this.entry.timestamp)) {
|
||||
// MONITOREXIT : alarmStore
|
||||
return false;
|
||||
}
|
||||
// MONITOREXIT : alarmStore
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BAlarmDatabase.log.error("Unable to read record", (Throwable)exception);
|
||||
return false;
|
||||
}
|
||||
if (this.endTime == null) return true;
|
||||
if (!this.rec.getTimestamp().isAfter(this.endTime)) return true;
|
||||
this.entry = null;
|
||||
return false;
|
||||
}
|
||||
this.entry = this.nextEntry(this.entry);
|
||||
if (this.entry == null) {
|
||||
this.rec = null;
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
AlarmStore alarmStore = this.store;
|
||||
// MONITORENTER : alarmStore
|
||||
if (this.store.io == null) {
|
||||
throw new IllegalStateException("Alarm database is closed.");
|
||||
}
|
||||
if (-1 == this.store.readPage(this.entry.pageIndex).getPageOfRecord()) {
|
||||
// MONITOREXIT : alarmStore
|
||||
return false;
|
||||
}
|
||||
if (!this.store.readRecord(this.entry.pageIndex, this.rec).getTimestamp().equals((Object)this.entry.timestamp)) {
|
||||
// MONITOREXIT : alarmStore
|
||||
return false;
|
||||
}
|
||||
// MONITOREXIT : alarmStore
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BAlarmDatabase.log.error("Unable to read record", (Throwable)exception);
|
||||
return false;
|
||||
}
|
||||
if (this.endTime == null) return true;
|
||||
if (!this.rec.getTimestamp().isAfter(this.endTime)) return true;
|
||||
this.entry = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean next(Class clazz) {
|
||||
Class clazz2 = class$javax$baja$alarm$BAlarmRecord;
|
||||
if (clazz2 == null) {
|
||||
clazz2 = class$javax$baja$alarm$BAlarmRecord = AlarmStoreCursor.class("[Ljavax.baja.alarm.BAlarmRecord;", false);
|
||||
}
|
||||
if (clazz2.equals(clazz)) {
|
||||
return this.next();
|
||||
}
|
||||
this.entry = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean nextComponent() {
|
||||
this.entry = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract IndexEntry nextEntry(IndexEntry var1);
|
||||
|
||||
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 AlarmStoreCursor(AlarmStore alarmStore, IndexEntry indexEntry, BAbsTime bAbsTime) {
|
||||
this.store = alarmStore;
|
||||
this.entry = indexEntry;
|
||||
this.rec = new BAlarmRecord();
|
||||
this.endTime = bAbsTime;
|
||||
if (this.endTime != null && this.endTime.isNull()) {
|
||||
this.endTime = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.io.ByteBuffer
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import javax.baja.io.ByteBuffer;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class AlarmStoreHeader {
|
||||
private static final int MAGIC = 1611526157;
|
||||
private static final int LATEST_VERSION = 1;
|
||||
private static final int DEFAULT_HEADER_SIZE = 1024;
|
||||
private static final int DEFAULT_PAGE_SIZE = 512;
|
||||
private static final int DEFAULT_PAGES_PER_BLOCK = 8;
|
||||
private long creationTime;
|
||||
private int version;
|
||||
private int recordVersion;
|
||||
private long dataOffset;
|
||||
private int pageSize;
|
||||
private int pagesPerBlock;
|
||||
private boolean newStore;
|
||||
private ByteBuffer writeBuffer;
|
||||
|
||||
public void write(DataOutput dataOutput) throws IOException {
|
||||
if (this.writeBuffer == null) {
|
||||
this.writeBuffer = new ByteBuffer(1024);
|
||||
} else {
|
||||
this.writeBuffer.reset();
|
||||
}
|
||||
this.writeBuffer.writeInt(1611526157);
|
||||
this.writeBuffer.writeInt(this.version);
|
||||
this.writeBuffer.writeInt(this.recordVersion);
|
||||
this.writeBuffer.writeLong(this.creationTime);
|
||||
this.writeBuffer.writeInt(this.pageSize);
|
||||
this.writeBuffer.writeInt(this.pagesPerBlock);
|
||||
int n = this.writeBuffer.getLength();
|
||||
int n2 = n + 8;
|
||||
if (this.newStore) {
|
||||
this.writeBuffer.writeTo(dataOutput, 0, n);
|
||||
this.dataOffset = Math.max(n2, 1024);
|
||||
dataOutput.writeLong(this.dataOffset);
|
||||
int n3 = (int)this.dataOffset - n2;
|
||||
dataOutput.write(new byte[n3]);
|
||||
} else {
|
||||
if ((long)n2 > this.dataOffset) {
|
||||
throw new IOException("Header overflow: " + n2 + " > " + this.dataOffset);
|
||||
}
|
||||
this.writeBuffer.writeTo(dataOutput, 0, n);
|
||||
dataOutput.writeLong(this.dataOffset);
|
||||
}
|
||||
}
|
||||
|
||||
public void read(DataInput dataInput) throws IOException {
|
||||
this.newStore = false;
|
||||
int n = dataInput.readInt();
|
||||
if (n != 1611526157) {
|
||||
throw new IOException("Invalid or corrupt alarm database.");
|
||||
}
|
||||
this.version = dataInput.readInt();
|
||||
if (this.version != 1) {
|
||||
throw new IOException("Unrecognized alarm db version: " + this.version);
|
||||
}
|
||||
this.recordVersion = dataInput.readInt();
|
||||
this.creationTime = dataInput.readLong();
|
||||
this.pageSize = dataInput.readInt();
|
||||
this.pagesPerBlock = dataInput.readInt();
|
||||
this.dataOffset = dataInput.readLong();
|
||||
}
|
||||
|
||||
public int getRecordVersion() {
|
||||
return this.recordVersion;
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return this.pageSize;
|
||||
}
|
||||
|
||||
public int getPagesPerBlock() {
|
||||
return this.pagesPerBlock;
|
||||
}
|
||||
|
||||
public long getDataOffset() {
|
||||
return this.dataOffset;
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.newStore = true;
|
||||
}
|
||||
|
||||
public AlarmStoreHeader() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public AlarmStoreHeader(int n) {
|
||||
this.this();
|
||||
this.version = 1;
|
||||
this.creationTime = System.currentTimeMillis();
|
||||
this.pageSize = 512;
|
||||
this.pagesPerBlock = 8;
|
||||
this.recordVersion = n;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,575 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.platform.BSystemPlatformService
|
||||
* com.tridium.platform.archive.FileArchive
|
||||
* com.tridium.sys.Nre
|
||||
* com.tridium.sys.resource.ResourceReport
|
||||
* com.tridium.sys.service.BServiceEvent
|
||||
* com.tridium.sys.service.ServiceListener
|
||||
* javax.baja.dataRecovery.BIDataRecoveryService
|
||||
* javax.baja.dataRecovery.BIDataRecoverySource
|
||||
* javax.baja.dataRecovery.IDataRecoveryRecord
|
||||
* javax.baja.file.BDirectory
|
||||
* javax.baja.file.BFileSpace
|
||||
* javax.baja.file.BIFile
|
||||
* javax.baja.file.BLocalFileStore
|
||||
* javax.baja.file.FilePath
|
||||
* javax.baja.io.BIEncodable
|
||||
* javax.baja.log.Log
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.security.AuditEvent
|
||||
* javax.baja.security.Auditor
|
||||
* javax.baja.spy.SpyWriter
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BLong
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.Clock
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.ServiceNotFoundException
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AlarmStore;
|
||||
import com.tridium.alarm.db.file.DataRecoveryAlarmEvent;
|
||||
import com.tridium.platform.BSystemPlatformService;
|
||||
import com.tridium.platform.archive.FileArchive;
|
||||
import com.tridium.sys.Nre;
|
||||
import com.tridium.sys.resource.ResourceReport;
|
||||
import com.tridium.sys.service.BServiceEvent;
|
||||
import com.tridium.sys.service.ServiceListener;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.dataRecovery.BIDataRecoveryService;
|
||||
import javax.baja.dataRecovery.BIDataRecoverySource;
|
||||
import javax.baja.dataRecovery.IDataRecoveryRecord;
|
||||
import javax.baja.file.BDirectory;
|
||||
import javax.baja.file.BFileSpace;
|
||||
import javax.baja.file.BIFile;
|
||||
import javax.baja.file.BLocalFileStore;
|
||||
import javax.baja.file.FilePath;
|
||||
import javax.baja.io.BIEncodable;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.security.AuditEvent;
|
||||
import javax.baja.security.Auditor;
|
||||
import javax.baja.spy.SpyWriter;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BLong;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.Clock;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.ServiceNotFoundException;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BFileAlarmDatabase
|
||||
extends BAlarmDatabase
|
||||
implements BIDataRecoverySource {
|
||||
public static final Type TYPE;
|
||||
private static final BOrd ordInSession;
|
||||
private static final String CAPACITY = "capacity";
|
||||
private static final String ARCHIVE_ID = "alarm";
|
||||
private static final Log dataRecoveryLog;
|
||||
private ServiceListener serviceListener;
|
||||
private int capacity;
|
||||
private File dbDir;
|
||||
private File alarmFile;
|
||||
private AlarmStore alarmStore;
|
||||
private BOrd alarmServiceOrd;
|
||||
private BIDataRecoveryService dataRecoveryService;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$file$BFileAlarmDatabase;
|
||||
|
||||
public void doOpen() throws IOException {
|
||||
Object object;
|
||||
if (this.dbDir == null) {
|
||||
try {
|
||||
FilePath filePath;
|
||||
BSystemPlatformService bSystemPlatformService = (BSystemPlatformService)Sys.getService((Type)BSystemPlatformService.TYPE);
|
||||
if (bSystemPlatformService.archiveEnabled(ARCHIVE_ID)) {
|
||||
bSystemPlatformService.extractArchive(ARCHIVE_ID);
|
||||
}
|
||||
String string = bSystemPlatformService.getRuntimeDirectory(ARCHIVE_ID);
|
||||
object = (BFileSpace)BOrd.make((String)"file:").get();
|
||||
BIFile bIFile = object.findFile(filePath = new FilePath(string));
|
||||
if (bIFile == null) {
|
||||
BDirectory bDirectory = object.makeDir(filePath);
|
||||
this.dbDir = ((BLocalFileStore)bDirectory.getStore()).getLocalFile();
|
||||
} else {
|
||||
this.dbDir = ((BLocalFileStore)bIFile.getStore()).getLocalFile();
|
||||
}
|
||||
}
|
||||
catch (ServiceNotFoundException serviceNotFoundException) {
|
||||
if (Sys.getStation() != null) {
|
||||
log.warning("No system platform service available, using station home directory for alarm database root.");
|
||||
this.dbDir = new File(Sys.getBajaHome().getAbsolutePath() + File.separatorChar + "stations" + File.separatorChar + Sys.getStation().getStationName() + File.separatorChar + ARCHIVE_ID);
|
||||
}
|
||||
log.warning("No system platform service available, using Niagara home directory for alarm database root.");
|
||||
this.dbDir = new File(Sys.getBajaHome().getAbsolutePath() + File.separatorChar + ARCHIVE_ID);
|
||||
}
|
||||
}
|
||||
if (!this.dbDir.exists()) {
|
||||
this.dbDir.mkdirs();
|
||||
}
|
||||
this.alarmFile = new File(this.dbDir, "alarm.adb");
|
||||
if (!this.alarmFile.exists()) {
|
||||
this.alarmFile.createNewFile();
|
||||
}
|
||||
int n = 0;
|
||||
while (true) {
|
||||
try {
|
||||
this.alarmStore = new AlarmStore(this.alarmFile, this.capacity);
|
||||
this.alarmStore.open();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BAlarmDatabase.log.error("Cannot open alarm database.", (Throwable)exception);
|
||||
if (!this.alarmFile.exists() || ++n == 2) break;
|
||||
if (Nre.getPlatform().isFlashFileSystem()) {
|
||||
if (this.alarmFile.delete()) {
|
||||
BAlarmDatabase.log.error("Old alarm database deleted.");
|
||||
continue;
|
||||
}
|
||||
throw new IOException("Unable to delete old alarm database.");
|
||||
}
|
||||
object = this.saveErrorDb();
|
||||
if (object == null) continue;
|
||||
BAlarmDatabase.log.error("Old alarm database saved as " + ((File)object).getAbsolutePath() + '.');
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
this.alarmServiceOrd = Sys.getService((Type)BAlarmService.TYPE).getOrdInSession();
|
||||
try {
|
||||
this.dataRecoveryService = (BIDataRecoveryService)Sys.getService((Type)BIDataRecoveryService.TYPE);
|
||||
if (!this.dataRecoveryService.isEnabled()) {
|
||||
this.dataRecoveryService = null;
|
||||
}
|
||||
}
|
||||
catch (ServiceNotFoundException serviceNotFoundException) {}
|
||||
Nre.serviceManager.addServiceListener(this.serviceListener);
|
||||
}
|
||||
|
||||
private final File saveErrorDb() throws IOException {
|
||||
String[] stringArray = this.dbDir.list();
|
||||
int n = 0;
|
||||
int n2 = 0;
|
||||
while (n2 < stringArray.length) {
|
||||
if (stringArray[n2].indexOf("error") != -1) {
|
||||
++n;
|
||||
}
|
||||
if (n == 3) {
|
||||
throw new IOException("Cannot create recovery file. " + n + " recovery files already exist.");
|
||||
}
|
||||
++n2;
|
||||
}
|
||||
File file = new File(this.dbDir, "alarm_error.adb");
|
||||
if (file.exists()) {
|
||||
int n3 = 2;
|
||||
while (file.exists()) {
|
||||
file = new File(this.dbDir, "alarm_error" + n3 + ".adb");
|
||||
++n3;
|
||||
}
|
||||
}
|
||||
if (!this.alarmFile.renameTo(file)) {
|
||||
throw new IOException("Unable to create recovery file.");
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
public void doSave() throws IOException {
|
||||
try {
|
||||
BSystemPlatformService bSystemPlatformService = (BSystemPlatformService)Sys.getService((Type)BSystemPlatformService.TYPE);
|
||||
if (bSystemPlatformService.archiveEnabled(ARCHIVE_ID)) {
|
||||
FileArchive fileArchive = bSystemPlatformService.createFileArchive(ARCHIVE_ID);
|
||||
String string = this.dbDir.getAbsolutePath();
|
||||
String string2 = this.alarmFile.getAbsolutePath().substring(string.length() + 1);
|
||||
fileArchive.writeFile(this.alarmFile, string2);
|
||||
fileArchive.close();
|
||||
}
|
||||
}
|
||||
catch (ServiceNotFoundException serviceNotFoundException) {
|
||||
log.error("No system platform service available, cannot create alarm archive file.");
|
||||
throw new IOException("Could not create alarm archive file.");
|
||||
}
|
||||
}
|
||||
|
||||
public void doFlush() throws IOException {
|
||||
this.alarmStore.flush();
|
||||
}
|
||||
|
||||
public void doClose() {
|
||||
this.alarmStore.close();
|
||||
this.alarmStore = null;
|
||||
}
|
||||
|
||||
public synchronized void append(BAlarmRecord bAlarmRecord) throws IOException {
|
||||
this.assertOpen();
|
||||
if (this.dataRecoveryService != null) {
|
||||
this.dataRecoveryService.append((BIDataRecoverySource)this, (BIEncodable)bAlarmRecord.getUuid(), new DataRecoveryAlarmEvent.Append(bAlarmRecord).encode());
|
||||
}
|
||||
this.alarmStore.append(bAlarmRecord);
|
||||
}
|
||||
|
||||
public synchronized void update(BAlarmRecord bAlarmRecord) throws IOException {
|
||||
this.assertOpen();
|
||||
if (this.dataRecoveryService != null) {
|
||||
this.dataRecoveryService.update((BIDataRecoverySource)this, (BIEncodable)bAlarmRecord.getUuid(), new DataRecoveryAlarmEvent.Update(bAlarmRecord).encode());
|
||||
}
|
||||
this.alarmStore.update(bAlarmRecord);
|
||||
}
|
||||
|
||||
public synchronized int getRecordCount() {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.getRecordCount();
|
||||
}
|
||||
|
||||
public synchronized BAlarmRecord getRecord(BUuid bUuid) throws IOException {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.getRecord(bUuid);
|
||||
}
|
||||
|
||||
public synchronized Cursor scan() {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.scan();
|
||||
}
|
||||
|
||||
public synchronized Cursor timeQuery(BAbsTime bAbsTime, BAbsTime bAbsTime2) {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.timeQuery(bAbsTime, bAbsTime2);
|
||||
}
|
||||
|
||||
public synchronized Cursor getAlarmsForSource(BOrdList bOrdList) throws IOException {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.getAlarmsForSource(bOrdList);
|
||||
}
|
||||
|
||||
public synchronized Cursor getOpenAlarms() throws IOException {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.getOpenAlarms();
|
||||
}
|
||||
|
||||
public synchronized Cursor getAckPendingAlarms() throws IOException {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.getAckPendingAlarms();
|
||||
}
|
||||
|
||||
public synchronized void clearAllRecords(Context context) throws IOException {
|
||||
this.assertOpen();
|
||||
if (this.dataRecoveryService != null) {
|
||||
this.dataRecoveryService.append((BIDataRecoverySource)this, (BIEncodable)BString.make((String)"clearAll"), new DataRecoveryAlarmEvent.ClearAll().encode());
|
||||
}
|
||||
Auditor auditor = Nre.auditor;
|
||||
int n = this.getRecordCount();
|
||||
this.alarmStore.clearAllRecords(context);
|
||||
if (auditor != null) {
|
||||
String string = "";
|
||||
if (context != null && context.getUser() != null) {
|
||||
string = context.getUser().getUsername();
|
||||
}
|
||||
auditor.audit(new AuditEvent("Invoked", "Alarm Database", "Clear", Integer.toString(n) + " records", Integer.toString(this.getRecordCount()) + " records", string));
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void clearOldRecords(BAbsTime bAbsTime, Context context) throws IOException {
|
||||
this.assertOpen();
|
||||
if (this.dataRecoveryService != null) {
|
||||
this.dataRecoveryService.append((BIDataRecoverySource)this, (BIEncodable)BLong.make((long)Clock.ticks()), new DataRecoveryAlarmEvent.ClearOld(bAbsTime).encode());
|
||||
}
|
||||
Auditor auditor = Nre.auditor;
|
||||
int n = this.getRecordCount();
|
||||
this.alarmStore.clearOldRecords(bAbsTime, context);
|
||||
if (auditor != null) {
|
||||
String string = "";
|
||||
if (context != null && context.getUser() != null) {
|
||||
string = context.getUser().getUsername();
|
||||
}
|
||||
auditor.audit(new AuditEvent("Invoked", "Alarm Database", "Clear before " + bAbsTime.toString((Context)BAlarmRecord.TIMESTAMP_FACETS), Integer.toString(n) + " records", Integer.toString(this.getRecordCount()) + " records", string));
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void clearRecord(BUuid bUuid, Context context) throws IOException {
|
||||
if (bUuid == null || bUuid.isNull()) {
|
||||
return;
|
||||
}
|
||||
this.assertOpen();
|
||||
if (this.dataRecoveryService != null) {
|
||||
this.dataRecoveryService.append((BIDataRecoverySource)this, (BIEncodable)bUuid, new DataRecoveryAlarmEvent.ClearRecord(bUuid).encode());
|
||||
}
|
||||
Auditor auditor = Nre.auditor;
|
||||
int n = this.getRecordCount();
|
||||
this.alarmStore.clearRecord(bUuid, context);
|
||||
if (auditor != null) {
|
||||
String string = "";
|
||||
if (context != null && context.getUser() != null) {
|
||||
string = context.getUser().getUsername();
|
||||
}
|
||||
auditor.audit(new AuditEvent("Invoked", "Alarm Database", "Clear record " + bUuid, Integer.toString(n) + " records", Integer.toString(this.getRecordCount()) + " records", string));
|
||||
}
|
||||
}
|
||||
|
||||
public void setCapacity(int n) throws IOException {
|
||||
if (this.capacity == n) {
|
||||
return;
|
||||
}
|
||||
if (this.dataRecoveryService != null) {
|
||||
this.dataRecoveryService.append((BIDataRecoverySource)this, (BIEncodable)BString.make((String)CAPACITY), new DataRecoveryAlarmEvent.CapacityChange(n).encode());
|
||||
}
|
||||
this.capacity = n;
|
||||
if (!this.isOpen()) {
|
||||
return;
|
||||
}
|
||||
this.alarmStore.setCapacity(this.capacity);
|
||||
this.alarmStore.trimToCapacity();
|
||||
}
|
||||
|
||||
public BOrd getOrdInSession() throws Exception {
|
||||
return ordInSession;
|
||||
}
|
||||
|
||||
public void dataRecoveryRestoreComplete() {
|
||||
}
|
||||
|
||||
public boolean dataRecoveryRestore(IDataRecoveryRecord iDataRecoveryRecord) throws Exception {
|
||||
DataRecoveryAlarmEvent dataRecoveryAlarmEvent = null;
|
||||
try {
|
||||
dataRecoveryAlarmEvent = DataRecoveryAlarmEvent.make(iDataRecoveryRecord.getData());
|
||||
dataRecoveryAlarmEvent.execute(this);
|
||||
if (dataRecoveryLog.isTraceOn()) {
|
||||
dataRecoveryLog.trace("Restored alarm event " + dataRecoveryAlarmEvent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (dataRecoveryAlarmEvent == null) {
|
||||
dataRecoveryLog.error("Could not restore event", (Throwable)exception);
|
||||
} else {
|
||||
dataRecoveryLog.error("Could not restore event " + dataRecoveryAlarmEvent, (Throwable)exception);
|
||||
}
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
public void dataRecoverySpy(SpyWriter spyWriter, Iterator iterator) throws Exception {
|
||||
Object object;
|
||||
Object object2;
|
||||
IDataRecoveryRecord iDataRecoveryRecord;
|
||||
DataRecoveryAlarmEvent dataRecoveryAlarmEvent = null;
|
||||
HashMap<Object, DataRecoveryAlarmSpyData> hashMap = new HashMap<Object, DataRecoveryAlarmSpyData>();
|
||||
int n = 0;
|
||||
while (iterator.hasNext()) {
|
||||
try {
|
||||
++n;
|
||||
iDataRecoveryRecord = (IDataRecoveryRecord)iterator.next();
|
||||
dataRecoveryAlarmEvent = DataRecoveryAlarmEvent.make(iDataRecoveryRecord.getData());
|
||||
object2 = new Integer(dataRecoveryAlarmEvent.getEventCode());
|
||||
object = (DataRecoveryAlarmSpyData)hashMap.get(object2);
|
||||
if (object == null) {
|
||||
hashMap.put(object2, new DataRecoveryAlarmSpyData(iDataRecoveryRecord.getData().length));
|
||||
continue;
|
||||
}
|
||||
hashMap.put(object2, ((DataRecoveryAlarmSpyData)object).addEvent(iDataRecoveryRecord.getData().length));
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
iDataRecoveryRecord = hashMap.keySet().iterator();
|
||||
object2 = n + " Alarm Events Recently Recorded in Data Recovery";
|
||||
spyWriter.startTable(true);
|
||||
spyWriter.trTitle(object2, 4);
|
||||
spyWriter.w((Object)"<tr><th>Event</th><th>Occurrences</th><th>Total Bytes</th><th>Avg Bytes</th></tr>\n");
|
||||
while (iDataRecoveryRecord.hasNext()) {
|
||||
try {
|
||||
String string;
|
||||
object = (Integer)iDataRecoveryRecord.next();
|
||||
DataRecoveryAlarmSpyData dataRecoveryAlarmSpyData = (DataRecoveryAlarmSpyData)hashMap.get(object);
|
||||
switch ((Integer)object) {
|
||||
case 0: {
|
||||
string = "Append";
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
string = "Update";
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
string = "ClearAll";
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
string = "ClearOld";
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
string = "ClearRecord";
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
string = "CapacityChange";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
throw new IllegalStateException("Unknown alarm event code: '" + object + '\'');
|
||||
}
|
||||
}
|
||||
spyWriter.tr((Object)string, (Object)("" + dataRecoveryAlarmSpyData.occurances), (Object)("" + dataRecoveryAlarmSpyData.totalBytes), (Object)("" + (double)dataRecoveryAlarmSpyData.totalBytes / (double)dataRecoveryAlarmSpyData.occurances));
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
spyWriter.endTable();
|
||||
}
|
||||
|
||||
private final BIDataRecoveryService getDataRecoveryService() {
|
||||
if (this.dataRecoveryService == null) {
|
||||
try {
|
||||
this.dataRecoveryService = (BIDataRecoveryService)Sys.getService((Type)BIDataRecoveryService.TYPE);
|
||||
if (!this.dataRecoveryService.isEnabled()) {
|
||||
this.dataRecoveryService = null;
|
||||
}
|
||||
}
|
||||
catch (ServiceNotFoundException serviceNotFoundException) {
|
||||
this.dataRecoveryService = null;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
return this.dataRecoveryService;
|
||||
}
|
||||
|
||||
public final Object fw(int n, Object object, Object object2, Object object3, Object object4) {
|
||||
switch (n) {
|
||||
case 21: {
|
||||
((ResourceReport)object).add(ARCHIVE_ID, this.countResourceUnits());
|
||||
break;
|
||||
}
|
||||
case 602: {
|
||||
return this.alarmStore;
|
||||
}
|
||||
}
|
||||
return super.fw(n, object, object2, object3, object4);
|
||||
}
|
||||
|
||||
private final int countResourceUnits() {
|
||||
return this.capacity;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static void main(String[] stringArray) throws Exception {
|
||||
try {
|
||||
String string = stringArray[0];
|
||||
if (string.equals("o")) {
|
||||
BFileAlarmDatabase bFileAlarmDatabase = new BFileAlarmDatabase();
|
||||
bFileAlarmDatabase.open();
|
||||
System.out.println("Done.");
|
||||
bFileAlarmDatabase.close();
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
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.serviceListener = new ServiceListener(){
|
||||
|
||||
public final void serviceEvent(BServiceEvent bServiceEvent) {
|
||||
if (bServiceEvent.getServiceType().is(BIDataRecoveryService.TYPE)) {
|
||||
if (bServiceEvent.getId() == 0) {
|
||||
BFileAlarmDatabase.this.dataRecoveryService = (BIDataRecoveryService)bServiceEvent.getService();
|
||||
if (!BFileAlarmDatabase.this.dataRecoveryService.isEnabled()) {
|
||||
BFileAlarmDatabase.this.dataRecoveryService = null;
|
||||
}
|
||||
} else if (bServiceEvent.getId() == 1) {
|
||||
BFileAlarmDatabase.this.dataRecoveryService = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
return "ServiceListener for AlarmService";
|
||||
}
|
||||
};
|
||||
this.capacity = 10000;
|
||||
this.dbDir = null;
|
||||
this.alarmFile = null;
|
||||
this.alarmStore = null;
|
||||
this.alarmServiceOrd = null;
|
||||
this.dataRecoveryService = null;
|
||||
}
|
||||
|
||||
public BFileAlarmDatabase() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$file$BFileAlarmDatabase;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$file$BFileAlarmDatabase = BFileAlarmDatabase.class("[Lcom.tridium.alarm.db.file.BFileAlarmDatabase;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
ordInSession = BOrd.make((String)"alarm:");
|
||||
dataRecoveryLog = Log.getLog((String)"alarm.dataRecovery");
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class DataRecoveryAlarmSpyData {
|
||||
int occurances;
|
||||
int totalBytes;
|
||||
|
||||
public DataRecoveryAlarmSpyData addEvent(int n) {
|
||||
++this.occurances;
|
||||
this.totalBytes += n;
|
||||
return this;
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.occurances = -1;
|
||||
this.totalBytes = -1;
|
||||
}
|
||||
|
||||
public DataRecoveryAlarmSpyData(int n) {
|
||||
this.this();
|
||||
this.occurances = 1;
|
||||
this.totalBytes = n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AlarmStore;
|
||||
import com.tridium.alarm.db.file.Page;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class Block {
|
||||
private AlarmStore store;
|
||||
private int index;
|
||||
private byte[] data;
|
||||
private Page[] pages;
|
||||
private Input in;
|
||||
private Output out;
|
||||
private boolean dirty;
|
||||
Block prev;
|
||||
Block next;
|
||||
|
||||
public int getSize() {
|
||||
return this.data.length;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
public boolean isDirty() {
|
||||
return this.dirty;
|
||||
}
|
||||
|
||||
public void clear() throws IOException {
|
||||
int n = 0;
|
||||
while (n < this.pages.length) {
|
||||
this.pages[n] = new Page(this, n, this.store.getHeader().getPageSize());
|
||||
this.pages[n].clear();
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
public void read(DataInput dataInput) throws IOException {
|
||||
dataInput.readFully(this.data);
|
||||
this.dirty = false;
|
||||
}
|
||||
|
||||
public void write(DataOutput dataOutput) throws IOException {
|
||||
dataOutput.write(this.data);
|
||||
this.dirty = false;
|
||||
}
|
||||
|
||||
public synchronized Page getPage(int n) throws IOException {
|
||||
if (this.pages == null) {
|
||||
this.pages = new Page[this.store.getHeader().getPagesPerBlock()];
|
||||
}
|
||||
try {
|
||||
if (this.pages[n] == null) {
|
||||
this.pages[n] = this.initPage(n);
|
||||
}
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException arrayIndexOutOfBoundsException) {
|
||||
int n2 = this.store.getHeader().getPagesPerBlock();
|
||||
throw new IllegalArgumentException("Invalid page index: " + n + ". Pages per block = " + n2);
|
||||
}
|
||||
return this.pages[n];
|
||||
}
|
||||
|
||||
private final Page initPage(int n) throws IOException {
|
||||
Page page = new Page(this, n, this.store.getHeader().getPageSize());
|
||||
page.read();
|
||||
return page;
|
||||
}
|
||||
|
||||
public void dump() throws IOException {
|
||||
int n = this.store.getHeader().getPagesPerBlock();
|
||||
int n2 = 0;
|
||||
while (n2 < n) {
|
||||
Page page = this.getPage(n2);
|
||||
System.out.println(n2 + "] " + page.getPageOfRecord() + " of " + page.getPagesOfRecord());
|
||||
++n2;
|
||||
}
|
||||
}
|
||||
|
||||
public Input getInput() {
|
||||
return this.in;
|
||||
}
|
||||
|
||||
public int write(int n, int n2) {
|
||||
this.data[n] = (byte)n2;
|
||||
this.dirty = true;
|
||||
return n + 1;
|
||||
}
|
||||
|
||||
public int write(int n, byte[] byArray, int n2, int n3) {
|
||||
System.arraycopy(byArray, n2, this.data, n, n3);
|
||||
this.dirty = true;
|
||||
return n + n3;
|
||||
}
|
||||
|
||||
public int writeInt(int n, int n2) {
|
||||
this.write(n++, n2 >>> 24 & 0xFF);
|
||||
this.write(n++, n2 >>> 16 & 0xFF);
|
||||
this.write(n++, n2 >>> 8 & 0xFF);
|
||||
this.write(n++, n2 & 0xFF);
|
||||
return n;
|
||||
}
|
||||
|
||||
public Output getOutput() {
|
||||
return this.out;
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
public Block(AlarmStore alarmStore, int n) {
|
||||
this.this();
|
||||
this.store = alarmStore;
|
||||
this.index = n;
|
||||
int n2 = alarmStore.getHeader().getPageSize();
|
||||
int n3 = alarmStore.getHeader().getPagesPerBlock();
|
||||
this.data = new byte[n2 * n3];
|
||||
this.pages = new Page[n3];
|
||||
this.out = new Output(this);
|
||||
this.in = new Input(this.data);
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class Output {
|
||||
private Block block;
|
||||
private int pos;
|
||||
|
||||
public void seek(int n) {
|
||||
this.pos = n;
|
||||
}
|
||||
|
||||
public void write(int n) {
|
||||
this.block.write(this.pos++, n);
|
||||
}
|
||||
|
||||
public void write(byte[] byArray) {
|
||||
this.pos = this.block.write(this.pos, byArray, 0, byArray.length);
|
||||
}
|
||||
|
||||
public void write(byte[] byArray, int n, int n2) {
|
||||
this.pos = this.block.write(this.pos, byArray, n, n2);
|
||||
}
|
||||
|
||||
public void writeInt(int n) {
|
||||
this.pos = this.block.writeInt(this.pos, n);
|
||||
}
|
||||
|
||||
public Output(Block block2) {
|
||||
this.block = block2;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class Input {
|
||||
private byte[] buffer;
|
||||
private int length;
|
||||
private int pos;
|
||||
|
||||
public void seek(int n) {
|
||||
this.pos = n;
|
||||
}
|
||||
|
||||
public int read() throws IOException {
|
||||
try {
|
||||
return this.buffer[this.pos++] & 0xFF;
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException arrayIndexOutOfBoundsException) {
|
||||
throw new EOFException();
|
||||
}
|
||||
}
|
||||
|
||||
public int read(byte[] byArray) throws IOException {
|
||||
return this.read(byArray, 0, byArray.length);
|
||||
}
|
||||
|
||||
public int read(byte[] byArray, int n, int n2) throws IOException {
|
||||
int n3 = Math.min(n2, this.length - this.pos);
|
||||
if (n3 == 0) {
|
||||
return -1;
|
||||
}
|
||||
System.arraycopy(this.buffer, this.pos, byArray, n, n3);
|
||||
this.pos += n3;
|
||||
return n3;
|
||||
}
|
||||
|
||||
public void readFully(byte[] byArray) throws IOException {
|
||||
this.read(byArray, 0, byArray.length);
|
||||
}
|
||||
|
||||
public void readFully(byte[] byArray, int n, int n2) throws IOException {
|
||||
this.read(byArray, n, n2);
|
||||
}
|
||||
|
||||
public int readInt() throws IOException {
|
||||
return (this.read() << 24) + (this.read() << 16) + (this.read() << 8) + this.read();
|
||||
}
|
||||
|
||||
public Input(byte[] byArray) {
|
||||
this.buffer = byArray;
|
||||
this.length = byArray.length;
|
||||
this.pos = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.nre.util.IntHashMap
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AlarmStore;
|
||||
import com.tridium.alarm.db.file.Block;
|
||||
import java.io.IOException;
|
||||
import javax.baja.nre.util.IntHashMap;
|
||||
|
||||
public class BlockCache {
|
||||
private AlarmStore store;
|
||||
private int max;
|
||||
private int size;
|
||||
private IntHashMap table;
|
||||
private Block newest;
|
||||
private Block oldest;
|
||||
|
||||
public synchronized Block getBlock(int n) {
|
||||
return (Block)this.table.get(n);
|
||||
}
|
||||
|
||||
public synchronized void add(Block block) throws IOException {
|
||||
int n = block.getIndex();
|
||||
Block block2 = (Block)this.table.get(n);
|
||||
if (block2 != null) {
|
||||
if (block2.prev != null) {
|
||||
block2.prev.next = block2.next;
|
||||
}
|
||||
if (block2.next != null) {
|
||||
block2.next.prev = block2.prev;
|
||||
}
|
||||
if (block2 == this.newest) {
|
||||
this.newest = block2.next;
|
||||
}
|
||||
if (block2 == this.oldest) {
|
||||
this.oldest = block2.prev;
|
||||
}
|
||||
block2.next = null;
|
||||
block2.prev = null;
|
||||
--this.size;
|
||||
}
|
||||
this.table.put(n, (Object)block);
|
||||
if (this.newest == null) {
|
||||
this.newest = this.oldest = block;
|
||||
block.next = null;
|
||||
block.prev = null;
|
||||
} else {
|
||||
this.newest.prev = block;
|
||||
block.next = this.newest;
|
||||
block.prev = null;
|
||||
this.newest = block;
|
||||
}
|
||||
++this.size;
|
||||
if (this.size > this.max) {
|
||||
this.evict(this.size - this.max);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void remove(int n) {
|
||||
Block block = (Block)this.table.get(n);
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
this.table.remove(n);
|
||||
if (block.prev != null) {
|
||||
block.prev.next = block.next;
|
||||
}
|
||||
if (block.next != null) {
|
||||
block.next.prev = block.prev;
|
||||
}
|
||||
if (block == this.newest) {
|
||||
this.newest = block.next;
|
||||
}
|
||||
if (block == this.oldest) {
|
||||
this.oldest = block.prev;
|
||||
}
|
||||
block.next = null;
|
||||
block.prev = null;
|
||||
--this.size;
|
||||
}
|
||||
|
||||
public synchronized void remove(Block block) {
|
||||
this.remove(block.getIndex());
|
||||
}
|
||||
|
||||
public synchronized void flush() throws IOException {
|
||||
Block block = this.newest;
|
||||
while (block != null) {
|
||||
this.store.writeBlock(block);
|
||||
block = block.next;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void evict(int n) throws IOException {
|
||||
int n2 = 0;
|
||||
while (n2 < n) {
|
||||
if (this.size == 0) {
|
||||
return;
|
||||
}
|
||||
this.store.writeBlock(this.oldest);
|
||||
this.table.remove(this.oldest.getIndex());
|
||||
if (this.newest == this.oldest) {
|
||||
this.oldest = null;
|
||||
this.newest = null;
|
||||
} else {
|
||||
Block block = this.oldest;
|
||||
this.oldest = this.oldest.prev;
|
||||
this.oldest.next = null;
|
||||
block.next = null;
|
||||
block.prev = null;
|
||||
}
|
||||
--this.size;
|
||||
++n2;
|
||||
}
|
||||
}
|
||||
|
||||
public void dump() {
|
||||
System.out.println("BlockCache.dump");
|
||||
System.out.println(" forward");
|
||||
int n = 0;
|
||||
Block block = this.newest;
|
||||
while (block != null) {
|
||||
System.out.print(" " + n++ + ") block " + block.getIndex());
|
||||
if (block == this.oldest) {
|
||||
System.out.print(" (oldest)");
|
||||
}
|
||||
if (block == this.newest) {
|
||||
System.out.print(" (newest)");
|
||||
}
|
||||
System.out.println();
|
||||
block = block.next;
|
||||
}
|
||||
System.out.println(" reverse");
|
||||
--n;
|
||||
block = this.oldest;
|
||||
while (block != null) {
|
||||
System.out.print(" " + n-- + ") block " + block.getIndex());
|
||||
if (block == this.oldest) {
|
||||
System.out.print(" (oldest)");
|
||||
}
|
||||
if (block == this.newest) {
|
||||
System.out.print(" (newest)");
|
||||
}
|
||||
System.out.println();
|
||||
block = block.prev;
|
||||
}
|
||||
}
|
||||
|
||||
public BlockCache(AlarmStore alarmStore, int n) {
|
||||
this.store = alarmStore;
|
||||
this.max = n;
|
||||
this.table = new IntHashMap(this.max);
|
||||
this.size = 0;
|
||||
this.newest = null;
|
||||
this.oldest = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,292 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.dataRecovery.DataRecoveryException
|
||||
* javax.baja.io.ByteBuffer
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AlarmStore;
|
||||
import com.tridium.alarm.db.file.BFileAlarmDatabase;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import javax.baja.alarm.BAckState;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.dataRecovery.DataRecoveryException;
|
||||
import javax.baja.io.ByteBuffer;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
public abstract class DataRecoveryAlarmEvent {
|
||||
static final byte EVENT_APPEND = 0;
|
||||
static final byte EVENT_UPDATE = 1;
|
||||
static final byte EVENT_CLEARALL = 2;
|
||||
static final byte EVENT_CLEAROLD = 3;
|
||||
static final byte EVENT_CLEARRECORD = 4;
|
||||
static final byte EVENT_CAPACITYCHANGE = 5;
|
||||
private int eventCode;
|
||||
|
||||
public static final DataRecoveryAlarmEvent make(byte[] byArray) throws Exception {
|
||||
ByteBuffer byteBuffer = new ByteBuffer(byArray);
|
||||
int n = -1;
|
||||
try {
|
||||
n = byteBuffer.readByte();
|
||||
switch (n) {
|
||||
case 0: {
|
||||
return new Append(byteBuffer);
|
||||
}
|
||||
case 1: {
|
||||
return new Update(byteBuffer);
|
||||
}
|
||||
case 2: {
|
||||
return new ClearAll(byteBuffer);
|
||||
}
|
||||
case 3: {
|
||||
return new ClearOld(byteBuffer);
|
||||
}
|
||||
case 4: {
|
||||
return new ClearRecord(byteBuffer);
|
||||
}
|
||||
case 5: {
|
||||
return new CapacityChange(byteBuffer);
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Unknown alarm event code: '" + n + '\'');
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
throw new DataRecoveryException("Invalid alarm data (event=" + n + ", length=" + byArray.length + ')', (Throwable)iOException);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void execute(BFileAlarmDatabase var1) throws Exception;
|
||||
|
||||
public byte[] encode() throws IOException {
|
||||
ByteBuffer byteBuffer = new ByteBuffer();
|
||||
byteBuffer.writeByte(this.eventCode);
|
||||
return byteBuffer.toByteArray();
|
||||
}
|
||||
|
||||
protected final AlarmStore getAlarmStore(BFileAlarmDatabase bFileAlarmDatabase) {
|
||||
return (AlarmStore)bFileAlarmDatabase.fw(602, null, null, null, null);
|
||||
}
|
||||
|
||||
int getEventCode() {
|
||||
return this.eventCode;
|
||||
}
|
||||
|
||||
private DataRecoveryAlarmEvent(int n) {
|
||||
this.eventCode = n;
|
||||
}
|
||||
|
||||
public static class Append
|
||||
extends DataRecoveryAlarmEvent {
|
||||
BAlarmRecord record;
|
||||
|
||||
public void execute(BFileAlarmDatabase bFileAlarmDatabase) throws IOException {
|
||||
AlarmStore alarmStore = this.getAlarmStore(bFileAlarmDatabase);
|
||||
BAlarmRecord bAlarmRecord = alarmStore.getRecord(this.record.getUuid());
|
||||
if (bAlarmRecord == null || bAlarmRecord.getLastUpdate().isBefore(this.record.getLastUpdate())) {
|
||||
this.getAlarmStore(bFileAlarmDatabase).append(this.record);
|
||||
if (this.record.getAckState().equals((Object)BAckState.ackPending)) {
|
||||
((BAlarmService)Sys.getService((Type)BAlarmService.TYPE)).ackAlarm(this.record);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] encode() throws IOException {
|
||||
ByteBuffer byteBuffer = new ByteBuffer();
|
||||
byteBuffer.write(super.encode());
|
||||
this.record.write((DataOutput)byteBuffer);
|
||||
return byteBuffer.toByteArray();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("[Append ");
|
||||
if (this.record.getAckState().equals((Object)BAckState.ackPending)) {
|
||||
stringBuffer.append("and Route ");
|
||||
}
|
||||
stringBuffer.append(this.record.getUuid()).append("]");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public Append(BAlarmRecord bAlarmRecord) {
|
||||
super(0);
|
||||
this.record = bAlarmRecord;
|
||||
}
|
||||
|
||||
public Append(ByteBuffer byteBuffer) throws Exception {
|
||||
super(0);
|
||||
this.record = new BAlarmRecord();
|
||||
this.record.read((DataInput)byteBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Update
|
||||
extends DataRecoveryAlarmEvent {
|
||||
BAlarmRecord record;
|
||||
|
||||
public void execute(BFileAlarmDatabase bFileAlarmDatabase) throws IOException {
|
||||
AlarmStore alarmStore = this.getAlarmStore(bFileAlarmDatabase);
|
||||
BAlarmRecord bAlarmRecord = alarmStore.getRecord(this.record.getUuid());
|
||||
if (bAlarmRecord == null || bAlarmRecord.getLastUpdate().isBefore(this.record.getLastUpdate())) {
|
||||
this.getAlarmStore(bFileAlarmDatabase).update(this.record);
|
||||
if (bAlarmRecord != null && bAlarmRecord.getAckState().equals((Object)BAckState.ackPending)) {
|
||||
((BAlarmService)Sys.getService((Type)BAlarmService.TYPE)).ackAlarm(this.record);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] encode() throws IOException {
|
||||
ByteBuffer byteBuffer = new ByteBuffer();
|
||||
byteBuffer.write(super.encode());
|
||||
this.record.write((DataOutput)byteBuffer);
|
||||
return byteBuffer.toByteArray();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("[Update ");
|
||||
if (this.record.getAckState().equals((Object)BAckState.ackPending)) {
|
||||
stringBuffer.append("and Route ");
|
||||
}
|
||||
stringBuffer.append(this.record.getUuid()).append("]");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public Update(BAlarmRecord bAlarmRecord) {
|
||||
super(1);
|
||||
this.record = bAlarmRecord;
|
||||
}
|
||||
|
||||
public Update(ByteBuffer byteBuffer) throws Exception {
|
||||
super(1);
|
||||
this.record = new BAlarmRecord();
|
||||
this.record.read((DataInput)byteBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ClearAll
|
||||
extends DataRecoveryAlarmEvent {
|
||||
public void execute(BFileAlarmDatabase bFileAlarmDatabase) throws IOException {
|
||||
this.getAlarmStore(bFileAlarmDatabase).clearAllRecords(null);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "[ClearAll]";
|
||||
}
|
||||
|
||||
public ClearAll() {
|
||||
super(2);
|
||||
}
|
||||
|
||||
public ClearAll(ByteBuffer byteBuffer) {
|
||||
this();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ClearOld
|
||||
extends DataRecoveryAlarmEvent {
|
||||
BAbsTime before;
|
||||
|
||||
public void execute(BFileAlarmDatabase bFileAlarmDatabase) throws IOException {
|
||||
this.getAlarmStore(bFileAlarmDatabase).clearOldRecords(this.before, null);
|
||||
}
|
||||
|
||||
public byte[] encode() throws IOException {
|
||||
ByteBuffer byteBuffer = new ByteBuffer();
|
||||
byteBuffer.write(super.encode());
|
||||
this.before.encode((DataOutput)byteBuffer);
|
||||
return byteBuffer.toByteArray();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("[ClearOld ").append(this.before).append("]");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public ClearOld(BAbsTime bAbsTime) {
|
||||
super(3);
|
||||
this.before = bAbsTime;
|
||||
}
|
||||
|
||||
public ClearOld(ByteBuffer byteBuffer) throws Exception {
|
||||
this(BAbsTime.make((long)byteBuffer.readLong()));
|
||||
}
|
||||
}
|
||||
|
||||
public static class ClearRecord
|
||||
extends DataRecoveryAlarmEvent {
|
||||
BUuid uuid;
|
||||
|
||||
public void execute(BFileAlarmDatabase bFileAlarmDatabase) throws IOException {
|
||||
this.getAlarmStore(bFileAlarmDatabase).clearRecord(this.uuid, null);
|
||||
}
|
||||
|
||||
public byte[] encode() throws IOException {
|
||||
ByteBuffer byteBuffer = new ByteBuffer();
|
||||
byteBuffer.write(super.encode());
|
||||
this.uuid.encode((DataOutput)byteBuffer);
|
||||
return byteBuffer.toByteArray();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("[ClearRecord ").append(this.uuid).append("]");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public ClearRecord(BUuid bUuid) {
|
||||
super(4);
|
||||
this.uuid = bUuid;
|
||||
}
|
||||
|
||||
public ClearRecord(ByteBuffer byteBuffer) throws IOException {
|
||||
this((BUuid)BUuid.DEFAULT.decode((DataInput)byteBuffer));
|
||||
}
|
||||
}
|
||||
|
||||
public static class CapacityChange
|
||||
extends DataRecoveryAlarmEvent {
|
||||
int capacity;
|
||||
|
||||
public void execute(BFileAlarmDatabase bFileAlarmDatabase) throws IOException {
|
||||
AlarmStore alarmStore = this.getAlarmStore(bFileAlarmDatabase);
|
||||
alarmStore.setCapacity(this.capacity);
|
||||
alarmStore.trimToCapacity();
|
||||
}
|
||||
|
||||
public byte[] encode() throws IOException {
|
||||
ByteBuffer byteBuffer = new ByteBuffer();
|
||||
byteBuffer.write(super.encode());
|
||||
byteBuffer.writeInt(this.capacity);
|
||||
return byteBuffer.toByteArray();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("[Capacity ").append(this.capacity).append("]");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public CapacityChange(int n) {
|
||||
super(5);
|
||||
this.capacity = n;
|
||||
}
|
||||
|
||||
public CapacityChange(ByteBuffer byteBuffer) throws Exception {
|
||||
this(byteBuffer.readInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
public class FreePageMap {
|
||||
private static final int[] BIT_MASKS = new int[]{1, 2, 4, 8, 16, 32, 64, 128};
|
||||
private int pageCount = 0;
|
||||
private byte[] pageMask = null;
|
||||
|
||||
public int getPageCount() {
|
||||
return this.pageCount;
|
||||
}
|
||||
|
||||
public int getFreeCount() {
|
||||
int n;
|
||||
int n2;
|
||||
byte by;
|
||||
if (this.pageCount == 0) {
|
||||
return 0;
|
||||
}
|
||||
int n3 = 0;
|
||||
int n4 = 0;
|
||||
while (n4 < this.pageMask.length - 1) {
|
||||
by = this.pageMask[n4];
|
||||
n2 = 1;
|
||||
n = 0;
|
||||
while (n < 8) {
|
||||
if ((by & n2) == 0) {
|
||||
++n3;
|
||||
}
|
||||
n2 <<= 1;
|
||||
++n;
|
||||
}
|
||||
++n4;
|
||||
}
|
||||
n4 = this.pageCount - (this.pageMask.length - 1) * 8;
|
||||
by = this.pageMask[this.pageMask.length - 1];
|
||||
n2 = 1;
|
||||
n = 0;
|
||||
while (n < n4) {
|
||||
if ((by & n2) == 0) {
|
||||
++n3;
|
||||
}
|
||||
n2 <<= 1;
|
||||
++n;
|
||||
}
|
||||
return n3;
|
||||
}
|
||||
|
||||
public int getFreePage() {
|
||||
if (this.pageCount != 0) {
|
||||
int n = this.pageMask.length;
|
||||
int n2 = 0;
|
||||
while (n2 < n) {
|
||||
if ((this.pageMask[n2] & 0xFF ^ 0xFF) != 0) {
|
||||
int n3 = 1;
|
||||
int n4 = 0;
|
||||
while (n4 < 8) {
|
||||
if ((this.pageMask[n2] & 0xFF & n3) == 0) {
|
||||
return n2 * 8 + n4;
|
||||
}
|
||||
n3 <<= 1;
|
||||
++n4;
|
||||
}
|
||||
}
|
||||
++n2;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean isFree(int n) {
|
||||
int n2 = n / 8;
|
||||
if (n2 >= this.pageCount) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
boolean bl = false;
|
||||
if ((this.pageMask[n2] & BIT_MASKS[n - n2 * 8]) == 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public void setFree(int n, boolean bl) {
|
||||
if (n >= this.pageCount) {
|
||||
this.addFreePages(n - this.pageCount + 1);
|
||||
}
|
||||
int n2 = n / 8;
|
||||
int n3 = BIT_MASKS[n - n2 * 8];
|
||||
this.pageMask[n2] = bl ? (byte)(this.pageMask[n2] & ~n3) : (byte)(this.pageMask[n2] | n3);
|
||||
}
|
||||
|
||||
public void addFreePages(int n) {
|
||||
int n2;
|
||||
if (n < 0) {
|
||||
throw new IllegalArgumentException("Invalid add count: " + n);
|
||||
}
|
||||
if (this.pageMask == null) {
|
||||
int n3 = n / 8;
|
||||
if (n % 8 != 0) {
|
||||
++n3;
|
||||
}
|
||||
this.pageMask = new byte[n3];
|
||||
this.pageCount = n;
|
||||
return;
|
||||
}
|
||||
int n4 = this.pageMask.length * 8;
|
||||
int n5 = n4 - this.pageCount;
|
||||
if (n5 != 0) {
|
||||
n2 = n5 > n ? n : n5;
|
||||
this.pageCount += n2;
|
||||
n -= n2;
|
||||
}
|
||||
if (n == 0) {
|
||||
return;
|
||||
}
|
||||
n2 = n / 8;
|
||||
if (n % 8 != 0) {
|
||||
++n2;
|
||||
}
|
||||
int n6 = this.pageMask.length;
|
||||
byte[] byArray = new byte[n6 + n2];
|
||||
System.arraycopy(this.pageMask, 0, byArray, 0, n6);
|
||||
this.pageMask = byArray;
|
||||
this.pageCount += n;
|
||||
}
|
||||
|
||||
public int getSizeInBytes() {
|
||||
return this.pageMask.length;
|
||||
}
|
||||
|
||||
public void dump() {
|
||||
int n;
|
||||
int n2;
|
||||
byte by;
|
||||
if (this.pageCount == 0) {
|
||||
return;
|
||||
}
|
||||
int n3 = 0;
|
||||
int n4 = 0;
|
||||
while (n4 < this.pageMask.length - 1) {
|
||||
by = this.pageMask[n4];
|
||||
n2 = 1;
|
||||
n = 0;
|
||||
while (n < 8) {
|
||||
if ((by & n2) == 0) {
|
||||
System.out.println(n3++ + ") free");
|
||||
} else {
|
||||
System.out.println(n3++ + ") in use");
|
||||
}
|
||||
n2 <<= 1;
|
||||
++n;
|
||||
}
|
||||
++n4;
|
||||
}
|
||||
n4 = this.pageCount - (this.pageMask.length - 1) * 8;
|
||||
by = this.pageMask[this.pageMask.length - 1];
|
||||
n2 = 1;
|
||||
n = 0;
|
||||
while (n < n4) {
|
||||
if ((by & n2) == 0) {
|
||||
System.out.println(n3++ + ") free");
|
||||
} else {
|
||||
System.out.println(n3++ + ") in use");
|
||||
}
|
||||
n2 <<= 1;
|
||||
++n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BAbsTime
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class IndexEntry {
|
||||
public static final int FLAG_OPEN = 1;
|
||||
public static final int FLAG_ACKED = 2;
|
||||
public static final int FLAG_NORMAL = 4;
|
||||
public static final int FLAG_ACK_PENDING = 8;
|
||||
public final BAbsTime timestamp;
|
||||
public final int pageIndex;
|
||||
public IndexEntry[] nextTimestamp;
|
||||
public IndexEntry prevTimestamp;
|
||||
public IndexEntry[] nextSource;
|
||||
public IndexEntry prevSource;
|
||||
public byte flags;
|
||||
public IndexEntry prevOpen;
|
||||
public IndexEntry nextOpen;
|
||||
public IndexEntry prevAckPending;
|
||||
public IndexEntry nextAckPending;
|
||||
|
||||
public boolean equals(Object object) {
|
||||
IndexEntry indexEntry = (IndexEntry)object;
|
||||
if (this.timestamp == null && indexEntry.timestamp == null) {
|
||||
return true;
|
||||
}
|
||||
if (this.timestamp == null || indexEntry.timestamp == null) {
|
||||
return false;
|
||||
}
|
||||
boolean bl = false;
|
||||
if (this.timestamp.equals((Object)indexEntry.timestamp) && this.pageIndex == indexEntry.pageIndex) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final boolean isOpen() {
|
||||
boolean bl = false;
|
||||
if ((this.flags & 1) != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final void setOpen(boolean bl) {
|
||||
this.flags = bl ? (byte)(this.flags | 1) : (byte)(this.flags & 0xFFFFFFFE);
|
||||
}
|
||||
|
||||
public final boolean isAcked() {
|
||||
boolean bl = false;
|
||||
if ((this.flags & 2) != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final void setAcked(boolean bl) {
|
||||
this.flags = bl ? (byte)(this.flags | 2) : (byte)(this.flags & 0xFFFFFFFD);
|
||||
}
|
||||
|
||||
public final boolean isNormal() {
|
||||
boolean bl = false;
|
||||
if ((this.flags & 4) != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final void setNormal(boolean bl) {
|
||||
this.flags = bl ? (byte)(this.flags | 4) : (byte)(this.flags & 0xFFFFFFFB);
|
||||
}
|
||||
|
||||
public final boolean isAckPending() {
|
||||
boolean bl = false;
|
||||
if ((this.flags & 8) != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final void setAckPending(boolean bl) {
|
||||
this.flags = bl ? (byte)(this.flags | 8) : (byte)(this.flags & 0xFFFFFFF7);
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.flags = 0;
|
||||
}
|
||||
|
||||
public IndexEntry() {
|
||||
this.this();
|
||||
this.timestamp = null;
|
||||
this.pageIndex = -1;
|
||||
}
|
||||
|
||||
public IndexEntry(BAlarmRecord bAlarmRecord, int n) {
|
||||
this.this();
|
||||
this.timestamp = bAlarmRecord.getTimestamp();
|
||||
this.pageIndex = n;
|
||||
}
|
||||
|
||||
public IndexEntry(BAbsTime bAbsTime, int n) {
|
||||
this.this();
|
||||
this.timestamp = bAbsTime;
|
||||
this.pageIndex = n;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.sys.BBoolean
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.Context
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.IndexEntry;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.Context;
|
||||
|
||||
public class OpenIndex {
|
||||
private static final BFacets showSecs = BFacets.make((String)"showSeconds", (BIDataValue)BBoolean.TRUE);
|
||||
private IndexEntry first = null;
|
||||
private IndexEntry last = null;
|
||||
private int size = 0;
|
||||
|
||||
public int getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public IndexEntry getFirstEntry() {
|
||||
return this.first;
|
||||
}
|
||||
|
||||
public void add(IndexEntry indexEntry) {
|
||||
if (indexEntry.isOpen()) {
|
||||
return;
|
||||
}
|
||||
indexEntry.setOpen(true);
|
||||
indexEntry.nextOpen = null;
|
||||
indexEntry.prevOpen = null;
|
||||
if (this.size == 0) {
|
||||
this.first = this.last = indexEntry;
|
||||
} else {
|
||||
IndexEntry indexEntry2 = indexEntry.prevTimestamp;
|
||||
while (indexEntry2 != null && !indexEntry2.isOpen()) {
|
||||
indexEntry2 = indexEntry2.prevTimestamp;
|
||||
}
|
||||
if (indexEntry2 == null) {
|
||||
if (this.first == null) {
|
||||
this.first = this.last = indexEntry;
|
||||
} else {
|
||||
indexEntry.nextOpen = this.first;
|
||||
this.first.prevOpen = indexEntry;
|
||||
this.first = indexEntry;
|
||||
}
|
||||
} else {
|
||||
indexEntry.nextOpen = indexEntry2.nextOpen;
|
||||
indexEntry.prevOpen = indexEntry2;
|
||||
if (indexEntry2.nextOpen != null) {
|
||||
indexEntry2.nextOpen.prevOpen = indexEntry;
|
||||
}
|
||||
indexEntry2.nextOpen = indexEntry;
|
||||
if (indexEntry.prevOpen == this.last) {
|
||||
this.last = indexEntry;
|
||||
}
|
||||
}
|
||||
}
|
||||
++this.size;
|
||||
}
|
||||
|
||||
public void remove(IndexEntry indexEntry) {
|
||||
if (this.size == 0 || indexEntry == null) {
|
||||
return;
|
||||
}
|
||||
if (!indexEntry.isOpen()) {
|
||||
return;
|
||||
}
|
||||
indexEntry.setOpen(false);
|
||||
if (indexEntry.prevOpen != null) {
|
||||
indexEntry.prevOpen.nextOpen = indexEntry.nextOpen;
|
||||
}
|
||||
if (indexEntry.nextOpen != null) {
|
||||
indexEntry.nextOpen.prevOpen = indexEntry.prevOpen;
|
||||
}
|
||||
if (indexEntry == this.first) {
|
||||
this.first = indexEntry.nextOpen;
|
||||
}
|
||||
if (indexEntry == this.last) {
|
||||
this.last = indexEntry.prevOpen;
|
||||
}
|
||||
indexEntry.nextOpen = null;
|
||||
indexEntry.prevOpen = null;
|
||||
--this.size;
|
||||
}
|
||||
|
||||
public void dump() {
|
||||
IndexEntry indexEntry = this.first;
|
||||
int n = 0;
|
||||
while (indexEntry != null) {
|
||||
System.out.println(n++ + ") " + indexEntry.timestamp.toString((Context)showSecs) + " open=" + indexEntry.isOpen());
|
||||
indexEntry = indexEntry.nextOpen;
|
||||
}
|
||||
}
|
||||
|
||||
public void verify() {
|
||||
IndexEntry indexEntry = null;
|
||||
IndexEntry indexEntry2 = this.first;
|
||||
int n = 0;
|
||||
while (indexEntry2 != null) {
|
||||
++n;
|
||||
if (indexEntry != null && indexEntry.timestamp.isAfter(indexEntry2.timestamp)) {
|
||||
throw new IllegalStateException("Invalid ascending order. " + indexEntry2.timestamp.toString((Context)showSecs) + " is before " + indexEntry.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
if (!indexEntry2.isOpen()) {
|
||||
throw new IllegalStateException("Cleared alarm in open index, ascending. " + indexEntry2.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = indexEntry2.nextOpen;
|
||||
}
|
||||
if (this.size != n) {
|
||||
throw new IllegalStateException("Invalid ascending count. size=" + this.size + ", count=" + n);
|
||||
}
|
||||
indexEntry = null;
|
||||
indexEntry2 = this.last;
|
||||
n = 0;
|
||||
while (indexEntry2 != null) {
|
||||
++n;
|
||||
if (indexEntry != null && indexEntry.timestamp.isBefore(indexEntry2.timestamp)) {
|
||||
throw new IllegalStateException("Invalid descending order. " + indexEntry2.timestamp.toString((Context)showSecs) + " is after " + indexEntry.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
if (!indexEntry2.isOpen()) {
|
||||
throw new IllegalStateException("Cleared alarm in open index, descending. " + indexEntry2.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = indexEntry2.prevOpen;
|
||||
}
|
||||
if (this.size != n) {
|
||||
throw new IllegalStateException("Invalid descending count. size=" + this.size + ", count=" + n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.Block;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Page {
|
||||
public static final int HEADER_SIZE = 12;
|
||||
private Block block;
|
||||
private int pageInBlock;
|
||||
private int size;
|
||||
private int recPage;
|
||||
private int recPages;
|
||||
private int nextPage;
|
||||
|
||||
public int getPageOfRecord() {
|
||||
return this.recPage;
|
||||
}
|
||||
|
||||
public int getPagesOfRecord() {
|
||||
return this.recPages;
|
||||
}
|
||||
|
||||
public int getNextPage() {
|
||||
return this.nextPage;
|
||||
}
|
||||
|
||||
public synchronized void read() throws IOException {
|
||||
Block.Input input = this.block.getInput();
|
||||
input.seek(this.size * this.pageInBlock);
|
||||
this.recPage = input.readInt();
|
||||
this.recPages = input.readInt();
|
||||
this.nextPage = input.readInt();
|
||||
}
|
||||
|
||||
public synchronized void write(int n, int n2, int n3, byte[] byArray, int n4, int n5) throws IOException {
|
||||
this.recPage = n;
|
||||
this.recPages = n2;
|
||||
this.nextPage = n3;
|
||||
Block.Output output = this.block.getOutput();
|
||||
output.seek(this.size * this.pageInBlock);
|
||||
output.writeInt(n);
|
||||
output.writeInt(n2);
|
||||
output.writeInt(n3);
|
||||
if (n5 != 0) {
|
||||
output.write(byArray, n4, n5);
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() throws IOException {
|
||||
this.write(-1, 0, -1, null, 0, 0);
|
||||
}
|
||||
|
||||
public synchronized int readData(int n) throws IOException {
|
||||
Block.Input input = this.block.getInput();
|
||||
input.seek(this.size * this.pageInBlock + 12 + n);
|
||||
return input.read();
|
||||
}
|
||||
|
||||
public synchronized int readData(int n, byte[] byArray, int n2, int n3) throws IOException {
|
||||
Block.Input input = this.block.getInput();
|
||||
input.seek(this.size * this.pageInBlock + 12 + n);
|
||||
int n4 = this.size - 12 - n;
|
||||
if (n4 < n3) {
|
||||
return input.read(byArray, n2, n4);
|
||||
}
|
||||
return input.read(byArray, n2, n3);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.recPage + " of " + this.recPages + ", next=" + this.nextPage;
|
||||
}
|
||||
|
||||
public Page(Block block, int n, int n2) {
|
||||
this.block = block;
|
||||
this.pageInBlock = n;
|
||||
this.size = n2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AlarmStore;
|
||||
import com.tridium.alarm.db.file.Page;
|
||||
import java.io.DataInput;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.UTFDataFormatException;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class PageReader
|
||||
implements DataInput {
|
||||
private AlarmStore store;
|
||||
private int pageIndex;
|
||||
private Page page;
|
||||
private int pos;
|
||||
private int pageLen;
|
||||
private int[] pages;
|
||||
private int pageCount;
|
||||
|
||||
public void init(int n) throws IOException {
|
||||
this.pageIndex = n;
|
||||
if (this.pageIndex != -1) {
|
||||
this.page = this.store.readPage(this.pageIndex);
|
||||
}
|
||||
this.pos = 0;
|
||||
this.pageLen = this.store.getHeader().getPageSize() - 12;
|
||||
this.pageCount = 1;
|
||||
if (this.pages == null) {
|
||||
this.pages = new int[3];
|
||||
}
|
||||
this.pages[0] = n;
|
||||
}
|
||||
|
||||
private final void nextPage() throws IOException {
|
||||
if (this.page == null) {
|
||||
throw new IllegalStateException("PageReader has not been initialized.");
|
||||
}
|
||||
int n = this.page.getNextPage();
|
||||
if (n == -1) {
|
||||
throw new EOFException();
|
||||
}
|
||||
this.pageIndex = n;
|
||||
this.page = this.store.readPage(this.pageIndex);
|
||||
this.pos = 0;
|
||||
if (this.pageCount == this.pages.length) {
|
||||
int[] nArray = new int[this.pageCount + 1];
|
||||
System.arraycopy(this.pages, 0, nArray, 0, this.pageCount);
|
||||
this.pages = nArray;
|
||||
}
|
||||
this.pages[this.pageCount++] = this.pageIndex;
|
||||
}
|
||||
|
||||
public int getPageCount() {
|
||||
return this.pageCount;
|
||||
}
|
||||
|
||||
public int getPageIndex(int n) {
|
||||
return this.pages[n];
|
||||
}
|
||||
|
||||
public int read() throws IOException {
|
||||
if (this.pos >= this.pageLen) {
|
||||
this.nextPage();
|
||||
}
|
||||
return this.page.readData(this.pos++);
|
||||
}
|
||||
|
||||
public int read(byte[] byArray) throws IOException {
|
||||
return this.read(byArray, 0, byArray.length);
|
||||
}
|
||||
|
||||
public int read(byte[] byArray, int n, int n2) throws IOException {
|
||||
if (this.pos >= this.pageLen) {
|
||||
this.nextPage();
|
||||
}
|
||||
int n3 = this.page.readData(this.pos, byArray, n, n2);
|
||||
this.pos += n3;
|
||||
return n3;
|
||||
}
|
||||
|
||||
public void readFully(byte[] byArray) throws IOException {
|
||||
this.readFully(byArray, 0, byArray.length);
|
||||
}
|
||||
|
||||
public void readFully(byte[] byArray, int n, int n2) throws IOException {
|
||||
int n3 = n2;
|
||||
int n4 = 0;
|
||||
while (n4 < n3) {
|
||||
int n5 = this.read(byArray, n + n4, n3 - n4);
|
||||
if (n5 == -1) {
|
||||
throw new EOFException();
|
||||
}
|
||||
n4 += n5;
|
||||
}
|
||||
}
|
||||
|
||||
public int skipBytes(int n) throws IOException {
|
||||
int n2 = n;
|
||||
while (n > 0) {
|
||||
int n3 = this.pageLen - this.pos;
|
||||
if (n3 > n) {
|
||||
this.pos += n;
|
||||
return n2;
|
||||
}
|
||||
n -= n3;
|
||||
this.nextPage();
|
||||
}
|
||||
return n2;
|
||||
}
|
||||
|
||||
public boolean readBoolean() throws IOException {
|
||||
boolean bl = false;
|
||||
if (this.read() != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public byte readByte() throws IOException {
|
||||
return (byte)this.read();
|
||||
}
|
||||
|
||||
public int readUnsignedByte() throws IOException {
|
||||
return this.read();
|
||||
}
|
||||
|
||||
public short readShort() throws IOException {
|
||||
return (short)((this.read() << 8) + this.read());
|
||||
}
|
||||
|
||||
public int readUnsignedShort() throws IOException {
|
||||
return (this.read() << 8) + this.read();
|
||||
}
|
||||
|
||||
public char readChar() throws IOException {
|
||||
return (char)((this.read() << 8) + this.read());
|
||||
}
|
||||
|
||||
public int readInt() throws IOException {
|
||||
return (this.read() << 24) + (this.read() << 16) + (this.read() << 8) + this.read();
|
||||
}
|
||||
|
||||
public long readLong() throws IOException {
|
||||
return ((long)this.readInt() << 32) + ((long)this.readInt() & 0xFFFFFFFFL);
|
||||
}
|
||||
|
||||
public float readFloat() throws IOException {
|
||||
return Float.intBitsToFloat(this.readInt());
|
||||
}
|
||||
|
||||
public double readDouble() throws IOException {
|
||||
return Double.longBitsToDouble(this.readLong());
|
||||
}
|
||||
|
||||
public String readLine() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String readUTF() throws IOException {
|
||||
int n = this.readUnsignedShort();
|
||||
StringBuffer stringBuffer = new StringBuffer(n);
|
||||
int n2 = 0;
|
||||
while (n2 < n) {
|
||||
int n3 = this.read();
|
||||
switch (n3 >> 4) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7: {
|
||||
++n2;
|
||||
stringBuffer.append((char)n3);
|
||||
break;
|
||||
}
|
||||
case 12:
|
||||
case 13: {
|
||||
if ((n2 += 2) > n) {
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
int n4 = this.read();
|
||||
if ((n4 & 0xC0) != 128) {
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
stringBuffer.append((char)((n3 & 0x1F) << 6 | n4 & 0x3F));
|
||||
break;
|
||||
}
|
||||
case 14: {
|
||||
if ((n2 += 3) > n) {
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
int n4 = this.read();
|
||||
int n5 = this.read();
|
||||
if ((n4 & 0xC0) != 128 || (n5 & 0xC0) != 128) {
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
stringBuffer.append((char)((n3 & 0xF) << 12 | (n4 & 0x3F) << 6 | n5 & 0x3F));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
}
|
||||
}
|
||||
return new String(stringBuffer);
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.pageIndex = -1;
|
||||
}
|
||||
|
||||
public PageReader(AlarmStore alarmStore) throws IOException {
|
||||
this(alarmStore, -1);
|
||||
}
|
||||
|
||||
public PageReader(AlarmStore alarmStore, int n) throws IOException {
|
||||
this.this();
|
||||
this.store = alarmStore;
|
||||
this.init(n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AlarmStore;
|
||||
import com.tridium.alarm.db.file.IndexEntry;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Random;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public abstract class SkipList {
|
||||
public static final int EQUAL_OR_AFTER = 0;
|
||||
public static final int EQUAL_OR_BEFORE = 1;
|
||||
public static final int EQUAL = 2;
|
||||
private int maxLevel;
|
||||
private IndexEntry header;
|
||||
private double probability;
|
||||
private int level;
|
||||
private int size;
|
||||
private Random rand;
|
||||
private IndexEntry[] addAt;
|
||||
private IndexEntry[] removeAt;
|
||||
private IndexEntry[] findAt;
|
||||
|
||||
public synchronized int getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public IndexEntry getHeader() {
|
||||
return this.header;
|
||||
}
|
||||
|
||||
public IndexEntry getFirstEntry() {
|
||||
return this.getNext(this.header, 0);
|
||||
}
|
||||
|
||||
public synchronized void add(IndexEntry indexEntry) {
|
||||
int n = this.generateNewLevel();
|
||||
this.setLevel(indexEntry, n);
|
||||
if (n > this.level) {
|
||||
this.level = n;
|
||||
}
|
||||
this.pathTo(indexEntry, this.addAt);
|
||||
int n2 = 0;
|
||||
while (n2 < n) {
|
||||
if (n2 == 0) {
|
||||
this.setPrev(indexEntry, this.addAt[0]);
|
||||
IndexEntry indexEntry2 = this.getNext(this.addAt[0], 0);
|
||||
if (indexEntry2 != null) {
|
||||
this.setPrev(indexEntry2, indexEntry);
|
||||
}
|
||||
}
|
||||
this.setNext(indexEntry, n2, this.getNext(this.addAt[n2], n2));
|
||||
this.setNext(this.addAt[n2], n2, indexEntry);
|
||||
++n2;
|
||||
}
|
||||
++this.size;
|
||||
}
|
||||
|
||||
public synchronized void remove(IndexEntry indexEntry) {
|
||||
if (this.size == 0) {
|
||||
return;
|
||||
}
|
||||
this.pathTo(indexEntry, this.removeAt);
|
||||
IndexEntry indexEntry2 = this.getNext(this.removeAt[0], 0);
|
||||
if (!indexEntry2.equals(indexEntry)) {
|
||||
throw new IllegalArgumentException("Entry not found: " + this.entryToString(indexEntry2));
|
||||
}
|
||||
int n = 0;
|
||||
while (n < this.level) {
|
||||
IndexEntry indexEntry3;
|
||||
if (this.getNext(this.removeAt[n], n) != indexEntry2) break;
|
||||
if (n == 0 && (indexEntry3 = this.getNext(indexEntry2, 0)) != null) {
|
||||
this.setPrev(indexEntry3, this.removeAt[0]);
|
||||
}
|
||||
this.setNext(this.removeAt[n], n, this.getNext(indexEntry2, n));
|
||||
++n;
|
||||
}
|
||||
while (this.level > 1 && this.getNext(this.header, this.level - 1) == null) {
|
||||
--this.level;
|
||||
}
|
||||
n = this.level;
|
||||
while (n < this.maxLevel) {
|
||||
this.addAt[n] = null;
|
||||
this.removeAt[n] = null;
|
||||
this.findAt[n] = null;
|
||||
++n;
|
||||
}
|
||||
--this.size;
|
||||
}
|
||||
|
||||
public IndexEntry find(Object object) {
|
||||
this.pathTo(object, this.findAt);
|
||||
return this.findAt[0];
|
||||
}
|
||||
|
||||
protected void pathTo(Object object, IndexEntry[] indexEntryArray) {
|
||||
IndexEntry indexEntry = this.header;
|
||||
IndexEntry indexEntry2 = null;
|
||||
int n = this.level - 1;
|
||||
while (n >= 0) {
|
||||
indexEntry2 = this.getNext(indexEntry, n);
|
||||
while (indexEntry2 != null && this.compareToKey(indexEntry2, object) < 0) {
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = this.getNext(indexEntry2, n);
|
||||
}
|
||||
indexEntryArray[n] = indexEntry;
|
||||
--n;
|
||||
}
|
||||
}
|
||||
|
||||
protected void pathTo(IndexEntry indexEntry, IndexEntry[] indexEntryArray) {
|
||||
IndexEntry indexEntry2 = this.header;
|
||||
IndexEntry indexEntry3 = null;
|
||||
int n = this.level - 1;
|
||||
while (n >= 0) {
|
||||
indexEntry3 = this.getNext(indexEntry2, n);
|
||||
while (indexEntry3 != null && this.isBefore(indexEntry3, indexEntry)) {
|
||||
indexEntry2 = indexEntry3;
|
||||
indexEntry3 = this.getNext(indexEntry3, n);
|
||||
}
|
||||
indexEntryArray[n] = indexEntry2;
|
||||
--n;
|
||||
}
|
||||
}
|
||||
|
||||
private final int generateNewLevel() {
|
||||
if (this.size == 0) {
|
||||
return 1;
|
||||
}
|
||||
int n = 1;
|
||||
while (this.rand.nextDouble() < this.probability && n < this.maxLevel) {
|
||||
if (++n != this.level + 1) continue;
|
||||
return n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
protected abstract int compare(IndexEntry var1, IndexEntry var2);
|
||||
|
||||
protected abstract int compareToKey(IndexEntry var1, Object var2);
|
||||
|
||||
protected boolean equals(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
boolean bl = false;
|
||||
if (this.compare(indexEntry, indexEntry2) == 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
protected boolean isBefore(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
boolean bl = false;
|
||||
if (this.compare(indexEntry, indexEntry2) < 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
protected boolean isAfter(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
boolean bl = false;
|
||||
if (this.compare(indexEntry, indexEntry2) > 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
protected abstract int getLevel(IndexEntry var1);
|
||||
|
||||
protected abstract void setLevel(IndexEntry var1, int var2);
|
||||
|
||||
protected abstract IndexEntry getNext(IndexEntry var1, int var2);
|
||||
|
||||
protected abstract void setNext(IndexEntry var1, int var2, IndexEntry var3);
|
||||
|
||||
protected abstract IndexEntry getPrev(IndexEntry var1);
|
||||
|
||||
protected abstract void setPrev(IndexEntry var1, IndexEntry var2);
|
||||
|
||||
public void dump() throws IOException {
|
||||
this.dump(null);
|
||||
}
|
||||
|
||||
public void dump(AlarmStore alarmStore) throws IOException {
|
||||
int n = 0;
|
||||
IndexEntry indexEntry = this.getNext(this.header, 0);
|
||||
BAlarmRecord bAlarmRecord = null;
|
||||
if (alarmStore != null) {
|
||||
bAlarmRecord = new BAlarmRecord();
|
||||
}
|
||||
while (indexEntry != null) {
|
||||
System.out.println(n++ + ": (" + this.getLevel(indexEntry) + ") " + this.entryToString(indexEntry));
|
||||
if (alarmStore != null) {
|
||||
bAlarmRecord = alarmStore.readRecord(indexEntry.pageIndex, bAlarmRecord, null);
|
||||
System.out.println(" " + bAlarmRecord.toSummaryString());
|
||||
}
|
||||
indexEntry = this.getNext(indexEntry, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void analyze(String string, PrintStream printStream) {
|
||||
printStream.println(string);
|
||||
printStream.println(" probability: " + this.probability);
|
||||
printStream.println(" maxLevel : " + this.maxLevel);
|
||||
printStream.println(" level : " + this.level);
|
||||
int[] nArray = new int[this.level];
|
||||
int n = 0;
|
||||
while (n < this.level) {
|
||||
IndexEntry indexEntry = this.getNext(this.header, n);
|
||||
while (indexEntry != null) {
|
||||
nArray[n] = nArray[n] + 1;
|
||||
indexEntry = this.getNext(indexEntry, n);
|
||||
}
|
||||
++n;
|
||||
}
|
||||
n = 0;
|
||||
while (n < this.level) {
|
||||
System.out.println(" level " + (n + 1) + ": " + nArray[n]);
|
||||
++n;
|
||||
}
|
||||
n = this.size * 4;
|
||||
int n2 = 0;
|
||||
while (n2 < this.level) {
|
||||
n += nArray[n2] * 4;
|
||||
++n2;
|
||||
}
|
||||
DecimalFormat decimalFormat = new DecimalFormat("###,###,###.##");
|
||||
printStream.println(" ptr ram : " + decimalFormat.format((double)n / 1024.0 / 1024.0) + " MB");
|
||||
}
|
||||
|
||||
public void verify() {
|
||||
int n = 0;
|
||||
IndexEntry indexEntry = null;
|
||||
IndexEntry indexEntry2 = this.getNext(this.header, 0);
|
||||
while (indexEntry2 != null) {
|
||||
++n;
|
||||
if (indexEntry != null && this.isAfter(indexEntry, indexEntry2)) {
|
||||
throw new IllegalStateException("Invalid ascending order. " + this.entryToString(indexEntry2) + " is before " + this.entryToString(indexEntry));
|
||||
}
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = this.getNext(indexEntry2, 0);
|
||||
}
|
||||
if (this.size != n) {
|
||||
throw new IllegalStateException("Invalid ascending count. size=" + this.size + ", count=" + n);
|
||||
}
|
||||
indexEntry2 = indexEntry;
|
||||
n = 0;
|
||||
indexEntry = null;
|
||||
while (indexEntry2 != this.header) {
|
||||
++n;
|
||||
if (indexEntry != null && this.isBefore(indexEntry, indexEntry2)) {
|
||||
throw new IllegalStateException("Invalid descending order. " + this.entryToString(indexEntry2) + " is after " + this.entryToString(indexEntry));
|
||||
}
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = this.getPrev(indexEntry2);
|
||||
}
|
||||
if (this.size != n) {
|
||||
throw new IllegalStateException("Invalid descending count. size=" + this.size + ", count=" + n);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract String entryToString(IndexEntry var1);
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.rand = new Random();
|
||||
}
|
||||
|
||||
public SkipList(double d, int n) {
|
||||
this.this();
|
||||
this.maxLevel = (int)(Math.log(n) / Math.log(1.0 / d)) + 1;
|
||||
this.probability = d;
|
||||
this.header = new IndexEntry();
|
||||
this.setLevel(this.header, this.maxLevel);
|
||||
this.level = 1;
|
||||
this.size = 0;
|
||||
this.addAt = new IndexEntry[this.maxLevel];
|
||||
this.removeAt = new IndexEntry[this.maxLevel];
|
||||
this.findAt = new IndexEntry[this.maxLevel];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.Context
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.IndexEntry;
|
||||
import com.tridium.alarm.db.file.SkipList;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.Context;
|
||||
|
||||
public class TimestampIndex
|
||||
extends SkipList {
|
||||
public IndexEntry find(Object object) {
|
||||
BAbsTime bAbsTime = (BAbsTime)object;
|
||||
IndexEntry indexEntry = super.find(object);
|
||||
if (indexEntry.timestamp == null) {
|
||||
return indexEntry;
|
||||
}
|
||||
if (!indexEntry.timestamp.equals((Object)bAbsTime)) {
|
||||
return indexEntry;
|
||||
}
|
||||
IndexEntry indexEntry2 = this.getPrev(indexEntry);
|
||||
while (indexEntry2.timestamp != null && indexEntry2.timestamp.equals((Object)bAbsTime)) {
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = this.getPrev(indexEntry);
|
||||
}
|
||||
return indexEntry;
|
||||
}
|
||||
|
||||
protected int compareToKey(IndexEntry indexEntry, Object object) {
|
||||
return indexEntry.timestamp.compareTo((Object)((BAbsTime)object));
|
||||
}
|
||||
|
||||
protected int compare(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
int n = indexEntry.timestamp.compareTo((Object)indexEntry2.timestamp);
|
||||
if (n == 0) {
|
||||
return indexEntry.pageIndex - indexEntry2.pageIndex;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
protected int getLevel(IndexEntry indexEntry) {
|
||||
return indexEntry.nextTimestamp.length;
|
||||
}
|
||||
|
||||
protected void setLevel(IndexEntry indexEntry, int n) {
|
||||
indexEntry.nextTimestamp = new IndexEntry[n];
|
||||
}
|
||||
|
||||
protected IndexEntry getNext(IndexEntry indexEntry, int n) {
|
||||
return indexEntry.nextTimestamp[n];
|
||||
}
|
||||
|
||||
protected void setNext(IndexEntry indexEntry, int n, IndexEntry indexEntry2) {
|
||||
indexEntry.nextTimestamp[n] = indexEntry2;
|
||||
}
|
||||
|
||||
protected IndexEntry getPrev(IndexEntry indexEntry) {
|
||||
return indexEntry.prevTimestamp;
|
||||
}
|
||||
|
||||
protected void setPrev(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
indexEntry.prevTimestamp = indexEntry2;
|
||||
}
|
||||
|
||||
public String entryToString(IndexEntry indexEntry) {
|
||||
return indexEntry.timestamp.toString((Context)BAlarmRecord.TIMESTAMP_FACETS) + " => " + indexEntry.pageIndex;
|
||||
}
|
||||
|
||||
public TimestampIndex(double d, int n) {
|
||||
super(d, n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,512 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.nre.util.IFilter
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.db.memory;
|
||||
|
||||
import com.tridium.alarm.FilterCursor;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import javax.baja.alarm.AlarmException;
|
||||
import javax.baja.alarm.BAlarmClass;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.nre.util.IFilter;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BMemoryAlarmDatabase
|
||||
extends BAlarmDatabase {
|
||||
public static final Type TYPE;
|
||||
private static final String CAPACITY = "capacity";
|
||||
private int capacity;
|
||||
private AlarmEntry first;
|
||||
private AlarmEntry last;
|
||||
private int recordCount;
|
||||
private HashMap byUuid;
|
||||
private IFilter openFilter;
|
||||
private IFilter ackPendingFilter;
|
||||
private BAlarmService alarmService;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$memory$BMemoryAlarmDatabase;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmClass;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
protected void doOpen() {
|
||||
this.recordCount = 0;
|
||||
this.first = null;
|
||||
this.last = null;
|
||||
this.byUuid = new HashMap();
|
||||
}
|
||||
|
||||
protected void doClose() {
|
||||
this.recordCount = 0;
|
||||
this.first = null;
|
||||
this.last = null;
|
||||
this.byUuid = new HashMap();
|
||||
}
|
||||
|
||||
public synchronized void append(BAlarmRecord bAlarmRecord) throws IOException {
|
||||
Object object;
|
||||
AlarmEntry alarmEntry = new AlarmEntry((BAlarmRecord)bAlarmRecord.newCopy(true));
|
||||
if (this.first == null) {
|
||||
this.first = this.last = alarmEntry;
|
||||
} else {
|
||||
object = bAlarmRecord.getTimestamp();
|
||||
AlarmEntry alarmEntry2 = this.first;
|
||||
while (alarmEntry2 != null && alarmEntry2.rec.getTimestamp().isBefore((BAbsTime)object)) {
|
||||
alarmEntry2 = alarmEntry2.next;
|
||||
}
|
||||
if (alarmEntry2 == null) {
|
||||
this.last.next = alarmEntry;
|
||||
alarmEntry.prev = this.last;
|
||||
this.last = alarmEntry;
|
||||
} else {
|
||||
alarmEntry.prev = alarmEntry2.prev;
|
||||
if (alarmEntry2.prev != null) {
|
||||
alarmEntry2.prev.next = alarmEntry;
|
||||
}
|
||||
alarmEntry.next = alarmEntry2;
|
||||
alarmEntry2.prev = alarmEntry;
|
||||
if (alarmEntry2 == this.first) {
|
||||
this.first = alarmEntry;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.byUuid.put(bAlarmRecord.getUuid(), alarmEntry);
|
||||
++this.recordCount;
|
||||
object = this.alarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (object.getName().equals(bAlarmRecord.getAlarmClass())) {
|
||||
((BAlarmClass)((Object)object)).setTotalAlarmCount(((BAlarmClass)((Object)object)).getTotalAlarmCount() + 1);
|
||||
if (!bAlarmRecord.isAcknowledged()) {
|
||||
((BAlarmClass)((Object)object)).setUnackedAlarmCount(((BAlarmClass)((Object)object)).getUnackedAlarmCount() + 1);
|
||||
}
|
||||
if (!bAlarmRecord.isNormal()) {
|
||||
((BAlarmClass)((Object)object)).setInAlarmCount(((BAlarmClass)((Object)object)).getInAlarmCount() + 1);
|
||||
}
|
||||
if (bAlarmRecord.isOpen()) {
|
||||
((BAlarmClass)((Object)object)).setOpenAlarmCount(((BAlarmClass)((Object)object)).getOpenAlarmCount() + 1);
|
||||
}
|
||||
}
|
||||
if (this.recordCount > this.capacity) {
|
||||
this.trim();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void update(BAlarmRecord bAlarmRecord) throws IOException {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
bAlarmRecord.write(new DataOutputStream(byteArrayOutputStream));
|
||||
BUuid bUuid = bAlarmRecord.getUuid();
|
||||
AlarmEntry alarmEntry = (AlarmEntry)this.byUuid.get(bUuid);
|
||||
if (alarmEntry != null) {
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass.getName().equals(bAlarmRecord.getAlarmClass())) {
|
||||
if (!alarmEntry.rec.isAcknowledged() && bAlarmRecord.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() - 1);
|
||||
} else if (alarmEntry.rec.isAcknowledged() && !bAlarmRecord.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() + 1);
|
||||
}
|
||||
if (alarmEntry.rec.isOpen() && !bAlarmRecord.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() - 1);
|
||||
}
|
||||
if (!alarmEntry.rec.isNormal() && bAlarmRecord.isNormal()) {
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() - 1);
|
||||
}
|
||||
}
|
||||
alarmEntry.rec = (BAlarmRecord)bAlarmRecord.newCopy(true);
|
||||
} else {
|
||||
this.append(bAlarmRecord);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void remove(BAlarmRecord bAlarmRecord) {
|
||||
BUuid bUuid = bAlarmRecord.getUuid();
|
||||
AlarmEntry alarmEntry = (AlarmEntry)this.byUuid.get(bUuid);
|
||||
if (alarmEntry != null) {
|
||||
if (alarmEntry.prev != null) {
|
||||
alarmEntry.prev.next = alarmEntry.next;
|
||||
}
|
||||
if (alarmEntry.next != null) {
|
||||
alarmEntry.next.prev = alarmEntry.prev;
|
||||
}
|
||||
if (alarmEntry == this.first) {
|
||||
this.first = alarmEntry.next;
|
||||
}
|
||||
if (alarmEntry == this.last) {
|
||||
this.last = alarmEntry.prev;
|
||||
}
|
||||
alarmEntry.prev = null;
|
||||
alarmEntry.next = null;
|
||||
this.byUuid.remove(bUuid);
|
||||
}
|
||||
}
|
||||
|
||||
private final synchronized void trim() {
|
||||
while (this.recordCount > this.capacity) {
|
||||
AlarmEntry alarmEntry = this.first;
|
||||
this.first = this.first.next;
|
||||
alarmEntry.next = null;
|
||||
if (this.first != null) {
|
||||
this.first.prev = null;
|
||||
}
|
||||
this.byUuid.remove(alarmEntry.rec.getUuid());
|
||||
--this.recordCount;
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(alarmEntry.rec.getAlarmClass());
|
||||
if (!bAlarmClass.getName().equals(alarmEntry.rec.getAlarmClass())) continue;
|
||||
bAlarmClass.setTotalAlarmCount(bAlarmClass.getTotalAlarmCount() - 1);
|
||||
if (!alarmEntry.rec.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() - 1);
|
||||
}
|
||||
if (alarmEntry.rec.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() - 1);
|
||||
}
|
||||
if (alarmEntry.rec.isNormal()) continue;
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized int getRecordCount() {
|
||||
return this.recordCount;
|
||||
}
|
||||
|
||||
public BAlarmRecord getRecord(BUuid bUuid) {
|
||||
AlarmEntry alarmEntry = (AlarmEntry)this.byUuid.get(bUuid);
|
||||
if (alarmEntry == null) {
|
||||
return null;
|
||||
}
|
||||
return alarmEntry.rec;
|
||||
}
|
||||
|
||||
public synchronized Cursor scan() throws IOException, AlarmException {
|
||||
return new AlarmCursor(this, this.first, BAbsTime.NULL, null);
|
||||
}
|
||||
|
||||
public synchronized Cursor timeQuery(BAbsTime bAbsTime, BAbsTime bAbsTime2) throws IOException, AlarmException {
|
||||
AlarmEntry alarmEntry = null;
|
||||
AlarmEntry alarmEntry2 = this.first;
|
||||
while (alarmEntry2 != null) {
|
||||
if (!alarmEntry2.rec.getTimestamp().isBefore(bAbsTime)) {
|
||||
alarmEntry = alarmEntry2;
|
||||
break;
|
||||
}
|
||||
alarmEntry2 = alarmEntry2.next;
|
||||
}
|
||||
return new AlarmCursor(this, alarmEntry, bAbsTime2, null);
|
||||
}
|
||||
|
||||
public Cursor getAlarmsForSource(BOrdList bOrdList) throws IOException {
|
||||
return new FilterCursor(new SourceFilter(bOrdList), this.scan());
|
||||
}
|
||||
|
||||
public Cursor getOpenAlarms() throws IOException {
|
||||
return new FilterCursor(this.openFilter, this.scan());
|
||||
}
|
||||
|
||||
public Cursor getAckPendingAlarms() throws IOException {
|
||||
return new FilterCursor(this.ackPendingFilter, this.scan());
|
||||
}
|
||||
|
||||
public synchronized void clearAllRecords(Context context) throws IOException {
|
||||
this.recordCount = 0;
|
||||
this.first = null;
|
||||
this.last = null;
|
||||
this.byUuid = new HashMap();
|
||||
Class clazz = class$javax$baja$alarm$BAlarmClass;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$alarm$BAlarmClass = BMemoryAlarmDatabase.class("[Ljavax.baja.alarm.BAlarmClass;", false);
|
||||
}
|
||||
BAlarmClass[] bAlarmClassArray = (BAlarmClass[])this.alarmService.getChildren(clazz);
|
||||
int n = 0;
|
||||
while (n < bAlarmClassArray.length) {
|
||||
bAlarmClassArray[n].setTotalAlarmCount(0);
|
||||
bAlarmClassArray[n].setUnackedAlarmCount(0);
|
||||
bAlarmClassArray[n].setOpenAlarmCount(0);
|
||||
bAlarmClassArray[n].setInAlarmCount(0);
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void clearOldRecords(BAbsTime bAbsTime, Context context) throws IOException {
|
||||
while (this.first != null) {
|
||||
if (!bAbsTime.isAfter(this.first.rec.getTimestamp())) {
|
||||
return;
|
||||
}
|
||||
AlarmEntry alarmEntry = this.first;
|
||||
this.first = this.first.next;
|
||||
alarmEntry.next = null;
|
||||
if (this.first != null) {
|
||||
this.first.prev = null;
|
||||
}
|
||||
this.byUuid.remove(alarmEntry.rec.getUuid());
|
||||
--this.recordCount;
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(alarmEntry.rec.getAlarmClass());
|
||||
if (!bAlarmClass.getName().equals(alarmEntry.rec.getAlarmClass())) continue;
|
||||
bAlarmClass.setTotalAlarmCount(bAlarmClass.getTotalAlarmCount() - 1);
|
||||
if (!alarmEntry.rec.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() - 1);
|
||||
}
|
||||
if (alarmEntry.rec.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() - 1);
|
||||
}
|
||||
if (alarmEntry.rec.isNormal()) continue;
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearRecord(BUuid bUuid, Context context) {
|
||||
if (bUuid == null || bUuid.isNull()) {
|
||||
return;
|
||||
}
|
||||
AlarmEntry alarmEntry = (AlarmEntry)this.byUuid.get(bUuid);
|
||||
if (alarmEntry != null) {
|
||||
if (alarmEntry.prev != null) {
|
||||
alarmEntry.prev.next = alarmEntry.next;
|
||||
}
|
||||
if (alarmEntry.next != null) {
|
||||
alarmEntry.next.prev = alarmEntry.prev;
|
||||
}
|
||||
alarmEntry.next = null;
|
||||
alarmEntry.prev = null;
|
||||
this.byUuid.remove(bUuid);
|
||||
--this.recordCount;
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(alarmEntry.rec.getAlarmClass());
|
||||
if (bAlarmClass.getName().equals(alarmEntry.rec.getAlarmClass())) {
|
||||
bAlarmClass.setTotalAlarmCount(bAlarmClass.getTotalAlarmCount() - 1);
|
||||
if (!alarmEntry.rec.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() - 1);
|
||||
}
|
||||
if (alarmEntry.rec.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() - 1);
|
||||
}
|
||||
if (!alarmEntry.rec.isNormal()) {
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() - 1);
|
||||
}
|
||||
}
|
||||
if (this.byUuid.size() == 0) {
|
||||
this.first = null;
|
||||
this.last = null;
|
||||
}
|
||||
alarmEntry = null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public void setCapacity(int n) throws IOException {
|
||||
if (n < 5) {
|
||||
throw new IllegalArgumentException("Attempted to set capacity < 5.");
|
||||
}
|
||||
if (this.capacity == n) {
|
||||
return;
|
||||
}
|
||||
this.capacity = n;
|
||||
if (!this.isOpen()) {
|
||||
return;
|
||||
}
|
||||
BMemoryAlarmDatabase bMemoryAlarmDatabase = this;
|
||||
synchronized (bMemoryAlarmDatabase) {
|
||||
AlarmEntry alarmEntry = this.first;
|
||||
this.first = null;
|
||||
this.last = null;
|
||||
this.recordCount = 0;
|
||||
while (alarmEntry != null) {
|
||||
this.append(alarmEntry.rec);
|
||||
alarmEntry = alarmEntry.next;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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.capacity = 1000;
|
||||
this.byUuid = new HashMap();
|
||||
this.openFilter = new OpenFilter();
|
||||
this.ackPendingFilter = new AckPendingFilter();
|
||||
}
|
||||
|
||||
public BMemoryAlarmDatabase() {
|
||||
this.this();
|
||||
this.alarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$memory$BMemoryAlarmDatabase;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$memory$BMemoryAlarmDatabase = BMemoryAlarmDatabase.class("[Lcom.tridium.alarm.db.memory.BMemoryAlarmDatabase;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class AlarmEntry {
|
||||
BAlarmRecord rec;
|
||||
AlarmEntry prev;
|
||||
AlarmEntry next;
|
||||
|
||||
public AlarmEntry(BAlarmRecord bAlarmRecord) {
|
||||
this.rec = bAlarmRecord;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class AlarmCursor
|
||||
implements Cursor {
|
||||
private BMemoryAlarmDatabase db;
|
||||
private AlarmEntry start;
|
||||
private AlarmEntry entry;
|
||||
private BAbsTime endTime;
|
||||
private Context context;
|
||||
|
||||
public Context getContext() {
|
||||
return this.context;
|
||||
}
|
||||
|
||||
public BObject get() {
|
||||
if (this.start == null) {
|
||||
return null;
|
||||
}
|
||||
if (this.entry == null) {
|
||||
throw new IllegalStateException("get() before next()");
|
||||
}
|
||||
return this.entry.rec;
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public boolean next() {
|
||||
if (this.start == null) {
|
||||
return false;
|
||||
}
|
||||
BMemoryAlarmDatabase bMemoryAlarmDatabase = this.db;
|
||||
synchronized (bMemoryAlarmDatabase) {
|
||||
this.entry = this.entry == null ? this.start : this.entry.next;
|
||||
if (this.entry == null) {
|
||||
this.start = null;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean next(Class clazz) {
|
||||
Class clazz2 = class$javax$baja$alarm$BAlarmRecord;
|
||||
if (clazz2 == null) {
|
||||
clazz2 = class$javax$baja$alarm$BAlarmRecord = BMemoryAlarmDatabase.class("[Ljavax.baja.alarm.BAlarmRecord;", false);
|
||||
}
|
||||
if (clazz2.isAssignableFrom(clazz)) {
|
||||
this.start = null;
|
||||
return false;
|
||||
}
|
||||
return this.next();
|
||||
}
|
||||
|
||||
public boolean nextComponent() {
|
||||
this.start = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public AlarmCursor(BMemoryAlarmDatabase bMemoryAlarmDatabase2, AlarmEntry alarmEntry, BAbsTime bAbsTime, Context context) {
|
||||
this.db = bMemoryAlarmDatabase2;
|
||||
this.start = alarmEntry;
|
||||
this.endTime = bAbsTime;
|
||||
this.context = context;
|
||||
this.entry = null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class SourceFilter
|
||||
implements IFilter {
|
||||
BOrdList source;
|
||||
|
||||
public boolean accept(Object object) {
|
||||
if (object == null || object instanceof BAlarmRecord) {
|
||||
return ((BAlarmRecord)((Object)object)).getSource().equals((Object)this.source);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public SourceFilter(BOrdList bOrdList) {
|
||||
this.source = bOrdList;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class OpenFilter
|
||||
implements IFilter {
|
||||
public boolean accept(Object object) {
|
||||
if (object == null || object instanceof BAlarmRecord) {
|
||||
return ((BAlarmRecord)((Object)object)).isOpen();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class AckPendingFilter
|
||||
implements IFilter {
|
||||
public boolean accept(Object object) {
|
||||
if (object == null || object instanceof BAlarmRecord) {
|
||||
return ((BAlarmRecord)((Object)object)).isAckPending();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,713 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.data.BToDataTable
|
||||
* com.tridium.data.DataTableDecoder
|
||||
* com.tridium.data.DataTableEncoder
|
||||
* com.tridium.fox.message.FoxMessage
|
||||
* com.tridium.fox.session.FoxCircuit
|
||||
* com.tridium.fox.session.FoxRequest
|
||||
* com.tridium.fox.session.FoxResponse
|
||||
* com.tridium.fox.session.InvalidCommandException
|
||||
* com.tridium.fox.sys.BFoxChannel
|
||||
* javax.baja.bql.BqlQuery
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.collection.BITable
|
||||
* javax.baja.collection.Column
|
||||
* javax.baja.collection.ColumnList
|
||||
* javax.baja.data.BIDataTable
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.security.BIProtected
|
||||
* javax.baja.security.BPermissions
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.user.BUser
|
||||
* javax.baja.util.BUuid
|
||||
* javax.baja.util.Version
|
||||
*/
|
||||
package com.tridium.alarm.fox;
|
||||
|
||||
import com.tridium.alarm.AlarmColumnSpec;
|
||||
import com.tridium.alarm.AlarmInput;
|
||||
import com.tridium.alarm.AlarmInputCursor;
|
||||
import com.tridium.alarm.AlarmOutput;
|
||||
import com.tridium.alarm.BAlarmInputTable;
|
||||
import com.tridium.alarm.db.BAlarmDbQueryResult;
|
||||
import com.tridium.alarm.fox.FoxAlarmCodec;
|
||||
import com.tridium.data.BToDataTable;
|
||||
import com.tridium.data.DataTableDecoder;
|
||||
import com.tridium.data.DataTableEncoder;
|
||||
import com.tridium.fox.message.FoxMessage;
|
||||
import com.tridium.fox.session.FoxCircuit;
|
||||
import com.tridium.fox.session.FoxRequest;
|
||||
import com.tridium.fox.session.FoxResponse;
|
||||
import com.tridium.fox.session.InvalidCommandException;
|
||||
import com.tridium.fox.sys.BFoxChannel;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutput;
|
||||
import java.io.DataOutputStream;
|
||||
import java.util.HashMap;
|
||||
import javax.baja.alarm.AlarmException;
|
||||
import javax.baja.alarm.BAlarmClass;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.bql.BqlQuery;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.collection.BITable;
|
||||
import javax.baja.collection.Column;
|
||||
import javax.baja.collection.ColumnList;
|
||||
import javax.baja.data.BIDataTable;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.security.BIProtected;
|
||||
import javax.baja.security.BPermissions;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.user.BUser;
|
||||
import javax.baja.util.BUuid;
|
||||
import javax.baja.util.Version;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BAlarmDbChannel
|
||||
extends BFoxChannel {
|
||||
public static final Type TYPE;
|
||||
private Version serverVersion;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$fox$BAlarmDbChannel;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public FoxResponse process(FoxRequest foxRequest) throws Exception {
|
||||
String string = foxRequest.command;
|
||||
if (string == "append") {
|
||||
return this.append(foxRequest);
|
||||
}
|
||||
if (string == "update") {
|
||||
return this.update(foxRequest);
|
||||
}
|
||||
if (string == "getRecordCount") {
|
||||
return this.getRecordCount(foxRequest);
|
||||
}
|
||||
if (string == "getRecord") {
|
||||
return this.getRecord(foxRequest);
|
||||
}
|
||||
if (string == "clearAll") {
|
||||
return this.clearAllRecords(foxRequest);
|
||||
}
|
||||
if (string == "clearOld") {
|
||||
return this.clearOldRecords(foxRequest);
|
||||
}
|
||||
if (string == "getVersion") {
|
||||
return this.getVersion(foxRequest);
|
||||
}
|
||||
throw new InvalidCommandException(string);
|
||||
}
|
||||
|
||||
public void circuitOpened(FoxCircuit foxCircuit) throws Exception {
|
||||
String string = foxCircuit.command;
|
||||
if (string == "resolve") {
|
||||
this.resolve(foxCircuit);
|
||||
return;
|
||||
}
|
||||
if (string == "resolve34") {
|
||||
this.resolve34(foxCircuit);
|
||||
return;
|
||||
}
|
||||
if (string == "scan") {
|
||||
this.scan(foxCircuit);
|
||||
return;
|
||||
}
|
||||
if (string == "timeQuery") {
|
||||
this.timeQuery(foxCircuit);
|
||||
return;
|
||||
}
|
||||
if (string == "bqlQuery") {
|
||||
this.bqlQuery(foxCircuit);
|
||||
return;
|
||||
}
|
||||
throw new InvalidCommandException(string);
|
||||
}
|
||||
|
||||
public Version checkVersion() {
|
||||
if (this.serverVersion == null) {
|
||||
try {
|
||||
this.serverVersion = this.getVersion();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
this.serverVersion = Version.ZERO;
|
||||
}
|
||||
}
|
||||
return this.serverVersion;
|
||||
}
|
||||
|
||||
public Version getVersion() throws Exception {
|
||||
FoxRequest foxRequest = this.makeRequest("getVersion");
|
||||
FoxResponse foxResponse = this.sendSync(foxRequest);
|
||||
return new Version(foxResponse.getString("version", ""));
|
||||
}
|
||||
|
||||
public FoxResponse getVersion(FoxRequest foxRequest) throws Exception {
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
FoxResponse foxResponse = new FoxResponse(foxRequest);
|
||||
foxResponse.add("version", TYPE.getModule().getVendorVersion().toString());
|
||||
return foxResponse;
|
||||
}
|
||||
|
||||
public void append(BAlarmRecord bAlarmRecord) throws Exception {
|
||||
FoxRequest foxRequest = this.makeRequest("append");
|
||||
foxRequest.add("rec", FoxAlarmCodec.encodeAlarm(bAlarmRecord));
|
||||
this.sendSync(foxRequest);
|
||||
}
|
||||
|
||||
private final FoxResponse append(FoxRequest foxRequest) throws Exception {
|
||||
BAlarmRecord bAlarmRecord = FoxAlarmCodec.decodeAlarm(foxRequest.getMessage("rec"));
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
BUser bUser = this.getSessionContext().getUser();
|
||||
BAlarmClass bAlarmClass = bAlarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass == null) {
|
||||
bAlarmClass = bAlarmService.getDefaultAlarmClass();
|
||||
}
|
||||
bUser.check((BIProtected)bAlarmClass, BPermissions.operatorWrite);
|
||||
bAlarmService.getAlarmDb().append(bAlarmRecord);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void update(BAlarmRecord bAlarmRecord) throws Exception {
|
||||
FoxRequest foxRequest = this.makeRequest("update");
|
||||
foxRequest.add("rec", FoxAlarmCodec.encodeAlarm(bAlarmRecord));
|
||||
this.sendSync(foxRequest);
|
||||
}
|
||||
|
||||
private final FoxResponse update(FoxRequest foxRequest) throws Exception {
|
||||
BAlarmRecord bAlarmRecord = FoxAlarmCodec.decodeAlarm(foxRequest.getMessage("rec"));
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
BUser bUser = this.getSessionContext().getUser();
|
||||
BAlarmClass bAlarmClass = bAlarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass == null) {
|
||||
bAlarmClass = bAlarmService.getDefaultAlarmClass();
|
||||
}
|
||||
bUser.check((BIProtected)bAlarmClass, BPermissions.operatorWrite);
|
||||
bAlarmService.getAlarmDb().update(bAlarmRecord);
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getRecordCount() throws Exception {
|
||||
FoxRequest foxRequest = this.makeRequest("getRecordCount");
|
||||
FoxResponse foxResponse = this.sendSync(foxRequest);
|
||||
return foxResponse.getInt("count");
|
||||
}
|
||||
|
||||
private final FoxResponse getRecordCount(FoxRequest foxRequest) throws Exception {
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
FoxResponse foxResponse = new FoxResponse(foxRequest);
|
||||
foxResponse.add("count", bAlarmService.getAlarmDb().getRecordCount());
|
||||
return foxResponse;
|
||||
}
|
||||
|
||||
public BAlarmRecord getRecord(BUuid bUuid) throws Exception {
|
||||
FoxRequest foxRequest = this.makeRequest("getRecord");
|
||||
foxRequest.add("uuid", bUuid.encodeToString());
|
||||
FoxResponse foxResponse = this.sendSync(foxRequest);
|
||||
return FoxAlarmCodec.decodeAlarm(foxResponse.getMessage("rec"));
|
||||
}
|
||||
|
||||
private final FoxResponse getRecord(FoxRequest foxRequest) throws Exception {
|
||||
BUuid bUuid = (BUuid)BUuid.DEFAULT.decodeFromString(foxRequest.getString("uuid"));
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
BAlarmRecord bAlarmRecord = bAlarmService.getAlarmDb().getRecord(bUuid);
|
||||
BUser bUser = this.getSessionContext().getUser();
|
||||
BAlarmClass bAlarmClass = bAlarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass == null) {
|
||||
bAlarmClass = bAlarmService.getDefaultAlarmClass();
|
||||
}
|
||||
bUser.check((BIProtected)bAlarmClass, BPermissions.operatorRead);
|
||||
FoxResponse foxResponse = new FoxResponse(foxRequest);
|
||||
foxResponse.add("rec", FoxAlarmCodec.encodeAlarm(bAlarmRecord));
|
||||
return foxResponse;
|
||||
}
|
||||
|
||||
public void clearAllRecords() throws Exception {
|
||||
this.sendAsync(this.makeRequest("clearAll"));
|
||||
}
|
||||
|
||||
private final FoxResponse clearAllRecords(FoxRequest foxRequest) throws Exception {
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
if (bAlarmService != null) {
|
||||
bAlarmService.getAlarmDb().clearAllRecords(this.getSessionContext());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void clearOldRecords(BAbsTime bAbsTime) throws Exception {
|
||||
FoxRequest foxRequest = this.makeRequest("clearOld");
|
||||
foxRequest.add("before", bAbsTime.getMillis());
|
||||
this.sendAsync(foxRequest);
|
||||
}
|
||||
|
||||
private final FoxResponse clearOldRecords(FoxRequest foxRequest) throws Exception {
|
||||
BAbsTime bAbsTime = BAbsTime.make((long)foxRequest.getTime("before"));
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
if (bAlarmService != null) {
|
||||
bAlarmService.getAlarmDb().clearOldRecords(bAbsTime, this.getSessionContext());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void clearRecord(BUuid bUuid) throws Exception {
|
||||
FoxRequest foxRequest = this.makeRequest("clear");
|
||||
foxRequest.add("uuid", bUuid.encodeToString());
|
||||
this.sendAsync(foxRequest);
|
||||
}
|
||||
|
||||
private final FoxResponse clearRecord(FoxRequest foxRequest) throws Exception {
|
||||
BUuid bUuid = (BUuid)BUuid.DEFAULT.decodeFromString(foxRequest.getString("uuid"));
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
if (bAlarmService != null) {
|
||||
bAlarmService.getAlarmDb().clearRecord(bUuid, this.getSessionContext());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Cursor scan() throws Exception {
|
||||
FoxCircuit foxCircuit = this.openCircuit("scan");
|
||||
AlarmInput alarmInput = new AlarmInput(new DataInputStream(foxCircuit.getInputStream()));
|
||||
return new AlarmInputCursor(alarmInput, null);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
private final void scan(FoxCircuit foxCircuit) throws Exception {
|
||||
try {
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
BAlarmDatabase bAlarmDatabase = bAlarmService.getAlarmDb();
|
||||
AlarmSecurityCursor alarmSecurityCursor = new AlarmSecurityCursor(bAlarmDatabase.scan(), bAlarmService, BPermissions.operatorRead, this.getSessionContext());
|
||||
DataOutputStream dataOutputStream = new DataOutputStream(foxCircuit.getOutputStream());
|
||||
AlarmOutput alarmOutput = new AlarmOutput(null, dataOutputStream);
|
||||
while (true) {
|
||||
block4: {
|
||||
if (alarmSecurityCursor.next()) break block4;
|
||||
alarmOutput.flush();
|
||||
alarmOutput.close();
|
||||
break;
|
||||
}
|
||||
alarmOutput.write((BAlarmRecord)alarmSecurityCursor.get());
|
||||
}
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
Object var3_8 = null;
|
||||
foxCircuit.close();
|
||||
throw throwable;
|
||||
}
|
||||
{
|
||||
Object var3_9 = null;
|
||||
}
|
||||
foxCircuit.close();
|
||||
}
|
||||
|
||||
public Cursor timeQuery(BAbsTime bAbsTime, BAbsTime bAbsTime2) throws Exception {
|
||||
FoxCircuit foxCircuit = this.openCircuit("timeQuery");
|
||||
FoxMessage foxMessage = new FoxMessage();
|
||||
if (bAbsTime != null && !bAbsTime.isNull()) {
|
||||
foxMessage.add("startTime", bAbsTime.getMillis());
|
||||
}
|
||||
if (bAbsTime2 != null && !bAbsTime2.isNull()) {
|
||||
foxMessage.add("endTime", bAbsTime2.getMillis());
|
||||
}
|
||||
foxCircuit.writeMessage(foxMessage);
|
||||
foxCircuit.flush();
|
||||
AlarmInput alarmInput = new AlarmInput(new DataInputStream(foxCircuit.getInputStream()));
|
||||
return new AlarmInputCursor(alarmInput, null);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
private final void timeQuery(FoxCircuit foxCircuit) throws Exception {
|
||||
try {
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
BAlarmDatabase bAlarmDatabase = bAlarmService.getAlarmDb();
|
||||
FoxMessage foxMessage = foxCircuit.readMessage();
|
||||
BAbsTime bAbsTime = null;
|
||||
BAbsTime bAbsTime2 = null;
|
||||
long l = foxMessage.getTime("startTime", (long)-1);
|
||||
if (l != (long)-1) {
|
||||
bAbsTime = BAbsTime.make((long)l);
|
||||
}
|
||||
if ((l = foxMessage.getTime("endTime", (long)-1)) != (long)-1) {
|
||||
bAbsTime2 = BAbsTime.make((long)l);
|
||||
}
|
||||
Cursor cursor = bAlarmDatabase.timeQuery(bAbsTime, bAbsTime2);
|
||||
cursor = new AlarmSecurityCursor(cursor, bAlarmService, BPermissions.operatorRead, this.getSessionContext());
|
||||
DataOutputStream dataOutputStream = new DataOutputStream(foxCircuit.getOutputStream());
|
||||
AlarmOutput alarmOutput = new AlarmOutput(null, dataOutputStream);
|
||||
while (true) {
|
||||
block6: {
|
||||
if (cursor.next()) break block6;
|
||||
alarmOutput.flush();
|
||||
alarmOutput.close();
|
||||
break;
|
||||
}
|
||||
alarmOutput.write((BAlarmRecord)cursor.get());
|
||||
}
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
Object var3_12 = null;
|
||||
foxCircuit.close();
|
||||
throw throwable;
|
||||
}
|
||||
{
|
||||
Object var3_13 = null;
|
||||
}
|
||||
foxCircuit.close();
|
||||
}
|
||||
|
||||
public Cursor bqlQuery(BqlQuery bqlQuery) throws Exception {
|
||||
Version version = this.getVersion();
|
||||
if (version.compareTo((Object)new Version("3.4.23")) < 0) {
|
||||
throw new AlarmException("Incompatible Version: " + version + " < 3.4.23");
|
||||
}
|
||||
FoxCircuit foxCircuit = this.openCircuit("bqlQuery");
|
||||
FoxMessage foxMessage = new FoxMessage();
|
||||
if (bqlQuery != null) {
|
||||
foxMessage.add("bql", bqlQuery.getBody());
|
||||
}
|
||||
foxCircuit.writeMessage(foxMessage);
|
||||
foxCircuit.flush();
|
||||
AlarmInput alarmInput = new AlarmInput(new DataInputStream(foxCircuit.getInputStream()));
|
||||
return new AlarmInputCursor(alarmInput, null);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
private final void bqlQuery(FoxCircuit foxCircuit) throws Exception {
|
||||
try {
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
BAlarmDatabase bAlarmDatabase = bAlarmService.getAlarmDb();
|
||||
FoxMessage foxMessage = foxCircuit.readMessage();
|
||||
BqlQuery bqlQuery = BqlQuery.make((String)foxMessage.getString("bql", ""));
|
||||
AlarmSecurityCursor alarmSecurityCursor = new AlarmSecurityCursor(((BAlarmDbQueryResult)bAlarmDatabase.bqlQuery(null, bqlQuery)).cursor(), bAlarmService, BPermissions.operatorRead, this.getSessionContext());
|
||||
DataOutputStream dataOutputStream = new DataOutputStream(foxCircuit.getOutputStream());
|
||||
AlarmOutput alarmOutput = new AlarmOutput(null, dataOutputStream);
|
||||
while (true) {
|
||||
block4: {
|
||||
if (alarmSecurityCursor.next()) break block4;
|
||||
alarmOutput.flush();
|
||||
alarmOutput.close();
|
||||
break;
|
||||
}
|
||||
alarmOutput.write((BAlarmRecord)alarmSecurityCursor.get());
|
||||
}
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
Object var3_10 = null;
|
||||
foxCircuit.close();
|
||||
throw throwable;
|
||||
}
|
||||
{
|
||||
Object var3_11 = null;
|
||||
}
|
||||
foxCircuit.close();
|
||||
}
|
||||
|
||||
public BObject resolve(BOrd bOrd) throws Exception {
|
||||
Version version = this.checkVersion();
|
||||
boolean bl = false;
|
||||
if (version.major() == 3) {
|
||||
boolean bl2 = false;
|
||||
if (version.minor() >= 4) {
|
||||
bl2 = true;
|
||||
}
|
||||
bl = bl2;
|
||||
} else {
|
||||
bl = version.major() >= 4;
|
||||
}
|
||||
if (bl) {
|
||||
bOrd = bOrd.relativizeToSession();
|
||||
FoxCircuit foxCircuit = this.openCircuit("resolve34");
|
||||
FoxMessage foxMessage = new FoxMessage();
|
||||
foxMessage.add("ord", bOrd.toString());
|
||||
foxCircuit.writeMessage(foxMessage);
|
||||
foxCircuit.flush();
|
||||
FoxMessage foxMessage2 = foxCircuit.readMessage();
|
||||
String string = foxMessage2.getString("resultType", null);
|
||||
if (string.equals("records")) {
|
||||
DataInputStream dataInputStream = new DataInputStream(foxCircuit.getInputStream());
|
||||
AlarmColumnSpec[] alarmColumnSpecArray = this.readColumns(dataInputStream);
|
||||
AlarmInput alarmInput = new AlarmInput(dataInputStream);
|
||||
return new BAlarmInputTable(alarmColumnSpecArray, alarmInput);
|
||||
}
|
||||
if (string.equals("table")) {
|
||||
BIDataTable bIDataTable = DataTableDecoder.decode((DataInput)new DataInputStream(foxCircuit.getInputStream()));
|
||||
foxCircuit.close();
|
||||
return (BObject)bIDataTable;
|
||||
}
|
||||
throw new UnsupportedOperationException("Unsupported result type: " + string);
|
||||
}
|
||||
bOrd = bOrd.relativizeToSession();
|
||||
FoxCircuit foxCircuit = this.openCircuit("resolve");
|
||||
FoxMessage foxMessage = new FoxMessage();
|
||||
foxMessage.add("ord", bOrd.toString());
|
||||
foxCircuit.writeMessage(foxMessage);
|
||||
foxCircuit.flush();
|
||||
DataInputStream dataInputStream = new DataInputStream(foxCircuit.getInputStream());
|
||||
AlarmInput alarmInput = new AlarmInput(dataInputStream);
|
||||
return new BAlarmInputTable(null, alarmInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
private final void resolve(FoxCircuit foxCircuit) throws Exception {
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
try {
|
||||
FoxMessage foxMessage = foxCircuit.readMessage();
|
||||
BOrd bOrd = BOrd.make((String)foxMessage.getString("ord"));
|
||||
BObject bObject = bOrd.resolve((BObject)this).get();
|
||||
DataOutputStream dataOutputStream = new DataOutputStream(foxCircuit.getOutputStream());
|
||||
if (!(bObject instanceof BICollection)) throw new IllegalStateException("Unsupported result type: " + bObject.getClass().getName());
|
||||
BITable bITable = ((BICollection)bObject).toTable();
|
||||
AlarmOutput alarmOutput = new AlarmOutput(bITable, dataOutputStream);
|
||||
AlarmSecurityCursor alarmSecurityCursor = new AlarmSecurityCursor(((BICollection)bObject).cursor(), bAlarmService, BPermissions.operatorRead, this.getSessionContext());
|
||||
while (true) {
|
||||
block4: {
|
||||
if (alarmSecurityCursor.next()) break block4;
|
||||
alarmOutput.flush();
|
||||
alarmOutput.close();
|
||||
break;
|
||||
}
|
||||
alarmOutput.write((BAlarmRecord)alarmSecurityCursor.get());
|
||||
}
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
Object var4_11 = null;
|
||||
foxCircuit.close();
|
||||
throw throwable;
|
||||
}
|
||||
{
|
||||
Object var4_12 = null;
|
||||
}
|
||||
foxCircuit.close();
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
|
||||
* Unable to fully structure code
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
private final void resolve34(FoxCircuit var1_1) throws Exception {
|
||||
var2_2 = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
try {
|
||||
block6: {
|
||||
var5_3 = var1_1.readMessage();
|
||||
var6_4 = new FoxMessage("resp");
|
||||
var7_5 = BOrd.make((String)var5_3.getString("ord"));
|
||||
var8_6 = var7_5.resolve((BObject)this).get();
|
||||
var6_4.add("resolved", true);
|
||||
var9_7 = new DataOutputStream(var1_1.getOutputStream());
|
||||
if (var8_6 instanceof BICollection == false) throw new IllegalStateException("Unsupported result type: " + var8_6.getClass().getName());
|
||||
var10_8 = ((BICollection)var8_6).toTable();
|
||||
var11_9 = var10_8.getColumns();
|
||||
var12_10 = true;
|
||||
var13_11 = new BAlarmRecord();
|
||||
var14_12 = 0;
|
||||
while (var14_12 < var11_9.size()) {
|
||||
var15_15 /* !! */ = var11_9.get(var14_12);
|
||||
if (var13_11.getProperty(var15_15 /* !! */ .getName()) == null) {
|
||||
var12_10 = false;
|
||||
break;
|
||||
}
|
||||
++var14_12;
|
||||
}
|
||||
if (!var12_10) break block6;
|
||||
var6_4.add("resultType", "records");
|
||||
var1_1.writeMessage(var6_4);
|
||||
var1_1.flush();
|
||||
this.writeColumns(var10_8, var9_7, this.getSessionContext());
|
||||
var14_13 = new AlarmOutput(var10_8, var9_7);
|
||||
var15_15 /* !! */ = new AlarmSecurityCursor(((BICollection)var8_6).cursor(), var2_2, BPermissions.operatorRead, this.getSessionContext());
|
||||
while (true) {
|
||||
block7: {
|
||||
if (var15_15 /* !! */ .next()) break block7;
|
||||
var14_13.flush();
|
||||
var14_13.close();
|
||||
** GOTO lbl-1000
|
||||
}
|
||||
var14_13.write((BAlarmRecord)var15_15 /* !! */ .get());
|
||||
}
|
||||
}
|
||||
var6_4.add("resultType", "table");
|
||||
var1_1.writeMessage(var6_4);
|
||||
var1_1.flush();
|
||||
var14_14 = new DataOutputStream(var1_1.getOutputStream());
|
||||
DataTableEncoder.encode((BIDataTable)BToDataTable.toDataTable((BITable)var10_8), (DataOutput)var14_14, (Context)this.getSessionContext());
|
||||
var14_14.flush();
|
||||
var14_14.close();
|
||||
}
|
||||
catch (Throwable var3_16) {
|
||||
var4_17 = null;
|
||||
var1_1.close();
|
||||
throw var3_16;
|
||||
}
|
||||
lbl-1000:
|
||||
// 2 sources
|
||||
|
||||
{
|
||||
var4_18 = null;
|
||||
}
|
||||
var1_1.close();
|
||||
}
|
||||
|
||||
private final AlarmColumnSpec[] readColumns(DataInput dataInput) throws Exception {
|
||||
int n = dataInput.readInt();
|
||||
AlarmColumnSpec[] alarmColumnSpecArray = new AlarmColumnSpec[n];
|
||||
int n2 = 0;
|
||||
while (n2 < alarmColumnSpecArray.length) {
|
||||
alarmColumnSpecArray[n2] = AlarmColumnSpec.read(dataInput);
|
||||
++n2;
|
||||
}
|
||||
return alarmColumnSpecArray;
|
||||
}
|
||||
|
||||
private final void writeColumns(BITable bITable, DataOutput dataOutput, Context context) throws Exception {
|
||||
ColumnList columnList = bITable.getColumns();
|
||||
dataOutput.writeInt(columnList.size());
|
||||
int n = 0;
|
||||
while (n < columnList.size()) {
|
||||
Column column = columnList.get(n);
|
||||
new AlarmColumnSpec(column.getName(), column.getDisplayName(context), column.getFacets()).write(dataOutput);
|
||||
++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());
|
||||
}
|
||||
}
|
||||
|
||||
public BAlarmDbChannel() {
|
||||
super("alarmdb");
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$fox$BAlarmDbChannel;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$fox$BAlarmDbChannel = BAlarmDbChannel.class("[Lcom.tridium.alarm.fox.BAlarmDbChannel;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class AlarmSecurityCursor
|
||||
implements Cursor {
|
||||
private BAlarmService service;
|
||||
private BUser user;
|
||||
private Context context;
|
||||
private BPermissions required;
|
||||
private Cursor inner;
|
||||
private BAlarmRecord rec;
|
||||
private HashMap classPermissions;
|
||||
|
||||
public Context getContext() {
|
||||
return this.context;
|
||||
}
|
||||
|
||||
public BObject get() {
|
||||
return this.rec;
|
||||
}
|
||||
|
||||
public boolean next() {
|
||||
while (this.inner.next()) {
|
||||
this.rec = (BAlarmRecord)this.inner.get();
|
||||
if (this.user != null) {
|
||||
BPermissions bPermissions = this.getClassPermissions(this.user, this.service.lookupAlarmClass(this.rec.getAlarmClass()));
|
||||
if (!bPermissions.has(this.required)) continue;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean nextComponent() {
|
||||
while (this.inner.next()) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean next(Class clazz) {
|
||||
Class clazz2 = class$javax$baja$alarm$BAlarmRecord;
|
||||
if (clazz2 == null) {
|
||||
clazz2 = class$javax$baja$alarm$BAlarmRecord = BAlarmDbChannel.class("[Ljavax.baja.alarm.BAlarmRecord;", false);
|
||||
}
|
||||
if (clazz2.isAssignableFrom(clazz)) {
|
||||
return this.next();
|
||||
}
|
||||
while (this.inner.next()) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private final BPermissions getClassPermissions(BUser bUser, BAlarmClass bAlarmClass) {
|
||||
BPermissions bPermissions = (BPermissions)this.classPermissions.get(bAlarmClass.getHandle());
|
||||
if (bPermissions == null) {
|
||||
bPermissions = BAlarmDbChannel.this.getPermissionsFor((Object)bAlarmClass);
|
||||
this.classPermissions.put(bAlarmClass.getHandle(), bPermissions);
|
||||
}
|
||||
return bPermissions;
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.classPermissions = new HashMap();
|
||||
}
|
||||
|
||||
public AlarmSecurityCursor(Cursor cursor, BAlarmService bAlarmService, BPermissions bPermissions, Context context) {
|
||||
this.this();
|
||||
this.inner = cursor;
|
||||
this.service = bAlarmService;
|
||||
this.required = bPermissions;
|
||||
this.context = context;
|
||||
this.user = context != null ? context.getUser() : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.fox.sys.BFoxChannelRegistry
|
||||
* com.tridium.fox.sys.BFoxSession
|
||||
* javax.baja.bql.BqlQuery
|
||||
* javax.baja.bql.Queryable
|
||||
* javax.baja.bql.RemoteQueryable
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.fox;
|
||||
|
||||
import com.tridium.alarm.fox.BAlarmDbChannel;
|
||||
import com.tridium.fox.sys.BFoxChannelRegistry;
|
||||
import com.tridium.fox.sys.BFoxSession;
|
||||
import java.io.IOException;
|
||||
import javax.baja.alarm.AlarmException;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.bql.BqlQuery;
|
||||
import javax.baja.bql.Queryable;
|
||||
import javax.baja.bql.RemoteQueryable;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BFoxAlarmDatabase
|
||||
extends BAlarmDatabase
|
||||
implements Queryable,
|
||||
RemoteQueryable {
|
||||
public static final Type TYPE;
|
||||
private BFoxSession session;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$fox$BFoxAlarmDatabase;
|
||||
|
||||
public BAlarmDbChannel getChannel() {
|
||||
BAlarmDbChannel bAlarmDbChannel = null;
|
||||
try {
|
||||
bAlarmDbChannel = (BAlarmDbChannel)this.session.getConnection().getChannels().get("alarmdb", BAlarmDbChannel.TYPE);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BFoxChannelRegistry.getPrototype().add("alarmdb", (BValue)new BAlarmDbChannel());
|
||||
bAlarmDbChannel = (BAlarmDbChannel)this.session.getConnection().getChannels().get("alarmdb", BAlarmDbChannel.TYPE);
|
||||
}
|
||||
return bAlarmDbChannel;
|
||||
}
|
||||
|
||||
public void append(BAlarmRecord bAlarmRecord) throws AlarmException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void update(BAlarmRecord bAlarmRecord) throws AlarmException {
|
||||
try {
|
||||
this.getChannel().update(bAlarmRecord);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (exception instanceof AlarmException) {
|
||||
throw (AlarmException)((Object)exception);
|
||||
}
|
||||
throw new AlarmException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public int getRecordCount() {
|
||||
try {
|
||||
return this.getChannel().getRecordCount();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (exception instanceof AlarmException) {
|
||||
throw (AlarmException)((Object)exception);
|
||||
}
|
||||
throw new AlarmException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public BAlarmRecord getRecord(BUuid bUuid) {
|
||||
try {
|
||||
return this.getChannel().getRecord(bUuid);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (exception instanceof AlarmException) {
|
||||
throw (AlarmException)((Object)exception);
|
||||
}
|
||||
throw new AlarmException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public Cursor scan() throws IOException, AlarmException {
|
||||
try {
|
||||
return this.getChannel().scan();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (exception instanceof AlarmException) {
|
||||
throw (AlarmException)((Object)exception);
|
||||
}
|
||||
throw new AlarmException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public Cursor timeQuery(BAbsTime bAbsTime, BAbsTime bAbsTime2) throws IOException, AlarmException {
|
||||
try {
|
||||
return this.getChannel().timeQuery(bAbsTime, bAbsTime2);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (exception instanceof AlarmException) {
|
||||
throw (AlarmException)((Object)exception);
|
||||
}
|
||||
throw new AlarmException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public Cursor doBqlQuery(BqlQuery bqlQuery) throws IOException, AlarmException {
|
||||
try {
|
||||
return this.getChannel().bqlQuery(bqlQuery);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new AlarmException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public Cursor getAlarmsForSource(BOrdList bOrdList) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Cursor getOpenAlarms() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Cursor getAckPendingAlarms() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public BObject bqlQuery(BOrd bOrd) {
|
||||
try {
|
||||
return this.getChannel().resolve(bOrd);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (exception instanceof AlarmException) {
|
||||
throw (AlarmException)((Object)exception);
|
||||
}
|
||||
throw new AlarmException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearAllRecords(Context context) throws IOException {
|
||||
try {
|
||||
this.getChannel().clearAllRecords();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (exception instanceof AlarmException) {
|
||||
throw (AlarmException)((Object)exception);
|
||||
}
|
||||
throw new AlarmException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearOldRecords(BAbsTime bAbsTime, Context context) throws IOException {
|
||||
try {
|
||||
this.getChannel().clearOldRecords(bAbsTime);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (exception instanceof AlarmException) {
|
||||
throw (AlarmException)((Object)exception);
|
||||
}
|
||||
throw new AlarmException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearRecord(BUuid bUuid, Context context) throws IOException {
|
||||
try {
|
||||
this.getChannel().clearRecord(bUuid);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (exception instanceof AlarmException) {
|
||||
throw (AlarmException)((Object)exception);
|
||||
}
|
||||
throw new AlarmException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
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 BFoxAlarmDatabase(BFoxSession bFoxSession) {
|
||||
this.session = bFoxSession;
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$fox$BFoxAlarmDatabase;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$fox$BFoxAlarmDatabase = BFoxAlarmDatabase.class("[Lcom.tridium.alarm.fox.BFoxAlarmDatabase;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.fox.sys.BFoxSession
|
||||
* javax.baja.agent.BIAgent
|
||||
* javax.baja.naming.BISession
|
||||
* javax.baja.naming.OrdTarget
|
||||
* javax.baja.naming.UnresolvedException
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BSingleton
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.fox;
|
||||
|
||||
import com.tridium.alarm.db.AlarmQuery;
|
||||
import com.tridium.alarm.db.BIAlarmResolver;
|
||||
import com.tridium.alarm.fox.BFoxAlarmDatabase;
|
||||
import com.tridium.fox.sys.BFoxSession;
|
||||
import javax.baja.agent.BIAgent;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.naming.BISession;
|
||||
import javax.baja.naming.OrdTarget;
|
||||
import javax.baja.naming.UnresolvedException;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BSingleton;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BFoxAlarmResolver
|
||||
extends BSingleton
|
||||
implements BIAlarmResolver,
|
||||
BIAgent {
|
||||
public static final BFoxAlarmResolver INSTANCE = new BFoxAlarmResolver();
|
||||
public static final Type TYPE;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$fox$BFoxAlarmResolver;
|
||||
|
||||
public OrdTarget resolve(BISession bISession, OrdTarget ordTarget, AlarmQuery alarmQuery) {
|
||||
BFoxSession bFoxSession = (BFoxSession)bISession;
|
||||
if (alarmQuery.isDbQuery()) {
|
||||
return new OrdTarget(ordTarget, (BObject)new BFoxAlarmDatabase(bFoxSession));
|
||||
}
|
||||
String string = alarmQuery.getQueryParameter("uuid", null);
|
||||
if (string != null) {
|
||||
BFoxAlarmDatabase bFoxAlarmDatabase = new BFoxAlarmDatabase(bFoxSession);
|
||||
BAlarmRecord bAlarmRecord = bFoxAlarmDatabase.getRecord(BUuid.make((String)string));
|
||||
if (bAlarmRecord == null) {
|
||||
throw new UnresolvedException(string);
|
||||
}
|
||||
return new OrdTarget(ordTarget, (BObject)bAlarmRecord);
|
||||
}
|
||||
throw new UnresolvedException("Invalid alarm query: " + alarmQuery);
|
||||
}
|
||||
|
||||
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$alarm$fox$BFoxAlarmResolver;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$fox$BFoxAlarmResolver = BFoxAlarmResolver.class("[Lcom.tridium.alarm.fox.BFoxAlarmResolver;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.fox.encoding.DecoderFactory
|
||||
* com.tridium.fox.message.FoxMessage
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.fox;
|
||||
|
||||
import com.tridium.fox.encoding.DecoderFactory;
|
||||
import com.tridium.fox.message.FoxMessage;
|
||||
import javax.baja.alarm.BAckState;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BSourceState;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
public class FoxAlarmCodec {
|
||||
public static FoxMessage encodeAlarm(BAlarmRecord bAlarmRecord) throws Exception {
|
||||
FoxMessage foxMessage = new FoxMessage();
|
||||
foxMessage.add("timestamp", bAlarmRecord.getTimestamp().getMillis());
|
||||
foxMessage.add("uuid", bAlarmRecord.getUuid().encodeToString());
|
||||
foxMessage.add("sourceState", bAlarmRecord.getSourceState().encodeToString());
|
||||
foxMessage.add("ackState", bAlarmRecord.getAckState().encodeToString());
|
||||
foxMessage.add("ackRequired", bAlarmRecord.getAckRequired());
|
||||
foxMessage.add("source", bAlarmRecord.getSource().encodeToString());
|
||||
foxMessage.add("alarmClass", bAlarmRecord.getAlarmClass());
|
||||
foxMessage.add("priority", bAlarmRecord.getPriority());
|
||||
foxMessage.add("normalTime", bAlarmRecord.getNormalTime().getMillis());
|
||||
foxMessage.add("ackTime", bAlarmRecord.getAckTime().getMillis());
|
||||
foxMessage.add("user", bAlarmRecord.getUser());
|
||||
foxMessage.add("alarmData", bAlarmRecord.getAlarmData().encodeToString());
|
||||
foxMessage.add("alarmTransition", bAlarmRecord.getAlarmTransition().encodeToString());
|
||||
foxMessage.add("lastUpdate", bAlarmRecord.getLastUpdate().getMillis());
|
||||
return foxMessage;
|
||||
}
|
||||
|
||||
public static BAlarmRecord decodeAlarm(FoxMessage foxMessage) throws Exception {
|
||||
BAlarmRecord bAlarmRecord = new BAlarmRecord();
|
||||
try {
|
||||
bAlarmRecord.setTimestamp(BAbsTime.make((long)foxMessage.getTime("timestamp")));
|
||||
bAlarmRecord.setUuid((BUuid)BUuid.DEFAULT.decodeFromString(foxMessage.getString("uuid")));
|
||||
bAlarmRecord.setSourceState((BSourceState)BSourceState.normal.decodeFromString(foxMessage.getString("sourceState")));
|
||||
bAlarmRecord.setAckState((BAckState)BAckState.acked.decodeFromString(foxMessage.getString("ackState")));
|
||||
bAlarmRecord.setAckRequired(foxMessage.getBoolean("ackRequired"));
|
||||
bAlarmRecord.setSource((BOrdList)BOrdList.DEFAULT.decodeFromString(foxMessage.getString("source")));
|
||||
bAlarmRecord.setAlarmClass(foxMessage.getString("alarmClass"));
|
||||
bAlarmRecord.setPriority(foxMessage.getInt("priority"));
|
||||
bAlarmRecord.setNormalTime(BAbsTime.make((long)foxMessage.getTime("normalTime")));
|
||||
bAlarmRecord.setAckTime(BAbsTime.make((long)foxMessage.getTime("ackTime")));
|
||||
bAlarmRecord.setUser(foxMessage.getString("user"));
|
||||
bAlarmRecord.setAlarmData((BFacets)BFacets.DEFAULT.decodeFromString(foxMessage.getString("alarmData")));
|
||||
bAlarmRecord.setAlarmTransition((BSourceState)BSourceState.normal.decodeFromString(foxMessage.getString("alarmTransition")));
|
||||
bAlarmRecord.setLastUpdate(BAbsTime.make((long)foxMessage.getTime("lastUpdate")));
|
||||
}
|
||||
catch (Exception exception) {
|
||||
bAlarmRecord.setTimestamp(BAbsTime.make((long)foxMessage.getTime("timestamp")));
|
||||
bAlarmRecord.setUuid((BUuid)DecoderFactory.decode((FoxMessage)foxMessage, (String)"uuid", null));
|
||||
bAlarmRecord.setSourceState((BSourceState)((Object)DecoderFactory.decode((FoxMessage)foxMessage, (String)"sourceState", null)));
|
||||
bAlarmRecord.setAckState((BAckState)((Object)DecoderFactory.decode((FoxMessage)foxMessage, (String)"ackState", null)));
|
||||
bAlarmRecord.setAckRequired(foxMessage.getBoolean("ackRequired"));
|
||||
bAlarmRecord.setSource((BOrdList)DecoderFactory.decode((FoxMessage)foxMessage, (String)"source", null));
|
||||
bAlarmRecord.setAlarmClass(foxMessage.getString("alarmClass"));
|
||||
bAlarmRecord.setPriority(foxMessage.getInt("priority"));
|
||||
bAlarmRecord.setNormalTime(BAbsTime.make((long)foxMessage.getTime("normalTime")));
|
||||
bAlarmRecord.setAckTime(BAbsTime.make((long)foxMessage.getTime("ackTime")));
|
||||
bAlarmRecord.setUser(foxMessage.getString("user"));
|
||||
bAlarmRecord.setAlarmData((BFacets)DecoderFactory.decode((FoxMessage)foxMessage, (String)"alarmData", null));
|
||||
bAlarmRecord.setAlarmTransition((BSourceState)((Object)DecoderFactory.decode((FoxMessage)foxMessage, (String)"alarmTransition", null)));
|
||||
bAlarmRecord.setLastUpdate(BAbsTime.make((long)foxMessage.getTime("lastUpdate")));
|
||||
}
|
||||
return bAlarmRecord;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.hx.HxOp
|
||||
* javax.baja.naming.OrdTarget
|
||||
* javax.baja.nre.util.Array
|
||||
*/
|
||||
package com.tridium.alarm.hx;
|
||||
|
||||
import javax.baja.hx.HxOp;
|
||||
import javax.baja.naming.OrdTarget;
|
||||
import javax.baja.nre.util.Array;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class AlarmConsoleOp
|
||||
extends HxOp {
|
||||
private Array args;
|
||||
|
||||
public String getCmd() {
|
||||
return this.args.size() > 0 ? (String)this.args.get(0) : "";
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.args.size() > 1 ? (String)this.args.get(1) : "";
|
||||
}
|
||||
|
||||
public String getSortCol() {
|
||||
return this.args.size() > 2 ? (String)this.args.get(2) : "";
|
||||
}
|
||||
|
||||
/*
|
||||
* Unable to fully structure code
|
||||
*/
|
||||
public void setSortCol(String var1_1) {
|
||||
block1: {
|
||||
if (this.args.size() <= 2) ** GOTO lbl7
|
||||
this.args.set(2, (Object)var1_1);
|
||||
break block1;
|
||||
lbl-1000:
|
||||
// 1 sources
|
||||
|
||||
{
|
||||
this.args.add((Object)"");
|
||||
lbl7:
|
||||
// 2 sources
|
||||
|
||||
** while (this.args.size() < 2)
|
||||
}
|
||||
lbl8:
|
||||
// 1 sources
|
||||
|
||||
this.args.add((Object)var1_1);
|
||||
}
|
||||
}
|
||||
|
||||
public String getSortOrder() {
|
||||
return this.args.size() > 3 ? (String)this.args.get(3) : "";
|
||||
}
|
||||
|
||||
/*
|
||||
* Unable to fully structure code
|
||||
*/
|
||||
public void setSortOrder(String var1_1) {
|
||||
block1: {
|
||||
if (this.args.size() <= 3) ** GOTO lbl7
|
||||
this.args.set(3, (Object)var1_1);
|
||||
break block1;
|
||||
lbl-1000:
|
||||
// 1 sources
|
||||
|
||||
{
|
||||
this.args.add((Object)"");
|
||||
lbl7:
|
||||
// 2 sources
|
||||
|
||||
** while (this.args.size() < 3)
|
||||
}
|
||||
lbl8:
|
||||
// 1 sources
|
||||
|
||||
this.args.add((Object)var1_1);
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.args = new Array();
|
||||
}
|
||||
|
||||
public AlarmConsoleOp(HxOp hxOp) {
|
||||
super(hxOp.getUniqueName(), (OrdTarget)hxOp, hxOp);
|
||||
this.this();
|
||||
}
|
||||
|
||||
public AlarmConsoleOp(HxOp hxOp, String[] stringArray) {
|
||||
super(hxOp.getUniqueName(), (OrdTarget)hxOp, hxOp);
|
||||
this.this();
|
||||
this.args = new Array((Object[])stringArray);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,419 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.log.Log
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.naming.SlotPath
|
||||
* javax.baja.nre.util.Array
|
||||
* javax.baja.security.BIProtected
|
||||
* javax.baja.security.BPermissions
|
||||
* javax.baja.security.PermissionException
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BComplex
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BRelTime
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.BasicContext
|
||||
* javax.baja.sys.Clock
|
||||
* javax.baja.sys.Clock$Ticket
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Slot
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.user.BUser
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.model;
|
||||
|
||||
import com.tridium.alarm.BConsoleRecipient;
|
||||
import com.tridium.alarm.model.BAlarmConsoleRow;
|
||||
import javax.baja.alarm.BAckState;
|
||||
import javax.baja.alarm.BAlarmClass;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecipient;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.alarm.BSourceState;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.naming.SlotPath;
|
||||
import javax.baja.nre.util.Array;
|
||||
import javax.baja.security.BIProtected;
|
||||
import javax.baja.security.BPermissions;
|
||||
import javax.baja.security.PermissionException;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BComplex;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BRelTime;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.BasicContext;
|
||||
import javax.baja.sys.Clock;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Slot;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.user.BUser;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class BAlarmConsoleModel
|
||||
extends BComponent {
|
||||
public static final Action routeAlarm = BAlarmConsoleModel.newAction((int)260, (BValue)new BAlarmRecord(), null);
|
||||
public static final Action ackAlarms = BAlarmConsoleModel.newAction((int)260, (BValue)new BComponent(), null);
|
||||
public static final Action forceClear = BAlarmConsoleModel.newAction((int)260, (BValue)new BComponent(), null);
|
||||
public static final Action refresh = BAlarmConsoleModel.newAction((int)260, null);
|
||||
public static final Action addNotes = BAlarmConsoleModel.newAction((int)260, (BValue)new BComponent(), null);
|
||||
public static final Action expire = BAlarmConsoleModel.newAction((int)260, null);
|
||||
public static final Type TYPE;
|
||||
private static final BRelTime expiryTime;
|
||||
private static final Log log;
|
||||
private volatile Context routeAlarmCx;
|
||||
private final Object alarmMon;
|
||||
private volatile boolean started;
|
||||
private volatile Clock.Ticket expireTicket;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$model$BAlarmConsoleModel;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$model$BAlarmConsoleRow;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
|
||||
public final void routeAlarm(BAlarmRecord bAlarmRecord) {
|
||||
this.invoke(routeAlarm, (BValue)bAlarmRecord, null);
|
||||
}
|
||||
|
||||
public final void ackAlarms(BComponent bComponent) {
|
||||
this.invoke(ackAlarms, (BValue)bComponent, null);
|
||||
}
|
||||
|
||||
public final void forceClear(BComponent bComponent) {
|
||||
this.invoke(forceClear, (BValue)bComponent, null);
|
||||
}
|
||||
|
||||
public final void refresh() {
|
||||
this.invoke(refresh, null, null);
|
||||
}
|
||||
|
||||
public final void addNotes(BComponent bComponent) {
|
||||
this.invoke(addNotes, (BValue)bComponent, null);
|
||||
}
|
||||
|
||||
public final void expire() {
|
||||
this.invoke(expire, null, null);
|
||||
}
|
||||
|
||||
public final Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public final void started() {
|
||||
this.linkTo(this.getConsole(), (Slot)BAlarmRecipient.routeAlarm, (Slot)routeAlarm);
|
||||
this.expireTicket = Clock.schedule((BComponent)this, (BRelTime)expiryTime, (Action)expire, null);
|
||||
}
|
||||
|
||||
public final void stopped() throws Exception {
|
||||
this.expireTicket.cancel();
|
||||
}
|
||||
|
||||
public final void subscribed() {
|
||||
this.expireTicket.cancel();
|
||||
}
|
||||
|
||||
public final void unsubscribed() {
|
||||
if (this.isRunning()) {
|
||||
this.expireTicket = Clock.schedule((BComponent)this, (BRelTime)expiryTime, (Action)expire, null);
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean isParentLegal(BComponent bComponent) {
|
||||
return bComponent instanceof BConsoleRecipient;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
public final void doRefresh(Context var1_1) {
|
||||
if (this.routeAlarmCx == null) {
|
||||
this.routeAlarmCx = new BasicContext(var1_1.getUser(), var1_1.getLanguage());
|
||||
}
|
||||
this.started = true;
|
||||
var2_2 = this.alarmMon;
|
||||
synchronized (var2_2) {
|
||||
if (BAlarmConsoleModel.log.isTraceOn()) {
|
||||
BAlarmConsoleModel.log.trace("Refreshing alarm console");
|
||||
}
|
||||
if ((v0 = BAlarmConsoleModel.class$com$tridium$alarm$model$BAlarmConsoleRow) == null) {
|
||||
v0 = BAlarmConsoleModel.class$com$tridium$alarm$model$BAlarmConsoleRow = BAlarmConsoleModel.class("[Lcom.tridium.alarm.model.BAlarmConsoleRow;", false);
|
||||
}
|
||||
var4_3 = (BAlarmConsoleRow[])this.getChildren(v0);
|
||||
var5_4 = 0;
|
||||
while (true) {
|
||||
block8: {
|
||||
if (var5_4 < var4_3.length) break block8;
|
||||
var5_5 = this.getConsole().getOpenAlarms(var1_1);
|
||||
if (true) ** GOTO lbl27
|
||||
}
|
||||
this.remove((BComplex)var4_3[var5_4]);
|
||||
++var5_4;
|
||||
}
|
||||
do {
|
||||
if ((var6_6 = (BAlarmRecord)var5_5.get()).getSourceState() == BSourceState.normal && (var6_6.isAcknowledged() || !var6_6.getAckRequired())) continue;
|
||||
this.doRouteAlarm(var6_6, var1_1);
|
||||
lbl27:
|
||||
// 3 sources
|
||||
|
||||
} while (var5_5.next());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public final void doRouteAlarm(BAlarmRecord bAlarmRecord, Context context) {
|
||||
if (!this.started) {
|
||||
return;
|
||||
}
|
||||
if (!this.getConsole().accept(bAlarmRecord)) {
|
||||
return;
|
||||
}
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
if (!this.hasPermissions(bAlarmService, bAlarmRecord, BPermissions.operatorRead, this.routeAlarmCx)) {
|
||||
return;
|
||||
}
|
||||
Object object = this.alarmMon;
|
||||
synchronized (object) {
|
||||
block11: {
|
||||
BAlarmConsoleRow bAlarmConsoleRow;
|
||||
String string;
|
||||
block10: {
|
||||
string = SlotPath.escape((String)bAlarmRecord.getSource().toString());
|
||||
bAlarmConsoleRow = (BAlarmConsoleRow)this.get(string);
|
||||
if (bAlarmConsoleRow == null) {
|
||||
bAlarmConsoleRow = new BAlarmConsoleRow(this.routeAlarmCx);
|
||||
}
|
||||
bAlarmConsoleRow.update(bAlarmRecord);
|
||||
if (!bAlarmConsoleRow.isEmpty()) break block10;
|
||||
if (bAlarmConsoleRow.getParent() != null) {
|
||||
this.remove((BComplex)bAlarmConsoleRow);
|
||||
}
|
||||
break block11;
|
||||
}
|
||||
int n = 258;
|
||||
if (!this.hasPermissions(bAlarmService, bAlarmRecord, BPermissions.operatorWrite, this.routeAlarmCx)) {
|
||||
n |= 1;
|
||||
}
|
||||
if (bAlarmConsoleRow.getParent() == null) {
|
||||
this.add(string, (BValue)bAlarmConsoleRow, n);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private final BAlarmRecord[] getAlarmRecords(BAlarmService bAlarmService, BComponent bComponent) throws Exception {
|
||||
BComponent bComponent2 = (BComponent)bComponent.get("alarmSources");
|
||||
Class clazz = class$javax$baja$alarm$BAlarmRecord;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$alarm$BAlarmRecord = BAlarmConsoleModel.class("[Ljavax.baja.alarm.BAlarmRecord;", false);
|
||||
}
|
||||
Array array = new Array(clazz);
|
||||
if (bComponent2 != null) {
|
||||
Property[] propertyArray = bComponent2.getDynamicPropertiesArray();
|
||||
int n = 0;
|
||||
while (n < propertyArray.length) {
|
||||
BValue bValue = bComponent2.get(propertyArray[n]);
|
||||
if (bValue instanceof BOrdList) {
|
||||
BOrdList bOrdList = (BOrdList)bValue;
|
||||
BOrd bOrd = BOrd.make((String)("alarm:|bql:select * from openAlarms where source = OrdList '" + SlotPath.escape((String)bOrdList.encodeToString()) + '\''));
|
||||
BICollection bICollection = (BICollection)bOrd.get();
|
||||
Cursor cursor = bICollection.cursor();
|
||||
while (cursor.next()) {
|
||||
array.add((Object)cursor.get().asValue().newCopy(true));
|
||||
}
|
||||
}
|
||||
++n;
|
||||
}
|
||||
} else {
|
||||
BComponent bComponent3 = (BComponent)bComponent.get("alarms");
|
||||
Property[] propertyArray = bComponent3.getDynamicPropertiesArray();
|
||||
int n = 0;
|
||||
while (n < propertyArray.length) {
|
||||
BAlarmRecord bAlarmRecord = bAlarmService.getAlarmDb().getRecord((BUuid)bComponent3.get(propertyArray[n]));
|
||||
if (bAlarmRecord != null) {
|
||||
array.add((Object)bAlarmRecord.newCopy(true));
|
||||
}
|
||||
++n;
|
||||
}
|
||||
}
|
||||
return (BAlarmRecord[])array.trim();
|
||||
}
|
||||
|
||||
public final void doAckAlarms(BComponent bComponent, Context context) throws Exception {
|
||||
if (log.isTraceOn()) {
|
||||
log.trace("Acknowledging alarms");
|
||||
}
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
BAlarmDatabase bAlarmDatabase = bAlarmService.getAlarmDb();
|
||||
BAlarmRecord[] bAlarmRecordArray = this.getAlarmRecords(bAlarmService, bComponent);
|
||||
int n = 0;
|
||||
while (n < bAlarmRecordArray.length) {
|
||||
if (this.hasPermissions(bAlarmService, bAlarmRecordArray[n], BPermissions.operatorWrite, context)) {
|
||||
boolean bl = false;
|
||||
if (bAlarmRecordArray[n].getAckState() != BAckState.ackPending) {
|
||||
bl = true;
|
||||
}
|
||||
boolean bl2 = bl;
|
||||
bAlarmRecordArray[n].setUser(context.getUser().getUsername());
|
||||
bAlarmRecordArray[n].setAckTime(BAbsTime.now());
|
||||
bAlarmRecordArray[n].setAckState(BAckState.ackPending);
|
||||
if (bl2) {
|
||||
bAlarmDatabase.update(bAlarmRecordArray[n]);
|
||||
}
|
||||
bAlarmService.ackAlarm(bAlarmRecordArray[n]);
|
||||
}
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
public final void doAddNotes(BComponent bComponent, Context context) throws Exception {
|
||||
if (log.isTraceOn()) {
|
||||
log.trace("Add Notes to alarms");
|
||||
}
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("##");
|
||||
stringBuffer.append(BAbsTime.now().toString());
|
||||
stringBuffer.append(" - ");
|
||||
stringBuffer.append(context.getUser().getName());
|
||||
stringBuffer.append(" ##\n");
|
||||
stringBuffer.append(((BString)bComponent.get("notes")).toString());
|
||||
BAlarmRecord[] bAlarmRecordArray = this.getAlarmRecords(bAlarmService, bComponent);
|
||||
int n = 0;
|
||||
while (n < bAlarmRecordArray.length) {
|
||||
if (this.hasPermissions(bAlarmService, bAlarmRecordArray[n], BPermissions.operatorWrite, context)) {
|
||||
String string = bAlarmRecordArray[n].getAlarmData().gets("notes", "");
|
||||
bAlarmRecordArray[n].setAlarmData(BFacets.make((BFacets)bAlarmRecordArray[n].getAlarmData(), (String)"notes", (BIDataValue)BString.make((String)(stringBuffer + string))));
|
||||
bAlarmRecordArray[n].setLastUpdate(BAbsTime.now());
|
||||
bAlarmService.routeAlarm(bAlarmRecordArray[n]);
|
||||
bAlarmService.doRouteToSource(bAlarmRecordArray[n]);
|
||||
}
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
public final void doExpire(Context context) {
|
||||
if (log.isTraceOn()) {
|
||||
log.trace("Expiring Alarm Console Model: " + this.toPathString());
|
||||
}
|
||||
this.getConsole().remove((BComplex)this);
|
||||
}
|
||||
|
||||
public final void doForceClear(BComponent bComponent, Context context) throws Exception {
|
||||
if (log.isTraceOn()) {
|
||||
log.trace("Alarm force clear");
|
||||
}
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
BAlarmDatabase bAlarmDatabase = bAlarmService.getAlarmDb();
|
||||
BUser bUser = context.getUser();
|
||||
BPermissions bPermissions = bUser.getPermissionsFor((BIProtected)this.getConsole());
|
||||
if (!bPermissions.has(BPermissions.adminWrite) && !bPermissions.has(BPermissions.adminInvoke)) {
|
||||
throw new PermissionException(bPermissions + " < " + BPermissions.adminWrite);
|
||||
}
|
||||
BAlarmRecord[] bAlarmRecordArray = this.getAlarmRecords(bAlarmService, bComponent);
|
||||
int n = 0;
|
||||
while (n < bAlarmRecordArray.length) {
|
||||
BAlarmRecord bAlarmRecord = bAlarmRecordArray[n];
|
||||
BAlarmClass bAlarmClass = bAlarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass == null) {
|
||||
bAlarmClass = bAlarmService.getDefaultAlarmClass();
|
||||
}
|
||||
if (bUser.getPermissionsFor((BIProtected)bAlarmClass).has(BPermissions.adminWrite)) {
|
||||
bAlarmRecord.addAlarmFacet("forceCleared", (BIDataValue)BString.make((String)bUser.getUsername()));
|
||||
if (bAlarmRecord.getAckTime().equals((Object)BAbsTime.NULL)) {
|
||||
bAlarmRecord.setAckTime(BAbsTime.now());
|
||||
}
|
||||
if (bAlarmRecord.getNormalTime().equals((Object)BAbsTime.NULL)) {
|
||||
bAlarmRecord.setNormalTime(BAbsTime.now());
|
||||
}
|
||||
if (!bAlarmRecord.getAckState().equals((Object)BAckState.acked)) {
|
||||
bAlarmRecord.setUser(bUser.getUsername());
|
||||
}
|
||||
bAlarmRecord.setSourceState(BSourceState.normal);
|
||||
bAlarmRecord.setAckState(BAckState.acked);
|
||||
bAlarmDatabase.update(bAlarmRecord);
|
||||
bAlarmService.invoke(BAlarmService.auditForceClear, (BValue)bAlarmRecord, context);
|
||||
}
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
private final boolean hasPermissions(BAlarmService bAlarmService, BAlarmRecord bAlarmRecord, BPermissions bPermissions, Context context) {
|
||||
BAlarmClass bAlarmClass = bAlarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass == null) {
|
||||
bAlarmClass = bAlarmService.getDefaultAlarmClass();
|
||||
}
|
||||
return context.getUser().getPermissionsFor((BIProtected)bAlarmClass).has(bPermissions);
|
||||
}
|
||||
|
||||
private final BConsoleRecipient getConsole() {
|
||||
return (BConsoleRecipient)this.getParent();
|
||||
}
|
||||
|
||||
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.alarmMon = new Object();
|
||||
this.started = false;
|
||||
this.expireTicket = Clock.expiredTicket;
|
||||
}
|
||||
|
||||
public BAlarmConsoleModel() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$model$BAlarmConsoleModel;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$model$BAlarmConsoleModel = BAlarmConsoleModel.class("[Lcom.tridium.alarm.model.BAlarmConsoleModel;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
expiryTime = BRelTime.makeSeconds((int)60);
|
||||
log = Log.getLog((String)"alarm.alarmConsoleModel");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BStruct
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
*/
|
||||
package com.tridium.alarm.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import javax.baja.alarm.BAckState;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BSourceState;
|
||||
import javax.baja.sys.BStruct;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class BAlarmConsoleRow
|
||||
extends BStruct {
|
||||
public static final Property alarm = BAlarmConsoleRow.newProperty((int)257, (BValue)new BAlarmRecord(), null);
|
||||
public static final Property ackState = BAlarmConsoleRow.newProperty((int)257, (String)"", null);
|
||||
public static final Type TYPE;
|
||||
private Map openAlarms;
|
||||
private Context cx;
|
||||
private int ackedCount;
|
||||
private int ackPendingCount;
|
||||
private int unackedCount;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$model$BAlarmConsoleRow;
|
||||
|
||||
public final BAlarmRecord getAlarm() {
|
||||
return (BAlarmRecord)this.get(alarm);
|
||||
}
|
||||
|
||||
public final void setAlarm(BAlarmRecord bAlarmRecord) {
|
||||
this.set(alarm, (BValue)bAlarmRecord, null);
|
||||
}
|
||||
|
||||
public final String getAckState() {
|
||||
return this.getString(ackState);
|
||||
}
|
||||
|
||||
public final void setAckState(String string) {
|
||||
this.setString(ackState, string, null);
|
||||
}
|
||||
|
||||
public final Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public final String toString(Context context) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(this.getAlarm().getTimestamp().toString());
|
||||
stringBuffer.append(" ");
|
||||
stringBuffer.append(this.getAckStateStr());
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
final void update(BAlarmRecord bAlarmRecord) {
|
||||
BAlarmRecord bAlarmRecord2 = (BAlarmRecord)((Object)this.openAlarms.get(bAlarmRecord.getUuid()));
|
||||
bAlarmRecord = (BAlarmRecord)bAlarmRecord.newCopy(true);
|
||||
this.openAlarms.put(bAlarmRecord.getUuid(), bAlarmRecord);
|
||||
if (bAlarmRecord2 != null) {
|
||||
if (!bAlarmRecord2.isAcknowledged() && !bAlarmRecord2.isAckPending() && bAlarmRecord.isAckPending()) {
|
||||
++this.ackPendingCount;
|
||||
--this.unackedCount;
|
||||
} else if (bAlarmRecord2.isAckPending() && bAlarmRecord.isAcknowledged()) {
|
||||
--this.ackPendingCount;
|
||||
++this.ackedCount;
|
||||
} else if (bAlarmRecord2.isAckPending() && !bAlarmRecord.isAcknowledged() && !bAlarmRecord.isAckPending()) {
|
||||
--this.ackPendingCount;
|
||||
++this.unackedCount;
|
||||
} else if (bAlarmRecord2.isAcknowledged() && !bAlarmRecord.isAcknowledged() && !bAlarmRecord.isAckPending()) {
|
||||
--this.ackedCount;
|
||||
++this.unackedCount;
|
||||
} else if (bAlarmRecord2.isAcknowledged() && bAlarmRecord.isAckPending()) {
|
||||
--this.ackedCount;
|
||||
++this.ackPendingCount;
|
||||
} else if (bAlarmRecord.isAcknowledged() && !bAlarmRecord2.isAcknowledged() && !bAlarmRecord2.isAckPending()) {
|
||||
++this.ackedCount;
|
||||
--this.unackedCount;
|
||||
}
|
||||
} else if (bAlarmRecord.isAcknowledged()) {
|
||||
++this.ackedCount;
|
||||
} else if (bAlarmRecord.isAckPending()) {
|
||||
++this.ackPendingCount;
|
||||
} else {
|
||||
++this.unackedCount;
|
||||
}
|
||||
if (!(bAlarmRecord.getSourceState() != BSourceState.normal && bAlarmRecord.getSourceState() != BSourceState.alert || !bAlarmRecord.isAcknowledged() && bAlarmRecord.getAckRequired())) {
|
||||
if (this.openAlarms.get(bAlarmRecord.getUuid()) == null) {
|
||||
return;
|
||||
}
|
||||
this.openAlarms.remove(bAlarmRecord.getUuid());
|
||||
if (bAlarmRecord.isAcknowledged()) {
|
||||
--this.ackedCount;
|
||||
} else if (bAlarmRecord.getAckState() == BAckState.ackPending) {
|
||||
--this.ackPendingCount;
|
||||
} else {
|
||||
--this.unackedCount;
|
||||
}
|
||||
}
|
||||
this.updateAlarmInfo();
|
||||
}
|
||||
|
||||
final boolean isEmpty() {
|
||||
boolean bl = false;
|
||||
if (this.openAlarms.size() == 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
private final void updateAlarmInfo() {
|
||||
BAlarmRecord bAlarmRecord = null;
|
||||
BAlarmRecord bAlarmRecord2 = null;
|
||||
Iterator iterator = this.openAlarms.keySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
bAlarmRecord2 = (BAlarmRecord)((Object)this.openAlarms.get(iterator.next()));
|
||||
if (bAlarmRecord == null) {
|
||||
bAlarmRecord = bAlarmRecord2;
|
||||
continue;
|
||||
}
|
||||
if (!bAlarmRecord2.getTimestamp().isAfter(bAlarmRecord.getTimestamp())) continue;
|
||||
bAlarmRecord = bAlarmRecord2;
|
||||
}
|
||||
if (bAlarmRecord != null) {
|
||||
this.setAlarm(bAlarmRecord);
|
||||
}
|
||||
this.setAckState(this.getAckStateStr());
|
||||
}
|
||||
|
||||
private final String getAckStateStr() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(this.ackedCount).append(" ").append(BAckState.acked.getDisplayTag(this.cx)).append(" / ");
|
||||
stringBuffer.append(this.unackedCount).append(" ").append(BAckState.unacked.getDisplayTag(this.cx));
|
||||
if (this.ackPendingCount > 0) {
|
||||
stringBuffer.append(" / ").append(this.ackPendingCount).append(" ").append(BAckState.ackPending.getDisplayTag(this.cx));
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
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.openAlarms = new HashMap();
|
||||
this.ackedCount = 0;
|
||||
this.ackPendingCount = 0;
|
||||
this.unackedCount = 0;
|
||||
}
|
||||
|
||||
public BAlarmConsoleRow() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
public BAlarmConsoleRow(Context context) {
|
||||
this.this();
|
||||
this.cx = context;
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$model$BAlarmConsoleRow;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$model$BAlarmConsoleRow = BAlarmConsoleRow.class("[Lcom.tridium.alarm.model.BAlarmConsoleRow;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,293 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.log.Log
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.naming.SlotPath
|
||||
* javax.baja.nre.util.TextUtil
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BBoolean
|
||||
* javax.baja.sys.BDynamicEnum
|
||||
* javax.baja.sys.BEnum
|
||||
* javax.baja.sys.BEnumRange
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BIcon
|
||||
* javax.baja.sys.BInteger
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.BajaRuntimeException
|
||||
* javax.baja.sys.InvalidEnumException
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Topic
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BFormat
|
||||
* javax.baja.util.Queue
|
||||
* javax.baja.util.Worker
|
||||
* javax.baja.util.Worker$ITodo
|
||||
*/
|
||||
package com.tridium.alarm.print;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import javax.baja.alarm.AlarmSupport;
|
||||
import javax.baja.alarm.BAlarmRecipient;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmSourceInfo;
|
||||
import javax.baja.alarm.BIAlarmSource;
|
||||
import javax.baja.alarm.BSourceState;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.naming.SlotPath;
|
||||
import javax.baja.nre.util.TextUtil;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BDynamicEnum;
|
||||
import javax.baja.sys.BEnum;
|
||||
import javax.baja.sys.BEnumRange;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BIcon;
|
||||
import javax.baja.sys.BInteger;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.BajaRuntimeException;
|
||||
import javax.baja.sys.InvalidEnumException;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Topic;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BFormat;
|
||||
import javax.baja.util.Queue;
|
||||
import javax.baja.util.Worker;
|
||||
import javax.print.DocFlavor;
|
||||
import javax.print.DocPrintJob;
|
||||
import javax.print.PrintService;
|
||||
import javax.print.PrintServiceLookup;
|
||||
import javax.print.SimpleDoc;
|
||||
import javax.print.attribute.HashAttributeSet;
|
||||
import javax.print.attribute.standard.PrinterName;
|
||||
|
||||
public class BLinePrinterRecipient
|
||||
extends BAlarmRecipient
|
||||
implements BIAlarmSource {
|
||||
public static final Property printer = BLinePrinterRecipient.newProperty((int)0, (BValue)BDynamicEnum.DEFAULT, (BFacets)BFacets.make((String)"fieldEditor", (BIDataValue)BString.make((String)"alarm:LinePrinterFE")));
|
||||
public static final Property language = BLinePrinterRecipient.newProperty((int)0, (String)"", (BFacets)BFacets.make((String)"fieldWidth", (BIDataValue)BInteger.make((int)6)));
|
||||
public static final Property printFormat = BLinePrinterRecipient.newProperty((int)0, (BValue)BLinePrinterRecipient.makeDefaultPrintFormat(), (BFacets)BFacets.make((String)"multiLine", (BIDataValue)BBoolean.make((boolean)true)));
|
||||
public static final Property alertOnFailure = BLinePrinterRecipient.newProperty((int)0, (boolean)false, null);
|
||||
public static final Property alarmSourceInfo = BLinePrinterRecipient.newProperty((int)0, (BValue)new BAlarmSourceInfo(), null);
|
||||
public static final Action ackAlarm = BLinePrinterRecipient.newAction((int)4, (BValue)new BAlarmRecord(), null);
|
||||
public static final Action loadPrinters = BLinePrinterRecipient.newAction((int)0, null);
|
||||
public static final Topic printersLoaded = BLinePrinterRecipient.newTopic((int)0, null);
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$print$BLinePrinterRecipient == null ? (class$com$tridium$alarm$print$BLinePrinterRecipient = BLinePrinterRecipient.class$("com.tridium.alarm.print.BLinePrinterRecipient")) : class$com$tridium$alarm$print$BLinePrinterRecipient));
|
||||
private AlarmSupport support;
|
||||
private Queue printQueue = new Queue();
|
||||
private Worker printThread = new Worker((Worker.ITodo)this.printQueue);
|
||||
private static final BIcon icon = BIcon.make((BIcon)BIcon.std((String)"print.png"), (BIcon)BIcon.std((String)"badges/alarm.png"));
|
||||
private static final Log log = Log.getLog((String)"alarm.printer");
|
||||
static /* synthetic */ Class class$com$tridium$alarm$print$BLinePrinterRecipient;
|
||||
|
||||
public BDynamicEnum getPrinter() {
|
||||
return (BDynamicEnum)this.get(printer);
|
||||
}
|
||||
|
||||
public void setPrinter(BDynamicEnum bDynamicEnum) {
|
||||
this.set(printer, (BValue)bDynamicEnum, null);
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return this.getString(language);
|
||||
}
|
||||
|
||||
public void setLanguage(String string) {
|
||||
this.setString(language, string, null);
|
||||
}
|
||||
|
||||
public BFormat getPrintFormat() {
|
||||
return (BFormat)this.get(printFormat);
|
||||
}
|
||||
|
||||
public void setPrintFormat(BFormat bFormat) {
|
||||
this.set(printFormat, (BValue)bFormat, null);
|
||||
}
|
||||
|
||||
public boolean getAlertOnFailure() {
|
||||
return this.getBoolean(alertOnFailure);
|
||||
}
|
||||
|
||||
public void setAlertOnFailure(boolean bl) {
|
||||
this.setBoolean(alertOnFailure, bl, null);
|
||||
}
|
||||
|
||||
public BAlarmSourceInfo getAlarmSourceInfo() {
|
||||
return (BAlarmSourceInfo)this.get(alarmSourceInfo);
|
||||
}
|
||||
|
||||
public void setAlarmSourceInfo(BAlarmSourceInfo bAlarmSourceInfo) {
|
||||
this.set(alarmSourceInfo, (BValue)bAlarmSourceInfo, null);
|
||||
}
|
||||
|
||||
public BBoolean ackAlarm(BAlarmRecord bAlarmRecord) {
|
||||
return (BBoolean)this.invoke(ackAlarm, (BValue)bAlarmRecord, null);
|
||||
}
|
||||
|
||||
public void loadPrinters() {
|
||||
this.invoke(loadPrinters, null, null);
|
||||
}
|
||||
|
||||
public void firePrintersLoaded(BValue bValue) {
|
||||
this.fire(printersLoaded, bValue, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public void started() throws Exception {
|
||||
this.support = new AlarmSupport((BIAlarmSource)this, this.getAlarmSourceInfo());
|
||||
this.printThread.start("alarm:printing");
|
||||
}
|
||||
|
||||
public void stopped() throws Exception {
|
||||
this.printThread.stop();
|
||||
}
|
||||
|
||||
public static BFormat makeDefaultPrintFormat() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("Source: %alarmData.sourceName%\n");
|
||||
stringBuffer.append("Timestamp: %timestamp%\n");
|
||||
stringBuffer.append("State: %sourceState% / %ackState%\n");
|
||||
stringBuffer.append("Priority: %priority%\n");
|
||||
stringBuffer.append("Alarm Class: %alarmClass%\n");
|
||||
stringBuffer.append("Text: %alarmData.msgText%\n");
|
||||
stringBuffer.append("\n");
|
||||
return BFormat.make((String)stringBuffer.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public void doLoadPrinters() {
|
||||
PrintService[] printServiceArray = PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.AUTOSENSE, null);
|
||||
String[] stringArray = new String[printServiceArray.length];
|
||||
for (int i = 0; i < printServiceArray.length; ++i) {
|
||||
stringArray[i] = SlotPath.escape((String)printServiceArray[i].getName());
|
||||
}
|
||||
BEnumRange bEnumRange = BEnumRange.make((String[])stringArray);
|
||||
try {
|
||||
BDynamicEnum bDynamicEnum;
|
||||
BDynamicEnum bDynamicEnum2 = this.getPrinter();
|
||||
if (bDynamicEnum2.equals((Object)BDynamicEnum.DEFAULT)) {
|
||||
bDynamicEnum = BDynamicEnum.make((int)0, (BEnumRange)bEnumRange);
|
||||
} else {
|
||||
BEnum bEnum = bEnumRange.get(bDynamicEnum2.getTag());
|
||||
bDynamicEnum = BDynamicEnum.make((int)bEnum.getOrdinal(), (BEnumRange)bEnumRange);
|
||||
}
|
||||
this.setPrinter(bDynamicEnum);
|
||||
}
|
||||
catch (InvalidEnumException invalidEnumException) {
|
||||
}
|
||||
finally {
|
||||
this.firePrintersLoaded(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleAlarm(BAlarmRecord bAlarmRecord) {
|
||||
if (bAlarmRecord.getSource().equals((Object)BOrdList.make((BOrd)this.getNavOrd()))) {
|
||||
return;
|
||||
}
|
||||
if (log.isTraceOn()) {
|
||||
log.trace("Enqueue");
|
||||
}
|
||||
String string = BFormat.make((String)this.getPrintFormat().format((Object)bAlarmRecord)).format((Object)bAlarmRecord);
|
||||
this.printQueue.enqueue((Object)new PrintJob(string));
|
||||
}
|
||||
|
||||
public BBoolean doAckAlarm(BAlarmRecord bAlarmRecord) {
|
||||
try {
|
||||
return BBoolean.make((boolean)this.support.ackAlarm(bAlarmRecord));
|
||||
}
|
||||
catch (Exception exception) {
|
||||
return BBoolean.FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
public BIcon getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private class PrintJob
|
||||
implements Runnable {
|
||||
String text;
|
||||
|
||||
public PrintJob(String string) {
|
||||
this.text = string;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if (log.isTraceOn()) {
|
||||
log.trace("Dequeueing print job for " + SlotPath.unescape((String)BLinePrinterRecipient.this.getPrinter().getTag()));
|
||||
}
|
||||
try {
|
||||
HashAttributeSet hashAttributeSet = new HashAttributeSet();
|
||||
hashAttributeSet.add(new PrinterName(SlotPath.unescape((String)BLinePrinterRecipient.this.getPrinter().getTag()), null));
|
||||
PrintService[] printServiceArray = PrintServiceLookup.lookupPrintServices(null, hashAttributeSet);
|
||||
if (printServiceArray.length < 1) {
|
||||
throw new BajaRuntimeException("Printer '" + SlotPath.unescape((String)BLinePrinterRecipient.this.getPrinter().getTag()) + "' not found.");
|
||||
}
|
||||
DocPrintJob docPrintJob = printServiceArray[0].createPrintJob();
|
||||
String[] stringArray = TextUtil.replace((String)this.text, (String)"\n", (String)"\n\r").split("\n\r");
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
for (int i = 0; i < stringArray.length; ++i) {
|
||||
int n;
|
||||
if (stringArray[i].length() < 80) {
|
||||
stringBuffer.append(stringArray[i]);
|
||||
stringBuffer.append("\n\r");
|
||||
continue;
|
||||
}
|
||||
for (int j = 0; j < stringArray[i].length(); j += n) {
|
||||
n = Math.min(80, stringArray[i].length() - j);
|
||||
int n2 = n;
|
||||
if (j + n2 < stringArray[i].length()) {
|
||||
while (stringArray[i].charAt(j + n2 - 1) != ' ' && n2 > 1) {
|
||||
--n2;
|
||||
}
|
||||
if (n2 > 1) {
|
||||
n = n2;
|
||||
}
|
||||
}
|
||||
stringBuffer.append(stringArray[i].substring(j, j + n));
|
||||
stringBuffer.append("\n\r");
|
||||
}
|
||||
}
|
||||
docPrintJob.print(new SimpleDoc(new ByteArrayInputStream(stringBuffer.toString().getBytes()), DocFlavor.INPUT_STREAM.AUTOSENSE, null), null);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BFacets bFacets = BLinePrinterRecipient.this.getAlarmSourceInfo().makeAlarmData(BSourceState.offnormal);
|
||||
bFacets = BFacets.make((BFacets)bFacets, (String)"msgText", (BIDataValue)BString.make((String)(SlotPath.unescape((String)BLinePrinterRecipient.this.getPrinter().getTag()) + " print error.")));
|
||||
try {
|
||||
if (BLinePrinterRecipient.this.getAlertOnFailure()) {
|
||||
BLinePrinterRecipient.this.support.newAlert(bFacets);
|
||||
}
|
||||
}
|
||||
catch (Exception exception2) {
|
||||
// empty catch block
|
||||
}
|
||||
log.error("Print error", (Throwable)exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,338 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.gx.BFont
|
||||
* javax.baja.log.Log
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BBoolean
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BIcon
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.BVector
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BFormat
|
||||
* javax.baja.util.Queue
|
||||
* javax.baja.util.Worker
|
||||
* javax.baja.util.Worker$ITodo
|
||||
*/
|
||||
package com.tridium.alarm.print;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.font.TextAttribute;
|
||||
import java.awt.print.PageFormat;
|
||||
import java.awt.print.Printable;
|
||||
import java.awt.print.PrinterException;
|
||||
import java.text.AttributedCharacterIterator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import javax.baja.alarm.AlarmSupport;
|
||||
import javax.baja.alarm.BAlarmRecipient;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmSourceInfo;
|
||||
import javax.baja.alarm.BIAlarmSource;
|
||||
import javax.baja.alarm.BSourceState;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.gx.BFont;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BIcon;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.BVector;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BFormat;
|
||||
import javax.baja.util.Queue;
|
||||
import javax.baja.util.Worker;
|
||||
import javax.print.DocFlavor;
|
||||
import javax.print.DocPrintJob;
|
||||
import javax.print.PrintException;
|
||||
import javax.print.PrintService;
|
||||
import javax.print.PrintServiceLookup;
|
||||
import javax.print.SimpleDoc;
|
||||
import javax.print.attribute.HashAttributeSet;
|
||||
import javax.print.attribute.standard.PrinterName;
|
||||
|
||||
public class BPrinterRecipient
|
||||
extends BAlarmRecipient
|
||||
implements BIAlarmSource {
|
||||
public static final Property printer = BPrinterRecipient.newProperty((int)0, (String)"<Enter Printer Name>", (BFacets)BFacets.make((String)"fieldEditor", (BIDataValue)BString.make((String)"alarm:PrinterFE")));
|
||||
public static final Property font = BPrinterRecipient.newProperty((int)0, (BValue)BFont.make((String)"12pt Monospaced"), null);
|
||||
public static final Property printFormat = BPrinterRecipient.newProperty((int)0, (BValue)BPrinterRecipient.makeDefaultPrintFormat(), (BFacets)BFacets.make((String)"multiLine", (BIDataValue)BBoolean.make((boolean)true)));
|
||||
public static final Property alertOnFailure = BPrinterRecipient.newProperty((int)0, (boolean)false, null);
|
||||
public static final Property alarmSourceInfo = BPrinterRecipient.newProperty((int)0, (BValue)BPrinterRecipient.makeDefaultAlarmSourceInfo(), null);
|
||||
public static final Action getPrinters = BPrinterRecipient.newAction((int)0, null);
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$print$BPrinterRecipient == null ? (class$com$tridium$alarm$print$BPrinterRecipient = BPrinterRecipient.class$("com.tridium.alarm.print.BPrinterRecipient")) : class$com$tridium$alarm$print$BPrinterRecipient));
|
||||
private static final Log log = Log.getLog((String)"alarm.printer");
|
||||
private AlarmSupport support;
|
||||
private Queue printQueue = new Queue();
|
||||
private Worker printThread = new Worker((Worker.ITodo)this.printQueue);
|
||||
private static final BIcon icon = BIcon.make((BIcon)BIcon.std((String)"print.png"), (BIcon)BIcon.std((String)"badges/alarm.png"));
|
||||
static /* synthetic */ Class class$com$tridium$alarm$print$BPrinterRecipient;
|
||||
|
||||
public String getPrinter() {
|
||||
return this.getString(printer);
|
||||
}
|
||||
|
||||
public void setPrinter(String string) {
|
||||
this.setString(printer, string, null);
|
||||
}
|
||||
|
||||
public BFont getFont() {
|
||||
return (BFont)this.get(font);
|
||||
}
|
||||
|
||||
public void setFont(BFont bFont) {
|
||||
this.set(font, (BValue)bFont, null);
|
||||
}
|
||||
|
||||
public BFormat getPrintFormat() {
|
||||
return (BFormat)this.get(printFormat);
|
||||
}
|
||||
|
||||
public void setPrintFormat(BFormat bFormat) {
|
||||
this.set(printFormat, (BValue)bFormat, null);
|
||||
}
|
||||
|
||||
public boolean getAlertOnFailure() {
|
||||
return this.getBoolean(alertOnFailure);
|
||||
}
|
||||
|
||||
public void setAlertOnFailure(boolean bl) {
|
||||
this.setBoolean(alertOnFailure, bl, null);
|
||||
}
|
||||
|
||||
public BAlarmSourceInfo getAlarmSourceInfo() {
|
||||
return (BAlarmSourceInfo)this.get(alarmSourceInfo);
|
||||
}
|
||||
|
||||
public void setAlarmSourceInfo(BAlarmSourceInfo bAlarmSourceInfo) {
|
||||
this.set(alarmSourceInfo, (BValue)bAlarmSourceInfo, null);
|
||||
}
|
||||
|
||||
public BVector getPrinters() {
|
||||
return (BVector)this.invoke(getPrinters, null, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public void started() throws Exception {
|
||||
this.support = new AlarmSupport((BIAlarmSource)this, this.getAlarmSourceInfo());
|
||||
this.printThread.start("alarm:printing");
|
||||
}
|
||||
|
||||
public void stopped() throws Exception {
|
||||
this.printThread.stop();
|
||||
}
|
||||
|
||||
public static BFormat makeDefaultPrintFormat() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("Source: %alarmData.sourceName%\n");
|
||||
stringBuffer.append("Timestamp: %timestamp%\n");
|
||||
stringBuffer.append("State: %sourceState% / %ackState%\n");
|
||||
stringBuffer.append("Priority: %priority%\n");
|
||||
stringBuffer.append("Alarm Class: %alarmClass%\n");
|
||||
stringBuffer.append("Text: %alarmData.msgText%\n");
|
||||
stringBuffer.append("\n");
|
||||
return BFormat.make((String)stringBuffer.toString());
|
||||
}
|
||||
|
||||
public static BAlarmSourceInfo makeDefaultAlarmSourceInfo() {
|
||||
BAlarmSourceInfo bAlarmSourceInfo = new BAlarmSourceInfo();
|
||||
bAlarmSourceInfo.setAlarmIcon(BOrd.make((String)"module://icons/x16/print.png"));
|
||||
return bAlarmSourceInfo;
|
||||
}
|
||||
|
||||
public BVector doGetPrinters() {
|
||||
PrintService[] printServiceArray = PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.AUTOSENSE, null);
|
||||
BVector bVector = new BVector();
|
||||
for (int i = 0; i < printServiceArray.length; ++i) {
|
||||
bVector.add(null, (BValue)BString.make((String)printServiceArray[i].getName()));
|
||||
}
|
||||
return bVector;
|
||||
}
|
||||
|
||||
public void handleAlarm(BAlarmRecord bAlarmRecord) {
|
||||
if (bAlarmRecord.getSource().equals((Object)BOrdList.make((BOrd)this.getNavOrd()))) {
|
||||
return;
|
||||
}
|
||||
this.printQueue.enqueue((Object)new PrintJob(BFormat.make((String)this.getPrintFormat().format((Object)bAlarmRecord)).format((Object)bAlarmRecord)));
|
||||
}
|
||||
|
||||
public BBoolean ackAlarm(BAlarmRecord bAlarmRecord) {
|
||||
try {
|
||||
return BBoolean.make((boolean)this.support.ackAlarm(bAlarmRecord));
|
||||
}
|
||||
catch (Exception exception) {
|
||||
return BBoolean.FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
public BIcon getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private class PrintJob
|
||||
implements Runnable,
|
||||
Printable {
|
||||
int[] lineNumberAtTopOfPage;
|
||||
ArrayList textLines = new ArrayList();
|
||||
|
||||
public PrintJob(String string) {
|
||||
int n;
|
||||
String[] stringArray = string.split("\n");
|
||||
for (n = 0; n < stringArray.length; ++n) {
|
||||
this.textLines.add(stringArray[n]);
|
||||
}
|
||||
this.lineNumberAtTopOfPage = new int[100];
|
||||
this.lineNumberAtTopOfPage[0] = 0;
|
||||
for (n = 1; n < this.lineNumberAtTopOfPage.length; ++n) {
|
||||
this.lineNumberAtTopOfPage[n] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
public int print(Graphics graphics, PageFormat pageFormat, int n) throws PrinterException {
|
||||
int n2 = this.lineNumberAtTopOfPage[n];
|
||||
if (this.lineNumberAtTopOfPage[n] == -1) {
|
||||
return 1;
|
||||
}
|
||||
if (n != 0) {
|
||||
while (((String)this.textLines.get(n2)).length() == 0) {
|
||||
++n2;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Object object;
|
||||
Font font;
|
||||
int n3;
|
||||
Object object2;
|
||||
Graphics2D graphics2D = (Graphics2D)graphics;
|
||||
graphics2D.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
|
||||
if (!BPrinterRecipient.this.getFont().isNull()) {
|
||||
object2 = BPrinterRecipient.this.getFont();
|
||||
n3 = 0;
|
||||
if (object2.isBold()) {
|
||||
n3 |= 1;
|
||||
}
|
||||
if (object2.isItalic()) {
|
||||
n3 |= 2;
|
||||
}
|
||||
font = new Font(object2.getName(), n3, (int)object2.getSize());
|
||||
if (object2.isUnderline()) {
|
||||
object = new Hashtable();
|
||||
object.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
|
||||
font = font.deriveFont((Map<? extends AttributedCharacterIterator.Attribute, ?>)object);
|
||||
}
|
||||
graphics.setFont(font);
|
||||
graphics2D.setFont(font);
|
||||
} else {
|
||||
font = graphics2D.getFont();
|
||||
}
|
||||
object2 = graphics2D.getFontMetrics(font);
|
||||
n3 = ((FontMetrics)object2).getAscent();
|
||||
while (n2 < this.textLines.size() && (double)n3 < pageFormat.getImageableHeight()) {
|
||||
object = (String)this.textLines.get(n2);
|
||||
if ((double)((FontMetrics)object2).charsWidth(((String)object).toCharArray(), 0, ((String)object).length()) > pageFormat.getImageableWidth()) {
|
||||
int n4;
|
||||
ArrayList<String> arrayList = new ArrayList<String>();
|
||||
for (int i = 0; i < ((String)object).length(); i += n4) {
|
||||
n4 = ((String)object).length() - i;
|
||||
while ((double)((FontMetrics)object2).charsWidth(((String)object).toCharArray(), i, n4) > pageFormat.getImageableWidth()) {
|
||||
--n4;
|
||||
}
|
||||
int n5 = n4;
|
||||
if (i + n5 < ((String)object).length()) {
|
||||
while (((String)object).charAt(i + n5 - 1) != ' ' && n5 > 1) {
|
||||
--n5;
|
||||
}
|
||||
if (n5 > 1) {
|
||||
n4 = n5;
|
||||
}
|
||||
}
|
||||
arrayList.add(((String)object).substring(i, i + n4));
|
||||
}
|
||||
this.textLines.remove(n2);
|
||||
for (n4 = arrayList.size() - 1; n4 >= 0; --n4) {
|
||||
this.textLines.add(n2, arrayList.get(n4));
|
||||
}
|
||||
}
|
||||
graphics2D.drawString((String)object, 0, n3);
|
||||
n3 += ((FontMetrics)object2).getAscent();
|
||||
++n2;
|
||||
}
|
||||
if ((double)n3 >= pageFormat.getImageableHeight()) {
|
||||
this.lineNumberAtTopOfPage[n + 1] = n2;
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
log.error("Print failure", (Throwable)exception);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
HashAttributeSet hashAttributeSet = new HashAttributeSet();
|
||||
hashAttributeSet.add(new PrinterName(BPrinterRecipient.this.getPrinter(), null));
|
||||
PrintService[] printServiceArray = PrintServiceLookup.lookupPrintServices(null, hashAttributeSet);
|
||||
if (printServiceArray.length < 1) {
|
||||
try {
|
||||
if (BPrinterRecipient.this.getAlertOnFailure()) {
|
||||
BFacets bFacets = BPrinterRecipient.this.getAlarmSourceInfo().makeAlarmData(BSourceState.offnormal);
|
||||
bFacets = BFacets.make((BFacets)bFacets, (String)"msgText", (BIDataValue)BString.make((String)("Printer '" + BPrinterRecipient.this.getPrinter() + "' not found.")));
|
||||
BPrinterRecipient.this.support.newAlert(bFacets);
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
log.warning("Printer not found: " + BPrinterRecipient.this.getPrinter(), (Throwable)exception);
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
DocPrintJob docPrintJob = printServiceArray[0].createPrintJob();
|
||||
docPrintJob.print(new SimpleDoc(this, DocFlavor.SERVICE_FORMATTED.PRINTABLE, null), null);
|
||||
}
|
||||
catch (PrintException printException) {
|
||||
if (BPrinterRecipient.this.getAlertOnFailure()) {
|
||||
BFacets bFacets = BPrinterRecipient.this.getAlarmSourceInfo().makeAlarmData(BSourceState.offnormal);
|
||||
bFacets = BFacets.make((BFacets)bFacets, (String)"msgText", (BIDataValue)BString.make((String)("Unable to print to '" + BPrinterRecipient.this.getPrinter() + "'")));
|
||||
try {
|
||||
BPrinterRecipient.this.support.newAlert(bFacets);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
// empty catch block
|
||||
}
|
||||
}
|
||||
log.error("Printer failure", (Throwable)printException);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.nre.util.Array
|
||||
* javax.baja.nre.util.SortUtil
|
||||
* javax.baja.sys.Cursor
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.alarm.ui.ConsoleColumns;
|
||||
import com.tridium.alarm.ui.ConsoleTableModel;
|
||||
import java.util.Comparator;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.nre.util.Array;
|
||||
import javax.baja.nre.util.SortUtil;
|
||||
import javax.baja.sys.Cursor;
|
||||
|
||||
public class AlarmDbTableModel
|
||||
extends ConsoleTableModel {
|
||||
private Array alarmList = new Array(class$javax$baja$alarm$BAlarmRecord == null ? (class$javax$baja$alarm$BAlarmRecord = AlarmDbTableModel.class$("javax.baja.alarm.BAlarmRecord")) : class$javax$baja$alarm$BAlarmRecord);
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
|
||||
public AlarmDbTableModel(ConsoleColumns consoleColumns) {
|
||||
super(consoleColumns);
|
||||
}
|
||||
|
||||
public synchronized void load(Cursor cursor) {
|
||||
this.clear();
|
||||
this.doAdd(cursor);
|
||||
}
|
||||
|
||||
public int getAlarmCount() {
|
||||
return this.alarmList.size();
|
||||
}
|
||||
|
||||
public int getSourceCount() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
private synchronized void doAdd(Cursor cursor) {
|
||||
while (cursor.next()) {
|
||||
this.add((BAlarmRecord)cursor.get());
|
||||
}
|
||||
this.updateTable();
|
||||
}
|
||||
|
||||
public synchronized void add(BAlarmRecord bAlarmRecord) {
|
||||
this.alarmList.add((Object)bAlarmRecord);
|
||||
}
|
||||
|
||||
public synchronized void clear() {
|
||||
this.alarmList.clear();
|
||||
this.updateTable();
|
||||
}
|
||||
|
||||
public int getRowCount() {
|
||||
return this.alarmList.size();
|
||||
}
|
||||
|
||||
public BAlarmRecord getRecord(int n) {
|
||||
if (n < this.getRowCount()) {
|
||||
return (BAlarmRecord)((Object)this.alarmList.get(n));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public synchronized void sortByColumn(int n, boolean bl) {
|
||||
if (n < 0 || n >= super.getColumnCount()) {
|
||||
return;
|
||||
}
|
||||
this.setInitialSort(n, bl);
|
||||
ConsoleColumns.Column column = this.getColumns().getColumn(n);
|
||||
if (bl) {
|
||||
this.sort(column, SortUtil.ASCENDING);
|
||||
} else {
|
||||
this.sort(column, SortUtil.DESCENDING);
|
||||
}
|
||||
}
|
||||
|
||||
private void sort(ConsoleColumns.Column column, Comparator comparator) {
|
||||
int n = this.alarmList.size();
|
||||
for (int i = n / 2; i >= 1; i /= 2) {
|
||||
for (int j = i; j < n; ++j) {
|
||||
int n2;
|
||||
BAlarmRecord bAlarmRecord = (BAlarmRecord)((Object)this.alarmList.get(j));
|
||||
Object object = column.getValue(bAlarmRecord);
|
||||
for (n2 = j; n2 >= i && comparator.compare(object, column.getValue((BAlarmRecord)((Object)this.alarmList.get(n2 - i)))) < 0; n2 -= i) {
|
||||
this.alarmList.set(n2, this.alarmList.get(n2 - i));
|
||||
}
|
||||
this.alarmList.set(n2, (Object)bAlarmRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.nre.util.SortUtil
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.alarm.ui.ConsoleColumns;
|
||||
import com.tridium.alarm.ui.ConsoleTableModel;
|
||||
import com.tridium.alarm.ui.SourceTableModel;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.nre.util.SortUtil;
|
||||
|
||||
public class AlarmTableModel
|
||||
extends ConsoleTableModel {
|
||||
private SourceTableModel.AlarmList alarmList;
|
||||
|
||||
public AlarmTableModel(ConsoleColumns consoleColumns, SourceTableModel.AlarmList alarmList) {
|
||||
super(consoleColumns);
|
||||
this.alarmList = alarmList;
|
||||
alarmList.setModel(this);
|
||||
this.sortByColumn(this.getLastSortColumn(), this.getLastSortAscending());
|
||||
}
|
||||
|
||||
public int getAlarmCount() {
|
||||
return this.getRowCount();
|
||||
}
|
||||
|
||||
public int getSourceCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int getRowCount() {
|
||||
return this.alarmList.size();
|
||||
}
|
||||
|
||||
public BAlarmRecord getRecord(int n) {
|
||||
SourceTableModel.AlarmEntry alarmEntry = this.alarmList.getEntry(n);
|
||||
return alarmEntry.rec;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
super.close();
|
||||
this.alarmList.setModel(null);
|
||||
}
|
||||
|
||||
public synchronized void sortByColumn(int n, boolean bl) {
|
||||
if (n < 0 || n >= super.getColumnCount()) {
|
||||
return;
|
||||
}
|
||||
this.setInitialSort(n, bl);
|
||||
ConsoleColumns.Column column = this.getColumns().getColumn(n);
|
||||
if (bl) {
|
||||
this.alarmList.sort(column, SortUtil.ASCENDING);
|
||||
} else {
|
||||
this.alarmList.sort(column, SortUtil.DESCENDING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.ui.UiEnv
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Slot
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.ui.UiEnv;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Slot;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
public class BAlarmClassDef
|
||||
extends BComponent {
|
||||
public static final Property defName = BAlarmClassDef.newProperty((int)0, (String)"", null);
|
||||
public static final Property alarmIcon = BAlarmClassDef.newProperty((int)0, (BValue)BOrd.NULL, null);
|
||||
public static final Property alarmUrl = BAlarmClassDef.newProperty((int)0, (BValue)BOrd.NULL, null);
|
||||
public static final Property alarmSound = BAlarmClassDef.newProperty((int)0, (BValue)BOrd.NULL, null);
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BAlarmClassDef == null ? (class$com$tridium$alarm$ui$BAlarmClassDef = BAlarmClassDef.class$("com.tridium.alarm.ui.BAlarmClassDef")) : class$com$tridium$alarm$ui$BAlarmClassDef));
|
||||
public static BAlarmClassDef DEFAULT = new BAlarmClassDef();
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmClassDef;
|
||||
|
||||
public String getDefName() {
|
||||
return this.getString(defName);
|
||||
}
|
||||
|
||||
public void setDefName(String string) {
|
||||
this.setString(defName, string, null);
|
||||
}
|
||||
|
||||
public BOrd getAlarmIcon() {
|
||||
return (BOrd)this.get(alarmIcon);
|
||||
}
|
||||
|
||||
public void setAlarmIcon(BOrd bOrd) {
|
||||
this.set(alarmIcon, (BValue)bOrd, null);
|
||||
}
|
||||
|
||||
public BOrd getAlarmUrl() {
|
||||
return (BOrd)this.get(alarmUrl);
|
||||
}
|
||||
|
||||
public void setAlarmUrl(BOrd bOrd) {
|
||||
this.set(alarmUrl, (BValue)bOrd, null);
|
||||
}
|
||||
|
||||
public BOrd getAlarmSound() {
|
||||
return (BOrd)this.get(alarmSound);
|
||||
}
|
||||
|
||||
public void setAlarmSound(BOrd bOrd) {
|
||||
this.set(alarmSound, (BValue)bOrd, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BAlarmClassDef() {
|
||||
if (UiEnv.get().isMicroEdition()) {
|
||||
int n = this.getFlags((Slot)alarmSound);
|
||||
this.setFlags((Slot)alarmSound, n | 4);
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.workbench.fieldeditors.BComponentNamePickerFE
|
||||
* javax.baja.nre.util.Array
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.workbench.fieldeditors.BComponentNamePickerFE;
|
||||
import javax.baja.alarm.BAlarmClassFolder;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.nre.util.Array;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
public class BAlarmClassFE
|
||||
extends BComponentNamePickerFE {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BAlarmClassFE == null ? (class$com$tridium$alarm$ui$BAlarmClassFE = BAlarmClassFE.class$("com.tridium.alarm.ui.BAlarmClassFE")) : class$com$tridium$alarm$ui$BAlarmClassFE));
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmClassFE;
|
||||
static /* synthetic */ Class class$javax$baja$sys$BComponent;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmClass;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmClassFolder;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BComponent[] list() throws Exception {
|
||||
BComponent bComponent = this.loadService(BAlarmService.TYPE);
|
||||
return this.loadFromFolder(bComponent);
|
||||
}
|
||||
|
||||
private BComponent[] loadFromFolder(BComponent bComponent) {
|
||||
Array array = new Array(class$javax$baja$sys$BComponent == null ? (class$javax$baja$sys$BComponent = BAlarmClassFE.class$("javax.baja.sys.BComponent")) : class$javax$baja$sys$BComponent);
|
||||
bComponent.lease();
|
||||
BComponent[] bComponentArray = (BComponent[])bComponent.getChildren(class$javax$baja$alarm$BAlarmClass == null ? (class$javax$baja$alarm$BAlarmClass = BAlarmClassFE.class$("javax.baja.alarm.BAlarmClass")) : class$javax$baja$alarm$BAlarmClass);
|
||||
for (int i = 0; i < bComponentArray.length; ++i) {
|
||||
array.add((Object)bComponentArray[i]);
|
||||
}
|
||||
BAlarmClassFolder[] bAlarmClassFolderArray = (BAlarmClassFolder[])bComponent.getChildren(class$javax$baja$alarm$BAlarmClassFolder == null ? (class$javax$baja$alarm$BAlarmClassFolder = BAlarmClassFE.class$("javax.baja.alarm.BAlarmClassFolder")) : class$javax$baja$alarm$BAlarmClassFolder);
|
||||
for (int i = 0; i < bAlarmClassFolderArray.length; ++i) {
|
||||
this.loadFromFolder((BComponent)bAlarmClassFolderArray[i]);
|
||||
BComponent[] bComponentArray2 = this.loadFromFolder((BComponent)bAlarmClassFolderArray[i]);
|
||||
for (int j = 0; j < bComponentArray2.length; ++j) {
|
||||
array.add((Object)bComponentArray2[j]);
|
||||
}
|
||||
}
|
||||
return (BComponent[])array.trim();
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.naming.SlotPath
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.alarm.ui.BAlarmClassDef;
|
||||
import javax.baja.naming.SlotPath;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
public class BAlarmClassMapping
|
||||
extends BComponent {
|
||||
public static final Property alarmClassDefinitions = BAlarmClassMapping.newProperty((int)4, (BValue)new BComponent(), null);
|
||||
public static final Property alarmClassDefMapping = BAlarmClassMapping.newProperty((int)4, (BValue)new BComponent(), null);
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BAlarmClassMapping == null ? (class$com$tridium$alarm$ui$BAlarmClassMapping = BAlarmClassMapping.class$("com.tridium.alarm.ui.BAlarmClassMapping")) : class$com$tridium$alarm$ui$BAlarmClassMapping));
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmClassMapping;
|
||||
|
||||
public BComponent getAlarmClassDefinitions() {
|
||||
return (BComponent)this.get(alarmClassDefinitions);
|
||||
}
|
||||
|
||||
public void setAlarmClassDefinitions(BComponent bComponent) {
|
||||
this.set(alarmClassDefinitions, (BValue)bComponent, null);
|
||||
}
|
||||
|
||||
public BComponent getAlarmClassDefMapping() {
|
||||
return (BComponent)this.get(alarmClassDefMapping);
|
||||
}
|
||||
|
||||
public void setAlarmClassDefMapping(BComponent bComponent) {
|
||||
this.set(alarmClassDefMapping, (BValue)bComponent, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BAlarmClassDef getAlarmClassDefFor(String string) {
|
||||
BString bString = (BString)this.getAlarmClassDefMapping().get(string);
|
||||
if (bString == null) {
|
||||
return BAlarmClassDef.DEFAULT;
|
||||
}
|
||||
return (BAlarmClassDef)this.getAlarmClassDefinitions().get(SlotPath.escape((String)bString.toString()));
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,525 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.ui.UiEnv
|
||||
* com.tridium.workbench.fieldeditors.BOrdFE
|
||||
* com.tridium.workbench.ord.BFileOrdChooser
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.SlotPath
|
||||
* javax.baja.registry.TypeInfo
|
||||
* javax.baja.sys.BComplex
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.SlotCursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BButton
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BTextDropDown
|
||||
* javax.baja.ui.BTextField
|
||||
* javax.baja.ui.BToolBar
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.Command
|
||||
* javax.baja.ui.CommandArtifact
|
||||
* javax.baja.ui.enums.BOrientation
|
||||
* javax.baja.ui.event.BMouseEvent
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BEdgePane
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.ui.pane.BSplitPane
|
||||
* javax.baja.ui.table.BTable
|
||||
* javax.baja.ui.table.DefaultTableModel
|
||||
* javax.baja.ui.table.TableController
|
||||
* javax.baja.ui.table.TableModel
|
||||
* javax.baja.ui.util.BTitlePane
|
||||
* javax.baja.ui.util.UiLexicon
|
||||
* javax.baja.workbench.BWbShell
|
||||
* javax.baja.workbench.fieldeditor.BWbFieldEditor
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.alarm.ui.BAlarmClassDef;
|
||||
import com.tridium.alarm.ui.BAlarmClassFE;
|
||||
import com.tridium.alarm.ui.BAlarmClassMapping;
|
||||
import com.tridium.ui.UiEnv;
|
||||
import com.tridium.workbench.fieldeditors.BOrdFE;
|
||||
import com.tridium.workbench.ord.BFileOrdChooser;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.SlotPath;
|
||||
import javax.baja.registry.TypeInfo;
|
||||
import javax.baja.sys.BComplex;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.SlotCursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BButton;
|
||||
import javax.baja.ui.BDialog;
|
||||
import javax.baja.ui.BLabel;
|
||||
import javax.baja.ui.BTextDropDown;
|
||||
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.BOrientation;
|
||||
import javax.baja.ui.event.BMouseEvent;
|
||||
import javax.baja.ui.pane.BBorderPane;
|
||||
import javax.baja.ui.pane.BEdgePane;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.ui.pane.BSplitPane;
|
||||
import javax.baja.ui.table.BTable;
|
||||
import javax.baja.ui.table.DefaultTableModel;
|
||||
import javax.baja.ui.table.TableController;
|
||||
import javax.baja.ui.table.TableModel;
|
||||
import javax.baja.ui.util.BTitlePane;
|
||||
import javax.baja.ui.util.UiLexicon;
|
||||
import javax.baja.workbench.BWbShell;
|
||||
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
|
||||
|
||||
public class BAlarmClassMappingFE
|
||||
extends BWbFieldEditor {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BAlarmClassMappingFE == null ? (class$com$tridium$alarm$ui$BAlarmClassMappingFE = BAlarmClassMappingFE.class$("com.tridium.alarm.ui.BAlarmClassMappingFE")) : class$com$tridium$alarm$ui$BAlarmClassMappingFE));
|
||||
protected BWidget popup;
|
||||
protected Context context;
|
||||
protected boolean isMicroEdition = false;
|
||||
protected Command mapCommand;
|
||||
protected Command removeMapCommand;
|
||||
protected Command addDefCommand;
|
||||
protected Command editDefCommand;
|
||||
protected Command delDefCommand;
|
||||
protected MappingTableModel mappingTableModel = new MappingTableModel();
|
||||
protected DefaultTableModel defTableModel;
|
||||
public static final UiLexicon lexicon = new UiLexicon(class$com$tridium$alarm$ui$BAlarmConsole == null ? (class$com$tridium$alarm$ui$BAlarmConsole = BAlarmClassMappingFE.class$("com.tridium.alarm.ui.BAlarmConsole")) : class$com$tridium$alarm$ui$BAlarmConsole);
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmClassMappingFE;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmClassDef;
|
||||
static /* synthetic */ Class class$javax$baja$sys$BString;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmConsole;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BAlarmClassMappingFE() {
|
||||
if (UiEnv.get().isMicroEdition()) {
|
||||
this.defTableModel = new DefaultTableModel(new String[]{lexicon.getText("alarmClassMapper.name"), lexicon.getText("alarmClassMapper.icon"), lexicon.getText("alarmClassMapper.hyperlink")});
|
||||
this.isMicroEdition = true;
|
||||
} else {
|
||||
this.defTableModel = new DefaultTableModel(new String[]{lexicon.getText("alarmClassMapper.name"), lexicon.getText("alarmClassMapper.icon"), lexicon.getText("alarmClassMapper.hyperlink"), lexicon.getText("alarmClassMapper.sound")});
|
||||
}
|
||||
Command command = new Command((BWidget)this, BAlarmClassMappingFE.lexicon.module, "commands.alarmClassMappingFE"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
int n;
|
||||
if (BAlarmClassMappingFE.this.popup == null) {
|
||||
BAlarmClassMappingFE.this.popup = BAlarmClassMappingFE.this.createPopup();
|
||||
}
|
||||
if ((n = BDialog.open((BWidget)BAlarmClassMappingFE.this, (String)lexicon.getText("alarmClassMapper.title"), (Object)BAlarmClassMappingFE.this.popup, (int)3)) == 1) {
|
||||
BAlarmClassMappingFE.this.setModified();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
BButton bButton = new BButton(command, false, true);
|
||||
BGridPane bGridPane = new BGridPane(2);
|
||||
bGridPane.add("name", (BValue)new BLabel(lexicon.getText("alarmClassMapper.mapping")));
|
||||
BToolBar bToolBar = new BToolBar();
|
||||
bToolBar.add("btn", (BValue)bButton);
|
||||
bGridPane.add("button", (BValue)bToolBar);
|
||||
this.setContent((BWidget)bGridPane);
|
||||
}
|
||||
|
||||
public BWidget createPopup() {
|
||||
this.addDefCommand = new Command((BWidget)this, BAlarmClassMappingFE.lexicon.module, "commands.addDef"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BAlarmClassMappingFE.this.addAlarmClassDef();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
BButton bButton = new BButton(this.addDefCommand);
|
||||
this.editDefCommand = new Command((BWidget)this, BAlarmClassMappingFE.lexicon.module, "commands.editDef"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BAlarmClassMappingFE.this.editAlarmClassDef();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
BButton bButton2 = new BButton(this.editDefCommand);
|
||||
this.editDefCommand.setEnabled(this.defTableModel.getRowCount() > 0);
|
||||
this.delDefCommand = new Command((BWidget)this, BAlarmClassMappingFE.lexicon.module, "commands.deleteDef"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BAlarmClassMappingFE.this.delAlarmClassDef();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
BButton bButton3 = new BButton(this.delDefCommand);
|
||||
this.delDefCommand.setEnabled(this.defTableModel.getRowCount() > 0);
|
||||
BEdgePane bEdgePane = new BEdgePane();
|
||||
BEdgePane bEdgePane2 = new BEdgePane();
|
||||
BGridPane bGridPane = new BGridPane(3);
|
||||
bGridPane.add("add", (BValue)bButton);
|
||||
bGridPane.add("edit", (BValue)bButton2);
|
||||
bGridPane.add("del", (BValue)bButton3);
|
||||
bEdgePane2.setCenter((BWidget)new BBorderPane((BWidget)new BTable((TableModel)this.defTableModel, (TableController)new Controller())));
|
||||
bEdgePane2.setBottom((BWidget)new BBorderPane((BWidget)bGridPane));
|
||||
this.defTableModel.getTable().setMultipleSelection(false);
|
||||
bEdgePane.setCenter((BWidget)new BTitlePane(lexicon.getText("alarmClassMapper.alarmClassDefs"), (BWidget)bEdgePane2));
|
||||
this.mapCommand = new Command((BWidget)this, BAlarmClassMappingFE.lexicon.module, "commands.mapAlarmClass"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BAlarmClassMappingFE.this.mapAlarmClass();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
BButton bButton4 = new BButton(this.mapCommand);
|
||||
this.removeMapCommand = new Command((BWidget)this, BAlarmClassMappingFE.lexicon.module, "commands.deleteAlarmClassMap"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BAlarmClassMappingFE.this.deleteAlarmClassMap();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
this.removeMapCommand.setEnabled(false);
|
||||
BButton bButton5 = new BButton(this.removeMapCommand);
|
||||
BGridPane bGridPane2 = new BGridPane(3);
|
||||
bGridPane2.add("b1", (BValue)bButton4);
|
||||
bGridPane2.add("b3", (BValue)bButton5);
|
||||
BEdgePane bEdgePane3 = new BEdgePane();
|
||||
BTable bTable = new BTable((TableModel)this.mappingTableModel, (TableController)new MappingTableController());
|
||||
bTable.setPreferredSize(800.0, 800.0);
|
||||
bEdgePane3.setCenter((BWidget)new BBorderPane((BWidget)bTable));
|
||||
bEdgePane3.setBottom((BWidget)new BBorderPane((BWidget)bGridPane2));
|
||||
BSplitPane bSplitPane = new BSplitPane(BOrientation.vertical, 50.0);
|
||||
bSplitPane.setWidget1((BWidget)bEdgePane);
|
||||
bSplitPane.setWidget2((BWidget)new BTitlePane(lexicon.getText("alarmClassMapper.alarmClassDefMapping"), (BWidget)bEdgePane3));
|
||||
return bSplitPane;
|
||||
}
|
||||
|
||||
protected void doSetReadonly(boolean bl) {
|
||||
}
|
||||
|
||||
protected void doLoadValue(BObject bObject, Context context) {
|
||||
BAlarmClassMapping bAlarmClassMapping = (BAlarmClassMapping)bObject;
|
||||
this.context = context;
|
||||
BAlarmClassDef[] bAlarmClassDefArray = (BAlarmClassDef[])bAlarmClassMapping.getAlarmClassDefinitions().getChildren(class$com$tridium$alarm$ui$BAlarmClassDef == null ? (class$com$tridium$alarm$ui$BAlarmClassDef = BAlarmClassMappingFE.class$("com.tridium.alarm.ui.BAlarmClassDef")) : class$com$tridium$alarm$ui$BAlarmClassDef);
|
||||
for (int i = 0; i < bAlarmClassDefArray.length; ++i) {
|
||||
if (this.isMicroEdition) {
|
||||
this.defTableModel.addRow(new Object[]{SlotPath.unescape((String)bAlarmClassDefArray[i].getDefName()), bAlarmClassDefArray[i].getAlarmIcon(), bAlarmClassDefArray[i].getAlarmUrl()});
|
||||
continue;
|
||||
}
|
||||
this.defTableModel.addRow(new Object[]{SlotPath.unescape((String)bAlarmClassDefArray[i].getDefName()), bAlarmClassDefArray[i].getAlarmIcon(), bAlarmClassDefArray[i].getAlarmUrl(), bAlarmClassDefArray[i].getAlarmSound()});
|
||||
}
|
||||
this.defTableModel.updateTable();
|
||||
BComponent bComponent = bAlarmClassMapping.getAlarmClassDefMapping();
|
||||
SlotCursor slotCursor = bComponent.getProperties();
|
||||
boolean bl = false;
|
||||
while (slotCursor.next(class$javax$baja$sys$BString == null ? BAlarmClassMappingFE.class$("javax.baja.sys.BString") : class$javax$baja$sys$BString)) {
|
||||
Property property = slotCursor.property();
|
||||
String string = property.getName();
|
||||
BString bString = (BString)slotCursor.get();
|
||||
this.mappingTableModel.addRow(new Object[]{string, bString});
|
||||
}
|
||||
this.mappingTableModel.updateTable();
|
||||
}
|
||||
|
||||
protected BObject doSaveValue(BObject object, Context context) {
|
||||
try {
|
||||
BOrd bOrd;
|
||||
String string;
|
||||
BComponent bComponent = new BComponent();
|
||||
for (int i = 0; i < this.defTableModel.getRowCount(); ++i) {
|
||||
BAlarmClassDef bAlarmClassDef = new BAlarmClassDef();
|
||||
string = SlotPath.escape((String)((String)this.defTableModel.getValueAt(i, 0)));
|
||||
bOrd = (BOrd)this.defTableModel.getValueAt(i, 1);
|
||||
BOrd bOrd2 = (BOrd)this.defTableModel.getValueAt(i, 2);
|
||||
bAlarmClassDef.setDefName(string);
|
||||
bAlarmClassDef.setAlarmIcon(bOrd);
|
||||
bAlarmClassDef.setAlarmUrl(bOrd2);
|
||||
if (!this.isMicroEdition) {
|
||||
BOrd bOrd3 = (BOrd)this.defTableModel.getValueAt(i, 3);
|
||||
bAlarmClassDef.setAlarmSound(bOrd3);
|
||||
}
|
||||
bComponent.add(string, (BValue)bAlarmClassDef);
|
||||
}
|
||||
BComponent bComponent2 = new BComponent();
|
||||
for (int i = 0; i < this.mappingTableModel.getRowCount(); ++i) {
|
||||
string = SlotPath.escape((String)this.mappingTableModel.getAlarmClassName(i));
|
||||
bOrd = (BString)this.mappingTableModel.getValueAt(i, 1);
|
||||
bComponent2.add(string, (BValue)bOrd);
|
||||
}
|
||||
BAlarmClassMapping bAlarmClassMapping = (BAlarmClassMapping)((Object)object);
|
||||
bAlarmClassMapping.setAlarmClassDefinitions(bComponent);
|
||||
bAlarmClassMapping.setAlarmClassDefMapping(bComponent2);
|
||||
object = bAlarmClassMapping;
|
||||
return bAlarmClassMapping;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected BWidget makeAlarmClassDefPane(String string, BAlarmClassDef bAlarmClassDef) {
|
||||
if (bAlarmClassDef == null) {
|
||||
bAlarmClassDef = new BAlarmClassDef();
|
||||
}
|
||||
BGridPane bGridPane = new BGridPane(2);
|
||||
bGridPane.add("nameLbl", (BValue)new BLabel(lexicon.getText("alarmClassMapper.name")));
|
||||
bGridPane.add("nameField", (BValue)new BTextField(string, 20));
|
||||
bGridPane.add("iconLbl", (BValue)new BLabel(lexicon.getText("alarmClassMapper.icon")));
|
||||
BOrdFE bOrdFE = new BOrdFE();
|
||||
bOrdFE.allowLinkButton(false);
|
||||
bOrdFE.loadMenu(new TypeInfo[]{BFileOrdChooser.TYPE.getTypeInfo()});
|
||||
bOrdFE.loadValue((BObject)bAlarmClassDef.getAlarmIcon());
|
||||
bGridPane.add("iconField", (BValue)bOrdFE);
|
||||
bGridPane.add("hyperlinkLbl", (BValue)new BLabel(lexicon.getText("alarmClassMapper.hyperlink")));
|
||||
BOrdFE bOrdFE2 = new BOrdFE();
|
||||
bOrdFE2.allowLinkButton(false);
|
||||
bOrdFE2.loadMenu(new TypeInfo[0]);
|
||||
bOrdFE2.loadValue((BObject)bAlarmClassDef.getAlarmUrl());
|
||||
bGridPane.add("hyperlinkField", (BValue)bOrdFE2);
|
||||
if (!this.isMicroEdition) {
|
||||
bGridPane.add("soundLbl", (BValue)new BLabel(lexicon.getText("alarmClassMapper.sound")));
|
||||
BOrdFE bOrdFE3 = new BOrdFE();
|
||||
bOrdFE3.allowLinkButton(false);
|
||||
bOrdFE3.loadMenu(new TypeInfo[]{BFileOrdChooser.TYPE.getTypeInfo()});
|
||||
bOrdFE3.loadValue((BObject)bAlarmClassDef.getAlarmSound());
|
||||
bGridPane.add("soundField", (BValue)bOrdFE3);
|
||||
}
|
||||
return bGridPane;
|
||||
}
|
||||
|
||||
protected void addAlarmClassDef() {
|
||||
BWidget bWidget = this.makeAlarmClassDefPane("", null);
|
||||
int n = BDialog.open((BWidget)this, (String)lexicon.getText("commands.addDef.label"), (Object)bWidget, (int)3);
|
||||
if (n == 2) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
String string = ((BTextField)bWidget.get("nameField")).getText();
|
||||
BOrd bOrd = (BOrd)((BOrdFE)bWidget.get("iconField")).saveValue();
|
||||
BOrd bOrd2 = (BOrd)((BOrdFE)bWidget.get("hyperlinkField")).saveValue();
|
||||
if (!this.isMicroEdition) {
|
||||
BOrd bOrd3 = (BOrd)((BOrdFE)bWidget.get("soundField")).saveValue();
|
||||
this.defTableModel.addRow(new Object[]{string, bOrd, bOrd2, bOrd3});
|
||||
} else {
|
||||
this.defTableModel.addRow(new Object[]{string, bOrd, bOrd2});
|
||||
}
|
||||
this.defTableModel.updateTable();
|
||||
this.editDefCommand.setEnabled(true);
|
||||
this.delDefCommand.setEnabled(true);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void editAlarmClassDef() {
|
||||
BWidget bWidget;
|
||||
int n = this.defTableModel.getTable().getSelection().getRow();
|
||||
if (n < 0) {
|
||||
return;
|
||||
}
|
||||
BAlarmClassDef bAlarmClassDef = new BAlarmClassDef();
|
||||
String string = (String)this.defTableModel.getValueAt(n, 0);
|
||||
BOrd bOrd = (BOrd)this.defTableModel.getValueAt(n, 1);
|
||||
BOrd bOrd2 = (BOrd)this.defTableModel.getValueAt(n, 2);
|
||||
bAlarmClassDef.setDefName(string);
|
||||
bAlarmClassDef.setAlarmIcon(bOrd);
|
||||
bAlarmClassDef.setAlarmUrl(bOrd2);
|
||||
if (!this.isMicroEdition) {
|
||||
bWidget = (BOrd)this.defTableModel.getValueAt(n, 3);
|
||||
bAlarmClassDef.setAlarmSound((BOrd)bWidget);
|
||||
}
|
||||
bWidget = this.makeAlarmClassDefPane(bAlarmClassDef.getDefName(), bAlarmClassDef);
|
||||
int n2 = BDialog.open((BWidget)this, (String)lexicon.getText("commands.editDef.label"), (Object)bWidget, (int)3);
|
||||
if (n2 == 2) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
string = ((BTextField)bWidget.get("nameField")).getText();
|
||||
bOrd = (BOrd)((BOrdFE)bWidget.get("iconField")).saveValue();
|
||||
bOrd2 = (BOrd)((BOrdFE)bWidget.get("hyperlinkField")).saveValue();
|
||||
this.defTableModel.set(n, 0, (Object)string);
|
||||
this.defTableModel.set(n, 1, (Object)bOrd);
|
||||
this.defTableModel.set(n, 2, (Object)bOrd2);
|
||||
if (!this.isMicroEdition) {
|
||||
BOrd bOrd3 = (BOrd)((BOrdFE)bWidget.get("soundField")).saveValue();
|
||||
this.defTableModel.set(n, 3, (Object)bOrd3);
|
||||
}
|
||||
this.defTableModel.updateTable();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void delAlarmClassDef() {
|
||||
int n = this.defTableModel.getTable().getSelection().getRow();
|
||||
if (n < 0) {
|
||||
return;
|
||||
}
|
||||
String string = (String)this.defTableModel.getValueAt(n, 0);
|
||||
this.defTableModel.removeRow(n);
|
||||
this.defTableModel.updateTable();
|
||||
this.delDefCommand.setEnabled(this.defTableModel.getRowCount() > 0);
|
||||
this.editDefCommand.setEnabled(this.defTableModel.getRowCount() > 0);
|
||||
try {
|
||||
int n2 = this.mappingTableModel.getRowCount();
|
||||
for (int i = n2 - 1; i >= 0; --i) {
|
||||
String string2 = this.mappingTableModel.getValueAt(i, 1).toString();
|
||||
if (!string.equals(string2)) continue;
|
||||
this.mappingTableModel.removeRow(n);
|
||||
this.mappingTableModel.updateTable();
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void mapAlarmClass() {
|
||||
String string;
|
||||
BTextDropDown bTextDropDown = new BTextDropDown(false);
|
||||
for (int i = 0; i < this.defTableModel.getRowCount(); ++i) {
|
||||
string = (String)this.defTableModel.getValueAt(i, 0);
|
||||
bTextDropDown.getList().addItem((Object)string);
|
||||
if (i != 0) continue;
|
||||
bTextDropDown.setText(string);
|
||||
}
|
||||
BAlarmClassFE bAlarmClassFE = new BAlarmClassFE();
|
||||
this.add("fe", (BValue)bAlarmClassFE);
|
||||
bAlarmClassFE.loadValue((BObject)BString.make((String)"defaultAlarmClass"));
|
||||
this.remove((BComplex)bAlarmClassFE);
|
||||
string = new BGridPane(2);
|
||||
string.add("acLbl", (BValue)new BLabel(lexicon.getText("alarm.alarmClass")));
|
||||
string.add("ac", (BValue)bAlarmClassFE);
|
||||
string.add("defLbl", (BValue)new BLabel(lexicon.getText("alarmClassMapper.definition")));
|
||||
string.add("def", (BValue)bTextDropDown);
|
||||
int n = BDialog.open((BWidget)this, (String)lexicon.getText("commands.mapAlarmClass"), (Object)string, (int)3);
|
||||
if (n == 2) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
String string2 = bAlarmClassFE.saveValue().toString(this.context);
|
||||
String string3 = bTextDropDown.getText();
|
||||
for (int i = 0; i < this.mappingTableModel.getRowCount(); ++i) {
|
||||
String string4 = (String)this.mappingTableModel.getValueAt(i, 0);
|
||||
if (!string4.equals(string2)) continue;
|
||||
this.mappingTableModel.removeRow(i);
|
||||
this.mappingTableModel.updateTable();
|
||||
}
|
||||
this.mappingTableModel.addRow(new Object[]{string2, BString.make((String)string3)});
|
||||
this.mappingTableModel.updateTable();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void deleteAlarmClassMap() {
|
||||
try {
|
||||
int n = this.mappingTableModel.getTable().getSelection().getRow();
|
||||
if (n < 0) {
|
||||
return;
|
||||
}
|
||||
this.mappingTableModel.removeRow(n);
|
||||
this.mappingTableModel.updateTable();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
class MappingTableController
|
||||
extends TableController {
|
||||
MappingTableController() {
|
||||
}
|
||||
|
||||
public void mouseReleased(BMouseEvent bMouseEvent) {
|
||||
super.mouseReleased(bMouseEvent);
|
||||
if (this.getTable().getSelection().getRowCount() > 0) {
|
||||
BAlarmClassMappingFE.this.removeMapCommand.setEnabled(true);
|
||||
} else {
|
||||
BAlarmClassMappingFE.this.removeMapCommand.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Controller
|
||||
extends TableController {
|
||||
Controller() {
|
||||
}
|
||||
|
||||
public void mouseReleased(BMouseEvent bMouseEvent) {
|
||||
super.mouseReleased(bMouseEvent);
|
||||
if (this.getTable().getSelection().getRowCount() > 0) {
|
||||
BAlarmClassMappingFE.this.editDefCommand.setEnabled(true);
|
||||
BAlarmClassMappingFE.this.delDefCommand.setEnabled(true);
|
||||
} else {
|
||||
BAlarmClassMappingFE.this.editDefCommand.setEnabled(false);
|
||||
BAlarmClassMappingFE.this.delDefCommand.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected void cellReleased(BMouseEvent bMouseEvent, int n, int n2) {
|
||||
super.cellReleased(bMouseEvent, n, n2);
|
||||
if (bMouseEvent.getClickCount() == 2) {
|
||||
BAlarmClassMappingFE.this.editAlarmClassDef();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MappingTableModel
|
||||
extends DefaultTableModel {
|
||||
BAlarmService alarmService = null;
|
||||
|
||||
public MappingTableModel() {
|
||||
super(new String[]{lexicon.getText("alarmClassMapper.alarmClass"), lexicon.getText("alarmClassMapper.definition")});
|
||||
}
|
||||
|
||||
public synchronized Object getValueAt(int n, int n2) {
|
||||
if (n2 == 0) {
|
||||
String string = super.getValueAt(n, n2).toString();
|
||||
return this.getAlarmService().getAlarmClassDisplayName(BString.make((String)string), null).toString();
|
||||
}
|
||||
return super.getValueAt(n, n2);
|
||||
}
|
||||
|
||||
public String getAlarmClassName(int n) {
|
||||
return super.getValueAt(n, 0).toString();
|
||||
}
|
||||
|
||||
private BAlarmService getAlarmService() {
|
||||
if (this.alarmService == null) {
|
||||
BWbShell bWbShell = BAlarmClassMappingFE.this.getWbShell();
|
||||
BOrd bOrd = BOrd.make((BOrd)bWbShell.getActiveOrd(), (String)"service:alarm:AlarmService");
|
||||
this.alarmService = (BAlarmService)bOrd.get();
|
||||
}
|
||||
return this.alarmService;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,302 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.ui.theme.Theme
|
||||
* com.tridium.workbench.bql.filter.ColumnNameTableModel
|
||||
* com.tridium.workbench.util.CollectionTableModel
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.collection.BITable
|
||||
* javax.baja.collection.ColumnList
|
||||
* javax.baja.gx.BBrush
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.nre.util.IntHashMap
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BLink
|
||||
* 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.BMenu
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.Command
|
||||
* javax.baja.ui.CommandArtifact
|
||||
* javax.baja.ui.ToggleCommand
|
||||
* javax.baja.ui.event.BMouseEvent
|
||||
* javax.baja.ui.table.BTable
|
||||
* javax.baja.ui.table.DynamicTableModel
|
||||
* javax.baja.ui.table.TableCellRenderer
|
||||
* javax.baja.ui.table.TableCellRenderer$Cell
|
||||
* javax.baja.ui.table.TableController
|
||||
* javax.baja.ui.table.TableModel
|
||||
* javax.baja.ui.util.BTitlePane
|
||||
* javax.baja.util.Lexicon
|
||||
* javax.baja.workbench.BWbShell
|
||||
* javax.baja.workbench.view.BWbComponentView
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.ui.theme.Theme;
|
||||
import com.tridium.workbench.bql.filter.ColumnNameTableModel;
|
||||
import com.tridium.workbench.util.CollectionTableModel;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.collection.BITable;
|
||||
import javax.baja.collection.ColumnList;
|
||||
import javax.baja.gx.BBrush;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.nre.util.IntHashMap;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BLink;
|
||||
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.BMenu;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.Command;
|
||||
import javax.baja.ui.CommandArtifact;
|
||||
import javax.baja.ui.ToggleCommand;
|
||||
import javax.baja.ui.event.BMouseEvent;
|
||||
import javax.baja.ui.table.BTable;
|
||||
import javax.baja.ui.table.DynamicTableModel;
|
||||
import javax.baja.ui.table.TableCellRenderer;
|
||||
import javax.baja.ui.table.TableController;
|
||||
import javax.baja.ui.table.TableModel;
|
||||
import javax.baja.ui.util.BTitlePane;
|
||||
import javax.baja.util.Lexicon;
|
||||
import javax.baja.workbench.BWbShell;
|
||||
import javax.baja.workbench.view.BWbComponentView;
|
||||
|
||||
public class BAlarmClassSummary
|
||||
extends BWbComponentView {
|
||||
public static final Action updateCommands = BAlarmClassSummary.newAction((int)4, null);
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BAlarmClassSummary == null ? (class$com$tridium$alarm$ui$BAlarmClassSummary = BAlarmClassSummary.class$("com.tridium.alarm.ui.BAlarmClassSummary")) : class$com$tridium$alarm$ui$BAlarmClassSummary));
|
||||
private static final String[] ATTRS = new String[]{"displayName", "totalAlarmCount", "openAlarmCount", "inAlarmCount", "unackedAlarmCount", "timeOfLastAlarm", "ackRequired", "priority", "toPathString"};
|
||||
private static final int[] DISPLAY = new int[]{0, 1, 2, 3, 4, 5};
|
||||
private static Lexicon lex = Lexicon.make((String)"alarm");
|
||||
private BTable table = new BTable();
|
||||
private BITable itable;
|
||||
private CollectionTableModel collectionModel;
|
||||
private ToggleCommand enableToOffnormal;
|
||||
private ToggleCommand enableToFault;
|
||||
private Command editAlarmClass;
|
||||
private IntHashMap nameMap;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmClassSummary;
|
||||
|
||||
public void updateCommands() {
|
||||
this.invoke(updateCommands, null, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BAlarmClassSummary() {
|
||||
this.table.setController((TableController)new Controller());
|
||||
this.table.setCellRenderer((TableCellRenderer)new CellRenderer());
|
||||
this.setContent((BWidget)BTitlePane.makePane((String)TYPE.getDisplayName(null), (BTable)this.table, (String)lex.getText("alarm.alarmClasses")));
|
||||
this.add("selectionLink", (BValue)new BLink((BComponent)this.table, (Slot)BTable.selectionModified, (Slot)updateCommands));
|
||||
this.nameMap = new IntHashMap();
|
||||
this.nameMap.put(0, (Object)"alarmClass.name");
|
||||
this.nameMap.put(1, (Object)"alarmClass.totalAlarmCount");
|
||||
this.nameMap.put(2, (Object)"alarmClass.openAlarmCount");
|
||||
this.nameMap.put(3, (Object)"alarmClass.inAlarmCount");
|
||||
this.nameMap.put(4, (Object)"alarmClass.unackedAlarmCount");
|
||||
this.nameMap.put(5, (Object)"alarmClass.timeOfLastAlarm");
|
||||
this.nameMap.put(6, (Object)"alarmClass.ackRequired");
|
||||
this.nameMap.put(7, (Object)"alarmClass.priority");
|
||||
}
|
||||
|
||||
protected void doLoadValue(BObject bObject, Context context) throws Exception {
|
||||
this.updateTable();
|
||||
this.table.fireTableModified(null);
|
||||
}
|
||||
|
||||
private void updateTable() {
|
||||
BOrd bOrd = ((BWbShell)this.getShell()).getActiveOrd();
|
||||
BOrd bOrd2 = BOrd.make((BOrd)bOrd, (String)this.query()).normalize();
|
||||
this.itable = ((BICollection)bOrd2.resolve().get()).toTable();
|
||||
boolean bl = false;
|
||||
int n = -1;
|
||||
boolean bl2 = true;
|
||||
if (this.table.getModel() instanceof AlarmClassSummaryTableModel) {
|
||||
bl = true;
|
||||
n = ((AlarmClassSummaryTableModel)this.table.getModel()).sortCol;
|
||||
bl2 = ((AlarmClassSummaryTableModel)this.table.getModel()).sortAsc;
|
||||
}
|
||||
this.collectionModel = new CollectionTableModel(this.itable, this.getCurrentContext());
|
||||
ColumnNameTableModel columnNameTableModel = new ColumnNameTableModel((TableModel)this.collectionModel, this.nameMap, lex);
|
||||
AlarmClassSummaryTableModel alarmClassSummaryTableModel = new AlarmClassSummaryTableModel((TableModel)columnNameTableModel, DISPLAY);
|
||||
alarmClassSummaryTableModel.setColumnShowable(1, false);
|
||||
alarmClassSummaryTableModel.setColumnShowable(6, false);
|
||||
if (bl && n != -1) {
|
||||
alarmClassSummaryTableModel.sortByColumn(n, bl2);
|
||||
}
|
||||
this.table.setModel((TableModel)alarmClassSummaryTableModel);
|
||||
this.table.relayout();
|
||||
}
|
||||
|
||||
private String query() {
|
||||
StringBuffer stringBuffer = new StringBuffer(128);
|
||||
stringBuffer.append("station:|slot:/|bql:select ");
|
||||
for (int i = 0; i < ATTRS.length; ++i) {
|
||||
if (i != 0) {
|
||||
stringBuffer.append(", ");
|
||||
}
|
||||
stringBuffer.append(ATTRS[i]);
|
||||
}
|
||||
stringBuffer.append(" from alarm:AlarmClass");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public void doUpdateCommands() {
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private class CellRenderer
|
||||
extends TableCellRenderer {
|
||||
private CellRenderer() {
|
||||
}
|
||||
|
||||
public BBrush getBackground(TableCellRenderer.Cell cell) {
|
||||
if (cell.row == this.getTable().getModel().getRowCount() - 2) {
|
||||
return Theme.table().getGridBrush();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class AlarmClassSummaryTableModel
|
||||
extends DynamicTableModel {
|
||||
public int sortCol = -1;
|
||||
public boolean sortAsc = true;
|
||||
|
||||
public AlarmClassSummaryTableModel(TableModel tableModel, int[] nArray) {
|
||||
super(tableModel, nArray);
|
||||
}
|
||||
|
||||
public AlarmClassSummaryTableModel(TableModel tableModel) {
|
||||
super(tableModel);
|
||||
}
|
||||
|
||||
public void sortByColumn(int n, boolean bl) {
|
||||
this.sortCol = n;
|
||||
this.sortAsc = bl;
|
||||
super.sortByColumn(n, bl);
|
||||
}
|
||||
|
||||
public Object getValueAt(int n, int n2) {
|
||||
if (n < super.getRowCount()) {
|
||||
return super.getValueAt(n, n2);
|
||||
}
|
||||
if (n == super.getRowCount()) {
|
||||
return "";
|
||||
}
|
||||
switch (n2) {
|
||||
case 0: {
|
||||
return lex.getText("alarmClass.total");
|
||||
}
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4: {
|
||||
int n3 = 0;
|
||||
for (int i = 0; i < super.getRowCount(); ++i) {
|
||||
n3 += Integer.parseInt((String)this.getValueAt(i, n2));
|
||||
}
|
||||
return "" + n3;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public int getRowCount() {
|
||||
return super.getRowCount() + 2;
|
||||
}
|
||||
}
|
||||
|
||||
public class GotoPoint
|
||||
extends Goto {
|
||||
public GotoPoint(int n, BITable bITable) {
|
||||
super("alarmClass.goto.alarmClass", n, bITable);
|
||||
}
|
||||
|
||||
public BOrd getTargetOrd() {
|
||||
return BOrd.make((String)("slot:" + BAlarmClassSummary.this.itable.getString(this.row, BAlarmClassSummary.this.itable.getColumns().get("toPathString"))));
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class Goto
|
||||
extends Command {
|
||||
int row;
|
||||
BITable itable;
|
||||
|
||||
public Goto(String string, int n, BITable bITable) {
|
||||
super((BWidget)BAlarmClassSummary.this, Sys.getModuleForClass((Class)(class$com$tridium$alarm$ui$BAlarmClassSummary == null ? (class$com$tridium$alarm$ui$BAlarmClassSummary = BAlarmClassSummary.class$("com.tridium.alarm.ui.BAlarmClassSummary")) : class$com$tridium$alarm$ui$BAlarmClassSummary)), string);
|
||||
this.row = n;
|
||||
this.itable = bITable;
|
||||
}
|
||||
|
||||
public abstract BOrd getTargetOrd();
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BOrd bOrd = this.getTargetOrd();
|
||||
if (bOrd == null) {
|
||||
return null;
|
||||
}
|
||||
BOrd bOrd2 = ((BWbShell)BAlarmClassSummary.this.getShell()).getActiveOrd();
|
||||
BOrd bOrd3 = BOrd.make((BOrd)bOrd2, (BOrd)bOrd).normalize();
|
||||
((BWbShell)this.getShell()).hyperlink(bOrd3);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class Controller
|
||||
extends TableController {
|
||||
private Controller() {
|
||||
}
|
||||
|
||||
protected void cellDoubleClicked(BMouseEvent bMouseEvent, int n, int n2) {
|
||||
if (n >= this.getTable().getModel().getRowCount() - 2) {
|
||||
return;
|
||||
}
|
||||
ColumnList columnList = BAlarmClassSummary.this.itable.getColumns();
|
||||
BOrd bOrd = null;
|
||||
String string = BAlarmClassSummary.this.itable.getString(n, columnList.get("toPathString"));
|
||||
BOrd bOrd2 = ((BWbShell)this.getShell()).getActiveOrd();
|
||||
bOrd = BOrd.make((BOrd)bOrd2, (String)("slot:" + string)).normalize();
|
||||
if (bOrd != null) {
|
||||
((BWbShell)this.getShell()).hyperlink(bOrd);
|
||||
}
|
||||
}
|
||||
|
||||
protected void cellPopup(BMouseEvent bMouseEvent, int n, int n2) {
|
||||
if (n >= this.getTable().getModel().getRowCount() - 2) {
|
||||
return;
|
||||
}
|
||||
ColumnList columnList = BAlarmClassSummary.this.itable.getColumns();
|
||||
String string = BAlarmClassSummary.this.itable.getString(n, columnList.get("toPathString"));
|
||||
BOrd bOrd = ((BWbShell)this.getShell()).getActiveOrd();
|
||||
BOrd bOrd2 = BOrd.make((BOrd)bOrd, (String)("slot:" + string)).normalize();
|
||||
BComponent bComponent = (BComponent)bOrd2.get();
|
||||
BMenu bMenu = new BMenu();
|
||||
bMenu.add(null, (Command)new GotoPoint(n, BAlarmClassSummary.this.itable));
|
||||
bMenu.open((BWidget)this.getTable(), bMouseEvent.getX(), bMouseEvent.getY());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,263 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.bql.filter.BFilterEntry
|
||||
* com.tridium.bql.filter.BFilterSet
|
||||
* com.tridium.ui.UiEnv
|
||||
* com.tridium.ui.theme.Theme
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.gx.BBrush$Solid
|
||||
* javax.baja.gx.BColor
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BRelTime
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.BVector
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Slot
|
||||
* javax.baja.sys.SlotCursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.options.BUserOptions
|
||||
* javax.baja.ui.util.UiLexicon
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.alarm.ui.BAlarmClassMapping;
|
||||
import com.tridium.alarm.ui.BAlarmDataCols;
|
||||
import com.tridium.alarm.ui.BTimeZoneDisplay;
|
||||
import com.tridium.bql.filter.BFilterEntry;
|
||||
import com.tridium.bql.filter.BFilterSet;
|
||||
import com.tridium.ui.UiEnv;
|
||||
import com.tridium.ui.theme.Theme;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.gx.BBrush;
|
||||
import javax.baja.gx.BColor;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BRelTime;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.BVector;
|
||||
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;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.options.BUserOptions;
|
||||
import javax.baja.ui.util.UiLexicon;
|
||||
|
||||
public class BAlarmConsoleOptions
|
||||
extends BUserOptions {
|
||||
public static final Property notesRequiredOnAck = BAlarmConsoleOptions.newProperty((int)0, (boolean)false, null);
|
||||
public static final Property soundsEnabled = BAlarmConsoleOptions.newProperty((int)0, (boolean)true, null);
|
||||
public static final Property defaultSoundFile = BAlarmConsoleOptions.newProperty((int)0, (BValue)BOrd.make((String)"module://alarm/com/tridium/alarm/ui/sounds/smallBeep.wav"), (BFacets)BFacets.make((String)"targetType", (BIDataValue)BString.make((String)"file:AudioFile")));
|
||||
public static final Property continuousAlarm = BAlarmConsoleOptions.newProperty((int)0, (boolean)false, null);
|
||||
public static final Property continuousAlarmDelay = BAlarmConsoleOptions.newProperty((int)0, (BValue)BRelTime.make((long)10000L), null);
|
||||
public static final Property alarmFilters = BAlarmConsoleOptions.newProperty((int)4, (BValue)new BFilterSet(), null);
|
||||
public static final Property lowPriorityColor = BAlarmConsoleOptions.newProperty((int)0, (BValue)((BBrush.Solid)Theme.table().getWindowBackground().getPaint()).getColor(), null);
|
||||
public static final Property midPriorityColor = BAlarmConsoleOptions.newProperty((int)0, (BValue)((BBrush.Solid)Theme.table().getWindowBackground().getPaint()).getColor(), null);
|
||||
public static final Property highPriorityColor = BAlarmConsoleOptions.newProperty((int)0, (BValue)((BBrush.Solid)Theme.table().getWindowBackground().getPaint()).getColor(), null);
|
||||
public static final Property timeZoneDisplay = BAlarmConsoleOptions.newProperty((int)0, (BValue)BTimeZoneDisplay.console, null);
|
||||
public static final Property displayColumns = BAlarmConsoleOptions.newProperty((int)4, (String)"0,2,3,5,6,7,14", null);
|
||||
public static final Property sortColumn = BAlarmConsoleOptions.newProperty((int)4, (int)7, null);
|
||||
public static final Property sortAscending = BAlarmConsoleOptions.newProperty((int)4, (boolean)true, null);
|
||||
public static final Property alarmDataCols = BAlarmConsoleOptions.newProperty((int)4, (BValue)new BAlarmDataCols(new String[]{"msgText"}), null);
|
||||
public static final Property alarmClassMapping = BAlarmConsoleOptions.newProperty((int)0, (BValue)new BAlarmClassMapping(), (BFacets)BFacets.make((String)"fieldEditor", (BIDataValue)BString.make((String)"alarm:AlarmClassMappingFE")));
|
||||
public static final Property alarmAckResponses = BAlarmConsoleOptions.newProperty((int)0, (BValue)new BVector(), (BFacets)BFacets.make((String)"fieldEditor", (BIDataValue)BString.make((String)"alarm:StringListFE")));
|
||||
public static final Property viewInstructions = BAlarmConsoleOptions.newProperty((int)0, (boolean)false, null);
|
||||
public static final Property instructionsDividerPosition = BAlarmConsoleOptions.newProperty((int)4, (int)80, null);
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BAlarmConsoleOptions == null ? (class$com$tridium$alarm$ui$BAlarmConsoleOptions = BAlarmConsoleOptions.class$("com.tridium.alarm.ui.BAlarmConsoleOptions")) : class$com$tridium$alarm$ui$BAlarmConsoleOptions));
|
||||
private static BAlarmConsoleOptions options;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmConsoleOptions;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmConsole;
|
||||
static /* synthetic */ Class class$com$tridium$bql$filter$BFilterEntry;
|
||||
|
||||
public boolean getNotesRequiredOnAck() {
|
||||
return this.getBoolean(notesRequiredOnAck);
|
||||
}
|
||||
|
||||
public void setNotesRequiredOnAck(boolean bl) {
|
||||
this.setBoolean(notesRequiredOnAck, bl, null);
|
||||
}
|
||||
|
||||
public boolean getSoundsEnabled() {
|
||||
return this.getBoolean(soundsEnabled);
|
||||
}
|
||||
|
||||
public void setSoundsEnabled(boolean bl) {
|
||||
this.setBoolean(soundsEnabled, bl, null);
|
||||
}
|
||||
|
||||
public BOrd getDefaultSoundFile() {
|
||||
return (BOrd)this.get(defaultSoundFile);
|
||||
}
|
||||
|
||||
public void setDefaultSoundFile(BOrd bOrd) {
|
||||
this.set(defaultSoundFile, (BValue)bOrd, null);
|
||||
}
|
||||
|
||||
public boolean getContinuousAlarm() {
|
||||
return this.getBoolean(continuousAlarm);
|
||||
}
|
||||
|
||||
public void setContinuousAlarm(boolean bl) {
|
||||
this.setBoolean(continuousAlarm, bl, null);
|
||||
}
|
||||
|
||||
public BRelTime getContinuousAlarmDelay() {
|
||||
return (BRelTime)this.get(continuousAlarmDelay);
|
||||
}
|
||||
|
||||
public void setContinuousAlarmDelay(BRelTime bRelTime) {
|
||||
this.set(continuousAlarmDelay, (BValue)bRelTime, null);
|
||||
}
|
||||
|
||||
public BFilterSet getAlarmFilters() {
|
||||
return (BFilterSet)this.get(alarmFilters);
|
||||
}
|
||||
|
||||
public void setAlarmFilters(BFilterSet bFilterSet) {
|
||||
this.set(alarmFilters, (BValue)bFilterSet, null);
|
||||
}
|
||||
|
||||
public BColor getLowPriorityColor() {
|
||||
return (BColor)this.get(lowPriorityColor);
|
||||
}
|
||||
|
||||
public void setLowPriorityColor(BColor bColor) {
|
||||
this.set(lowPriorityColor, (BValue)bColor, null);
|
||||
}
|
||||
|
||||
public BColor getMidPriorityColor() {
|
||||
return (BColor)this.get(midPriorityColor);
|
||||
}
|
||||
|
||||
public void setMidPriorityColor(BColor bColor) {
|
||||
this.set(midPriorityColor, (BValue)bColor, null);
|
||||
}
|
||||
|
||||
public BColor getHighPriorityColor() {
|
||||
return (BColor)this.get(highPriorityColor);
|
||||
}
|
||||
|
||||
public void setHighPriorityColor(BColor bColor) {
|
||||
this.set(highPriorityColor, (BValue)bColor, null);
|
||||
}
|
||||
|
||||
public BTimeZoneDisplay getTimeZoneDisplay() {
|
||||
return (BTimeZoneDisplay)this.get(timeZoneDisplay);
|
||||
}
|
||||
|
||||
public void setTimeZoneDisplay(BTimeZoneDisplay bTimeZoneDisplay) {
|
||||
this.set(timeZoneDisplay, (BValue)bTimeZoneDisplay, null);
|
||||
}
|
||||
|
||||
public String getDisplayColumns() {
|
||||
return this.getString(displayColumns);
|
||||
}
|
||||
|
||||
public void setDisplayColumns(String string) {
|
||||
this.setString(displayColumns, string, null);
|
||||
}
|
||||
|
||||
public int getSortColumn() {
|
||||
return this.getInt(sortColumn);
|
||||
}
|
||||
|
||||
public void setSortColumn(int n) {
|
||||
this.setInt(sortColumn, n, null);
|
||||
}
|
||||
|
||||
public boolean getSortAscending() {
|
||||
return this.getBoolean(sortAscending);
|
||||
}
|
||||
|
||||
public void setSortAscending(boolean bl) {
|
||||
this.setBoolean(sortAscending, bl, null);
|
||||
}
|
||||
|
||||
public BVector getAlarmDataCols() {
|
||||
return (BVector)this.get(alarmDataCols);
|
||||
}
|
||||
|
||||
public void setAlarmDataCols(BVector bVector) {
|
||||
this.set(alarmDataCols, (BValue)bVector, null);
|
||||
}
|
||||
|
||||
public BAlarmClassMapping getAlarmClassMapping() {
|
||||
return (BAlarmClassMapping)this.get(alarmClassMapping);
|
||||
}
|
||||
|
||||
public void setAlarmClassMapping(BAlarmClassMapping bAlarmClassMapping) {
|
||||
this.set(alarmClassMapping, (BValue)bAlarmClassMapping, null);
|
||||
}
|
||||
|
||||
public BVector getAlarmAckResponses() {
|
||||
return (BVector)this.get(alarmAckResponses);
|
||||
}
|
||||
|
||||
public void setAlarmAckResponses(BVector bVector) {
|
||||
this.set(alarmAckResponses, (BValue)bVector, null);
|
||||
}
|
||||
|
||||
public boolean getViewInstructions() {
|
||||
return this.getBoolean(viewInstructions);
|
||||
}
|
||||
|
||||
public void setViewInstructions(boolean bl) {
|
||||
this.setBoolean(viewInstructions, bl, null);
|
||||
}
|
||||
|
||||
public double getInstructionsDividerPosition() {
|
||||
return this.getDouble(instructionsDividerPosition);
|
||||
}
|
||||
|
||||
public void setInstructionsDividerPosition(double d) {
|
||||
this.setDouble(instructionsDividerPosition, d, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BAlarmConsoleOptions() {
|
||||
if (UiEnv.get().isMicroEdition()) {
|
||||
int n = this.getFlags((Slot)defaultSoundFile);
|
||||
this.setFlags((Slot)defaultSoundFile, n | 4);
|
||||
}
|
||||
}
|
||||
|
||||
public static BAlarmConsoleOptions getDefault() {
|
||||
if (options == null) {
|
||||
options = BWidget.getApplication() == null ? new BAlarmConsoleOptions() : (BAlarmConsoleOptions)BAlarmConsoleOptions.load((Type)TYPE);
|
||||
UiLexicon uiLexicon = new UiLexicon(class$com$tridium$alarm$ui$BAlarmConsole == null ? (class$com$tridium$alarm$ui$BAlarmConsole = BAlarmConsoleOptions.class$("com.tridium.alarm.ui.BAlarmConsole")) : class$com$tridium$alarm$ui$BAlarmConsole);
|
||||
SlotCursor slotCursor = options.getAlarmFilters().getProperties();
|
||||
while (slotCursor.next(class$com$tridium$bql$filter$BFilterEntry == null ? BAlarmConsoleOptions.class$("com.tridium.bql.filter.BFilterEntry") : class$com$tridium$bql$filter$BFilterEntry)) {
|
||||
BFilterEntry bFilterEntry = (BFilterEntry)slotCursor.get();
|
||||
bFilterEntry.setLabel(uiLexicon.getText(bFilterEntry.getName()));
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
if (BWidget.getApplication() != null) {
|
||||
super.save();
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,294 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.pdf.BPdfFlowPane
|
||||
* com.tridium.pdf.BWidgetToPdf
|
||||
* com.tridium.pdf.gx.PdfDocument
|
||||
* javax.baja.gx.BFont
|
||||
* javax.baja.gx.Insets
|
||||
* javax.baja.pdf.BPdfExporter
|
||||
* javax.baja.pdf.PdfOp
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.enums.BHalign
|
||||
* javax.baja.ui.table.BTable
|
||||
* javax.baja.ui.table.TableModel
|
||||
* javax.baja.ui.table.TableSelection
|
||||
* javax.baja.util.BFormat
|
||||
* javax.baja.util.Lexicon
|
||||
* javax.baja.workbench.view.BIWbViewExporter
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.alarm.BConsoleRecipient;
|
||||
import com.tridium.alarm.ui.BAlarmConsole;
|
||||
import com.tridium.pdf.BPdfFlowPane;
|
||||
import com.tridium.pdf.BWidgetToPdf;
|
||||
import com.tridium.pdf.gx.PdfDocument;
|
||||
import java.util.ArrayList;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.gx.BFont;
|
||||
import javax.baja.gx.Insets;
|
||||
import javax.baja.pdf.BPdfExporter;
|
||||
import javax.baja.pdf.PdfOp;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BLabel;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.enums.BHalign;
|
||||
import javax.baja.ui.table.BTable;
|
||||
import javax.baja.ui.table.TableModel;
|
||||
import javax.baja.ui.table.TableSelection;
|
||||
import javax.baja.util.BFormat;
|
||||
import javax.baja.util.Lexicon;
|
||||
import javax.baja.workbench.view.BIWbViewExporter;
|
||||
|
||||
public class BAlarmConsoleToPdf
|
||||
extends BPdfExporter
|
||||
implements BIWbViewExporter {
|
||||
public static final Property showAllColumns = BAlarmConsoleToPdf.newProperty((int)0, (boolean)false, null);
|
||||
public static final Property showOnlySelectedRows = BAlarmConsoleToPdf.newProperty((int)0, (boolean)false, null);
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BAlarmConsoleToPdf == null ? (class$com$tridium$alarm$ui$BAlarmConsoleToPdf = BAlarmConsoleToPdf.class$("com.tridium.alarm.ui.BAlarmConsoleToPdf")) : class$com$tridium$alarm$ui$BAlarmConsoleToPdf));
|
||||
private BPdfFlowPane pane;
|
||||
private PdfDocument doc;
|
||||
private PdfOp op;
|
||||
private String msgTxt = null;
|
||||
private String notesTxt = null;
|
||||
private boolean showAlarmData = false;
|
||||
private static Lexicon lex = Lexicon.make((String)"alarm");
|
||||
private static final int MAXSTR = 70;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmConsoleToPdf;
|
||||
|
||||
public boolean getShowAllColumns() {
|
||||
return this.getBoolean(showAllColumns);
|
||||
}
|
||||
|
||||
public void setShowAllColumns(boolean bl) {
|
||||
this.setBoolean(showAllColumns, bl, null);
|
||||
}
|
||||
|
||||
public boolean getShowOnlySelectedRows() {
|
||||
return this.getBoolean(showOnlySelectedRows);
|
||||
}
|
||||
|
||||
public void setShowOnlySelectedRows(boolean bl) {
|
||||
this.setBoolean(showOnlySelectedRows, bl, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public void export(PdfOp pdfOp) throws Exception {
|
||||
this.op = pdfOp;
|
||||
BAlarmConsole bAlarmConsole = (BAlarmConsole)pdfOp.get();
|
||||
TableModel tableModel = bAlarmConsole.sourceTable.getModel();
|
||||
TableSelection tableSelection = bAlarmConsole.sourceTable.getController().getSelection();
|
||||
BWidgetToPdf bWidgetToPdf = new BWidgetToPdf();
|
||||
this.doc = new PdfDocument(pdfOp.getOutputStream(), pdfOp.getWidth(), pdfOp.getHeight());
|
||||
this.pane = new BPdfFlowPane();
|
||||
this.makeHeader(bAlarmConsole.recipient);
|
||||
for (int i = 0; i < tableModel.getRowCount(); ++i) {
|
||||
if (this.getShowOnlySelectedRows() && (!this.getShowOnlySelectedRows() || !tableSelection.isSelected(i))) continue;
|
||||
this.makeRecord(tableModel, i);
|
||||
}
|
||||
this.pane.setupPane();
|
||||
bWidgetToPdf.renderDocument((BWidget)this.pane, this.doc, pdfOp);
|
||||
}
|
||||
|
||||
private void makeHeader(BConsoleRecipient bConsoleRecipient) {
|
||||
BFont bFont = BFont.make((String)lex.getText("alarmConsoleToPdf.font.reportHeader"));
|
||||
BFont bFont2 = BFont.make((String)lex.getText("alarmConsoleToPdf.font.normal"));
|
||||
BLabel bLabel = new BLabel(lex.getText("alarmConsoleToPdf.header") + " " + bConsoleRecipient.getDisplayName((Context)this.op));
|
||||
bLabel.setHalign(BHalign.left);
|
||||
bLabel.setFont(bFont);
|
||||
this.pane.add(null, (BValue)bLabel);
|
||||
BLabel bLabel2 = new BLabel(BAbsTime.now().toString((Context)this.op), bFont2, BHalign.left);
|
||||
this.pane.add(null, (BValue)bLabel2);
|
||||
}
|
||||
|
||||
private void makeRecord(TableModel tableModel, int n) {
|
||||
BFacets bFacets;
|
||||
this.notesTxt = null;
|
||||
this.msgTxt = null;
|
||||
BAlarmRecord bAlarmRecord = (BAlarmRecord)((Object)tableModel.getSubject(n));
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
BString bString = (BString)bAlarmRecord.getAlarmData().get("sourceName");
|
||||
if (bString != null && bString != BString.DEFAULT) {
|
||||
stringBuffer.append(BFormat.make((String)bString.toString((Context)this.op)).format((Object)bAlarmRecord));
|
||||
} else {
|
||||
stringBuffer.append(bAlarmRecord.get(BAlarmRecord.source).toString((Context)this.op));
|
||||
}
|
||||
stringBuffer.append(" - ").append(bAlarmRecord.getSourceState().toString((Context)this.op)).append(" / ");
|
||||
stringBuffer.append(bAlarmRecord.getAckState().toString((Context)this.op));
|
||||
BLabel bLabel = new BLabel(stringBuffer.toString(), BFont.make((String)lex.getText("alarmConsoleToPdf.font.source")), BHalign.left);
|
||||
bLabel.setImage(tableModel.getRowIcon(n));
|
||||
ArrayList<String> arrayList = new ArrayList<String>();
|
||||
ArrayList<String> arrayList2 = new ArrayList<String>();
|
||||
this.buildColumnsAndValues(arrayList, arrayList2, tableModel, n);
|
||||
if (this.showAlarmData) {
|
||||
bFacets = bAlarmRecord.getAlarmData();
|
||||
String[] stringArray = bFacets.list();
|
||||
arrayList.add("");
|
||||
arrayList2.add("");
|
||||
for (int i = 0; i < stringArray.length; ++i) {
|
||||
String string = bFacets.get(stringArray[i]).toString((Context)this.op);
|
||||
if (stringArray[i].equals("notes")) {
|
||||
this.notesTxt = string;
|
||||
continue;
|
||||
}
|
||||
arrayList.add("Alarm Data (" + stringArray[i] + ")");
|
||||
if (stringArray[i].equals("msgText") && string.length() > 70) {
|
||||
string = string.substring(0, 68) + "...";
|
||||
}
|
||||
arrayList2.add(string);
|
||||
}
|
||||
}
|
||||
bFacets = new BTable((TableModel)new Model(arrayList, arrayList2));
|
||||
this.pane.add(null, (BValue)new BLabel(""));
|
||||
this.pane.add(null, (BValue)bLabel);
|
||||
this.pane.add(null, (BValue)bFacets);
|
||||
if (this.msgTxt != null) {
|
||||
this.buildMultiLineLabels("Message", this.msgTxt, ' ');
|
||||
}
|
||||
if (this.notesTxt != null) {
|
||||
this.pane.add(null, (BValue)new BLabel(""));
|
||||
this.buildMultiLineLabels("Note", this.notesTxt, ' ');
|
||||
}
|
||||
}
|
||||
|
||||
private void buildColumnsAndValues(ArrayList arrayList, ArrayList arrayList2, TableModel tableModel, int n) {
|
||||
if (this.getShowAllColumns()) {
|
||||
String[] stringArray = tableModel.getColumnNames();
|
||||
for (int i = 0; i < stringArray.length; ++i) {
|
||||
String string = stringArray[i];
|
||||
if (string.equals("Msg Text")) {
|
||||
this.msgTxt = tableModel.getRowValues(n)[i].toString();
|
||||
if (this.msgTxt.length() > 70 || this.msgTxt.length() == 0) continue;
|
||||
this.msgTxt = null;
|
||||
} else if (string.equals("Alarm Data")) {
|
||||
this.showAlarmData = true;
|
||||
continue;
|
||||
}
|
||||
arrayList.add(string);
|
||||
arrayList2.add(tableModel.getRowValues(n)[i]);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < tableModel.getColumnCount(); ++i) {
|
||||
String string = tableModel.getColumnName(i);
|
||||
if (string.equals("Msg Text")) {
|
||||
this.msgTxt = tableModel.getValueAt(n, i).toString();
|
||||
if (this.msgTxt.length() > 70 || this.msgTxt.length() == 0) continue;
|
||||
this.msgTxt = null;
|
||||
} else if (string.equals("Alarm Data")) {
|
||||
this.showAlarmData = true;
|
||||
continue;
|
||||
}
|
||||
arrayList.add(string);
|
||||
arrayList2.add(tableModel.getValueAt(n, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buildMultiLineLabels(String string, String string2, char c) {
|
||||
if (string2 == null || string2.length() == 0) {
|
||||
return;
|
||||
}
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(string).append(": ").append(string2);
|
||||
BLabel[] bLabelArray = this.split(stringBuffer.toString(), c);
|
||||
for (int i = 0; i < bLabelArray.length; ++i) {
|
||||
this.pane.add(null, (BValue)bLabelArray[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private BLabel[] split(String string, char c) {
|
||||
BFont bFont = BFont.make((String)lex.getText("alarmConsoleToPdf.font.normal"));
|
||||
Insets insets = this.doc.getMargins();
|
||||
double d = this.doc.getPageSize().width - insets.right;
|
||||
ArrayList<BLabel> arrayList = new ArrayList<BLabel>();
|
||||
String string2 = string;
|
||||
while (bFont.width(string2) > d) {
|
||||
int n;
|
||||
int n2 = string2.indexOf(c, 0);
|
||||
boolean bl = false;
|
||||
if (n2 == -1 || bFont.width(string2.substring(0, n2)) > d) {
|
||||
bl = true;
|
||||
n = 1;
|
||||
while (bFont.width(string2.substring(0, n)) < d) {
|
||||
++n;
|
||||
}
|
||||
n2 = n - 2;
|
||||
} else {
|
||||
n = n2;
|
||||
String string3 = string2.substring(0, n2 + 1);
|
||||
while (bFont.width(string3) < d && n != -1) {
|
||||
n2 = n;
|
||||
n = string2.indexOf(c, n + 1);
|
||||
string3 = string2.substring(0, n + 1);
|
||||
}
|
||||
}
|
||||
String string4 = string2.substring(0, n2 + 1);
|
||||
if (bl) {
|
||||
string4 = string4 + "-";
|
||||
}
|
||||
string2 = string2.substring(n2 + 1);
|
||||
arrayList.add(new BLabel(string4, bFont, BHalign.left));
|
||||
}
|
||||
arrayList.add(new BLabel(string2, bFont, BHalign.left));
|
||||
return arrayList.toArray(new BLabel[arrayList.size()]);
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
class Model
|
||||
extends TableModel {
|
||||
private String[] cols = new String[]{"Attribute", "Value"};
|
||||
private ArrayList names = new ArrayList();
|
||||
private ArrayList values = new ArrayList();
|
||||
|
||||
public Model(ArrayList arrayList, ArrayList arrayList2) {
|
||||
this.names = arrayList;
|
||||
this.values = arrayList2;
|
||||
}
|
||||
|
||||
public int getRowCount() {
|
||||
return this.names.size();
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
return this.cols.length;
|
||||
}
|
||||
|
||||
public String getColumnName(int n) {
|
||||
return this.cols[n];
|
||||
}
|
||||
|
||||
public Object getValueAt(int n, int n2) {
|
||||
return n2 == 0 ? this.names.get(n) : this.values.get(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,269 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.fox.message.FoxMessage
|
||||
* com.tridium.fox.message.FoxTuple
|
||||
* com.tridium.fox.session.FoxRequest
|
||||
* com.tridium.fox.session.FoxResponse
|
||||
* com.tridium.fox.session.InvalidCommandException
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.nre.util.Array
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.alarm.BAlarmConsoleChannel;
|
||||
import com.tridium.alarm.BConsoleRecipient;
|
||||
import com.tridium.alarm.fox.FoxAlarmCodec;
|
||||
import com.tridium.alarm.ui.BAlarmConsole;
|
||||
import com.tridium.alarm.ui.portal.BAlarmPortalTool;
|
||||
import com.tridium.alarm.ui.portal.BPortalAlarmConsole;
|
||||
import com.tridium.fox.message.FoxMessage;
|
||||
import com.tridium.fox.message.FoxTuple;
|
||||
import com.tridium.fox.session.FoxRequest;
|
||||
import com.tridium.fox.session.FoxResponse;
|
||||
import com.tridium.fox.session.InvalidCommandException;
|
||||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.util.HashMap;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.nre.util.Array;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
public class BAlarmConsoleUIChannel
|
||||
extends BAlarmConsoleChannel {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BAlarmConsoleUIChannel == null ? (class$com$tridium$alarm$ui$BAlarmConsoleUIChannel = BAlarmConsoleUIChannel.class$("com.tridium.alarm.ui.BAlarmConsoleUIChannel")) : class$com$tridium$alarm$ui$BAlarmConsoleUIChannel));
|
||||
private Array recips = new Array(class$java$lang$String == null ? (class$java$lang$String = BAlarmConsoleUIChannel.class$("java.lang.String")) : class$java$lang$String);
|
||||
private Array consoles = new Array(class$com$tridium$alarm$ui$BAlarmConsole == null ? (class$com$tridium$alarm$ui$BAlarmConsole = BAlarmConsoleUIChannel.class$("com.tridium.alarm.ui.BAlarmConsole")) : class$com$tridium$alarm$ui$BAlarmConsole);
|
||||
private HashMap recipOrdMap = new HashMap();
|
||||
private BAlarmPortalTool tool;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmConsoleUIChannel;
|
||||
static /* synthetic */ Class class$java$lang$String;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmConsole;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BAlarmConsoleUIChannel() {
|
||||
super("alarmui");
|
||||
}
|
||||
|
||||
public FoxResponse process(FoxRequest foxRequest) throws Exception {
|
||||
String string = foxRequest.command;
|
||||
if (this.isTraceOn()) {
|
||||
this.trace("AlarmConsoleChannel: command = " + string);
|
||||
}
|
||||
if (string == "new") {
|
||||
return this.newAlarms(foxRequest);
|
||||
}
|
||||
if (string == "error") {
|
||||
return this.error(foxRequest);
|
||||
}
|
||||
throw new InvalidCommandException(string);
|
||||
}
|
||||
|
||||
private FoxResponse newAlarms(FoxRequest foxRequest) {
|
||||
if (this.isTraceOn()) {
|
||||
this.trace("recieved: new");
|
||||
foxRequest.dump();
|
||||
}
|
||||
FoxTuple[] foxTupleArray = foxRequest.list("alarmRec");
|
||||
for (int i = 0; i < foxTupleArray.length; ++i) {
|
||||
try {
|
||||
BAlarmRecord bAlarmRecord = FoxAlarmCodec.decodeAlarm(((FoxMessage)foxTupleArray[i]).getMessage("alarm"));
|
||||
String string = ((FoxMessage)foxTupleArray[i]).getString("ord");
|
||||
BAlarmConsole[] bAlarmConsoleArray = this.getConsolesRegisteredOn(string);
|
||||
for (int j = 0; j < bAlarmConsoleArray.length; ++j) {
|
||||
BOrd bOrd;
|
||||
BAlarmRecord bAlarmRecord2;
|
||||
BOrdList bOrdList;
|
||||
if (bAlarmConsoleArray[j] == null) {
|
||||
bOrdList = bAlarmRecord.getSource();
|
||||
bAlarmRecord2 = (BAlarmRecord)bAlarmRecord.newCopy();
|
||||
bOrd = (BOrd)this.recipOrdMap.get(string);
|
||||
if (bOrd == null) continue;
|
||||
bOrdList = BOrdList.add((BOrdList)bOrdList, (BOrd)bOrd);
|
||||
bAlarmRecord2.setSource(bOrdList);
|
||||
this.tool.processAlarm(bAlarmRecord2);
|
||||
continue;
|
||||
}
|
||||
if (bAlarmConsoleArray[j] instanceof BPortalAlarmConsole) {
|
||||
bOrdList = bAlarmRecord.getSource();
|
||||
bAlarmRecord2 = (BAlarmRecord)bAlarmRecord.newCopy();
|
||||
bOrd = (BOrd)this.recipOrdMap.get(string);
|
||||
if (bOrd == null) continue;
|
||||
bOrdList = BOrdList.add((BOrdList)bOrdList, (BOrd)bOrd);
|
||||
bAlarmRecord2.setSource(bOrdList);
|
||||
bAlarmConsoleArray[j].processAlarm(bAlarmRecord2);
|
||||
continue;
|
||||
}
|
||||
bAlarmConsoleArray[j].processAlarm(bAlarmRecord);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void ackAlarms(BConsoleRecipient bConsoleRecipient, BAlarmRecord[] bAlarmRecordArray) throws Exception {
|
||||
int n;
|
||||
int n2 = 100;
|
||||
int n3 = 0;
|
||||
int n4 = n = n2 < bAlarmRecordArray.length ? n2 : bAlarmRecordArray.length;
|
||||
while (n3 < bAlarmRecordArray.length) {
|
||||
int n5;
|
||||
FoxRequest foxRequest = this.makeRequest("ack");
|
||||
foxRequest.add("ord", bConsoleRecipient.getOrdInSession().encodeToString());
|
||||
int n6 = 0;
|
||||
for (n5 = n3; n5 < n; ++n5) {
|
||||
++n6;
|
||||
foxRequest.add("alarm", FoxAlarmCodec.encodeAlarm(bAlarmRecordArray[n5]));
|
||||
}
|
||||
if (this.isTraceOn()) {
|
||||
this.trace("sending: ack");
|
||||
}
|
||||
n5 = foxRequest.list("alarm").length;
|
||||
this.sendAsync(foxRequest);
|
||||
n3 = n;
|
||||
n = (n += n2) < bAlarmRecordArray.length ? n : bAlarmRecordArray.length;
|
||||
}
|
||||
}
|
||||
|
||||
public String getInitialAlarmQuery(BAlarmConsole bAlarmConsole, BConsoleRecipient bConsoleRecipient) throws Exception {
|
||||
return this.getInitialAlarmQuery(bAlarmConsole, bConsoleRecipient, BOrd.NULL);
|
||||
}
|
||||
|
||||
public String getInitialAlarmQuery(BAlarmPortalTool bAlarmPortalTool, BConsoleRecipient bConsoleRecipient) throws Exception {
|
||||
this.tool = bAlarmPortalTool;
|
||||
return this.getInitialAlarmQuery(null, bConsoleRecipient, BOrd.NULL);
|
||||
}
|
||||
|
||||
public String getInitialAlarmQuery(BAlarmConsole bAlarmConsole, BConsoleRecipient bConsoleRecipient, BOrd bOrd) throws Exception {
|
||||
FoxRequest foxRequest = this.makeRequest("getInitialAlarmQuery");
|
||||
String string = bConsoleRecipient.getOrdInSession().encodeToString();
|
||||
foxRequest.add("ord", string);
|
||||
if (bOrd != null && !bOrd.isNull()) {
|
||||
this.recipOrdMap.put(string, bOrd);
|
||||
}
|
||||
try {
|
||||
FoxResponse foxResponse = this.sendSync(foxRequest);
|
||||
String string2 = foxResponse.getString("error", null);
|
||||
if (string2 != null) {
|
||||
throw new Exception(string2);
|
||||
}
|
||||
this.register(bAlarmConsole, string);
|
||||
return foxResponse.getString("query");
|
||||
}
|
||||
catch (InterruptedIOException interruptedIOException) {
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
// empty catch block
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private FoxResponse error(FoxRequest foxRequest) {
|
||||
try {
|
||||
String string = foxRequest.getString("msg");
|
||||
Exception exception = new Exception(foxRequest.getString("error"));
|
||||
String string2 = foxRequest.getString("ord");
|
||||
BAlarmConsole[] bAlarmConsoleArray = this.getConsolesRegisteredOn(string2);
|
||||
for (int i = 0; i < bAlarmConsoleArray.length; ++i) {
|
||||
if (bAlarmConsoleArray[i] == null) continue;
|
||||
bAlarmConsoleArray[i].showError(string, exception);
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void unregister(BConsoleRecipient bConsoleRecipient) throws Exception {
|
||||
FoxRequest foxRequest = this.makeRequest("unregister");
|
||||
String string = bConsoleRecipient.getOrdInSession().encodeToString();
|
||||
foxRequest.add("ord", string);
|
||||
try {
|
||||
FoxResponse foxResponse = this.sendSync(foxRequest);
|
||||
String string2 = foxResponse.getString("error", null);
|
||||
if (string2 != null) {
|
||||
throw new Exception(string2);
|
||||
}
|
||||
}
|
||||
catch (InterruptedIOException interruptedIOException) {
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
// empty catch block
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAlarm(BAlarmRecord bAlarmRecord) throws Exception {
|
||||
FoxRequest foxRequest = this.makeRequest("updateAlarm");
|
||||
foxRequest.add("alarm", FoxAlarmCodec.encodeAlarm(bAlarmRecord));
|
||||
if (this.isTraceOn()) {
|
||||
this.trace("sending: update : timestamp: " + bAlarmRecord.getTimestamp());
|
||||
this.trace(" source: " + bAlarmRecord.getSource().encodeToString());
|
||||
}
|
||||
try {
|
||||
FoxResponse foxResponse = this.sendSync(foxRequest);
|
||||
String string = foxResponse.getString("error", null);
|
||||
if (string != null) {
|
||||
throw new Exception(string);
|
||||
}
|
||||
}
|
||||
catch (InterruptedIOException interruptedIOException) {
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
private void register(BAlarmConsole bAlarmConsole, String string) {
|
||||
this.recips.add((Object)string);
|
||||
this.consoles.add((Object)bAlarmConsole);
|
||||
}
|
||||
|
||||
public void unregister(BAlarmConsole bAlarmConsole) {
|
||||
int n = this.consoles.indexOf((Object)bAlarmConsole);
|
||||
if (n < 0) {
|
||||
return;
|
||||
}
|
||||
if (this.consoles.size() > n) {
|
||||
this.consoles.remove(n);
|
||||
}
|
||||
if (this.recips.size() > n) {
|
||||
this.recips.remove(n);
|
||||
}
|
||||
}
|
||||
|
||||
private BAlarmConsole[] getConsolesRegisteredOn(String string) {
|
||||
Array array = new Array(class$com$tridium$alarm$ui$BAlarmConsole == null ? (class$com$tridium$alarm$ui$BAlarmConsole = BAlarmConsoleUIChannel.class$("com.tridium.alarm.ui.BAlarmConsole")) : class$com$tridium$alarm$ui$BAlarmConsole);
|
||||
for (int i = 0; i < this.recips.size(); ++i) {
|
||||
if (!this.recips.get(i).equals(string)) continue;
|
||||
array.add(this.consoles.get(i));
|
||||
}
|
||||
return (BAlarmConsole[])array.trim();
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.BVector
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.BVector;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
public class BAlarmDataCols
|
||||
extends BVector {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BAlarmDataCols == null ? (class$com$tridium$alarm$ui$BAlarmDataCols = BAlarmDataCols.class$("com.tridium.alarm.ui.BAlarmDataCols")) : class$com$tridium$alarm$ui$BAlarmDataCols));
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmDataCols;
|
||||
|
||||
public BAlarmDataCols() {
|
||||
}
|
||||
|
||||
public BAlarmDataCols(String[] stringArray) {
|
||||
for (int i = 0; i < stringArray.length; ++i) {
|
||||
this.add(stringArray[i], (BValue)BString.make((String)stringArray[i]));
|
||||
}
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,252 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BMonth
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Clock
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BButton
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BRadioButton
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.Command
|
||||
* javax.baja.ui.CommandArtifact
|
||||
* javax.baja.ui.ToggleCommand
|
||||
* javax.baja.ui.ToggleCommandGroup
|
||||
* javax.baja.ui.enums.BHalign
|
||||
* javax.baja.ui.enums.BValign
|
||||
* javax.baja.ui.event.BMouseEvent
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BEdgePane
|
||||
* javax.baja.ui.pane.BFlowPane
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.ui.table.TableController
|
||||
* javax.baja.util.Lexicon
|
||||
* javax.baja.workbench.BWbEditor
|
||||
* javax.baja.workbench.fieldeditor.BWbFieldEditor
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.alarm.ui.BAlarmDbView;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BMonth;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Clock;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BButton;
|
||||
import javax.baja.ui.BDialog;
|
||||
import javax.baja.ui.BLabel;
|
||||
import javax.baja.ui.BRadioButton;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.Command;
|
||||
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.enums.BValign;
|
||||
import javax.baja.ui.event.BMouseEvent;
|
||||
import javax.baja.ui.pane.BBorderPane;
|
||||
import javax.baja.ui.pane.BEdgePane;
|
||||
import javax.baja.ui.pane.BFlowPane;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.ui.table.TableController;
|
||||
import javax.baja.util.Lexicon;
|
||||
import javax.baja.workbench.BWbEditor;
|
||||
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
|
||||
|
||||
public class BAlarmDbMaintenance
|
||||
extends BAlarmDbView {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BAlarmDbMaintenance == null ? (class$com$tridium$alarm$ui$BAlarmDbMaintenance = BAlarmDbMaintenance.class$("com.tridium.alarm.ui.BAlarmDbMaintenance")) : class$com$tridium$alarm$ui$BAlarmDbMaintenance));
|
||||
private static Lexicon lex = Lexicon.make((String)"alarm");
|
||||
private ToggleCommand clearRecordsBeforeSelected;
|
||||
private ToggleCommand clearAllRecords;
|
||||
private ToggleCommand clearOldRecords;
|
||||
private Command runMaintenance;
|
||||
private BWbEditor dateEditor;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmDbMaintenance;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public void doLoadValue(BObject bObject, Context context) {
|
||||
super.doLoadValue(bObject, context);
|
||||
BWidget bWidget = this.getContent();
|
||||
this.setContent((BWidget)new BLabel(""));
|
||||
BGridPane bGridPane = new BGridPane(2);
|
||||
bGridPane.setHalign(BHalign.left);
|
||||
bGridPane.setValign(BValign.top);
|
||||
OptionGroup optionGroup = new OptionGroup();
|
||||
this.clearOldRecords = new ClearOldRecords();
|
||||
optionGroup.add(this.clearOldRecords);
|
||||
bGridPane.add("clearOld", (BValue)new BRadioButton(this.clearOldRecords));
|
||||
this.dateEditor = BWbFieldEditor.makeFor((BObject)BAbsTime.DEFAULT);
|
||||
BAbsTime bAbsTime = Clock.time();
|
||||
BAbsTime bAbsTime2 = BAbsTime.make((int)(bAbsTime.getYear() - 5), (BMonth)bAbsTime.getMonth(), (int)bAbsTime.getDay());
|
||||
this.dateEditor.loadValue((BObject)bAbsTime2);
|
||||
BFlowPane bFlowPane = new BFlowPane();
|
||||
bFlowPane.add("before", (BValue)new BLabel(lex.getText("before")));
|
||||
bFlowPane.add("dateEditor", (BValue)this.dateEditor);
|
||||
bGridPane.add("date", (BValue)new BBorderPane((BWidget)bFlowPane, 0.0, 0.0, 0.0, 10.0));
|
||||
this.clearRecordsBeforeSelected = new ClearRecordsBeforeSelected();
|
||||
optionGroup.add(this.clearRecordsBeforeSelected);
|
||||
bGridPane.add("clearBeforeSelected", (BValue)new BRadioButton(this.clearRecordsBeforeSelected));
|
||||
bGridPane.add(null, (BValue)new BLabel(""));
|
||||
this.clearAllRecords = new ClearAllRecords();
|
||||
optionGroup.add(this.clearAllRecords);
|
||||
bGridPane.add("clearAll", (BValue)new BRadioButton(this.clearAllRecords));
|
||||
bGridPane.add(null, (BValue)new BLabel(""));
|
||||
this.runMaintenance = new RunMaintenance();
|
||||
BButton bButton = new BButton(this.runMaintenance);
|
||||
BGridPane bGridPane2 = new BGridPane(1);
|
||||
bGridPane2.add("run", (BValue)bButton);
|
||||
BEdgePane bEdgePane = new BEdgePane();
|
||||
bEdgePane.setCenter((BWidget)new BBorderPane((BWidget)bGridPane));
|
||||
bEdgePane.setBottom((BWidget)bGridPane2);
|
||||
BEdgePane bEdgePane2 = new BEdgePane();
|
||||
bEdgePane2.setCenter(bWidget);
|
||||
bEdgePane2.setBottom((BWidget)bEdgePane);
|
||||
this.setContent((BWidget)bEdgePane2);
|
||||
this.query();
|
||||
}
|
||||
|
||||
public void runMaintenance() {
|
||||
try {
|
||||
if (this.clearAllRecords.isSelected()) {
|
||||
String string;
|
||||
String string2 = lex.getText("confirmClear.title");
|
||||
if (BDialog.confirm((BWidget)this, (String)string2, (Object)(string = lex.getText("confirmClear"))) != 4) {
|
||||
return;
|
||||
}
|
||||
} else if (this.clearRecordsBeforeSelected.isSelected()) {
|
||||
int n = this.table.getSelection().getRow();
|
||||
if (n == -1) {
|
||||
BDialog.error((BWidget)this, (String)lex.getText("confirmClear.title"), (Object)lex.getText("alarm.noRecordSelected"));
|
||||
} else {
|
||||
String string;
|
||||
BAbsTime bAbsTime = this.model.getRecord(n).getTimestamp();
|
||||
String string3 = lex.getText("confirmClear.title");
|
||||
if (BDialog.confirm((BWidget)this, (String)string3, (Object)(string = lex.getText("confirmClear"))) != 4) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (this.clearOldRecords.isSelected()) {
|
||||
BAbsTime bAbsTime = (BAbsTime)this.dateEditor.saveValue();
|
||||
String string = lex.getText("confirmClear.title");
|
||||
String string4 = lex.getText("confirmClear.before", new Object[]{bAbsTime.toString()});
|
||||
if (BDialog.confirm((BWidget)this, (String)string, (Object)string4) != 4) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.query();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
new MaintenanceThread().start();
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
class Controller
|
||||
extends TableController {
|
||||
Controller() {
|
||||
}
|
||||
|
||||
protected void cellReleased(BMouseEvent bMouseEvent, int n, int n2) {
|
||||
super.cellReleased(bMouseEvent, n, n2);
|
||||
if (bMouseEvent.getClickCount() == 2) {
|
||||
BAlarmDbMaintenance.this.showDetailsDialog(BAlarmDbMaintenance.this.model.getRecord(n));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class RunMaintenance
|
||||
extends Command {
|
||||
public RunMaintenance() {
|
||||
super((BWidget)BAlarmDbMaintenance.this, Sys.getModuleForClass((Class)(class$com$tridium$alarm$ui$BAlarmDbMaintenance == null ? (class$com$tridium$alarm$ui$BAlarmDbMaintenance = BAlarmDbMaintenance.class$("com.tridium.alarm.ui.BAlarmDbMaintenance")) : class$com$tridium$alarm$ui$BAlarmDbMaintenance)), "command.runMaintenance");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BAlarmDbMaintenance.this.runMaintenance();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class ClearOldRecords
|
||||
extends ToggleCommand {
|
||||
public ClearOldRecords() {
|
||||
super((BWidget)BAlarmDbMaintenance.this, Sys.getModuleForClass((Class)(class$com$tridium$alarm$ui$BAlarmDbMaintenance == null ? (class$com$tridium$alarm$ui$BAlarmDbMaintenance = BAlarmDbMaintenance.class$("com.tridium.alarm.ui.BAlarmDbMaintenance")) : class$com$tridium$alarm$ui$BAlarmDbMaintenance)), "command.clearOldRecords");
|
||||
}
|
||||
}
|
||||
|
||||
private class ClearRecordsBeforeSelected
|
||||
extends ToggleCommand {
|
||||
public ClearRecordsBeforeSelected() {
|
||||
super((BWidget)BAlarmDbMaintenance.this, Sys.getModuleForClass((Class)(class$com$tridium$alarm$ui$BAlarmDbMaintenance == null ? (class$com$tridium$alarm$ui$BAlarmDbMaintenance = BAlarmDbMaintenance.class$("com.tridium.alarm.ui.BAlarmDbMaintenance")) : class$com$tridium$alarm$ui$BAlarmDbMaintenance)), "command.clearRecordsBeforeSelected");
|
||||
}
|
||||
}
|
||||
|
||||
private class ClearAllRecords
|
||||
extends ToggleCommand {
|
||||
public ClearAllRecords() {
|
||||
super((BWidget)BAlarmDbMaintenance.this, Sys.getModuleForClass((Class)(class$com$tridium$alarm$ui$BAlarmDbMaintenance == null ? (class$com$tridium$alarm$ui$BAlarmDbMaintenance = BAlarmDbMaintenance.class$("com.tridium.alarm.ui.BAlarmDbMaintenance")) : class$com$tridium$alarm$ui$BAlarmDbMaintenance)), "command.clearAllRecords");
|
||||
}
|
||||
}
|
||||
|
||||
private class OptionGroup
|
||||
extends ToggleCommandGroup {
|
||||
private OptionGroup() {
|
||||
}
|
||||
|
||||
public void selected(ToggleCommand toggleCommand) {
|
||||
if (BAlarmDbMaintenance.this.dateEditor != null) {
|
||||
BAlarmDbMaintenance.this.dateEditor.setReadonly(toggleCommand != BAlarmDbMaintenance.this.clearOldRecords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MaintenanceThread
|
||||
extends Thread {
|
||||
public void run() {
|
||||
BAlarmDbMaintenance.this.enterBusy();
|
||||
try {
|
||||
if (BAlarmDbMaintenance.this.clearAllRecords.isSelected()) {
|
||||
BAlarmDbMaintenance.this.getAlarmDbChannel().clearAllRecords();
|
||||
} else if (BAlarmDbMaintenance.this.clearRecordsBeforeSelected.isSelected()) {
|
||||
int n = BAlarmDbMaintenance.this.table.getSelection().getRow();
|
||||
BAbsTime bAbsTime = BAlarmDbMaintenance.this.model.getRecord(n).getTimestamp();
|
||||
BAlarmDbMaintenance.this.getAlarmDbChannel().clearOldRecords(bAbsTime);
|
||||
BAlarmDbMaintenance.this.model.getSelection().deselectAll();
|
||||
} else if (BAlarmDbMaintenance.this.clearOldRecords.isSelected()) {
|
||||
BAbsTime bAbsTime = (BAbsTime)BAlarmDbMaintenance.this.dateEditor.saveValue();
|
||||
BAlarmDbMaintenance.this.getAlarmDbChannel().clearOldRecords(bAbsTime);
|
||||
}
|
||||
BAlarmDbMaintenance.this.query();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
BAlarmDbMaintenance.this.exitBusy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,584 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.bql.filter.BAbsTimeFilter
|
||||
* com.tridium.bql.filter.BFilterEntry
|
||||
* com.tridium.bql.filter.BFilterSet
|
||||
* com.tridium.bql.util.BDynamicTimeRange
|
||||
* com.tridium.fox.sys.BFoxClientConnection
|
||||
* com.tridium.fox.sys.BFoxSession
|
||||
* com.tridium.workbench.bql.filter.BFilterSetEditor
|
||||
* com.tridium.workbench.fieldeditors.BDynamicTimeRangeFE
|
||||
* com.tridium.workbench.fieldeditors.BFrozenEnumFE
|
||||
* javax.baja.agent.AgentFilter
|
||||
* javax.baja.agent.AgentList
|
||||
* javax.baja.bql.BIBqlFilter
|
||||
* javax.baja.bql.BqlQuery
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.gx.BImage
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.SlotPath
|
||||
* javax.baja.nre.util.Array
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BComplex
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BString
|
||||
* 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.BDialog
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BMenu
|
||||
* javax.baja.ui.BSeparator
|
||||
* javax.baja.ui.BTextDropDown
|
||||
* 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.event.BMouseEvent
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BEdgePane
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.ui.table.BTable
|
||||
* javax.baja.ui.table.DynamicTableModel
|
||||
* javax.baja.ui.table.TableController
|
||||
* javax.baja.ui.table.TableModel
|
||||
* javax.baja.ui.util.BTitlePane
|
||||
* javax.baja.ui.util.UiLexicon
|
||||
* javax.baja.workbench.BWbShell
|
||||
* javax.baja.workbench.fieldeditor.BWbFieldEditor
|
||||
* javax.baja.workbench.view.BWbComponentView
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.alarm.fox.BAlarmDbChannel;
|
||||
import com.tridium.alarm.ui.AlarmDbTableModel;
|
||||
import com.tridium.alarm.ui.BAlarmConsoleOptions;
|
||||
import com.tridium.alarm.ui.BAlarmDetailsDialog;
|
||||
import com.tridium.alarm.ui.BIAlarmServiceView;
|
||||
import com.tridium.alarm.ui.BNotesDialog;
|
||||
import com.tridium.alarm.ui.BTimeZoneDisplay;
|
||||
import com.tridium.alarm.ui.ConsoleColumns;
|
||||
import com.tridium.alarm.ui.ConsoleTableModel;
|
||||
import com.tridium.bql.filter.BAbsTimeFilter;
|
||||
import com.tridium.bql.filter.BFilterEntry;
|
||||
import com.tridium.bql.filter.BFilterSet;
|
||||
import com.tridium.bql.util.BDynamicTimeRange;
|
||||
import com.tridium.fox.sys.BFoxClientConnection;
|
||||
import com.tridium.fox.sys.BFoxSession;
|
||||
import com.tridium.workbench.bql.filter.BFilterSetEditor;
|
||||
import com.tridium.workbench.fieldeditors.BDynamicTimeRangeFE;
|
||||
import com.tridium.workbench.fieldeditors.BFrozenEnumFE;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.StringTokenizer;
|
||||
import javax.baja.agent.AgentFilter;
|
||||
import javax.baja.agent.AgentList;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.bql.BIBqlFilter;
|
||||
import javax.baja.bql.BqlQuery;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.gx.BImage;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.SlotPath;
|
||||
import javax.baja.nre.util.Array;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BComplex;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BString;
|
||||
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.BDialog;
|
||||
import javax.baja.ui.BLabel;
|
||||
import javax.baja.ui.BMenu;
|
||||
import javax.baja.ui.BSeparator;
|
||||
import javax.baja.ui.BTextDropDown;
|
||||
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.event.BMouseEvent;
|
||||
import javax.baja.ui.pane.BBorderPane;
|
||||
import javax.baja.ui.pane.BEdgePane;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.ui.table.BTable;
|
||||
import javax.baja.ui.table.DynamicTableModel;
|
||||
import javax.baja.ui.table.TableController;
|
||||
import javax.baja.ui.table.TableModel;
|
||||
import javax.baja.ui.util.BTitlePane;
|
||||
import javax.baja.ui.util.UiLexicon;
|
||||
import javax.baja.workbench.BWbShell;
|
||||
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
|
||||
import javax.baja.workbench.view.BWbComponentView;
|
||||
|
||||
public class BAlarmDbView
|
||||
extends BWbComponentView
|
||||
implements BIAlarmServiceView {
|
||||
public static final Property defaultTimeRange = BAlarmDbView.newProperty((int)0, (BValue)BDynamicTimeRange.DEFAULT, null);
|
||||
public static final Property timeZoneDisplay = BAlarmDbView.newProperty((int)0, (BValue)BTimeZoneDisplay.console, null);
|
||||
public static final Action query = BAlarmDbView.newAction((int)16, null);
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BAlarmDbView == null ? (class$com$tridium$alarm$ui$BAlarmDbView = BAlarmDbView.class$("com.tridium.alarm.ui.BAlarmDbView")) : class$com$tridium$alarm$ui$BAlarmDbView));
|
||||
private static UiLexicon lex = new UiLexicon(class$com$tridium$alarm$ui$BAlarmDbView == null ? (class$com$tridium$alarm$ui$BAlarmDbView = BAlarmDbView.class$("com.tridium.alarm.ui.BAlarmDbView")) : class$com$tridium$alarm$ui$BAlarmDbView);
|
||||
public static final BFacets TIME_FACETS = BFacets.make((String)"showSeconds", (boolean)true);
|
||||
BTable table;
|
||||
AlarmDbTableModel model;
|
||||
BAlarmService alarmService;
|
||||
Context context;
|
||||
private BAlarmDatabase alarmDatabase;
|
||||
private BFilterSet filterSet;
|
||||
private BDynamicTimeRangeFE timeRangeEd;
|
||||
private Command filterCmd;
|
||||
private Command notesCmd;
|
||||
private Command tzCmd;
|
||||
private Command addColumnCommand;
|
||||
private Command removeColumnCommand;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmDbView;
|
||||
static /* synthetic */ Class class$javax$baja$sys$BString;
|
||||
static /* synthetic */ Class class$java$lang$Integer;
|
||||
|
||||
public BDynamicTimeRange getDefaultTimeRange() {
|
||||
return (BDynamicTimeRange)this.get(defaultTimeRange);
|
||||
}
|
||||
|
||||
public void setDefaultTimeRange(BDynamicTimeRange bDynamicTimeRange) {
|
||||
this.set(defaultTimeRange, (BValue)bDynamicTimeRange, null);
|
||||
}
|
||||
|
||||
public BTimeZoneDisplay getTimeZoneDisplay() {
|
||||
return (BTimeZoneDisplay)this.get(timeZoneDisplay);
|
||||
}
|
||||
|
||||
public void setTimeZoneDisplay(BTimeZoneDisplay bTimeZoneDisplay) {
|
||||
this.set(timeZoneDisplay, (BValue)bTimeZoneDisplay, null);
|
||||
}
|
||||
|
||||
public void query() {
|
||||
this.invoke(query, null, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public ConsoleColumns getConsoleColumns() {
|
||||
if (this.model != null) {
|
||||
return this.model.getColumns();
|
||||
}
|
||||
ConsoleColumns consoleColumns = new ConsoleColumns();
|
||||
BString[] bStringArray = (BString[])BAlarmConsoleOptions.getDefault().getAlarmDataCols().getChildren(class$javax$baja$sys$BString == null ? (class$javax$baja$sys$BString = BAlarmDbView.class$("javax.baja.sys.BString")) : class$javax$baja$sys$BString);
|
||||
for (int i = 0; i < bStringArray.length; ++i) {
|
||||
consoleColumns.addDataColumn(null, bStringArray[i].toString());
|
||||
}
|
||||
return consoleColumns;
|
||||
}
|
||||
|
||||
public int[] getDefaultColumns() {
|
||||
Object object;
|
||||
String string = BAlarmConsoleOptions.getDefault().getDisplayColumns();
|
||||
StringTokenizer stringTokenizer = new StringTokenizer(string, ",");
|
||||
Array array = new Array(class$java$lang$Integer == null ? (class$java$lang$Integer = BAlarmDbView.class$("java.lang.Integer")) : class$java$lang$Integer);
|
||||
while (stringTokenizer.hasMoreTokens()) {
|
||||
object = stringTokenizer.nextToken();
|
||||
array.add((Object)new Integer((String)object));
|
||||
}
|
||||
object = new int[array.size()];
|
||||
for (int i = 0; i < array.size(); ++i) {
|
||||
object[i] = (Integer)array.get(i);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public int getSortColumn() {
|
||||
return BAlarmConsoleOptions.getDefault().getSortColumn();
|
||||
}
|
||||
|
||||
public boolean getSortDirection() {
|
||||
return BAlarmConsoleOptions.getDefault().getSortAscending();
|
||||
}
|
||||
|
||||
public BTable getTable() {
|
||||
return this.table;
|
||||
}
|
||||
|
||||
public BAlarmService getAlarmService(BAlarmRecord bAlarmRecord) {
|
||||
return this.alarmService;
|
||||
}
|
||||
|
||||
public void doLoadValue(BObject bObject, Context context) {
|
||||
this.filterSet = this.buildFilterSet();
|
||||
if (bObject instanceof BAlarmService) {
|
||||
this.alarmService = (BAlarmService)bObject;
|
||||
this.alarmDatabase = (BAlarmDatabase)BOrd.make((BOrd)this.alarmService.getAbsoluteOrd(), (BOrd)BOrd.make((String)"alarm:")).get();
|
||||
} else if (bObject instanceof BAlarmDatabase) {
|
||||
this.alarmDatabase = (BAlarmDatabase)bObject;
|
||||
this.alarmService = this.getAlarmService();
|
||||
}
|
||||
this.context = context;
|
||||
this.model = new AlarmDbTableModel(this.getConsoleColumns());
|
||||
this.model.init(this, context);
|
||||
this.table = new BTable((TableModel)new DynamicTableModel((TableModel)this.model, this.getDefaultColumns()), (TableController)new Controller());
|
||||
this.table.setMultipleSelection(false);
|
||||
this.model.options.setTimeZoneDisplay(this.getTimeZoneDisplay());
|
||||
this.filterCmd = new Command((BWidget)this, BAlarmDbView.lex.module, "commands.filter"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BAlarmDbView.this.configFilters();
|
||||
BAlarmDbView.this.query();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
this.notesCmd = new Command((BWidget)this, BAlarmDbView.lex.module, "commands.notes"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
int n = BAlarmDbView.this.table.getSelection().getRow();
|
||||
if (n != -1) {
|
||||
BAlarmRecord bAlarmRecord = BAlarmDbView.this.model.getRecord(n);
|
||||
BAlarmDbView.this.showNotes(bAlarmRecord);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
this.tzCmd = new Command((BWidget)this, BAlarmDbView.lex.module, "commands.timeZoneDisplay"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BFrozenEnumFE bFrozenEnumFE = new BFrozenEnumFE();
|
||||
bFrozenEnumFE.loadValue((BObject)BAlarmDbView.this.getTimeZoneDisplay());
|
||||
int n = BDialog.open((BWidget)BAlarmDbView.this, (String)lex.getText("commands.timeZoneDisplay.label"), (Object)bFrozenEnumFE, (int)3);
|
||||
if (n == 2) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
BTimeZoneDisplay bTimeZoneDisplay = (BTimeZoneDisplay)bFrozenEnumFE.saveValue();
|
||||
BAlarmDbView.this.setTimeZoneDisplay(bTimeZoneDisplay);
|
||||
BAlarmDbView.this.model.options.setTimeZoneDisplay(bTimeZoneDisplay);
|
||||
BAlarmDbView.this.model.options.save();
|
||||
BAlarmDbView.this.repaint();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BDialog.error((BWidget)BAlarmDbView.this, (String)"Cannot Save", (Object)exception.getMessage(), (Throwable)exception);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
this.addColumnCommand = new Command((BWidget)this, BAlarmDbView.lex.module, "commands.addColumn"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BGridPane bGridPane = new BGridPane(2);
|
||||
bGridPane.add("lbl", (BValue)new BLabel("AlarmData."));
|
||||
BTextField bTextField = new BTextField("");
|
||||
bGridPane.add("tf", (BValue)bTextField);
|
||||
int n = BDialog.open((BWidget)BAlarmDbView.this, (String)lex.getText("commands.addColumn.label"), (Object)bGridPane, (int)3, (BImage)null);
|
||||
if (n == 1) {
|
||||
try {
|
||||
BAlarmDbView.this.getConsoleColumns().addDataColumn(null, bTextField.getText());
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
DynamicTableModel dynamicTableModel = (DynamicTableModel)BAlarmDbView.this.table.getModel();
|
||||
dynamicTableModel.setColumnShowable(BAlarmDbView.this.getConsoleColumns().getColumnCount() - 1, true);
|
||||
dynamicTableModel.setShowColumn(BAlarmDbView.this.getConsoleColumns().getColumnCount() - 1, true);
|
||||
dynamicTableModel.updateTable();
|
||||
}
|
||||
BAlarmDbView.this.model.options.getAlarmDataCols().add(SlotPath.escape((String)bTextField.getText()), (BValue)BString.make((String)bTextField.getText()));
|
||||
BAlarmDbView.this.model.options.save();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
this.removeColumnCommand = new Command((BWidget)this, BAlarmDbView.lex.module, "commands.removeColumn"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BGridPane bGridPane = new BGridPane(2);
|
||||
bGridPane.add("lbl", (BValue)new BLabel("AlarmData."));
|
||||
ArrayList<String> arrayList = new ArrayList<String>();
|
||||
BString[] bStringArray = (BString[])BAlarmDbView.this.model.options.getAlarmDataCols().getChildren(class$javax$baja$sys$BString == null ? (class$javax$baja$sys$BString = BAlarmDbView.class$("javax.baja.sys.BString")) : class$javax$baja$sys$BString);
|
||||
for (int i = 0; i < bStringArray.length; ++i) {
|
||||
arrayList.add(bStringArray[i].toString());
|
||||
}
|
||||
BTextDropDown bTextDropDown = new BTextDropDown(arrayList, 20, false);
|
||||
bGridPane.add("tf", (BValue)bTextDropDown);
|
||||
int n = BDialog.open((BWidget)BAlarmDbView.this, (String)lex.getText("commands.removeColumn.label"), (Object)bGridPane, (int)3, (BImage)null);
|
||||
if (n == 1) {
|
||||
String string = bTextDropDown.getText();
|
||||
int n2 = BAlarmDbView.this.getConsoleColumns().dataColumnIndex(string);
|
||||
if (n2 == -1) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
int n3;
|
||||
DynamicTableModel dynamicTableModel = (DynamicTableModel)BAlarmDbView.this.table.getModel();
|
||||
boolean[] blArray = new boolean[BAlarmDbView.this.getConsoleColumns().getColumnCount()];
|
||||
for (n3 = 0; n3 < blArray.length; ++n3) {
|
||||
blArray[n3] = dynamicTableModel.showColumn(n3);
|
||||
}
|
||||
for (n3 = n2; n3 < blArray.length - 1; ++n3) {
|
||||
blArray[n3] = blArray[n3 + 1];
|
||||
}
|
||||
blArray[blArray.length - 1] = false;
|
||||
for (n3 = 0; n3 < blArray.length; ++n3) {
|
||||
dynamicTableModel.setShowColumn(n3, blArray[n3]);
|
||||
}
|
||||
}
|
||||
BAlarmDbView.this.getConsoleColumns().removeDataColumn(string);
|
||||
BAlarmDbView.this.model.options.getAlarmDataCols().remove(SlotPath.escape((String)bTextDropDown.getText()));
|
||||
BAlarmDbView.this.model.options.save();
|
||||
BAlarmDbView.this.model.updateTable();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
BGridPane bGridPane = new BGridPane(3);
|
||||
bGridPane.setHalign(BHalign.left);
|
||||
this.timeRangeEd = new BDynamicTimeRangeFE();
|
||||
this.timeRangeEd.loadValue((BObject)BDynamicTimeRange.TODAY);
|
||||
bGridPane.add("timeRangeQuery", (BValue)this.timeRangeEd);
|
||||
BDynamicTimeRange bDynamicTimeRange = this.getDefaultTimeRange();
|
||||
if (!bDynamicTimeRange.equals((Object)BDynamicTimeRange.DEFAULT)) {
|
||||
this.timeRangeEd.loadValue((BObject)bDynamicTimeRange, context);
|
||||
}
|
||||
this.linkTo("rangeLink", (BComponent)this.timeRangeEd, (Slot)BWbFieldEditor.setModified, (Slot)query);
|
||||
BEdgePane bEdgePane = new BEdgePane();
|
||||
bEdgePane.setTop((BWidget)new BBorderPane((BWidget)bGridPane));
|
||||
bEdgePane.setCenter((BWidget)BTitlePane.makePane((String)lex.getText("alarm.alarmHistory"), (BTable)this.table, (String)lex.getText("alarm.alarms")));
|
||||
this.setContent((BWidget)bEdgePane);
|
||||
this.query();
|
||||
}
|
||||
|
||||
public BToolBar getViewToolBar() {
|
||||
BToolBar bToolBar = new BToolBar();
|
||||
bToolBar.add("filter", this.filterCmd);
|
||||
bToolBar.add("notes", this.notesCmd);
|
||||
bToolBar.add("timezone", this.tzCmd);
|
||||
return bToolBar;
|
||||
}
|
||||
|
||||
public void stopped() throws Exception {
|
||||
super.stopped();
|
||||
DynamicTableModel dynamicTableModel = (DynamicTableModel)this.table.getModel();
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
for (int i = 0; i < dynamicTableModel.getRootColumnCount(); ++i) {
|
||||
if (!dynamicTableModel.showColumn(i)) continue;
|
||||
stringBuffer.append(i + ",");
|
||||
}
|
||||
if (dynamicTableModel.getRootColumnCount() > 0) {
|
||||
this.model.options.setDisplayColumns(stringBuffer.toString());
|
||||
}
|
||||
this.model.options.setSortColumn(this.model.getLastSortColumn());
|
||||
this.model.options.setSortAscending(this.model.getLastSortAscending());
|
||||
if (this.model != null) {
|
||||
this.model.options.save();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public void doQuery() {
|
||||
this.enterBusy();
|
||||
try {
|
||||
BAbsTimeFilter bAbsTimeFilter;
|
||||
BDynamicTimeRange bDynamicTimeRange;
|
||||
Object object;
|
||||
StringBuffer stringBuffer;
|
||||
StringBuffer stringBuffer2 = new StringBuffer("select * ");
|
||||
if (this.filterSet != null) {
|
||||
stringBuffer = new StringBuffer(64);
|
||||
object = this.filterSet.getPredicate();
|
||||
if (object != null && object.length() > 0) {
|
||||
if (stringBuffer.length() != 0) {
|
||||
stringBuffer.append(" and ");
|
||||
}
|
||||
stringBuffer.append((String)object);
|
||||
}
|
||||
if (!(bDynamicTimeRange = (BDynamicTimeRange)this.timeRangeEd.saveValue()).equals((Object)BDynamicTimeRange.DEFAULT)) {
|
||||
bAbsTimeFilter = new BAbsTimeFilter();
|
||||
bAbsTimeFilter.initFromDynamicTimeRange(bDynamicTimeRange);
|
||||
String string = bAbsTimeFilter.getPredicate(BAlarmRecord.timestamp.getName());
|
||||
if (stringBuffer.length() != 0) {
|
||||
stringBuffer.append(" and ");
|
||||
}
|
||||
stringBuffer.append(string.toString());
|
||||
}
|
||||
if (stringBuffer.length() != 0) {
|
||||
stringBuffer2.append(" where ").append(stringBuffer.toString());
|
||||
}
|
||||
}
|
||||
if (null == this.alarmDatabase) {
|
||||
this.alarmDatabase = (BAlarmDatabase)BOrd.make((BOrd)this.alarmService.getAbsoluteOrd(), (BOrd)BOrd.make((String)"alarm:")).get();
|
||||
}
|
||||
try {
|
||||
stringBuffer = this.alarmDatabase.doBqlQuery(BqlQuery.make((String)stringBuffer2.toString()));
|
||||
}
|
||||
catch (Exception exception) {
|
||||
bDynamicTimeRange = BOrd.make((BOrd)((BWbShell)this.getShell()).getActiveOrd(), (BOrd)BOrd.make((String)("alarm:|bql:" + stringBuffer2.toString())));
|
||||
bAbsTimeFilter = (BICollection)bDynamicTimeRange.resolve(this.getCurrentValue()).get();
|
||||
stringBuffer = bAbsTimeFilter.cursor();
|
||||
}
|
||||
this.model.clear();
|
||||
while (stringBuffer.next()) {
|
||||
object = (BAlarmRecord)stringBuffer.get();
|
||||
if (!this.filterSet.accept((BComplex)object)) continue;
|
||||
this.model.add((BAlarmRecord)((Object)object));
|
||||
}
|
||||
this.model.sortByColumn(this.getSortColumn(), this.getSortDirection());
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
this.exitBusy();
|
||||
this.table.sizeColumnsToFit();
|
||||
}
|
||||
this.table.fireTableModified(null);
|
||||
}
|
||||
|
||||
public BAlarmService getAlarmService() {
|
||||
if (this.alarmService == null) {
|
||||
BOrd bOrd = ((BWbShell)this.getShell()).getActiveOrd();
|
||||
try {
|
||||
BOrd bOrd2 = BOrd.make((BOrd)bOrd, (String)"service:alarm:AlarmService");
|
||||
this.alarmService = (BAlarmService)bOrd2.resolve().get();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
return this.alarmService;
|
||||
}
|
||||
|
||||
public void configFilters() {
|
||||
BFilterSetEditor bFilterSetEditor = new BFilterSetEditor();
|
||||
bFilterSetEditor.loadValue((BObject)this.filterSet);
|
||||
BBorderPane bBorderPane = new BBorderPane((BWidget)bFilterSetEditor);
|
||||
if (BDialog.open((BWidget)this, (String)"Filters", (Object)bBorderPane, (int)3) != 2) {
|
||||
try {
|
||||
if (bFilterSetEditor.isModified()) {
|
||||
this.filterSet = (BFilterSet)bFilterSetEditor.saveValue();
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BFilterSet buildFilterSet() {
|
||||
BAlarmRecord bAlarmRecord = new BAlarmRecord();
|
||||
BFilterSet bFilterSet = new BFilterSet();
|
||||
Property[] propertyArray = bAlarmRecord.getPropertiesArray();
|
||||
for (int i = 0; i < propertyArray.length; ++i) {
|
||||
BValue bValue;
|
||||
AgentList agentList;
|
||||
if (propertyArray[i].equals(BAlarmRecord.timestamp) || (agentList = (bValue = bAlarmRecord.get(propertyArray[i])).getAgents().filter(AgentFilter.is((Type)BIBqlFilter.TYPE))).size() == 0) continue;
|
||||
BIBqlFilter bIBqlFilter = (BIBqlFilter)agentList.getDefault().getInstance();
|
||||
bIBqlFilter.init((BObject)bValue);
|
||||
BFilterEntry bFilterEntry = new BFilterEntry(false, propertyArray[i].getDefaultDisplayName(this.getCurrentContext()), bIBqlFilter);
|
||||
bFilterSet.add(propertyArray[i].getName(), (BValue)bFilterEntry, 0, bAlarmRecord.getSlotFacets((Slot)propertyArray[i]), null);
|
||||
}
|
||||
return bFilterSet;
|
||||
}
|
||||
|
||||
public void showDetailsDialog(BAlarmRecord bAlarmRecord) {
|
||||
BAlarmDetailsDialog bAlarmDetailsDialog = new BAlarmDetailsDialog(this.alarmService, this.getTimeZoneDisplay(), bAlarmRecord, (ConsoleTableModel)((DynamicTableModel)this.table.getModel()).getRootModel(), this.context, this.getAlarmDbChannel());
|
||||
bAlarmDetailsDialog.setBoundsCenteredOnOwner();
|
||||
bAlarmDetailsDialog.open();
|
||||
}
|
||||
|
||||
public void showNotes(BAlarmRecord bAlarmRecord) {
|
||||
String string = "";
|
||||
try {
|
||||
string = ((BString)bAlarmRecord.getAlarmData().getFacet("notes")).getString();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
// empty catch block
|
||||
}
|
||||
BNotesDialog bNotesDialog = new BNotesDialog((BWidget)this, string, this.getUsername(bAlarmRecord), true);
|
||||
bNotesDialog.setBoundsCenteredOnOwner();
|
||||
bNotesDialog.open();
|
||||
String string2 = bNotesDialog.getNewNotes();
|
||||
if (string2 != null) {
|
||||
string = string2 + string;
|
||||
BFacets bFacets = bAlarmRecord.getAlarmData();
|
||||
HashMap<String, Object> hashMap = new HashMap<String, Object>();
|
||||
String[] stringArray = bFacets.list();
|
||||
for (int i = 0; i < stringArray.length; ++i) {
|
||||
if (stringArray[i].equals("notes")) continue;
|
||||
BObject bObject = bFacets.get(stringArray[i]);
|
||||
hashMap.put(stringArray[i], bObject);
|
||||
}
|
||||
hashMap.put("notes", BString.make((String)string));
|
||||
BFacets bFacets2 = BFacets.make(hashMap);
|
||||
bAlarmRecord.setAlarmData(bFacets2);
|
||||
try {
|
||||
this.getAlarmDbChannel().update(bAlarmRecord);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String getUsername(BAlarmRecord bAlarmRecord) {
|
||||
BFoxSession bFoxSession = (BFoxSession)this.getCurrentValueSession();
|
||||
BFoxClientConnection bFoxClientConnection = bFoxSession.getConnection();
|
||||
return bFoxClientConnection.getUsername();
|
||||
}
|
||||
|
||||
protected BAlarmDbChannel getAlarmDbChannel() {
|
||||
BFoxSession bFoxSession = (BFoxSession)this.getCurrentValueSession();
|
||||
BFoxClientConnection bFoxClientConnection = bFoxSession.getConnection();
|
||||
return (BAlarmDbChannel)bFoxClientConnection.getChannels().get("alarmdb", BAlarmDbChannel.TYPE);
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
class Controller
|
||||
extends TableController {
|
||||
Controller() {
|
||||
}
|
||||
|
||||
protected void cellReleased(BMouseEvent bMouseEvent, int n, int n2) {
|
||||
super.cellReleased(bMouseEvent, n, n2);
|
||||
if (bMouseEvent.getClickCount() == 2) {
|
||||
BAlarmDbView.this.showDetailsDialog(BAlarmDbView.this.model.getRecord(n));
|
||||
}
|
||||
}
|
||||
|
||||
public BMenu makeOptionsMenu() {
|
||||
BMenu bMenu = super.makeOptionsMenu();
|
||||
bMenu.add("acSep", (BValue)new BSeparator());
|
||||
bMenu.add("addColumn", BAlarmDbView.this.addColumnCommand);
|
||||
bMenu.add("removeColumn", BAlarmDbView.this.removeColumnCommand);
|
||||
return bMenu;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,622 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.ui.theme.Theme
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.gx.BBrush
|
||||
* javax.baja.gx.BImage
|
||||
* javax.baja.log.Log
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.naming.SlotPath
|
||||
* javax.baja.nre.util.SortUtil
|
||||
* javax.baja.nre.util.TextUtil
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BComplex
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BIcon
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Flags
|
||||
* javax.baja.sys.LocalizableRuntimeException
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Slot
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.timezone.BTimeZone
|
||||
* javax.baja.ui.BButton
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BToolBar
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.Command
|
||||
* javax.baja.ui.CommandArtifact
|
||||
* javax.baja.ui.enums.BHalign
|
||||
* javax.baja.ui.enums.BValign
|
||||
* javax.baja.ui.event.BWindowEvent
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BEdgePane
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.ui.pane.BScrollPane
|
||||
* javax.baja.ui.text.BTextEditor
|
||||
* javax.baja.ui.text.TextRenderer
|
||||
* javax.baja.ui.util.UiLexicon
|
||||
* javax.baja.util.BFormat
|
||||
* javax.baja.util.Lexicon
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.alarm.fox.BAlarmDbChannel;
|
||||
import com.tridium.alarm.ui.BAlarmClassDef;
|
||||
import com.tridium.alarm.ui.BAlarmConsole;
|
||||
import com.tridium.alarm.ui.BNotesDialog;
|
||||
import com.tridium.alarm.ui.BTimeZoneDisplay;
|
||||
import com.tridium.alarm.ui.ConsoleTableModel;
|
||||
import com.tridium.ui.theme.Theme;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import javax.baja.alarm.AlarmException;
|
||||
import javax.baja.alarm.BAlarmClass;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.gx.BBrush;
|
||||
import javax.baja.gx.BImage;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.naming.SlotPath;
|
||||
import javax.baja.nre.util.SortUtil;
|
||||
import javax.baja.nre.util.TextUtil;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BComplex;
|
||||
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.Context;
|
||||
import javax.baja.sys.Flags;
|
||||
import javax.baja.sys.LocalizableRuntimeException;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Slot;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.timezone.BTimeZone;
|
||||
import javax.baja.ui.BButton;
|
||||
import javax.baja.ui.BDialog;
|
||||
import javax.baja.ui.BLabel;
|
||||
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.enums.BValign;
|
||||
import javax.baja.ui.event.BWindowEvent;
|
||||
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.ui.text.BTextEditor;
|
||||
import javax.baja.ui.text.TextRenderer;
|
||||
import javax.baja.ui.util.UiLexicon;
|
||||
import javax.baja.util.BFormat;
|
||||
import javax.baja.util.Lexicon;
|
||||
|
||||
public class BAlarmDetailsDialog
|
||||
extends BDialog {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BAlarmDetailsDialog == null ? (class$com$tridium$alarm$ui$BAlarmDetailsDialog = BAlarmDetailsDialog.class$("com.tridium.alarm.ui.BAlarmDetailsDialog")) : class$com$tridium$alarm$ui$BAlarmDetailsDialog));
|
||||
BAlarmConsole console;
|
||||
BAlarmService alarmService;
|
||||
BGridPane alarmPane = new BGridPane(2);
|
||||
protected BAlarmRecord alarm;
|
||||
BTimeZoneDisplay timeZoneDisplay;
|
||||
BAlarmDbChannel alarmDbChannel;
|
||||
ConsoleTableModel tm;
|
||||
Log logger = Log.getLog((String)"alarm");
|
||||
Command ackCmd;
|
||||
Command closeCmd;
|
||||
Command hyperlinkCmd;
|
||||
Command notesCmd;
|
||||
Command showVideoCmd;
|
||||
Command nextCmd;
|
||||
Command prevCmd;
|
||||
public static final BFacets TIME_FACETS = BFacets.make((String)"showSeconds", (boolean)true);
|
||||
public static final UiLexicon lex = new UiLexicon(class$com$tridium$alarm$ui$BAlarmDetailsDialog == null ? (class$com$tridium$alarm$ui$BAlarmDetailsDialog = BAlarmDetailsDialog.class$("com.tridium.alarm.ui.BAlarmDetailsDialog")) : class$com$tridium$alarm$ui$BAlarmDetailsDialog);
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmDetailsDialog;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmConsole;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BAlarmDetailsDialog() {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
public BAlarmDetailsDialog(BAlarmConsole bAlarmConsole, BTimeZoneDisplay bTimeZoneDisplay, BAlarmRecord bAlarmRecord, ConsoleTableModel consoleTableModel) {
|
||||
this(bAlarmConsole, bTimeZoneDisplay, bAlarmRecord, consoleTableModel, null);
|
||||
}
|
||||
|
||||
public BAlarmDetailsDialog(BAlarmService bAlarmService, BTimeZoneDisplay bTimeZoneDisplay, BAlarmRecord bAlarmRecord, ConsoleTableModel consoleTableModel, Context context) {
|
||||
this(bAlarmService, null, bTimeZoneDisplay, bAlarmRecord, consoleTableModel, context);
|
||||
}
|
||||
|
||||
public BAlarmDetailsDialog(BAlarmService bAlarmService, BTimeZoneDisplay bTimeZoneDisplay, BAlarmRecord bAlarmRecord, ConsoleTableModel consoleTableModel, Context context, BAlarmDbChannel bAlarmDbChannel) {
|
||||
this(bAlarmService, null, bTimeZoneDisplay, bAlarmRecord, consoleTableModel, context, bAlarmDbChannel);
|
||||
}
|
||||
|
||||
public BAlarmDetailsDialog(BAlarmConsole bAlarmConsole, BTimeZoneDisplay bTimeZoneDisplay, BAlarmRecord bAlarmRecord, ConsoleTableModel consoleTableModel, Context context) {
|
||||
this(null, bAlarmConsole, bTimeZoneDisplay, bAlarmRecord, consoleTableModel, context);
|
||||
}
|
||||
|
||||
protected BAlarmDetailsDialog(BAlarmService bAlarmService, BAlarmConsole bAlarmConsole, BTimeZoneDisplay bTimeZoneDisplay, BAlarmRecord bAlarmRecord, ConsoleTableModel consoleTableModel, Context context) {
|
||||
this(bAlarmService, bAlarmConsole, bTimeZoneDisplay, bAlarmRecord, consoleTableModel, context, null);
|
||||
}
|
||||
|
||||
protected BAlarmDetailsDialog(BAlarmService bAlarmService, BAlarmConsole bAlarmConsole, BTimeZoneDisplay bTimeZoneDisplay, BAlarmRecord bAlarmRecord, ConsoleTableModel consoleTableModel, Context context, BAlarmDbChannel bAlarmDbChannel) {
|
||||
super((BWidget)bAlarmConsole, "Alarm Record", true);
|
||||
BEdgePane bEdgePane;
|
||||
Object object;
|
||||
BAlarmClass bAlarmClass;
|
||||
this.console = bAlarmConsole;
|
||||
this.alarm = bAlarmRecord;
|
||||
this.tm = consoleTableModel;
|
||||
this.timeZoneDisplay = bTimeZoneDisplay;
|
||||
if (bAlarmConsole != null) {
|
||||
this.alarmService = bAlarmConsole.getAlarmService();
|
||||
}
|
||||
if (bAlarmService != null) {
|
||||
this.alarmService = bAlarmService;
|
||||
}
|
||||
this.alarmDbChannel = bAlarmDbChannel;
|
||||
this.hyperlinkCmd = new HyperlinkCommand((BWidget)this);
|
||||
BButton bButton = new BButton(this.hyperlinkCmd, true, true);
|
||||
this.ackCmd = new AckCommand((BWidget)this);
|
||||
BButton bButton2 = new BButton(this.ackCmd, true, true);
|
||||
this.notesCmd = new NotesCommand((BWidget)this);
|
||||
BButton bButton3 = new BButton(this.notesCmd, true, true);
|
||||
this.showVideoCmd = new ShowVideoCommand((BWidget)this);
|
||||
BButton bButton4 = new BButton(this.showVideoCmd, true, true);
|
||||
this.closeCmd = new CloseCommand((BWidget)this);
|
||||
BButton bButton5 = new BButton(this.closeCmd, true, true);
|
||||
this.nextCmd = new PrevCommand((BWidget)this, context);
|
||||
BButton bButton6 = new BButton(this.nextCmd, false, true);
|
||||
this.prevCmd = new NextCommand((BWidget)this, context);
|
||||
BButton bButton7 = new BButton(this.prevCmd, false, true);
|
||||
BOrdList bOrdList = bAlarmRecord.getSource();
|
||||
boolean bl = false;
|
||||
int n = consoleTableModel.getAlarmCount(bOrdList);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (!consoleTableModel.getRecord(bOrdList, i).getUuid().equals((Object)bAlarmRecord.getUuid())) continue;
|
||||
this.prevCmd.setEnabled(i != 0);
|
||||
this.nextCmd.setEnabled(i + 1 < n);
|
||||
bl = true;
|
||||
break;
|
||||
}
|
||||
if (!bl) {
|
||||
this.prevCmd.setEnabled(false);
|
||||
this.nextCmd.setEnabled(false);
|
||||
}
|
||||
this.createAlarmPane(context);
|
||||
BGridPane bGridPane = new BGridPane();
|
||||
bGridPane.setColumnAlign(BHalign.fill);
|
||||
bGridPane.setUniformColumnWidth(true);
|
||||
bGridPane.add("next", (BValue)bButton6);
|
||||
if (bAlarmConsole != null) {
|
||||
bAlarmClass = bAlarmConsole.getAlarmService().lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass.getPermissions(bAlarmConsole.ctx).hasOperatorWrite()) {
|
||||
bGridPane.add("ack", (BValue)bButton2);
|
||||
}
|
||||
bGridPane.add("url", (BValue)bButton);
|
||||
bGridPane.add("notes", (BValue)bButton3);
|
||||
if (BAlarmConsole.isVideoDriverAvailable() && (object = bAlarmRecord.getAlarmData().gets("cameraOrd", null)) != null && !(bEdgePane = BOrd.make((String)object)).equals((Object)BOrd.NULL)) {
|
||||
bGridPane.add("showVideo", (BValue)bButton4);
|
||||
}
|
||||
}
|
||||
bGridPane.add("close", (BValue)bButton5);
|
||||
bGridPane.add("prev", (BValue)bButton7);
|
||||
bGridPane.setColumnCount(bGridPane.getChildWidgets().length);
|
||||
bAlarmClass = new BScrollPane();
|
||||
object = new BBorderPane();
|
||||
bAlarmClass.setContent((BWidget)object);
|
||||
object.setContent((BWidget)this.alarmPane);
|
||||
bEdgePane = new BEdgePane();
|
||||
bEdgePane.setCenter((BWidget)new BBorderPane((BWidget)bAlarmClass));
|
||||
bEdgePane.setBottom((BWidget)new BBorderPane((BWidget)bGridPane));
|
||||
this.setContent((BWidget)bEdgePane);
|
||||
}
|
||||
|
||||
public void windowClosing(BWindowEvent bWindowEvent) {
|
||||
this.close();
|
||||
}
|
||||
|
||||
void createAlarmPane(Context context) {
|
||||
Object object;
|
||||
Object object2;
|
||||
BOrd bOrd;
|
||||
Property[] propertyArray = this.alarm.loadSlots().getPropertiesArray();
|
||||
int n = propertyArray.length;
|
||||
this.alarmPane.removeAll();
|
||||
this.alarmPane.setColorRows(true);
|
||||
this.alarmPane.setRowAlign(BValign.top);
|
||||
this.alarmPane.setColumnGap(9.0);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
BTextEditor bTextEditor;
|
||||
if (Flags.isHidden((BComplex)this.alarm, (Slot)propertyArray[i])) continue;
|
||||
bOrd = new BLabel(this.alarm.getDisplayName((Slot)propertyArray[i], this.console != null ? this.console.ctx : null), BHalign.left);
|
||||
bOrd.setFont(Theme.label().getBoldText());
|
||||
this.alarmPane.add(null, (BValue)bOrd, null);
|
||||
if (propertyArray[i].getName().equals("alarmData")) {
|
||||
object2 = (BFacets)this.alarm.get(propertyArray[i]);
|
||||
object = new BGridPane(2);
|
||||
object.setHalign(BHalign.fill);
|
||||
object.setColumnGap(5.0);
|
||||
object.setRowAlign(BValign.top);
|
||||
bTextEditor = object2.list();
|
||||
bTextEditor = this.addNotePropertyIfNotPresent((String[])bTextEditor);
|
||||
SortUtil.sort((Object[])bTextEditor, (Object[])bTextEditor, (Comparator)new Comparator(){
|
||||
|
||||
public int compare(Object object, Object object2) {
|
||||
return ((String)object).compareToIgnoreCase((String)object2);
|
||||
}
|
||||
});
|
||||
for (int j = 0; j < ((Object[])bTextEditor).length; ++j) {
|
||||
BFormat bFormat;
|
||||
Object object3;
|
||||
BLabel bLabel = new BLabel(lex.get("alarmData." + (String)bTextEditor[j], TextUtil.toFriendly((String)bTextEditor[j])), BHalign.left);
|
||||
bLabel.setFont(Theme.label().getBoldText());
|
||||
object.add(null, (BValue)bLabel, null);
|
||||
if (bTextEditor[j].equals("notes")) {
|
||||
object3 = new Command((BWidget)this, "", BImage.make((BIcon)BIcon.std((String)"doubleArrowRight.png")), null, ""){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
try {
|
||||
BAlarmDetailsDialog.this.notesCmd.doInvoke();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
// empty catch block
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
bFormat = new BToolBar();
|
||||
bFormat.add("eb", (BValue)new BButton(object3, false, true));
|
||||
object.add(null, (BValue)bFormat, null);
|
||||
continue;
|
||||
}
|
||||
if (bTextEditor[j].equals("msgText")) {
|
||||
bFormat = BFormat.make((String)object2.getFacet((String)bTextEditor[j]).toString());
|
||||
object3 = bFormat.format((Object)this.alarm);
|
||||
} else {
|
||||
object3 = bTextEditor[j].equals("instructions") ? BFormat.make((String)object2.getFacet((String)bTextEditor[j]).toString()).format((Object)this) : object2.getFacet((String)bTextEditor[j]).toString();
|
||||
}
|
||||
object3 = TextUtil.replace((String)object3, (String)"\\n", (String)"\n");
|
||||
bFormat = new BTextEditor((String)object3, false);
|
||||
bFormat.setRenderer(new TextRenderer(){
|
||||
|
||||
public BBrush getBackground() {
|
||||
return BBrush.NULL;
|
||||
}
|
||||
});
|
||||
object.add(null, (BValue)bFormat);
|
||||
}
|
||||
this.alarmPane.add(null, (BValue)object, null);
|
||||
continue;
|
||||
}
|
||||
if (propertyArray[i].getType().is(BOrdList.TYPE)) {
|
||||
try {
|
||||
BString bString;
|
||||
object2 = (BOrdList)this.alarm.get(propertyArray[i]);
|
||||
object = new StringBuffer();
|
||||
for (int j = object2.size() - 1; j >= 0; --j) {
|
||||
if (j < object2.size() - 1) {
|
||||
((StringBuffer)object).append("-> ");
|
||||
}
|
||||
((StringBuffer)object).append(SlotPath.unescape((String)object2.get(j).encodeToString()).toString());
|
||||
if (j - 1 < 0) continue;
|
||||
((StringBuffer)object).append("\n");
|
||||
}
|
||||
if (propertyArray[i].getName().equals("source") && (bString = (BString)this.alarm.getAlarmData().get("sourceName")) != null && bString != BString.DEFAULT) {
|
||||
((StringBuffer)object).insert(0, BFormat.make((String)bString.toString(context)).format((Object)this.alarm) + "\n");
|
||||
}
|
||||
bTextEditor = new BTextEditor(((StringBuffer)object).toString(), false);
|
||||
bTextEditor.setRenderer(new TextRenderer(){
|
||||
|
||||
public BBrush getBackground() {
|
||||
return BBrush.NULL;
|
||||
}
|
||||
});
|
||||
this.alarmPane.add(null, (BValue)bTextEditor, null);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
this.alarmPane.add(null, (BValue)new BLabel("unknown"), null);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (propertyArray[i].getType().is(BAbsTime.TYPE)) {
|
||||
object2 = (BAbsTime)this.alarm.get(propertyArray[i]);
|
||||
object = "";
|
||||
object = this.timeZoneDisplay == BTimeZoneDisplay.source ? object2.toString((Context)BFacets.make((BFacets)this.alarm.getAlarmData(), (BFacets)TIME_FACETS)) : object2.toString((Context)BFacets.make((BFacets)TIME_FACETS, (String)"TimeZone", (BIDataValue)BTimeZone.getLocal()));
|
||||
bTextEditor = new BTextEditor((String)object, false);
|
||||
bTextEditor.setRenderer(new TextRenderer(){
|
||||
|
||||
public BBrush getBackground() {
|
||||
return BBrush.NULL;
|
||||
}
|
||||
});
|
||||
this.alarmPane.add(null, (BValue)bTextEditor);
|
||||
continue;
|
||||
}
|
||||
object2 = SlotPath.unescape((String)this.alarm.get(propertyArray[i].getName()).toString());
|
||||
object2 = TextUtil.replace((String)object2, (String)"\\n", (String)"\n");
|
||||
if (propertyArray[i].getName().equals("alarmClass")) {
|
||||
object2 = this.alarmService.getAlarmClassDisplayName(BString.make((String)this.alarm.get(propertyArray[i].getName()).toString()), context).toString();
|
||||
}
|
||||
object = new BTextEditor((String)object2, false);
|
||||
object.setRenderer(new TextRenderer(){
|
||||
|
||||
public BBrush getBackground() {
|
||||
return BBrush.NULL;
|
||||
}
|
||||
});
|
||||
this.alarmPane.add(null, (BValue)object);
|
||||
}
|
||||
BString bString = (BString)this.alarm.getAlarmData().get("hyperlinkOrd");
|
||||
bOrd = BOrd.NULL;
|
||||
if (bString != null) {
|
||||
bOrd = BOrd.make((String)bString.toString());
|
||||
}
|
||||
if (bOrd == null || bOrd.isNull() && this.console != null) {
|
||||
object2 = this.console.options.getAlarmClassMapping();
|
||||
object = object2.getAlarmClassDefFor(this.alarm.getAlarmClass());
|
||||
bOrd = ((BAlarmClassDef)((Object)object)).getAlarmUrl();
|
||||
}
|
||||
if (bOrd != null && !bOrd.isNull()) {
|
||||
this.hyperlinkCmd.setEnabled(true);
|
||||
} else {
|
||||
this.hyperlinkCmd.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
private String[] addNotePropertyIfNotPresent(String[] stringArray) {
|
||||
boolean bl = false;
|
||||
for (int i = 0; i < stringArray.length; ++i) {
|
||||
if (!"notes".equals(stringArray[i])) continue;
|
||||
bl = true;
|
||||
break;
|
||||
}
|
||||
if (!bl) {
|
||||
String[] stringArray2 = new String[stringArray.length + 1];
|
||||
int n = 0;
|
||||
for (n = 0; n < stringArray.length; ++n) {
|
||||
stringArray2[n] = stringArray[n];
|
||||
}
|
||||
stringArray2[n] = "notes";
|
||||
stringArray = stringArray2;
|
||||
}
|
||||
return stringArray;
|
||||
}
|
||||
|
||||
protected void alarmCleared() {
|
||||
this.notesCmd.setEnabled(false);
|
||||
this.ackCmd.setEnabled(false);
|
||||
this.hyperlinkCmd.setEnabled(false);
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private class ShowVideoCommand
|
||||
extends Command {
|
||||
public ShowVideoCommand(BWidget bWidget) {
|
||||
super(bWidget, (Lexicon)BAlarmConsole.lexicon, "commands.showVideo");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
block8: {
|
||||
try {
|
||||
Class clazz = Sys.loadClass((String)"videoDriver", (String)"com.tridium.videoDriver.alarm.AlarmConsoleExt");
|
||||
if (clazz != null) {
|
||||
Method method = clazz.getMethod("doShowVideo", class$com$tridium$alarm$ui$BAlarmConsole == null ? (class$com$tridium$alarm$ui$BAlarmConsole = BAlarmDetailsDialog.class$("com.tridium.alarm.ui.BAlarmConsole")) : class$com$tridium$alarm$ui$BAlarmConsole, class$javax$baja$alarm$BAlarmRecord == null ? (class$javax$baja$alarm$BAlarmRecord = BAlarmDetailsDialog.class$("javax.baja.alarm.BAlarmRecord")) : class$javax$baja$alarm$BAlarmRecord);
|
||||
if (method != null) {
|
||||
method.invoke((Object)clazz, new Object[]{BAlarmDetailsDialog.this.console, BAlarmDetailsDialog.this.alarm});
|
||||
} else {
|
||||
System.out.println("The 'doShowVideo' method was not found on class AlarmConsoleExt in videoDriver.jar. Please have my program fixed");
|
||||
}
|
||||
break block8;
|
||||
}
|
||||
throw new LocalizableRuntimeException("alarm", "VideoDriverModuleNotFound");
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new LocalizableRuntimeException("alarm", "VideoDriverModuleNotFound", (Throwable)classNotFoundException);
|
||||
}
|
||||
catch (NoSuchMethodException noSuchMethodException) {
|
||||
throw new LocalizableRuntimeException("alarm", "VideoDriverModuleNotFound", (Throwable)noSuchMethodException);
|
||||
}
|
||||
catch (InvocationTargetException invocationTargetException) {
|
||||
throw new LocalizableRuntimeException("alarm", "VideoDriverModuleNotFound", (Throwable)invocationTargetException);
|
||||
}
|
||||
catch (IllegalAccessException illegalAccessException) {
|
||||
throw new LocalizableRuntimeException("alarm", "VideoDriverModuleNotFound", (Throwable)illegalAccessException);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class NextCommand
|
||||
extends Command {
|
||||
Context cx;
|
||||
|
||||
public NextCommand(BWidget bWidget, Context context) {
|
||||
super(bWidget, (Lexicon)UiLexicon.bajaui, "commands.forward");
|
||||
this.cx = context;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return "Previous";
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BOrdList bOrdList = BAlarmDetailsDialog.this.alarm.getSource();
|
||||
int n = BAlarmDetailsDialog.this.tm.getAlarmCount(bOrdList);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (!BAlarmDetailsDialog.this.tm.getRecord(bOrdList, i).getUuid().equals((Object)BAlarmDetailsDialog.this.alarm.getUuid())) continue;
|
||||
if (i > 0) {
|
||||
BAlarmDetailsDialog.this.alarm = BAlarmDetailsDialog.this.tm.getRecord(bOrdList, i - 1);
|
||||
BAlarmDetailsDialog.this.createAlarmPane(this.cx);
|
||||
BAlarmDetailsDialog.this.alarmPane.relayout();
|
||||
--i;
|
||||
}
|
||||
BAlarmDetailsDialog.this.prevCmd.setEnabled(i != 0);
|
||||
BAlarmDetailsDialog.this.nextCmd.setEnabled(i + 1 < n);
|
||||
return null;
|
||||
}
|
||||
BAlarmDetailsDialog.this.prevCmd.setEnabled(false);
|
||||
BAlarmDetailsDialog.this.nextCmd.setEnabled(false);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class PrevCommand
|
||||
extends Command {
|
||||
Context cx;
|
||||
|
||||
public PrevCommand(BWidget bWidget, Context context) {
|
||||
super(bWidget, (Lexicon)UiLexicon.bajaui, "commands.back");
|
||||
this.cx = context;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return "Next";
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BOrdList bOrdList = BAlarmDetailsDialog.this.alarm.getSource();
|
||||
int n = BAlarmDetailsDialog.this.tm.getAlarmCount(bOrdList);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (!BAlarmDetailsDialog.this.tm.getRecord(bOrdList, i).getUuid().equals((Object)BAlarmDetailsDialog.this.alarm.getUuid())) continue;
|
||||
if (i + 1 < n) {
|
||||
BAlarmDetailsDialog.this.alarm = BAlarmDetailsDialog.this.tm.getRecord(bOrdList, i + 1);
|
||||
BAlarmDetailsDialog.this.createAlarmPane(this.cx);
|
||||
BAlarmDetailsDialog.this.alarmPane.relayout();
|
||||
++i;
|
||||
}
|
||||
BAlarmDetailsDialog.this.prevCmd.setEnabled(i != 0);
|
||||
BAlarmDetailsDialog.this.nextCmd.setEnabled(i + 1 < n);
|
||||
return null;
|
||||
}
|
||||
BAlarmDetailsDialog.this.prevCmd.setEnabled(false);
|
||||
BAlarmDetailsDialog.this.nextCmd.setEnabled(false);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class CloseCommand
|
||||
extends Command {
|
||||
public CloseCommand(BWidget bWidget) {
|
||||
super(bWidget, (Lexicon)UiLexicon.bajaui, "commands.close");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BAlarmDetailsDialog.this.close();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class HyperlinkCommand
|
||||
extends Command {
|
||||
public HyperlinkCommand(BWidget bWidget) {
|
||||
super(bWidget, (Lexicon)BAlarmConsole.lexicon, "commands.hyperlink");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BAlarmDetailsDialog.this.console.hyperlink(BAlarmDetailsDialog.this.alarm);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class NotesCommand
|
||||
extends Command {
|
||||
public NotesCommand(BWidget bWidget) {
|
||||
super(bWidget, (Lexicon)BAlarmConsole.lexicon, "commands.notes");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
if (BAlarmDetailsDialog.this.console != null) {
|
||||
BAlarmDetailsDialog.this.console.showNotes((BWidget)BAlarmDetailsDialog.this.alarmPane, new BAlarmRecord[]{BAlarmDetailsDialog.this.alarm});
|
||||
} else {
|
||||
if (BAlarmDetailsDialog.this.alarmDbChannel == null) {
|
||||
AlarmException alarmException = new AlarmException("Unable to find alarmDBChannel");
|
||||
BAlarmDetailsDialog.this.logger.error("Unable to find alarmDBChannel", (Throwable)((Object)alarmException));
|
||||
throw alarmException;
|
||||
}
|
||||
this.showAndAddNotes();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void showAndAddNotes() {
|
||||
String string = "";
|
||||
try {
|
||||
string = ((BString)BAlarmDetailsDialog.this.alarm.getAlarmData().getFacet("notes")).getString();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BAlarmDetailsDialog.this.logger.error("Exception occurred while fetching the notes ", (Throwable)exception);
|
||||
}
|
||||
String string2 = BAlarmDetailsDialog.this.alarmDbChannel.getClientConnection().getUsername();
|
||||
BNotesDialog bNotesDialog = new BNotesDialog(null, string, string2, true);
|
||||
bNotesDialog.setBoundsCenteredOnOwner();
|
||||
bNotesDialog.open();
|
||||
String string3 = bNotesDialog.getNewNotes();
|
||||
if (string3 != null) {
|
||||
string = string3 + string;
|
||||
BFacets bFacets = BAlarmDetailsDialog.this.alarm.getAlarmData();
|
||||
HashMap<String, Object> hashMap = new HashMap<String, Object>();
|
||||
String[] stringArray = bFacets.list();
|
||||
for (int i = 0; i < stringArray.length; ++i) {
|
||||
if (stringArray[i].equals("notes")) continue;
|
||||
BObject bObject = bFacets.get(stringArray[i]);
|
||||
hashMap.put(stringArray[i], bObject);
|
||||
}
|
||||
hashMap.put("notes", BString.make((String)string));
|
||||
BFacets bFacets2 = BFacets.make(hashMap);
|
||||
BAlarmDetailsDialog.this.alarm.setAlarmData(bFacets2);
|
||||
try {
|
||||
BAlarmDetailsDialog.this.alarmDbChannel.update(BAlarmDetailsDialog.this.alarm);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BAlarmDetailsDialog.this.logger.error("Exception while updating the notes for an alarm", (Throwable)exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class AckCommand
|
||||
extends Command {
|
||||
public AckCommand(BWidget bWidget) {
|
||||
super(bWidget, (Lexicon)BAlarmConsole.lexicon, "commands.acknowledge");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BAlarmDetailsDialog.this.console.acknowledgeAlarms(new BAlarmRecord[]{BAlarmDetailsDialog.this.alarm});
|
||||
BAlarmDetailsDialog.this.prevCmd.setEnabled(false);
|
||||
BAlarmDetailsDialog.this.nextCmd.setEnabled(false);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,410 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.gx.BBrush
|
||||
* javax.baja.gx.BColor
|
||||
* javax.baja.gx.BImage
|
||||
* javax.baja.gx.BInsets
|
||||
* javax.baja.gx.BPoint
|
||||
* javax.baja.gx.Point
|
||||
* javax.baja.naming.BOrd
|
||||
* 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.Slot
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BBorder
|
||||
* javax.baja.ui.BFrame
|
||||
* javax.baja.ui.BHyperlinkLabel
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.enums.BHalign
|
||||
* javax.baja.ui.enums.BValign
|
||||
* javax.baja.ui.event.BMouseEvent
|
||||
* javax.baja.ui.event.BWindowEvent
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BEdgePane
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.ui.util.UiLexicon
|
||||
* javax.baja.util.BFormat
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.alarm.ui.BAlarmConsoleOptions;
|
||||
import com.tridium.alarm.ui.portal.BAlarmPortalOptions;
|
||||
import com.tridium.alarm.ui.portal.BAlarmPortalTool;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.gx.BBrush;
|
||||
import javax.baja.gx.BColor;
|
||||
import javax.baja.gx.BImage;
|
||||
import javax.baja.gx.BInsets;
|
||||
import javax.baja.gx.BPoint;
|
||||
import javax.baja.gx.Point;
|
||||
import javax.baja.naming.BOrd;
|
||||
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.Slot;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BBorder;
|
||||
import javax.baja.ui.BFrame;
|
||||
import javax.baja.ui.BHyperlinkLabel;
|
||||
import javax.baja.ui.BLabel;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.enums.BHalign;
|
||||
import javax.baja.ui.enums.BValign;
|
||||
import javax.baja.ui.event.BMouseEvent;
|
||||
import javax.baja.ui.event.BWindowEvent;
|
||||
import javax.baja.ui.pane.BBorderPane;
|
||||
import javax.baja.ui.pane.BEdgePane;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.ui.util.UiLexicon;
|
||||
import javax.baja.util.BFormat;
|
||||
|
||||
public class BAlarmDialog
|
||||
extends BFrame {
|
||||
public static final Action update = BAlarmDialog.newAction((int)4, null);
|
||||
public static final Action handleHyperlink = BAlarmDialog.newAction((int)4, (BValue)new BMouseEvent(), null);
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BAlarmDialog == null ? (class$com$tridium$alarm$ui$BAlarmDialog = BAlarmDialog.class$("com.tridium.alarm.ui.BAlarmDialog")) : class$com$tridium$alarm$ui$BAlarmDialog));
|
||||
private BLabel lastAlarm;
|
||||
private BLabel lastAlarmSrc;
|
||||
private BLabel lastAlarmMsg;
|
||||
private BHyperlinkLabel lastAlarmHyperlink;
|
||||
private BLabel status;
|
||||
private BAlarmRecord lastAlarmRecord;
|
||||
private boolean lastAlarmRecordChanged;
|
||||
private BHyperlinkLabel imgLabel;
|
||||
private String title;
|
||||
private boolean fullyConnected = false;
|
||||
private int acked;
|
||||
private int unacked;
|
||||
private boolean sourcesInAlarm;
|
||||
private boolean alwaysOnTop;
|
||||
private boolean uncloseable;
|
||||
private boolean closed = true;
|
||||
private BAlarmPortalTool tool;
|
||||
static BImage alarmImg = BImage.make((String)"module://icons/x16/alarm.png");
|
||||
static BImage alarmRed = BImage.make((String)"module://alarm/com/tridium/alarm/icons/alarmRed.png");
|
||||
static BImage alarmGreen = BImage.make((String)"module://alarm/com/tridium/alarm/icons/alarmGreen.png");
|
||||
private static BImage ALARM_YELLOW = BImage.make((String)"module://alarm/com/tridium/alarm/ui/images/alarm.gif");
|
||||
private static BImage ALARM_GREEN = BImage.make((String)"module://alarm/com/tridium/alarm/ui/images/alarmGreen.gif");
|
||||
private static BImage ALARM_RED = BImage.make((String)"module://alarm/com/tridium/alarm/ui/images/alarmRed.gif");
|
||||
private static BImage ALARM_WHITE = BImage.make((String)"module://alarm/com/tridium/alarm/ui/images/alarmWhite.gif");
|
||||
private static BImage ALARM_GRAY = BImage.make((String)"module://alarm/com/tridium/alarm/ui/images/alarmGray.gif");
|
||||
public static final UiLexicon lexicon = new UiLexicon(class$com$tridium$alarm$ui$BAlarmDialog == null ? (class$com$tridium$alarm$ui$BAlarmDialog = BAlarmDialog.class$("com.tridium.alarm.ui.BAlarmDialog")) : class$com$tridium$alarm$ui$BAlarmDialog);
|
||||
public BAlarmConsoleOptions options = BAlarmConsoleOptions.getDefault();
|
||||
public static final BFacets TIME_FACETS = BFacets.make((String)"showTimeZone", (BIDataValue)BBoolean.FALSE, (String)"showSeconds", (BIDataValue)BBoolean.TRUE);
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmDialog;
|
||||
|
||||
public void update() {
|
||||
this.invoke(update, null, null);
|
||||
}
|
||||
|
||||
public void handleHyperlink(BMouseEvent bMouseEvent) {
|
||||
this.invoke(handleHyperlink, (BValue)bMouseEvent, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BAlarmDialog() {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
public BAlarmDialog(BAlarmPortalTool bAlarmPortalTool, String string, BImage bImage, BAlarmRecord bAlarmRecord, int n, int n2, boolean bl, boolean bl2) {
|
||||
super(string);
|
||||
this.acked = n;
|
||||
this.unacked = n2;
|
||||
this.title = string;
|
||||
this.alwaysOnTop = bl;
|
||||
this.uncloseable = bl2;
|
||||
this.tool = bAlarmPortalTool;
|
||||
BAlarmPortalOptions bAlarmPortalOptions = BAlarmPortalOptions.getDefault();
|
||||
BPoint bPoint = bAlarmPortalOptions.getPopupPosition();
|
||||
this.setVisible(true);
|
||||
this.setIconImage(bImage);
|
||||
String string2 = lexicon.getText("portal.popup.lastAlarm") + ": ";
|
||||
String string3 = lexicon.getText("portal.popup.source") + ": ";
|
||||
String string4 = lexicon.getText("portal.popup.message") + ": ";
|
||||
String string5 = lexicon.getText("portal.popup.hyperlink") + ": ";
|
||||
BEdgePane bEdgePane = new BEdgePane();
|
||||
BGridPane bGridPane = new BGridPane(1);
|
||||
bGridPane.setValign(BValign.top);
|
||||
bGridPane.setHalign(BHalign.center);
|
||||
bGridPane.setColumnAlign(BHalign.center);
|
||||
this.imgLabel = new BHyperlinkLabel();
|
||||
this.imgLabel.setImage(ALARM_GRAY);
|
||||
this.imgLabel.setBackground(BColor.white.toBrush());
|
||||
BBorderPane bBorderPane = new BBorderPane((BWidget)this.imgLabel);
|
||||
bBorderPane.setBorder(BBorder.make((double)1.0, (int)1, (BBrush)BColor.black.toBrush()));
|
||||
bBorderPane.setMargin(BInsets.make((double)15.0, (double)20.0, (double)10.0, (double)20.0));
|
||||
bBorderPane.setPadding(BInsets.NULL);
|
||||
bGridPane.add(null, (BValue)bBorderPane);
|
||||
this.linkTo((BComponent)this.imgLabel, (Slot)BWidget.mouseEvent, (Slot)handleHyperlink);
|
||||
this.status = new BLabel();
|
||||
this.status.setHalign(BHalign.center);
|
||||
this.status.setPadding(BInsets.make((double)0.0, (double)10.0, (double)0.0, (double)10.0));
|
||||
bGridPane.add(null, (BValue)this.status);
|
||||
BGridPane bGridPane2 = new BGridPane(2);
|
||||
bGridPane2.setRowAlign(BValign.top);
|
||||
bGridPane2.setColumnAlign(BHalign.left);
|
||||
BLabel bLabel = new BLabel(string2);
|
||||
bLabel.setPadding(BInsets.make((double)10.0, (double)0.0, (double)0.0, (double)0.0));
|
||||
bLabel.setHalign(BHalign.left);
|
||||
bGridPane2.add(null, (BValue)bLabel);
|
||||
this.lastAlarm = new BLabel();
|
||||
this.lastAlarm.setPadding(BInsets.make((double)10.0, (double)0.0, (double)0.0, (double)0.0));
|
||||
this.lastAlarm.setHalign(BHalign.left);
|
||||
bGridPane2.add(null, (BValue)this.lastAlarm);
|
||||
BLabel bLabel2 = new BLabel(string3);
|
||||
bLabel2.setHalign(BHalign.left);
|
||||
bGridPane2.add(null, (BValue)bLabel2);
|
||||
this.lastAlarmSrc = new BLabel();
|
||||
this.lastAlarmSrc.setHalign(BHalign.left);
|
||||
bGridPane2.add(null, (BValue)this.lastAlarmSrc);
|
||||
BLabel bLabel3 = new BLabel(string4);
|
||||
bLabel3.setHalign(BHalign.left);
|
||||
bGridPane2.add(null, (BValue)bLabel3);
|
||||
this.lastAlarmMsg = new BLabel();
|
||||
this.lastAlarmMsg.setHalign(BHalign.left);
|
||||
bGridPane2.add(null, (BValue)this.lastAlarmMsg);
|
||||
BLabel bLabel4 = new BLabel(string5);
|
||||
bLabel4.setHalign(BHalign.left);
|
||||
bLabel4.setPadding(BInsets.make((double)0.0, (double)0.0, (double)10.0, (double)0.0));
|
||||
bGridPane2.add(null, (BValue)bLabel4);
|
||||
this.lastAlarmHyperlink = new BHyperlinkLabel();
|
||||
this.lastAlarmHyperlink.setHalign(BHalign.left);
|
||||
this.lastAlarmHyperlink.setPadding(BInsets.make((double)0.0, (double)0.0, (double)10.0, (double)0.0));
|
||||
bGridPane2.add(null, (BValue)this.lastAlarmHyperlink);
|
||||
this.linkTo((BComponent)this.lastAlarmHyperlink, (Slot)BWidget.mouseEvent, (Slot)handleHyperlink);
|
||||
bEdgePane.setLeft((BWidget)bGridPane);
|
||||
bEdgePane.setCenter((BWidget)bGridPane2);
|
||||
bEdgePane.computePreferredSize();
|
||||
this.setScreenBounds(bPoint.x(), bPoint.y(), bEdgePane.getPreferredWidth() + 50.0, bEdgePane.getPreferredHeight() + 50.0);
|
||||
this.setContent((BWidget)bEdgePane);
|
||||
if (bAlarmRecord != null) {
|
||||
this.updateLastAlarm(bAlarmRecord);
|
||||
}
|
||||
try {
|
||||
this.doLoad();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
this.setAlwaysOnTop(string, bl);
|
||||
Thread thread = new Thread(){
|
||||
|
||||
public void run() {
|
||||
while (!BAlarmDialog.this.closed) {
|
||||
BAlarmDialog.this.update();
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
}
|
||||
catch (InterruptedException interruptedException) {}
|
||||
}
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
}
|
||||
|
||||
protected void doLoad() throws Exception {
|
||||
System.loadLibrary("alarmDialog");
|
||||
}
|
||||
|
||||
public void windowClosing(BWindowEvent bWindowEvent) {
|
||||
if (!this.uncloseable) {
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void open() {
|
||||
if (this.closed) {
|
||||
this.closed = false;
|
||||
super.open();
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
this.tool.onAlarmDialogClosed(this);
|
||||
this.closed = true;
|
||||
this.releaseNativeResources(this.title);
|
||||
this.setVisible(false);
|
||||
super.close();
|
||||
}
|
||||
|
||||
public void windowDeactivated(BWindowEvent bWindowEvent) {
|
||||
if (!this.closed) {
|
||||
this.setAlwaysOnTop(this.title, this.alwaysOnTop);
|
||||
}
|
||||
}
|
||||
|
||||
public void windowActivated(BWindowEvent bWindowEvent) {
|
||||
if (!this.closed) {
|
||||
this.setAlwaysOnTop(this.title, this.alwaysOnTop);
|
||||
}
|
||||
}
|
||||
|
||||
public void windowDeiconified(BWindowEvent bWindowEvent) {
|
||||
if (!this.closed) {
|
||||
this.setAlwaysOnTop(this.title, this.alwaysOnTop);
|
||||
}
|
||||
}
|
||||
|
||||
public void windowIconified(BWindowEvent bWindowEvent) {
|
||||
if (!this.closed) {
|
||||
this.setAlwaysOnTop(this.title, this.alwaysOnTop);
|
||||
if (this.alwaysOnTop) {
|
||||
this.toTop(this.title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getPixel(BWidget bWidget, int n, int n2) {
|
||||
bWidget = (BWidget)bWidget.getParent();
|
||||
while (bWidget.getParent() != null) {
|
||||
Point point = new Point(bWidget.getX(), bWidget.getY());
|
||||
n = (int)((double)n + point.x);
|
||||
n2 = (int)((double)n2 + point.y);
|
||||
bWidget = (BWidget)bWidget.getParent();
|
||||
}
|
||||
return this.getPixel(n -= 3, n2 -= 22);
|
||||
}
|
||||
|
||||
public void doUpdate() {
|
||||
BObject bObject;
|
||||
Object object;
|
||||
if (this.lastAlarmRecord != null && this.lastAlarmRecordChanged) {
|
||||
this.lastAlarmRecordChanged = false;
|
||||
object = this.lastAlarmRecord.getSource().toString();
|
||||
bObject = this.lastAlarmRecord.getAlarmData().get("sourceName");
|
||||
if (bObject != null && !bObject.toString().equals("")) {
|
||||
object = BFormat.make((String)this.lastAlarmRecord.getAlarmData().get("sourceName").toString()).format((Object)this.lastAlarmRecord);
|
||||
}
|
||||
this.lastAlarmSrc.setText((String)object);
|
||||
this.lastAlarm.setText(this.lastAlarmRecord.getTimestamp().toString());
|
||||
this.lastAlarm.setImage(alarmImg);
|
||||
String string = "";
|
||||
if (this.lastAlarmRecord.getAlarmData().get("msgText") != null) {
|
||||
string = this.lastAlarmRecord.getAlarmData().get("msgText").toString();
|
||||
}
|
||||
this.lastAlarmMsg.setText(lexicon.getText(BFormat.make((String)string).format((Object)this.lastAlarmRecord)));
|
||||
String string2 = "";
|
||||
if (this.lastAlarmRecord.getAlarmData().get("hyperlinkOrd") != null) {
|
||||
string2 = this.lastAlarmRecord.getAlarmData().get("hyperlinkOrd").toString();
|
||||
this.lastAlarmHyperlink.setText(BFormat.make((String)string2).format((Object)this.lastAlarmRecord));
|
||||
this.lastAlarmHyperlink.setOrd(BOrd.make((String)string2));
|
||||
this.lastAlarmHyperlink.setVisible(true);
|
||||
this.imgLabel.setOrd(BOrd.make((String)string2));
|
||||
} else {
|
||||
this.lastAlarmHyperlink.setVisible(false);
|
||||
this.lastAlarmHyperlink.setOrd(BOrd.NULL);
|
||||
this.imgLabel.setOrd(BOrd.NULL);
|
||||
}
|
||||
}
|
||||
object = new Object[]{new Integer(this.acked), new Integer(this.unacked)};
|
||||
this.status.setText(lexicon.getText("portal.popup.unackedAlarms", object));
|
||||
this.updateImage(this.sourcesInAlarm);
|
||||
bObject = this.getContent();
|
||||
bObject.computePreferredSize();
|
||||
this.setScreenBounds(this.getScreenBounds().x(), this.getScreenBounds().y(), bObject.getPreferredWidth() + 50.0, bObject.getPreferredHeight() + 50.0);
|
||||
this.repaint();
|
||||
this.toTop(this.title);
|
||||
}
|
||||
|
||||
public void updateLastAlarm(BAlarmRecord bAlarmRecord) {
|
||||
this.lastAlarmRecord = bAlarmRecord;
|
||||
this.lastAlarmRecordChanged = true;
|
||||
}
|
||||
|
||||
public void updateAlarmCounts(int n, int n2, boolean bl) {
|
||||
boolean bl2 = n != this.acked;
|
||||
bl2 |= n2 != this.unacked;
|
||||
bl2 |= bl != this.sourcesInAlarm;
|
||||
this.unacked = n2;
|
||||
this.acked = n;
|
||||
this.sourcesInAlarm = bl;
|
||||
}
|
||||
|
||||
private void updateImage(BImage bImage) {
|
||||
if (!this.imgLabel.getImage().equals((Object)bImage)) {
|
||||
this.imgLabel.setImage(bImage);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateImage(boolean bl) {
|
||||
if (!this.fullyConnected) {
|
||||
this.updateImage(ALARM_GRAY);
|
||||
} else if (this.unacked > 0) {
|
||||
if (bl) {
|
||||
this.updateImage(ALARM_RED);
|
||||
} else {
|
||||
this.updateImage(ALARM_GREEN);
|
||||
}
|
||||
} else if (this.unacked == 0 && this.acked > 0) {
|
||||
this.updateImage(ALARM_YELLOW);
|
||||
} else if (this.acked == 0 && this.unacked == 0) {
|
||||
this.updateImage(ALARM_WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
public void doHandleHyperlink(BMouseEvent bMouseEvent) {
|
||||
switch (bMouseEvent.getId()) {
|
||||
case 501: {
|
||||
this.fireHyperlink(this.lastAlarmHyperlink.getOrd());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void fireHyperlink(BOrd bOrd) {
|
||||
if (bOrd.isNull()) {
|
||||
return;
|
||||
}
|
||||
this.tool.onAlarmDialogHyperlink(this, bOrd);
|
||||
}
|
||||
|
||||
public void setUncloseable(boolean bl) {
|
||||
this.uncloseable = bl;
|
||||
}
|
||||
|
||||
public void setAlwaysOnTop(boolean bl) {
|
||||
this.alwaysOnTop = bl;
|
||||
this.setAlwaysOnTop(this.title, bl);
|
||||
if (bl) {
|
||||
this.toTop(this.title);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFullyConnected(boolean bl) {
|
||||
this.fullyConnected = bl;
|
||||
}
|
||||
|
||||
public native void setAlwaysOnTop(String var1, boolean var2);
|
||||
|
||||
public native void toTop(String var1);
|
||||
|
||||
public native int getPixel(int var1, int var2);
|
||||
|
||||
public native void releaseNativeResources(String var1);
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,654 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.ui.theme.Theme
|
||||
* com.tridium.workbench.bql.filter.ColumnNameTableModel
|
||||
* com.tridium.workbench.job.BJobBar
|
||||
* com.tridium.workbench.util.CollectionTableModel
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.collection.BITable
|
||||
* javax.baja.collection.ColumnList
|
||||
* javax.baja.data.BIDataTable
|
||||
* javax.baja.gx.BColor
|
||||
* javax.baja.gx.BImage
|
||||
* javax.baja.gx.BInsets
|
||||
* javax.baja.gx.Graphics
|
||||
* javax.baja.job.BJob
|
||||
* javax.baja.job.BJobService
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.SlotPath
|
||||
* javax.baja.nre.util.IntHashMap
|
||||
* javax.baja.status.BStatus
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BLink
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.BVector
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Slot
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BBorder
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BMenu
|
||||
* javax.baja.ui.BSeparator
|
||||
* javax.baja.ui.BSubMenuItem
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.BWidgetShell
|
||||
* javax.baja.ui.Command
|
||||
* javax.baja.ui.CommandArtifact
|
||||
* javax.baja.ui.ToggleCommand
|
||||
* javax.baja.ui.event.BMouseEvent
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BEdgePane
|
||||
* javax.baja.ui.table.BTable
|
||||
* javax.baja.ui.table.DynamicTableModel
|
||||
* javax.baja.ui.table.TableCellRenderer
|
||||
* javax.baja.ui.table.TableCellRenderer$Cell
|
||||
* javax.baja.ui.table.TableController
|
||||
* javax.baja.ui.table.TableModel
|
||||
* javax.baja.ui.table.WrapperTableModel
|
||||
* javax.baja.ui.util.BTitlePane
|
||||
* javax.baja.util.Lexicon
|
||||
* javax.baja.workbench.BWbShell
|
||||
* javax.baja.workbench.nav.menu.NavMenuUtil
|
||||
* javax.baja.workbench.view.BWbComponentView
|
||||
* javax.baja.workbench.view.BWbComponentView$Attachable
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.alarm.BAlarmExtStatusJob;
|
||||
import com.tridium.alarm.ui.BAlarmClassFE;
|
||||
import com.tridium.alarm.ui.BInstructionsFE;
|
||||
import com.tridium.ui.theme.Theme;
|
||||
import com.tridium.workbench.bql.filter.ColumnNameTableModel;
|
||||
import com.tridium.workbench.job.BJobBar;
|
||||
import com.tridium.workbench.util.CollectionTableModel;
|
||||
import javax.baja.alarm.BAlarmInstructions;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.alarm.ext.BAlarmSourceExt;
|
||||
import javax.baja.alarm.ext.BAlarmState;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.collection.BITable;
|
||||
import javax.baja.collection.ColumnList;
|
||||
import javax.baja.data.BIDataTable;
|
||||
import javax.baja.gx.BColor;
|
||||
import javax.baja.gx.BImage;
|
||||
import javax.baja.gx.BInsets;
|
||||
import javax.baja.gx.Graphics;
|
||||
import javax.baja.job.BJob;
|
||||
import javax.baja.job.BJobService;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.SlotPath;
|
||||
import javax.baja.nre.util.IntHashMap;
|
||||
import javax.baja.status.BStatus;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BLink;
|
||||
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.Slot;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BBorder;
|
||||
import javax.baja.ui.BDialog;
|
||||
import javax.baja.ui.BMenu;
|
||||
import javax.baja.ui.BSeparator;
|
||||
import javax.baja.ui.BSubMenuItem;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.BWidgetShell;
|
||||
import javax.baja.ui.Command;
|
||||
import javax.baja.ui.CommandArtifact;
|
||||
import javax.baja.ui.ToggleCommand;
|
||||
import javax.baja.ui.event.BMouseEvent;
|
||||
import javax.baja.ui.pane.BBorderPane;
|
||||
import javax.baja.ui.pane.BEdgePane;
|
||||
import javax.baja.ui.table.BTable;
|
||||
import javax.baja.ui.table.DynamicTableModel;
|
||||
import javax.baja.ui.table.TableCellRenderer;
|
||||
import javax.baja.ui.table.TableController;
|
||||
import javax.baja.ui.table.TableModel;
|
||||
import javax.baja.ui.table.WrapperTableModel;
|
||||
import javax.baja.ui.util.BTitlePane;
|
||||
import javax.baja.util.Lexicon;
|
||||
import javax.baja.workbench.BWbShell;
|
||||
import javax.baja.workbench.nav.menu.NavMenuUtil;
|
||||
import javax.baja.workbench.view.BWbComponentView;
|
||||
|
||||
public class BAlarmExtManager
|
||||
extends BWbComponentView {
|
||||
public static final Action updateCommands = BAlarmExtManager.newAction((int)4, null);
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BAlarmExtManager == null ? (class$com$tridium$alarm$ui$BAlarmExtManager = BAlarmExtManager.class$("com.tridium.alarm.ui.BAlarmExtManager")) : class$com$tridium$alarm$ui$BAlarmExtManager));
|
||||
private static final String[] ATTRS = new String[]{"parent.toPathString", "toPathString", "name", "alarmState", "alarmEnable.isToOffnormal", "alarmEnable.isToFault", "alarmState.ordinal", "alarmClass", "alarmInstructions", "status"};
|
||||
private static final int[] DISPLAY = new int[]{0, 2, 3, 4, 5, 7, 8};
|
||||
private static Lexicon lex = Lexicon.make((String)"alarm");
|
||||
private BAlarmService alarmService;
|
||||
private BTable table;
|
||||
private BITable itable;
|
||||
private CollectionTableModel collectionModel;
|
||||
private ToggleCommand enableToOffnormal;
|
||||
private ToggleCommand enableToFault;
|
||||
private Command editAlarmClass;
|
||||
private Command editInstructions;
|
||||
private IntHashMap nameMap;
|
||||
private BBorderPane topPane;
|
||||
private BJobBar jobBar;
|
||||
private BJob job;
|
||||
private boolean jobComplete;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmExtManager;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$BAlarmExtStatusJob;
|
||||
|
||||
public void updateCommands() {
|
||||
this.invoke(updateCommands, null, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BAlarmExtManager() {
|
||||
BEdgePane bEdgePane = new BEdgePane();
|
||||
this.jobBar = new BJobBar();
|
||||
this.attach((BWbComponentView.Attachable)this.jobBar);
|
||||
BBorderPane bBorderPane = new BBorderPane((BWidget)this.jobBar, BBorder.solid, BInsets.make((double)0.0, (double)5.0, (double)0.0, (double)5.0));
|
||||
bBorderPane.setFill(Theme.widget().getWindowBackground());
|
||||
bBorderPane = new BBorderPane((BWidget)bBorderPane, BBorder.inset, BInsets.DEFAULT);
|
||||
this.topPane = new BBorderPane((BWidget)bBorderPane, BInsets.make((double)0.0, (double)0.0, (double)5.0, (double)0.0));
|
||||
bEdgePane.setTop((BWidget)this.topPane);
|
||||
this.topPane.setVisible(false);
|
||||
this.table = new BTable();
|
||||
this.table.setController((TableController)new Controller());
|
||||
this.table.setCellRenderer((TableCellRenderer)new CellRenderer());
|
||||
bEdgePane.setCenter((BWidget)BTitlePane.makePane((String)lex.getText("alarm.alarmSourceExts"), (BTable)this.table, (String)lex.getText("alarm.exts")));
|
||||
this.setContent((BWidget)bEdgePane);
|
||||
this.enableToOffnormal = new EnableToOffnormal();
|
||||
this.enableToFault = new EnableToFault();
|
||||
this.editAlarmClass = new EditAlarmClass();
|
||||
this.editInstructions = new EditInstructions();
|
||||
this.add("selectionLink", (BValue)new BLink((BComponent)this.table, (Slot)BTable.selectionModified, (Slot)updateCommands));
|
||||
this.nameMap = new IntHashMap();
|
||||
this.nameMap.put(0, (Object)"alarm.point");
|
||||
this.nameMap.put(2, (Object)"alarm.extension");
|
||||
this.nameMap.put(3, (Object)"alarm.alarmState");
|
||||
this.nameMap.put(4, (Object)"alarm.toOffnormalEnabled.label");
|
||||
this.nameMap.put(5, (Object)"alarm.toFaultEnabled.label");
|
||||
this.nameMap.put(7, (Object)"alarm.alarmClass");
|
||||
this.nameMap.put(8, (Object)"alarm.instructions");
|
||||
}
|
||||
|
||||
protected void doLoadValue(BObject bObject, Context context) throws Exception {
|
||||
this.alarmService = (BAlarmService)bObject;
|
||||
this.updateTable();
|
||||
this.table.fireTableModified(null);
|
||||
}
|
||||
|
||||
private void updateTable() {
|
||||
BOrd bOrd = ((BWbShell)this.getShell()).getActiveOrd();
|
||||
BOrd bOrd2 = BOrd.make((BOrd)bOrd, (String)this.query()).normalize();
|
||||
this.itable = ((BICollection)bOrd2.resolve().get()).toTable();
|
||||
boolean bl = false;
|
||||
int n = -1;
|
||||
boolean bl2 = true;
|
||||
if (this.table.getModel() instanceof AlarmExtTableModel) {
|
||||
bl = true;
|
||||
n = ((AlarmExtTableModel)this.table.getModel()).sortCol;
|
||||
bl2 = ((AlarmExtTableModel)this.table.getModel()).sortAsc;
|
||||
}
|
||||
this.collectionModel = new CollectionTableModel(this.itable, this.getCurrentContext());
|
||||
ColumnNameTableModel columnNameTableModel = new ColumnNameTableModel((TableModel)this.collectionModel, this.nameMap, lex);
|
||||
AlarmExtTableModel alarmExtTableModel = new AlarmExtTableModel((TableModel)columnNameTableModel, DISPLAY);
|
||||
alarmExtTableModel.setColumnShowable(1, false);
|
||||
alarmExtTableModel.setColumnShowable(6, false);
|
||||
if (bl && n != -1) {
|
||||
alarmExtTableModel.sortByColumn(n, bl2);
|
||||
}
|
||||
this.table.setModel((TableModel)alarmExtTableModel);
|
||||
this.table.relayout();
|
||||
}
|
||||
|
||||
private String query() {
|
||||
StringBuffer stringBuffer = new StringBuffer(128);
|
||||
stringBuffer.append("station:|slot:/|bql:select ");
|
||||
for (int i = 0; i < ATTRS.length; ++i) {
|
||||
if (i != 0) {
|
||||
stringBuffer.append(", ");
|
||||
}
|
||||
stringBuffer.append(ATTRS[i]);
|
||||
}
|
||||
stringBuffer.append(" from alarm:AlarmSourceExt");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public void doUpdateCommands() {
|
||||
}
|
||||
|
||||
public BOrd[] getSelectedOrds() {
|
||||
int[] nArray = this.table.getSelection().getRows();
|
||||
int n = nArray.length;
|
||||
BOrd[] bOrdArray = new BOrd[n];
|
||||
for (int i = 0; i < n; ++i) {
|
||||
String string = this.itable.getString(nArray[i], this.itable.getColumns().get("toPathString"));
|
||||
bOrdArray[i] = BOrd.make((String)("station:|slot:" + string)).normalize();
|
||||
}
|
||||
return bOrdArray;
|
||||
}
|
||||
|
||||
public BAlarmSourceExt getExtensionForRow(int n) {
|
||||
String string = this.collectionModel.getValueAt(n, 1).toString();
|
||||
BOrd bOrd = ((BWbShell)this.getShell()).getActiveOrd();
|
||||
BOrd bOrd2 = BOrd.make((BOrd)bOrd, (String)("slot:" + string)).normalize();
|
||||
return (BAlarmSourceExt)bOrd2.resolve().get();
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public void enableToOffnormal() {
|
||||
BWidgetShell bWidgetShell;
|
||||
BOrd[] bOrdArray = this.getSelectedOrds();
|
||||
if (bOrdArray.length == 0) {
|
||||
return;
|
||||
}
|
||||
BOrd bOrd = ((BWbShell)this.getShell()).getActiveOrd();
|
||||
BOrd bOrd2 = BOrd.make((BOrd)bOrd, (String)"service:baja:JobService");
|
||||
BJobService bJobService = (BJobService)bOrd2.resolve().get();
|
||||
bJobService.lease();
|
||||
BAlarmExtStatusJob[] bAlarmExtStatusJobArray = (BAlarmExtStatusJob[])bJobService.getChildren(class$com$tridium$alarm$BAlarmExtStatusJob == null ? (class$com$tridium$alarm$BAlarmExtStatusJob = BAlarmExtManager.class$("com.tridium.alarm.BAlarmExtStatusJob")) : class$com$tridium$alarm$BAlarmExtStatusJob);
|
||||
if (bAlarmExtStatusJobArray != null) {
|
||||
for (int i = 0; i < bAlarmExtStatusJobArray.length; ++i) {
|
||||
if (bAlarmExtStatusJobArray[i] == null) continue;
|
||||
bAlarmExtStatusJobArray[i].lease();
|
||||
if (!bAlarmExtStatusJobArray[i].isAlive()) continue;
|
||||
BDialog.error((BWidget)this, (String)lex.getText("alarmExtManager.commandFail"), (Object)lex.getText("alarmExtManager.statusJobExists"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!this.topPane.isVisible()) {
|
||||
this.topPane.setVisible(true);
|
||||
this.topPane.getParentWidget().relayout();
|
||||
}
|
||||
if ((bWidgetShell = this.getShell()) != null) {
|
||||
bWidgetShell.enterBusy();
|
||||
}
|
||||
try {
|
||||
BOrd bOrd3 = BOrd.make((BOrd)bOrd, (String)"service:alarm:AlarmService");
|
||||
BAlarmService bAlarmService = (BAlarmService)bOrd3.resolve().get();
|
||||
BVector bVector = new BVector();
|
||||
for (int i = 0; i < bOrdArray.length; ++i) {
|
||||
bVector.add("o" + i, (BValue)bOrdArray[i]);
|
||||
}
|
||||
if (this.enableToOffnormal.isSelected()) {
|
||||
this.setJob(bAlarmService.enableToOffnormal(bVector), bAlarmService);
|
||||
} else {
|
||||
this.setJob(bAlarmService.disableToOffnormal(bVector), bAlarmService);
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
if (bWidgetShell != null) {
|
||||
bWidgetShell.exitBusy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public void enableToFault() {
|
||||
BWidgetShell bWidgetShell;
|
||||
BOrd[] bOrdArray = this.getSelectedOrds();
|
||||
if (bOrdArray.length == 0) {
|
||||
return;
|
||||
}
|
||||
BOrd bOrd = ((BWbShell)this.getShell()).getActiveOrd();
|
||||
BOrd bOrd2 = BOrd.make((BOrd)bOrd, (String)"service:baja:JobService");
|
||||
BJobService bJobService = (BJobService)bOrd2.resolve().get();
|
||||
bJobService.lease();
|
||||
BAlarmExtStatusJob[] bAlarmExtStatusJobArray = (BAlarmExtStatusJob[])bJobService.getChildren(class$com$tridium$alarm$BAlarmExtStatusJob == null ? (class$com$tridium$alarm$BAlarmExtStatusJob = BAlarmExtManager.class$("com.tridium.alarm.BAlarmExtStatusJob")) : class$com$tridium$alarm$BAlarmExtStatusJob);
|
||||
if (bAlarmExtStatusJobArray != null) {
|
||||
for (int i = 0; i < bAlarmExtStatusJobArray.length; ++i) {
|
||||
if (bAlarmExtStatusJobArray[i] == null) continue;
|
||||
bAlarmExtStatusJobArray[i].lease();
|
||||
if (!bAlarmExtStatusJobArray[i].isAlive()) continue;
|
||||
BDialog.error((BWidget)this, (String)lex.getText("alarmExtManager.commandFail"), (Object)lex.getText("alarmExtManager.statusJobExists"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!this.topPane.isVisible()) {
|
||||
this.topPane.setVisible(true);
|
||||
this.topPane.getParentWidget().relayout();
|
||||
}
|
||||
if ((bWidgetShell = this.getShell()) != null) {
|
||||
bWidgetShell.enterBusy();
|
||||
}
|
||||
try {
|
||||
BOrd bOrd3 = BOrd.make((BOrd)bOrd, (String)"service:alarm:AlarmService");
|
||||
BAlarmService bAlarmService = (BAlarmService)bOrd3.resolve().get();
|
||||
BVector bVector = new BVector();
|
||||
for (int i = 0; i < bOrdArray.length; ++i) {
|
||||
bVector.add("o" + i, (BValue)bOrdArray[i]);
|
||||
}
|
||||
if (this.enableToOffnormal.isSelected()) {
|
||||
this.setJob(bAlarmService.enableToFault(bVector), bAlarmService);
|
||||
} else {
|
||||
this.setJob(bAlarmService.disableToFault(bVector), bAlarmService);
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
if (bWidgetShell != null) {
|
||||
bWidgetShell.exitBusy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BJob getJob() {
|
||||
return this.job;
|
||||
}
|
||||
|
||||
private void setJob(BJob bJob) {
|
||||
this.job = bJob;
|
||||
this.jobComplete = false;
|
||||
this.registerForComponentEvents((BComponent)bJob);
|
||||
this.jobBar.load(bJob);
|
||||
if (bJob != null && bJob.getJobState().isComplete() && !this.jobComplete) {
|
||||
this.jobComplete = true;
|
||||
this.jobComplete(bJob);
|
||||
}
|
||||
}
|
||||
|
||||
private void setJob(BOrd bOrd, BAlarmService bAlarmService) throws Exception {
|
||||
bAlarmService.getComponentSpace().sync();
|
||||
BJob bJob = (BJob)bOrd.get((BObject)bAlarmService);
|
||||
this.setJob(bJob);
|
||||
}
|
||||
|
||||
private void jobComplete(BJob bJob) {
|
||||
this.updateTable();
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public class AlarmExtTableModel
|
||||
extends DynamicTableModel {
|
||||
public int sortCol = -1;
|
||||
public boolean sortAsc = true;
|
||||
|
||||
public AlarmExtTableModel(TableModel tableModel, int[] nArray) {
|
||||
super(tableModel, nArray);
|
||||
}
|
||||
|
||||
public AlarmExtTableModel(TableModel tableModel) {
|
||||
super(tableModel);
|
||||
}
|
||||
|
||||
public void sortByColumn(int n, boolean bl) {
|
||||
this.sortCol = n;
|
||||
this.sortAsc = bl;
|
||||
super.sortByColumn(n, bl);
|
||||
}
|
||||
|
||||
public Object getValueAt(int n, int n2) {
|
||||
Object object = super.getValueAt(n, n2);
|
||||
if (this.toRootColumnIndex(n2) == 7) {
|
||||
try {
|
||||
return BAlarmExtManager.this.alarmService.getAlarmClassDisplayName(BString.make((String)object.toString()), null).toString();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
return object.toString();
|
||||
}
|
||||
}
|
||||
if (object instanceof String) {
|
||||
object = SlotPath.unescape((String)((String)object));
|
||||
}
|
||||
return object;
|
||||
}
|
||||
}
|
||||
|
||||
public class GotoPoint
|
||||
extends Goto {
|
||||
public GotoPoint(int n, BITable bITable) {
|
||||
super("alarmExtManager.goto.point", n, bITable);
|
||||
}
|
||||
|
||||
public BOrd getTargetOrd() {
|
||||
return BOrd.make((String)("slot:" + BAlarmExtManager.this.collectionModel.getValueAt(this.row, 0)));
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class Goto
|
||||
extends Command {
|
||||
int row;
|
||||
BITable itable;
|
||||
|
||||
public Goto(String string, int n, BITable bITable) {
|
||||
super((BWidget)BAlarmExtManager.this, Sys.getModuleForClass((Class)(class$com$tridium$alarm$ui$BAlarmExtManager == null ? (class$com$tridium$alarm$ui$BAlarmExtManager = BAlarmExtManager.class$("com.tridium.alarm.ui.BAlarmExtManager")) : class$com$tridium$alarm$ui$BAlarmExtManager)), string);
|
||||
this.row = n;
|
||||
this.itable = bITable;
|
||||
}
|
||||
|
||||
public abstract BOrd getTargetOrd();
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BOrd bOrd = this.getTargetOrd();
|
||||
if (bOrd == null) {
|
||||
return null;
|
||||
}
|
||||
BOrd bOrd2 = ((BWbShell)BAlarmExtManager.this.getShell()).getActiveOrd();
|
||||
BOrd bOrd3 = BOrd.make((BOrd)bOrd2, (BOrd)bOrd).normalize();
|
||||
((BWbShell)this.getShell()).hyperlink(bOrd3);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class CellRenderer
|
||||
extends TableCellRenderer {
|
||||
BIDataTable lastTable = null;
|
||||
int stateOrdCol = -1;
|
||||
|
||||
private CellRenderer() {
|
||||
}
|
||||
|
||||
protected void paintCellBackground(Graphics graphics, TableCellRenderer.Cell cell) {
|
||||
if (cell.selected) {
|
||||
super.paintCellBackground(graphics, cell);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
ColumnList columnList = BAlarmExtManager.this.itable.getColumns();
|
||||
if (BAlarmExtManager.this.itable != this.lastTable || this.stateOrdCol == -1) {
|
||||
this.stateOrdCol = columnList.indexOf("alarmState.ordinal");
|
||||
}
|
||||
BColor bColor = null;
|
||||
BColor bColor2 = null;
|
||||
TableModel tableModel = BAlarmExtManager.this.table.getModel();
|
||||
if (!(tableModel instanceof WrapperTableModel)) {
|
||||
super.paintCellBackground(graphics, cell);
|
||||
return;
|
||||
}
|
||||
int n = Integer.parseInt(((WrapperTableModel)tableModel).getRootModel().getValueAt(cell.row, this.stateOrdCol).toString());
|
||||
if (n != BAlarmState.normal.getOrdinal()) {
|
||||
if (n == BAlarmState.fault.getOrdinal()) {
|
||||
bColor = (BColor)BStatus.faultBg;
|
||||
bColor2 = (BColor)BStatus.faultFg;
|
||||
} else {
|
||||
bColor = (BColor)BStatus.alarmBg;
|
||||
bColor2 = (BColor)BStatus.alarmFg;
|
||||
}
|
||||
}
|
||||
if (bColor != null) {
|
||||
graphics.setBrush(bColor);
|
||||
graphics.fillRect(0.0, 0.0, cell.width, cell.height);
|
||||
graphics.setBrush(bColor2);
|
||||
} else {
|
||||
graphics.setBrush(Theme.table().getTextBrush());
|
||||
}
|
||||
graphics.setFont(Theme.table().getCellFont());
|
||||
}
|
||||
catch (ClassCastException classCastException) {
|
||||
super.paintCellBackground(graphics, cell);
|
||||
}
|
||||
catch (NullPointerException nullPointerException) {
|
||||
super.paintCellBackground(graphics, cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class Controller
|
||||
extends TableController {
|
||||
private Controller() {
|
||||
}
|
||||
|
||||
protected void cellDoubleClicked(BMouseEvent bMouseEvent, int n, int n2) {
|
||||
ColumnList columnList = BAlarmExtManager.this.itable.getColumns();
|
||||
BOrd bOrd = null;
|
||||
String string = BAlarmExtManager.this.collectionModel.getValueAt(n, 1).toString();
|
||||
BOrd bOrd2 = ((BWbShell)this.getShell()).getActiveOrd();
|
||||
bOrd = BOrd.make((BOrd)bOrd2, (String)("slot:" + string)).normalize();
|
||||
if (bOrd != null) {
|
||||
((BWbShell)this.getShell()).hyperlink(bOrd);
|
||||
}
|
||||
}
|
||||
|
||||
protected void cellPopup(BMouseEvent bMouseEvent, int n, int n2) {
|
||||
ColumnList columnList = BAlarmExtManager.this.itable.getColumns();
|
||||
String string = BAlarmExtManager.this.collectionModel.getValueAt(n, 1).toString();
|
||||
BOrd bOrd = ((BWbShell)this.getShell()).getActiveOrd();
|
||||
BOrd bOrd2 = BOrd.make((BOrd)bOrd, (String)("slot:" + string)).normalize();
|
||||
BComponent bComponent = (BComponent)bOrd2.get();
|
||||
BMenu bMenu = new BMenu();
|
||||
bMenu.add(null, (BValue)new BSubMenuItem(NavMenuUtil.makeViewsMenu((BWidget)this.getTable(), (BObject)bComponent)));
|
||||
bMenu.add(null, (BValue)new BSubMenuItem(NavMenuUtil.makeActionsMenu((BWidget)this.getTable(), (BComponent)bComponent)));
|
||||
bMenu.add(null, (BValue)new BSeparator());
|
||||
bMenu.add(null, (Command)new GotoPoint(n, BAlarmExtManager.this.itable));
|
||||
bMenu.add(null, (BValue)new BSeparator());
|
||||
if (BAlarmExtManager.this.table.getModel().getSelection().getRows().length == 1) {
|
||||
BAlarmExtManager.this.enableToOffnormal.setSelected(BAlarmExtManager.this.itable.getBoolean(n, columnList.get("alarmEnable.isToOffnormal")));
|
||||
BAlarmExtManager.this.enableToFault.setSelected(BAlarmExtManager.this.itable.getBoolean(n, columnList.get("alarmEnable.isToFault")));
|
||||
}
|
||||
bMenu.add("toOffnormal", (Command)BAlarmExtManager.this.enableToOffnormal);
|
||||
bMenu.add("toFault", (Command)BAlarmExtManager.this.enableToFault);
|
||||
bMenu.add("editAlarmClass", BAlarmExtManager.this.editAlarmClass);
|
||||
bMenu.add("editInstructions", BAlarmExtManager.this.editInstructions);
|
||||
bMenu.open((BWidget)this.getTable(), bMouseEvent.getX(), bMouseEvent.getY());
|
||||
}
|
||||
}
|
||||
|
||||
public class EditInstructions
|
||||
extends Command {
|
||||
public EditInstructions() {
|
||||
super((BWidget)BAlarmExtManager.this, Sys.getModuleForClass((Class)(class$com$tridium$alarm$ui$BAlarmExtManager == null ? (class$com$tridium$alarm$ui$BAlarmExtManager = BAlarmExtManager.class$("com.tridium.alarm.ui.BAlarmExtManager")) : class$com$tridium$alarm$ui$BAlarmExtManager)), "alarm.editInstructions");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
Object object;
|
||||
int[] nArray = BAlarmExtManager.this.table.getSelection().getRows();
|
||||
BAlarmInstructions bAlarmInstructions = BAlarmInstructions.NULL;
|
||||
if (nArray.length == 1) {
|
||||
object = BAlarmExtManager.this.getExtensionForRow(nArray[0]);
|
||||
object.lease();
|
||||
bAlarmInstructions = ((BAlarmSourceExt)object).getAlarmInstructions();
|
||||
}
|
||||
object = new BInstructionsFE();
|
||||
BAlarmExtManager.this.add("temp", (BValue)object);
|
||||
object.loadValue((BObject)bAlarmInstructions, null);
|
||||
BAlarmExtManager.this.remove("temp");
|
||||
int n = BDialog.open((BWidget)BAlarmExtManager.this, (String)lex.get("alarm.editAlarmClass.label"), (Object)object, (int)3, (BImage)null);
|
||||
if (n == 1) {
|
||||
try {
|
||||
bAlarmInstructions = (BAlarmInstructions)object.saveValue((BObject)bAlarmInstructions, null);
|
||||
for (int i = 0; i < nArray.length; ++i) {
|
||||
BAlarmSourceExt bAlarmSourceExt = BAlarmExtManager.this.getExtensionForRow(nArray[i]);
|
||||
bAlarmSourceExt.lease();
|
||||
bAlarmSourceExt.setAlarmInstructions(bAlarmInstructions);
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
// empty catch block
|
||||
}
|
||||
BAlarmExtManager.this.updateTable();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class EditAlarmClass
|
||||
extends Command {
|
||||
public EditAlarmClass() {
|
||||
super((BWidget)BAlarmExtManager.this, Sys.getModuleForClass((Class)(class$com$tridium$alarm$ui$BAlarmExtManager == null ? (class$com$tridium$alarm$ui$BAlarmExtManager = BAlarmExtManager.class$("com.tridium.alarm.ui.BAlarmExtManager")) : class$com$tridium$alarm$ui$BAlarmExtManager)), "alarm.editAlarmClass");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
Object object;
|
||||
int[] nArray = BAlarmExtManager.this.table.getSelection().getRows();
|
||||
String string = "";
|
||||
if (nArray.length == 1) {
|
||||
object = BAlarmExtManager.this.getExtensionForRow(nArray[0]);
|
||||
object.lease();
|
||||
string = ((BAlarmSourceExt)object).getAlarmClass();
|
||||
}
|
||||
object = new BAlarmClassFE();
|
||||
BAlarmExtManager.this.add("temp", (BValue)object);
|
||||
object.loadValue((BObject)BString.make((String)string), null);
|
||||
BAlarmExtManager.this.remove("temp");
|
||||
int n = BDialog.open((BWidget)BAlarmExtManager.this, (String)lex.get("alarm.editAlarmClass.label"), (Object)object, (int)3, (BImage)null);
|
||||
if (n == 1) {
|
||||
try {
|
||||
string = object.saveValue((BObject)BString.make((String)string), null).toString();
|
||||
for (int i = 0; i < nArray.length; ++i) {
|
||||
BAlarmSourceExt bAlarmSourceExt = BAlarmExtManager.this.getExtensionForRow(nArray[i]);
|
||||
bAlarmSourceExt.lease();
|
||||
bAlarmSourceExt.setAlarmClass(string);
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
// empty catch block
|
||||
}
|
||||
BAlarmExtManager.this.updateTable();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class EnableToFault
|
||||
extends ToggleCommand {
|
||||
public EnableToFault() {
|
||||
super((BWidget)BAlarmExtManager.this, Sys.getModuleForClass((Class)(class$com$tridium$alarm$ui$BAlarmExtManager == null ? (class$com$tridium$alarm$ui$BAlarmExtManager = BAlarmExtManager.class$("com.tridium.alarm.ui.BAlarmExtManager")) : class$com$tridium$alarm$ui$BAlarmExtManager)), "alarm.toFaultEnabled");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BAlarmExtManager.this.enableToFault();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class EnableToOffnormal
|
||||
extends ToggleCommand {
|
||||
public EnableToOffnormal() {
|
||||
super((BWidget)BAlarmExtManager.this, Sys.getModuleForClass((Class)(class$com$tridium$alarm$ui$BAlarmExtManager == null ? (class$com$tridium$alarm$ui$BAlarmExtManager = BAlarmExtManager.class$("com.tridium.alarm.ui.BAlarmExtManager")) : class$com$tridium$alarm$ui$BAlarmExtManager)), "alarm.toOffnormalEnabled");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BAlarmExtManager.this.enableToOffnormal();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,592 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.collection.BITable
|
||||
* javax.baja.collection.Column
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BButton
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.Command
|
||||
* javax.baja.ui.CommandArtifact
|
||||
* javax.baja.ui.enums.BHalign
|
||||
* javax.baja.ui.enums.BOrientation
|
||||
* javax.baja.ui.enums.BValign
|
||||
* javax.baja.ui.event.BKeyEvent
|
||||
* javax.baja.ui.event.BMouseEvent
|
||||
* javax.baja.ui.list.BList
|
||||
* javax.baja.ui.list.ListController
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BEdgePane
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.ui.pane.BSplitPane
|
||||
* javax.baja.ui.table.BTable
|
||||
* javax.baja.ui.table.DefaultTableModel
|
||||
* javax.baja.ui.table.DynamicTableModel
|
||||
* javax.baja.ui.table.TableController
|
||||
* javax.baja.ui.table.TableModel
|
||||
* javax.baja.ui.table.TableSelection
|
||||
* javax.baja.ui.util.BTitlePane
|
||||
* javax.baja.ui.util.UiLexicon
|
||||
* javax.baja.util.BFormat
|
||||
* javax.baja.workbench.BWbShell
|
||||
* javax.baja.workbench.view.BWbComponentView
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import javax.baja.alarm.BAlarmInstructions;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.alarm.BAlarmSourceInfo;
|
||||
import javax.baja.alarm.ext.BAlarmSourceExt;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.collection.BITable;
|
||||
import javax.baja.collection.Column;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BButton;
|
||||
import javax.baja.ui.BDialog;
|
||||
import javax.baja.ui.BLabel;
|
||||
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.enums.BOrientation;
|
||||
import javax.baja.ui.enums.BValign;
|
||||
import javax.baja.ui.event.BKeyEvent;
|
||||
import javax.baja.ui.event.BMouseEvent;
|
||||
import javax.baja.ui.list.BList;
|
||||
import javax.baja.ui.list.ListController;
|
||||
import javax.baja.ui.pane.BBorderPane;
|
||||
import javax.baja.ui.pane.BEdgePane;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.ui.pane.BSplitPane;
|
||||
import javax.baja.ui.table.BTable;
|
||||
import javax.baja.ui.table.DefaultTableModel;
|
||||
import javax.baja.ui.table.DynamicTableModel;
|
||||
import javax.baja.ui.table.TableController;
|
||||
import javax.baja.ui.table.TableModel;
|
||||
import javax.baja.ui.table.TableSelection;
|
||||
import javax.baja.ui.util.BTitlePane;
|
||||
import javax.baja.ui.util.UiLexicon;
|
||||
import javax.baja.util.BFormat;
|
||||
import javax.baja.workbench.BWbShell;
|
||||
import javax.baja.workbench.view.BWbComponentView;
|
||||
|
||||
public class BAlarmInstructionsManager
|
||||
extends BWbComponentView {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BAlarmInstructionsManager == null ? (class$com$tridium$alarm$ui$BAlarmInstructionsManager = BAlarmInstructionsManager.class$("com.tridium.alarm.ui.BAlarmInstructionsManager")) : class$com$tridium$alarm$ui$BAlarmInstructionsManager));
|
||||
protected BAlarmService alarmService;
|
||||
protected Context cx;
|
||||
protected Model model;
|
||||
protected BTable table;
|
||||
protected BList instructionList;
|
||||
protected BList masterList;
|
||||
Command mAddCmd;
|
||||
Command mRemoveCmd;
|
||||
Command mEditCmd;
|
||||
Command mSaveCmd;
|
||||
Command saveCmd;
|
||||
Command addFromMasterCmd;
|
||||
Command addCmd;
|
||||
Command removeCmd;
|
||||
Command moveUpCmd;
|
||||
Command moveDownCmd;
|
||||
Command editCmd;
|
||||
Hashtable instructions = new Hashtable();
|
||||
public static final UiLexicon lexicon = new UiLexicon(class$com$tridium$alarm$ui$BAlarmInstructionsManager == null ? (class$com$tridium$alarm$ui$BAlarmInstructionsManager = BAlarmInstructionsManager.class$("com.tridium.alarm.ui.BAlarmInstructionsManager")) : class$com$tridium$alarm$ui$BAlarmInstructionsManager);
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmInstructionsManager;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmSourceInfo;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BAlarmInstructionsManager() {
|
||||
this.addCmd = new Command((BWidget)this, BAlarmInstructionsManager.lexicon.module, "commands.addMsg"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
String string = BDialog.prompt((BWidget)BAlarmInstructionsManager.this, (String)"Add", (String)"", (int)40);
|
||||
if (string != null) {
|
||||
BAlarmInstructionsManager.this.instructionList.addItem((Object)BString.make((String)string));
|
||||
BAlarmInstructionsManager.this.saveCmd.setEnabled(true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
this.removeCmd = new Command((BWidget)this, BAlarmInstructionsManager.lexicon.module, "commands.removeMsg"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BAlarmInstructionsManager.this.instructionList.removeSelectedItems();
|
||||
BAlarmInstructionsManager.this.saveCmd.setEnabled(true);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
this.removeCmd.setEnabled(false);
|
||||
this.editCmd = new Command((BWidget)this, BAlarmInstructionsManager.lexicon.module, "commands.editMsg"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
if (BAlarmInstructionsManager.this.instructionList.getSelectedItem() == null) {
|
||||
return null;
|
||||
}
|
||||
String string = BDialog.prompt((BWidget)BAlarmInstructionsManager.this, (String)"Edit", (String)BAlarmInstructionsManager.this.instructionList.getSelectedItem().toString(), (int)40);
|
||||
if (string != null) {
|
||||
BAlarmInstructionsManager.this.instructionList.setItem(BAlarmInstructionsManager.this.instructionList.getSelectedIndex(), (Object)BString.make((String)string));
|
||||
BAlarmInstructionsManager.this.saveCmd.setEnabled(true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
this.editCmd.setEnabled(false);
|
||||
this.moveUpCmd = new Command((BWidget)this, BAlarmInstructionsManager.lexicon.module, "commands.moveUp"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
int n = BAlarmInstructionsManager.this.instructionList.getSelectedIndex();
|
||||
if (n > 0) {
|
||||
Object object = BAlarmInstructionsManager.this.instructionList.getItem(n);
|
||||
Object object2 = BAlarmInstructionsManager.this.instructionList.getItem(n - 1);
|
||||
BAlarmInstructionsManager.this.instructionList.setItem(n, object2);
|
||||
BAlarmInstructionsManager.this.instructionList.setItem(n - 1, object);
|
||||
BAlarmInstructionsManager.this.instructionList.getSelection().deselectAll();
|
||||
BAlarmInstructionsManager.this.instructionList.getSelection().select(n - 1);
|
||||
BAlarmInstructionsManager.this.saveCmd.setEnabled(true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
this.moveUpCmd.setEnabled(false);
|
||||
this.moveDownCmd = new Command((BWidget)this, BAlarmInstructionsManager.lexicon.module, "commands.moveDown"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
int n = BAlarmInstructionsManager.this.instructionList.getSelectedIndex();
|
||||
if (n < BAlarmInstructionsManager.this.instructionList.getItemCount() - 1) {
|
||||
Object object = BAlarmInstructionsManager.this.instructionList.getItem(n);
|
||||
Object object2 = BAlarmInstructionsManager.this.instructionList.getItem(n + 1);
|
||||
BAlarmInstructionsManager.this.instructionList.setItem(n, object2);
|
||||
BAlarmInstructionsManager.this.instructionList.setItem(n + 1, object);
|
||||
BAlarmInstructionsManager.this.instructionList.getSelection().deselectAll();
|
||||
BAlarmInstructionsManager.this.instructionList.getSelection().select(n + 1);
|
||||
BAlarmInstructionsManager.this.saveCmd.setEnabled(true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
this.moveDownCmd.setEnabled(false);
|
||||
this.saveCmd = new Command((BWidget)this, UiLexicon.bajaui.module, "commands.save"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
int[] nArray = BAlarmInstructionsManager.this.table.getSelection().getRows();
|
||||
for (int i = 0; i < nArray.length; ++i) {
|
||||
BAlarmInstructions bAlarmInstructions = ((Controller)BAlarmInstructionsManager.this.table.getController()).getInstructions(nArray[i]);
|
||||
BFormat[] bFormatArray = new BFormat[BAlarmInstructionsManager.this.instructionList.getItemCount()];
|
||||
for (int j = 0; j < BAlarmInstructionsManager.this.instructionList.getItemCount(); ++j) {
|
||||
bFormatArray[j] = BFormat.make((String)BAlarmInstructionsManager.this.instructionList.getItem(j).toString());
|
||||
}
|
||||
bAlarmInstructions = BAlarmInstructions.make(bFormatArray);
|
||||
((Controller)BAlarmInstructionsManager.this.table.getController()).setInstructions(nArray[i], bAlarmInstructions);
|
||||
}
|
||||
BAlarmInstructionsManager.this.saveCmd.setEnabled(false);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
this.saveCmd.setEnabled(false);
|
||||
this.addFromMasterCmd = new Command((BWidget)this, BAlarmInstructionsManager.lexicon.module, "commands.addFromMaster"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
Object[] objectArray = BAlarmInstructionsManager.this.masterList.getSelectedItems();
|
||||
for (int i = 0; i < objectArray.length; ++i) {
|
||||
BAlarmInstructionsManager.this.instructionList.addItem((Object)((BFormat)objectArray[i]));
|
||||
BAlarmInstructionsManager.this.saveCmd.setEnabled(true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
this.addFromMasterCmd.setEnabled(false);
|
||||
this.mAddCmd = new Command((BWidget)this, BAlarmInstructionsManager.lexicon.module, "commands.addMsg"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
String string = BDialog.prompt((BWidget)BAlarmInstructionsManager.this, (String)"Add", (String)"", (int)40);
|
||||
if (string != null) {
|
||||
BAlarmInstructionsManager.this.masterList.addItem((Object)BFormat.make((String)string));
|
||||
BAlarmInstructionsManager.this.setModified();
|
||||
BAlarmInstructionsManager.this.mSaveCmd.setEnabled(true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
this.mRemoveCmd = new Command((BWidget)this, BAlarmInstructionsManager.lexicon.module, "commands.removeMsg"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BAlarmInstructionsManager.this.masterList.removeSelectedItems();
|
||||
BAlarmInstructionsManager.this.setModified();
|
||||
BAlarmInstructionsManager.this.mSaveCmd.setEnabled(true);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
this.mRemoveCmd.setEnabled(false);
|
||||
this.mEditCmd = new Command((BWidget)this, BAlarmInstructionsManager.lexicon.module, "commands.editMsg"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
if (BAlarmInstructionsManager.this.masterList.getSelectedItem() == null) {
|
||||
return null;
|
||||
}
|
||||
String string = BDialog.prompt((BWidget)BAlarmInstructionsManager.this, (String)"Edit", (String)BAlarmInstructionsManager.this.masterList.getSelectedItem().toString(), (int)40);
|
||||
if (string != null) {
|
||||
BAlarmInstructionsManager.this.masterList.setItem(BAlarmInstructionsManager.this.masterList.getSelectedIndex(), (Object)BFormat.make((String)string));
|
||||
BAlarmInstructionsManager.this.setModified();
|
||||
BAlarmInstructionsManager.this.mSaveCmd.setEnabled(true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
this.mEditCmd.setEnabled(false);
|
||||
this.mSaveCmd = new Command((BWidget)this, UiLexicon.bajaui.module, "commands.save"){
|
||||
|
||||
public CommandArtifact doInvoke() throws Exception {
|
||||
BAlarmInstructionsManager.this.saveValue();
|
||||
BAlarmInstructionsManager.this.mSaveCmd.setEnabled(false);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
this.mSaveCmd.setEnabled(false);
|
||||
BSplitPane bSplitPane = new BSplitPane(BOrientation.vertical, 50.0);
|
||||
BEdgePane bEdgePane = new BEdgePane();
|
||||
this.instructionList = new BList();
|
||||
this.instructionList.setController((ListController)new InstListController());
|
||||
BGridPane bGridPane = new BGridPane(1);
|
||||
bGridPane.setColumnAlign(BHalign.fill);
|
||||
bGridPane.setValign(BValign.top);
|
||||
bGridPane.add(null, (BValue)new BButton(this.addCmd));
|
||||
bGridPane.add(null, (BValue)new BButton(this.removeCmd));
|
||||
bGridPane.add(null, (BValue)new BButton(this.editCmd));
|
||||
bGridPane.add(null, (BValue)new BButton(this.saveCmd));
|
||||
bGridPane.add(null, (BValue)new BLabel(""));
|
||||
bGridPane.add(null, (BValue)new BButton(this.moveUpCmd));
|
||||
bGridPane.add(null, (BValue)new BButton(this.moveDownCmd));
|
||||
bEdgePane.setCenter((BWidget)this.instructionList);
|
||||
bEdgePane.setRight((BWidget)bGridPane);
|
||||
BGridPane bGridPane2 = new BGridPane(1);
|
||||
bGridPane2.add(null, (BValue)new BButton(this.addFromMasterCmd));
|
||||
bEdgePane.setBottom((BWidget)bGridPane2);
|
||||
bSplitPane.setWidget1((BWidget)new BTitlePane("Point Instructions", (BWidget)bEdgePane));
|
||||
BEdgePane bEdgePane2 = new BEdgePane();
|
||||
this.masterList = new BList();
|
||||
this.masterList.setController((ListController)new MasterListController());
|
||||
BGridPane bGridPane3 = new BGridPane(1);
|
||||
bGridPane3.setColumnAlign(BHalign.fill);
|
||||
bGridPane3.setValign(BValign.top);
|
||||
bGridPane3.add(null, (BValue)new BButton(this.mAddCmd));
|
||||
bGridPane3.add(null, (BValue)new BButton(this.mRemoveCmd));
|
||||
bGridPane3.add(null, (BValue)new BButton(this.mEditCmd));
|
||||
bGridPane3.add(null, (BValue)new BButton(this.mSaveCmd));
|
||||
bEdgePane2.setCenter((BWidget)this.masterList);
|
||||
bEdgePane2.setRight((BWidget)bGridPane3);
|
||||
bSplitPane.setWidget2((BWidget)new BTitlePane("Master Instructions List", (BWidget)bEdgePane2));
|
||||
this.table = new BTable();
|
||||
this.table.setController((TableController)new Controller());
|
||||
BSplitPane bSplitPane2 = new BSplitPane(BOrientation.horizontal, 35.0);
|
||||
bSplitPane2.setWidget1((BWidget)new BTitlePane("Points", (BWidget)this.table));
|
||||
bSplitPane2.setWidget2((BWidget)bSplitPane);
|
||||
this.setContent((BWidget)new BBorderPane((BWidget)bSplitPane2));
|
||||
}
|
||||
|
||||
public void doLoadValue(BObject bObject, Context context) {
|
||||
System.out.println("start");
|
||||
this.alarmService = (BAlarmService)bObject;
|
||||
this.cx = context;
|
||||
this.model = new Model();
|
||||
this.table.setModel((TableModel)new DynamicTableModel((TableModel)this.model, new int[]{0, 1}));
|
||||
this.table.setController((TableController)new Controller());
|
||||
new Thread(){
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public void run() {
|
||||
BAlarmInstructionsManager.this.enterBusy();
|
||||
try {
|
||||
BAlarmInstructionsManager.this.alarmService.lease();
|
||||
BAlarmInstructions bAlarmInstructions = BAlarmInstructionsManager.this.alarmService.getMasterAlarmInstructions();
|
||||
for (int i = 0; i < bAlarmInstructions.size(); ++i) {
|
||||
BAlarmInstructionsManager.this.masterList.addItem((Object)bAlarmInstructions.get(i));
|
||||
}
|
||||
BObject[] bObjectArray = BAlarmInstructionsManager.this.queryPoints();
|
||||
for (int i = 0; i < bObjectArray.length; ++i) {
|
||||
try {
|
||||
BComponent bComponent = (BComponent)bObjectArray[i];
|
||||
bComponent.lease();
|
||||
Property[] propertyArray = bComponent.getPropertiesArray();
|
||||
for (int j = 0; j < propertyArray.length; ++j) {
|
||||
Property property = propertyArray[j];
|
||||
if (property.getType().equals(BAlarmInstructions.TYPE)) {
|
||||
BAlarmInstructionsManager.this.model.addRow(bComponent, property);
|
||||
continue;
|
||||
}
|
||||
if (!property.getType().equals(BAlarmSourceInfo.TYPE)) continue;
|
||||
BAlarmInstructionsManager.this.model.addRow(bComponent, property);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
// empty catch block
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
BAlarmInstructionsManager.this.exitBusy();
|
||||
BAlarmInstructionsManager.this.table.sizeColumnsToFit();
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
protected BObject[] queryPoints() {
|
||||
BOrd bOrd = ((BWbShell)this.getShell()).getActiveOrd();
|
||||
BOrd bOrd2 = BOrd.make((BOrd)bOrd, (String)"station:|slot:/|bql:select slotPath from alarm:IAlarmSource").normalize();
|
||||
BITable bITable = ((BICollection)bOrd2.resolve().get()).toTable();
|
||||
Column column = bITable.getColumns().get(0);
|
||||
BObject[] bObjectArray = new BObject[bITable.size()];
|
||||
for (int i = 0; i < bITable.size(); ++i) {
|
||||
BOrd bOrd3 = BOrd.make((String)bITable.getString(i, column));
|
||||
bObjectArray[i] = bOrd3.resolve((BObject)this.alarmService).get();
|
||||
}
|
||||
return bObjectArray;
|
||||
}
|
||||
|
||||
public BObject doSaveValue(BObject bObject, Context context) {
|
||||
BAlarmService bAlarmService = (BAlarmService)bObject;
|
||||
BFormat[] bFormatArray = new BFormat[this.masterList.getItemCount()];
|
||||
for (int i = 0; i < this.masterList.getItemCount(); ++i) {
|
||||
bFormatArray[i] = BFormat.make((String)this.masterList.getItem(i).toString());
|
||||
}
|
||||
bAlarmService.setMasterAlarmInstructions(BAlarmInstructions.make(bFormatArray));
|
||||
return bAlarmService;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
class MasterListController
|
||||
extends ListController {
|
||||
MasterListController() {
|
||||
}
|
||||
|
||||
public void keyReleased(BKeyEvent bKeyEvent) {
|
||||
super.keyReleased(bKeyEvent);
|
||||
this.enabledCommands();
|
||||
}
|
||||
|
||||
public void mouseReleased(BMouseEvent bMouseEvent) {
|
||||
super.mouseReleased(bMouseEvent);
|
||||
this.enabledCommands();
|
||||
}
|
||||
|
||||
protected void enabledCommands() {
|
||||
int n = this.getList().getSelection().getItemCount();
|
||||
if (n > 0) {
|
||||
BAlarmInstructionsManager.this.addFromMasterCmd.setEnabled(true);
|
||||
BAlarmInstructionsManager.this.mRemoveCmd.setEnabled(true);
|
||||
BAlarmInstructionsManager.this.mEditCmd.setEnabled(true);
|
||||
} else {
|
||||
BAlarmInstructionsManager.this.addFromMasterCmd.setEnabled(false);
|
||||
BAlarmInstructionsManager.this.mRemoveCmd.setEnabled(false);
|
||||
BAlarmInstructionsManager.this.mEditCmd.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class InstListController
|
||||
extends ListController {
|
||||
InstListController() {
|
||||
}
|
||||
|
||||
public void keyReleased(BKeyEvent bKeyEvent) {
|
||||
super.keyReleased(bKeyEvent);
|
||||
this.enabledCommands();
|
||||
}
|
||||
|
||||
public void mouseReleased(BMouseEvent bMouseEvent) {
|
||||
super.mouseReleased(bMouseEvent);
|
||||
this.enabledCommands();
|
||||
}
|
||||
|
||||
protected void enabledCommands() {
|
||||
int n = BAlarmInstructionsManager.this.instructionList.getSelection().getItemCount();
|
||||
if (n > 0) {
|
||||
BAlarmInstructionsManager.this.removeCmd.setEnabled(true);
|
||||
BAlarmInstructionsManager.this.editCmd.setEnabled(true);
|
||||
if (this.getList().getItemCount() > 1) {
|
||||
BAlarmInstructionsManager.this.moveUpCmd.setEnabled(true);
|
||||
BAlarmInstructionsManager.this.moveDownCmd.setEnabled(true);
|
||||
} else {
|
||||
BAlarmInstructionsManager.this.moveUpCmd.setEnabled(false);
|
||||
BAlarmInstructionsManager.this.moveDownCmd.setEnabled(false);
|
||||
}
|
||||
} else {
|
||||
BAlarmInstructionsManager.this.removeCmd.setEnabled(false);
|
||||
BAlarmInstructionsManager.this.moveUpCmd.setEnabled(false);
|
||||
BAlarmInstructionsManager.this.moveDownCmd.setEnabled(false);
|
||||
BAlarmInstructionsManager.this.editCmd.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected class Controller
|
||||
extends TableController {
|
||||
Hashtable components = new Hashtable();
|
||||
|
||||
protected Controller() {
|
||||
}
|
||||
|
||||
public void keyReleased(BKeyEvent bKeyEvent) {
|
||||
super.keyReleased(bKeyEvent);
|
||||
this.showInstructions();
|
||||
}
|
||||
|
||||
public void mouseReleased(BMouseEvent bMouseEvent) {
|
||||
super.mouseReleased(bMouseEvent);
|
||||
this.showInstructions();
|
||||
}
|
||||
|
||||
protected void setInstructions(int n, BAlarmInstructions bAlarmInstructions) {
|
||||
BComponent bComponent = BAlarmInstructionsManager.this.model.getComponent(n);
|
||||
bComponent.lease();
|
||||
Property property = BAlarmInstructionsManager.this.model.getProperty(n);
|
||||
if (property.getType() == BAlarmInstructions.TYPE) {
|
||||
bComponent.set(BAlarmInstructionsManager.this.model.getProperty(n), (BValue)bAlarmInstructions);
|
||||
} else {
|
||||
BAlarmSourceInfo bAlarmSourceInfo = (BAlarmSourceInfo)bComponent.get(BAlarmInstructionsManager.this.model.getProperty(n));
|
||||
bAlarmSourceInfo.lease();
|
||||
bAlarmSourceInfo.setAlarmInstructions(bAlarmInstructions);
|
||||
}
|
||||
}
|
||||
|
||||
protected BAlarmInstructions getInstructions(int n) {
|
||||
BComponent bComponent = BAlarmInstructionsManager.this.model.getComponent(n);
|
||||
bComponent.lease();
|
||||
Property property = BAlarmInstructionsManager.this.model.getProperty(n);
|
||||
if (property.getType() == BAlarmInstructions.TYPE) {
|
||||
return (BAlarmInstructions)bComponent.get(property);
|
||||
}
|
||||
BAlarmSourceInfo bAlarmSourceInfo = (BAlarmSourceInfo)bComponent.get(BAlarmInstructionsManager.this.model.getProperty(n));
|
||||
bAlarmSourceInfo.lease();
|
||||
return bAlarmSourceInfo.getAlarmInstructions();
|
||||
}
|
||||
|
||||
protected void showInstructions() {
|
||||
TableSelection tableSelection = this.getTable().getSelection();
|
||||
BAlarmInstructionsManager.this.instructionList.getSelection().deselectAll();
|
||||
if (tableSelection.getRowCount() == 1) {
|
||||
BAlarmInstructions bAlarmInstructions = this.getInstructions(tableSelection.getRow());
|
||||
BAlarmInstructionsManager.this.instructionList.removeAllItems();
|
||||
for (int i = 0; i < bAlarmInstructions.size(); ++i) {
|
||||
BAlarmInstructionsManager.this.instructionList.addItem((Object)bAlarmInstructions.get(i));
|
||||
}
|
||||
} else if (tableSelection.getRowCount() > 1) {
|
||||
int n;
|
||||
BAlarmInstructionsManager.this.instructionList.removeAllItems();
|
||||
int[] nArray = tableSelection.getRows();
|
||||
BAlarmInstructions bAlarmInstructions = null;
|
||||
boolean bl = true;
|
||||
for (n = 0; n < nArray.length; ++n) {
|
||||
BAlarmInstructions bAlarmInstructions2 = this.getInstructions(nArray[n]);
|
||||
if (bAlarmInstructions == null) {
|
||||
bAlarmInstructions = (BAlarmInstructions)bAlarmInstructions2.newCopy();
|
||||
continue;
|
||||
}
|
||||
if (bAlarmInstructions.equivalent((Object)bAlarmInstructions2)) continue;
|
||||
bl = false;
|
||||
break;
|
||||
}
|
||||
if (bl) {
|
||||
for (n = 0; n < bAlarmInstructions.size(); ++n) {
|
||||
BAlarmInstructionsManager.this.instructionList.addItem((Object)bAlarmInstructions.get(n));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
((InstListController)BAlarmInstructionsManager.this.instructionList.getController()).enabledCommands();
|
||||
BAlarmInstructionsManager.this.saveCmd.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected class Model
|
||||
extends DefaultTableModel {
|
||||
Hashtable controllers = new Hashtable();
|
||||
|
||||
public Model() {
|
||||
super(new String[]{"Point", "Condition", "Path"});
|
||||
}
|
||||
|
||||
public BComponent getComponent(int n) {
|
||||
return (BComponent)super.getValueAt(n, 0);
|
||||
}
|
||||
|
||||
public Property getProperty(int n) {
|
||||
return (Property)super.getValueAt(n, 1);
|
||||
}
|
||||
|
||||
public Object getValueAt(int n, int n2) {
|
||||
if (n2 == 2) {
|
||||
try {
|
||||
BComponent bComponent = this.getComponent(n);
|
||||
return bComponent.toPathString();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
if (n2 == 1) {
|
||||
return ((Property)super.getValueAt(n, n2)).getDefaultDisplayName(BAlarmInstructionsManager.this.cx);
|
||||
}
|
||||
if (n2 == 0) {
|
||||
BComponent bComponent = this.getComponent(n);
|
||||
bComponent.lease();
|
||||
String string = bComponent.getDisplayName(BAlarmInstructionsManager.this.cx);
|
||||
if (bComponent instanceof BAlarmSourceExt) {
|
||||
string = ((BAlarmSourceExt)bComponent).getSourceName().format((Object)bComponent);
|
||||
} else {
|
||||
BAlarmSourceInfo[] bAlarmSourceInfoArray = (BAlarmSourceInfo[])bComponent.getChildren(class$javax$baja$alarm$BAlarmSourceInfo == null ? (class$javax$baja$alarm$BAlarmSourceInfo = BAlarmInstructionsManager.class$("javax.baja.alarm.BAlarmSourceInfo")) : class$javax$baja$alarm$BAlarmSourceInfo);
|
||||
if (bAlarmSourceInfoArray.length > 0) {
|
||||
bAlarmSourceInfoArray[0].lease();
|
||||
string = bAlarmSourceInfoArray[0].getSourceName().format((Object)bAlarmSourceInfoArray[0]);
|
||||
}
|
||||
}
|
||||
return string;
|
||||
}
|
||||
}
|
||||
return "???";
|
||||
}
|
||||
|
||||
public void addRow(BComponent bComponent, Property property) {
|
||||
BComponent bComponent2 = bComponent;
|
||||
this.addRow(new Object[]{bComponent2, property, null});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BComponent
|
||||
* 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.BLabel
|
||||
* javax.baja.ui.BTextField
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.workbench.CannotSaveException
|
||||
* javax.baja.workbench.fieldeditor.BWbFieldEditor
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import javax.baja.alarm.BAlarmPriorities;
|
||||
import javax.baja.alarm.BAlarmTransitionBits;
|
||||
import javax.baja.sys.BComponent;
|
||||
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.BLabel;
|
||||
import javax.baja.ui.BTextField;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.workbench.CannotSaveException;
|
||||
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
|
||||
|
||||
public class BAlarmPrioritiesFE
|
||||
extends BWbFieldEditor {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BAlarmPrioritiesFE == null ? (class$com$tridium$alarm$ui$BAlarmPrioritiesFE = BAlarmPrioritiesFE.class$("com.tridium.alarm.ui.BAlarmPrioritiesFE")) : class$com$tridium$alarm$ui$BAlarmPrioritiesFE));
|
||||
static final String offnormalText = BAlarmTransitionBits.DEFAULT.getTag(1);
|
||||
static final String faultText = BAlarmTransitionBits.DEFAULT.getTag(2);
|
||||
static final String normalText = BAlarmTransitionBits.DEFAULT.getTag(4);
|
||||
static final String alertText = BAlarmTransitionBits.DEFAULT.getTag(8);
|
||||
private boolean init = false;
|
||||
private BTextField offnormal;
|
||||
private BTextField fault;
|
||||
private BTextField normal;
|
||||
private BTextField alert;
|
||||
private BAlarmPriorities priorities;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmPrioritiesFE;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
protected void doSetReadonly(boolean bl) {
|
||||
this.init = false;
|
||||
if (bl) {
|
||||
this.setContent((BWidget)new BTextField("", 40, false));
|
||||
}
|
||||
}
|
||||
|
||||
protected void doLoadValue(BObject bObject, Context context) {
|
||||
BAlarmPriorities bAlarmPriorities = (BAlarmPriorities)bObject;
|
||||
if (this.isReadonly()) {
|
||||
((BTextField)this.getContent()).setText(bObject.toString());
|
||||
} else {
|
||||
if (!this.init) {
|
||||
this.initUi();
|
||||
}
|
||||
this.offnormal.setText(Integer.toString(bAlarmPriorities.getToOffnormal()));
|
||||
this.fault.setText(Integer.toString(bAlarmPriorities.getToFault()));
|
||||
this.normal.setText(Integer.toString(bAlarmPriorities.getToNormal()));
|
||||
this.alert.setText(Integer.toString(bAlarmPriorities.getToAlert()));
|
||||
this.linkTo((BComponent)this.offnormal, (Slot)BTextField.actionPerformed, (Slot)actionPerformed);
|
||||
this.linkTo((BComponent)this.fault, (Slot)BTextField.actionPerformed, (Slot)actionPerformed);
|
||||
this.linkTo((BComponent)this.normal, (Slot)BTextField.actionPerformed, (Slot)actionPerformed);
|
||||
this.linkTo((BComponent)this.alert, (Slot)BTextField.actionPerformed, (Slot)actionPerformed);
|
||||
}
|
||||
}
|
||||
|
||||
protected BObject doSaveValue(BObject bObject, Context context) throws CannotSaveException {
|
||||
int n = Integer.parseInt(this.offnormal.getText());
|
||||
int n2 = Integer.parseInt(this.fault.getText());
|
||||
int n3 = Integer.parseInt(this.normal.getText());
|
||||
int n4 = Integer.parseInt(this.alert.getText());
|
||||
try {
|
||||
return BAlarmPriorities.make(n, n2, n3, n4);
|
||||
}
|
||||
catch (IllegalStateException illegalStateException) {
|
||||
throw new CannotSaveException(illegalStateException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void initUi() {
|
||||
this.init = true;
|
||||
BGridPane bGridPane = new BGridPane(8);
|
||||
bGridPane.add(null, (BValue)new BLabel(offnormalText), null);
|
||||
this.offnormal = new BTextField("", 5);
|
||||
bGridPane.add("offNormal", (BValue)this.offnormal, null);
|
||||
bGridPane.add(null, (BValue)new BLabel(faultText), null);
|
||||
this.fault = new BTextField("", 5);
|
||||
bGridPane.add("fault", (BValue)this.fault, null);
|
||||
bGridPane.add(null, (BValue)new BLabel(normalText), null);
|
||||
this.normal = new BTextField("", 5);
|
||||
bGridPane.add("normal", (BValue)this.normal, null);
|
||||
bGridPane.add(null, (BValue)new BLabel(alertText), null);
|
||||
this.alert = new BTextField("", 5);
|
||||
bGridPane.add("alert", (BValue)this.alert, null);
|
||||
this.setContent((BWidget)bGridPane);
|
||||
this.linkTo("lk0", (BComponent)this.offnormal, (Slot)BTextField.textModified, (Slot)setModified);
|
||||
this.linkTo("lk1", (BComponent)this.fault, (Slot)BTextField.textModified, (Slot)setModified);
|
||||
this.linkTo("lk2", (BComponent)this.normal, (Slot)BTextField.textModified, (Slot)setModified);
|
||||
this.linkTo("lk3", (BComponent)this.alert, (Slot)BTextField.textModified, (Slot)setModified);
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,366 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.security.BPermissions
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.LocalizableRuntimeException
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BButton
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BMenu
|
||||
* javax.baja.ui.BNullWidget
|
||||
* javax.baja.ui.BSeparator
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.Command
|
||||
* javax.baja.ui.CommandArtifact
|
||||
* javax.baja.ui.enums.BHalign
|
||||
* javax.baja.ui.event.BKeyEvent
|
||||
* javax.baja.ui.event.BMouseEvent
|
||||
* javax.baja.ui.event.BWindowEvent
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BEdgePane
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.ui.table.BTable
|
||||
* javax.baja.ui.table.DynamicTableModel
|
||||
* javax.baja.ui.table.TableController
|
||||
* javax.baja.ui.table.TableSelection
|
||||
* javax.baja.ui.util.UiLexicon
|
||||
* javax.baja.util.Lexicon
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.alarm.ui.BAlarmClassDef;
|
||||
import com.tridium.alarm.ui.BAlarmConsole;
|
||||
import com.tridium.alarm.ui.BAlarmTitlePane;
|
||||
import com.tridium.alarm.ui.ConsoleTableModel;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import javax.baja.alarm.BAlarmClass;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.security.BPermissions;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.LocalizableRuntimeException;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BButton;
|
||||
import javax.baja.ui.BDialog;
|
||||
import javax.baja.ui.BMenu;
|
||||
import javax.baja.ui.BNullWidget;
|
||||
import javax.baja.ui.BSeparator;
|
||||
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.event.BKeyEvent;
|
||||
import javax.baja.ui.event.BMouseEvent;
|
||||
import javax.baja.ui.event.BWindowEvent;
|
||||
import javax.baja.ui.pane.BBorderPane;
|
||||
import javax.baja.ui.pane.BEdgePane;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.ui.table.BTable;
|
||||
import javax.baja.ui.table.DynamicTableModel;
|
||||
import javax.baja.ui.table.TableController;
|
||||
import javax.baja.ui.table.TableSelection;
|
||||
import javax.baja.ui.util.UiLexicon;
|
||||
import javax.baja.util.Lexicon;
|
||||
|
||||
public class BAlarmReportDialog
|
||||
extends BDialog {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BAlarmReportDialog == null ? (class$com$tridium$alarm$ui$BAlarmReportDialog = BAlarmReportDialog.class$("com.tridium.alarm.ui.BAlarmReportDialog")) : class$com$tridium$alarm$ui$BAlarmReportDialog));
|
||||
BAlarmConsole console;
|
||||
BTable table;
|
||||
String title;
|
||||
private Command ackCmd;
|
||||
private Command closeCmd;
|
||||
private Command hyperlinkCmd;
|
||||
private Command notesCmd;
|
||||
private Command detailsCmd;
|
||||
private Command showVideoCmd;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmReportDialog;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmConsole;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BAlarmReportDialog() {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
public BAlarmReportDialog(BAlarmConsole bAlarmConsole, String string, BTable bTable) {
|
||||
super((BWidget)bAlarmConsole, string, true);
|
||||
Object object;
|
||||
BAlarmRecord bAlarmRecord;
|
||||
this.console = bAlarmConsole;
|
||||
this.table = bTable;
|
||||
this.hyperlinkCmd = new HyperlinkCommand((BWidget)this);
|
||||
BButton bButton = new BButton(this.hyperlinkCmd, true, true);
|
||||
this.ackCmd = new AckCommand((BWidget)this);
|
||||
BButton bButton2 = new BButton(this.ackCmd, true, true);
|
||||
this.notesCmd = new NotesCommand((BWidget)this);
|
||||
BButton bButton3 = new BButton(this.notesCmd, true, true);
|
||||
this.showVideoCmd = new ShowVideoCommand((BWidget)this);
|
||||
BButton bButton4 = new BButton(this.showVideoCmd, true, true);
|
||||
this.closeCmd = new CloseCommand((BWidget)this);
|
||||
BButton bButton5 = new BButton(this.closeCmd, true, true);
|
||||
this.detailsCmd = new DetailsCommand((BWidget)this);
|
||||
BGridPane bGridPane = new BGridPane(BAlarmConsole.isVideoDriverAvailable() ? 5 : 4);
|
||||
bGridPane.setColumnAlign(BHalign.fill);
|
||||
bGridPane.setUniformColumnWidth(true);
|
||||
ConsoleTableModel consoleTableModel = (ConsoleTableModel)((DynamicTableModel)bTable.getModel()).getRootModel();
|
||||
if (consoleTableModel.getRowCount() > 0) {
|
||||
bAlarmRecord = consoleTableModel.getRecord(0);
|
||||
object = bAlarmConsole.getAlarmService();
|
||||
BAlarmClass bAlarmClass = ((BAlarmService)object).lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
BPermissions bPermissions = bAlarmClass.getPermissions(bAlarmConsole.ctx);
|
||||
if (bPermissions.hasOperatorWrite()) {
|
||||
bGridPane.add("ack", (BValue)bButton2);
|
||||
}
|
||||
} else {
|
||||
bGridPane.add("ack", (BValue)bButton2);
|
||||
}
|
||||
bGridPane.add("url", (BValue)bButton);
|
||||
bGridPane.add("notes", (BValue)bButton3);
|
||||
if (BAlarmConsole.isVideoDriverAvailable()) {
|
||||
bGridPane.add("showVideo", (BValue)bButton4);
|
||||
}
|
||||
bGridPane.add("close", (BValue)bButton5);
|
||||
bAlarmRecord = new BEdgePane();
|
||||
bAlarmRecord.setBottom((BWidget)new BBorderPane((BWidget)bGridPane));
|
||||
object = new Controller();
|
||||
bTable.setController((TableController)object);
|
||||
bAlarmRecord.setCenter((BWidget)BAlarmTitlePane.makePane(bAlarmConsole.getTitle(), bTable));
|
||||
bTable.getSelection().select(0);
|
||||
((Controller)((Object)object)).enableCommands();
|
||||
this.setContent((BWidget)bAlarmRecord);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
((BEdgePane)this.getContent()).setCenter((BWidget)new BNullWidget());
|
||||
super.close();
|
||||
}
|
||||
|
||||
public void windowClosing(BWindowEvent bWindowEvent) {
|
||||
this.close();
|
||||
}
|
||||
|
||||
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 keyReleased(BKeyEvent bKeyEvent) {
|
||||
super.keyReleased(bKeyEvent);
|
||||
this.enableCommands();
|
||||
}
|
||||
|
||||
public void mouseReleased(BMouseEvent bMouseEvent) {
|
||||
super.mouseReleased(bMouseEvent);
|
||||
this.enableCommands();
|
||||
}
|
||||
|
||||
void enableCommands() {
|
||||
TableSelection tableSelection = this.getTable().getSelection();
|
||||
if (tableSelection.getRows().length == 1) {
|
||||
BAlarmClassDef bAlarmClassDef;
|
||||
Object object;
|
||||
ConsoleTableModel consoleTableModel = (ConsoleTableModel)((DynamicTableModel)this.getTable().getModel()).getRootModel();
|
||||
BAlarmRecord bAlarmRecord = consoleTableModel.getRecord(tableSelection.getRow());
|
||||
BString bString = (BString)bAlarmRecord.getAlarmData().get("hyperlinkOrd");
|
||||
BOrd bOrd = BOrd.NULL;
|
||||
if (bString != null) {
|
||||
bOrd = BOrd.make((String)bString.toString());
|
||||
}
|
||||
if (bOrd == null || bOrd.isNull()) {
|
||||
object = BAlarmReportDialog.this.console.options.getAlarmClassMapping();
|
||||
bAlarmClassDef = object.getAlarmClassDefFor(bAlarmRecord.getAlarmClass());
|
||||
bOrd = bAlarmClassDef.getAlarmUrl();
|
||||
}
|
||||
if (bOrd != null && !bOrd.isNull()) {
|
||||
BAlarmReportDialog.this.hyperlinkCmd.setEnabled(true);
|
||||
} else {
|
||||
BAlarmReportDialog.this.hyperlinkCmd.setEnabled(false);
|
||||
}
|
||||
object = bAlarmRecord.getAlarmData().gets("cameraOrd", null);
|
||||
if (object != null) {
|
||||
bAlarmClassDef = BOrd.make((String)object);
|
||||
if (!bAlarmClassDef.equals(BOrd.NULL)) {
|
||||
BAlarmReportDialog.this.showVideoCmd.setEnabled(true);
|
||||
} else {
|
||||
BAlarmReportDialog.this.showVideoCmd.setEnabled(false);
|
||||
}
|
||||
} else {
|
||||
BAlarmReportDialog.this.showVideoCmd.setEnabled(false);
|
||||
}
|
||||
BAlarmReportDialog.this.notesCmd.setEnabled(true);
|
||||
} else {
|
||||
BAlarmReportDialog.this.hyperlinkCmd.setEnabled(false);
|
||||
BAlarmReportDialog.this.notesCmd.setEnabled(false);
|
||||
BAlarmReportDialog.this.detailsCmd.setEnabled(false);
|
||||
BAlarmReportDialog.this.showVideoCmd.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected void cellReleased(BMouseEvent bMouseEvent, int n, int n2) {
|
||||
super.cellReleased(bMouseEvent, n, n2);
|
||||
if (bMouseEvent.getClickCount() == 2) {
|
||||
BAlarmReportDialog.this.console.showDetailsDialog(BAlarmReportDialog.this.table, n);
|
||||
}
|
||||
}
|
||||
|
||||
protected void cellPopup(BMouseEvent bMouseEvent, int n, int n2) {
|
||||
BMenu bMenu = new BMenu();
|
||||
bMenu.add("ack", BAlarmReportDialog.this.ackCmd);
|
||||
bMenu.add("url", BAlarmReportDialog.this.hyperlinkCmd);
|
||||
bMenu.add("notes", BAlarmReportDialog.this.notesCmd);
|
||||
bMenu.add("details", BAlarmReportDialog.this.detailsCmd);
|
||||
if (BAlarmConsole.isVideoDriverAvailable()) {
|
||||
bMenu.add("showVideo", BAlarmReportDialog.this.showVideoCmd);
|
||||
}
|
||||
bMenu.open((BWidget)BAlarmReportDialog.this.table, bMouseEvent.getX(), bMouseEvent.getY());
|
||||
}
|
||||
|
||||
public BMenu makeOptionsMenu() {
|
||||
BMenu bMenu = super.makeOptionsMenu();
|
||||
bMenu.add("acSep", (BValue)new BSeparator());
|
||||
bMenu.add("addColumn", BAlarmReportDialog.this.console.addColumnCommand);
|
||||
bMenu.add("removeColumn", BAlarmReportDialog.this.console.removeColumnCommand);
|
||||
return bMenu;
|
||||
}
|
||||
}
|
||||
|
||||
private class ShowVideoCommand
|
||||
extends Command {
|
||||
public ShowVideoCommand(BWidget bWidget) {
|
||||
super(bWidget, (Lexicon)BAlarmConsole.lexicon, "commands.showVideo");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
block9: {
|
||||
try {
|
||||
Class clazz = Sys.loadClass((String)"videoDriver", (String)"com.tridium.videoDriver.alarm.AlarmConsoleExt");
|
||||
if (clazz != null) {
|
||||
Method method = clazz.getMethod("doShowVideo", class$com$tridium$alarm$ui$BAlarmConsole == null ? (class$com$tridium$alarm$ui$BAlarmConsole = BAlarmReportDialog.class$("com.tridium.alarm.ui.BAlarmConsole")) : class$com$tridium$alarm$ui$BAlarmConsole, class$javax$baja$alarm$BAlarmRecord == null ? (class$javax$baja$alarm$BAlarmRecord = BAlarmReportDialog.class$("javax.baja.alarm.BAlarmRecord")) : class$javax$baja$alarm$BAlarmRecord);
|
||||
if (method != null) {
|
||||
BAlarmRecord[] bAlarmRecordArray = BAlarmReportDialog.this.console.getSelectedAlarms(BAlarmReportDialog.this.table);
|
||||
if (bAlarmRecordArray != null && bAlarmRecordArray.length > 0) {
|
||||
method.invoke((Object)clazz, new Object[]{BAlarmReportDialog.this.console, bAlarmRecordArray[0]});
|
||||
}
|
||||
} else {
|
||||
System.out.println("The 'doShowVideo' method was not found on class AlarmConsoleExt in videoDriver.jar. Please have my program fixed");
|
||||
}
|
||||
break block9;
|
||||
}
|
||||
throw new LocalizableRuntimeException("alarm", "VideoDriverModuleNotFound");
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new LocalizableRuntimeException("alarm", "VideoDriverModuleNotFound", (Throwable)classNotFoundException);
|
||||
}
|
||||
catch (NoSuchMethodException noSuchMethodException) {
|
||||
throw new LocalizableRuntimeException("alarm", "VideoDriverModuleNotFound", (Throwable)noSuchMethodException);
|
||||
}
|
||||
catch (InvocationTargetException invocationTargetException) {
|
||||
throw new LocalizableRuntimeException("alarm", "VideoDriverModuleNotFound", (Throwable)invocationTargetException);
|
||||
}
|
||||
catch (IllegalAccessException illegalAccessException) {
|
||||
throw new LocalizableRuntimeException("alarm", "VideoDriverModuleNotFound", (Throwable)illegalAccessException);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class DetailsCommand
|
||||
extends Command {
|
||||
public DetailsCommand(BWidget bWidget) {
|
||||
super(bWidget, (Lexicon)BAlarmConsole.lexicon, "commands.details");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
int[] nArray = BAlarmReportDialog.this.table.getSelection().getRows();
|
||||
if (nArray.length != 1) {
|
||||
return null;
|
||||
}
|
||||
BAlarmReportDialog.this.console.showDetailsDialog(BAlarmReportDialog.this.table, nArray[0]);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class CloseCommand
|
||||
extends Command {
|
||||
public CloseCommand(BWidget bWidget) {
|
||||
super(bWidget, (Lexicon)UiLexicon.bajaui, "commands.close");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BAlarmReportDialog.this.close();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class NotesCommand
|
||||
extends Command {
|
||||
public NotesCommand(BWidget bWidget) {
|
||||
super(bWidget, (Lexicon)BAlarmConsole.lexicon, "commands.notes");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BAlarmRecord[] bAlarmRecordArray = BAlarmReportDialog.this.console.getSelectedAlarms(BAlarmReportDialog.this.table);
|
||||
if (bAlarmRecordArray.length == 0) {
|
||||
return null;
|
||||
}
|
||||
BAlarmReportDialog.this.console.showNotes((BWidget)BAlarmReportDialog.this.table, bAlarmRecordArray);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class HyperlinkCommand
|
||||
extends Command {
|
||||
public HyperlinkCommand(BWidget bWidget) {
|
||||
super(bWidget, (Lexicon)BAlarmConsole.lexicon, "commands.hyperlink");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BAlarmRecord[] bAlarmRecordArray = BAlarmReportDialog.this.console.getSelectedAlarms(BAlarmReportDialog.this.table);
|
||||
if (bAlarmRecordArray.length == 0) {
|
||||
return null;
|
||||
}
|
||||
BAlarmReportDialog.this.console.hyperlink(bAlarmRecordArray[0]);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class AckCommand
|
||||
extends Command {
|
||||
public AckCommand(BWidget bWidget) {
|
||||
super(bWidget, (Lexicon)BAlarmConsole.lexicon, "commands.acknowledge");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BAlarmRecord[] bAlarmRecordArray = BAlarmReportDialog.this.console.getSelectedAlarms(BAlarmReportDialog.this.table);
|
||||
if (bAlarmRecordArray.length == 0) {
|
||||
return null;
|
||||
}
|
||||
BAlarmReportDialog.this.console.acknowledgeAlarms(bAlarmRecordArray);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.ui.theme.Theme
|
||||
* javax.baja.gx.BColor
|
||||
* javax.baja.gx.BInsets
|
||||
* javax.baja.gx.BSize
|
||||
* javax.baja.gx.Graphics
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.Slot
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BBorder
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.event.BMouseEvent
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BEdgePane
|
||||
* javax.baja.ui.table.BTable
|
||||
* javax.baja.ui.table.DynamicTableModel
|
||||
* javax.baja.ui.util.BAuxWidget$Support
|
||||
* javax.baja.ui.util.UiLexicon
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.alarm.ui.ConsoleTableModel;
|
||||
import com.tridium.ui.theme.Theme;
|
||||
import javax.baja.gx.BColor;
|
||||
import javax.baja.gx.BInsets;
|
||||
import javax.baja.gx.BSize;
|
||||
import javax.baja.gx.Graphics;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.Slot;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BBorder;
|
||||
import javax.baja.ui.BLabel;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.event.BMouseEvent;
|
||||
import javax.baja.ui.pane.BBorderPane;
|
||||
import javax.baja.ui.pane.BEdgePane;
|
||||
import javax.baja.ui.table.BTable;
|
||||
import javax.baja.ui.table.DynamicTableModel;
|
||||
import javax.baja.ui.util.BAuxWidget;
|
||||
import javax.baja.ui.util.UiLexicon;
|
||||
|
||||
public class BAlarmTitlePane
|
||||
extends BEdgePane {
|
||||
public static final Action tableModified = BAlarmTitlePane.newAction((int)0, null, null);
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BAlarmTitlePane == null ? (class$com$tridium$alarm$ui$BAlarmTitlePane = BAlarmTitlePane.class$("com.tridium.alarm.ui.BAlarmTitlePane")) : class$com$tridium$alarm$ui$BAlarmTitlePane));
|
||||
public static final UiLexicon lexicon = new UiLexicon(class$com$tridium$alarm$ui$BAlarmConsole == null ? (class$com$tridium$alarm$ui$BAlarmConsole = BAlarmTitlePane.class$("com.tridium.alarm.ui.BAlarmConsole")) : class$com$tridium$alarm$ui$BAlarmConsole);
|
||||
static String sourceText = lexicon.getText("alarm.sources");
|
||||
static String alarmText = lexicon.getText("alarm.alarms");
|
||||
static BInsets withIcon = BInsets.make((double)1.0, (double)4.0, (double)1.0, (double)2.0);
|
||||
static BInsets withoutIcon = BInsets.make((double)2.0, (double)4.0, (double)2.0, (double)4.0);
|
||||
BWidget content;
|
||||
BLabel label;
|
||||
BLabel info;
|
||||
BEdgePane top;
|
||||
BTable table;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmTitlePane;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmConsole;
|
||||
|
||||
public void tableModified() {
|
||||
this.invoke(tableModified, null, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static BAlarmTitlePane makePane(String string, BTable bTable) {
|
||||
BAlarmTitlePane bAlarmTitlePane = new BAlarmTitlePane(string, (BWidget)bTable);
|
||||
bAlarmTitlePane.setTable(bTable);
|
||||
return bAlarmTitlePane;
|
||||
}
|
||||
|
||||
public BAlarmTitlePane(String string, BWidget bWidget) {
|
||||
this.content = bWidget;
|
||||
this.label = new BLabel(string);
|
||||
this.label.setFont(Theme.widget().getBoldText());
|
||||
this.label.setForeground(BColor.white.toBrush());
|
||||
this.top = new BEdgePane();
|
||||
this.top.setLeft((BWidget)this.label);
|
||||
BBorderPane bBorderPane = new BBorderPane((BWidget)this.top, BBorder.make((String)"top(1) left(1) right(1)"), withoutIcon);
|
||||
bBorderPane.setFill(Theme.widget().getControlShadow());
|
||||
BEdgePane bEdgePane = new BEdgePane();
|
||||
bEdgePane.setTop((BWidget)bBorderPane);
|
||||
bEdgePane.setCenter(bWidget);
|
||||
this.setCenter((BWidget)new BBorderPane((BWidget)bEdgePane, BBorder.inset, BInsets.DEFAULT));
|
||||
}
|
||||
|
||||
public BAlarmTitlePane() {
|
||||
}
|
||||
|
||||
public void setTitleVisible(boolean bl) {
|
||||
this.top.getParentWidget().setVisible(bl);
|
||||
}
|
||||
|
||||
public void setTitle(String string) {
|
||||
this.label.setText(string);
|
||||
}
|
||||
|
||||
public void setTable(BTable bTable) {
|
||||
this.table = bTable;
|
||||
if (this.info == null) {
|
||||
this.info = new BLabel("");
|
||||
this.info.setFont(Theme.widget().getBoldText());
|
||||
this.info.setForeground(BColor.white.toBrush());
|
||||
this.top.setRight((BWidget)this.info);
|
||||
}
|
||||
if (this.get("tableLink") != null) {
|
||||
this.remove("tableLink");
|
||||
}
|
||||
this.linkTo("tableLink", (BComponent)bTable, (Slot)BTable.tableModified, (Slot)tableModified);
|
||||
this.doTableModified();
|
||||
}
|
||||
|
||||
public void doTableModified() {
|
||||
int n = 0;
|
||||
int n2 = 0;
|
||||
try {
|
||||
DynamicTableModel dynamicTableModel = (DynamicTableModel)this.table.getModel();
|
||||
ConsoleTableModel consoleTableModel = (ConsoleTableModel)dynamicTableModel.getRootModel();
|
||||
n = consoleTableModel.getSourceCount();
|
||||
n2 = consoleTableModel.getAlarmCount();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
// empty catch block
|
||||
}
|
||||
this.info.setText(n + " " + sourceText + " / " + n2 + " " + alarmText);
|
||||
this.relayout();
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
class AuxSupport
|
||||
extends BAuxWidget.Support {
|
||||
final BSize size = BSize.make((double)10.0, (double)16.0);
|
||||
|
||||
AuxSupport() {
|
||||
}
|
||||
|
||||
public BSize getPreferredSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public void paint(Graphics graphics, double d, double d2) {
|
||||
graphics.setBrush(BColor.white);
|
||||
double d3 = 2.0;
|
||||
double d4 = 5.0;
|
||||
if (BAlarmTitlePane.this.content.isVisible()) {
|
||||
graphics.strokeLine(d3, d4 + 2.0, d3 + 2.0, d4);
|
||||
graphics.strokeLine(d3 + 2.0, d4, d3 + 4.0, d4 + 2.0);
|
||||
graphics.strokeLine(d3 + 1.0, d4 + 2.0, d3 + 2.0, d4 + 1.0);
|
||||
graphics.strokeLine(d3 + 2.0, d4 + 1.0, d3 + 3.0, d4 + 2.0);
|
||||
graphics.strokeLine(d3, d4 + 6.0, d3 + 2.0, d4 + 4.0);
|
||||
graphics.strokeLine(d3 + 2.0, d4 + 4.0, d3 + 4.0, d4 + 6.0);
|
||||
graphics.strokeLine(d3 + 1.0, d4 + 6.0, d3 + 2.0, d4 + 5.0);
|
||||
graphics.strokeLine(d3 + 2.0, d4 + 5.0, d3 + 3.0, d4 + 6.0);
|
||||
} else {
|
||||
graphics.strokeLine(d3, d4, d3 + 2.0, d4 + 2.0);
|
||||
graphics.strokeLine(d3 + 2.0, d4 + 2.0, d3 + 4.0, d4);
|
||||
graphics.strokeLine(d3 + 1.0, d4, d3 + 2.0, d4 + 1.0);
|
||||
graphics.strokeLine(d3 + 2.0, d4 + 1.0, d3 + 3.0, d4);
|
||||
graphics.strokeLine(d3, d4 + 4.0, d3 + 2.0, d4 + 6.0);
|
||||
graphics.strokeLine(d3 + 2.0, d4 + 6.0, d3 + 4.0, d4 + 4.0);
|
||||
graphics.strokeLine(d3 + 1.0, d4 + 4.0, d3 + 2.0, d4 + 5.0);
|
||||
graphics.strokeLine(d3 + 2.0, d4 + 5.0, d3 + 3.0, d4 + 4.0);
|
||||
}
|
||||
}
|
||||
|
||||
public void mousePressed(BMouseEvent bMouseEvent) {
|
||||
BAlarmTitlePane.this.content.setVisible(!BAlarmTitlePane.this.content.getVisible());
|
||||
BAlarmTitlePane.this.relayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BBoolean
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BString
|
||||
* 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.BTextField
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.workbench.fieldeditor.BWbFieldEditor
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import javax.baja.alarm.BAlarmTransitionBits;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BString;
|
||||
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.BTextField;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
|
||||
|
||||
public class BAlarmTransitionBitsFE
|
||||
extends BWbFieldEditor {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BAlarmTransitionBitsFE == null ? (class$com$tridium$alarm$ui$BAlarmTransitionBitsFE = BAlarmTransitionBitsFE.class$("com.tridium.alarm.ui.BAlarmTransitionBitsFE")) : class$com$tridium$alarm$ui$BAlarmTransitionBitsFE));
|
||||
static final String offnormalText = BAlarmTransitionBits.ALL.getTag(1);
|
||||
static final String faultText = BAlarmTransitionBits.ALL.getTag(2);
|
||||
static final String normalText = BAlarmTransitionBits.ALL.getTag(4);
|
||||
static final String alertText = BAlarmTransitionBits.ALL.getTag(8);
|
||||
public static final String SHOW_OFF_NORMAL = "showOffNormal";
|
||||
public static final String SHOW_NORMAL = "showNormal";
|
||||
public static final String SHOW_FAULT = "showFault";
|
||||
public static final String SHOW_ALERT = "showAlert";
|
||||
public static final String OFF_NORMAL_LABEL = "offNormalLabel";
|
||||
public static final String NORMAL_LABEL = "normalLabel";
|
||||
public static final String FAULT_LABEL = "faultLabel";
|
||||
public static final String ALERT_LABEL = "alertLabel";
|
||||
private boolean init = false;
|
||||
private BCheckBox offnormal;
|
||||
private BCheckBox fault;
|
||||
private BCheckBox normal;
|
||||
private BCheckBox alert;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmTransitionBitsFE;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
protected void doSetReadonly(boolean bl) {
|
||||
this.init = false;
|
||||
if (bl) {
|
||||
this.setContent((BWidget)new BTextField("", 45, false));
|
||||
}
|
||||
}
|
||||
|
||||
protected void doLoadValue(BObject bObject, Context context) {
|
||||
BAlarmTransitionBits bAlarmTransitionBits = (BAlarmTransitionBits)bObject;
|
||||
if (this.isReadonly()) {
|
||||
((BTextField)this.getContent()).setText(bObject.toString(context));
|
||||
} else {
|
||||
if (!this.init) {
|
||||
this.initCheckBoxes(context);
|
||||
}
|
||||
this.offnormal.setSelected(bAlarmTransitionBits.isToOffnormal());
|
||||
this.fault.setSelected(bAlarmTransitionBits.isToFault());
|
||||
this.normal.setSelected(bAlarmTransitionBits.isToNormal());
|
||||
this.alert.setSelected(bAlarmTransitionBits.isToAlert());
|
||||
}
|
||||
}
|
||||
|
||||
protected BObject doSaveValue(BObject bObject, Context context) {
|
||||
int n = 0;
|
||||
if (this.offnormal.isSelected()) {
|
||||
n |= 1;
|
||||
}
|
||||
if (this.fault.isSelected()) {
|
||||
n |= 2;
|
||||
}
|
||||
if (this.normal.isSelected()) {
|
||||
n |= 4;
|
||||
}
|
||||
if (this.alert.isSelected()) {
|
||||
n |= 8;
|
||||
}
|
||||
return BAlarmTransitionBits.make(n);
|
||||
}
|
||||
|
||||
private void initCheckBoxes(Context context) {
|
||||
this.init = true;
|
||||
int n = 4;
|
||||
if (this.getBooleanFacetValue(context, "multiLine", false)) {
|
||||
n = 1;
|
||||
}
|
||||
BGridPane bGridPane = new BGridPane(n);
|
||||
this.offnormal = new BCheckBox(this.getStringFacetValue(context, OFF_NORMAL_LABEL, offnormalText));
|
||||
this.fault = new BCheckBox(this.getStringFacetValue(context, FAULT_LABEL, faultText));
|
||||
this.normal = new BCheckBox(this.getStringFacetValue(context, NORMAL_LABEL, normalText));
|
||||
this.alert = new BCheckBox(this.getStringFacetValue(context, ALERT_LABEL, alertText));
|
||||
if (this.getBooleanFacetValue(context, SHOW_OFF_NORMAL, true)) {
|
||||
bGridPane.add("offNormal", (BValue)this.offnormal, null);
|
||||
}
|
||||
if (this.getBooleanFacetValue(context, SHOW_FAULT, true)) {
|
||||
bGridPane.add("fault", (BValue)this.fault, null);
|
||||
}
|
||||
if (this.getBooleanFacetValue(context, SHOW_NORMAL, true)) {
|
||||
bGridPane.add("normal", (BValue)this.normal, null);
|
||||
}
|
||||
if (this.getBooleanFacetValue(context, SHOW_ALERT, true)) {
|
||||
bGridPane.add("alert", (BValue)this.alert, null);
|
||||
}
|
||||
this.setContent((BWidget)bGridPane);
|
||||
this.linkTo("l0", (BComponent)this.offnormal, (Slot)BCheckBox.actionPerformed, (Slot)setModified);
|
||||
this.linkTo("l1", (BComponent)this.fault, (Slot)BCheckBox.actionPerformed, (Slot)setModified);
|
||||
this.linkTo("l2", (BComponent)this.normal, (Slot)BCheckBox.actionPerformed, (Slot)setModified);
|
||||
this.linkTo("l3", (BComponent)this.alert, (Slot)BCheckBox.actionPerformed, (Slot)setModified);
|
||||
}
|
||||
|
||||
private boolean getBooleanFacetValue(Context context, String string, boolean bl) {
|
||||
if (context == null) {
|
||||
return bl;
|
||||
}
|
||||
BBoolean bBoolean = (BBoolean)context.getFacet(string);
|
||||
return bBoolean == null ? bl : bBoolean.getBoolean();
|
||||
}
|
||||
|
||||
private String getStringFacetValue(Context context, String string, String string2) {
|
||||
if (context == null) {
|
||||
return string2;
|
||||
}
|
||||
BString bString = (BString)context.getFacet(string);
|
||||
return bString == null ? string2 : bString.toString();
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.workbench.fieldeditors.BFrozenEnumFE
|
||||
* com.tridium.workbench.fieldeditors.BStringFE
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Slot
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.ui.util.UiLexicon
|
||||
* javax.baja.workbench.fieldeditor.BWbFieldEditor
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.alarm.BTextOp;
|
||||
import com.tridium.alarm.ui.BAlarmClassFE;
|
||||
import com.tridium.workbench.fieldeditors.BFrozenEnumFE;
|
||||
import com.tridium.workbench.fieldeditors.BStringFE;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BString;
|
||||
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.BLabel;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.ui.util.UiLexicon;
|
||||
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
|
||||
|
||||
public class BDeviceExtAlarmClassFE
|
||||
extends BWbFieldEditor {
|
||||
public static final Action textOpChanged = BDeviceExtAlarmClassFE.newAction((int)4, null);
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BDeviceExtAlarmClassFE == null ? (class$com$tridium$alarm$ui$BDeviceExtAlarmClassFE = BDeviceExtAlarmClassFE.class$("com.tridium.alarm.ui.BDeviceExtAlarmClassFE")) : class$com$tridium$alarm$ui$BDeviceExtAlarmClassFE));
|
||||
BFrozenEnumFE opFE;
|
||||
BWbFieldEditor formatFE;
|
||||
Context cx;
|
||||
BGridPane pane = new BGridPane(2);
|
||||
protected BAlarmClassFE alarmClassFE;
|
||||
public static final UiLexicon lexicon = new UiLexicon(class$com$tridium$alarm$ui$BDeviceExtAlarmClassFE == null ? (class$com$tridium$alarm$ui$BDeviceExtAlarmClassFE = BDeviceExtAlarmClassFE.class$("com.tridium.alarm.ui.BDeviceExtAlarmClassFE")) : class$com$tridium$alarm$ui$BDeviceExtAlarmClassFE);
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BDeviceExtAlarmClassFE;
|
||||
|
||||
public void textOpChanged() {
|
||||
this.invoke(textOpChanged, null, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BDeviceExtAlarmClassFE() {
|
||||
this.opFE = new BFrozenEnumFE();
|
||||
this.formatFE = new BStringFE();
|
||||
this.pane.add(null, (BValue)this.opFE);
|
||||
this.pane.add("formatFE", (BValue)this.formatFE);
|
||||
this.setContent((BWidget)this.pane);
|
||||
this.linkTo("l1", (BComponent)this.formatFE, (Slot)BWbFieldEditor.pluginModified, (Slot)setModified);
|
||||
this.linkTo("l2", (BComponent)this.opFE, (Slot)BFrozenEnumFE.pluginModified, (Slot)textOpChanged);
|
||||
}
|
||||
|
||||
protected void doSetReadonly(boolean bl) {
|
||||
this.opFE.setReadonly(bl);
|
||||
this.formatFE.setReadonly(bl);
|
||||
}
|
||||
|
||||
protected void doLoadValue(BObject bObject, Context context) {
|
||||
String string;
|
||||
BTextOp bTextOp;
|
||||
this.cx = context;
|
||||
this.formatFE = new BStringFE();
|
||||
String string2 = bObject.toString();
|
||||
if (string2.equals("%alarmClass%")) {
|
||||
bTextOp = BTextOp.useExisting;
|
||||
string = "";
|
||||
} else if (string2.startsWith("%alarmClass%")) {
|
||||
bTextOp = BTextOp.append;
|
||||
string = string2.substring(12);
|
||||
} else if (string2.endsWith("%alarmClass%")) {
|
||||
bTextOp = BTextOp.prepend;
|
||||
string = string2.substring(0, string2.indexOf("%alarmClass%"));
|
||||
} else {
|
||||
bTextOp = BTextOp.replace;
|
||||
string = string2;
|
||||
this.formatFE = new BAlarmClassFE();
|
||||
}
|
||||
if (bTextOp == BTextOp.useExisting) {
|
||||
this.pane.set("formatFE", (BValue)new BLabel(""));
|
||||
} else {
|
||||
this.pane.set("formatFE", (BValue)this.formatFE);
|
||||
this.remove("l1", context);
|
||||
this.linkTo("l1", (BComponent)this.formatFE, (Slot)BWbFieldEditor.pluginModified, (Slot)setModified);
|
||||
}
|
||||
this.doSetReadonly(this.isReadonly());
|
||||
this.opFE.loadValue((BObject)bTextOp, context);
|
||||
this.formatFE.loadValue((BObject)BString.make((String)string), context);
|
||||
}
|
||||
|
||||
protected BObject doSaveValue(BObject bObject, Context context) throws Exception {
|
||||
BTextOp bTextOp = (BTextOp)this.opFE.saveValue(context);
|
||||
String string = this.formatFE.saveValue(bObject, context).toString();
|
||||
string = string.replace("%alarmClass%", "");
|
||||
if (bTextOp == BTextOp.useExisting) {
|
||||
return BString.make((String)"%alarmClass%");
|
||||
}
|
||||
if (bTextOp == BTextOp.replace) {
|
||||
return BString.make((String)string);
|
||||
}
|
||||
if (bTextOp == BTextOp.prepend) {
|
||||
return BString.make((String)(string + "%alarmClass%"));
|
||||
}
|
||||
if (bTextOp == BTextOp.append) {
|
||||
return BString.make((String)("%alarmClass%" + string));
|
||||
}
|
||||
return BString.make((String)"");
|
||||
}
|
||||
|
||||
public void doTextOpChanged() throws Exception {
|
||||
BTextOp bTextOp = (BTextOp)this.opFE.saveValue(this.cx);
|
||||
String string = "";
|
||||
if (this.formatFE != null && this.formatFE.saveValue(this.cx) != null) {
|
||||
string = this.formatFE.saveValue(this.cx).toString();
|
||||
}
|
||||
this.formatFE = bTextOp == BTextOp.replace ? new BAlarmClassFE() : new BStringFE();
|
||||
string = string.replace("%alarmClass%", "");
|
||||
if (bTextOp == BTextOp.useExisting) {
|
||||
this.pane.set("formatFE", (BValue)new BLabel(""));
|
||||
} else {
|
||||
this.pane.set("formatFE", (BValue)this.formatFE);
|
||||
this.remove("l1", this.cx);
|
||||
this.linkTo("l1", (BComponent)this.formatFE, (Slot)BWbFieldEditor.pluginModified, (Slot)setModified);
|
||||
}
|
||||
if (bTextOp == BTextOp.replace) {
|
||||
this.formatFE.loadValue((BObject)BString.make((String)"defaultAlarmClass"), this.cx);
|
||||
} else {
|
||||
this.formatFE.loadValue((BObject)BString.make((String)""), this.cx);
|
||||
}
|
||||
this.setModified();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
public void doToggleUseExisting() {
|
||||
this.setModified();
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.workbench.fieldeditors.BDialogFE
|
||||
* com.tridium.workbench.fieldeditors.BIntegerFE
|
||||
* javax.baja.naming.SlotPath
|
||||
* javax.baja.sys.BEnumRange
|
||||
* javax.baja.sys.BInteger
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BButton
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.Command
|
||||
* javax.baja.ui.CommandArtifact
|
||||
* javax.baja.ui.list.BCheckList
|
||||
* javax.baja.ui.list.DefaultListModel
|
||||
* javax.baja.ui.list.ListModel
|
||||
* javax.baja.ui.list.ListSelection
|
||||
* javax.baja.ui.pane.BEdgePane
|
||||
* javax.baja.ui.pane.BFlowPane
|
||||
* javax.baja.workbench.CannotSaveException
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.workbench.fieldeditors.BDialogFE;
|
||||
import com.tridium.workbench.fieldeditors.BIntegerFE;
|
||||
import javax.baja.naming.SlotPath;
|
||||
import javax.baja.sys.BEnumRange;
|
||||
import javax.baja.sys.BInteger;
|
||||
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.BButton;
|
||||
import javax.baja.ui.BDialog;
|
||||
import javax.baja.ui.BLabel;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.Command;
|
||||
import javax.baja.ui.CommandArtifact;
|
||||
import javax.baja.ui.list.BCheckList;
|
||||
import javax.baja.ui.list.DefaultListModel;
|
||||
import javax.baja.ui.list.ListModel;
|
||||
import javax.baja.ui.list.ListSelection;
|
||||
import javax.baja.ui.pane.BEdgePane;
|
||||
import javax.baja.ui.pane.BFlowPane;
|
||||
import javax.baja.workbench.CannotSaveException;
|
||||
|
||||
public class BEnumAlarmRangeFE
|
||||
extends BDialogFE {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BEnumAlarmRangeFE == null ? (class$com$tridium$alarm$ui$BEnumAlarmRangeFE = BEnumAlarmRangeFE.class$("com.tridium.alarm.ui.BEnumAlarmRangeFE")) : class$com$tridium$alarm$ui$BEnumAlarmRangeFE));
|
||||
boolean init = false;
|
||||
BEnumRange range;
|
||||
Context ctx;
|
||||
BCheckList checkList;
|
||||
BLabel config;
|
||||
BWidget editor;
|
||||
DefaultListModel listModel;
|
||||
BLabel label;
|
||||
boolean readonly;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BEnumAlarmRangeFE;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BEnumAlarmRangeFE() {
|
||||
BFlowPane bFlowPane = new BFlowPane();
|
||||
this.label = new BLabel();
|
||||
bFlowPane.add(null, (BValue)this.label);
|
||||
bFlowPane.add(null, (BValue)this.getEditButton());
|
||||
this.setContent((BWidget)bFlowPane);
|
||||
}
|
||||
|
||||
protected void doSetReadonly(boolean bl) {
|
||||
this.readonly = bl;
|
||||
this.setEditorReadonly(bl);
|
||||
}
|
||||
|
||||
public void doEditPressed() {
|
||||
this.initUi();
|
||||
BEnumRange bEnumRange = this.range;
|
||||
int n = BDialog.open((BWidget)this, (String)"", (Object)this.editor, (int)3);
|
||||
if (n == 1) {
|
||||
this.loadValue((BObject)this.getRange(this.ctx));
|
||||
if (!this.range.equals((Object)bEnumRange)) {
|
||||
this.setModified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void doLoadValue(BObject bObject, Context context) {
|
||||
this.range = (BEnumRange)bObject;
|
||||
this.label.setText(this.makeDisplayString(this.range, context));
|
||||
if (context != null) {
|
||||
this.ctx = context;
|
||||
}
|
||||
}
|
||||
|
||||
protected BObject doSaveValue(BObject bObject, Context context) throws CannotSaveException {
|
||||
bObject = this.getRange(context);
|
||||
if (context != null) {
|
||||
this.ctx = context;
|
||||
}
|
||||
return bObject;
|
||||
}
|
||||
|
||||
private BEnumRange getRange(Context context) {
|
||||
BEnumRange bEnumRange = (BEnumRange)this.ctx.getFacet("range");
|
||||
if (bEnumRange == null || bEnumRange.isNull()) {
|
||||
int[] nArray = this.checkList.getSelection().getItems();
|
||||
int[] nArray2 = new int[nArray.length];
|
||||
String[] stringArray = new String[nArray.length];
|
||||
for (int i = 0; i < nArray.length; ++i) {
|
||||
int n;
|
||||
Object object = this.checkList.getItem(nArray[i]);
|
||||
nArray2[i] = n = Integer.parseInt(object.toString());
|
||||
stringArray[i] = SlotPath.escape((String)("" + n));
|
||||
}
|
||||
return BEnumRange.make((int[])nArray2, (String[])stringArray);
|
||||
}
|
||||
int[] nArray = this.checkList.getSelection().getItems();
|
||||
int[] nArray3 = new int[nArray.length];
|
||||
String[] stringArray = new String[nArray.length];
|
||||
for (int i = 0; i < nArray.length; ++i) {
|
||||
String string = (String)this.checkList.getItem(nArray[i]);
|
||||
int n = -1;
|
||||
int[] nArray4 = bEnumRange.getOrdinals();
|
||||
for (int j = 0; j < nArray4.length; ++j) {
|
||||
int n2 = nArray4[j];
|
||||
String string2 = bEnumRange.getDisplayTag(n2, context);
|
||||
if (!string2.equals(string)) continue;
|
||||
n = n2;
|
||||
break;
|
||||
}
|
||||
nArray3[i] = n;
|
||||
stringArray[i] = bEnumRange.getTag(n);
|
||||
}
|
||||
return BEnumRange.make((int[])nArray3, (String[])stringArray);
|
||||
}
|
||||
|
||||
private void initUi() {
|
||||
BEnumRange bEnumRange = (BEnumRange)this.ctx.getFacet("range");
|
||||
if (bEnumRange == null || bEnumRange.isNull()) {
|
||||
this.checkList = new BCheckList();
|
||||
this.listModel = new DefaultListModel();
|
||||
ListSelection listSelection = this.checkList.getSelection();
|
||||
int[] nArray = this.range.getOrdinals();
|
||||
for (int i = 0; i < nArray.length; ++i) {
|
||||
this.listModel.addItem((Object)("" + nArray[i]));
|
||||
listSelection.select(i);
|
||||
}
|
||||
Command command = new Command((BWidget)this.getWbShell(), Sys.getModuleForClass((Class)(class$com$tridium$alarm$ui$BEnumAlarmRangeFE == null ? (class$com$tridium$alarm$ui$BEnumAlarmRangeFE = BEnumAlarmRangeFE.class$("com.tridium.alarm.ui.BEnumAlarmRangeFE")) : class$com$tridium$alarm$ui$BEnumAlarmRangeFE)), "alarm.enumRangeFE.add"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
try {
|
||||
BInteger bInteger;
|
||||
BIntegerFE bIntegerFE = new BIntegerFE();
|
||||
bIntegerFE.loadValue((BObject)BInteger.make((int)BEnumAlarmRangeFE.this.listModel.getItemCount()));
|
||||
int n = BDialog.open((BWidget)BEnumAlarmRangeFE.this, (String)"", (Object)bIntegerFE, (int)3);
|
||||
if (n == 1 && BEnumAlarmRangeFE.this.listModel.indexOfItem((Object)(bInteger = (BInteger)bIntegerFE.saveValue())) == -1 && BEnumAlarmRangeFE.this.listModel.indexOfItem((Object)bInteger.toString()) == -1) {
|
||||
BEnumAlarmRangeFE.this.listModel.addItem((Object)bInteger);
|
||||
ListSelection listSelection = BEnumAlarmRangeFE.this.checkList.getSelection();
|
||||
listSelection.select(BEnumAlarmRangeFE.this.listModel.getItemCount() - 1);
|
||||
BEnumAlarmRangeFE.this.checkList.setSelection(listSelection);
|
||||
BEnumAlarmRangeFE.this.checkList.setModel((ListModel)BEnumAlarmRangeFE.this.listModel);
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
BButton bButton = new BButton(command, true, true);
|
||||
this.checkList.setSelection(listSelection);
|
||||
this.checkList.setModel((ListModel)this.listModel);
|
||||
BEdgePane bEdgePane = new BEdgePane();
|
||||
bEdgePane.setCenter((BWidget)this.checkList);
|
||||
bEdgePane.setBottom((BWidget)bButton);
|
||||
this.editor = bEdgePane;
|
||||
} else {
|
||||
this.checkList = new BCheckList();
|
||||
this.listModel = new DefaultListModel();
|
||||
ListSelection listSelection = this.checkList.getSelection();
|
||||
int[] nArray = bEnumRange.getOrdinals();
|
||||
for (int i = 0; i < nArray.length; ++i) {
|
||||
this.listModel.addItem((Object)bEnumRange.getDisplayTag(nArray[i], this.ctx));
|
||||
if (!this.range.isOrdinal(nArray[i])) continue;
|
||||
listSelection.select(i);
|
||||
}
|
||||
this.checkList.setSelection(listSelection);
|
||||
this.checkList.setModel((ListModel)this.listModel);
|
||||
this.editor = this.checkList;
|
||||
}
|
||||
this.setEditorReadonly(this.readonly);
|
||||
}
|
||||
|
||||
private String makeDisplayString(BEnumRange bEnumRange, Context context) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
int[] nArray = bEnumRange.getOrdinals();
|
||||
for (int i = 0; i < nArray.length; ++i) {
|
||||
if (i > 0) {
|
||||
stringBuffer.append(", ");
|
||||
}
|
||||
stringBuffer.append(bEnumRange.getDisplayTag(nArray[i], this.ctx));
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
private void setEditorReadonly(boolean bl) {
|
||||
if (this.editor != null) {
|
||||
this.editor.setEnabled(!bl);
|
||||
BWidget[] bWidgetArray = this.editor.getChildWidgets();
|
||||
for (int i = 0; i < bWidgetArray.length; ++i) {
|
||||
bWidgetArray[i].setEnabled(!bl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BInterface
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.sys.BInterface;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
public interface BIAlarmServiceView
|
||||
extends BInterface {
|
||||
public static final Type TYPE = Sys.loadType((Class)(1.class$com$tridium$alarm$ui$BIAlarmServiceView == null ? (1.class$com$tridium$alarm$ui$BIAlarmServiceView = 1.class$("com.tridium.alarm.ui.BIAlarmServiceView")) : 1.class$com$tridium$alarm$ui$BIAlarmServiceView));
|
||||
|
||||
public BAlarmService getAlarmService(BAlarmRecord var1);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,348 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.workbench.fieldeditors.BDialogFE
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BComponent
|
||||
* 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.BButton
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BTextDropDown
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.Command
|
||||
* javax.baja.ui.CommandArtifact
|
||||
* javax.baja.ui.enums.BHalign
|
||||
* javax.baja.ui.list.BList
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BConstrainedPane
|
||||
* javax.baja.ui.pane.BEdgePane
|
||||
* javax.baja.ui.pane.BFlowPane
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.ui.table.BTable
|
||||
* javax.baja.ui.table.DefaultTableModel
|
||||
* javax.baja.ui.table.TableModel
|
||||
* javax.baja.ui.util.UiLexicon
|
||||
* javax.baja.util.BFormat
|
||||
* javax.baja.workbench.BWbShell
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.workbench.fieldeditors.BDialogFE;
|
||||
import javax.baja.alarm.BAlarmInstructions;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BComponent;
|
||||
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.BButton;
|
||||
import javax.baja.ui.BDialog;
|
||||
import javax.baja.ui.BLabel;
|
||||
import javax.baja.ui.BTextDropDown;
|
||||
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.list.BList;
|
||||
import javax.baja.ui.pane.BBorderPane;
|
||||
import javax.baja.ui.pane.BConstrainedPane;
|
||||
import javax.baja.ui.pane.BEdgePane;
|
||||
import javax.baja.ui.pane.BFlowPane;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.ui.table.BTable;
|
||||
import javax.baja.ui.table.DefaultTableModel;
|
||||
import javax.baja.ui.table.TableModel;
|
||||
import javax.baja.ui.util.UiLexicon;
|
||||
import javax.baja.util.BFormat;
|
||||
import javax.baja.workbench.BWbShell;
|
||||
|
||||
public class BInstructionsFE
|
||||
extends BDialogFE {
|
||||
public static final Action setEnabledStates = BInstructionsFE.newAction((int)0, null);
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BInstructionsFE == null ? (class$com$tridium$alarm$ui$BInstructionsFE = BInstructionsFE.class$("com.tridium.alarm.ui.BInstructionsFE")) : class$com$tridium$alarm$ui$BInstructionsFE));
|
||||
BLabel label = new BLabel();
|
||||
BList list;
|
||||
BTable table;
|
||||
BAlarmInstructions instructions;
|
||||
Context ctx;
|
||||
BEdgePane mainPane = null;
|
||||
MoveDownCommand moveDownCommand = null;
|
||||
MoveUpCommand moveUpCommand = null;
|
||||
RemoveCommand removeCommand = null;
|
||||
EditCommand editCommand = null;
|
||||
AddCommand addCommand = null;
|
||||
public static final UiLexicon lexicon = new UiLexicon(class$com$tridium$alarm$ui$BInstructionsFE == null ? (class$com$tridium$alarm$ui$BInstructionsFE = BInstructionsFE.class$("com.tridium.alarm.ui.BInstructionsFE")) : class$com$tridium$alarm$ui$BInstructionsFE);
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BInstructionsFE;
|
||||
|
||||
public void setEnabledStates() {
|
||||
this.invoke(setEnabledStates, null, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BInstructionsFE() {
|
||||
BFlowPane bFlowPane = new BFlowPane();
|
||||
bFlowPane.add(null, (BValue)this.label);
|
||||
bFlowPane.add(null, (BValue)this.getEditButton());
|
||||
this.setContent((BWidget)bFlowPane);
|
||||
this.addCommand = new AddCommand();
|
||||
this.editCommand = new EditCommand();
|
||||
this.removeCommand = new RemoveCommand();
|
||||
this.moveUpCommand = new MoveUpCommand();
|
||||
this.moveDownCommand = new MoveDownCommand();
|
||||
this.table = new BTable((TableModel)new NumberedTableModel());
|
||||
this.table.setHeaderVisible(false);
|
||||
this.table.setVgridVisible(false);
|
||||
BConstrainedPane bConstrainedPane = new BConstrainedPane((BWidget)this.table);
|
||||
bConstrainedPane.setMinSize(400.0, 200.0);
|
||||
this.mainPane = new BEdgePane();
|
||||
BGridPane bGridPane = new BGridPane(1);
|
||||
bGridPane.setColumnAlign(BHalign.fill);
|
||||
bGridPane.add(null, (BValue)new BButton((Command)this.addCommand));
|
||||
bGridPane.add(null, (BValue)new BButton((Command)this.editCommand));
|
||||
bGridPane.add(null, (BValue)new BButton((Command)this.removeCommand));
|
||||
bGridPane.add(null, (BValue)new BLabel(""));
|
||||
bGridPane.add(null, (BValue)new BButton((Command)this.moveUpCommand));
|
||||
bGridPane.add(null, (BValue)new BButton((Command)this.moveDownCommand));
|
||||
this.linkTo(null, (BComponent)this.table, (Slot)BTable.tableModified, (Slot)setEnabledStates);
|
||||
this.linkTo(null, (BComponent)this.table, (Slot)BTable.actionPerformed, (Slot)setEnabledStates);
|
||||
this.linkTo(null, (BComponent)this.table, (Slot)BTable.selectionModified, (Slot)setEnabledStates);
|
||||
this.doSetEnabledStates();
|
||||
this.mainPane.setCenter((BWidget)new BBorderPane((BWidget)bConstrainedPane));
|
||||
this.mainPane.setRight((BWidget)new BBorderPane((BWidget)bGridPane));
|
||||
}
|
||||
|
||||
public void doLoadValue(BObject bObject, Context context) {
|
||||
this.instructions = (BAlarmInstructions)bObject;
|
||||
this.ctx = context;
|
||||
this.label.setText(this.instructions.size() + " " + lexicon.getText("alarm.instructions"));
|
||||
}
|
||||
|
||||
public BObject doSaveValue(BObject bObject, Context context) {
|
||||
return this.instructions;
|
||||
}
|
||||
|
||||
public void doSetReadonly(boolean bl) {
|
||||
if (bl) {
|
||||
this.moveDownCommand.setEnabled(!bl);
|
||||
this.moveUpCommand.setEnabled(!bl);
|
||||
this.removeCommand.setEnabled(!bl);
|
||||
this.editCommand.setEnabled(!bl);
|
||||
this.addCommand.setEnabled(!bl);
|
||||
} else {
|
||||
this.addCommand.setEnabled(true);
|
||||
}
|
||||
this.table.setEnabled(!bl);
|
||||
this.mainPane.setEnabled(!bl);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean bl) {
|
||||
this.setReadonly(!bl);
|
||||
}
|
||||
|
||||
public void doEditPressed() {
|
||||
int n;
|
||||
((NumberedTableModel)this.table.getModel()).removeAllRows();
|
||||
for (n = 0; n < this.instructions.size(); ++n) {
|
||||
((NumberedTableModel)this.table.getModel()).addRow(this.instructions.get(n));
|
||||
}
|
||||
n = BDialog.open((BWidget)this, (String)"Edit", (Object)this.mainPane, (int)3);
|
||||
if (n == 2) {
|
||||
return;
|
||||
}
|
||||
BAlarmInstructions bAlarmInstructions = this.instructions;
|
||||
BFormat[] bFormatArray = new BFormat[this.table.getModel().getRowCount()];
|
||||
for (int i = 0; i < this.table.getModel().getRowCount(); ++i) {
|
||||
bFormatArray[i] = ((NumberedTableModel)this.table.getModel()).getFormat(i);
|
||||
}
|
||||
this.instructions = BAlarmInstructions.make(bFormatArray);
|
||||
if (!this.instructions.equivalent((Object)bAlarmInstructions)) {
|
||||
this.label.setText(this.instructions.size() + " " + lexicon.getText("alarm.instructions"));
|
||||
this.setModified();
|
||||
}
|
||||
}
|
||||
|
||||
public void doSetEnabledStates() {
|
||||
boolean bl = this.isReadonly();
|
||||
if (bl) {
|
||||
this.moveDownCommand.setEnabled(false);
|
||||
this.moveUpCommand.setEnabled(false);
|
||||
this.removeCommand.setEnabled(false);
|
||||
this.editCommand.setEnabled(false);
|
||||
this.addCommand.setEnabled(false);
|
||||
} else {
|
||||
this.addCommand.setEnabled(true);
|
||||
boolean bl2 = !this.table.getSelection().isEmpty();
|
||||
this.removeCommand.setEnabled(bl2);
|
||||
boolean bl3 = this.table.getSelection().getRows().length == 1;
|
||||
this.moveDownCommand.setEnabled(bl3);
|
||||
this.moveUpCommand.setEnabled(bl3);
|
||||
this.editCommand.setEnabled(bl3);
|
||||
}
|
||||
}
|
||||
|
||||
public final BComponent loadService(Type type) {
|
||||
BWbShell bWbShell = this.getWbShell();
|
||||
BOrd bOrd = BOrd.make((BOrd)bWbShell.getActiveOrd(), (String)("service:" + type.toString()));
|
||||
return (BComponent)bOrd.get();
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public class NumberedTableModel
|
||||
extends DefaultTableModel {
|
||||
public NumberedTableModel() {
|
||||
super(new String[]{"", ""});
|
||||
}
|
||||
|
||||
public void addRow(BFormat bFormat) {
|
||||
super.addRow(new Object[]{null, bFormat});
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public String getColumnName(int n) {
|
||||
return "";
|
||||
}
|
||||
|
||||
public BFormat getFormat(int n) {
|
||||
return BFormat.make((String)super.getValueAt(n, 1).toString());
|
||||
}
|
||||
|
||||
public Object getValueAt(int n, int n2) {
|
||||
if (n2 == 0) {
|
||||
return new String(n + 1 + ".");
|
||||
}
|
||||
return this.getFormat(n);
|
||||
}
|
||||
}
|
||||
|
||||
private class MoveDownCommand
|
||||
extends Command {
|
||||
public MoveDownCommand() {
|
||||
super((BWidget)BInstructionsFE.this, TYPE.getModule(), "commands.moveDown");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
int n = BInstructionsFE.this.table.getSelection().getRow();
|
||||
if (n < BInstructionsFE.this.table.getModel().getRowCount() - 1) {
|
||||
Object object = BInstructionsFE.this.table.getModel().getValueAt(n, 1);
|
||||
Object object2 = BInstructionsFE.this.table.getModel().getValueAt(n + 1, 1);
|
||||
((NumberedTableModel)BInstructionsFE.this.table.getModel()).set(n, 1, object2);
|
||||
((NumberedTableModel)BInstructionsFE.this.table.getModel()).set(n + 1, 1, object);
|
||||
BInstructionsFE.this.table.getSelection().deselectAll();
|
||||
BInstructionsFE.this.table.getSelection().select(n + 1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class MoveUpCommand
|
||||
extends Command {
|
||||
public MoveUpCommand() {
|
||||
super((BWidget)BInstructionsFE.this, TYPE.getModule(), "commands.moveUp");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
int n = BInstructionsFE.this.table.getSelection().getRow();
|
||||
if (n > 0) {
|
||||
Object object = BInstructionsFE.this.table.getModel().getValueAt(n, 1);
|
||||
Object object2 = BInstructionsFE.this.table.getModel().getValueAt(n - 1, 1);
|
||||
((NumberedTableModel)BInstructionsFE.this.table.getModel()).set(n, 1, object2);
|
||||
((NumberedTableModel)BInstructionsFE.this.table.getModel()).set(n - 1, 1, object);
|
||||
BInstructionsFE.this.table.getSelection().deselectAll();
|
||||
BInstructionsFE.this.table.getSelection().select(n - 1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class RemoveCommand
|
||||
extends Command {
|
||||
public RemoveCommand() {
|
||||
super((BWidget)BInstructionsFE.this, TYPE.getModule(), "commands.removeMsg");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
int[] nArray = BInstructionsFE.this.table.getSelection().getRows();
|
||||
for (int i = nArray.length - 1; i >= 0; --i) {
|
||||
((NumberedTableModel)BInstructionsFE.this.table.getModel()).removeRow(nArray[i]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class EditCommand
|
||||
extends Command {
|
||||
public EditCommand() {
|
||||
super((BWidget)BInstructionsFE.this, TYPE.getModule(), "commands.editMsg");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
int n = BInstructionsFE.this.table.getSelection().getRow();
|
||||
String string = BDialog.prompt((BWidget)BInstructionsFE.this, (String)"Edit", (String)BInstructionsFE.this.table.getModel().getValueAt(n, 1).toString(), (int)40);
|
||||
if (string != null) {
|
||||
if ((string = string.trim()).equals("")) {
|
||||
((NumberedTableModel)BInstructionsFE.this.table.getModel()).removeRow(n);
|
||||
} else {
|
||||
((NumberedTableModel)BInstructionsFE.this.table.getModel()).set(n, 1, string);
|
||||
BInstructionsFE.this.table.sizeColumnsToFit();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class AddCommand
|
||||
extends Command {
|
||||
public AddCommand() {
|
||||
super((BWidget)BInstructionsFE.this, TYPE.getModule(), "commands.addMsg");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
int n;
|
||||
BTextDropDown bTextDropDown = new BTextDropDown();
|
||||
BAlarmService bAlarmService = (BAlarmService)BInstructionsFE.this.loadService(BAlarmService.TYPE);
|
||||
bAlarmService.lease();
|
||||
BAlarmInstructions bAlarmInstructions = bAlarmService.getMasterAlarmInstructions();
|
||||
if (!BInstructionsFE.this.instructions.equals((Object)bAlarmInstructions)) {
|
||||
for (n = 0; n < bAlarmInstructions.size(); ++n) {
|
||||
bTextDropDown.getList().addItem((Object)bAlarmInstructions.get(n));
|
||||
}
|
||||
}
|
||||
if ((n = BDialog.open((BWidget)BInstructionsFE.this, (String)"Add", (Object)new BBorderPane((BWidget)bTextDropDown), (int)3)) == 1) {
|
||||
String string = bTextDropDown.getText().trim();
|
||||
if (string == null || string.equals("")) {
|
||||
return null;
|
||||
}
|
||||
((NumberedTableModel)BInstructionsFE.this.table.getModel()).addRow(BFormat.make((String)string));
|
||||
BInstructionsFE.this.table.sizeColumnsToFit();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.log.Log
|
||||
* javax.baja.sys.BBoolean
|
||||
* javax.baja.sys.BComponent
|
||||
* 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.BWidget
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.util.Lexicon
|
||||
* javax.baja.workbench.BWbPlugin
|
||||
* javax.baja.workbench.fieldeditor.BWbFieldEditor
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import javax.baja.alarm.ext.BLimitEnable;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BComponent;
|
||||
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.BWidget;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.util.Lexicon;
|
||||
import javax.baja.workbench.BWbPlugin;
|
||||
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
|
||||
|
||||
public class BLimitEnableFE
|
||||
extends BWbFieldEditor {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BLimitEnableFE == null ? (class$com$tridium$alarm$ui$BLimitEnableFE = BLimitEnableFE.class$("com.tridium.alarm.ui.BLimitEnableFE")) : class$com$tridium$alarm$ui$BLimitEnableFE));
|
||||
private static Log log = Log.getLog((String)"control");
|
||||
private static Lexicon lex = Lexicon.make((String)"alarm");
|
||||
private boolean init = false;
|
||||
private BCheckBox low;
|
||||
private BCheckBox high;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BLimitEnableFE;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
protected void doSetReadonly(boolean bl) {
|
||||
this.init = false;
|
||||
}
|
||||
|
||||
protected void doLoadValue(BObject bObject, Context context) {
|
||||
BLimitEnable bLimitEnable = (BLimitEnable)bObject;
|
||||
if (!this.init) {
|
||||
this.initUi(bLimitEnable);
|
||||
}
|
||||
this.low.setSelected(bLimitEnable.getLowLimitEnable());
|
||||
this.high.setSelected(bLimitEnable.getHighLimitEnable());
|
||||
this.low.setEnabled(!this.isReadonly());
|
||||
this.high.setEnabled(!this.isReadonly());
|
||||
this.linkTo((BComponent)this.low, (Slot)BWbPlugin.actionPerformed, (Slot)actionPerformed);
|
||||
this.linkTo((BComponent)this.high, (Slot)BWbPlugin.actionPerformed, (Slot)actionPerformed);
|
||||
}
|
||||
|
||||
protected BObject doSaveValue(BObject bObject, Context context) {
|
||||
BLimitEnable bLimitEnable = (BLimitEnable)bObject;
|
||||
try {
|
||||
boolean bl = this.low.getSelected();
|
||||
bLimitEnable.set(BLimitEnable.lowLimitEnable, (BValue)BBoolean.make((boolean)bl), context);
|
||||
boolean bl2 = this.high.getSelected();
|
||||
bLimitEnable.set(BLimitEnable.highLimitEnable, (BValue)BBoolean.make((boolean)bl2), context);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
log.error("BLimitEnable SaveValue Failed: ", (Throwable)exception);
|
||||
}
|
||||
return bLimitEnable;
|
||||
}
|
||||
|
||||
private void initUi(BLimitEnable bLimitEnable) {
|
||||
this.init = true;
|
||||
BGridPane bGridPane = new BGridPane(2);
|
||||
bGridPane.setColumnGap(6.0);
|
||||
this.low = new BCheckBox(lex.getText("lowLimit.enable"));
|
||||
bGridPane.add("low", (BValue)this.low);
|
||||
this.high = new BCheckBox(lex.getText("highLimit.enable"));
|
||||
bGridPane.add("high", (BValue)this.high);
|
||||
this.setContent((BWidget)bGridPane);
|
||||
this.linkTo("lk0", (BComponent)this.low, (Slot)BCheckBox.actionPerformed, (Slot)setModified);
|
||||
this.linkTo("lk1", (BComponent)this.high, (Slot)BCheckBox.actionPerformed, (Slot)setModified);
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.workbench.fieldeditors.BDynamicEnumFE
|
||||
* javax.baja.naming.SlotPath
|
||||
* javax.baja.sys.BComplex
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BDynamicEnum
|
||||
* javax.baja.sys.BEnumRange
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Slot
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BTextDropDown
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.workbench.BWbEditor
|
||||
* javax.baja.workbench.fieldeditor.BWbFieldEditor
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.alarm.print.BLinePrinterRecipient;
|
||||
import com.tridium.workbench.fieldeditors.BDynamicEnumFE;
|
||||
import javax.baja.naming.SlotPath;
|
||||
import javax.baja.sys.BComplex;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BDynamicEnum;
|
||||
import javax.baja.sys.BEnumRange;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Slot;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BTextDropDown;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.workbench.BWbEditor;
|
||||
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
|
||||
|
||||
public class BLinePrinterFE
|
||||
extends BWbFieldEditor {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BLinePrinterFE == null ? (class$com$tridium$alarm$ui$BLinePrinterFE = BLinePrinterFE.class$("com.tridium.alarm.ui.BLinePrinterFE")) : class$com$tridium$alarm$ui$BLinePrinterFE));
|
||||
private BDynamicEnumFE printerFE = new BDynamicEnumFE();
|
||||
private BDynamicEnum printersEnum;
|
||||
private boolean loaded = false;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BLinePrinterFE;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BLinePrinterFE() {
|
||||
this.setContent((BWidget)this.printerFE);
|
||||
this.linkTo("l1", (BComponent)this.printerFE, (Slot)BDynamicEnumFE.pluginModified, (Slot)setModified);
|
||||
}
|
||||
|
||||
protected void doLoadValue(BObject bObject, Context context) {
|
||||
BComplex bComplex;
|
||||
this.printersEnum = (BDynamicEnum)bObject;
|
||||
BLinePrinterRecipient bLinePrinterRecipient = null;
|
||||
for (bComplex = this.getParent(); bComplex != null && !(bComplex instanceof BWbEditor); bComplex = bComplex.getParent()) {
|
||||
}
|
||||
if (bComplex != null) {
|
||||
bLinePrinterRecipient = (BLinePrinterRecipient)((BWbEditor)bComplex).getCurrentValue();
|
||||
}
|
||||
if (!this.loaded) {
|
||||
bLinePrinterRecipient.loadPrinters();
|
||||
this.loaded = true;
|
||||
}
|
||||
this.printerFE.loadValue(bObject, context);
|
||||
}
|
||||
|
||||
protected BObject doSaveValue(BObject bObject, Context context) throws Exception {
|
||||
try {
|
||||
return this.printerFE.saveValue(bObject, context);
|
||||
}
|
||||
catch (NumberFormatException numberFormatException) {
|
||||
String string = ((BTextDropDown)this.printerFE.getContent()).getText();
|
||||
int[] nArray = this.printersEnum.getRange().getOrdinals();
|
||||
String[] stringArray = new String[nArray.length + 1];
|
||||
for (int i = 0; i < nArray.length; ++i) {
|
||||
stringArray[i] = this.printersEnum.getRange().getTag(nArray[i]);
|
||||
}
|
||||
stringArray[nArray.length] = SlotPath.escape((String)string);
|
||||
BEnumRange bEnumRange = BEnumRange.make((String[])stringArray);
|
||||
return BDynamicEnum.make((int)nArray.length, (BEnumRange)bEnumRange);
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BButton
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.Command
|
||||
* javax.baja.ui.CommandArtifact
|
||||
* javax.baja.ui.enums.BHalign
|
||||
* javax.baja.ui.event.BWindowEvent
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BEdgePane
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.ui.pane.BTextEditorPane
|
||||
* javax.baja.ui.util.UiLexicon
|
||||
* javax.baja.util.Lexicon
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BButton;
|
||||
import javax.baja.ui.BDialog;
|
||||
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.event.BWindowEvent;
|
||||
import javax.baja.ui.pane.BBorderPane;
|
||||
import javax.baja.ui.pane.BEdgePane;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.ui.pane.BTextEditorPane;
|
||||
import javax.baja.ui.util.UiLexicon;
|
||||
import javax.baja.util.Lexicon;
|
||||
|
||||
public class BNotesDialog
|
||||
extends BDialog {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BNotesDialog == null ? (class$com$tridium$alarm$ui$BNotesDialog = BNotesDialog.class$("com.tridium.alarm.ui.BNotesDialog")) : class$com$tridium$alarm$ui$BNotesDialog));
|
||||
BWidget widget;
|
||||
String username;
|
||||
BTextEditorPane historyPane;
|
||||
BTextEditorPane addPane;
|
||||
Command addCmd;
|
||||
Command closeCmd;
|
||||
boolean newNotes = false;
|
||||
public static final UiLexicon lexicon = new UiLexicon(class$com$tridium$alarm$ui$BNotesDialog == null ? (class$com$tridium$alarm$ui$BNotesDialog = BNotesDialog.class$("com.tridium.alarm.ui.BNotesDialog")) : class$com$tridium$alarm$ui$BNotesDialog);
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BNotesDialog;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BNotesDialog() {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
public BNotesDialog(BWidget bWidget, String string, String string2, boolean bl) {
|
||||
super(bWidget, lexicon.getText("alarm.notes"), true);
|
||||
this.widget = bWidget;
|
||||
this.username = string2;
|
||||
this.historyPane = new BTextEditorPane(string, 12, 80, false);
|
||||
this.addPane = new BTextEditorPane("", 6, 80, true);
|
||||
this.addCmd = new AddCmd((BWidget)this);
|
||||
if (!bl) {
|
||||
this.addCmd.setEnabled(false);
|
||||
}
|
||||
this.closeCmd = new CloseCmd((BWidget)this);
|
||||
BButton bButton = new BButton(this.addCmd, true, true);
|
||||
BButton bButton2 = new BButton(this.closeCmd, true, true);
|
||||
BGridPane bGridPane = new BGridPane(2);
|
||||
bGridPane.setColumnAlign(BHalign.fill);
|
||||
bGridPane.setUniformColumnWidth(true);
|
||||
bGridPane.add("add", (BValue)bButton);
|
||||
bGridPane.add("close", (BValue)bButton2);
|
||||
BEdgePane bEdgePane = new BEdgePane();
|
||||
bEdgePane.setTop((BWidget)new BBorderPane((BWidget)this.historyPane));
|
||||
bEdgePane.setCenter((BWidget)new BBorderPane((BWidget)this.addPane));
|
||||
bEdgePane.setBottom((BWidget)new BBorderPane((BWidget)bGridPane));
|
||||
this.setContent((BWidget)bEdgePane);
|
||||
}
|
||||
|
||||
public void open() {
|
||||
this.newNotes = false;
|
||||
this.addPane.getEditor().requestFocus();
|
||||
super.open();
|
||||
}
|
||||
|
||||
public void windowClosing(BWindowEvent bWindowEvent) {
|
||||
this.close();
|
||||
}
|
||||
|
||||
public String getNewNotes() {
|
||||
if (!this.newNotes) {
|
||||
return null;
|
||||
}
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("## " + BAbsTime.now() + " - " + this.username + " ##\n");
|
||||
stringBuffer.append(this.addPane.getText());
|
||||
stringBuffer.append("\n\n");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
class CloseCmd
|
||||
extends Command {
|
||||
CloseCmd(BWidget bWidget) {
|
||||
super(bWidget, (Lexicon)UiLexicon.bajaui, "commands.close");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BNotesDialog.this.close();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class AddCmd
|
||||
extends Command {
|
||||
AddCmd(BWidget bWidget) {
|
||||
super(bWidget, (Lexicon)lexicon, "commands.addNote");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BNotesDialog.this.newNotes = true;
|
||||
BNotesDialog.this.close();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.gx.BImage
|
||||
* javax.baja.sys.BComplex
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BIcon
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BVector
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Slot
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BTextDropDown
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.workbench.BWbEditor
|
||||
* javax.baja.workbench.fieldeditor.BWbFieldEditor
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.alarm.print.BPrinterRecipient;
|
||||
import javax.baja.gx.BImage;
|
||||
import javax.baja.sys.BComplex;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BIcon;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BVector;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Slot;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BTextDropDown;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.workbench.BWbEditor;
|
||||
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
|
||||
|
||||
public class BPrinterFE
|
||||
extends BWbFieldEditor {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BPrinterFE == null ? (class$com$tridium$alarm$ui$BPrinterFE = BPrinterFE.class$("com.tridium.alarm.ui.BPrinterFE")) : class$com$tridium$alarm$ui$BPrinterFE));
|
||||
BTextDropDown field = new BTextDropDown("", 20, true);
|
||||
String[] options;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BPrinterFE;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BPrinterFE() {
|
||||
this.setContent((BWidget)this.field);
|
||||
this.linkTo("la", (BComponent)this.field, (Slot)BTextDropDown.valueModified, (Slot)setModified);
|
||||
this.linkTo("lb", (BComponent)this.field, (Slot)BTextDropDown.actionPerformed, (Slot)actionPerformed);
|
||||
}
|
||||
|
||||
protected void doSetReadonly(boolean bl) {
|
||||
this.field.getEditor().setEditable(!bl);
|
||||
this.field.setDropDownEnabled(!bl);
|
||||
}
|
||||
|
||||
protected void doLoadValue(BObject bObject, Context context) {
|
||||
this.loadName(bObject.toString());
|
||||
}
|
||||
|
||||
protected String[] list() {
|
||||
BComplex bComplex;
|
||||
BPrinterRecipient bPrinterRecipient = null;
|
||||
for (bComplex = this.getParent(); bComplex != null && !(bComplex instanceof BWbEditor); bComplex = bComplex.getParent()) {
|
||||
}
|
||||
if (bComplex != null) {
|
||||
bPrinterRecipient = (BPrinterRecipient)((BWbEditor)bComplex).getCurrentValue();
|
||||
}
|
||||
if (bPrinterRecipient != null) {
|
||||
BVector bVector = bPrinterRecipient.getPrinters();
|
||||
Slot[] slotArray = bVector.getSlotsArray();
|
||||
String[] stringArray = new String[slotArray.length];
|
||||
for (int i = 0; i < stringArray.length; ++i) {
|
||||
stringArray[i] = bVector.get(slotArray[i].asProperty()).toString();
|
||||
}
|
||||
return stringArray;
|
||||
}
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
public void loadName(String string) {
|
||||
this.field.setText(string);
|
||||
this.field.getList().removeAllItems();
|
||||
this.options = this.list();
|
||||
String string2 = null;
|
||||
if (this.options != null) {
|
||||
for (int i = 0; i < this.options.length; ++i) {
|
||||
if (this.options[i].equals(string)) {
|
||||
string2 = this.options[i];
|
||||
}
|
||||
this.field.getList().addItem(BImage.make((BIcon)BIcon.std((String)"print.png")), (Object)this.options[i]);
|
||||
}
|
||||
}
|
||||
if (string2 != null) {
|
||||
this.field.setText(string2);
|
||||
}
|
||||
}
|
||||
|
||||
protected BObject doSaveValue(BObject bObject, Context context) {
|
||||
return BString.make((String)this.saveName());
|
||||
}
|
||||
|
||||
public String saveName() {
|
||||
String string = this.field.getText();
|
||||
for (int i = 0; i < this.options.length; ++i) {
|
||||
if (!this.options[i].equals(string)) continue;
|
||||
string = this.options[i];
|
||||
break;
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.fox.sys.BFoxSession
|
||||
* com.tridium.fox.sys.NiagaraStation
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.OrdTarget
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Slot
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BTextDropDown
|
||||
* javax.baja.ui.BTextField
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.list.BList
|
||||
* javax.baja.ui.util.UiLexicon
|
||||
* javax.baja.util.BFolder
|
||||
* javax.baja.workbench.BWbShell
|
||||
* javax.baja.workbench.fieldeditor.BWbFieldEditor
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.fox.sys.BFoxSession;
|
||||
import com.tridium.fox.sys.NiagaraStation;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.OrdTarget;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Slot;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BTextDropDown;
|
||||
import javax.baja.ui.BTextField;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.list.BList;
|
||||
import javax.baja.ui.util.UiLexicon;
|
||||
import javax.baja.util.BFolder;
|
||||
import javax.baja.workbench.BWbShell;
|
||||
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
|
||||
|
||||
public class BRemoteStationFE
|
||||
extends BWbFieldEditor {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BRemoteStationFE == null ? (class$com$tridium$alarm$ui$BRemoteStationFE = BRemoteStationFE.class$("com.tridium.alarm.ui.BRemoteStationFE")) : class$com$tridium$alarm$ui$BRemoteStationFE));
|
||||
private static UiLexicon lex = new UiLexicon(class$com$tridium$alarm$ui$BAlarmDbView == null ? (class$com$tridium$alarm$ui$BAlarmDbView = BRemoteStationFE.class$("com.tridium.alarm.ui.BAlarmDbView")) : class$com$tridium$alarm$ui$BAlarmDbView);
|
||||
private BTextDropDown remoteStation;
|
||||
private boolean loaded = false;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BRemoteStationFE;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BAlarmDbView;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
protected void doSetReadonly(boolean bl) {
|
||||
if (bl) {
|
||||
this.setContent((BWidget)new BTextField("", 45, false));
|
||||
}
|
||||
}
|
||||
|
||||
protected void doLoadValue(BObject bObject, Context context) {
|
||||
if (this.loaded) {
|
||||
return;
|
||||
}
|
||||
this.init();
|
||||
BString bString = (BString)bObject;
|
||||
if (bString == null || bString.isNull() || bString.toString().equals("")) {
|
||||
((BTextDropDown)this.getContent()).setText(lex.getText("stationRecipient.selectStation"));
|
||||
} else {
|
||||
((BTextDropDown)this.getContent()).setText(bString.toString());
|
||||
}
|
||||
try {
|
||||
BWbShell bWbShell = this.getWbShell();
|
||||
OrdTarget ordTarget = bWbShell.getActiveOrdTarget();
|
||||
BFoxSession bFoxSession = (BFoxSession)BOrd.toSession((BObject)ordTarget.get());
|
||||
BOrd bOrd = BOrd.make((BOrd)bWbShell.getActiveOrd(), (String)"service:niagaraDriver:NiagaraNetwork");
|
||||
BComponent bComponent = (BComponent)bOrd.get();
|
||||
BList bList = this.remoteStation.getList();
|
||||
this.loadStations(bComponent, bList);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
this.loaded = true;
|
||||
}
|
||||
|
||||
private void loadStations(BComponent bComponent, BList bList) {
|
||||
bComponent.lease();
|
||||
BComponent[] bComponentArray = bComponent.getChildComponents();
|
||||
for (int i = 0; i < bComponentArray.length; ++i) {
|
||||
BComponent bComponent2 = bComponentArray[i];
|
||||
if (bComponent2 instanceof NiagaraStation) {
|
||||
bList.addItem((Object)bComponent2.getName());
|
||||
continue;
|
||||
}
|
||||
if (!(bComponent2 instanceof BFolder)) continue;
|
||||
this.loadStations(bComponent2, bList);
|
||||
}
|
||||
}
|
||||
|
||||
protected BObject doSaveValue(BObject bObject, Context context) {
|
||||
if (this.remoteStation.getText().equals(lex.getText("stationRecipient.selectStation"))) {
|
||||
return BString.make((String)"");
|
||||
}
|
||||
return BString.make((String)this.remoteStation.getText());
|
||||
}
|
||||
|
||||
private void init() {
|
||||
this.remoteStation = new BTextDropDown();
|
||||
this.setContent((BWidget)this.remoteStation);
|
||||
this.linkTo("l0", (BComponent)this.remoteStation, (Slot)BTextDropDown.valueModified, (Slot)setModified);
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.workbench.fieldeditors.BDialogFE
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.BVector
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BButton
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.Command
|
||||
* javax.baja.ui.CommandArtifact
|
||||
* javax.baja.ui.enums.BHalign
|
||||
* javax.baja.ui.enums.BValign
|
||||
* javax.baja.ui.list.BList
|
||||
* javax.baja.ui.list.DefaultListModel
|
||||
* javax.baja.ui.list.ListModel
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BEdgePane
|
||||
* javax.baja.ui.pane.BFlowPane
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.ui.util.UiLexicon
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.workbench.fieldeditors.BDialogFE;
|
||||
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.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BButton;
|
||||
import javax.baja.ui.BDialog;
|
||||
import javax.baja.ui.BLabel;
|
||||
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.enums.BValign;
|
||||
import javax.baja.ui.list.BList;
|
||||
import javax.baja.ui.list.DefaultListModel;
|
||||
import javax.baja.ui.list.ListModel;
|
||||
import javax.baja.ui.pane.BBorderPane;
|
||||
import javax.baja.ui.pane.BEdgePane;
|
||||
import javax.baja.ui.pane.BFlowPane;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.ui.util.UiLexicon;
|
||||
|
||||
public class BStringListFE
|
||||
extends BDialogFE {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BStringListFE == null ? (class$com$tridium$alarm$ui$BStringListFE = BStringListFE.class$("com.tridium.alarm.ui.BStringListFE")) : class$com$tridium$alarm$ui$BStringListFE));
|
||||
BList list;
|
||||
DefaultListModel listModel;
|
||||
BVector vector;
|
||||
public static final UiLexicon lexicon = new UiLexicon(class$com$tridium$alarm$ui$BStringListFE == null ? (class$com$tridium$alarm$ui$BStringListFE = BStringListFE.class$("com.tridium.alarm.ui.BStringListFE")) : class$com$tridium$alarm$ui$BStringListFE);
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BStringListFE;
|
||||
static /* synthetic */ Class class$javax$baja$sys$BString;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BStringListFE() {
|
||||
BFlowPane bFlowPane = new BFlowPane();
|
||||
bFlowPane.add(null, (BValue)this.getEditButton());
|
||||
this.setContent((BWidget)bFlowPane);
|
||||
}
|
||||
|
||||
public void doEditPressed() {
|
||||
int n;
|
||||
Command command = new Command((BWidget)this, BStringListFE.lexicon.module, "commands.addMsg"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
String string = BDialog.prompt((BWidget)BStringListFE.this, (String)"Add", (String)"", (int)40);
|
||||
if (string != null) {
|
||||
BStringListFE.this.listModel.addItem((Object)string);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
Command command2 = new Command((BWidget)this, BStringListFE.lexicon.module, "commands.removeMsg"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
int n = BStringListFE.this.list.getSelection().getItem();
|
||||
if (n > -1) {
|
||||
BStringListFE.this.listModel.removeItem(n);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
Command command3 = new Command((BWidget)this, BStringListFE.lexicon.module, "commands.editMsg"){
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
String string;
|
||||
String string2;
|
||||
int n = BStringListFE.this.list.getSelection().getItem();
|
||||
if (n > -1 && (string2 = BDialog.prompt((BWidget)BStringListFE.this, (String)"Edit", (String)(string = BStringListFE.this.listModel.getItem(n).toString()), (int)40)) != null) {
|
||||
BStringListFE.this.listModel.setItem(n, null, (Object)string2);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
BEdgePane bEdgePane = new BEdgePane();
|
||||
this.listModel = new DefaultListModel();
|
||||
this.list = new BList((ListModel)this.listModel);
|
||||
this.list.setMultipleSelection(false);
|
||||
BGridPane bGridPane = new BGridPane(1);
|
||||
bGridPane.setValign(BValign.top);
|
||||
bGridPane.setColumnAlign(BHalign.fill);
|
||||
bGridPane.add(null, (BValue)new BButton(command));
|
||||
bGridPane.add(null, (BValue)new BButton(command2));
|
||||
bGridPane.add(null, (BValue)new BLabel(""));
|
||||
bGridPane.add(null, (BValue)new BButton(command3));
|
||||
bEdgePane.setCenter((BWidget)this.list);
|
||||
bEdgePane.setRight((BWidget)new BBorderPane((BWidget)bGridPane));
|
||||
BString[] bStringArray = (BString[])this.vector.getChildren(class$javax$baja$sys$BString == null ? (class$javax$baja$sys$BString = BStringListFE.class$("javax.baja.sys.BString")) : class$javax$baja$sys$BString);
|
||||
for (n = 0; n < bStringArray.length; ++n) {
|
||||
this.listModel.addItem((Object)bStringArray[n].toString());
|
||||
}
|
||||
n = BDialog.open((BWidget)this, (String)"Edit", (Object)bEdgePane, (int)3);
|
||||
if (n == 1) {
|
||||
this.vector.removeAll();
|
||||
for (int i = 0; i < this.listModel.getItemCount(); ++i) {
|
||||
this.vector.add(null, (BValue)BString.make((String)this.listModel.getItem(i).toString()));
|
||||
}
|
||||
this.setModified();
|
||||
}
|
||||
}
|
||||
|
||||
public void doLoadValue(BObject bObject, Context context) {
|
||||
this.vector = (BVector)bObject;
|
||||
}
|
||||
|
||||
public BObject doSaveValue(BObject bObject, Context context) {
|
||||
return this.vector;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.workbench.fieldeditors.BFrozenEnumFE
|
||||
* com.tridium.workbench.fieldeditors.BStringFE
|
||||
* javax.baja.sys.BComplex
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Flags
|
||||
* javax.baja.sys.Slot
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.util.BFormat
|
||||
* javax.baja.workbench.fieldeditor.BWbFieldEditor
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.alarm.BTextCustomizer;
|
||||
import com.tridium.alarm.BTextOp;
|
||||
import com.tridium.workbench.fieldeditors.BFrozenEnumFE;
|
||||
import com.tridium.workbench.fieldeditors.BStringFE;
|
||||
import javax.baja.sys.BComplex;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Flags;
|
||||
import javax.baja.sys.Slot;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.util.BFormat;
|
||||
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
|
||||
|
||||
public class BTextCustomizerFE
|
||||
extends BWbFieldEditor {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BTextCustomizerFE == null ? (class$com$tridium$alarm$ui$BTextCustomizerFE = BTextCustomizerFE.class$("com.tridium.alarm.ui.BTextCustomizerFE")) : class$com$tridium$alarm$ui$BTextCustomizerFE));
|
||||
BFrozenEnumFE opFE = new BFrozenEnumFE();
|
||||
BStringFE formatFE = new BStringFE();
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BTextCustomizerFE;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
protected void doSetReadonly(boolean bl) {
|
||||
this.opFE.setReadonly(bl);
|
||||
this.formatFE.setReadonly(bl);
|
||||
}
|
||||
|
||||
protected void doLoadValue(BObject bObject, Context context) {
|
||||
BTextCustomizer bTextCustomizer = (BTextCustomizer)bObject;
|
||||
this.opFE.loadValue((BObject)bTextCustomizer.getOp(), context);
|
||||
this.formatFE.loadValue((BObject)BString.make((String)bTextCustomizer.getText().getFormat()), context);
|
||||
BGridPane bGridPane = new BGridPane(2);
|
||||
bGridPane.add("c0", (BValue)this.opFE);
|
||||
bGridPane.add("c1", (BValue)this.formatFE);
|
||||
this.setContent((BWidget)bGridPane);
|
||||
this.opFE.setReadonly(Flags.isReadonly((BComplex)bTextCustomizer, (Slot)BTextCustomizer.op));
|
||||
this.formatFE.setReadonly(Flags.isReadonly((BComplex)bTextCustomizer, (Slot)BTextCustomizer.text));
|
||||
this.linkTo((BComponent)this.opFE, (Slot)BFrozenEnumFE.actionPerformed, (Slot)actionPerformed);
|
||||
this.linkTo((BComponent)this.formatFE, (Slot)BStringFE.actionPerformed, (Slot)actionPerformed);
|
||||
this.linkTo((BComponent)this.opFE, (Slot)BFrozenEnumFE.pluginModified, (Slot)setModified);
|
||||
this.linkTo((BComponent)this.formatFE, (Slot)BStringFE.pluginModified, (Slot)setModified);
|
||||
}
|
||||
|
||||
protected BObject doSaveValue(BObject bObject, Context context) throws Exception {
|
||||
BTextCustomizer bTextCustomizer = (BTextCustomizer)bObject;
|
||||
BTextOp bTextOp = (BTextOp)this.opFE.saveValue();
|
||||
BString bString = (BString)this.formatFE.saveValue();
|
||||
bTextCustomizer.setOp(bTextOp);
|
||||
bTextCustomizer.setText(BFormat.make((String)bString.toString()));
|
||||
return bTextCustomizer;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BFrozenEnum
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import javax.baja.sys.BFrozenEnum;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
public final class BTimeZoneDisplay
|
||||
extends BFrozenEnum {
|
||||
public static final int CONSOLE = 0;
|
||||
public static final int SOURCE = 1;
|
||||
public static final BTimeZoneDisplay console = new BTimeZoneDisplay(0);
|
||||
public static final BTimeZoneDisplay source = new BTimeZoneDisplay(1);
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BTimeZoneDisplay == null ? (class$com$tridium$alarm$ui$BTimeZoneDisplay = BTimeZoneDisplay.class$("com.tridium.alarm.ui.BTimeZoneDisplay")) : class$com$tridium$alarm$ui$BTimeZoneDisplay));
|
||||
public static final BTimeZoneDisplay DEFAULT = console;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BTimeZoneDisplay;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static BTimeZoneDisplay make(int n) {
|
||||
return (BTimeZoneDisplay)console.getRange().get(n, false);
|
||||
}
|
||||
|
||||
public static BTimeZoneDisplay make(String string) {
|
||||
return (BTimeZoneDisplay)console.getRange().get(string);
|
||||
}
|
||||
|
||||
private BTimeZoneDisplay(int n) {
|
||||
super(n);
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
*/
|
||||
package com.tridium.alarm.ui;
|
||||
|
||||
import com.tridium.alarm.ui.TrayIconListener;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Vector;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
public class BTrayIcon
|
||||
extends BComponent {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$alarm$ui$BTrayIcon == null ? (class$com$tridium$alarm$ui$BTrayIcon = BTrayIcon.class$("com.tridium.alarm.ui.BTrayIcon")) : class$com$tridium$alarm$ui$BTrayIcon));
|
||||
private boolean isShowing = false;
|
||||
private int nativePeer;
|
||||
private int nativeImage;
|
||||
private String toolTip;
|
||||
private Vector listeners = new Vector();
|
||||
private Thread thread;
|
||||
public static int YELLOW_ICON;
|
||||
public static int GRAY_ICON;
|
||||
public static int GREEN_ICON;
|
||||
public static int RED_ICON;
|
||||
public static int WHITE_ICON;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ui$BTrayIcon;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BTrayIcon make() {
|
||||
return new BTrayIcon();
|
||||
}
|
||||
|
||||
public BTrayIcon() {
|
||||
this.nativeImage = BTrayIcon.loadImage(System.mapLibraryName("trayIcon"));
|
||||
this.toolTip = "Niagara Alarms";
|
||||
}
|
||||
|
||||
public BTrayIcon(int n, String string) {
|
||||
this.nativeImage = n;
|
||||
this.toolTip = string;
|
||||
}
|
||||
|
||||
public boolean isShowing() {
|
||||
return this.isShowing;
|
||||
}
|
||||
|
||||
public int getImage() {
|
||||
return this.nativeImage;
|
||||
}
|
||||
|
||||
public String getToolTip() {
|
||||
return this.toolTip;
|
||||
}
|
||||
|
||||
public void setImage(int n) {
|
||||
this.nativeImage = n;
|
||||
}
|
||||
|
||||
public void setToolTip(String string) {
|
||||
this.toolTip = string;
|
||||
}
|
||||
|
||||
public void show() {
|
||||
this.isShowing = true;
|
||||
this.doShow();
|
||||
}
|
||||
|
||||
public void updateTrayIcon() {
|
||||
this.updateTrayIcon(this.nativeImage, this.toolTip);
|
||||
}
|
||||
|
||||
public void updateTrayIcon(String string) {
|
||||
this.updateTrayIcon(this.nativeImage, string);
|
||||
}
|
||||
|
||||
public void updateTrayIcon(int n) {
|
||||
this.updateTrayIcon(n, this.toolTip);
|
||||
}
|
||||
|
||||
public void updateTrayIcon(int n, String string) {
|
||||
this.nativeImage = n;
|
||||
this.toolTip = string;
|
||||
if (this.isShowing) {
|
||||
this.nativePeer = this.nativeUpdate(this.nativeImage, string, this.nativePeer);
|
||||
}
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
if (this.isShowing) {
|
||||
this.isShowing = false;
|
||||
this.nativeHide(this.nativePeer);
|
||||
this.thread = null;
|
||||
}
|
||||
this.nativePeer = 0;
|
||||
}
|
||||
|
||||
private void doShow() {
|
||||
if (this.thread != null) {
|
||||
this.hide();
|
||||
}
|
||||
this.thread = new Thread(){
|
||||
|
||||
public void run() {
|
||||
BTrayIcon.this.nativePeer = BTrayIcon.this.nativeShow(BTrayIcon.this.nativeImage, BTrayIcon.this.toolTip, BTrayIcon.this.nativePeer);
|
||||
}
|
||||
};
|
||||
this.thread.start();
|
||||
}
|
||||
|
||||
public void fireClicked() {
|
||||
Vector vector = (Vector)this.listeners.clone();
|
||||
Enumeration enumeration = vector.elements();
|
||||
while (enumeration.hasMoreElements()) {
|
||||
TrayIconListener trayIconListener = (TrayIconListener)enumeration.nextElement();
|
||||
trayIconListener.onTrayIconClicked(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void fireDoubleClicked() {
|
||||
Vector vector = (Vector)this.listeners.clone();
|
||||
Enumeration enumeration = vector.elements();
|
||||
while (enumeration.hasMoreElements()) {
|
||||
TrayIconListener trayIconListener = (TrayIconListener)enumeration.nextElement();
|
||||
trayIconListener.onTrayIconDoubleClicked(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void addTrayIconListener(TrayIconListener trayIconListener) {
|
||||
this.listeners.addElement(trayIconListener);
|
||||
}
|
||||
|
||||
public void removeTrayIconListener(TrayIconListener trayIconListener) {
|
||||
this.listeners.removeElement(trayIconListener);
|
||||
}
|
||||
|
||||
private native int nativeShow(int var1, String var2, int var3);
|
||||
|
||||
private synchronized native int nativeUpdate(int var1, String var2, int var3);
|
||||
|
||||
private native void nativeHide(int var1);
|
||||
|
||||
private static synchronized native int nativeLoadImage(String var0, int var1) throws UnsatisfiedLinkError;
|
||||
|
||||
private static synchronized native int nativeFreeImage(int var0) throws UnsatisfiedLinkError;
|
||||
|
||||
public static int loadImage(String string) {
|
||||
return BTrayIcon.loadImage(string, 0);
|
||||
}
|
||||
|
||||
public static int loadImage(String string, int n) {
|
||||
try {
|
||||
return BTrayIcon.nativeLoadImage(string, n);
|
||||
}
|
||||
catch (UnsatisfiedLinkError unsatisfiedLinkError) {
|
||||
unsatisfiedLinkError.printStackTrace();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
protected static void freeImage(int n) {
|
||||
try {
|
||||
BTrayIcon.nativeFreeImage(n);
|
||||
}
|
||||
catch (UnsatisfiedLinkError unsatisfiedLinkError) {
|
||||
unsatisfiedLinkError.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] stringArray) {
|
||||
BTrayIcon bTrayIcon = new BTrayIcon();
|
||||
long l = System.currentTimeMillis();
|
||||
bTrayIcon.show();
|
||||
long l2 = System.currentTimeMillis();
|
||||
bTrayIcon.updateTrayIcon("77 UnAcked Alarms");
|
||||
long l3 = System.currentTimeMillis();
|
||||
System.out.println("show: " + (l2 - l) + "ms");
|
||||
System.out.println("end: " + (l3 - l2) + "ms");
|
||||
System.out.println("total: " + (l3 - l) + "ms");
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("trayIcon");
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
System.out.println("ERROR: Cannot load trayIcon native library");
|
||||
System.out.println(" " + throwable);
|
||||
}
|
||||
YELLOW_ICON = 0;
|
||||
GRAY_ICON = 1;
|
||||
GREEN_ICON = 2;
|
||||
RED_ICON = 3;
|
||||
WHITE_ICON = 4;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user