237 lines
9.5 KiB
Java
237 lines
9.5 KiB
Java
/*
|
|
* 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());
|
|
}
|
|
}
|
|
}
|
|
|