link start!
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.space.Mark
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.CommandArtifact
|
||||
* javax.baja.ui.transfer.TransferContext
|
||||
* javax.baja.ui.transfer.TransferFormat
|
||||
* javax.baja.ui.transfer.UnsupportedFormatException
|
||||
* javax.baja.ui.util.UiLexicon
|
||||
* javax.baja.workbench.mgr.BMgrTable
|
||||
* javax.baja.workbench.mgr.MgrModel
|
||||
*/
|
||||
package com.tridium.program.ui;
|
||||
|
||||
import com.tridium.program.BProgram;
|
||||
import javax.baja.space.Mark;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.CommandArtifact;
|
||||
import javax.baja.ui.transfer.TransferContext;
|
||||
import javax.baja.ui.transfer.TransferFormat;
|
||||
import javax.baja.ui.transfer.UnsupportedFormatException;
|
||||
import javax.baja.ui.util.UiLexicon;
|
||||
import javax.baja.workbench.mgr.BMgrTable;
|
||||
import javax.baja.workbench.mgr.MgrModel;
|
||||
|
||||
public class BBuilderTable
|
||||
extends BMgrTable {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$BBuilderTable == null ? (class$com$tridium$program$ui$BBuilderTable = BBuilderTable.class$("com.tridium.program.ui.BBuilderTable")) : class$com$tridium$program$ui$BBuilderTable));
|
||||
static /* synthetic */ Class class$com$tridium$program$ui$BBuilderTable;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BBuilderTable(MgrModel mgrModel) {
|
||||
super(mgrModel);
|
||||
}
|
||||
|
||||
public int getRowOfProgram(String string) {
|
||||
int n = this.getModel().getRowCount();
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (!this.getComponentAt(i).getDisplayName(null).equals(string)) continue;
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int dragOver(TransferContext transferContext) {
|
||||
return this.isAllPrograms(transferContext) ? super.dragOver(transferContext) : 0;
|
||||
}
|
||||
|
||||
public boolean isPasteSpecialEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public CommandArtifact insertTransferData(TransferContext transferContext) throws Exception {
|
||||
if (!this.isAllPrograms(transferContext)) {
|
||||
throw new UnsupportedFormatException(UiLexicon.bajaui().getText("command.paste.unsupportedFormat"));
|
||||
}
|
||||
return this.drop(transferContext);
|
||||
}
|
||||
|
||||
private boolean isAllPrograms(TransferContext transferContext) {
|
||||
Mark mark = (Mark)transferContext.getEnvelope().getData(TransferFormat.mark);
|
||||
BObject[] bObjectArray = mark.getValues();
|
||||
for (int i = 0; i < bObjectArray.length; ++i) {
|
||||
if (bObjectArray[i] instanceof BProgram) continue;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.gx.BColor
|
||||
* javax.baja.gx.BImage
|
||||
* javax.baja.gx.Graphics
|
||||
* javax.baja.nre.util.Array
|
||||
* javax.baja.nre.util.TextUtil
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BComplex
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BIcon
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.BasicContext
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Flags
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Slot
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.event.BWidgetEvent
|
||||
* javax.baja.workbench.BWbEditor
|
||||
* javax.baja.workbench.CannotSaveException
|
||||
* javax.baja.workbench.fieldeditor.BWbFieldEditor
|
||||
*/
|
||||
package com.tridium.program.ui;
|
||||
|
||||
import javax.baja.gx.BColor;
|
||||
import javax.baja.gx.BImage;
|
||||
import javax.baja.gx.Graphics;
|
||||
import javax.baja.nre.util.Array;
|
||||
import javax.baja.nre.util.TextUtil;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BComplex;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BIcon;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.BasicContext;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Flags;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Slot;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BLabel;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.event.BWidgetEvent;
|
||||
import javax.baja.workbench.BWbEditor;
|
||||
import javax.baja.workbench.CannotSaveException;
|
||||
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
|
||||
|
||||
public class BFieldSheet
|
||||
extends BWbEditor {
|
||||
public static final Property labelMargin = BFieldSheet.newProperty((int)0, (double)10.0, null);
|
||||
public static final Property rowGap = BFieldSheet.newProperty((int)0, (double)8.0, null);
|
||||
public static final Property indent = BFieldSheet.newProperty((int)0, (double)0.0, null);
|
||||
public static final Action handleEditorModified = BFieldSheet.newAction((int)0, (BValue)new BWidgetEvent(), null);
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$BFieldSheet == null ? (class$com$tridium$program$ui$BFieldSheet = BFieldSheet.class$("com.tridium.program.ui.BFieldSheet")) : class$com$tridium$program$ui$BFieldSheet));
|
||||
public static final String FORCE_SHOW = "fieldSheetShow";
|
||||
static final BColor dividerColor = BColor.make((int)0xBBBBBB);
|
||||
static BImage defaultIcon = BImage.make((String)"module://icons/x16/object.png");
|
||||
boolean showModified;
|
||||
private Array fields;
|
||||
private double[] divs;
|
||||
static /* synthetic */ Class class$com$tridium$program$ui$BFieldSheet;
|
||||
static /* synthetic */ Class class$com$tridium$program$ui$BFieldSheet$Field;
|
||||
|
||||
public double getLabelMargin() {
|
||||
return this.getDouble(labelMargin);
|
||||
}
|
||||
|
||||
public void setLabelMargin(double d) {
|
||||
this.setDouble(labelMargin, d, null);
|
||||
}
|
||||
|
||||
public double getRowGap() {
|
||||
return this.getDouble(rowGap);
|
||||
}
|
||||
|
||||
public void setRowGap(double d) {
|
||||
this.setDouble(rowGap, d, null);
|
||||
}
|
||||
|
||||
public double getIndent() {
|
||||
return this.getDouble(indent);
|
||||
}
|
||||
|
||||
public void setIndent(double d) {
|
||||
this.setDouble(indent, d, null);
|
||||
}
|
||||
|
||||
public void handleEditorModified(BWidgetEvent bWidgetEvent) {
|
||||
this.invoke(handleEditorModified, (BValue)bWidgetEvent, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BFieldSheet() {
|
||||
this(true);
|
||||
}
|
||||
|
||||
public BFieldSheet(boolean bl) {
|
||||
this.showModified = bl;
|
||||
}
|
||||
|
||||
public void doLoadValue(BObject bObject, Context context) {
|
||||
BComponent bComponent = (BComponent)bObject;
|
||||
Property[] propertyArray = bComponent.getPropertiesArray();
|
||||
this.fields = new Array(class$com$tridium$program$ui$BFieldSheet$Field == null ? (class$com$tridium$program$ui$BFieldSheet$Field = BFieldSheet.class$("com.tridium.program.ui.BFieldSheet$Field")) : class$com$tridium$program$ui$BFieldSheet$Field, propertyArray.length);
|
||||
for (int i = 0; i < propertyArray.length; ++i) {
|
||||
Property property = propertyArray[i];
|
||||
if (Flags.isHidden((BComplex)bComponent, (Slot)property) || property.isDynamic() && !property.getFacets().getb(FORCE_SHOW, false)) continue;
|
||||
BValue bValue = bComponent.get(property);
|
||||
BWbFieldEditor bWbFieldEditor = BWbFieldEditor.makeFor((BObject)bValue, (Context)property.getFacets());
|
||||
bWbFieldEditor.setReadonly((property.getDefaultFlags() & 1) != 0);
|
||||
bWbFieldEditor.loadValue((BObject)bValue, (Context)new BasicContext(context, property.getFacets()));
|
||||
String string = null;
|
||||
BImage bImage = null;
|
||||
string = property.getFacets().gets("iconOverride", null);
|
||||
bImage = string != null ? BImage.make((BIcon)BIcon.make((String)string)) : BImage.make((BIcon)bValue.getIcon());
|
||||
if (bImage == null) {
|
||||
bImage = defaultIcon;
|
||||
}
|
||||
Field field = new Field(property, new BLabel(bImage, TextUtil.toFriendly((String)property.getName())), bWbFieldEditor);
|
||||
field.icon = bImage;
|
||||
this.add("label" + i, (BValue)field.label);
|
||||
this.add("editor" + i, (BValue)field.editor);
|
||||
this.linkTo((BComponent)field.editor, (Slot)BWbFieldEditor.setModified, (Slot)setModified);
|
||||
this.linkTo((BComponent)field.editor, (Slot)BWbFieldEditor.setModified, (Slot)handleEditorModified);
|
||||
this.fields.add((Object)field);
|
||||
}
|
||||
this.divs = new double[this.fields.size()];
|
||||
}
|
||||
|
||||
public BObject doSaveValue(BObject bObject, Context context) throws CannotSaveException, Exception {
|
||||
int n;
|
||||
BComponent bComponent = (BComponent)bObject;
|
||||
int n2 = this.fields.size();
|
||||
for (n = 0; n < n2; ++n) {
|
||||
Field field = (Field)this.fields.get(n);
|
||||
if (!field.editor.isModified()) continue;
|
||||
bComponent.set(field.prop, (BValue)field.editor.saveValue((BObject)bComponent.get(field.prop), context));
|
||||
}
|
||||
for (n = 0; n < n2; ++n) {
|
||||
((Field)this.fields.get((int)n)).editor.clearModified();
|
||||
}
|
||||
this.handleEditorModified(null);
|
||||
this.clearModified();
|
||||
return bComponent;
|
||||
}
|
||||
|
||||
public void computePreferredSize() {
|
||||
if (this.fields == null) {
|
||||
this.setPreferredSize(0.0, 0.0);
|
||||
return;
|
||||
}
|
||||
double d = 0.0;
|
||||
double d2 = 0.0;
|
||||
double d3 = 0.0;
|
||||
int n = this.fields.size();
|
||||
for (int i = 0; i < n; ++i) {
|
||||
Field field = (Field)this.fields.get(i);
|
||||
field.label.computePreferredSize();
|
||||
field.editor.computePreferredSize();
|
||||
if (i == 0) {
|
||||
d = field.label.getPreferredWidth();
|
||||
d2 = field.editor.getPreferredWidth();
|
||||
} else {
|
||||
d = Math.max(d, field.label.getPreferredWidth());
|
||||
d2 = Math.max(d2, field.editor.getPreferredWidth());
|
||||
}
|
||||
if (i != 0) {
|
||||
d3 += this.getRowGap();
|
||||
}
|
||||
d3 += Math.max(field.label.getPreferredHeight(), field.editor.getPreferredHeight());
|
||||
}
|
||||
this.setPreferredSize(this.getIndent() + d + d2 + this.getLabelMargin(), d3);
|
||||
}
|
||||
|
||||
public void doLayout(BWidget[] bWidgetArray) {
|
||||
if (this.fields == null) {
|
||||
return;
|
||||
}
|
||||
double d = 0.0;
|
||||
int n = this.fields.size();
|
||||
for (int i = 0; i < n; ++i) {
|
||||
Field field = (Field)this.fields.get(i);
|
||||
field.label.computePreferredSize();
|
||||
field.editor.computePreferredSize();
|
||||
d = i == 0 ? field.label.getPreferredWidth() : Math.max(d, field.label.getPreferredWidth());
|
||||
}
|
||||
double d2 = 0.0;
|
||||
double d3 = this.getIndent();
|
||||
for (int i = 0; i < n; ++i) {
|
||||
Field field = (Field)this.fields.get(i);
|
||||
double d4 = Math.max(field.label.getPreferredHeight(), field.editor.getPreferredHeight());
|
||||
field.label.setBounds(d3, d2 + (d4 - field.label.getPreferredHeight()) / 2.0, field.label.getPreferredWidth(), d4);
|
||||
field.editor.setBounds(d3 + d + this.getLabelMargin(), d2 + (d4 - field.editor.getPreferredHeight()) / 2.0, field.editor.getPreferredWidth(), d4);
|
||||
this.divs[i] = d2 += d4 + this.getRowGap();
|
||||
}
|
||||
}
|
||||
|
||||
public void paint(Graphics graphics) {
|
||||
this.paintChildren(graphics);
|
||||
for (int i = 0; i < this.divs.length; ++i) {
|
||||
double d = this.divs[i] - this.getRowGap() / 2.0;
|
||||
graphics.setBrush(dividerColor);
|
||||
graphics.strokeLine(0.0, d, this.getWidth(), d);
|
||||
}
|
||||
}
|
||||
|
||||
public void doHandleEditorModified(BWidgetEvent bWidgetEvent) {
|
||||
if (!this.showModified) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < this.fields.size(); ++i) {
|
||||
Field field = (Field)this.fields.get(i);
|
||||
if (field.editor.isModified()) {
|
||||
field.label.setImage(field.icon.getHighlightedImage());
|
||||
continue;
|
||||
}
|
||||
field.label.setImage(field.icon);
|
||||
}
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private class Field {
|
||||
public Property prop;
|
||||
public BLabel label;
|
||||
public BWbFieldEditor editor;
|
||||
public BImage icon;
|
||||
|
||||
public Field(Property property, BLabel bLabel, BWbFieldEditor bWbFieldEditor) {
|
||||
this.prop = property;
|
||||
this.label = bLabel;
|
||||
this.editor = bWbFieldEditor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,396 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.workbench.console.BConsole$HyperlinkInterceptor
|
||||
* com.tridium.workbench.shell.BNiagaraWbShell
|
||||
* com.tridium.workbench.slotsheet.BSlotSheet
|
||||
* javax.baja.gx.BImage
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.SlotPath
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BComponentEvent
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Slot
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BButton
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BMenu
|
||||
* javax.baja.ui.BToolBar
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.CommandArtifact
|
||||
* javax.baja.ui.enums.BHalign
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BEdgePane
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.ui.pane.BTabbedPane
|
||||
* javax.baja.ui.pane.BTextEditorPane
|
||||
* javax.baja.ui.text.BTextEditor
|
||||
* javax.baja.ui.text.Position
|
||||
* javax.baja.ui.text.TextParser
|
||||
* javax.baja.ui.text.parsers.JavaParser
|
||||
* javax.baja.ui.transfer.BTransferWidget
|
||||
* javax.baja.ui.util.UiLexicon
|
||||
* javax.baja.workbench.view.BWbComponentView
|
||||
*/
|
||||
package com.tridium.program.ui;
|
||||
|
||||
import com.tridium.program.BProgram;
|
||||
import com.tridium.program.BProgramCode;
|
||||
import com.tridium.program.module.BProgramModule;
|
||||
import com.tridium.program.ui.Imports;
|
||||
import com.tridium.program.ui.ProgramCompiler;
|
||||
import com.tridium.program.ui.ProgramEditorCommands;
|
||||
import com.tridium.program.ui.SourceWriter;
|
||||
import com.tridium.workbench.console.BConsole;
|
||||
import com.tridium.workbench.shell.BNiagaraWbShell;
|
||||
import com.tridium.workbench.slotsheet.BSlotSheet;
|
||||
import java.io.File;
|
||||
import javax.baja.gx.BImage;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.SlotPath;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BComponentEvent;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Slot;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BButton;
|
||||
import javax.baja.ui.BLabel;
|
||||
import javax.baja.ui.BMenu;
|
||||
import javax.baja.ui.BToolBar;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.CommandArtifact;
|
||||
import javax.baja.ui.enums.BHalign;
|
||||
import javax.baja.ui.pane.BBorderPane;
|
||||
import javax.baja.ui.pane.BEdgePane;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.ui.pane.BTabbedPane;
|
||||
import javax.baja.ui.pane.BTextEditorPane;
|
||||
import javax.baja.ui.text.BTextEditor;
|
||||
import javax.baja.ui.text.Position;
|
||||
import javax.baja.ui.text.TextParser;
|
||||
import javax.baja.ui.text.parsers.JavaParser;
|
||||
import javax.baja.ui.transfer.BTransferWidget;
|
||||
import javax.baja.ui.util.UiLexicon;
|
||||
import javax.baja.workbench.view.BWbComponentView;
|
||||
|
||||
public class BProgramEditor
|
||||
extends BWbComponentView
|
||||
implements BConsole.HyperlinkInterceptor {
|
||||
public static final Action codeTextModified = BProgramEditor.newAction((int)0, null);
|
||||
public static final Action tabSelectionModified = BProgramEditor.newAction((int)0, null);
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$BProgramEditor == null ? (class$com$tridium$program$ui$BProgramEditor = BProgramEditor.class$("com.tridium.program.ui.BProgramEditor")) : class$com$tridium$program$ui$BProgramEditor));
|
||||
static UiLexicon lex = UiLexicon.bajaui;
|
||||
static String statusOk = lex.getText("programEditor.status.ok");
|
||||
static String statusNeedsCompile = lex.getText("programEditor.status.needsCompile");
|
||||
static String statusError = lex.getText("programEditor.status.error");
|
||||
static BImage statusOkIcon = BImage.make((String)"module://icons/x16/shapes/circleGreen.png");
|
||||
static BImage statusNeedsCompileIcon = BImage.make((String)"module://icons/x16/shapes/circleGold.png");
|
||||
static BImage statusErrorIcon = BImage.make((String)"module://icons/x16/shapes/circleRed.png");
|
||||
static BImage editIcon = BImage.make((String)"module://icons/x16/edit.png");
|
||||
static BImage slotsIcon = BImage.make((String)"module://icons/x16/page.png");
|
||||
static BImage importsIcon = BImage.make((String)"module://icons/x16/module.png");
|
||||
static BImage sourceIcon = BImage.make((String)"module://icons/x16/script.png");
|
||||
static BImage addIcon = BImage.make((String)"module://icons/x16/add.png");
|
||||
static BImage removeIcon = BImage.make((String)"module://icons/x16/delete.png");
|
||||
static final String boilerPlate = "public void onStart() throws Exception\n{\n // start up code here\n}\n\npublic void onExecute() throws Exception\n{\n // execute code (set executeOnChange flag on inputs)\n}\n\npublic void onStop() throws Exception\n{\n // shutdown code here\n}\n\n";
|
||||
ProgramEditorCommands commands = new ProgramEditorCommands(this);
|
||||
ProgramCompiler compiler = new ProgramCompiler(this);
|
||||
int sourceLine;
|
||||
BProgram program;
|
||||
BProgramCode code;
|
||||
BTabbedPane tabs;
|
||||
boolean modified = false;
|
||||
BWidget statusPane;
|
||||
BLabel status;
|
||||
BWidget editTab;
|
||||
BTextEditor editText;
|
||||
BWidget slotTab;
|
||||
BSlotSheet slotSheet;
|
||||
Imports imports = new Imports(this);
|
||||
BWidget importsTab;
|
||||
BWidget sourceTab;
|
||||
BTextEditor sourceText;
|
||||
static /* synthetic */ Class class$com$tridium$program$ui$BProgramEditor;
|
||||
|
||||
public void codeTextModified() {
|
||||
this.invoke(codeTextModified, null, null);
|
||||
}
|
||||
|
||||
public void tabSelectionModified() {
|
||||
this.invoke(tabSelectionModified, null, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BProgramEditor() {
|
||||
this.autoRegisterForComponentEvents = false;
|
||||
this.setContent((BWidget)new BLabel("ProgramEditor"));
|
||||
this.initStatusPane();
|
||||
this.initEditPane();
|
||||
this.initSlotPane();
|
||||
this.initImportsPane();
|
||||
this.initSourcePane();
|
||||
this.tabs = new BTabbedPane();
|
||||
this.tabs.addPane(lex.getText("programEditor.edit"), editIcon, this.editTab);
|
||||
this.tabs.addPane(lex.getText("programEditor.slots"), slotsIcon, this.slotTab);
|
||||
this.tabs.addPane(lex.getText("programEditor.imports"), importsIcon, this.importsTab);
|
||||
this.tabs.addPane(lex.getText("programEditor.source"), sourceIcon, this.sourceTab);
|
||||
this.linkTo(null, (BComponent)this.editText, (Slot)BTextEditor.textModified, (Slot)codeTextModified);
|
||||
this.linkTo(null, (BComponent)this.tabs, (Slot)BTabbedPane.selectionModified, (Slot)tabSelectionModified);
|
||||
BEdgePane bEdgePane = new BEdgePane();
|
||||
bEdgePane.setTop(this.statusPane);
|
||||
bEdgePane.setCenter((BWidget)this.tabs);
|
||||
this.setContent((BWidget)bEdgePane);
|
||||
}
|
||||
|
||||
private void initStatusPane() {
|
||||
this.status = new BLabel("status not initialized");
|
||||
this.status.setHalign(BHalign.left);
|
||||
this.statusPane = new BBorderPane((BWidget)this.status, 5.0, 0.0, 10.0, 0.0);
|
||||
}
|
||||
|
||||
private void initEditPane() {
|
||||
this.editText = new BTextEditor();
|
||||
this.editText.setParser((TextParser)new JavaParser());
|
||||
BTextEditorPane bTextEditorPane = new BTextEditorPane(this.editText);
|
||||
this.editTab = bTextEditorPane;
|
||||
}
|
||||
|
||||
private void initSlotPane() {
|
||||
this.slotSheet = new BSlotSheet();
|
||||
this.slotTab = this.slotSheet;
|
||||
}
|
||||
|
||||
private void initImportsPane() {
|
||||
BGridPane bGridPane = new BGridPane(3);
|
||||
bGridPane.add(null, (BValue)new BButton(this.commands.importType));
|
||||
bGridPane.add(null, (BValue)new BButton(this.commands.importPackage));
|
||||
bGridPane.add(null, (BValue)new BButton(this.commands.removeImport));
|
||||
bGridPane.setUniformColumnWidth(true);
|
||||
bGridPane.setColumnAlign(BHalign.fill);
|
||||
BEdgePane bEdgePane = new BEdgePane();
|
||||
bEdgePane.setCenter((BWidget)this.imports.table);
|
||||
bEdgePane.setBottom((BWidget)new BBorderPane((BWidget)bGridPane));
|
||||
this.importsTab = bEdgePane;
|
||||
}
|
||||
|
||||
private void initSourcePane() {
|
||||
this.sourceText = new BTextEditor();
|
||||
this.sourceText.setEditable(false);
|
||||
this.sourceText.setParser((TextParser)new JavaParser());
|
||||
BTextEditorPane bTextEditorPane = new BTextEditorPane(this.sourceText);
|
||||
this.sourceTab = bTextEditorPane;
|
||||
}
|
||||
|
||||
public BMenu[] getViewMenus() {
|
||||
return this.commands.getViewMenus();
|
||||
}
|
||||
|
||||
public BToolBar getViewToolBar() {
|
||||
return this.commands.getViewToolBar();
|
||||
}
|
||||
|
||||
public void doLoadValue(BObject bObject, Context context) {
|
||||
this.program = (BProgram)bObject;
|
||||
this.registerForComponentEvents(this.program, 1);
|
||||
this.code = (BProgramCode)this.program.getCode().newCopy();
|
||||
this.loadCode();
|
||||
this.imports.load(this.code);
|
||||
this.slotSheet.doLoadValue((BObject)this.program, context);
|
||||
this.updateStatus();
|
||||
this.tabs.selectPane(this.editTab);
|
||||
}
|
||||
|
||||
public BObject doSaveValue(BObject bObject, Context context) throws Exception {
|
||||
this.saveCode();
|
||||
this.imports.save(this.code);
|
||||
this.program.setCode(this.code);
|
||||
this.program.updateActionParameters();
|
||||
this.modified = false;
|
||||
this.updateStatus();
|
||||
return this.program;
|
||||
}
|
||||
|
||||
public CommandArtifact invokeCommand(int n) throws Exception {
|
||||
BTextEditor bTextEditor = this.getActiveTextEditor();
|
||||
if (bTextEditor == null) {
|
||||
return null;
|
||||
}
|
||||
switch (n) {
|
||||
case 6: {
|
||||
return bTextEditor.doFind();
|
||||
}
|
||||
case 8: {
|
||||
return bTextEditor.doFindNext();
|
||||
}
|
||||
case 7: {
|
||||
return bTextEditor.doFindPrev();
|
||||
}
|
||||
case 9: {
|
||||
return bTextEditor.doReplace();
|
||||
}
|
||||
case 10: {
|
||||
return bTextEditor.doGoto();
|
||||
}
|
||||
}
|
||||
return super.invokeCommand(n);
|
||||
}
|
||||
|
||||
public BTextEditor getActiveTextEditor() {
|
||||
BWidget bWidget = this.tabs.getSelectedPane();
|
||||
if (bWidget == this.editTab) {
|
||||
return this.editText;
|
||||
}
|
||||
if (bWidget == this.sourceTab) {
|
||||
return this.sourceText;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void updateEditorCommands() {
|
||||
BTextEditor bTextEditor = this.getActiveTextEditor();
|
||||
if (bTextEditor != null) {
|
||||
bTextEditor.updateEnableStates();
|
||||
}
|
||||
this.setTransferWidget((BTransferWidget)bTextEditor);
|
||||
boolean bl = bTextEditor != null;
|
||||
this.setCommandEnabled(6, bl);
|
||||
this.setCommandEnabled(8, bl);
|
||||
this.setCommandEnabled(7, bl);
|
||||
this.setCommandEnabled(9, bl && bTextEditor.isEditable());
|
||||
this.setCommandEnabled(10, bl);
|
||||
}
|
||||
|
||||
public boolean consoleHyperlink(File file, int n, int n2, int n3, int n4) {
|
||||
if (!file.equals(this.compiler.java)) {
|
||||
BOrd bOrd = BOrd.make((String)SlotPath.unescape((String)file.getName()));
|
||||
BObject bObject = bOrd.get();
|
||||
if (bObject instanceof BProgramModule || bObject instanceof BProgram) {
|
||||
((BNiagaraWbShell)this.getWbShell()).hyperlink(bOrd);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
this.highlight(n, n2, n3, n4);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void highlight(int n, int n2, int n3, int n4) {
|
||||
this.tabs.selectPane(this.editTab);
|
||||
this.highlight(this.editText, n -= this.sourceLine, n2 -= 2, n3 -= this.sourceLine, n4 -= 2);
|
||||
}
|
||||
|
||||
void highlight(BTextEditor bTextEditor, int n, int n2, int n3, int n4) {
|
||||
Position position = bTextEditor.getModel().getEndPosition();
|
||||
Position position2 = new Position(n - 1, n2 - 1);
|
||||
Position position3 = new Position(n3 - 1, n4);
|
||||
if (position2.compareTo((Object)position) > 0) {
|
||||
position2 = position;
|
||||
}
|
||||
if (position3.compareTo((Object)position) > 0) {
|
||||
position3 = position;
|
||||
}
|
||||
bTextEditor.getSelection().select(position2, position3);
|
||||
bTextEditor.moveCaretPosition(position3);
|
||||
bTextEditor.requestFocus();
|
||||
}
|
||||
|
||||
public void updateStatus() {
|
||||
if (this.modified || this.computeChecksum(this.editText.getText()) != this.program.getCode().getChecksum()) {
|
||||
this.status.setText(statusNeedsCompile);
|
||||
this.status.setImage(statusNeedsCompileIcon);
|
||||
} else {
|
||||
this.status.setText(statusOk);
|
||||
this.status.setImage(statusOkIcon);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateProgramCode() {
|
||||
this.program.setCode(this.code);
|
||||
}
|
||||
|
||||
public void updateStatusToError() {
|
||||
this.status.setText(statusError);
|
||||
this.status.setImage(statusErrorIcon);
|
||||
}
|
||||
|
||||
public void updateSource() {
|
||||
char[] cArray = SourceWriter.generateToCharArray(this, "ProgramImpl");
|
||||
this.sourceText.getModel().read(cArray);
|
||||
}
|
||||
|
||||
public void saveCode() {
|
||||
String string = this.editText.getText();
|
||||
this.code.setSource(string);
|
||||
this.imports.updateImports();
|
||||
}
|
||||
|
||||
public void loadCode() {
|
||||
String string = this.code.getSource();
|
||||
if (string.length() == 0) {
|
||||
string = boilerPlate;
|
||||
}
|
||||
this.editText.setText(string);
|
||||
}
|
||||
|
||||
public int computeChecksum(String string) {
|
||||
int n = string.hashCode();
|
||||
Property[] propertyArray = this.program.getPropertiesArray();
|
||||
for (int i = 0; i < propertyArray.length; ++i) {
|
||||
Property property = propertyArray[i];
|
||||
if (property.isFrozen()) continue;
|
||||
n ^= property.getName().hashCode();
|
||||
n ^= property.getType().getTypeName().hashCode();
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
public void doCodeTextModified() {
|
||||
if (!this.isModifiedStateLocked()) {
|
||||
this.setModified();
|
||||
this.modified = true;
|
||||
this.updateStatus();
|
||||
}
|
||||
}
|
||||
|
||||
public void doTabSelectionModified() {
|
||||
this.updateEditorCommands();
|
||||
this.saveCode();
|
||||
this.updateSource();
|
||||
}
|
||||
|
||||
public void handleComponentEvent(BComponentEvent bComponentEvent) {
|
||||
this.slotSheet.handleComponentEvent(bComponentEvent);
|
||||
this.imports.updateImports();
|
||||
switch (bComponentEvent.getId()) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3: {
|
||||
this.updateStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,622 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.ui.theme.Theme
|
||||
* com.tridium.workbench.console.BConsole
|
||||
* com.tridium.workbench.transfer.TransferUtil
|
||||
* javax.baja.gx.BFont
|
||||
* javax.baja.gx.BImage
|
||||
* javax.baja.gx.BInsets
|
||||
* javax.baja.gx.Graphics
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.ViewQuery
|
||||
* javax.baja.nre.util.SortUtil
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BComponentEvent
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BIcon
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.BVector
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Slot
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BNullWidget
|
||||
* javax.baja.ui.BProgressDialog
|
||||
* javax.baja.ui.BProgressDialog$Worker
|
||||
* javax.baja.ui.BToolBar
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.CommandArtifact
|
||||
* javax.baja.ui.enums.BOrientation
|
||||
* javax.baja.ui.enums.BScrollBarPolicy
|
||||
* javax.baja.ui.event.BMouseEvent
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BEdgePane
|
||||
* javax.baja.ui.pane.BExpandablePane
|
||||
* javax.baja.ui.pane.BScrollPane
|
||||
* javax.baja.ui.pane.BSplitPane
|
||||
* javax.baja.ui.table.BTable
|
||||
* javax.baja.ui.table.TableCellRenderer
|
||||
* javax.baja.ui.table.TableCellRenderer$Cell
|
||||
* javax.baja.ui.table.TableModel
|
||||
* javax.baja.ui.transfer.TransferContext
|
||||
* javax.baja.util.BFolder
|
||||
* javax.baja.util.BNameMap
|
||||
* javax.baja.util.Lexicon
|
||||
* javax.baja.workbench.BWbShell
|
||||
* javax.baja.workbench.CannotSaveException
|
||||
* javax.baja.workbench.component.table.BComponentTable
|
||||
* javax.baja.workbench.component.table.ComponentTableCellRenderer
|
||||
* javax.baja.workbench.mgr.BAbstractManager
|
||||
* javax.baja.workbench.mgr.BMgrTable
|
||||
* javax.baja.workbench.mgr.MgrColumn
|
||||
* javax.baja.workbench.mgr.MgrColumn$Name
|
||||
* javax.baja.workbench.mgr.MgrController
|
||||
* javax.baja.workbench.mgr.MgrController$IMgrCommand
|
||||
* javax.baja.workbench.mgr.MgrController$MgrCommand
|
||||
* javax.baja.workbench.mgr.MgrModel
|
||||
* javax.baja.workbench.mgr.folder.BFolderManager
|
||||
* javax.baja.workbench.mgr.folder.FolderController
|
||||
* javax.baja.workbench.mgr.folder.FolderModel
|
||||
*/
|
||||
package com.tridium.program.ui;
|
||||
|
||||
import com.tridium.program.BCode;
|
||||
import com.tridium.program.BProgram;
|
||||
import com.tridium.program.module.BProgramModule;
|
||||
import com.tridium.program.module.IBuildListener;
|
||||
import com.tridium.program.module.ValidateModel;
|
||||
import com.tridium.program.ui.BBuilderTable;
|
||||
import com.tridium.program.ui.BFieldSheet;
|
||||
import com.tridium.program.ui.BProgramEditor;
|
||||
import com.tridium.program.ui.Compiler;
|
||||
import com.tridium.program.ui.SourceWriter;
|
||||
import com.tridium.ui.theme.Theme;
|
||||
import com.tridium.workbench.console.BConsole;
|
||||
import com.tridium.workbench.transfer.TransferUtil;
|
||||
import java.io.FileWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import javax.baja.gx.BFont;
|
||||
import javax.baja.gx.BImage;
|
||||
import javax.baja.gx.BInsets;
|
||||
import javax.baja.gx.Graphics;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.ViewQuery;
|
||||
import javax.baja.nre.util.SortUtil;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BComponentEvent;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BIcon;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.BVector;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Slot;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BDialog;
|
||||
import javax.baja.ui.BLabel;
|
||||
import javax.baja.ui.BNullWidget;
|
||||
import javax.baja.ui.BProgressDialog;
|
||||
import javax.baja.ui.BToolBar;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.CommandArtifact;
|
||||
import javax.baja.ui.enums.BOrientation;
|
||||
import javax.baja.ui.enums.BScrollBarPolicy;
|
||||
import javax.baja.ui.event.BMouseEvent;
|
||||
import javax.baja.ui.pane.BBorderPane;
|
||||
import javax.baja.ui.pane.BEdgePane;
|
||||
import javax.baja.ui.pane.BExpandablePane;
|
||||
import javax.baja.ui.pane.BScrollPane;
|
||||
import javax.baja.ui.pane.BSplitPane;
|
||||
import javax.baja.ui.table.BTable;
|
||||
import javax.baja.ui.table.TableCellRenderer;
|
||||
import javax.baja.ui.table.TableModel;
|
||||
import javax.baja.ui.transfer.TransferContext;
|
||||
import javax.baja.util.BFolder;
|
||||
import javax.baja.util.BNameMap;
|
||||
import javax.baja.util.Lexicon;
|
||||
import javax.baja.workbench.BWbShell;
|
||||
import javax.baja.workbench.CannotSaveException;
|
||||
import javax.baja.workbench.component.table.BComponentTable;
|
||||
import javax.baja.workbench.component.table.ComponentTableCellRenderer;
|
||||
import javax.baja.workbench.mgr.BAbstractManager;
|
||||
import javax.baja.workbench.mgr.BMgrTable;
|
||||
import javax.baja.workbench.mgr.MgrColumn;
|
||||
import javax.baja.workbench.mgr.MgrController;
|
||||
import javax.baja.workbench.mgr.MgrModel;
|
||||
import javax.baja.workbench.mgr.folder.BFolderManager;
|
||||
import javax.baja.workbench.mgr.folder.FolderController;
|
||||
import javax.baja.workbench.mgr.folder.FolderModel;
|
||||
|
||||
public class BProgramModuleBuilder
|
||||
extends BFolderManager {
|
||||
public static final Action handleSelection = BProgramModuleBuilder.newAction((int)4, null);
|
||||
public static final Action handleModified = BProgramModuleBuilder.newAction((int)4, null);
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$BProgramModuleBuilder == null ? (class$com$tridium$program$ui$BProgramModuleBuilder = BProgramModuleBuilder.class$("com.tridium.program.ui.BProgramModuleBuilder")) : class$com$tridium$program$ui$BProgramModuleBuilder));
|
||||
Lexicon lex = Lexicon.make((Class)(class$com$tridium$program$ui$BProgramModuleBuilder == null ? (class$com$tridium$program$ui$BProgramModuleBuilder = BProgramModuleBuilder.class$("com.tridium.program.ui.BProgramModuleBuilder")) : class$com$tridium$program$ui$BProgramModuleBuilder));
|
||||
static final BImage CHECK = BImage.make((BIcon)BIcon.std((String)"check.png"));
|
||||
static final BImage BLANK = BImage.make((BIcon)BIcon.std((String)"blank.png"));
|
||||
BProgramModule module;
|
||||
BSplitPane split;
|
||||
BFieldSheet sheet = new BFieldSheet();
|
||||
HashMap verify;
|
||||
static /* synthetic */ Class class$com$tridium$program$ui$BProgramModuleBuilder;
|
||||
|
||||
public void handleSelection() {
|
||||
this.invoke(handleSelection, null, null);
|
||||
}
|
||||
|
||||
public void handleModified() {
|
||||
this.invoke(handleModified, null, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public void doLoadValue(BObject bObject, Context context) {
|
||||
this.module = (BProgramModule)bObject;
|
||||
this.verify = new HashMap();
|
||||
this.verify.put(this.module, ValidateModel.make(this.module));
|
||||
super.doLoadValue(bObject, context);
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
super.init();
|
||||
ViewQuery viewQuery = this.getWbShell().getActiveOrdTarget().getViewQuery();
|
||||
if (viewQuery != null) {
|
||||
try {
|
||||
String string = viewQuery.getParameter("program");
|
||||
int n = ((BBuilderTable)this.getModel().getTable()).getRowOfProgram(string);
|
||||
this.getModel().getTable().getSelection().select(n);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
// empty catch block
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleComponentEvent(BComponentEvent bComponentEvent) {
|
||||
super.handleComponentEvent(bComponentEvent);
|
||||
BComponent bComponent = bComponentEvent.getSourceComponent();
|
||||
BValue bValue = bComponentEvent.getValue();
|
||||
if (bComponent == this.module) {
|
||||
this.verify.put(this.module, ValidateModel.make(this.module));
|
||||
} else if (bComponentEvent.getId() == 3) {
|
||||
this.verify.put(this.getSelectedProgram(), ValidateModel.make(this.getSelectedProgram()));
|
||||
this.handleSelection();
|
||||
} else if (bValue instanceof BProgram) {
|
||||
switch (bComponentEvent.getId()) {
|
||||
case 0:
|
||||
case 1: {
|
||||
this.verify.put(bValue, ValidateModel.make((BProgram)bValue));
|
||||
this.handleSelection();
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
if (bValue == this.getSelectedProgram()) {
|
||||
this.getModel().getTable().getSelection().deselectAll();
|
||||
}
|
||||
this.verify.remove(bValue);
|
||||
}
|
||||
}
|
||||
this.verify.put(this.module, ValidateModel.make(this.module));
|
||||
}
|
||||
super.handleComponentEvent(bComponentEvent);
|
||||
}
|
||||
|
||||
protected BObject doSaveValue(BObject bObject, Context context) throws CannotSaveException, Exception {
|
||||
try {
|
||||
this.sheet.saveValue((BObject)this.module, context);
|
||||
this.verify.put(this.module, ValidateModel.make(this.module));
|
||||
}
|
||||
catch (Exception exception) {
|
||||
((ValidateModel)((Object)this.verify.get((Object)this.module))).err(exception.getMessage());
|
||||
throw exception;
|
||||
}
|
||||
finally {
|
||||
this.getModel().getTable().getSelection().select(-1);
|
||||
}
|
||||
return this.module;
|
||||
}
|
||||
|
||||
public void doHandleModified() {
|
||||
if (this.sheet.isModified()) {
|
||||
this.getController().updateCommands();
|
||||
}
|
||||
}
|
||||
|
||||
protected MgrModel makeModel() {
|
||||
return new BuilderModel(this);
|
||||
}
|
||||
|
||||
protected MgrController makeController() {
|
||||
return new Controller(this);
|
||||
}
|
||||
|
||||
public void doHandleSelection() {
|
||||
ValidateModel validateModel = (ValidateModel)((Object)this.verify.get((Object)this.module));
|
||||
BProgram bProgram = this.getSelectedProgram();
|
||||
if (bProgram != null) {
|
||||
validateModel = (ValidateModel)((Object)this.verify.get((Object)bProgram));
|
||||
}
|
||||
if (validateModel.getTable() != null) {
|
||||
validateModel.setTable(null);
|
||||
}
|
||||
this.split.setWidget2((BWidget)new BTable((TableModel)validateModel));
|
||||
if (this.split.getDividerPosition() > 75.0) {
|
||||
this.split.setDividerPosition(75.0);
|
||||
this.split.relayout();
|
||||
}
|
||||
}
|
||||
|
||||
private BProgram getSelectedProgram() {
|
||||
return (BProgram)this.getModel().getTable().getSelectedComponent();
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
class BuilderModel
|
||||
extends FolderModel {
|
||||
MgrColumn colProgramName = new ProgName(1);
|
||||
MgrColumn colComp = new CompName();
|
||||
MgrColumn[] columns = new MgrColumn[]{this.colProgramName, this.colComp};
|
||||
|
||||
public BuilderModel(BFolderManager bFolderManager) {
|
||||
super(bFolderManager);
|
||||
}
|
||||
|
||||
protected BMgrTable makeTable() {
|
||||
BBuilderTable bBuilderTable = new BBuilderTable((MgrModel)this);
|
||||
BProgramModuleBuilder.this.linkTo((BComponent)bBuilderTable, (Slot)BTable.selectionModified, (Slot)handleSelection);
|
||||
return bBuilderTable;
|
||||
}
|
||||
|
||||
public Type getFolderType() {
|
||||
return BFolder.TYPE;
|
||||
}
|
||||
|
||||
public Type[] getIncludeTypes() {
|
||||
return new Type[]{BProgram.TYPE};
|
||||
}
|
||||
|
||||
public boolean accept(BComponent bComponent) {
|
||||
if (bComponent.getParent().equals((Object)BProgramModuleBuilder.this.module.getPrograms())) {
|
||||
BProgramModuleBuilder.this.verify.put(bComponent, ValidateModel.make((BProgram)bComponent));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getSubscribeDepth() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
protected String makeTableTitle() {
|
||||
return BProgramModuleBuilder.this.lex.getText("modBuilder.title");
|
||||
}
|
||||
|
||||
public BWidget makePane() {
|
||||
BProgramModuleBuilder.this.sheet = new BFieldSheet();
|
||||
BProgramModuleBuilder.this.sheet.loadValue((BObject)BProgramModuleBuilder.this.module, BProgramModuleBuilder.this.getCurrentContext());
|
||||
BProgramModuleBuilder.this.linkTo((BComponent)BProgramModuleBuilder.this.sheet, (Slot)BFieldSheet.pluginModified, (Slot)BAbstractManager.setModified);
|
||||
BProgramModuleBuilder.this.linkTo((BComponent)BProgramModuleBuilder.this.sheet, (Slot)BFieldSheet.pluginModified, (Slot)handleModified);
|
||||
BExpandablePane bExpandablePane = new BExpandablePane();
|
||||
BEdgePane bEdgePane = new BEdgePane();
|
||||
bEdgePane.setCenter((BWidget)BProgramModuleBuilder.this.sheet);
|
||||
bExpandablePane.setSummary((BWidget)new BLabel(BProgramModuleBuilder.this.lex.getText("modBuilder.settings")));
|
||||
bExpandablePane.setExpansion((BWidget)new BBorderPane((BWidget)bEdgePane, 0.0, 0.0, 5.0, 0.0));
|
||||
bExpandablePane.setExpanded(true);
|
||||
BWidget bWidget = super.makePane();
|
||||
BProgramModuleBuilder.this.split = new BSplitPane(BOrientation.vertical, 75.0);
|
||||
BProgramModuleBuilder.this.split.setWidget1(bWidget);
|
||||
BProgramModuleBuilder.this.split.setWidget2((BWidget)new BNullWidget());
|
||||
BEdgePane bEdgePane2 = new BEdgePane();
|
||||
bEdgePane2.setTop((BWidget)bExpandablePane);
|
||||
bEdgePane2.setCenter((BWidget)BProgramModuleBuilder.this.split);
|
||||
return bEdgePane2;
|
||||
}
|
||||
|
||||
protected MgrColumn[] makeColumns() {
|
||||
return this.columns;
|
||||
}
|
||||
|
||||
protected class CompName
|
||||
extends MgrColumn {
|
||||
public CompName() {
|
||||
super("BComponent Name", 6);
|
||||
}
|
||||
|
||||
public Object get(Object object) {
|
||||
return BProgramModule.toComponentName((BProgram)((Object)object));
|
||||
}
|
||||
}
|
||||
|
||||
protected class ProgName
|
||||
extends MgrColumn.Name {
|
||||
private CellRenderer rend = new CellRenderer();
|
||||
|
||||
public ProgName(int n) {
|
||||
super(n);
|
||||
}
|
||||
|
||||
public TableCellRenderer getCellRenderer() {
|
||||
return this.rend;
|
||||
}
|
||||
|
||||
private class CellRenderer
|
||||
extends ComponentTableCellRenderer {
|
||||
private CellRenderer() {
|
||||
}
|
||||
|
||||
public double getPreferredCellWidth(TableCellRenderer.Cell cell) {
|
||||
return 20.0 + this.getFont(cell).width("VeryLongBProgramNameExample");
|
||||
}
|
||||
|
||||
public void paintCell(Graphics graphics, TableCellRenderer.Cell cell) {
|
||||
this.paintCellBackground(graphics, cell);
|
||||
double d = 2.0;
|
||||
double d2 = (cell.height - 16.0) / 2.0;
|
||||
ValidateModel validateModel = (ValidateModel)((Object)((BuilderModel)((ProgName)ProgName.this).BuilderModel.this).BProgramModuleBuilder.this.verify.get(this.getComponentTable().getComponentAt(cell.row)));
|
||||
graphics.drawImage(validateModel.getProgramStatusIcon(), d, d2);
|
||||
String string = (String)cell.value;
|
||||
BFont bFont = this.getFont(cell);
|
||||
graphics.setFont(bFont);
|
||||
graphics.drawString(string, d += 20.0, (cell.height + bFont.getAscent() - bFont.getDescent()) / 2.0);
|
||||
}
|
||||
|
||||
protected BComponentTable getComponentTable() {
|
||||
return ProgName.this.getManager().getModel().getTable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Controller
|
||||
extends FolderController {
|
||||
CompileCommand compileCmd;
|
||||
BuildCommand buildCmd;
|
||||
EditDepends dependsCmd;
|
||||
|
||||
public Controller(BFolderManager bFolderManager) {
|
||||
super(bFolderManager);
|
||||
this.compileCmd = new CompileCommand((BWidget)bFolderManager);
|
||||
this.buildCmd = new BuildCommand((BWidget)bFolderManager);
|
||||
this.dependsCmd = new EditDepends((BWidget)bFolderManager);
|
||||
}
|
||||
|
||||
protected MgrController.IMgrCommand[] makeCommands() {
|
||||
this.allDescendants.setSelected(true);
|
||||
return new MgrController.IMgrCommand[]{this.edit, this.compileCmd, this.buildCmd, this.dependsCmd};
|
||||
}
|
||||
|
||||
public void cellDoubleClicked(BMgrTable bMgrTable, BMouseEvent bMouseEvent, int n, int n2) {
|
||||
BProgram bProgram = (BProgram)bMgrTable.getComponentAt(n);
|
||||
BWbShell bWbShell = bMgrTable.getManager().getWbShell();
|
||||
bWbShell.hyperlink(BOrd.make((BOrd)bProgram.getNavOrd(), (String)"view:program:ProgramEditor"));
|
||||
}
|
||||
|
||||
public BToolBar makeToolBar() {
|
||||
return super.makeToolBar();
|
||||
}
|
||||
|
||||
public void updateCommands() {
|
||||
super.updateCommands();
|
||||
boolean bl = true;
|
||||
Iterator iterator = BProgramModuleBuilder.this.verify.values().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (((ValidateModel)((Object)iterator.next())).getErrCount() <= 0) continue;
|
||||
bl = false;
|
||||
break;
|
||||
}
|
||||
if (BProgramModuleBuilder.this.sheet != null && BProgramModuleBuilder.this.sheet.isModified()) {
|
||||
bl = false;
|
||||
}
|
||||
this.buildCmd.setEnabled(bl);
|
||||
this.dependsCmd.setEnabled(bl);
|
||||
this.compileCmd.setEnabled(!bl && !BProgramModuleBuilder.this.sheet.isModified());
|
||||
}
|
||||
|
||||
public CommandArtifact drop(BMgrTable bMgrTable, TransferContext transferContext) throws Exception {
|
||||
return TransferUtil.insert((BWidget)BProgramModuleBuilder.this, (TransferContext)transferContext, (BObject)BProgramModuleBuilder.this.module.getPrograms(), null);
|
||||
}
|
||||
|
||||
protected class EditDepends
|
||||
extends MgrController.MgrCommand {
|
||||
public EditDepends(BWidget bWidget) {
|
||||
super(bWidget, ((Controller)Controller.this).BProgramModuleBuilder.this.lex, "modBuilder.cmd.editDepends");
|
||||
this.setFlags(3);
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() throws Exception {
|
||||
BVector bVector = new BVector();
|
||||
BFieldSheet bFieldSheet = this.makeDependsSheet(bVector);
|
||||
BScrollPane bScrollPane = new BScrollPane((BWidget)new BBorderPane((BWidget)bFieldSheet, BInsets.make((double)10.0)));
|
||||
bScrollPane.setVpolicy(BScrollBarPolicy.always);
|
||||
bScrollPane.setViewportBackground(Theme.widget().getControlBackground());
|
||||
while (true) {
|
||||
if (2 == BDialog.open((BWidget)BProgramModuleBuilder.this, (String)((Controller)Controller.this).BProgramModuleBuilder.this.lex.getText("modBuilder.cmd.editDepends.title"), (Object)bScrollPane, (int)3)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
bFieldSheet.saveValue((BObject)bVector, null);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BDialog.error((BWidget)BProgramModuleBuilder.this, (String)"Error", (Object)exception.getMessage(), (Throwable)exception);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
BNameMap bNameMap = BNameMap.DEFAULT;
|
||||
Property[] propertyArray = bVector.getPropertiesArray();
|
||||
for (int i = 0; i < propertyArray.length; ++i) {
|
||||
String string = propertyArray[i].getName();
|
||||
String string2 = bVector.getString(propertyArray[i]);
|
||||
bNameMap = BNameMap.make((BNameMap)bNameMap, (String)string, (String)string2);
|
||||
}
|
||||
((Controller)Controller.this).BProgramModuleBuilder.this.module.setDependencies(bNameMap);
|
||||
return null;
|
||||
}
|
||||
|
||||
private BFieldSheet makeDependsSheet(BVector bVector) {
|
||||
BFieldSheet bFieldSheet = new BFieldSheet(true);
|
||||
BFacets bFacets = BFacets.make((String)"validator", (String)"baja:VersionValidator");
|
||||
bFacets = BFacets.make((BFacets)bFacets, (BFacets)BFacets.make((String)"fieldSheetShow", (boolean)true));
|
||||
bFacets = BFacets.make((BFacets)bFacets, (BFacets)BFacets.make((String)"iconOverride", (String)"module://icons/x16/module.png"));
|
||||
BNameMap bNameMap = BProgramModule.rationalizeDependecies(((Controller)Controller.this).BProgramModuleBuilder.this.module);
|
||||
Object[] objectArray = bNameMap.list();
|
||||
SortUtil.sort((Object[])objectArray);
|
||||
for (int i = 0; i < objectArray.length; ++i) {
|
||||
bVector.add((String)objectArray[i], (BValue)BString.make((String)bNameMap.get((String)objectArray[i]).getFormat()));
|
||||
bVector.setFacets(bVector.getSlot((String)objectArray[i]), bFacets);
|
||||
}
|
||||
bFieldSheet.loadValue((BObject)bVector);
|
||||
return bFieldSheet;
|
||||
}
|
||||
}
|
||||
|
||||
protected class BuildCommand
|
||||
extends MgrController.MgrCommand {
|
||||
public BuildCommand(BWidget bWidget) {
|
||||
super(bWidget, ((Controller)Controller.this).BProgramModuleBuilder.this.lex, "modBuilder.cmd.build");
|
||||
this.setFlags(7);
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() throws Exception {
|
||||
BProgramModuleBuilder.this.saveValue();
|
||||
BProgressDialog.open((BWidget)this.getOwner(), (String)((Controller)Controller.this).BProgramModuleBuilder.this.lex.getText("modBuilder.cmd.build.title"), (BProgressDialog.Worker)new BuildWorker());
|
||||
return null;
|
||||
}
|
||||
|
||||
class BuildWorker
|
||||
extends BProgressDialog.Worker
|
||||
implements IBuildListener {
|
||||
int curStep = 0;
|
||||
|
||||
BuildWorker() {
|
||||
}
|
||||
|
||||
public void setNumBuildSteps(int n) {
|
||||
this.getDialog().getProgressBar().setMax((double)n);
|
||||
}
|
||||
|
||||
public void nextStep(String string) {
|
||||
this.getDialog().getProgressBar().setValue((double)(++this.curStep));
|
||||
this.updateDesc(string);
|
||||
}
|
||||
|
||||
public void updateDesc(String string) {
|
||||
this.getDialog().getMessageLabel().setText(string);
|
||||
}
|
||||
|
||||
public BWidget getOwner() {
|
||||
return BProgramModuleBuilder.this;
|
||||
}
|
||||
|
||||
public void doCancel() throws Exception {
|
||||
}
|
||||
|
||||
public void doRun() throws Exception {
|
||||
try {
|
||||
((Controller)((BuildCommand)BuildCommand.this).Controller.this).BProgramModuleBuilder.this.module.buildModule(this);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BDialog.error((BWidget)this.getDialog(), (String)((Controller)((BuildCommand)BuildCommand.this).Controller.this).BProgramModuleBuilder.this.lex.getText("programModule.nbuild.fail"), (Object)exception.getMessage(), (Throwable)exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected class CompileCommand
|
||||
extends MgrController.MgrCommand {
|
||||
public CompileCommand(BWidget bWidget) {
|
||||
super(bWidget, ((Controller)Controller.this).BProgramModuleBuilder.this.lex, "modBuilder.cmd.compile");
|
||||
this.setFlags(7);
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() throws Exception {
|
||||
BProgram[] bProgramArray = ((Controller)Controller.this).BProgramModuleBuilder.this.module.listPrograms();
|
||||
for (int i = 0; i < bProgramArray.length; ++i) {
|
||||
if (((ValidateModel)((Object)((Controller)Controller.this).BProgramModuleBuilder.this.verify.get((Object)bProgramArray[i]))).getErrCount() == 0) continue;
|
||||
try {
|
||||
PCompiler pCompiler = new PCompiler(this.getOwner(), bProgramArray[i]);
|
||||
pCompiler.compile(BCode.generateClassName(), bProgramArray[i].getCode(), null);
|
||||
continue;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private class PCompiler
|
||||
extends Compiler {
|
||||
BProgram program;
|
||||
BProgramEditor pe;
|
||||
|
||||
public PCompiler(BWidget bWidget, BProgram bProgram) {
|
||||
super(bWidget);
|
||||
this.program = bProgram;
|
||||
this.pe = new BProgramEditor();
|
||||
this.pe.loadValue((BObject)bProgram);
|
||||
}
|
||||
|
||||
public void writeSource(FileWriter fileWriter, String string) throws Exception {
|
||||
SourceWriter sourceWriter = new SourceWriter((Writer)fileWriter, this.pe);
|
||||
sourceWriter.generate(this.className);
|
||||
}
|
||||
|
||||
public synchronized void compile(String string, BCode bCode, String string2) throws Exception {
|
||||
super.compile(string, bCode, string2);
|
||||
this.wait();
|
||||
}
|
||||
|
||||
public synchronized void consoleExecDone(BConsole bConsole, int n) {
|
||||
try {
|
||||
super.consoleExecDone(bConsole, n);
|
||||
}
|
||||
finally {
|
||||
this.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
public void compileFailed(BConsole bConsole) throws Exception {
|
||||
bConsole.cls();
|
||||
((ValidateModel)((Object)((Controller)((CompileCommand)CompileCommand.this).Controller.this).BProgramModuleBuilder.this.verify.get((Object)this.program))).err(((Controller)((CompileCommand)CompileCommand.this).Controller.this).BProgramModuleBuilder.this.lex.getText("vprogram.err.compile"));
|
||||
}
|
||||
|
||||
public void compileSuccess(BConsole bConsole) throws Exception {
|
||||
super.compileSuccess(bConsole);
|
||||
int n = this.program.getCode().getChecksum();
|
||||
int n2 = this.pe.computeChecksum(this.program.getCode().getSource());
|
||||
if (n != n2) {
|
||||
this.program.getCode().setChecksum(n2);
|
||||
BProgramModuleBuilder.this.handleComponentEvent(new BComponentEvent(0, (BComponent)((Controller)((CompileCommand)CompileCommand.this).Controller.this).BProgramModuleBuilder.this.module.getPrograms(), null, (BValue)this.program));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.workbench.console.BConsole
|
||||
* com.tridium.workbench.console.BConsole$HyperlinkInterceptor
|
||||
* javax.baja.nre.util.TextUtil
|
||||
* javax.baja.registry.DependencyInfo
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BMenu
|
||||
* javax.baja.ui.BToolBar
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.CommandArtifact
|
||||
* javax.baja.ui.pane.BTextEditorPane
|
||||
* javax.baja.ui.text.BTextEditor
|
||||
* javax.baja.ui.text.Position
|
||||
* javax.baja.ui.text.TextParser
|
||||
* javax.baja.ui.text.parsers.JavaParser
|
||||
* javax.baja.ui.transfer.BTransferWidget
|
||||
* javax.baja.ui.util.UiLexicon
|
||||
* javax.baja.workbench.view.BWbComponentView
|
||||
*/
|
||||
package com.tridium.program.ui;
|
||||
|
||||
import com.tridium.program.BCode;
|
||||
import com.tridium.program.BProgram;
|
||||
import com.tridium.program.BProgramService;
|
||||
import com.tridium.program.BRobotCode;
|
||||
import com.tridium.program.BRobotResult;
|
||||
import com.tridium.program.ui.Compiler;
|
||||
import com.tridium.program.ui.RobotEditorCommands;
|
||||
import com.tridium.workbench.console.BConsole;
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import javax.baja.nre.util.TextUtil;
|
||||
import javax.baja.registry.DependencyInfo;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BDialog;
|
||||
import javax.baja.ui.BMenu;
|
||||
import javax.baja.ui.BToolBar;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.CommandArtifact;
|
||||
import javax.baja.ui.pane.BTextEditorPane;
|
||||
import javax.baja.ui.text.BTextEditor;
|
||||
import javax.baja.ui.text.Position;
|
||||
import javax.baja.ui.text.TextParser;
|
||||
import javax.baja.ui.text.parsers.JavaParser;
|
||||
import javax.baja.ui.transfer.BTransferWidget;
|
||||
import javax.baja.ui.util.UiLexicon;
|
||||
import javax.baja.workbench.view.BWbComponentView;
|
||||
|
||||
public class BRobotEditor
|
||||
extends BWbComponentView
|
||||
implements BConsole.HyperlinkInterceptor {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$BRobotEditor == null ? (class$com$tridium$program$ui$BRobotEditor = BRobotEditor.class$("com.tridium.program.ui.BRobotEditor")) : class$com$tridium$program$ui$BRobotEditor));
|
||||
static String defaultDepends = "baja; program";
|
||||
static String defaultCode = "// depends: " + defaultDepends + "\n" + "\n" + "import javax.baja.sys.*;\n" + "import com.tridium.program.*;\n" + "\n" + "public class RobotImpl\n" + " extends Robot\n" + "{\n" + "\n" + " public void run()\n" + " throws Exception\n" + " {\n" + " process(Sys.getStation());\n" + " }\n" + "\n" + " public void process(BComponent c)\n" + " throws Exception\n" + " {\n" + " // do something here\n" + " log.println(c.toPathString() + \" [\" + c.getType() + \"]\");\n" + " \n" + " // recurse\n" + " BComponent[] kids = c.getChildComponents();\n" + " for(int i=0; i<kids.length; ++i)\n" + " process(kids[i]);\n" + " }\n" + "\n" + "}\n";
|
||||
static UiLexicon lex = UiLexicon.bajaui;
|
||||
RobotEditorCommands commands = new RobotEditorCommands(this);
|
||||
BProgramService service;
|
||||
BTextEditor editor;
|
||||
RobotCompiler compiler = new RobotCompiler(this);
|
||||
BRobotCode robotCode = new BRobotCode();
|
||||
static /* synthetic */ Class class$com$tridium$program$ui$BRobotEditor;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BRobotEditor() {
|
||||
this.editor = new BTextEditor();
|
||||
this.editor.setParser((TextParser)new JavaParser());
|
||||
this.editor.setText(defaultCode);
|
||||
this.setTransferWidget((BTransferWidget)this.editor);
|
||||
this.setCommandEnabled(6, true);
|
||||
this.setCommandEnabled(8, true);
|
||||
this.setCommandEnabled(7, true);
|
||||
this.setCommandEnabled(9, true);
|
||||
this.setCommandEnabled(10, true);
|
||||
BTextEditorPane bTextEditorPane = new BTextEditorPane(this.editor);
|
||||
this.setContent((BWidget)bTextEditorPane);
|
||||
}
|
||||
|
||||
public BMenu[] getViewMenus() {
|
||||
return this.commands.getViewMenus();
|
||||
}
|
||||
|
||||
public BToolBar getViewToolBar() {
|
||||
return this.commands.getViewToolBar();
|
||||
}
|
||||
|
||||
public void doLoadValue(BObject bObject, Context context) {
|
||||
this.service = (BProgramService)bObject;
|
||||
}
|
||||
|
||||
public void deactivated() {
|
||||
super.deactivated();
|
||||
defaultCode = this.editor.getText();
|
||||
}
|
||||
|
||||
public CommandArtifact invokeCommand(int n) throws Exception {
|
||||
switch (n) {
|
||||
case 6: {
|
||||
return this.editor.doFind();
|
||||
}
|
||||
case 8: {
|
||||
return this.editor.doFindNext();
|
||||
}
|
||||
case 7: {
|
||||
return this.editor.doFindPrev();
|
||||
}
|
||||
case 9: {
|
||||
return this.editor.doReplace();
|
||||
}
|
||||
case 10: {
|
||||
return this.editor.doGoto();
|
||||
}
|
||||
}
|
||||
return super.invokeCommand(n);
|
||||
}
|
||||
|
||||
public boolean consoleHyperlink(File file, int n, int n2, int n3, int n4) {
|
||||
if (!file.equals(this.compiler.java)) {
|
||||
return false;
|
||||
}
|
||||
this.highlight(n, n2, n3, n4);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void highlight(int n, int n2, int n3, int n4) {
|
||||
this.highlight(this.editor, n, n2, n3, n4);
|
||||
}
|
||||
|
||||
void highlight(BTextEditor bTextEditor, int n, int n2, int n3, int n4) {
|
||||
Position position = bTextEditor.getModel().getEndPosition();
|
||||
Position position2 = new Position(n - 1, n2 - 1);
|
||||
Position position3 = new Position(n3 - 1, n4);
|
||||
if (position2.compareTo((Object)position) > 0) {
|
||||
position2 = position;
|
||||
}
|
||||
if (position3.compareTo((Object)position) > 0) {
|
||||
position3 = position;
|
||||
}
|
||||
bTextEditor.getSelection().select(position2, position3);
|
||||
bTextEditor.moveCaretPosition(position3);
|
||||
bTextEditor.requestFocus();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
BRobotResult bRobotResult = this.service.runRobot(this.robotCode);
|
||||
BTextEditor bTextEditor = new BTextEditor(bRobotResult.getLog(), false);
|
||||
BTextEditorPane bTextEditorPane = new BTextEditorPane(bTextEditor, 20, 80);
|
||||
BDialog.open((BWidget)this, (String)"Log Output", (Object)bTextEditorPane, (int)1);
|
||||
}
|
||||
|
||||
public String parseDepends(String string) throws Exception {
|
||||
if (string.startsWith("// depends:")) {
|
||||
int n = string.indexOf(58);
|
||||
int n2 = string.indexOf(10);
|
||||
if (n >= 0 && n2 >= 0) {
|
||||
CharSequence charSequence;
|
||||
HashSet hashSet = new HashSet();
|
||||
StringTokenizer stringTokenizer = new StringTokenizer(string.trim().substring(n + 1, n2), ";");
|
||||
while (stringTokenizer.hasMoreTokens()) {
|
||||
charSequence = stringTokenizer.nextToken().trim();
|
||||
if (((String)charSequence).length() <= 0 || BProgram.isSpecialModule((String)charSequence)) continue;
|
||||
this.accumDepends(hashSet, (String)charSequence);
|
||||
}
|
||||
charSequence = new StringBuffer();
|
||||
Iterator iterator = hashSet.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (((StringBuffer)charSequence).length() > 0) {
|
||||
((StringBuffer)charSequence).append("; ");
|
||||
}
|
||||
((StringBuffer)charSequence).append(iterator.next().toString());
|
||||
}
|
||||
return ((StringBuffer)charSequence).toString();
|
||||
}
|
||||
}
|
||||
return defaultDepends;
|
||||
}
|
||||
|
||||
protected void accumDepends(Set set, String string) throws Exception {
|
||||
if (set.contains(string)) {
|
||||
return;
|
||||
}
|
||||
set.add(string);
|
||||
DependencyInfo[] dependencyInfoArray = Sys.getRegistry().getModule(string).getDependencies();
|
||||
for (int i = 0; i < dependencyInfoArray.length; ++i) {
|
||||
this.accumDepends(set, dependencyInfoArray[i].getModuleName());
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
class RobotCompiler
|
||||
extends Compiler {
|
||||
boolean runOnSuccess;
|
||||
|
||||
RobotCompiler(BRobotEditor bRobotEditor2) {
|
||||
super((BWidget)bRobotEditor2);
|
||||
}
|
||||
|
||||
public void compile(boolean bl) throws Exception {
|
||||
this.runOnSuccess = bl;
|
||||
String string = BRobotEditor.this.editor.getText();
|
||||
String string2 = BCode.generateClassName();
|
||||
int n = string.indexOf("RobotImpl");
|
||||
if (n < 0) {
|
||||
throw new Exception("Class name must be RobotImpl");
|
||||
}
|
||||
string = TextUtil.replace((String)string, (String)"RobotImpl", (String)string2);
|
||||
BRobotEditor.this.robotCode.setDependencies(BRobotEditor.this.parseDepends(string));
|
||||
this.compile(string2, BRobotEditor.this.robotCode, string);
|
||||
}
|
||||
|
||||
public void compileSuccess(BConsole bConsole) throws Exception {
|
||||
super.compileSuccess(bConsole);
|
||||
if (this.runOnSuccess) {
|
||||
BRobotEditor.this.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,293 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.nsh.NShell
|
||||
* com.tridium.workbench.console.BConsole
|
||||
* com.tridium.workbench.console.BConsole$ExecCallback
|
||||
* com.tridium.workbench.shell.BNiagaraWbShell
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.nre.util.Array
|
||||
* javax.baja.registry.DependencyInfo
|
||||
* javax.baja.sys.BBlob
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.workbench.BWbEditor
|
||||
*/
|
||||
package com.tridium.program.ui;
|
||||
|
||||
import com.tridium.nsh.NShell;
|
||||
import com.tridium.program.BCode;
|
||||
import com.tridium.program.BProgramService;
|
||||
import com.tridium.workbench.console.BConsole;
|
||||
import com.tridium.workbench.shell.BNiagaraWbShell;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.FilenameFilter;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.nre.util.Array;
|
||||
import javax.baja.registry.DependencyInfo;
|
||||
import javax.baja.sys.BBlob;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.workbench.BWbEditor;
|
||||
|
||||
public class Compiler
|
||||
implements BConsole.ExecCallback {
|
||||
BWidget owner;
|
||||
public String className;
|
||||
File temp;
|
||||
File java;
|
||||
File classFile;
|
||||
File[] innerClassFiles;
|
||||
BCode code;
|
||||
static /* synthetic */ Class class$java$io$File;
|
||||
static /* synthetic */ Class class$java$lang$String;
|
||||
static /* synthetic */ Class class$java$lang$Object;
|
||||
|
||||
public Compiler(BWidget bWidget) {
|
||||
this.owner = bWidget;
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public void compile(String string, BCode bCode, String string2) throws Exception {
|
||||
this.className = string;
|
||||
this.temp = new File(Sys.getBajaHome(), "temp");
|
||||
this.java = new File(this.temp, string + ".java");
|
||||
this.classFile = new File(this.temp, string + ".class");
|
||||
this.innerClassFiles = null;
|
||||
this.code = bCode;
|
||||
if (!this.temp.exists()) {
|
||||
this.temp.mkdirs();
|
||||
}
|
||||
FileWriter fileWriter = new FileWriter(this.java);
|
||||
try {
|
||||
this.writeSource(fileWriter, string2);
|
||||
}
|
||||
finally {
|
||||
fileWriter.close();
|
||||
}
|
||||
String string3 = Compiler.getDevkitTargetEdition(this.owner, null);
|
||||
String string4 = File.separator;
|
||||
String string5 = File.pathSeparator;
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
String string6 = Sys.getBajaHome() + string4 + "lib" + string4 + "editions" + string4 + (string3.startsWith("javac.") ? string3.substring(6) : string3) + string4;
|
||||
File file = new File(string6);
|
||||
String[] stringArray = file.list();
|
||||
if (stringArray != null) {
|
||||
for (int i = 0; i < stringArray.length; ++i) {
|
||||
stringBuffer.append(string6 + stringArray[i] + string5);
|
||||
}
|
||||
}
|
||||
File file2 = new File(Sys.getBajaHome(), "bin");
|
||||
String[] stringArray2 = file2.list(new JarFilenameFilter());
|
||||
String string7 = string5 + Sys.getBajaHome() + string4 + "bin" + string4;
|
||||
for (int i = 0; i < stringArray2.length; ++i) {
|
||||
stringBuffer.append(string7).append(stringArray2[i]).append(string5);
|
||||
}
|
||||
stringBuffer.append(Sys.getBajaHome() + string4 + "modules" + string4 + "baja.jar");
|
||||
String[] stringArray3 = this.parseDependencies(bCode);
|
||||
String string8 = string5 + Sys.getBajaHome() + string4 + "modules" + string4;
|
||||
for (int i = 0; i < stringArray3.length; ++i) {
|
||||
if (stringArray3[i].equals("baja")) continue;
|
||||
stringBuffer.append(string8).append(stringArray3[i]).append(".jar");
|
||||
}
|
||||
String string9 = null;
|
||||
try {
|
||||
string9 = Compiler.getCompileJavaCommand(string3, stringBuffer.toString(), this.temp.toString(), this.java.toString());
|
||||
}
|
||||
catch (Exception exception) {
|
||||
System.out.println("Problem loading '" + string3 + "' command from devkit.properties.");
|
||||
exception.printStackTrace();
|
||||
string9 = "jikes +E -classpath \"" + stringBuffer + "\" \"" + this.java + "\"";
|
||||
}
|
||||
this.exec(string9);
|
||||
}
|
||||
|
||||
protected String[] parseDependencies(BCode bCode) throws Exception {
|
||||
HashSet hashSet = new HashSet();
|
||||
String[] stringArray = bCode.parseDependencies();
|
||||
for (int i = 0; i < stringArray.length; ++i) {
|
||||
this.accumDependencies(hashSet, stringArray[i]);
|
||||
}
|
||||
return hashSet.toArray(new String[hashSet.size()]);
|
||||
}
|
||||
|
||||
protected void accumDependencies(Set set, String string) throws Exception {
|
||||
if (set.contains(string)) {
|
||||
return;
|
||||
}
|
||||
set.add(string);
|
||||
DependencyInfo[] dependencyInfoArray = Sys.getRegistry().getModule(string).getDependencies();
|
||||
for (int i = 0; i < dependencyInfoArray.length; ++i) {
|
||||
this.accumDependencies(set, dependencyInfoArray[i].getModuleName());
|
||||
}
|
||||
}
|
||||
|
||||
public void writeSource(FileWriter fileWriter, String string) throws Exception {
|
||||
fileWriter.write(string);
|
||||
}
|
||||
|
||||
public void exec(String string) throws Exception {
|
||||
if (this.owner != null) {
|
||||
this.openConsole().exec(string, (BConsole.ExecCallback)this);
|
||||
return;
|
||||
}
|
||||
NShell nShell = new NShell(System.out);
|
||||
nShell.exec(string);
|
||||
nShell.execWaitUntilDone();
|
||||
this.compileSuccess(null);
|
||||
this.cleanup();
|
||||
}
|
||||
|
||||
public BConsole openConsole() {
|
||||
return ((BNiagaraWbShell)this.owner.getShell()).openConsole();
|
||||
}
|
||||
|
||||
public void consoleExecDone(BConsole bConsole, int n) {
|
||||
try {
|
||||
if (n == 0) {
|
||||
this.compileSuccess(bConsole);
|
||||
} else {
|
||||
this.compileFailed(bConsole);
|
||||
}
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
this.cleanup();
|
||||
}
|
||||
|
||||
public void compileSuccess(BConsole bConsole) throws Exception {
|
||||
byte[] byArray = new byte[(int)this.classFile.length()];
|
||||
DataInputStream dataInputStream = new DataInputStream(new BufferedInputStream(new FileInputStream(this.classFile)));
|
||||
dataInputStream.readFully(byArray);
|
||||
dataInputStream.close();
|
||||
this.code.setClassName(this.className);
|
||||
this.code.setClassFile(BBlob.make((byte[])byArray));
|
||||
File[] fileArray = this.classFile.getParentFile().listFiles();
|
||||
this.code.clearInnerClassFiles();
|
||||
Array array = new Array(class$java$io$File == null ? (class$java$io$File = Compiler.class$("java.io.File")) : class$java$io$File);
|
||||
for (int i = 0; i < fileArray.length; ++i) {
|
||||
if (!fileArray[i].getName().startsWith(this.className + '$')) continue;
|
||||
array.add((Object)fileArray[i]);
|
||||
String string = fileArray[i].getName();
|
||||
string = string.substring(0, string.length() - 6);
|
||||
byArray = new byte[(int)fileArray[i].length()];
|
||||
dataInputStream = new DataInputStream(new BufferedInputStream(new FileInputStream(fileArray[i])));
|
||||
dataInputStream.readFully(byArray);
|
||||
dataInputStream.close();
|
||||
this.code.addInnerClassFile(string, BBlob.make((byte[])byArray));
|
||||
}
|
||||
this.innerClassFiles = (File[])array.trim();
|
||||
}
|
||||
|
||||
public void compileFailed(BConsole bConsole) throws Exception {
|
||||
bConsole.next();
|
||||
}
|
||||
|
||||
public void cleanup() {
|
||||
this.classFile.delete();
|
||||
if (this.innerClassFiles != null) {
|
||||
for (int i = 0; i < this.innerClassFiles.length; ++i) {
|
||||
this.innerClassFiles[i].delete();
|
||||
}
|
||||
}
|
||||
this.java.delete();
|
||||
}
|
||||
|
||||
public static String getDevkitTargetEdition(BWidget bWidget, String string) {
|
||||
try {
|
||||
if (bWidget instanceof BWbEditor) {
|
||||
BProgramService bProgramService = (BProgramService)BOrd.make((String)"service:program:ProgramService").resolve(((BWbEditor)bWidget).getCurrentValue()).get();
|
||||
bProgramService.lease();
|
||||
BValue bValue = bProgramService.get("devkitTargetEdition");
|
||||
if (bValue instanceof BString) {
|
||||
return bValue.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
// empty catch block
|
||||
}
|
||||
return string == null ? "javac.j2me" : string;
|
||||
}
|
||||
|
||||
public static String getCompileJavaCommand(String string, String string2, String string3, String string4) throws Exception {
|
||||
int n;
|
||||
if (!string4.startsWith("\"")) {
|
||||
string4 = "\"" + string4;
|
||||
}
|
||||
if (!string4.endsWith("\"")) {
|
||||
string4 = string4 + "\"";
|
||||
}
|
||||
Class<?> clazz = Class.forName("com.tridium.build.Env");
|
||||
Method method = clazz.getMethod("initEnv", class$java$lang$String == null ? (class$java$lang$String = Compiler.class$("java.lang.String")) : class$java$lang$String, class$java$lang$String == null ? (class$java$lang$String = Compiler.class$("java.lang.String")) : class$java$lang$String);
|
||||
method.invoke(null, null, "jar");
|
||||
Object object = clazz.getField("props").get(null);
|
||||
clazz = Class.forName("com.tridium.build.MacroProperties");
|
||||
method = clazz.getMethod("copy", null);
|
||||
object = method.invoke(object, null);
|
||||
method = clazz.getMethod("put", class$java$lang$Object == null ? (class$java$lang$Object = Compiler.class$("java.lang.Object")) : class$java$lang$Object, class$java$lang$Object == null ? (class$java$lang$Object = Compiler.class$("java.lang.Object")) : class$java$lang$Object);
|
||||
method.invoke(object, "javac.classpath", string2);
|
||||
method.invoke(object, "javac.out", string3);
|
||||
method.invoke(object, "javac.src", string4);
|
||||
Method method2 = clazz.getMethod("getProperty", class$java$lang$String == null ? (class$java$lang$String = Compiler.class$("java.lang.String")) : class$java$lang$String, class$java$lang$String == null ? (class$java$lang$String = Compiler.class$("java.lang.String")) : class$java$lang$String);
|
||||
if (((String)method2.invoke(object, "debug", "false")).equalsIgnoreCase("true")) {
|
||||
method.invoke(object, "javac.debug", "-g");
|
||||
} else {
|
||||
method.invoke(object, "javac.debug", "");
|
||||
}
|
||||
method = clazz.getMethod("resolve", class$java$lang$String == null ? (class$java$lang$String = Compiler.class$("java.lang.String")) : class$java$lang$String);
|
||||
String string5 = (String)method.invoke(object, string);
|
||||
if (!string5.endsWith(string4)) {
|
||||
n = string5.lastIndexOf(string4);
|
||||
string5 = n > -1 ? string5.substring(0, n) : string5 + " ";
|
||||
string5 = string5 + string4;
|
||||
}
|
||||
if (!string5.startsWith("\"")) {
|
||||
n = string5.indexOf(32);
|
||||
while (n >= 0) {
|
||||
String string6 = string5.substring(0, n);
|
||||
File file = new File(string6);
|
||||
if (file.exists() && !file.isDirectory()) {
|
||||
string5 = "\"" + string6 + "\"" + string5.substring(n);
|
||||
break;
|
||||
}
|
||||
if ((n = string5.indexOf(32, n + 1)) >= 0 || !(file = new File(string5)).exists() || file.isDirectory()) continue;
|
||||
string5 = "\"" + string5 + "\"";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return string5;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static class JarFilenameFilter
|
||||
implements FilenameFilter {
|
||||
public boolean accept(File file, String string) {
|
||||
return string.endsWith(".jar");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,324 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.gx.BImage
|
||||
* javax.baja.nre.util.SortUtil
|
||||
* javax.baja.nre.util.TextUtil
|
||||
* javax.baja.sys.BModule
|
||||
* javax.baja.sys.SlotCursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.ui.BMenu
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.event.BMouseEvent
|
||||
* javax.baja.ui.table.BTable
|
||||
* javax.baja.ui.table.TableController
|
||||
* javax.baja.ui.table.TableModel
|
||||
* javax.baja.ui.util.UiLexicon
|
||||
*/
|
||||
package com.tridium.program.ui;
|
||||
|
||||
import com.tridium.program.BProgramCode;
|
||||
import com.tridium.program.ui.BProgramEditor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.StringTokenizer;
|
||||
import javax.baja.gx.BImage;
|
||||
import javax.baja.nre.util.SortUtil;
|
||||
import javax.baja.nre.util.TextUtil;
|
||||
import javax.baja.sys.BModule;
|
||||
import javax.baja.sys.SlotCursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.ui.BMenu;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.event.BMouseEvent;
|
||||
import javax.baja.ui.table.BTable;
|
||||
import javax.baja.ui.table.TableController;
|
||||
import javax.baja.ui.table.TableModel;
|
||||
import javax.baja.ui.util.UiLexicon;
|
||||
|
||||
public class Imports
|
||||
extends TableModel {
|
||||
static final int PREDEFINED = 0;
|
||||
static final int USER_DEFINED = 1;
|
||||
static final int BY_PROPERTY = 2;
|
||||
static Import[] predefined = new Import[]{new Import("java", "java.util", 0), new Import("baja", "javax.baja.sys", 0), new Import("baja", "javax.baja.status", 0), new Import("baja", "javax.baja.util", 0), new Import("program", "com.tridium.program", 0)};
|
||||
static UiLexicon lex = UiLexicon.bajaui;
|
||||
static String lexModule = lex.getText("programEditor.module");
|
||||
static String lexPackage = lex.getText("programEditor.package");
|
||||
static String lexDefinition = lex.getText("programEditor.definition");
|
||||
static BImage importIcon = BImage.make((String)"module://icons/x16/module.png");
|
||||
final BProgramEditor editor;
|
||||
BTable table;
|
||||
private ArrayList list = new ArrayList();
|
||||
private HashMap map = new HashMap();
|
||||
|
||||
Imports(BProgramEditor bProgramEditor) {
|
||||
this.editor = bProgramEditor;
|
||||
this.table = new BTable((TableModel)this);
|
||||
this.table.setController((TableController)new Controller());
|
||||
}
|
||||
|
||||
public Import[] getAll() {
|
||||
return this.list.toArray(new Import[this.list.size()]);
|
||||
}
|
||||
|
||||
public String[] getDependencies() {
|
||||
Object object;
|
||||
Hashtable<String, String> hashtable = new Hashtable<String, String>(13);
|
||||
hashtable.put("baja", "baja");
|
||||
hashtable.put("program", "program");
|
||||
for (int i = 0; i < this.list.size(); ++i) {
|
||||
object = (Import)this.list.get(i);
|
||||
if (((Import)object).moduleName.equals("java")) continue;
|
||||
hashtable.put(((Import)object).moduleName, ((Import)object).moduleName);
|
||||
}
|
||||
String[] stringArray = new String[hashtable.size()];
|
||||
object = hashtable.keys();
|
||||
int n = 0;
|
||||
while (object.hasMoreElements()) {
|
||||
stringArray[n] = (String)object.nextElement();
|
||||
++n;
|
||||
}
|
||||
return stringArray;
|
||||
}
|
||||
|
||||
public void updateImports() {
|
||||
Object object;
|
||||
int n;
|
||||
ArrayList<Import> arrayList = new ArrayList<Import>();
|
||||
HashMap<Object, Object> hashMap = new HashMap<Object, Object>();
|
||||
for (n = 0; n < predefined.length; ++n) {
|
||||
arrayList.add(predefined[n]);
|
||||
hashMap.put(predefined[n], predefined[n]);
|
||||
}
|
||||
for (n = 0; n < this.list.size(); ++n) {
|
||||
object = (Import)this.list.get(n);
|
||||
if (((Import)object).definition != 1 || hashMap.get(object) != null) continue;
|
||||
arrayList.add((Import)object);
|
||||
hashMap.put(object, object);
|
||||
}
|
||||
SlotCursor slotCursor = this.editor.program.getProperties();
|
||||
while (slotCursor.next()) {
|
||||
if (!slotCursor.property().isDynamic()) continue;
|
||||
object = slotCursor.get().getClass();
|
||||
String string = TextUtil.getPackageName((Class)object);
|
||||
BModule bModule = Sys.getModuleForClass((Class)object);
|
||||
Import import_ = new Import(bModule.getModuleName(), string, 2);
|
||||
if (hashMap.get(import_) != null) continue;
|
||||
arrayList.add(import_);
|
||||
hashMap.put(import_, import_);
|
||||
}
|
||||
this.list = arrayList;
|
||||
this.map = hashMap;
|
||||
this.updateTable();
|
||||
}
|
||||
|
||||
void add(Import import_) {
|
||||
Import import_2 = (Import)this.map.get(import_);
|
||||
if (import_2 != null) {
|
||||
if (import_2.definition > import_.definition) {
|
||||
import_2.definition = import_.definition;
|
||||
}
|
||||
} else {
|
||||
this.list.add(import_);
|
||||
this.map.put(import_, import_);
|
||||
}
|
||||
this.updateTable();
|
||||
this.editor.setModified();
|
||||
}
|
||||
|
||||
void remove(Import import_) {
|
||||
this.list.remove(import_);
|
||||
this.map.remove(import_);
|
||||
this.updateTable();
|
||||
this.editor.setModified();
|
||||
}
|
||||
|
||||
void removeSelection() {
|
||||
int n;
|
||||
int[] nArray = this.table.getSelection().getRows();
|
||||
if (nArray == null || nArray.length == 0) {
|
||||
return;
|
||||
}
|
||||
boolean bl = false;
|
||||
Import[] importArray = this.getAll();
|
||||
for (n = 0; n < nArray.length; ++n) {
|
||||
int n2 = nArray[n];
|
||||
if (importArray[n2].definition != 1) continue;
|
||||
importArray[n2] = null;
|
||||
bl = true;
|
||||
}
|
||||
if (!bl) {
|
||||
return;
|
||||
}
|
||||
this.list.clear();
|
||||
this.map.clear();
|
||||
for (n = 0; n < importArray.length; ++n) {
|
||||
if (importArray[n] == null) continue;
|
||||
this.list.add(importArray[n]);
|
||||
this.map.put(importArray[n], importArray[n]);
|
||||
}
|
||||
this.updateTable();
|
||||
this.editor.setModified();
|
||||
}
|
||||
|
||||
public void save(BProgramCode bProgramCode) {
|
||||
String[] stringArray;
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
for (int i = 0; i < this.list.size(); ++i) {
|
||||
stringArray = (String[])this.list.get(i);
|
||||
if (stringArray.definition != 1) continue;
|
||||
if (stringBuffer.length() > 0) {
|
||||
stringBuffer.append(';');
|
||||
}
|
||||
stringBuffer.append(stringArray.moduleName).append(':').append(stringArray.packageName);
|
||||
}
|
||||
bProgramCode.setUserDefinedImports(stringBuffer.toString());
|
||||
StringBuffer stringBuffer2 = new StringBuffer();
|
||||
stringArray = this.getDependencies();
|
||||
for (int i = 0; i < stringArray.length; ++i) {
|
||||
if (stringBuffer2.length() > 0) {
|
||||
stringBuffer2.append(';');
|
||||
}
|
||||
stringBuffer2.append(stringArray[i]);
|
||||
}
|
||||
bProgramCode.setDependencies(stringBuffer2.toString());
|
||||
}
|
||||
|
||||
public void load(BProgramCode bProgramCode) {
|
||||
this.list.clear();
|
||||
this.map.clear();
|
||||
String string = bProgramCode.getUserDefinedImports();
|
||||
StringTokenizer stringTokenizer = new StringTokenizer(string, ";");
|
||||
while (stringTokenizer.hasMoreTokens()) {
|
||||
String string2 = stringTokenizer.nextToken();
|
||||
int n = string2.indexOf(58);
|
||||
String string3 = string2.substring(0, n);
|
||||
String string4 = string2.substring(n + 1);
|
||||
this.add(new Import(string3, string4, 1));
|
||||
}
|
||||
this.updateImports();
|
||||
}
|
||||
|
||||
public int getRowCount() {
|
||||
return this.list.size();
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
public String getColumnName(int n) {
|
||||
switch (n) {
|
||||
case 0: {
|
||||
return lexModule;
|
||||
}
|
||||
case 1: {
|
||||
return lexPackage;
|
||||
}
|
||||
case 2: {
|
||||
return lexDefinition;
|
||||
}
|
||||
}
|
||||
return "???";
|
||||
}
|
||||
|
||||
public Object getValueAt(int n, int n2) {
|
||||
Import import_ = (Import)this.list.get(n);
|
||||
switch (n2) {
|
||||
case 0: {
|
||||
return import_.moduleName;
|
||||
}
|
||||
case 1: {
|
||||
return import_.packageName;
|
||||
}
|
||||
case 2: {
|
||||
return import_.definitionToString();
|
||||
}
|
||||
}
|
||||
return "???";
|
||||
}
|
||||
|
||||
public BImage getRowIcon(int n) {
|
||||
return importIcon;
|
||||
}
|
||||
|
||||
public boolean isColumnSortable(int n) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void sortByColumn(int n, boolean bl) {
|
||||
Object[] objectArray = this.list.toArray(new Import[this.list.size()]);
|
||||
Object[] objectArray2 = new Object[objectArray.length];
|
||||
for (int i = 0; i < objectArray2.length; ++i) {
|
||||
objectArray2[i] = this.getValueAt(i, n).toString();
|
||||
}
|
||||
SortUtil.sort((Object[])objectArray2, (Object[])objectArray, (boolean)bl);
|
||||
ArrayList<Object> arrayList = new ArrayList<Object>();
|
||||
for (int i = 0; i < objectArray.length; ++i) {
|
||||
arrayList.add(objectArray[i]);
|
||||
}
|
||||
this.list = arrayList;
|
||||
}
|
||||
|
||||
static class Import {
|
||||
public final String moduleName;
|
||||
public final String packageName;
|
||||
public int definition;
|
||||
|
||||
public Import(String string, String string2, int n) {
|
||||
this.moduleName = string;
|
||||
this.packageName = string2;
|
||||
this.definition = n;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.moduleName.hashCode() ^ this.packageName.hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object object) {
|
||||
Import import_ = (Import)object;
|
||||
return this.moduleName.equals(import_.moduleName) && this.packageName.equals(import_.packageName);
|
||||
}
|
||||
|
||||
public String definitionToString() {
|
||||
switch (this.definition) {
|
||||
case 0: {
|
||||
return "Predefined";
|
||||
}
|
||||
case 1: {
|
||||
return "User Defined";
|
||||
}
|
||||
case 2: {
|
||||
return "By Property";
|
||||
}
|
||||
}
|
||||
return "???";
|
||||
}
|
||||
}
|
||||
|
||||
class Controller
|
||||
extends TableController {
|
||||
Controller() {
|
||||
}
|
||||
|
||||
public void cellPopup(BMouseEvent bMouseEvent, int n, int n2) {
|
||||
this.popup(bMouseEvent);
|
||||
}
|
||||
|
||||
public void backgroundPopup(BMouseEvent bMouseEvent) {
|
||||
this.popup(bMouseEvent);
|
||||
}
|
||||
|
||||
public void popup(BMouseEvent bMouseEvent) {
|
||||
BMenu bMenu = new BMenu();
|
||||
bMenu.add(null, Imports.this.editor.commands.importType);
|
||||
bMenu.add(null, Imports.this.editor.commands.importPackage);
|
||||
bMenu.add(null, Imports.this.editor.commands.removeImport);
|
||||
bMenu.open((BWidget)Imports.this.table, bMouseEvent.getX(), bMouseEvent.getY());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.workbench.console.BConsole
|
||||
* javax.baja.ui.BWidget
|
||||
*/
|
||||
package com.tridium.program.ui;
|
||||
|
||||
import com.tridium.program.BProgramCode;
|
||||
import com.tridium.program.module.BProgramModule;
|
||||
import com.tridium.program.module.BuildException;
|
||||
import com.tridium.program.module.IBuildListener;
|
||||
import com.tridium.program.ui.BProgramEditor;
|
||||
import com.tridium.program.ui.Compiler;
|
||||
import com.tridium.program.ui.SourceWriter;
|
||||
import com.tridium.workbench.console.BConsole;
|
||||
import java.io.FileWriter;
|
||||
import java.io.Writer;
|
||||
import javax.baja.ui.BWidget;
|
||||
|
||||
public class ProgramCompiler
|
||||
extends Compiler {
|
||||
BProgramEditor editor;
|
||||
boolean saveOnSuccess;
|
||||
boolean buildOnSuccess;
|
||||
|
||||
public ProgramCompiler(BProgramEditor bProgramEditor) {
|
||||
super((BWidget)bProgramEditor);
|
||||
this.editor = bProgramEditor;
|
||||
}
|
||||
|
||||
public void compile(String string, boolean bl) throws Exception {
|
||||
this.compile(string, bl, false);
|
||||
}
|
||||
|
||||
public void compile(String string, boolean bl, boolean bl2) throws Exception {
|
||||
this.saveOnSuccess = bl;
|
||||
this.buildOnSuccess = bl2;
|
||||
this.editor.saveCode();
|
||||
this.editor.imports.updateImports();
|
||||
this.editor.imports.save(this.editor.code);
|
||||
this.editor.updateSource();
|
||||
this.compile(string, this.editor.code, null);
|
||||
}
|
||||
|
||||
public void writeSource(FileWriter fileWriter, String string) throws Exception {
|
||||
SourceWriter sourceWriter = new SourceWriter((Writer)fileWriter, this.editor);
|
||||
sourceWriter.generate(this.className);
|
||||
}
|
||||
|
||||
public void compileSuccess(BConsole bConsole) throws Exception {
|
||||
super.compileSuccess(bConsole);
|
||||
BProgramCode bProgramCode = this.editor.code;
|
||||
bProgramCode.setChecksum(this.editor.computeChecksum(bProgramCode.getSource()));
|
||||
this.editor.updateProgramCode();
|
||||
this.editor.updateStatus();
|
||||
if (this.saveOnSuccess) {
|
||||
this.editor.getWbShell().getSaveCommand().invoke();
|
||||
}
|
||||
if (this.buildOnSuccess) {
|
||||
this.buildProgramModule(bConsole);
|
||||
}
|
||||
}
|
||||
|
||||
public void compileFailed(BConsole bConsole) throws Exception {
|
||||
this.editor.setModified();
|
||||
this.editor.code.setChecksum(0);
|
||||
this.editor.updateStatusToError();
|
||||
super.compileFailed(bConsole);
|
||||
}
|
||||
|
||||
private void buildProgramModule(BConsole bConsole) {
|
||||
BProgramModule bProgramModule = this.editor.program.getProgramModule();
|
||||
if (bProgramModule == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
bConsole.appendBreak();
|
||||
bProgramModule.buildModule(new BuildConsoleListener(bConsole));
|
||||
}
|
||||
catch (BuildException buildException) {
|
||||
bConsole.appendLine(buildException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private class BuildConsoleListener
|
||||
implements IBuildListener {
|
||||
private BConsole console;
|
||||
|
||||
public BuildConsoleListener(BConsole bConsole) {
|
||||
this.console = bConsole;
|
||||
}
|
||||
|
||||
public BWidget getOwner() {
|
||||
return this.console;
|
||||
}
|
||||
|
||||
public void nextStep(String string) {
|
||||
this.console.appendLine(string);
|
||||
}
|
||||
|
||||
public void setNumBuildSteps(int n) {
|
||||
}
|
||||
|
||||
public void updateDesc(String string) {
|
||||
this.console.appendLine(string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,262 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.workbench.fieldeditors.BTypeSpecFE
|
||||
* com.tridium.workbench.shell.BNiagaraWbShell
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.gx.BImage
|
||||
* javax.baja.nre.util.SortUtil
|
||||
* javax.baja.nre.util.TextUtil
|
||||
* javax.baja.registry.ModuleInfo
|
||||
* javax.baja.sys.BBoolean
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BListDropDown
|
||||
* javax.baja.ui.BMenu
|
||||
* javax.baja.ui.BSeparator
|
||||
* javax.baja.ui.BTextField
|
||||
* javax.baja.ui.BToolBar
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.Command
|
||||
* javax.baja.ui.CommandArtifact
|
||||
* javax.baja.ui.enums.BHalign
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.ui.util.UiLexicon
|
||||
* javax.baja.util.BTypeSpec
|
||||
* javax.baja.util.Lexicon
|
||||
*/
|
||||
package com.tridium.program.ui;
|
||||
|
||||
import com.tridium.program.BCode;
|
||||
import com.tridium.program.ui.BProgramEditor;
|
||||
import com.tridium.program.ui.Compiler;
|
||||
import com.tridium.program.ui.Imports;
|
||||
import com.tridium.workbench.fieldeditors.BTypeSpecFE;
|
||||
import com.tridium.workbench.shell.BNiagaraWbShell;
|
||||
import java.io.File;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.gx.BImage;
|
||||
import javax.baja.nre.util.SortUtil;
|
||||
import javax.baja.nre.util.TextUtil;
|
||||
import javax.baja.registry.ModuleInfo;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.ui.BDialog;
|
||||
import javax.baja.ui.BLabel;
|
||||
import javax.baja.ui.BListDropDown;
|
||||
import javax.baja.ui.BMenu;
|
||||
import javax.baja.ui.BSeparator;
|
||||
import javax.baja.ui.BTextField;
|
||||
import javax.baja.ui.BToolBar;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.Command;
|
||||
import javax.baja.ui.CommandArtifact;
|
||||
import javax.baja.ui.enums.BHalign;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.ui.util.UiLexicon;
|
||||
import javax.baja.util.BTypeSpec;
|
||||
import javax.baja.util.Lexicon;
|
||||
|
||||
public class ProgramEditorCommands {
|
||||
static UiLexicon lex = UiLexicon.bajaui;
|
||||
public final BProgramEditor editor;
|
||||
public Command importType;
|
||||
public Command importPackage;
|
||||
public Command removeImport;
|
||||
public Command saveAndCompile;
|
||||
public Command compile;
|
||||
public Command build;
|
||||
static /* synthetic */ Class class$com$tridium$program$ui$BProgramEditor;
|
||||
|
||||
public ProgramEditorCommands(BProgramEditor bProgramEditor) {
|
||||
this.editor = bProgramEditor;
|
||||
this.importType = new ImportTypeCommand();
|
||||
this.importPackage = new ImportPackageCommand();
|
||||
this.removeImport = new RemoveImportCommand();
|
||||
this.saveAndCompile = new SaveAndCompileCommand();
|
||||
this.compile = new CompileCommand();
|
||||
this.build = new BuildCommand();
|
||||
}
|
||||
|
||||
public BMenu[] getViewMenus() {
|
||||
BMenu bMenu = UiLexicon.bajaui.buildMenu("programEditor.menu.label");
|
||||
bMenu.add("importType", this.importType);
|
||||
bMenu.add("importPackage", this.importPackage);
|
||||
bMenu.add("importRemove", this.removeImport);
|
||||
bMenu.add("sep0", (BValue)new BSeparator());
|
||||
bMenu.add("addSlot", (Command)this.editor.slotSheet.commands.add);
|
||||
bMenu.add("deleteSlot", (Command)this.editor.slotSheet.commands.delete);
|
||||
bMenu.add("renameSlot", (Command)this.editor.slotSheet.commands.rename);
|
||||
bMenu.add("reorderSlots", (Command)this.editor.slotSheet.commands.reorder);
|
||||
bMenu.add("sep1", (BValue)new BSeparator());
|
||||
bMenu.add("saveAndCompile", this.saveAndCompile);
|
||||
bMenu.add("compile", this.compile);
|
||||
return new BMenu[]{bMenu};
|
||||
}
|
||||
|
||||
public BToolBar getViewToolBar() {
|
||||
BNiagaraWbShell bNiagaraWbShell = (BNiagaraWbShell)this.editor.getShell();
|
||||
BToolBar bToolBar = new BToolBar();
|
||||
bToolBar.add("find", bNiagaraWbShell.commands.find);
|
||||
bToolBar.add("replace", bNiagaraWbShell.commands.replace);
|
||||
bToolBar.add("sep2", (BValue)new BSeparator());
|
||||
if (this.editor.program.getProgramModule() != null) {
|
||||
bToolBar.add("build", this.build);
|
||||
}
|
||||
bToolBar.add("saveAndCompile", this.saveAndCompile);
|
||||
bToolBar.add("compile", this.compile);
|
||||
bToolBar.add("consolePrev", bNiagaraWbShell.commands.consolePrev);
|
||||
bToolBar.add("consoleNext", bNiagaraWbShell.commands.consoleNext);
|
||||
return bToolBar;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public class BuildCommand
|
||||
extends Command {
|
||||
public BuildCommand() {
|
||||
super((BWidget)ProgramEditorCommands.this.editor, Lexicon.make((Class)(class$com$tridium$program$ui$BProgramEditor == null ? (class$com$tridium$program$ui$BProgramEditor = ProgramEditorCommands.class$("com.tridium.program.ui.BProgramEditor")) : class$com$tridium$program$ui$BProgramEditor)), "programEditor.build");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() throws Exception {
|
||||
ProgramEditorCommands.this.editor.compiler.compile(BCode.generateClassName(), true, true);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class SaveAndCompileCommand
|
||||
extends ProgramEditorCommand {
|
||||
public SaveAndCompileCommand() {
|
||||
super("programEditor.saveAndCompile");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() throws Exception {
|
||||
ProgramEditorCommands.this.editor.compiler.compile(BCode.generateClassName(), true);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class CompileCommand
|
||||
extends ProgramEditorCommand {
|
||||
public CompileCommand() {
|
||||
super("programEditor.compile");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() throws Exception {
|
||||
ProgramEditorCommands.this.editor.compiler.compile(BCode.generateClassName(), false);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class RemoveImportCommand
|
||||
extends ProgramEditorCommand {
|
||||
public RemoveImportCommand() {
|
||||
super("programEditor.removeImport");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() throws Exception {
|
||||
ProgramEditorCommands.this.editor.imports.removeSelection();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class ImportPackageCommand
|
||||
extends ProgramEditorCommand {
|
||||
public ImportPackageCommand() {
|
||||
super("programEditor.importPackage");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() throws Exception {
|
||||
int n;
|
||||
BListDropDown bListDropDown = new BListDropDown();
|
||||
ModuleInfo[] moduleInfoArray = Sys.getRegistry().getModules();
|
||||
File file = new File(Sys.getBajaHome(), "bin");
|
||||
String[] stringArray = file.list(new Compiler.JarFilenameFilter());
|
||||
Object[] objectArray = new String[moduleInfoArray.length + stringArray.length];
|
||||
for (n = 0; n < moduleInfoArray.length; ++n) {
|
||||
objectArray[n] = moduleInfoArray[n].getModuleName();
|
||||
}
|
||||
for (n = 0; n < stringArray.length; ++n) {
|
||||
objectArray[moduleInfoArray.length + n] = stringArray[n].substring(0, stringArray[n].length() - 4);
|
||||
}
|
||||
SortUtil.sort((Object[])objectArray);
|
||||
bListDropDown.getList().addItem((Object)"java");
|
||||
for (n = 0; n < objectArray.length; ++n) {
|
||||
bListDropDown.getList().addItem(objectArray[n]);
|
||||
}
|
||||
bListDropDown.setSelectedItem((Object)"baja");
|
||||
BTextField bTextField = new BTextField("", 25);
|
||||
BGridPane bGridPane = new BGridPane(2);
|
||||
bGridPane.setColumnAlign(BHalign.fill);
|
||||
bGridPane.add(null, (BValue)new BLabel(lex.getText("programEditor.module")));
|
||||
bGridPane.add(null, (BValue)bListDropDown);
|
||||
bGridPane.add(null, (BValue)new BLabel(lex.getText("programEditor.package")));
|
||||
bGridPane.add(null, (BValue)bTextField);
|
||||
int n2 = BDialog.open((BWidget)ProgramEditorCommands.this.editor, (String)this.getLabel(), (Object)bGridPane, (int)3, (BImage)BDialog.QUESTION_ICON);
|
||||
if (n2 == 2) {
|
||||
return null;
|
||||
}
|
||||
String string = (String)bListDropDown.getSelectedItem();
|
||||
String string2 = bTextField.getText();
|
||||
if (string2.equals("")) {
|
||||
return null;
|
||||
}
|
||||
ProgramEditorCommands.this.editor.imports.add(new Imports.Import(string, string2, 1));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class ImportTypeCommand
|
||||
extends ProgramEditorCommand {
|
||||
public ImportTypeCommand() {
|
||||
super("programEditor.importType");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() throws Exception {
|
||||
BTypeSpecFE bTypeSpecFE = new BTypeSpecFE();
|
||||
bTypeSpecFE.loadValue((BObject)BTypeSpec.make((String)"baja", (String)"String"), (Context)BFacets.make((String)"allowNull", (BIDataValue)BBoolean.FALSE));
|
||||
int n = BDialog.open((BWidget)ProgramEditorCommands.this.editor, (String)this.getLabel(), (Object)bTypeSpecFE, (int)3, (BImage)BDialog.QUESTION_ICON);
|
||||
if (n == 2) {
|
||||
return null;
|
||||
}
|
||||
BTypeSpec bTypeSpec = (BTypeSpec)bTypeSpecFE.saveValue();
|
||||
if (bTypeSpec.getTypeName().equals("")) {
|
||||
return null;
|
||||
}
|
||||
String string = bTypeSpec.getResolvedType().getTypeClass().getName();
|
||||
String string2 = TextUtil.getPackageName((String)string);
|
||||
ProgramEditorCommands.this.editor.imports.add(new Imports.Import(bTypeSpec.getModuleName(), string2, 1));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class ProgramEditorCommand
|
||||
extends Command {
|
||||
public ProgramEditorCommand(String string) {
|
||||
super((BWidget)ProgramEditorCommands.this.editor, UiLexicon.bajaui.module, string);
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() throws Exception {
|
||||
BDialog.message((BWidget)ProgramEditorCommands.this.editor, (Object)("Incomplete: " + this.getLabel()));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.workbench.shell.BNiagaraWbShell
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BMenu
|
||||
* javax.baja.ui.BSeparator
|
||||
* javax.baja.ui.BToolBar
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.Command
|
||||
* javax.baja.ui.CommandArtifact
|
||||
* javax.baja.ui.util.UiLexicon
|
||||
*/
|
||||
package com.tridium.program.ui;
|
||||
|
||||
import com.tridium.program.ui.BRobotEditor;
|
||||
import com.tridium.workbench.shell.BNiagaraWbShell;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.ui.BDialog;
|
||||
import javax.baja.ui.BMenu;
|
||||
import javax.baja.ui.BSeparator;
|
||||
import javax.baja.ui.BToolBar;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.Command;
|
||||
import javax.baja.ui.CommandArtifact;
|
||||
import javax.baja.ui.util.UiLexicon;
|
||||
|
||||
public class RobotEditorCommands {
|
||||
static UiLexicon lex = UiLexicon.bajaui;
|
||||
public final BRobotEditor editor;
|
||||
public final Command compile;
|
||||
public final Command compileAndRun;
|
||||
|
||||
public RobotEditorCommands(BRobotEditor bRobotEditor) {
|
||||
this.editor = bRobotEditor;
|
||||
this.compileAndRun = new CompileAndRunCommand();
|
||||
this.compile = new CompileCommand();
|
||||
}
|
||||
|
||||
public BMenu[] getViewMenus() {
|
||||
BMenu bMenu = UiLexicon.bajaui.buildMenu("robotEditor.menu.label");
|
||||
bMenu.add("compile", this.compile);
|
||||
bMenu.add("run", this.compileAndRun);
|
||||
return new BMenu[]{bMenu};
|
||||
}
|
||||
|
||||
public BToolBar getViewToolBar() {
|
||||
BNiagaraWbShell bNiagaraWbShell = (BNiagaraWbShell)this.editor.getShell();
|
||||
BToolBar bToolBar = new BToolBar();
|
||||
bToolBar.add("find", bNiagaraWbShell.commands.find);
|
||||
bToolBar.add("replace", bNiagaraWbShell.commands.replace);
|
||||
bToolBar.add("sep1", (BValue)new BSeparator());
|
||||
bToolBar.add("compile", this.compile);
|
||||
bToolBar.add("run", this.compileAndRun);
|
||||
bToolBar.add("sep2", (BValue)new BSeparator());
|
||||
bToolBar.add("consolePrev", bNiagaraWbShell.commands.consolePrev);
|
||||
bToolBar.add("consoleNext", bNiagaraWbShell.commands.consoleNext);
|
||||
return bToolBar;
|
||||
}
|
||||
|
||||
public class CompileAndRunCommand
|
||||
extends RobotEditorCommand {
|
||||
public CompileAndRunCommand() {
|
||||
super("robotEditor.compileAndRun");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() throws Exception {
|
||||
RobotEditorCommands.this.editor.compiler.compile(true);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class CompileCommand
|
||||
extends RobotEditorCommand {
|
||||
public CompileCommand() {
|
||||
super("robotEditor.compile");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() throws Exception {
|
||||
RobotEditorCommands.this.editor.compiler.compile(false);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class RobotEditorCommand
|
||||
extends Command {
|
||||
public RobotEditorCommand(String string) {
|
||||
super((BWidget)RobotEditorCommands.this.editor, UiLexicon.bajaui.module, string);
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() throws Exception {
|
||||
BDialog.message((BWidget)RobotEditorCommands.this.editor, (Object)("Incomplete: " + this.getLabel()));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,300 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.nre.util.TextUtil
|
||||
* javax.baja.sys.BAction
|
||||
* javax.baja.sys.BBoolean
|
||||
* javax.baja.sys.BDouble
|
||||
* javax.baja.sys.BFloat
|
||||
* javax.baja.sys.BInteger
|
||||
* javax.baja.sys.BLink
|
||||
* javax.baja.sys.BLong
|
||||
* javax.baja.sys.BModule
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BTopic
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.SlotCursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.util.BWsAnnotation
|
||||
*/
|
||||
package com.tridium.program.ui;
|
||||
|
||||
import com.tridium.program.BProgram;
|
||||
import com.tridium.program.BProgramCode;
|
||||
import com.tridium.program.ui.BProgramEditor;
|
||||
import com.tridium.program.ui.Imports;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.CharArrayWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringReader;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import javax.baja.nre.util.TextUtil;
|
||||
import javax.baja.sys.BAction;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BDouble;
|
||||
import javax.baja.sys.BFloat;
|
||||
import javax.baja.sys.BInteger;
|
||||
import javax.baja.sys.BLink;
|
||||
import javax.baja.sys.BLong;
|
||||
import javax.baja.sys.BModule;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BTopic;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.SlotCursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.util.BWsAnnotation;
|
||||
|
||||
public class SourceWriter
|
||||
extends PrintWriter {
|
||||
public BProgramEditor editor;
|
||||
public BProgram program;
|
||||
public BProgramCode code;
|
||||
public Imports.Import[] imports;
|
||||
private Property[] accessProps;
|
||||
private int line;
|
||||
public int sourceLine;
|
||||
|
||||
public static char[] generateToCharArray(BProgramEditor bProgramEditor, String string) {
|
||||
CharArrayWriter charArrayWriter = new CharArrayWriter();
|
||||
new SourceWriter((Writer)charArrayWriter, bProgramEditor).generate(string);
|
||||
return charArrayWriter.toCharArray();
|
||||
}
|
||||
|
||||
public SourceWriter(Writer writer, BProgramEditor bProgramEditor) {
|
||||
super(writer);
|
||||
this.init(bProgramEditor);
|
||||
}
|
||||
|
||||
public SourceWriter(OutputStream outputStream, BProgramEditor bProgramEditor) {
|
||||
super(outputStream);
|
||||
this.init(bProgramEditor);
|
||||
}
|
||||
|
||||
private void init(BProgramEditor bProgramEditor) {
|
||||
this.editor = bProgramEditor;
|
||||
this.program = bProgramEditor.program;
|
||||
this.code = bProgramEditor.code;
|
||||
this.sourceLine = 0;
|
||||
this.imports = bProgramEditor.imports.getAll();
|
||||
this.accessProps = this.getAccessProperties();
|
||||
}
|
||||
|
||||
private Property[] getAccessProperties() {
|
||||
ArrayList<Property> arrayList = new ArrayList<Property>();
|
||||
SlotCursor slotCursor = this.program.getProperties();
|
||||
while (slotCursor.next()) {
|
||||
BObject bObject;
|
||||
Property property = slotCursor.property();
|
||||
if (property.isFrozen() || (bObject = slotCursor.get()) instanceof BWsAnnotation || bObject instanceof BLink || bObject instanceof BAction || bObject instanceof BTopic) continue;
|
||||
arrayList.add(property);
|
||||
}
|
||||
return arrayList.toArray(new Property[arrayList.size()]);
|
||||
}
|
||||
|
||||
public void generate(String string) {
|
||||
this.generateHeader(string);
|
||||
this.generateGetters();
|
||||
this.generateSetters();
|
||||
this.generateSource();
|
||||
this.generateFooter();
|
||||
this.editor.sourceLine = this.sourceLine;
|
||||
this.flush();
|
||||
}
|
||||
|
||||
private void generateHeader(String string) {
|
||||
BModule bModule = Sys.getModuleForClass(this.getClass());
|
||||
this.w("/* Auto-generated ProgramImpl Code */");
|
||||
this.w("");
|
||||
for (int i = 0; i < this.imports.length; ++i) {
|
||||
this.x("import ");
|
||||
this.x(TextUtil.pad((String)(this.imports[i].packageName + ".*;"), (int)25));
|
||||
this.x(" /* ");
|
||||
this.x(this.imports[i].moduleName);
|
||||
this.x(" ");
|
||||
this.x(this.imports[i].definitionToString());
|
||||
this.w("*/");
|
||||
}
|
||||
this.w("");
|
||||
this.w("public class " + string);
|
||||
this.w(" extends com.tridium.program.ProgramBase");
|
||||
this.w("{");
|
||||
}
|
||||
|
||||
private void generateGetters() {
|
||||
if (this.accessProps.length == 0) {
|
||||
return;
|
||||
}
|
||||
this.header("Getters");
|
||||
for (int i = 0; i < this.accessProps.length; ++i) {
|
||||
Property property = this.accessProps[i];
|
||||
String string = property.getName();
|
||||
BValue bValue = this.program.get(property);
|
||||
if (bValue.getType() == BBoolean.TYPE) {
|
||||
this.x(" public boolean get");
|
||||
this.x(SourceWriter.capitalize(string));
|
||||
this.x("() { return getBoolean(\"");
|
||||
this.x(string);
|
||||
this.x("\"); }");
|
||||
} else if (bValue.getType() == BInteger.TYPE) {
|
||||
this.x(" public int get");
|
||||
this.x(SourceWriter.capitalize(string));
|
||||
this.x("() { return getInt(\"");
|
||||
this.x(string);
|
||||
this.x("\"); }");
|
||||
} else if (bValue.getType() == BFloat.TYPE) {
|
||||
this.x(" public float get");
|
||||
this.x(SourceWriter.capitalize(string));
|
||||
this.x("() { return getFloat(\"");
|
||||
this.x(string);
|
||||
this.x("\"); }");
|
||||
} else if (bValue.getType() == BString.TYPE) {
|
||||
this.x(" public String get");
|
||||
this.x(SourceWriter.capitalize(string));
|
||||
this.x("() { return getString(\"");
|
||||
this.x(string);
|
||||
this.x("\"); }");
|
||||
} else if (bValue.getType() == BDouble.TYPE) {
|
||||
this.x(" public double get");
|
||||
this.x(SourceWriter.capitalize(string));
|
||||
this.x("() { return getDouble(\"");
|
||||
this.x(string);
|
||||
this.x("\"); }");
|
||||
} else if (bValue.getType() == BLong.TYPE) {
|
||||
this.x(" public long get");
|
||||
this.x(SourceWriter.capitalize(string));
|
||||
this.x("() { return getLong(\"");
|
||||
this.x(string);
|
||||
this.x("\"); }");
|
||||
} else {
|
||||
String string2 = TextUtil.getClassName(bValue.getClass());
|
||||
this.x(" public ");
|
||||
this.x(string2);
|
||||
this.x(" get");
|
||||
this.x(SourceWriter.capitalize(string));
|
||||
this.x("() { return (");
|
||||
this.x(string2);
|
||||
this.x(")get(\"");
|
||||
this.x(string);
|
||||
this.x("\"); }");
|
||||
}
|
||||
this.w("");
|
||||
}
|
||||
}
|
||||
|
||||
private void generateSetters() {
|
||||
if (this.accessProps.length == 0) {
|
||||
return;
|
||||
}
|
||||
this.header("Setters");
|
||||
for (int i = 0; i < this.accessProps.length; ++i) {
|
||||
Property property = this.accessProps[i];
|
||||
String string = property.getName();
|
||||
BValue bValue = this.program.get(property);
|
||||
if (bValue.getType() == BBoolean.TYPE) {
|
||||
this.x(" public void set");
|
||||
this.x(SourceWriter.capitalize(string));
|
||||
this.x("(boolean v) { setBoolean(\"");
|
||||
this.x(string);
|
||||
this.x("\", v); }");
|
||||
} else if (bValue.getType() == BInteger.TYPE) {
|
||||
this.x(" public void set");
|
||||
this.x(SourceWriter.capitalize(string));
|
||||
this.x("(int v) { setInt(\"");
|
||||
this.x(string);
|
||||
this.x("\", v); }");
|
||||
} else if (bValue.getType() == BFloat.TYPE) {
|
||||
this.x(" public void set");
|
||||
this.x(SourceWriter.capitalize(string));
|
||||
this.x("(float v) { setFloat(\"");
|
||||
this.x(string);
|
||||
this.x("\", v); }");
|
||||
} else if (bValue.getType() == BString.TYPE) {
|
||||
this.x(" public void set");
|
||||
this.x(SourceWriter.capitalize(string));
|
||||
this.x("(String v) { setString(\"");
|
||||
this.x(string);
|
||||
this.x("\", v); }");
|
||||
} else if (bValue.getType() == BDouble.TYPE) {
|
||||
this.x(" public void set");
|
||||
this.x(SourceWriter.capitalize(string));
|
||||
this.x("(double v) { setDouble(\"");
|
||||
this.x(string);
|
||||
this.x("\", v); }");
|
||||
} else if (bValue.getType() == BLong.TYPE) {
|
||||
this.x(" public void set");
|
||||
this.x(SourceWriter.capitalize(string));
|
||||
this.x("(long v) { setLong(\"");
|
||||
this.x(string);
|
||||
this.x("\", v); }");
|
||||
} else {
|
||||
this.x(" public void set");
|
||||
this.x(SourceWriter.capitalize(string));
|
||||
this.x("(");
|
||||
this.x(bValue.getClass().getName());
|
||||
this.x(" v) { set(\"");
|
||||
this.x(string);
|
||||
this.x("\", v); }");
|
||||
}
|
||||
this.w("");
|
||||
}
|
||||
}
|
||||
|
||||
private void generateSource() {
|
||||
this.header("Program Source");
|
||||
this.sourceLine = this.line;
|
||||
this.writeCode(this.code.getSource(), 2);
|
||||
}
|
||||
|
||||
private void generateFooter() {
|
||||
this.w("}");
|
||||
}
|
||||
|
||||
static String capitalize(String string) {
|
||||
return TextUtil.capitalize((String)string);
|
||||
}
|
||||
|
||||
static String decapitalize(String string) {
|
||||
return TextUtil.decapitalize((String)string);
|
||||
}
|
||||
|
||||
private void header(String string) {
|
||||
this.w("");
|
||||
this.w("////////////////////////////////////////////////////////////////");
|
||||
this.w("// " + string);
|
||||
this.w("////////////////////////////////////////////////////////////////");
|
||||
this.w("");
|
||||
}
|
||||
|
||||
private void writeCode(String string, int n) {
|
||||
try {
|
||||
String string2;
|
||||
BufferedReader bufferedReader = new BufferedReader(new StringReader(string));
|
||||
while ((string2 = bufferedReader.readLine()) != null) {
|
||||
this.x(TextUtil.getSpaces((int)n));
|
||||
this.w(string2);
|
||||
}
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
|
||||
private void x(String string) {
|
||||
this.print(string);
|
||||
}
|
||||
|
||||
private void w(String string) {
|
||||
this.print(string);
|
||||
this.print('\n');
|
||||
++this.line;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.ui.BOptionDialog
|
||||
* com.tridium.ui.theme.Theme
|
||||
* com.tridium.workbench.fieldeditors.BTypeSpecFE
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.gx.BBrush
|
||||
* javax.baja.io.ValueDocEncoder
|
||||
* javax.baja.naming.SlotPath
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BBoolean
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Slot
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BCheckBox
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BNullWidget
|
||||
* javax.baja.ui.BTextField
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.enums.BHalign
|
||||
* javax.baja.ui.enums.BScrollBarPolicy
|
||||
* javax.baja.ui.enums.BValign
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BEdgePane
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.ui.pane.BScrollPane
|
||||
* javax.baja.util.BTypeSpec
|
||||
* javax.baja.util.Lexicon
|
||||
* javax.baja.workbench.fieldeditor.BWbFieldEditor
|
||||
*/
|
||||
package com.tridium.program.ui.batch;
|
||||
|
||||
import com.tridium.program.ui.batch.BBatchEditor;
|
||||
import com.tridium.ui.BOptionDialog;
|
||||
import com.tridium.ui.theme.Theme;
|
||||
import com.tridium.workbench.fieldeditors.BTypeSpecFE;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.gx.BBrush;
|
||||
import javax.baja.io.ValueDocEncoder;
|
||||
import javax.baja.naming.SlotPath;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Slot;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BCheckBox;
|
||||
import javax.baja.ui.BDialog;
|
||||
import javax.baja.ui.BLabel;
|
||||
import javax.baja.ui.BNullWidget;
|
||||
import javax.baja.ui.BTextField;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.enums.BHalign;
|
||||
import javax.baja.ui.enums.BScrollBarPolicy;
|
||||
import javax.baja.ui.enums.BValign;
|
||||
import javax.baja.ui.pane.BBorderPane;
|
||||
import javax.baja.ui.pane.BEdgePane;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.ui.pane.BScrollPane;
|
||||
import javax.baja.util.BTypeSpec;
|
||||
import javax.baja.util.Lexicon;
|
||||
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
|
||||
|
||||
public class BAddDialog
|
||||
extends BOptionDialog {
|
||||
public static final Action typeChanged = BAddDialog.newAction((int)0, null, null);
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$batch$BAddDialog == null ? (class$com$tridium$program$ui$batch$BAddDialog = BAddDialog.class$("com.tridium.program.ui.batch.BAddDialog")) : class$com$tridium$program$ui$batch$BAddDialog));
|
||||
private static Lexicon lex = Lexicon.make((String)"program");
|
||||
private BTextField name = new BTextField("", 30);
|
||||
private BTypeSpecFE type;
|
||||
private BWbFieldEditor editor;
|
||||
private BCheckBox setIfExists = new BCheckBox(lex.getText("batchEditor.setIfExists"));
|
||||
private BBorderPane content;
|
||||
static /* synthetic */ Class class$com$tridium$program$ui$batch$BAddDialog;
|
||||
|
||||
public void typeChanged() {
|
||||
this.invoke(typeChanged, null, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static String open(BBatchEditor bBatchEditor) {
|
||||
BAddDialog bAddDialog = new BAddDialog(bBatchEditor);
|
||||
bAddDialog.setBoundsCenteredOnOwner();
|
||||
bAddDialog.open();
|
||||
if (bAddDialog.getResult() == 1) {
|
||||
try {
|
||||
if (SlotPath.isValidName((String)bAddDialog.name.getText())) {
|
||||
String string = bAddDialog.name.getText();
|
||||
BValue bValue = (BValue)bAddDialog.editor.saveValue();
|
||||
boolean bl = bAddDialog.setIfExists.isSelected();
|
||||
String string2 = ValueDocEncoder.marshal((BValue)bValue);
|
||||
string2 = string2.replaceAll("\"", "'");
|
||||
string2 = string2.replaceAll("\n", "");
|
||||
StringBuffer stringBuffer = new StringBuffer("add(ord, ");
|
||||
stringBuffer.append("\"").append(string).append("\", ");
|
||||
stringBuffer.append("\"").append(bValue.getType().getTypeSpec()).append("\", ");
|
||||
stringBuffer.append("\"").append(string2).append("\", ");
|
||||
stringBuffer.append(bl ? "true" : "false").append(");");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
BDialog.error((BWidget)bBatchEditor, (String)lex.getText("batchEditor.commands.slotAdd.label"), (Object)lex.getText("batchEditor.invalidName"));
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BDialog.error((BWidget)bBatchEditor, (String)"Error", (Object)"Failed", (Throwable)exception);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private BAddDialog(BBatchEditor bBatchEditor) {
|
||||
super((BWidget)bBatchEditor, lex.getText("batchEditor.commands.slotAdd.label"), (BWidget)new BNullWidget(), 3, null, null);
|
||||
BFacets bFacets = BFacets.make((String)"allowNull", (BIDataValue)BBoolean.FALSE);
|
||||
bFacets = BFacets.make((BFacets)bFacets, (String)"showAbstract", (BIDataValue)BBoolean.FALSE);
|
||||
this.type = new BTypeSpecFE();
|
||||
this.linkTo("link", (BComponent)this.type, (Slot)BTypeSpecFE.pluginModified, (Slot)typeChanged);
|
||||
this.type.loadValue((BObject)BComponent.TYPE.getTypeSpec(), (Context)bFacets);
|
||||
this.setIfExists.setSelected(true);
|
||||
this.editor = this.make(BComponent.TYPE);
|
||||
BGridPane bGridPane = new BGridPane(1);
|
||||
bGridPane.setValign(BValign.top);
|
||||
bGridPane.setHalign(BHalign.left);
|
||||
this.content = new BBorderPane((BWidget)this.editor, 1.0, 1.0, 1.0, 1.0);
|
||||
bGridPane.add(null, (BValue)this.content);
|
||||
BGridPane bGridPane2 = new BGridPane(2);
|
||||
bGridPane2.add(null, (BValue)new BLabel(lex.getText("batchEditor.newName")));
|
||||
bGridPane2.add(null, (BValue)this.name);
|
||||
bGridPane2.add(null, (BValue)new BLabel(lex.getText("batchEditor.newType")));
|
||||
bGridPane2.add(null, (BValue)this.type);
|
||||
BGridPane bGridPane3 = new BGridPane(1);
|
||||
bGridPane3.setHalign(BHalign.left);
|
||||
bGridPane3.add(null, (BValue)bGridPane2);
|
||||
bGridPane3.add(null, (BValue)this.setIfExists);
|
||||
BEdgePane bEdgePane = new BEdgePane();
|
||||
bEdgePane.setTop((BWidget)new BBorderPane((BWidget)bGridPane3, 0.0, 0.0, 10.0, 0.0));
|
||||
BBrush bBrush = Theme.scrollPane().getControlBackground();
|
||||
BScrollPane bScrollPane = new BScrollPane((BWidget)new BBorderPane((BWidget)bGridPane, lex.getText("batchEditor.newValue")));
|
||||
bScrollPane.setBorderPolicy(BScrollBarPolicy.asNeeded);
|
||||
bScrollPane.setViewportBackground(bBrush);
|
||||
bEdgePane.setCenter((BWidget)bScrollPane);
|
||||
this.setContent((BWidget)new BBorderPane((BWidget)bEdgePane, 10.0, 10.0, 10.0, 10.0));
|
||||
}
|
||||
|
||||
private BWbFieldEditor make(Type type) {
|
||||
BObject bObject = type.getInstance();
|
||||
BWbFieldEditor bWbFieldEditor = BWbFieldEditor.makeFor((BObject)bObject);
|
||||
bWbFieldEditor.loadValue(bObject);
|
||||
return bWbFieldEditor;
|
||||
}
|
||||
|
||||
public void computePreferredSize() {
|
||||
super.computePreferredSize();
|
||||
double d = Math.max(500.0, this.getPreferredWidth());
|
||||
double d2 = Math.max(300.0, this.getPreferredHeight());
|
||||
this.setPreferredSize(d, d2);
|
||||
}
|
||||
|
||||
public void doTypeChanged() {
|
||||
try {
|
||||
BObject bObject = ((BTypeSpec)this.type.saveValue()).getInstance();
|
||||
this.editor = this.make(bObject.getType());
|
||||
this.content.setContent((BWidget)this.editor);
|
||||
this.computePreferredSize();
|
||||
this.setSize(this.getPreferredWidth(), this.getPreferredHeight());
|
||||
this.setBoundsCenteredOnOwner();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.gx.BInsets
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BBorder
|
||||
* javax.baja.ui.BButton
|
||||
* javax.baja.ui.BMenu
|
||||
* javax.baja.ui.BSeparator
|
||||
* javax.baja.ui.BToolBar
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.Command
|
||||
* javax.baja.ui.enums.BHalign
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BEdgePane
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.ui.transfer.BTransferWidget
|
||||
* javax.baja.workbench.view.BWbView
|
||||
*/
|
||||
package com.tridium.program.ui.batch;
|
||||
|
||||
import com.tridium.program.BProgramService;
|
||||
import com.tridium.program.ui.batch.BBatchTable;
|
||||
import com.tridium.program.ui.batch.BatchCommands;
|
||||
import javax.baja.gx.BInsets;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BBorder;
|
||||
import javax.baja.ui.BButton;
|
||||
import javax.baja.ui.BMenu;
|
||||
import javax.baja.ui.BSeparator;
|
||||
import javax.baja.ui.BToolBar;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.Command;
|
||||
import javax.baja.ui.enums.BHalign;
|
||||
import javax.baja.ui.pane.BBorderPane;
|
||||
import javax.baja.ui.pane.BEdgePane;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.ui.transfer.BTransferWidget;
|
||||
import javax.baja.workbench.view.BWbView;
|
||||
|
||||
public class BBatchEditor
|
||||
extends BWbView {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$batch$BBatchEditor == null ? (class$com$tridium$program$ui$batch$BBatchEditor = BBatchEditor.class$("com.tridium.program.ui.batch.BBatchEditor")) : class$com$tridium$program$ui$batch$BBatchEditor));
|
||||
private static BBatchTable.Model model;
|
||||
BBatchTable table = new BBatchTable(this);
|
||||
BatchCommands commands;
|
||||
BProgramService service;
|
||||
static /* synthetic */ Class class$com$tridium$program$ui$batch$BBatchEditor;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BBatchEditor() {
|
||||
if (model != null) {
|
||||
this.table.setModel(model.makeCopy());
|
||||
}
|
||||
this.commands = new BatchCommands(this);
|
||||
BGridPane bGridPane = new BGridPane(4);
|
||||
bGridPane.setColumnAlign(BHalign.fill);
|
||||
bGridPane.add(null, (BValue)new BButton((Command)this.commands.findObjects));
|
||||
bGridPane.add(null, (BValue)new BButton((Command)this.commands.clearAll));
|
||||
bGridPane.add(null, (BValue)new BButton((Command)this.commands.rename));
|
||||
bGridPane.add(null, (BValue)new BButton((Command)this.commands.slotAdd));
|
||||
bGridPane.add(null, (BValue)new BButton((Command)this.commands.slotEdit));
|
||||
bGridPane.add(null, (BValue)new BButton((Command)this.commands.slotRename));
|
||||
bGridPane.add(null, (BValue)new BButton((Command)this.commands.slotRemove));
|
||||
bGridPane.add(null, (BValue)new BButton((Command)this.commands.slotFlags));
|
||||
BEdgePane bEdgePane = new BEdgePane();
|
||||
bEdgePane.setCenter((BWidget)new BBorderPane((BWidget)this.table, BBorder.inset, BInsets.make((double)0.0, (double)0.0, (double)0.0, (double)0.0)));
|
||||
bEdgePane.setBottom((BWidget)new BBorderPane((BWidget)bGridPane, 5.0, 0.0, 0.0, 0.0));
|
||||
this.setContent((BWidget)bEdgePane);
|
||||
this.setTransferWidget((BTransferWidget)this.table);
|
||||
}
|
||||
|
||||
public BMenu[] getViewMenus() {
|
||||
return new BMenu[]{this.commands.buildMenu()};
|
||||
}
|
||||
|
||||
public BToolBar getViewToolBar() {
|
||||
BToolBar bToolBar = new BToolBar();
|
||||
bToolBar.add(null, (Command)this.commands.findObjects);
|
||||
bToolBar.add(null, (Command)this.commands.clear);
|
||||
bToolBar.add(null, (Command)this.commands.selectCols);
|
||||
bToolBar.add(null, (BValue)new BSeparator());
|
||||
bToolBar.add(null, (Command)this.commands.rename);
|
||||
bToolBar.add(null, (Command)this.commands.slotAdd);
|
||||
bToolBar.add(null, (Command)this.commands.slotEdit);
|
||||
bToolBar.add(null, (Command)this.commands.slotRename);
|
||||
bToolBar.add(null, (Command)this.commands.slotRemove);
|
||||
bToolBar.add(null, (Command)this.commands.slotFlags);
|
||||
return bToolBar;
|
||||
}
|
||||
|
||||
protected void doLoadValue(BObject bObject, Context context) throws Exception {
|
||||
this.service = (BProgramService)bObject;
|
||||
this.table.refresh();
|
||||
this.commands.updateCommands();
|
||||
}
|
||||
|
||||
public void deactivated() {
|
||||
super.deactivated();
|
||||
model = this.table.model;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,292 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.script.PropertyField
|
||||
* com.tridium.script.ScriptField
|
||||
* com.tridium.script.ScriptUtil
|
||||
* com.tridium.workbench.user.BPermissionsMapFE
|
||||
* javax.baja.gx.BImage
|
||||
* javax.baja.naming.SlotPath
|
||||
* javax.baja.space.Mark
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BIcon
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BMenu
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.CommandArtifact
|
||||
* javax.baja.ui.event.BKeyEvent
|
||||
* javax.baja.ui.event.BMouseEvent
|
||||
* javax.baja.ui.table.BTable
|
||||
* javax.baja.ui.table.TableController
|
||||
* javax.baja.ui.table.TableModel
|
||||
* javax.baja.ui.table.TableSelection
|
||||
* javax.baja.ui.transfer.TransferContext
|
||||
* javax.baja.ui.transfer.TransferFormat
|
||||
* javax.baja.util.Lexicon
|
||||
* javax.baja.workbench.fieldeditor.BWbFieldEditor
|
||||
*/
|
||||
package com.tridium.program.ui.batch;
|
||||
|
||||
import com.tridium.program.ui.batch.BBatchEditor;
|
||||
import com.tridium.program.ui.batch.BatchCommands;
|
||||
import com.tridium.script.PropertyField;
|
||||
import com.tridium.script.ScriptField;
|
||||
import com.tridium.script.ScriptUtil;
|
||||
import com.tridium.workbench.user.BPermissionsMapFE;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import javax.baja.gx.BImage;
|
||||
import javax.baja.naming.SlotPath;
|
||||
import javax.baja.space.Mark;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BIcon;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BMenu;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.CommandArtifact;
|
||||
import javax.baja.ui.event.BKeyEvent;
|
||||
import javax.baja.ui.event.BMouseEvent;
|
||||
import javax.baja.ui.table.BTable;
|
||||
import javax.baja.ui.table.TableController;
|
||||
import javax.baja.ui.table.TableModel;
|
||||
import javax.baja.ui.table.TableSelection;
|
||||
import javax.baja.ui.transfer.TransferContext;
|
||||
import javax.baja.ui.transfer.TransferFormat;
|
||||
import javax.baja.util.Lexicon;
|
||||
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
|
||||
|
||||
public class BBatchTable
|
||||
extends BTable {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$batch$BBatchTable == null ? (class$com$tridium$program$ui$batch$BBatchTable = BBatchTable.class$("com.tridium.program.ui.batch.BBatchTable")) : class$com$tridium$program$ui$batch$BBatchTable));
|
||||
private Lexicon lex = Lexicon.make((String)"program");
|
||||
BBatchEditor editor;
|
||||
Model model;
|
||||
static /* synthetic */ Class class$com$tridium$program$ui$batch$BBatchTable;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BBatchTable(BBatchEditor bBatchEditor) {
|
||||
this.editor = bBatchEditor;
|
||||
this.model = new Model();
|
||||
this.setModel(this.model);
|
||||
this.setSelection(new Selection());
|
||||
this.setController(new Controller());
|
||||
this.setPasteEnabled(true);
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
BatchCommands.lease(this.model.kids.toArray(new BComponent[this.model.kids.size()]));
|
||||
this.relayout();
|
||||
}
|
||||
|
||||
public void setModel(TableModel tableModel) {
|
||||
super.setModel(tableModel);
|
||||
if (tableModel instanceof Model) {
|
||||
this.model = (Model)tableModel;
|
||||
}
|
||||
}
|
||||
|
||||
public int dragOver(TransferContext transferContext) {
|
||||
Mark mark = (Mark)transferContext.getEnvelope().getData(TransferFormat.mark);
|
||||
BObject[] bObjectArray = mark.getValues();
|
||||
for (int i = 0; i < bObjectArray.length; ++i) {
|
||||
if (!(bObjectArray[i] instanceof BComponent)) continue;
|
||||
return 16;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public CommandArtifact drop(TransferContext transferContext) throws Exception {
|
||||
Mark mark = (Mark)transferContext.getEnvelope().getData(TransferFormat.mark);
|
||||
BObject[] bObjectArray = mark.getValues();
|
||||
ArrayList<BObject> arrayList = new ArrayList<BObject>();
|
||||
for (int i = 0; i < bObjectArray.length; ++i) {
|
||||
if (!(bObjectArray[i] instanceof BComponent) || this.model.kids.contains(bObjectArray[i])) continue;
|
||||
arrayList.add(bObjectArray[i]);
|
||||
this.model.kids.add(bObjectArray[i]);
|
||||
}
|
||||
BatchCommands.lease(arrayList.toArray(new BComponent[arrayList.size()]));
|
||||
this.sizeColumnsToFit();
|
||||
this.relayout();
|
||||
this.editor.commands.updateCommands();
|
||||
return null;
|
||||
}
|
||||
|
||||
public CommandArtifact insertTransferData(TransferContext transferContext) throws Exception {
|
||||
return this.drop(transferContext);
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
class Controller
|
||||
extends TableController {
|
||||
Controller() {
|
||||
}
|
||||
|
||||
public void keyPressed(BKeyEvent bKeyEvent) {
|
||||
if (bKeyEvent.getKeyCode() == 127) {
|
||||
bKeyEvent.consume();
|
||||
BBatchTable.this.editor.commands.clear.invoke();
|
||||
} else {
|
||||
super.keyPressed(bKeyEvent);
|
||||
}
|
||||
}
|
||||
|
||||
protected void cellPopup(BMouseEvent bMouseEvent, int n, int n2) {
|
||||
BMenu bMenu = BBatchTable.this.editor.commands.buildMenu();
|
||||
bMenu.open((BWidget)this.getTable(), bMouseEvent.getX(), bMouseEvent.getY());
|
||||
}
|
||||
|
||||
protected void backgroundPopup(BMouseEvent bMouseEvent) {
|
||||
BMenu bMenu = BBatchTable.this.editor.commands.buildMenu();
|
||||
bMenu.open((BWidget)this.getTable(), bMouseEvent.getX(), bMouseEvent.getY());
|
||||
}
|
||||
}
|
||||
|
||||
class Selection
|
||||
extends TableSelection {
|
||||
Selection() {
|
||||
}
|
||||
|
||||
public void updateTable() {
|
||||
super.updateTable();
|
||||
BBatchTable.this.editor.commands.updateCommands();
|
||||
}
|
||||
}
|
||||
|
||||
class Model
|
||||
extends TableModel {
|
||||
ArrayList cols = new ArrayList();
|
||||
ArrayList kids = new ArrayList();
|
||||
HashMap hash = new HashMap();
|
||||
|
||||
private Model() {
|
||||
this.cols.add(BBatchTable.this.lex.getText("batchEditor.object"));
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
return this.cols.size();
|
||||
}
|
||||
|
||||
public String getColumnName(int n) {
|
||||
return (String)this.cols.get(n);
|
||||
}
|
||||
|
||||
public int getRowCount() {
|
||||
return this.kids.size();
|
||||
}
|
||||
|
||||
public Object getValueAt(int n, int n2) {
|
||||
BComponent bComponent = (BComponent)this.kids.get(n);
|
||||
if (n2 == 0) {
|
||||
return SlotPath.unescape((String)bComponent.getSlotPath().getBody());
|
||||
}
|
||||
BValue bValue = bComponent.get((String)this.cols.get(n2));
|
||||
return bValue == null ? "n/a" : String.valueOf(bValue);
|
||||
}
|
||||
|
||||
public BImage getRowIcon(int n) {
|
||||
BImage bImage = (BImage)this.hash.get(this.kids.get(n));
|
||||
if (bImage == null) {
|
||||
Object e = this.kids.get(n);
|
||||
bImage = BImage.make((BIcon)((BObject)e).getIcon());
|
||||
this.hash.put(e, bImage);
|
||||
}
|
||||
return bImage;
|
||||
}
|
||||
|
||||
public String[] getAllColumns() {
|
||||
return this.getAllColumns(true);
|
||||
}
|
||||
|
||||
public String[] getAllColumns(boolean bl) {
|
||||
ArrayList<String> arrayList = new ArrayList<String>();
|
||||
for (int i = 0; i < this.kids.size(); ++i) {
|
||||
ScriptField[] scriptFieldArray = ScriptUtil.scriptFields(this.kids.get(i));
|
||||
for (int j = 0; j < scriptFieldArray.length; ++j) {
|
||||
boolean bl2;
|
||||
if (!scriptFieldArray[j].isProperty() || arrayList.contains(scriptFieldArray[j].scriptName()) || (scriptFieldArray[j].scriptFlags(this.kids.get(i)) & 1) != 0 || (scriptFieldArray[j].scriptType().getModifiers() & 0x400) != 0) continue;
|
||||
boolean bl3 = bl2 = scriptFieldArray[j].isProperty() && ((PropertyField)scriptFieldArray[j]).getProperty().isFrozen();
|
||||
if (!bl && (bl || bl2)) continue;
|
||||
arrayList.add(scriptFieldArray[j].scriptName());
|
||||
}
|
||||
}
|
||||
Object[] objectArray = arrayList.toArray(new String[arrayList.size()]);
|
||||
Arrays.sort(objectArray);
|
||||
return objectArray;
|
||||
}
|
||||
|
||||
public Class getColumnType(String string) {
|
||||
for (int i = 0; i < this.kids.size(); ++i) {
|
||||
ScriptField[] scriptFieldArray = ScriptUtil.scriptFields(this.kids.get(i));
|
||||
for (int j = 0; j < scriptFieldArray.length; ++j) {
|
||||
if (!string.equals(scriptFieldArray[j].scriptName())) continue;
|
||||
return scriptFieldArray[j].scriptType();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public BWbFieldEditor getColumnEditor(String string) {
|
||||
for (int i = 0; i < this.kids.size(); ++i) {
|
||||
ScriptField[] scriptFieldArray = ScriptUtil.scriptFields(this.kids.get(i));
|
||||
for (int j = 0; j < scriptFieldArray.length; ++j) {
|
||||
BWbFieldEditor bWbFieldEditor;
|
||||
if (!string.equals(scriptFieldArray[j].scriptName())) continue;
|
||||
Context context = null;
|
||||
BObject bObject = null;
|
||||
if (this.kids.get(i) instanceof BComponent && (bWbFieldEditor = ((BComponent)this.kids.get(i)).getSlot(scriptFieldArray[j].scriptName())) != null && bWbFieldEditor.isProperty()) {
|
||||
context = bWbFieldEditor.asProperty().getFacets();
|
||||
bObject = bWbFieldEditor.asProperty().getDefaultValue();
|
||||
}
|
||||
if (bObject == null) {
|
||||
bObject = Sys.getType((Class)scriptFieldArray[j].scriptType()).getInstance();
|
||||
}
|
||||
if ((bWbFieldEditor = BWbFieldEditor.makeFor(bObject, context)) instanceof BPermissionsMapFE && (context == null || context.getFacets().isNull())) {
|
||||
context = BBatchTable.this.editor.getCurrentContext();
|
||||
}
|
||||
bWbFieldEditor.loadValue(bObject, context);
|
||||
return bWbFieldEditor;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Model makeCopy() {
|
||||
int n;
|
||||
ArrayList<BComponent> arrayList = new ArrayList<BComponent>();
|
||||
Model model = new Model();
|
||||
for (n = 1; n < this.cols.size(); ++n) {
|
||||
model.cols.add(this.cols.get(n));
|
||||
}
|
||||
for (n = 0; n < this.kids.size(); ++n) {
|
||||
BComponent bComponent = (BComponent)this.kids.get(n);
|
||||
if (!bComponent.isMounted()) continue;
|
||||
arrayList.add(bComponent);
|
||||
model.kids.add(bComponent);
|
||||
}
|
||||
BatchCommands.lease(arrayList.toArray(new BComponent[arrayList.size()]));
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.ui.BOptionDialog
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BListDropDown
|
||||
* javax.baja.ui.BNullWidget
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.util.Lexicon
|
||||
*/
|
||||
package com.tridium.program.ui.batch;
|
||||
|
||||
import com.tridium.program.ui.batch.BBatchEditor;
|
||||
import com.tridium.ui.BOptionDialog;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BDialog;
|
||||
import javax.baja.ui.BLabel;
|
||||
import javax.baja.ui.BListDropDown;
|
||||
import javax.baja.ui.BNullWidget;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.pane.BBorderPane;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.util.Lexicon;
|
||||
|
||||
public class BRemoveDialog
|
||||
extends BOptionDialog {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$batch$BRemoveDialog == null ? (class$com$tridium$program$ui$batch$BRemoveDialog = BRemoveDialog.class$("com.tridium.program.ui.batch.BRemoveDialog")) : class$com$tridium$program$ui$batch$BRemoveDialog));
|
||||
private static Lexicon lex = Lexicon.make((String)"program");
|
||||
BListDropDown dropDown = new BListDropDown();
|
||||
static /* synthetic */ Class class$com$tridium$program$ui$batch$BRemoveDialog;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static String open(BBatchEditor bBatchEditor) {
|
||||
BRemoveDialog bRemoveDialog = new BRemoveDialog(bBatchEditor);
|
||||
bRemoveDialog.setBoundsCenteredOnOwner();
|
||||
bRemoveDialog.open();
|
||||
if (bRemoveDialog.getResult() == 1) {
|
||||
try {
|
||||
String string = (String)bRemoveDialog.dropDown.getSelectedItem();
|
||||
StringBuffer stringBuffer = new StringBuffer("remove(ord, ");
|
||||
stringBuffer.append("\"").append(string).append("\", true, true);");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BDialog.error((BWidget)bBatchEditor, (String)"Error", (Object)"Failed", (Throwable)exception);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private BRemoveDialog(BBatchEditor bBatchEditor) {
|
||||
super((BWidget)bBatchEditor, lex.getText("batchEditor.commands.slotRemove.label"), (BWidget)new BNullWidget(), 3, null, null);
|
||||
String[] stringArray = bBatchEditor.table.model.getAllColumns(false);
|
||||
for (int i = 0; i < stringArray.length; ++i) {
|
||||
this.dropDown.getList().addItem((Object)stringArray[i]);
|
||||
}
|
||||
BGridPane bGridPane = new BGridPane(2);
|
||||
bGridPane.add(null, (BValue)new BLabel(lex.getText("batchEditor.property")));
|
||||
bGridPane.add(null, (BValue)this.dropDown);
|
||||
this.setContent((BWidget)new BBorderPane((BWidget)bGridPane, 10.0, 10.0, 10.0, 10.0));
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.ui.BOptionDialog
|
||||
* javax.baja.naming.SlotPath
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BCheckBox
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BNullWidget
|
||||
* javax.baja.ui.BTextField
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.util.Lexicon
|
||||
*/
|
||||
package com.tridium.program.ui.batch;
|
||||
|
||||
import com.tridium.program.ui.batch.BBatchEditor;
|
||||
import com.tridium.ui.BOptionDialog;
|
||||
import javax.baja.naming.SlotPath;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BCheckBox;
|
||||
import javax.baja.ui.BDialog;
|
||||
import javax.baja.ui.BLabel;
|
||||
import javax.baja.ui.BNullWidget;
|
||||
import javax.baja.ui.BTextField;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.pane.BBorderPane;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.util.Lexicon;
|
||||
|
||||
public class BRenameDialog
|
||||
extends BOptionDialog {
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$batch$BRenameDialog == null ? (class$com$tridium$program$ui$batch$BRenameDialog = BRenameDialog.class$("com.tridium.program.ui.batch.BRenameDialog")) : class$com$tridium$program$ui$batch$BRenameDialog));
|
||||
private static Lexicon lex = Lexicon.make((String)"program");
|
||||
private BTextField find = new BTextField("", 30);
|
||||
private BTextField replace = new BTextField("", 30);
|
||||
private BCheckBox matchCase = new BCheckBox(lex.getText("batchEditor.matchCase"));
|
||||
private BCheckBox matchWord = new BCheckBox(lex.getText("batchEditor.matchWord"));
|
||||
static /* synthetic */ Class class$com$tridium$program$ui$batch$BRenameDialog;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static String open(BBatchEditor bBatchEditor, boolean bl) {
|
||||
BRenameDialog bRenameDialog = new BRenameDialog(bBatchEditor, bl);
|
||||
bRenameDialog.setBoundsCenteredOnOwner();
|
||||
bRenameDialog.open();
|
||||
if (bRenameDialog.getResult() == 1) {
|
||||
try {
|
||||
String string = SlotPath.escape((String)bRenameDialog.find.getText());
|
||||
String string2 = SlotPath.escape((String)bRenameDialog.replace.getText());
|
||||
StringBuffer stringBuffer = new StringBuffer(bl ? "rename" : "componentRename");
|
||||
stringBuffer.append("(ord, ");
|
||||
stringBuffer.append("\"").append(string).append("\", ");
|
||||
stringBuffer.append("\"").append(string2).append("\", ");
|
||||
stringBuffer.append(bRenameDialog.matchCase.isSelected() ? "true" : "false").append(", ");
|
||||
stringBuffer.append(bRenameDialog.matchWord.isSelected() ? "true" : "false").append(");");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BDialog.error((BWidget)bBatchEditor, (String)"Error", (Object)"Failed", (Throwable)exception);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private BRenameDialog(BBatchEditor bBatchEditor, boolean bl) {
|
||||
super((BWidget)bBatchEditor, lex.getText(bl ? "batchEditor.commands.slotRename.label" : "batchEditor.commands.rename.label"), (BWidget)new BNullWidget(), 3, null, null);
|
||||
BGridPane bGridPane = new BGridPane(2);
|
||||
bGridPane.add(null, (BValue)new BLabel(lex.getText("batchEditor.find")));
|
||||
bGridPane.add(null, (BValue)this.find);
|
||||
bGridPane.add(null, (BValue)new BLabel(lex.getText("batchEditor.replace")));
|
||||
bGridPane.add(null, (BValue)this.replace);
|
||||
BGridPane bGridPane2 = new BGridPane(1);
|
||||
bGridPane2.add(null, (BValue)this.matchCase);
|
||||
bGridPane2.add(null, (BValue)this.matchWord);
|
||||
BGridPane bGridPane3 = new BGridPane(1);
|
||||
bGridPane3.add(null, (BValue)bGridPane);
|
||||
bGridPane3.add(null, (BValue)bGridPane2);
|
||||
this.setContent((BWidget)new BBorderPane((BWidget)bGridPane3, 10.0, 10.0, 10.0, 10.0));
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.ui.BOptionDialog
|
||||
* com.tridium.ui.theme.Theme
|
||||
* javax.baja.gx.BBrush
|
||||
* javax.baja.io.ValueDocEncoder
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Slot
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BCheckBox
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BListDropDown
|
||||
* javax.baja.ui.BNullWidget
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.enums.BHalign
|
||||
* javax.baja.ui.enums.BScrollBarPolicy
|
||||
* javax.baja.ui.enums.BValign
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BEdgePane
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.ui.pane.BScrollPane
|
||||
* javax.baja.util.Lexicon
|
||||
* javax.baja.workbench.fieldeditor.BWbFieldEditor
|
||||
*/
|
||||
package com.tridium.program.ui.batch;
|
||||
|
||||
import com.tridium.program.ui.batch.BBatchEditor;
|
||||
import com.tridium.ui.BOptionDialog;
|
||||
import com.tridium.ui.theme.Theme;
|
||||
import javax.baja.gx.BBrush;
|
||||
import javax.baja.io.ValueDocEncoder;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Slot;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BCheckBox;
|
||||
import javax.baja.ui.BDialog;
|
||||
import javax.baja.ui.BLabel;
|
||||
import javax.baja.ui.BListDropDown;
|
||||
import javax.baja.ui.BNullWidget;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.enums.BHalign;
|
||||
import javax.baja.ui.enums.BScrollBarPolicy;
|
||||
import javax.baja.ui.enums.BValign;
|
||||
import javax.baja.ui.pane.BBorderPane;
|
||||
import javax.baja.ui.pane.BEdgePane;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.ui.pane.BScrollPane;
|
||||
import javax.baja.util.Lexicon;
|
||||
import javax.baja.workbench.fieldeditor.BWbFieldEditor;
|
||||
|
||||
public class BSetDialog
|
||||
extends BOptionDialog {
|
||||
public static final Action propertyChanged = BSetDialog.newAction((int)0, null, null);
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$batch$BSetDialog == null ? (class$com$tridium$program$ui$batch$BSetDialog = BSetDialog.class$("com.tridium.program.ui.batch.BSetDialog")) : class$com$tridium$program$ui$batch$BSetDialog));
|
||||
private static Lexicon lex = Lexicon.make((String)"program");
|
||||
private BBatchEditor parent;
|
||||
private BListDropDown dropDown;
|
||||
private BWbFieldEditor editor;
|
||||
private BCheckBox add;
|
||||
private BBorderPane content;
|
||||
static /* synthetic */ Class class$com$tridium$program$ui$batch$BSetDialog;
|
||||
|
||||
public void propertyChanged() {
|
||||
this.invoke(propertyChanged, null, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static String open(BBatchEditor bBatchEditor) {
|
||||
BSetDialog bSetDialog = new BSetDialog(bBatchEditor);
|
||||
bSetDialog.setBoundsCenteredOnOwner();
|
||||
bSetDialog.open();
|
||||
if (bSetDialog.getResult() == 1) {
|
||||
try {
|
||||
String string = (String)bSetDialog.dropDown.getList().getSelectedItem();
|
||||
BValue bValue = (BValue)bSetDialog.editor.saveValue();
|
||||
String string2 = ValueDocEncoder.marshal((BValue)bValue);
|
||||
string2 = string2.replaceAll("\"", "'");
|
||||
string2 = string2.replaceAll("\n", "");
|
||||
StringBuffer stringBuffer = new StringBuffer("set(ord, ");
|
||||
stringBuffer.append("\"").append(string).append("\", ");
|
||||
stringBuffer.append("\"").append(bValue.getType().getTypeSpec()).append("\", ");
|
||||
stringBuffer.append("\"").append(string2).append("\", true, true);");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BDialog.error((BWidget)bBatchEditor, (String)"Error", (Object)"Failed", (Throwable)exception);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private BSetDialog(BBatchEditor bBatchEditor) {
|
||||
super((BWidget)bBatchEditor, lex.getText("batchEditor.commands.slotEdit.label"), (BWidget)new BNullWidget(), 3, null, null);
|
||||
this.parent = bBatchEditor;
|
||||
this.editor = this.make(BComponent.TYPE);
|
||||
this.add = new BCheckBox(lex.getText("batchEditor.addIfNotExist"));
|
||||
this.add.setSelected(true);
|
||||
this.dropDown = new BListDropDown();
|
||||
String[] stringArray = bBatchEditor.table.model.getAllColumns();
|
||||
for (int i = 0; i < stringArray.length; ++i) {
|
||||
this.dropDown.getList().addItem((Object)stringArray[i]);
|
||||
}
|
||||
this.linkTo((BComponent)this.dropDown, (Slot)BListDropDown.listActionPerformed, (Slot)propertyChanged);
|
||||
BGridPane bGridPane = new BGridPane(2);
|
||||
bGridPane.setHalign(BHalign.left);
|
||||
bGridPane.add(null, (BValue)new BLabel(lex.getText("batchEditor.property")));
|
||||
bGridPane.add(null, (BValue)this.dropDown);
|
||||
BGridPane bGridPane2 = new BGridPane(1);
|
||||
bGridPane2.setValign(BValign.top);
|
||||
bGridPane2.setHalign(BHalign.left);
|
||||
this.content = new BBorderPane((BWidget)this.editor, 1.0, 1.0, 1.0, 1.0);
|
||||
bGridPane2.add(null, (BValue)this.content);
|
||||
BEdgePane bEdgePane = new BEdgePane();
|
||||
bEdgePane.setTop((BWidget)new BBorderPane((BWidget)bGridPane, 0.0, 0.0, 10.0, 0.0));
|
||||
BBrush bBrush = Theme.scrollPane().getControlBackground();
|
||||
BScrollPane bScrollPane = new BScrollPane((BWidget)new BBorderPane((BWidget)bGridPane2, lex.getText("batchEditor.newValue")));
|
||||
bScrollPane.setBorderPolicy(BScrollBarPolicy.asNeeded);
|
||||
bScrollPane.setViewportBackground(bBrush);
|
||||
bEdgePane.setCenter((BWidget)bScrollPane);
|
||||
this.setContent((BWidget)new BBorderPane((BWidget)bEdgePane, 10.0, 10.0, 10.0, 10.0));
|
||||
this.dropDown.getList().setSelectedIndex(0);
|
||||
this.doPropertyChanged();
|
||||
}
|
||||
|
||||
private BWbFieldEditor make(Type type) {
|
||||
BObject bObject = type.getInstance();
|
||||
BWbFieldEditor bWbFieldEditor = BWbFieldEditor.makeFor((BObject)bObject);
|
||||
bWbFieldEditor.loadValue(bObject);
|
||||
return bWbFieldEditor;
|
||||
}
|
||||
|
||||
public void computePreferredSize() {
|
||||
super.computePreferredSize();
|
||||
double d = Math.max(500.0, this.getPreferredWidth());
|
||||
double d2 = Math.max(300.0, this.getPreferredHeight());
|
||||
this.setPreferredSize(d, d2);
|
||||
}
|
||||
|
||||
public void doPropertyChanged() {
|
||||
try {
|
||||
String string = (String)this.dropDown.getList().getSelectedItem();
|
||||
this.editor = this.parent.table.model.getColumnEditor(string);
|
||||
this.content.setContent((BWidget)this.editor);
|
||||
this.editor.loadValue(this.editor.getCurrentValue(), this.editor.getCurrentContext());
|
||||
this.computePreferredSize();
|
||||
this.setSize(this.getPreferredWidth(), this.getPreferredHeight());
|
||||
this.setBoundsCenteredOnOwner();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,333 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.ui.BOptionDialog
|
||||
* com.tridium.workbench.util.BFlagConfig
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BIPropertyContainer
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Flags
|
||||
* javax.baja.sys.Flags$Flag
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Slot
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.ui.BCheckBox
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BLabel
|
||||
* javax.baja.ui.BListDropDown
|
||||
* javax.baja.ui.BNullWidget
|
||||
* javax.baja.ui.BRadioButton
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.CommandArtifact
|
||||
* javax.baja.ui.ToggleCommand
|
||||
* javax.baja.ui.ToggleCommandGroup
|
||||
* javax.baja.ui.enums.BHalign
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BGridPane
|
||||
* javax.baja.util.Lexicon
|
||||
*/
|
||||
package com.tridium.program.ui.batch;
|
||||
|
||||
import com.tridium.program.ui.batch.BBatchEditor;
|
||||
import com.tridium.ui.BOptionDialog;
|
||||
import com.tridium.workbench.util.BFlagConfig;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BIPropertyContainer;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Flags;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Slot;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.ui.BCheckBox;
|
||||
import javax.baja.ui.BDialog;
|
||||
import javax.baja.ui.BLabel;
|
||||
import javax.baja.ui.BListDropDown;
|
||||
import javax.baja.ui.BNullWidget;
|
||||
import javax.baja.ui.BRadioButton;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.CommandArtifact;
|
||||
import javax.baja.ui.ToggleCommand;
|
||||
import javax.baja.ui.ToggleCommandGroup;
|
||||
import javax.baja.ui.enums.BHalign;
|
||||
import javax.baja.ui.pane.BBorderPane;
|
||||
import javax.baja.ui.pane.BGridPane;
|
||||
import javax.baja.util.Lexicon;
|
||||
|
||||
public class BSetFlagsDialog
|
||||
extends BOptionDialog {
|
||||
public static final Action propertyChanged = BSetFlagsDialog.newAction((int)0, null, null);
|
||||
public static final Action useSelectionChanged = BSetFlagsDialog.newAction((int)0, null, null);
|
||||
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$program$ui$batch$BSetFlagsDialog == null ? (class$com$tridium$program$ui$batch$BSetFlagsDialog = BSetFlagsDialog.class$("com.tridium.program.ui.batch.BSetFlagsDialog")) : class$com$tridium$program$ui$batch$BSetFlagsDialog));
|
||||
private static Lexicon lex = Lexicon.make((String)"program");
|
||||
private static final FlagWrapper[] FLAGS;
|
||||
private static final Object USE_SELECTED_COMPONENTS;
|
||||
private BBatchEditor parent;
|
||||
private BListDropDown dropDown;
|
||||
private BListDropDown flagDropDown;
|
||||
private BCheckBox useSelection = new BCheckBox(lex.getText("batchEditor.setFlagsOnSelectedObjects"));
|
||||
private SetFlag setFlag;
|
||||
private RemoveFlag removeFlag;
|
||||
private Hashtable validFlags;
|
||||
static /* synthetic */ Class class$com$tridium$program$ui$batch$BSetFlagsDialog;
|
||||
|
||||
public void propertyChanged() {
|
||||
this.invoke(propertyChanged, null, null);
|
||||
}
|
||||
|
||||
public void useSelectionChanged() {
|
||||
this.invoke(useSelectionChanged, null, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static String open(BBatchEditor bBatchEditor) {
|
||||
BSetFlagsDialog bSetFlagsDialog = new BSetFlagsDialog(bBatchEditor);
|
||||
bSetFlagsDialog.setBoundsCenteredOnOwner();
|
||||
bSetFlagsDialog.open();
|
||||
if (bSetFlagsDialog.getResult() == 1) {
|
||||
try {
|
||||
boolean bl = bSetFlagsDialog.useSelection.isSelected();
|
||||
String string = bl ? "null" : (String)bSetFlagsDialog.dropDown.getList().getSelectedItem();
|
||||
int n = ((FlagWrapper)bSetFlagsDialog.flagDropDown.getList().getSelectedItem()).flag.getMask();
|
||||
boolean bl2 = bSetFlagsDialog.setFlag.isSelected();
|
||||
StringBuffer stringBuffer = new StringBuffer("setFlag(ord, ");
|
||||
stringBuffer.append("\"").append(string).append("\", ").append(n);
|
||||
stringBuffer.append(bl ? ", true" : ", false");
|
||||
stringBuffer.append(bl2 ? ", true);" : ", false);");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BDialog.error((BWidget)bBatchEditor, (String)"Error", (Object)"Failed", (Throwable)exception);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private BSetFlagsDialog(BBatchEditor bBatchEditor) {
|
||||
super((BWidget)bBatchEditor, lex.getText("batchEditor.commands.slotFlags.label"), (BWidget)new BNullWidget(), 3, null, null);
|
||||
Object object;
|
||||
Object object2;
|
||||
Object object3;
|
||||
this.useSelection.setSelected(false);
|
||||
this.linkTo((BComponent)this.useSelection, (Slot)BCheckBox.actionPerformed, (Slot)useSelectionChanged);
|
||||
int n = bBatchEditor.table.model.kids.size();
|
||||
this.validFlags = new Hashtable();
|
||||
String string = null;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
Object object4;
|
||||
Slot slot;
|
||||
Property property;
|
||||
object3 = (BComponent)bBatchEditor.table.model.kids.get(i);
|
||||
object2 = object3.getParent();
|
||||
if (object2 instanceof BComponent && (property = object3.getPropertyInParent()) != null) {
|
||||
int n2;
|
||||
slot = new BFlagConfig((BIPropertyContainer)((BComponent)object2), new Slot[]{property});
|
||||
object4 = (boolean[])this.validFlags.get(USE_SELECTED_COMPONENTS);
|
||||
if (object4 == null) {
|
||||
object4 = new boolean[FLAGS.length];
|
||||
for (n2 = 0; n2 < FLAGS.length; ++n2) {
|
||||
object4[n2] = slot.isEnabled(BSetFlagsDialog.FLAGS[n2].flag);
|
||||
}
|
||||
} else {
|
||||
for (n2 = 0; n2 < FLAGS.length; ++n2) {
|
||||
object4[n2] = object4[n2] != false && slot.isEnabled(BSetFlagsDialog.FLAGS[n2].flag);
|
||||
}
|
||||
}
|
||||
this.validFlags.put(USE_SELECTED_COMPONENTS, object4);
|
||||
}
|
||||
property = object3.getSlots();
|
||||
while (property.next()) {
|
||||
int n3;
|
||||
slot = property.slot();
|
||||
object4 = slot.getName();
|
||||
if (string == null) {
|
||||
string = object4;
|
||||
}
|
||||
BFlagConfig bFlagConfig = new BFlagConfig((BIPropertyContainer)object3, new Slot[]{slot});
|
||||
object = (boolean[])this.validFlags.get(object4);
|
||||
if (object == null) {
|
||||
object = new boolean[FLAGS.length];
|
||||
for (n3 = 0; n3 < FLAGS.length; ++n3) {
|
||||
object[n3] = bFlagConfig.isEnabled(BSetFlagsDialog.FLAGS[n3].flag);
|
||||
}
|
||||
} else {
|
||||
for (n3 = 0; n3 < FLAGS.length; ++n3) {
|
||||
object[n3] = object[n3] && bFlagConfig.isEnabled(BSetFlagsDialog.FLAGS[n3].flag);
|
||||
}
|
||||
}
|
||||
this.validFlags.put(object4, object);
|
||||
}
|
||||
}
|
||||
this.dropDown = new BListDropDown();
|
||||
ArrayList<String> arrayList = new ArrayList<String>();
|
||||
object3 = this.validFlags.keys();
|
||||
while (object3.hasMoreElements()) {
|
||||
object2 = object3.nextElement();
|
||||
if (object2 == USE_SELECTED_COMPONENTS) continue;
|
||||
arrayList.add((String)object2);
|
||||
}
|
||||
object2 = arrayList.toArray(new String[arrayList.size()]);
|
||||
Arrays.sort((Object[])object2);
|
||||
for (int i = 0; i < ((Object[])object2).length; ++i) {
|
||||
this.dropDown.getList().addItem(object2[i]);
|
||||
}
|
||||
if (((Object[])object2).length > 0) {
|
||||
this.dropDown.getList().setSelectedIndex(0);
|
||||
}
|
||||
this.linkTo((BComponent)this.dropDown, (Slot)BListDropDown.listActionPerformed, (Slot)propertyChanged);
|
||||
this.flagDropDown = new BListDropDown();
|
||||
if (string != null) {
|
||||
boolean[] blArray = (boolean[])this.validFlags.get(string);
|
||||
boolean bl = false;
|
||||
for (int i = 0; i < FLAGS.length; ++i) {
|
||||
if (!blArray[i]) continue;
|
||||
this.flagDropDown.getList().addItem((Object)FLAGS[i]);
|
||||
bl = true;
|
||||
}
|
||||
if (bl) {
|
||||
this.flagDropDown.getList().setSelectedIndex(0);
|
||||
}
|
||||
}
|
||||
BGridPane bGridPane = new BGridPane(1);
|
||||
bGridPane.setHalign(BHalign.left);
|
||||
bGridPane.add(null, (BValue)this.useSelection);
|
||||
BGridPane bGridPane2 = new BGridPane(2);
|
||||
bGridPane2.setHalign(BHalign.left);
|
||||
bGridPane2.add(null, (BValue)new BLabel(lex.getText("batchEditor.slot")));
|
||||
bGridPane2.add(null, (BValue)this.dropDown);
|
||||
bGridPane2.add(null, (BValue)new BLabel(lex.getText("batchEditor.flag")));
|
||||
bGridPane2.add(null, (BValue)this.flagDropDown);
|
||||
ToggleCommandGroup toggleCommandGroup = new ToggleCommandGroup();
|
||||
this.setFlag = new SetFlag((BWidget)this);
|
||||
toggleCommandGroup.add((ToggleCommand)this.setFlag);
|
||||
this.removeFlag = new RemoveFlag((BWidget)this);
|
||||
toggleCommandGroup.add((ToggleCommand)this.removeFlag);
|
||||
this.setFlag.setSelected(true);
|
||||
BGridPane bGridPane3 = new BGridPane(2);
|
||||
bGridPane3.setHalign(BHalign.left);
|
||||
bGridPane3.add(null, (BValue)new BRadioButton((ToggleCommand)this.setFlag));
|
||||
bGridPane3.add(null, (BValue)new BRadioButton((ToggleCommand)this.removeFlag));
|
||||
object = new BGridPane(1);
|
||||
object.setHalign(BHalign.left);
|
||||
object.add(null, (BValue)bGridPane);
|
||||
object.add(null, (BValue)bGridPane2);
|
||||
object.add(null, (BValue)bGridPane3);
|
||||
this.setContent((BWidget)new BBorderPane((BWidget)object, 10.0, 10.0, 10.0, 10.0));
|
||||
}
|
||||
|
||||
public void doPropertyChanged() {
|
||||
try {
|
||||
String string = (String)this.dropDown.getList().getSelectedItem();
|
||||
if (string == null) {
|
||||
this.flagDropDown.getList().removeAllItems();
|
||||
this.flagDropDown.getList().setSelectedIndex(0);
|
||||
return;
|
||||
}
|
||||
boolean[] blArray = (boolean[])this.validFlags.get(string);
|
||||
Object object = this.flagDropDown.getSelectedItem();
|
||||
FlagWrapper flagWrapper = null;
|
||||
this.flagDropDown.getList().removeAllItems();
|
||||
for (int i = 0; i < FLAGS.length; ++i) {
|
||||
if (!blArray[i]) continue;
|
||||
this.flagDropDown.getList().addItem((Object)FLAGS[i]);
|
||||
if (FLAGS[i] != object) continue;
|
||||
flagWrapper = FLAGS[i];
|
||||
}
|
||||
if (flagWrapper != null) {
|
||||
this.flagDropDown.getList().setSelectedItem(flagWrapper);
|
||||
} else {
|
||||
this.flagDropDown.getList().setSelectedIndex(0);
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void doUseSelectionChanged() {
|
||||
boolean bl = !this.useSelection.isSelected();
|
||||
this.dropDown.setEnabled(bl);
|
||||
if (!bl) {
|
||||
boolean[] blArray = (boolean[])this.validFlags.get(USE_SELECTED_COMPONENTS);
|
||||
Object object = this.flagDropDown.getSelectedItem();
|
||||
FlagWrapper flagWrapper = null;
|
||||
this.flagDropDown.getList().removeAllItems();
|
||||
for (int i = 0; i < FLAGS.length; ++i) {
|
||||
if (!blArray[i]) continue;
|
||||
this.flagDropDown.getList().addItem((Object)FLAGS[i]);
|
||||
if (FLAGS[i] != object) continue;
|
||||
flagWrapper = FLAGS[i];
|
||||
}
|
||||
if (flagWrapper != null) {
|
||||
this.flagDropDown.getList().setSelectedItem(flagWrapper);
|
||||
} else {
|
||||
this.flagDropDown.getList().setSelectedIndex(0);
|
||||
}
|
||||
} else {
|
||||
this.doPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
Flags.Flag[] flagArray = Flags.getFlags();
|
||||
FLAGS = new FlagWrapper[flagArray.length];
|
||||
for (int i = 0; i < flagArray.length; ++i) {
|
||||
BSetFlagsDialog.FLAGS[i] = new FlagWrapper(flagArray[i]);
|
||||
}
|
||||
USE_SELECTED_COMPONENTS = new Object();
|
||||
}
|
||||
|
||||
static class RemoveFlag
|
||||
extends ToggleCommand {
|
||||
RemoveFlag(BWidget bWidget) {
|
||||
super(bWidget, lex.getText("batchEditor.removeFlag"));
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static class SetFlag
|
||||
extends ToggleCommand {
|
||||
SetFlag(BWidget bWidget) {
|
||||
super(bWidget, lex.getText("batchEditor.setFlag"));
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static class FlagWrapper {
|
||||
Flags.Flag flag;
|
||||
|
||||
public FlagWrapper(Flags.Flag flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.flag.getDisplayName(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,441 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.bql.BSelect
|
||||
* com.tridium.bql.SelectQuery
|
||||
* com.tridium.bql.expression.BPath
|
||||
* com.tridium.workbench.bql.builder.BBqlQueryBuilder
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.collection.BITable
|
||||
* javax.baja.collection.ColumnList
|
||||
* javax.baja.gx.BInsets
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.OrdQuery
|
||||
* javax.baja.query.BExpression
|
||||
* javax.baja.query.BProjectionColumn
|
||||
* javax.baja.query.util.Columns
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BModule
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.ui.BBorder
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BMenu
|
||||
* javax.baja.ui.BSeparator
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.Command
|
||||
* javax.baja.ui.CommandArtifact
|
||||
* javax.baja.ui.commands.PasteCommand
|
||||
* javax.baja.ui.list.BCheckList
|
||||
* javax.baja.ui.pane.BBorderPane
|
||||
* javax.baja.ui.pane.BConstrainedPane
|
||||
* javax.baja.ui.transfer.BTransferWidget
|
||||
* javax.baja.util.Lexicon
|
||||
*/
|
||||
package com.tridium.program.ui.batch;
|
||||
|
||||
import com.tridium.bql.BSelect;
|
||||
import com.tridium.bql.SelectQuery;
|
||||
import com.tridium.bql.expression.BPath;
|
||||
import com.tridium.program.ui.batch.BAddDialog;
|
||||
import com.tridium.program.ui.batch.BBatchEditor;
|
||||
import com.tridium.program.ui.batch.BBatchTable;
|
||||
import com.tridium.program.ui.batch.BRemoveDialog;
|
||||
import com.tridium.program.ui.batch.BRenameDialog;
|
||||
import com.tridium.program.ui.batch.BSetDialog;
|
||||
import com.tridium.program.ui.batch.BSetFlagsDialog;
|
||||
import com.tridium.program.ui.batch.BatchCompiler;
|
||||
import com.tridium.workbench.bql.builder.BBqlQueryBuilder;
|
||||
import java.util.ArrayList;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.collection.BITable;
|
||||
import javax.baja.collection.ColumnList;
|
||||
import javax.baja.gx.BInsets;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.OrdQuery;
|
||||
import javax.baja.query.BExpression;
|
||||
import javax.baja.query.BProjectionColumn;
|
||||
import javax.baja.query.util.Columns;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BModule;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.ui.BBorder;
|
||||
import javax.baja.ui.BDialog;
|
||||
import javax.baja.ui.BMenu;
|
||||
import javax.baja.ui.BSeparator;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.Command;
|
||||
import javax.baja.ui.CommandArtifact;
|
||||
import javax.baja.ui.commands.PasteCommand;
|
||||
import javax.baja.ui.list.BCheckList;
|
||||
import javax.baja.ui.pane.BBorderPane;
|
||||
import javax.baja.ui.pane.BConstrainedPane;
|
||||
import javax.baja.ui.transfer.BTransferWidget;
|
||||
import javax.baja.util.Lexicon;
|
||||
|
||||
public class BatchCommands {
|
||||
private static BModule module = Sys.getModuleForClass((Class)(class$com$tridium$program$ui$batch$BBatchEditor == null ? (class$com$tridium$program$ui$batch$BBatchEditor = BatchCommands.class$("com.tridium.program.ui.batch.BBatchEditor")) : class$com$tridium$program$ui$batch$BBatchEditor));
|
||||
private static Lexicon lex = Lexicon.make((String)"program");
|
||||
private BBatchEditor editor;
|
||||
private BBqlQueryBuilder builder;
|
||||
FindObjects findObjects;
|
||||
Clear clear;
|
||||
ClearAll clearAll;
|
||||
SelectColumns selectCols;
|
||||
Rename rename;
|
||||
SlotAdd slotAdd;
|
||||
SlotEdit slotEdit;
|
||||
SlotRename slotRename;
|
||||
SlotRemove slotRemove;
|
||||
SlotFlags slotFlags;
|
||||
Hyperlink hyperlink;
|
||||
static /* synthetic */ Class class$com$tridium$program$ui$batch$BBatchEditor;
|
||||
|
||||
public BatchCommands(BBatchEditor bBatchEditor) {
|
||||
this.editor = bBatchEditor;
|
||||
this.findObjects = new FindObjects();
|
||||
this.clear = new Clear();
|
||||
this.clearAll = new ClearAll();
|
||||
this.selectCols = new SelectColumns();
|
||||
this.rename = new Rename();
|
||||
this.slotAdd = new SlotAdd();
|
||||
this.slotEdit = new SlotEdit();
|
||||
this.slotRename = new SlotRename();
|
||||
this.slotRemove = new SlotRemove();
|
||||
this.slotFlags = new SlotFlags();
|
||||
this.hyperlink = new Hyperlink();
|
||||
}
|
||||
|
||||
public void updateCommands() {
|
||||
boolean bl = this.editor.table.getModel().getRowCount() > 0;
|
||||
boolean bl2 = this.editor.table.getSelection().getRows().length > 0;
|
||||
boolean bl3 = this.editor.table.getSelection().getRows().length == 1;
|
||||
this.clear.setEnabled(bl && bl2);
|
||||
this.clearAll.setEnabled(bl);
|
||||
this.selectCols.setEnabled(bl);
|
||||
this.rename.setEnabled(bl);
|
||||
this.slotAdd.setEnabled(bl);
|
||||
this.slotEdit.setEnabled(bl);
|
||||
this.slotRename.setEnabled(bl);
|
||||
this.slotRemove.setEnabled(bl);
|
||||
this.slotFlags.setEnabled(bl);
|
||||
this.hyperlink.setEnabled(bl && bl3);
|
||||
}
|
||||
|
||||
public BMenu buildMenu() {
|
||||
BMenu bMenu = new BMenu(lex.getText("batchEditor"));
|
||||
bMenu.add(null, (Command)this.findObjects);
|
||||
bMenu.add(null, (Command)this.clear);
|
||||
bMenu.add(null, (Command)this.clearAll);
|
||||
bMenu.add(null, (Command)this.selectCols);
|
||||
bMenu.add(null, (BValue)new BSeparator());
|
||||
bMenu.add(null, (Command)new PasteCommand((BTransferWidget)this.editor.table));
|
||||
bMenu.add(null, (BValue)new BSeparator());
|
||||
bMenu.add(null, (Command)this.rename);
|
||||
bMenu.add(null, (Command)this.slotAdd);
|
||||
bMenu.add(null, (Command)this.slotEdit);
|
||||
bMenu.add(null, (Command)this.slotRename);
|
||||
bMenu.add(null, (Command)this.slotRemove);
|
||||
bMenu.add(null, (Command)this.slotFlags);
|
||||
bMenu.add(null, (BValue)new BSeparator());
|
||||
bMenu.add(null, (Command)this.hyperlink);
|
||||
return bMenu;
|
||||
}
|
||||
|
||||
static void lease(BComponent[] bComponentArray) {
|
||||
try {
|
||||
BComponent.lease((BComponent[])bComponentArray, (int)0, (long)60000L);
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
System.out.println("Error leasing Components...");
|
||||
throwable.printStackTrace();
|
||||
for (int i = 0; i < bComponentArray.length; ++i) {
|
||||
try {
|
||||
bComponentArray[i].lease(0, 60000L);
|
||||
continue;
|
||||
}
|
||||
catch (Throwable throwable2) {
|
||||
// empty catch block
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
class Hyperlink
|
||||
extends BatchCommand {
|
||||
public Hyperlink() {
|
||||
super("hyperlink");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
int[] nArray = ((BatchCommands)BatchCommands.this).editor.table.getSelection().getRows();
|
||||
BComponent bComponent = (BComponent)((BatchCommands)BatchCommands.this).editor.table.model.kids.get(nArray[0]);
|
||||
BOrd bOrd = BOrd.make((String)("station:|" + bComponent.getSlotPath()));
|
||||
BatchCommands.this.editor.getWbShell().hyperlink(bOrd);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class SlotFlags
|
||||
extends BatchCommand {
|
||||
public SlotFlags() {
|
||||
super("slotFlags");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
String string = BSetFlagsDialog.open(BatchCommands.this.editor);
|
||||
if (string != null) {
|
||||
try {
|
||||
BatchCompiler batchCompiler = new BatchCompiler(BatchCommands.this.editor, string);
|
||||
batchCompiler.compile();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BDialog.error((BWidget)BatchCommands.this.editor, (String)"Error", (Object)"Commit Failed", (Throwable)exception);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class SlotRemove
|
||||
extends BatchCommand {
|
||||
public SlotRemove() {
|
||||
super("slotRemove");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
String string = BRemoveDialog.open(BatchCommands.this.editor);
|
||||
if (string != null) {
|
||||
try {
|
||||
BatchCompiler batchCompiler = new BatchCompiler(BatchCommands.this.editor, string);
|
||||
batchCompiler.compile();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BDialog.error((BWidget)BatchCommands.this.editor, (String)"Error", (Object)"Commit Failed", (Throwable)exception);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class SlotRename
|
||||
extends BatchCommand {
|
||||
public SlotRename() {
|
||||
super("slotRename");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
String string = BRenameDialog.open(BatchCommands.this.editor, true);
|
||||
if (string != null) {
|
||||
try {
|
||||
BatchCompiler batchCompiler = new BatchCompiler(BatchCommands.this.editor, string);
|
||||
batchCompiler.compile();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BDialog.error((BWidget)BatchCommands.this.editor, (String)"Error", (Object)"Commit Failed", (Throwable)exception);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class SlotEdit
|
||||
extends BatchCommand {
|
||||
public SlotEdit() {
|
||||
super("slotEdit");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
String string = BSetDialog.open(BatchCommands.this.editor);
|
||||
if (string != null) {
|
||||
try {
|
||||
BatchCompiler batchCompiler = new BatchCompiler(BatchCommands.this.editor, string);
|
||||
batchCompiler.compile();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BDialog.error((BWidget)BatchCommands.this.editor, (String)"Error", (Object)"Commit Failed", (Throwable)exception);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class SlotAdd
|
||||
extends BatchCommand {
|
||||
public SlotAdd() {
|
||||
super("slotAdd");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
String string = BAddDialog.open(BatchCommands.this.editor);
|
||||
if (string != null) {
|
||||
try {
|
||||
BatchCompiler batchCompiler = new BatchCompiler(BatchCommands.this.editor, string);
|
||||
batchCompiler.compile();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BDialog.error((BWidget)BatchCommands.this.editor, (String)"Error", (Object)"Commit Failed", (Throwable)exception);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class Rename
|
||||
extends BatchCommand {
|
||||
public Rename() {
|
||||
super("rename");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
String string = BRenameDialog.open(BatchCommands.this.editor, false);
|
||||
if (string != null) {
|
||||
try {
|
||||
BatchCompiler batchCompiler = new BatchCompiler(BatchCommands.this.editor, string);
|
||||
batchCompiler.compile();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BDialog.error((BWidget)BatchCommands.this.editor, (String)"Error", (Object)"Commit Failed", (Throwable)exception);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class SelectColumns
|
||||
extends BatchCommand {
|
||||
public SelectColumns() {
|
||||
super("selectColumns");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
int n;
|
||||
BBatchTable.Model model = ((BatchCommands)BatchCommands.this).editor.table.model;
|
||||
BCheckList bCheckList = new BCheckList();
|
||||
String[] stringArray = model.getAllColumns();
|
||||
for (n = 0; n < stringArray.length; ++n) {
|
||||
bCheckList.getModel().addItem((Object)stringArray[n]);
|
||||
}
|
||||
for (n = 1; n < model.cols.size(); ++n) {
|
||||
int n2 = bCheckList.indexOfItem(model.cols.get(n));
|
||||
if (n2 < 0) continue;
|
||||
bCheckList.getSelection().select(n2);
|
||||
}
|
||||
BConstrainedPane bConstrainedPane = new BConstrainedPane((BWidget)new BBorderPane((BWidget)bCheckList, BBorder.inset, BInsets.make((double)0.0, (double)0.0, (double)0.0, (double)0.0)));
|
||||
bConstrainedPane.setMinWidth(300.0);
|
||||
bConstrainedPane.setMaxWidth(300.0);
|
||||
bConstrainedPane.setMinHeight(300.0);
|
||||
bConstrainedPane.setMaxHeight(400.0);
|
||||
if (1 == BDialog.open((BWidget)BatchCommands.this.editor, (String)lex.getText("batchEditor.commands.selectColumns.label"), (Object)bConstrainedPane, (int)3)) {
|
||||
String string = (String)((BatchCommands)BatchCommands.this).editor.table.model.cols.get(0);
|
||||
model.cols.clear();
|
||||
model.cols.add(string);
|
||||
int[] nArray = bCheckList.getSelection().getItems();
|
||||
for (int i = 0; i < nArray.length; ++i) {
|
||||
model.cols.add(bCheckList.getItem(nArray[i]));
|
||||
}
|
||||
((BatchCommands)BatchCommands.this).editor.table.sizeColumnsToFit();
|
||||
((BatchCommands)BatchCommands.this).editor.table.relayout();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class ClearAll
|
||||
extends BatchCommand {
|
||||
public ClearAll() {
|
||||
super("clearAll");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
while (!((BatchCommands)BatchCommands.this).editor.table.model.kids.isEmpty()) {
|
||||
((BatchCommands)BatchCommands.this).editor.table.model.kids.remove(0);
|
||||
}
|
||||
BatchCommands.this.updateCommands();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class Clear
|
||||
extends BatchCommand {
|
||||
public Clear() {
|
||||
super("clear");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
int[] nArray = ((BatchCommands)BatchCommands.this).editor.table.getSelection().getRows();
|
||||
((BatchCommands)BatchCommands.this).editor.table.getSelection().deselectAll();
|
||||
for (int i = 0; i < nArray.length; ++i) {
|
||||
((BatchCommands)BatchCommands.this).editor.table.getSelection().deselectAll();
|
||||
((BatchCommands)BatchCommands.this).editor.table.model.kids.remove(nArray[i] - i);
|
||||
}
|
||||
BatchCommands.this.updateCommands();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class FindObjects
|
||||
extends BatchCommand {
|
||||
public FindObjects() {
|
||||
super("findObjects");
|
||||
}
|
||||
|
||||
public CommandArtifact doInvoke() {
|
||||
BOrd bOrd;
|
||||
if (BatchCommands.this.builder == null) {
|
||||
BatchCommands.this.builder = new BBqlQueryBuilder((BObject)((BatchCommands)BatchCommands.this).editor.service, BOrd.NULL, false);
|
||||
}
|
||||
if ((bOrd = BatchCommands.this.builder.open((BWidget)BatchCommands.this.editor)) != null && !bOrd.isNull()) {
|
||||
OrdQuery[] ordQueryArray = bOrd.parse();
|
||||
SelectQuery selectQuery = (SelectQuery)ordQueryArray[ordQueryArray.length - 1];
|
||||
BSelect bSelect = selectQuery.getSelect();
|
||||
BPath bPath = new BPath("toPathString");
|
||||
if (bSelect.hasProjection() && bSelect.getProjection().isDistinct()) {
|
||||
bSelect.select(Columns.distinctProjection().add(Columns.make((BExpression)bPath)));
|
||||
} else {
|
||||
bSelect.select(Columns.projection((BProjectionColumn)Columns.make((BExpression)bPath)));
|
||||
}
|
||||
ordQueryArray[ordQueryArray.length - 1] = new SelectQuery(bSelect);
|
||||
bOrd = BOrd.make((OrdQuery[])ordQueryArray);
|
||||
BICollection bICollection = (BICollection)bOrd.resolve((BObject)((BatchCommands)BatchCommands.this).editor.service).get();
|
||||
BITable bITable = bICollection.toTable();
|
||||
ColumnList columnList = bITable.getColumns();
|
||||
ArrayList<BObject> arrayList = new ArrayList<BObject>();
|
||||
for (int i = 0; i < bITable.size(); ++i) {
|
||||
BOrd bOrd2 = BOrd.make((String)("station:|slot:" + bITable.get(i, columnList.get(0))));
|
||||
bOrd2 = BOrd.make((BOrd)BatchCommands.this.editor.getWbShell().getActiveOrd(), (BOrd)bOrd2).normalize();
|
||||
BObject bObject = bOrd2.resolve().get();
|
||||
if (!(bObject instanceof BComponent) || ((BatchCommands)BatchCommands.this).editor.table.model.kids.contains(bObject)) continue;
|
||||
arrayList.add(bObject);
|
||||
((BatchCommands)BatchCommands.this).editor.table.model.kids.add(bObject);
|
||||
}
|
||||
BatchCommands.lease(arrayList.toArray(new BComponent[arrayList.size()]));
|
||||
((BatchCommands)BatchCommands.this).editor.table.sizeColumnsToFit();
|
||||
((BatchCommands)BatchCommands.this).editor.table.relayout();
|
||||
BatchCommands.this.updateCommands();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class BatchCommand
|
||||
extends Command {
|
||||
public BatchCommand(String string) {
|
||||
super((BWidget)BatchCommands.this.editor, module, "batchEditor.commands." + string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.workbench.console.BConsole
|
||||
* com.tridium.workbench.shell.BNiagaraWbShell
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.ui.BDialog
|
||||
* javax.baja.ui.BWidget
|
||||
* javax.baja.ui.pane.BTextEditorPane
|
||||
* javax.baja.ui.text.BTextEditor
|
||||
*/
|
||||
package com.tridium.program.ui.batch;
|
||||
|
||||
import com.tridium.program.BCode;
|
||||
import com.tridium.program.BRobotCode;
|
||||
import com.tridium.program.BRobotResult;
|
||||
import com.tridium.program.ui.Compiler;
|
||||
import com.tridium.program.ui.batch.BBatchEditor;
|
||||
import com.tridium.workbench.console.BConsole;
|
||||
import com.tridium.workbench.shell.BNiagaraWbShell;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.ui.BDialog;
|
||||
import javax.baja.ui.BWidget;
|
||||
import javax.baja.ui.pane.BTextEditorPane;
|
||||
import javax.baja.ui.text.BTextEditor;
|
||||
|
||||
class BatchCompiler
|
||||
extends Compiler {
|
||||
private BBatchEditor editor;
|
||||
private String method;
|
||||
private BRobotCode code = new BRobotCode();
|
||||
String source;
|
||||
|
||||
BatchCompiler(BBatchEditor bBatchEditor, String string) {
|
||||
super((BWidget)bBatchEditor);
|
||||
this.editor = bBatchEditor;
|
||||
this.method = string;
|
||||
}
|
||||
|
||||
public void generateCode(String string) throws Exception {
|
||||
String string2 = "import java.util.*;\nimport javax.baja.data.*;\nimport javax.baja.io.*;\nimport javax.baja.naming.*;\nimport javax.baja.sys.*;\nimport javax.baja.util.*;\nimport com.tridium.program.*;\nimport com.tridium.program.ui.batch.*;\n\npublic class " + string + "\n" + " extends BatchRobot\n" + "{\n" + "\n" + " public void run()\n" + " throws Exception\n" + " {\n" + " for (int i=0; i<ords.length; i++)\n" + " {\n" + " BOrd ord = BOrd.make(ords[i]);\n";
|
||||
string2 = string2 + this.method + "\n";
|
||||
string2 = string2 + " }\n }\n\n String[] ords = {\n";
|
||||
int n = this.editor.table.model.getRowCount();
|
||||
for (int i = 0; i < n; ++i) {
|
||||
BComponent bComponent = (BComponent)this.editor.table.model.kids.get(i);
|
||||
string2 = string2 + " \"station:|slot:" + bComponent.getSlotPath().getBody() + "\"";
|
||||
if (i < n - 1) {
|
||||
string2 = string2 + ",";
|
||||
}
|
||||
string2 = string2 + "\n";
|
||||
}
|
||||
this.source = string2 = string2 + " };\n}\n";
|
||||
}
|
||||
|
||||
public void compile() throws Exception {
|
||||
String string = BCode.generateClassName();
|
||||
this.generateCode(string);
|
||||
this.code.setDependencies("baja;program");
|
||||
this.compile(string, this.code, this.source);
|
||||
}
|
||||
|
||||
public BConsole openConsole() {
|
||||
return ((BNiagaraWbShell)this.editor.getShell()).getConsole();
|
||||
}
|
||||
|
||||
public void compileSuccess(BConsole bConsole) throws Exception {
|
||||
super.compileSuccess(bConsole);
|
||||
this.run();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
BRobotResult bRobotResult = this.editor.service.runRobot(this.code);
|
||||
this.editor.table.refresh();
|
||||
BTextEditor bTextEditor = new BTextEditor(bRobotResult.getLog(), false);
|
||||
BTextEditorPane bTextEditorPane = new BTextEditorPane(bTextEditor, 20, 100);
|
||||
BDialog.open((BWidget)this.editor, (String)"BatchEditor Results", (Object)bTextEditorPane, (int)1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user