2026-03-17 13:31:18 -07:00

196 lines
8.1 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.ui.BOptionDialog
* com.tridium.ui.theme.Theme
* com.tridium.workbench.fieldeditors.BTypeSpecFE
* javax.baja.data.BIDataValue
* javax.baja.gx.BBrush
* javax.baja.io.ValueDocEncoder
* javax.baja.naming.SlotPath
* javax.baja.sys.Action
* javax.baja.sys.BBoolean
* javax.baja.sys.BComponent
* javax.baja.sys.BFacets
* javax.baja.sys.BObject
* javax.baja.sys.BValue
* javax.baja.sys.Context
* javax.baja.sys.Slot
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BCheckBox
* javax.baja.ui.BDialog
* javax.baja.ui.BLabel
* javax.baja.ui.BNullWidget
* javax.baja.ui.BTextField
* javax.baja.ui.BWidget
* javax.baja.ui.enums.BHalign
* javax.baja.ui.enums.BScrollBarPolicy
* javax.baja.ui.enums.BValign
* javax.baja.ui.pane.BBorderPane
* javax.baja.ui.pane.BEdgePane
* javax.baja.ui.pane.BGridPane
* javax.baja.ui.pane.BScrollPane
* javax.baja.util.BTypeSpec
* javax.baja.util.Lexicon
* javax.baja.workbench.fieldeditor.BWbFieldEditor
*/
package com.tridium.program.ui.batch;
import com.tridium.program.ui.batch.BBatchEditor;
import com.tridium.ui.BOptionDialog;
import com.tridium.ui.theme.Theme;
import com.tridium.workbench.fieldeditors.BTypeSpecFE;
import javax.baja.data.BIDataValue;
import javax.baja.gx.BBrush;
import javax.baja.io.ValueDocEncoder;
import javax.baja.naming.SlotPath;
import javax.baja.sys.Action;
import javax.baja.sys.BBoolean;
import javax.baja.sys.BComponent;
import javax.baja.sys.BFacets;
import javax.baja.sys.BObject;
import javax.baja.sys.BValue;
import javax.baja.sys.Context;
import javax.baja.sys.Slot;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BCheckBox;
import javax.baja.ui.BDialog;
import javax.baja.ui.BLabel;
import javax.baja.ui.BNullWidget;
import javax.baja.ui.BTextField;
import javax.baja.ui.BWidget;
import javax.baja.ui.enums.BHalign;
import javax.baja.ui.enums.BScrollBarPolicy;
import javax.baja.ui.enums.BValign;
import javax.baja.ui.pane.BBorderPane;
import javax.baja.ui.pane.BEdgePane;
import javax.baja.ui.pane.BGridPane;
import javax.baja.ui.pane.BScrollPane;
import javax.baja.util.BTypeSpec;
import javax.baja.util.Lexicon;
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
public class BAddDialog
extends BOptionDialog {
public static final Action typeChanged = BAddDialog.newAction((int)0, null, null);
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$batch$BAddDialog == null ? (class$com$tridium$program$ui$batch$BAddDialog = BAddDialog.class$("com.tridium.program.ui.batch.BAddDialog")) : class$com$tridium$program$ui$batch$BAddDialog));
private static Lexicon lex = Lexicon.make((String)"program");
private BTextField name = new BTextField("", 30);
private BTypeSpecFE type;
private BWbFieldEditor editor;
private BCheckBox setIfExists = new BCheckBox(lex.getText("batchEditor.setIfExists"));
private BBorderPane content;
static /* synthetic */ Class class$com$tridium$program$ui$batch$BAddDialog;
public void typeChanged() {
this.invoke(typeChanged, null, null);
}
public Type getType() {
return TYPE;
}
public static String open(BBatchEditor bBatchEditor) {
BAddDialog bAddDialog = new BAddDialog(bBatchEditor);
bAddDialog.setBoundsCenteredOnOwner();
bAddDialog.open();
if (bAddDialog.getResult() == 1) {
try {
if (SlotPath.isValidName((String)bAddDialog.name.getText())) {
String string = bAddDialog.name.getText();
BValue bValue = (BValue)bAddDialog.editor.saveValue();
boolean bl = bAddDialog.setIfExists.isSelected();
String string2 = ValueDocEncoder.marshal((BValue)bValue);
string2 = string2.replaceAll("\"", "'");
string2 = string2.replaceAll("\n", "");
StringBuffer stringBuffer = new StringBuffer("add(ord, ");
stringBuffer.append("\"").append(string).append("\", ");
stringBuffer.append("\"").append(bValue.getType().getTypeSpec()).append("\", ");
stringBuffer.append("\"").append(string2).append("\", ");
stringBuffer.append(bl ? "true" : "false").append(");");
return stringBuffer.toString();
}
BDialog.error((BWidget)bBatchEditor, (String)lex.getText("batchEditor.commands.slotAdd.label"), (Object)lex.getText("batchEditor.invalidName"));
}
catch (Exception exception) {
BDialog.error((BWidget)bBatchEditor, (String)"Error", (Object)"Failed", (Throwable)exception);
}
}
return null;
}
private BAddDialog(BBatchEditor bBatchEditor) {
super((BWidget)bBatchEditor, lex.getText("batchEditor.commands.slotAdd.label"), (BWidget)new BNullWidget(), 3, null, null);
BFacets bFacets = BFacets.make((String)"allowNull", (BIDataValue)BBoolean.FALSE);
bFacets = BFacets.make((BFacets)bFacets, (String)"showAbstract", (BIDataValue)BBoolean.FALSE);
this.type = new BTypeSpecFE();
this.linkTo("link", (BComponent)this.type, (Slot)BTypeSpecFE.pluginModified, (Slot)typeChanged);
this.type.loadValue((BObject)BComponent.TYPE.getTypeSpec(), (Context)bFacets);
this.setIfExists.setSelected(true);
this.editor = this.make(BComponent.TYPE);
BGridPane bGridPane = new BGridPane(1);
bGridPane.setValign(BValign.top);
bGridPane.setHalign(BHalign.left);
this.content = new BBorderPane((BWidget)this.editor, 1.0, 1.0, 1.0, 1.0);
bGridPane.add(null, (BValue)this.content);
BGridPane bGridPane2 = new BGridPane(2);
bGridPane2.add(null, (BValue)new BLabel(lex.getText("batchEditor.newName")));
bGridPane2.add(null, (BValue)this.name);
bGridPane2.add(null, (BValue)new BLabel(lex.getText("batchEditor.newType")));
bGridPane2.add(null, (BValue)this.type);
BGridPane bGridPane3 = new BGridPane(1);
bGridPane3.setHalign(BHalign.left);
bGridPane3.add(null, (BValue)bGridPane2);
bGridPane3.add(null, (BValue)this.setIfExists);
BEdgePane bEdgePane = new BEdgePane();
bEdgePane.setTop((BWidget)new BBorderPane((BWidget)bGridPane3, 0.0, 0.0, 10.0, 0.0));
BBrush bBrush = Theme.scrollPane().getControlBackground();
BScrollPane bScrollPane = new BScrollPane((BWidget)new BBorderPane((BWidget)bGridPane, lex.getText("batchEditor.newValue")));
bScrollPane.setBorderPolicy(BScrollBarPolicy.asNeeded);
bScrollPane.setViewportBackground(bBrush);
bEdgePane.setCenter((BWidget)bScrollPane);
this.setContent((BWidget)new BBorderPane((BWidget)bEdgePane, 10.0, 10.0, 10.0, 10.0));
}
private BWbFieldEditor make(Type type) {
BObject bObject = type.getInstance();
BWbFieldEditor bWbFieldEditor = BWbFieldEditor.makeFor((BObject)bObject);
bWbFieldEditor.loadValue(bObject);
return bWbFieldEditor;
}
public void computePreferredSize() {
super.computePreferredSize();
double d = Math.max(500.0, this.getPreferredWidth());
double d2 = Math.max(300.0, this.getPreferredHeight());
this.setPreferredSize(d, d2);
}
public void doTypeChanged() {
try {
BObject bObject = ((BTypeSpec)this.type.saveValue()).getInstance();
this.editor = this.make(bObject.getType());
this.content.setContent((BWidget)this.editor);
this.computePreferredSize();
this.setSize(this.getPreferredWidth(), this.getPreferredHeight());
this.setBoundsCenteredOnOwner();
}
catch (Exception exception) {
exception.printStackTrace();
}
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
}