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

334 lines
13 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.ui.BOptionDialog
* com.tridium.workbench.util.BFlagConfig
* javax.baja.sys.Action
* javax.baja.sys.BComponent
* javax.baja.sys.BIPropertyContainer
* javax.baja.sys.BValue
* javax.baja.sys.Flags
* javax.baja.sys.Flags$Flag
* javax.baja.sys.Property
* javax.baja.sys.Slot
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BCheckBox
* javax.baja.ui.BDialog
* javax.baja.ui.BLabel
* javax.baja.ui.BListDropDown
* javax.baja.ui.BNullWidget
* javax.baja.ui.BRadioButton
* javax.baja.ui.BWidget
* javax.baja.ui.CommandArtifact
* javax.baja.ui.ToggleCommand
* javax.baja.ui.ToggleCommandGroup
* javax.baja.ui.enums.BHalign
* javax.baja.ui.pane.BBorderPane
* javax.baja.ui.pane.BGridPane
* javax.baja.util.Lexicon
*/
package com.tridium.program.ui.batch;
import com.tridium.program.ui.batch.BBatchEditor;
import com.tridium.ui.BOptionDialog;
import com.tridium.workbench.util.BFlagConfig;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;
import javax.baja.sys.Action;
import javax.baja.sys.BComponent;
import javax.baja.sys.BIPropertyContainer;
import javax.baja.sys.BValue;
import javax.baja.sys.Flags;
import javax.baja.sys.Property;
import javax.baja.sys.Slot;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BCheckBox;
import javax.baja.ui.BDialog;
import javax.baja.ui.BLabel;
import javax.baja.ui.BListDropDown;
import javax.baja.ui.BNullWidget;
import javax.baja.ui.BRadioButton;
import javax.baja.ui.BWidget;
import javax.baja.ui.CommandArtifact;
import javax.baja.ui.ToggleCommand;
import javax.baja.ui.ToggleCommandGroup;
import javax.baja.ui.enums.BHalign;
import javax.baja.ui.pane.BBorderPane;
import javax.baja.ui.pane.BGridPane;
import javax.baja.util.Lexicon;
public class BSetFlagsDialog
extends BOptionDialog {
public static final Action propertyChanged = BSetFlagsDialog.newAction((int)0, null, null);
public static final Action useSelectionChanged = BSetFlagsDialog.newAction((int)0, null, null);
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$batch$BSetFlagsDialog == null ? (class$com$tridium$program$ui$batch$BSetFlagsDialog = BSetFlagsDialog.class$("com.tridium.program.ui.batch.BSetFlagsDialog")) : class$com$tridium$program$ui$batch$BSetFlagsDialog));
private static Lexicon lex = Lexicon.make((String)"program");
private static final FlagWrapper[] FLAGS;
private static final Object USE_SELECTED_COMPONENTS;
private BBatchEditor parent;
private BListDropDown dropDown;
private BListDropDown flagDropDown;
private BCheckBox useSelection = new BCheckBox(lex.getText("batchEditor.setFlagsOnSelectedObjects"));
private SetFlag setFlag;
private RemoveFlag removeFlag;
private Hashtable validFlags;
static /* synthetic */ Class class$com$tridium$program$ui$batch$BSetFlagsDialog;
public void propertyChanged() {
this.invoke(propertyChanged, null, null);
}
public void useSelectionChanged() {
this.invoke(useSelectionChanged, null, null);
}
public Type getType() {
return TYPE;
}
public static String open(BBatchEditor bBatchEditor) {
BSetFlagsDialog bSetFlagsDialog = new BSetFlagsDialog(bBatchEditor);
bSetFlagsDialog.setBoundsCenteredOnOwner();
bSetFlagsDialog.open();
if (bSetFlagsDialog.getResult() == 1) {
try {
boolean bl = bSetFlagsDialog.useSelection.isSelected();
String string = bl ? "null" : (String)bSetFlagsDialog.dropDown.getList().getSelectedItem();
int n = ((FlagWrapper)bSetFlagsDialog.flagDropDown.getList().getSelectedItem()).flag.getMask();
boolean bl2 = bSetFlagsDialog.setFlag.isSelected();
StringBuffer stringBuffer = new StringBuffer("setFlag(ord, ");
stringBuffer.append("\"").append(string).append("\", ").append(n);
stringBuffer.append(bl ? ", true" : ", false");
stringBuffer.append(bl2 ? ", true);" : ", false);");
return stringBuffer.toString();
}
catch (Exception exception) {
BDialog.error((BWidget)bBatchEditor, (String)"Error", (Object)"Failed", (Throwable)exception);
}
}
return null;
}
private BSetFlagsDialog(BBatchEditor bBatchEditor) {
super((BWidget)bBatchEditor, lex.getText("batchEditor.commands.slotFlags.label"), (BWidget)new BNullWidget(), 3, null, null);
Object object;
Object object2;
Object object3;
this.useSelection.setSelected(false);
this.linkTo((BComponent)this.useSelection, (Slot)BCheckBox.actionPerformed, (Slot)useSelectionChanged);
int n = bBatchEditor.table.model.kids.size();
this.validFlags = new Hashtable();
String string = null;
for (int i = 0; i < n; ++i) {
Object object4;
Slot slot;
Property property;
object3 = (BComponent)bBatchEditor.table.model.kids.get(i);
object2 = object3.getParent();
if (object2 instanceof BComponent && (property = object3.getPropertyInParent()) != null) {
int n2;
slot = new BFlagConfig((BIPropertyContainer)((BComponent)object2), new Slot[]{property});
object4 = (boolean[])this.validFlags.get(USE_SELECTED_COMPONENTS);
if (object4 == null) {
object4 = new boolean[FLAGS.length];
for (n2 = 0; n2 < FLAGS.length; ++n2) {
object4[n2] = slot.isEnabled(BSetFlagsDialog.FLAGS[n2].flag);
}
} else {
for (n2 = 0; n2 < FLAGS.length; ++n2) {
object4[n2] = object4[n2] != false && slot.isEnabled(BSetFlagsDialog.FLAGS[n2].flag);
}
}
this.validFlags.put(USE_SELECTED_COMPONENTS, object4);
}
property = object3.getSlots();
while (property.next()) {
int n3;
slot = property.slot();
object4 = slot.getName();
if (string == null) {
string = object4;
}
BFlagConfig bFlagConfig = new BFlagConfig((BIPropertyContainer)object3, new Slot[]{slot});
object = (boolean[])this.validFlags.get(object4);
if (object == null) {
object = new boolean[FLAGS.length];
for (n3 = 0; n3 < FLAGS.length; ++n3) {
object[n3] = bFlagConfig.isEnabled(BSetFlagsDialog.FLAGS[n3].flag);
}
} else {
for (n3 = 0; n3 < FLAGS.length; ++n3) {
object[n3] = object[n3] && bFlagConfig.isEnabled(BSetFlagsDialog.FLAGS[n3].flag);
}
}
this.validFlags.put(object4, object);
}
}
this.dropDown = new BListDropDown();
ArrayList<String> arrayList = new ArrayList<String>();
object3 = this.validFlags.keys();
while (object3.hasMoreElements()) {
object2 = object3.nextElement();
if (object2 == USE_SELECTED_COMPONENTS) continue;
arrayList.add((String)object2);
}
object2 = arrayList.toArray(new String[arrayList.size()]);
Arrays.sort((Object[])object2);
for (int i = 0; i < ((Object[])object2).length; ++i) {
this.dropDown.getList().addItem(object2[i]);
}
if (((Object[])object2).length > 0) {
this.dropDown.getList().setSelectedIndex(0);
}
this.linkTo((BComponent)this.dropDown, (Slot)BListDropDown.listActionPerformed, (Slot)propertyChanged);
this.flagDropDown = new BListDropDown();
if (string != null) {
boolean[] blArray = (boolean[])this.validFlags.get(string);
boolean bl = false;
for (int i = 0; i < FLAGS.length; ++i) {
if (!blArray[i]) continue;
this.flagDropDown.getList().addItem((Object)FLAGS[i]);
bl = true;
}
if (bl) {
this.flagDropDown.getList().setSelectedIndex(0);
}
}
BGridPane bGridPane = new BGridPane(1);
bGridPane.setHalign(BHalign.left);
bGridPane.add(null, (BValue)this.useSelection);
BGridPane bGridPane2 = new BGridPane(2);
bGridPane2.setHalign(BHalign.left);
bGridPane2.add(null, (BValue)new BLabel(lex.getText("batchEditor.slot")));
bGridPane2.add(null, (BValue)this.dropDown);
bGridPane2.add(null, (BValue)new BLabel(lex.getText("batchEditor.flag")));
bGridPane2.add(null, (BValue)this.flagDropDown);
ToggleCommandGroup toggleCommandGroup = new ToggleCommandGroup();
this.setFlag = new SetFlag((BWidget)this);
toggleCommandGroup.add((ToggleCommand)this.setFlag);
this.removeFlag = new RemoveFlag((BWidget)this);
toggleCommandGroup.add((ToggleCommand)this.removeFlag);
this.setFlag.setSelected(true);
BGridPane bGridPane3 = new BGridPane(2);
bGridPane3.setHalign(BHalign.left);
bGridPane3.add(null, (BValue)new BRadioButton((ToggleCommand)this.setFlag));
bGridPane3.add(null, (BValue)new BRadioButton((ToggleCommand)this.removeFlag));
object = new BGridPane(1);
object.setHalign(BHalign.left);
object.add(null, (BValue)bGridPane);
object.add(null, (BValue)bGridPane2);
object.add(null, (BValue)bGridPane3);
this.setContent((BWidget)new BBorderPane((BWidget)object, 10.0, 10.0, 10.0, 10.0));
}
public void doPropertyChanged() {
try {
String string = (String)this.dropDown.getList().getSelectedItem();
if (string == null) {
this.flagDropDown.getList().removeAllItems();
this.flagDropDown.getList().setSelectedIndex(0);
return;
}
boolean[] blArray = (boolean[])this.validFlags.get(string);
Object object = this.flagDropDown.getSelectedItem();
FlagWrapper flagWrapper = null;
this.flagDropDown.getList().removeAllItems();
for (int i = 0; i < FLAGS.length; ++i) {
if (!blArray[i]) continue;
this.flagDropDown.getList().addItem((Object)FLAGS[i]);
if (FLAGS[i] != object) continue;
flagWrapper = FLAGS[i];
}
if (flagWrapper != null) {
this.flagDropDown.getList().setSelectedItem(flagWrapper);
} else {
this.flagDropDown.getList().setSelectedIndex(0);
}
}
catch (Exception exception) {
exception.printStackTrace();
}
}
public void doUseSelectionChanged() {
boolean bl = !this.useSelection.isSelected();
this.dropDown.setEnabled(bl);
if (!bl) {
boolean[] blArray = (boolean[])this.validFlags.get(USE_SELECTED_COMPONENTS);
Object object = this.flagDropDown.getSelectedItem();
FlagWrapper flagWrapper = null;
this.flagDropDown.getList().removeAllItems();
for (int i = 0; i < FLAGS.length; ++i) {
if (!blArray[i]) continue;
this.flagDropDown.getList().addItem((Object)FLAGS[i]);
if (FLAGS[i] != object) continue;
flagWrapper = FLAGS[i];
}
if (flagWrapper != null) {
this.flagDropDown.getList().setSelectedItem(flagWrapper);
} else {
this.flagDropDown.getList().setSelectedIndex(0);
}
} else {
this.doPropertyChanged();
}
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
static {
Flags.Flag[] flagArray = Flags.getFlags();
FLAGS = new FlagWrapper[flagArray.length];
for (int i = 0; i < flagArray.length; ++i) {
BSetFlagsDialog.FLAGS[i] = new FlagWrapper(flagArray[i]);
}
USE_SELECTED_COMPONENTS = new Object();
}
static class RemoveFlag
extends ToggleCommand {
RemoveFlag(BWidget bWidget) {
super(bWidget, lex.getText("batchEditor.removeFlag"));
}
public CommandArtifact doInvoke() {
return null;
}
}
static class SetFlag
extends ToggleCommand {
SetFlag(BWidget bWidget) {
super(bWidget, lex.getText("batchEditor.setFlag"));
}
public CommandArtifact doInvoke() {
return null;
}
}
static class FlagWrapper {
Flags.Flag flag;
public FlagWrapper(Flags.Flag flag) {
this.flag = flag;
}
public String toString() {
return this.flag.getDisplayName(null);
}
}
}