home *** CD-ROM | disk | FTP | other *** search
- import java.awt.BorderLayout;
- import java.awt.Button;
- import java.awt.CardLayout;
- import java.awt.CheckboxMenuItem;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Event;
- import java.awt.FileDialog;
- import java.awt.FlowLayout;
- import java.awt.Frame;
- import java.awt.GridBagConstraints;
- import java.awt.GridBagLayout;
- import java.awt.GridLayout;
- import java.awt.Insets;
- import java.awt.Label;
- import java.awt.Menu;
- import java.awt.MenuBar;
- import java.awt.MenuItem;
- import java.awt.Panel;
- import java.awt.TextArea;
- import java.awt.TextField;
- import java.awt.Window;
- import stardiv.tools.SjProtocolWindow;
-
- public class JScriptIDEWindow extends Frame {
- private static final int IDE_EDIT_STATE = 0;
- private static final int IDE_DEBUG_STATE = 1;
- private static final int IDE_RUN_STATE = 2;
- private static final int IDE_COMPILE_STATE = 3;
- private static final String MENU_FILE_NEW = "New";
- private static final String MENU_FILE_OPEN = "Open";
- private static final String MENU_FILE_SAVE = "Save";
- private static final String MENU_FILE_SAVE_AS = "Save as";
- private static final String MENU_FILE_CLOSE = "Close";
- private static final String MENU_FILE_CLOSE_ALL = "Close all";
- private static final String MENU_FILE_EXIT = "Exit";
- private static final String MENU_DEBUGGER_CLEAR_ALL = "Clear all breakpoints (in act. codeblock)";
- private static final String MENU_BROWSER_GLOBAL = "Global";
- private static final String MENU_BROWSER_LOCAL = "Local";
- private static final String MENU_BROWSER_SPECIAL = "Special";
- private static final String MENU_BROWSER_REMOVE_ALL_WATCHES = "Remove all watches";
- private static final String MENU_BROWSER_ENABLE = "enable";
- private static final String BROWSER_NAME = "Browser ";
- private static final String MODULE_MAIN_CODE_NAME = "(main)";
- private static final String PCODE_NAME = " PCode ";
- private static final String NEW_MODULE_NAME = "Module";
- private static int NewModuleCount;
- private static final String SPACE_FOR_LAYOUT = " ";
- private JScriptManager rJSManager;
- private int nState;
- private String aFunctionName;
- private JScriptCodeBlock aActCodeBlock;
- private JScriptModule aActModule;
- int[] nStartPCodePos;
- private boolean bSourceChanged;
- private boolean bNeedCompile;
- private boolean bIDEOpen;
- private boolean bLineNumbersOn;
- private String aOldSourceTemp;
- private static boolean bWithMenu = true;
- SJIDETextArea aSourceEdit;
- SJIDETextArea aPCodeEdit;
- SJIDETextArea aExprStackEdit;
- SJIDETextArea aCallLevelStackEdit;
- SJIDETextArea aBrowserEdit;
- SJIDETextArea aWatchEdit;
- SJIDETextArea aOutputEdit;
- TextField aBrowserEditField;
- Button ButDoIt;
- Button ButAddWatch;
- Button ButSetVariable;
- Button ButAddBreakpoint;
- Label aJavaEnvText;
- Button ButToCallLevelStack;
- Button ButToExprStack;
- Button ButToNext;
- Panel aCardPanel;
- CardLayout aStackCardLayout;
- Label aActModuleName;
- Label aActPCodeName;
- Label aShowStatusText;
- Label aShowStatus;
- Label aBrowserName;
- Panel aPCodePanel;
- Button ButClearOutput;
- Button ButClearAllWatches;
- Button ButNextPCodeFcn;
- Button ButNextBrowserMode;
- Button ButRunModule;
- Button ButStartDebugger;
- Button ButCompile;
- Button ButRTReset;
- Button ButToggleLineNumbers;
- Button ButStopDebugger;
- Button ButListThreads;
- Button ButKillAllThreads;
- Button ButUpdateBrowser;
- Button ButStart;
- Button ButRun;
- Button ButStepOver;
- Button ButStepOut;
- Button ButStep;
- Button ButPCodeStep;
- Button ButPCodeStepOver;
- Button ButBreak;
- Button ButReset;
- Button ButTest;
- MenuBar aMainMenu;
- Menu aFileMenu;
- MenuItem aFileOpen;
- MenuItem aFileNew;
- MenuItem aFileSave;
- MenuItem aFileSaveAs;
- MenuItem aFileClose;
- MenuItem aFileCloseAll;
- MenuItem aFileExit;
- Menu aDebuggerMenu;
- MenuItem aDebuggerClearAll;
- Menu aCompilerMenu;
- Menu aBrowserMenu;
- MenuItem aBrowserGlobal;
- MenuItem aBrowserLocal;
- MenuItem aBrowserSpecial;
- CheckboxMenuItem aBrowserEnable;
- Menu aOptionsMenu;
- Menu aModulesMenu;
- Menu aFunctionsMenu;
- Menu aManagerMenu;
- Menu aHelpMenu;
-
- public TextArea GetOutputField() {
- return this.aOutputEdit;
- }
-
- public JScriptIDEWindow(JScriptManager var1) {
- this(var1, false);
- }
-
- public JScriptIDEWindow(JScriptManager var1, boolean var2) {
- super("(Star)JavaScript-IDE");
- this.rJSManager = var1;
- this.bSourceChanged = false;
- this.bNeedCompile = false;
- this.bIDEOpen = false;
- this.bLineNumbersOn = false;
- NewModuleCount = 0;
- this.aActCodeBlock = null;
- this.aActModule = null;
- this.aFunctionName = "(main)";
- this.nState = 0;
- ((Frame)this).setResizable(true);
- this.CreateIDEMenu();
- ((Container)this).setLayout(new BorderLayout());
- this.DoNewLayout(var2);
- }
-
- public final void SetJScriptManager(JScriptManager var1) {
- this.rJSManager = var1;
- this.UpDateIDE();
- }
-
- public final void StartIDE() {
- ((Window)this).show();
- this.bIDEOpen = true;
- this.EnterEditState();
- this.UpDateIDE();
- }
-
- public final synchronized void CloseIDE() {
- ((Component)this).hide();
- ((Frame)this).dispose();
- this.NotifyIDEClosed();
- }
-
- private final synchronized void CloseAndExit() {
- ((Component)this).hide();
- ((Frame)this).dispose();
- this.NotifyIDEClosed();
- if (this.rJSManager.IsSysExitAllowed()) {
- System.exit(0);
- }
-
- }
-
- private final synchronized void NotifyIDEClosed() {
- this.bIDEOpen = false;
- SjProtocolWindow.AddNotifyEvent(this, "JScritpIDEWindow.NotifyIDEClosed()");
- this.notifyAll();
- SjProtocolWindow.AddNotifyEventDONE(this, "JScritpIDEWindow.NotifyIDEClosed()");
- }
-
- public final synchronized void WaitForIDEClosed() {
- try {
- while(this.bIDEOpen) {
- SjProtocolWindow.AddWaitEvent(this, "JScritpIDEWindow.WaitForIDEClosed()");
- this.wait();
- SjProtocolWindow.AddWaitEventDONE(this, "JScritpIDEWindow.WaitForIDEClosed()");
- }
-
- } catch (InterruptedException var1) {
- }
- }
-
- private final void DoNewLayout(boolean var1) {
- int var2 = 0;
- this.aSourceEdit = new SJIDETextArea("", 20, 60, true);
- this.aPCodeEdit = new SJIDETextArea("", 8, 30);
- this.aExprStackEdit = new SJIDETextArea("", 6, 30);
- this.aCallLevelStackEdit = new SJIDETextArea("", 6, 30);
- this.aBrowserEdit = new SJIDETextArea("", 5, 40);
- this.aWatchEdit = new SJIDETextArea("", 5, 40);
- this.aOutputEdit = new SJIDETextArea("", 4, 80);
- GridBagLayout var3 = new GridBagLayout();
- GridBagConstraints var4 = new GridBagConstraints();
- var4.anchor = 10;
- var4.fill = 1;
- var4.gridheight = 1;
- var4.gridwidth = 1;
- var4.weightx = (double)1.0F;
- var4.weighty = (double)1.0F;
- var4.insets = new Insets(0, 0, 0, 4);
- Panel var5 = new Panel();
- ((Container)var5).setLayout(var3);
- Panel var6 = new Panel();
- ((Container)var6).setLayout(new BorderLayout());
- this.aActModuleName = new Label("Quelltext");
- ((Container)var6).add("North", this.aActModuleName);
- ((Container)var6).add("Center", this.aSourceEdit);
- var4.gridx = 0;
- var4.gridy = var2;
- var4.gridheight = 2;
- var4.gridwidth = -1;
- var3.setConstraints(var6, var4);
- this.aPCodePanel = new Panel();
- this.aPCodePanel.setLayout(new BorderLayout());
- Panel var7 = new Panel();
- ((Container)var7).setLayout(new FlowLayout(0));
- this.aActPCodeName = new Label(" PCode ");
- this.ButNextPCodeFcn = new Button("next");
- ((Container)var7).add(this.ButNextPCodeFcn);
- ((Container)var7).add(this.aActPCodeName);
- this.aPCodePanel.add("North", var7);
- this.aPCodePanel.add("Center", this.aPCodeEdit);
- this.ButToCallLevelStack = new Button("to CallLevel");
- this.ButToExprStack = new Button("to Expr");
- Panel var8 = new Panel();
- this.aCardPanel = var8;
- ((Container)var8).setLayout(this.aStackCardLayout = new CardLayout());
- Panel var9 = new Panel();
- ((Container)var9).setLayout(new BorderLayout());
- Panel var10 = new Panel();
- ((Container)var10).setLayout(new FlowLayout(0));
- ((Container)var10).add(this.ButToCallLevelStack);
- ((Container)var10).add(new Label("Expression-Stack"));
- ((Container)var9).add("North", var10);
- ((Container)var9).add("Center", this.aExprStackEdit);
- Panel var11 = new Panel();
- ((Container)var11).setLayout(new BorderLayout());
- Panel var12 = new Panel();
- ((Container)var12).setLayout(new FlowLayout(0));
- ((Container)var12).add(this.ButToExprStack);
- ((Container)var12).add(new Label("Call-Level-Stack"));
- ((Container)var11).add("North", var12);
- ((Container)var11).add("Center", this.aCallLevelStackEdit);
- ((Container)var8).add(var11);
- ((Container)var8).add(var9);
- var4.gridheight = 1;
- var4.gridx = 1;
- var4.gridy = var2;
- var4.gridwidth = 0;
- ++var2;
- var3.setConstraints(this.aPCodePanel, var4);
- var4.gridx = 1;
- var4.gridy = var2;
- var3.setConstraints(var8, var4);
- ++var2;
- Panel var13 = new Panel();
- ((Container)var13).setLayout(new BorderLayout());
- Panel var14 = new Panel();
- ((Container)var14).setLayout(new FlowLayout(0));
- ((Container)var14).add(this.ButNextBrowserMode = new Button("next"));
- ((Container)var14).add(this.aBrowserName = new Label("Browser "));
- ((Container)var13).add("North", var14);
- ((Container)var13).add("Center", this.aBrowserEdit);
- var4.gridx = 0;
- var4.gridy = var2;
- var4.gridwidth = -1;
- var3.setConstraints(var13, var4);
- Panel var15 = new Panel();
- ((Container)var15).setLayout(new BorderLayout());
- Panel var16 = new Panel();
- ((Container)var16).setLayout(new FlowLayout(0));
- ((Container)var16).add(new Label("Watch"));
- ((Container)var16).add(this.ButClearAllWatches = new Button("Clear All"));
- ((Container)var15).add("North", var16);
- ((Container)var15).add("Center", this.aWatchEdit);
- var4.gridx = 1;
- var4.gridy = var2;
- var4.gridwidth = 0;
- var3.setConstraints(var15, var4);
- ++var2;
- Panel var17 = new Panel();
- ((Container)var17).setLayout(new BorderLayout());
- Panel var18 = new Panel();
- ((Container)var18).setLayout(new FlowLayout(0));
- ((Container)var18).add(new Label("Output"));
- ((Container)var18).add(this.ButClearOutput = new Button("Clear"));
- ((Container)var17).add("North", var18);
- ((Container)var17).add("Center", this.aOutputEdit);
- var4.gridx = 0;
- var4.gridy = var2;
- var4.gridwidth = 0;
- var3.setConstraints(var17, var4);
- ++var2;
- ((Container)var5).add(var6);
- ((Container)var5).add(this.aPCodePanel);
- ((Container)var5).add(var8);
- ((Container)var5).add(var13);
- ((Container)var5).add(var15);
- ((Container)var5).add(var17);
- Panel var19 = new Panel();
- ((Container)var19).setLayout(new FlowLayout(0));
- this.aBrowserEditField = new TextField(15);
- this.ButDoIt = new Button("browse it");
- this.ButAddWatch = new Button("add watch");
- this.ButSetVariable = new Button("set var");
- this.ButAddBreakpoint = new Button("add breakpoint");
- this.aJavaEnvText = new Label("init init init init init init init init init init");
- var4.gridx = 0;
- var4.gridy = var2;
- var4.gridwidth = 0;
- var3.setConstraints(var19, var4);
- ++var2;
- ((Container)var19).add(new Label("enter:"));
- ((Container)var19).add(this.aBrowserEditField);
- ((Container)var19).add(this.ButDoIt);
- ((Container)var19).add(this.ButAddWatch);
- ((Container)var19).add(this.ButSetVariable);
- ((Container)var19).add(this.ButAddBreakpoint);
- ((Container)var19).add(this.aJavaEnvText);
- ((Container)var5).add(var19);
- var4.weightx = (double)0.0F;
- var4.weighty = (double)0.0F;
- this.ButRunModule = new Button("Run Module");
- this.ButStartDebugger = new Button("START Debugger");
- this.ButStopDebugger = new Button("STOP Debugger");
- this.ButListThreads = new Button("List Threads");
- this.ButKillAllThreads = new Button("Kill all Threads");
- this.ButTest = new Button("TEST");
- this.ButCompile = new Button("Compile");
- this.ButRTReset = new Button("RTI Reset");
- this.ButToggleLineNumbers = new Button("toggle line#");
- this.ButStart = new Button("Start");
- this.ButRun = new Button("Run");
- this.ButUpdateBrowser = new Button("Update Browser");
- this.ButStep = new Button("Step");
- this.ButStepOver = new Button("Step over");
- this.ButStepOut = new Button("Step out");
- this.ButPCodeStep = new Button("P-Code-Step");
- this.ButPCodeStepOver = new Button("P-Code-Step over");
- this.ButBreak = new Button("Break");
- this.ButReset = new Button("Reset");
- Panel var20 = new Panel();
- Panel var21 = new Panel();
- ((Container)var21).setLayout(new FlowLayout(0));
- this.aShowStatusText = new Label("status:");
- this.aShowStatus = new Label("IDE started...");
- ((Container)var21).add(this.ButRunModule);
- ((Container)var21).add(this.ButCompile);
- ((Container)var21).add(this.ButRTReset);
- ((Container)var21).add(this.ButToggleLineNumbers);
- ((Container)var21).add(this.ButListThreads);
- ((Container)var21).add(this.ButKillAllThreads);
- ((Container)var21).add(this.ButTest);
- ((Container)var21).add(this.aShowStatusText);
- ((Container)var21).add(this.aShowStatus);
- var4.gridx = 0;
- var4.gridy = var2;
- var3.setConstraints(var21, var4);
- ((Container)var5).add(var21);
- ++var2;
- ((Container)var20).setLayout(new GridLayout(2, 5));
- ((Container)var20).add(this.ButStartDebugger);
- ((Container)var20).add(this.ButStopDebugger);
- ((Container)var20).add(this.ButUpdateBrowser);
- ((Container)var20).add(this.ButRun);
- ((Container)var20).add(this.ButBreak);
- ((Container)var20).add(this.ButReset);
- ((Container)var20).add(this.ButStepOver);
- ((Container)var20).add(this.ButStepOut);
- ((Container)var20).add(this.ButStep);
- ((Container)var20).add(this.ButPCodeStep);
- ((Container)var20).add(this.ButPCodeStepOver);
- var4.gridx = 0;
- var4.gridy = var2;
- var3.setConstraints(var20, var4);
- ((Container)var5).add(var20);
- ++var2;
- if (var1) {
- Panel var22 = new Panel();
- ((Container)var22).setLayout(new FlowLayout(0));
- ((Container)var22).add(new Label("Applet Warning Hack"));
- var4.gridx = 0;
- var4.gridy = var2;
- var3.setConstraints(var22, var4);
- ((Container)var5).add(var22);
- ++var2;
- }
-
- ((Container)this).add("Center", var5);
- ((Window)this).pack();
- }
-
- private void CreateIDEMenu() {
- if (bWithMenu) {
- this.aMainMenu = new MenuBar();
- this.aFileMenu = new Menu("File");
- this.aMainMenu.add(this.aFileMenu);
- this.aFileMenu.add(this.aFileOpen = new MenuItem("Open"));
- this.aFileMenu.add(this.aFileNew = new MenuItem("New"));
- this.aFileMenu.add(this.aFileSave = new MenuItem("Save"));
- this.aFileMenu.add(this.aFileSaveAs = new MenuItem("Save as"));
- this.aFileMenu.add(this.aFileClose = new MenuItem("Close"));
- this.aFileMenu.add(this.aFileCloseAll = new MenuItem("Close all"));
- this.aFileMenu.addSeparator();
- this.aFileMenu.add(this.aFileExit = new MenuItem("Exit"));
- this.aCompilerMenu = new Menu("Compiler");
- this.aMainMenu.add(this.aCompilerMenu);
- this.aDebuggerMenu = new Menu("Debugger");
- this.aDebuggerMenu.add(this.aDebuggerClearAll = new MenuItem("Clear all breakpoints (in act. codeblock)"));
- this.aMainMenu.add(this.aDebuggerMenu);
- this.aBrowserMenu = new Menu("Browser");
- this.aBrowserMenu.add(this.aBrowserGlobal = new MenuItem("Global"));
- this.aBrowserMenu.add(this.aBrowserLocal = new MenuItem("Local"));
- this.aBrowserMenu.add(this.aBrowserSpecial = new MenuItem("Special"));
- this.aBrowserMenu.addSeparator();
- this.aBrowserMenu.add(this.aBrowserSpecial = new MenuItem("Remove all watches"));
- this.aBrowserMenu.addSeparator();
- this.aBrowserMenu.add(this.aBrowserEnable = new CheckboxMenuItem("enable"));
- this.aBrowserEnable.setState(true);
- this.aMainMenu.add(this.aBrowserMenu);
- this.aOptionsMenu = new Menu("Options");
- this.aMainMenu.add(this.aOptionsMenu);
- this.aModulesMenu = new Menu("Modules");
- this.aMainMenu.add(this.aModulesMenu);
- this.aFunctionsMenu = new Menu("Functions");
- this.aMainMenu.add(this.aFunctionsMenu);
- this.aManagerMenu = new Menu("Managers");
- this.aMainMenu.add(this.aManagerMenu);
- this.aHelpMenu = new Menu("Help");
- this.aHelpMenu.add(new MenuItem("Version: 12.12.1996"));
- this.aMainMenu.add(this.aHelpMenu);
- ((Frame)this).setMenuBar(this.aMainMenu);
- }
-
- }
-
- public Insets insets() {
- return bWithMenu ? new Insets(40, 10, 5, 5) : new Insets(20, 10, 5, 5);
- }
-
- private boolean HandleAction(Event var1) {
- if (bWithMenu && var1.id == 1001) {
- if ((String)var1.arg == "New") {
- this.NewModule();
- return true;
- }
-
- if ((String)var1.arg == "Open") {
- this.LoadFile();
- return true;
- }
-
- if ((String)var1.arg == "Save") {
- this.SaveFile();
- return true;
- }
-
- if ((String)var1.arg == "Save as") {
- this.SaveFileAs();
- return true;
- }
-
- if ((String)var1.arg == "Close") {
- this.rJSManager.DeleteModule(this.rJSManager.GetActModule());
- this.UpDateIDE();
- return true;
- }
-
- if ((String)var1.arg == "Close all") {
- this.rJSManager.DeleteAllModules();
- this.UpDateIDE();
- return true;
- }
-
- if ((String)var1.arg == "Exit") {
- this.CloseAndExit();
- return true;
- }
-
- if ((String)var1.arg == "Clear all breakpoints (in act. codeblock)") {
- if (this.aActCodeBlock != null) {
- this.aActCodeBlock.ClearAllBreakPoints();
- this.SetCodeBlock(this.aActCodeBlock);
- this.ShowStatus("cleared all breakpoints");
- } else {
- this.ShowStatus("nothing to do");
- }
-
- return true;
- }
-
- if ((String)var1.arg == "Global") {
- this.rJSManager.Browser_SetMode(0);
- this.UpDateIDE();
- return true;
- }
-
- if ((String)var1.arg == "Local") {
- this.rJSManager.Browser_SetMode(1);
- this.UpDateIDE();
- return true;
- }
-
- if ((String)var1.arg == "Special") {
- this.rJSManager.Browser_SetSpecialName(this.aBrowserEditField.getText());
- this.rJSManager.Browser_SetMode(2);
- this.UpDateIDE();
- return true;
- }
-
- if ((String)var1.arg == "Remove all watches") {
- this.rJSManager.Browser_RemoveAllWatches();
- this.UpDateIDE();
- return true;
- }
-
- if ((String)var1.arg == "enable") {
- if (!this.aBrowserEnable.getState()) {
- this.rJSManager.Browser_SetEnable(false);
- this.aBrowserEnable.setState(false);
- } else {
- this.rJSManager.Browser_SetEnable(true);
- this.aBrowserEnable.setState(true);
- }
-
- return true;
- }
-
- for(int var2 = 0; var2 < this.aModulesMenu.countItems(); ++var2) {
- if ((String)var1.arg == this.aModulesMenu.getItem(var2).getLabel()) {
- this.rJSManager.SetActModuleNo(var2);
- this.UpDateIDE();
- return true;
- }
- }
-
- if ((String)var1.arg == "(main)") {
- this.aFunctionName = (String)var1.arg;
- this.SetCodeBlock(this.rJSManager.GetActModule().GetCodeBlock());
- this.UpDateIDE();
- return true;
- }
-
- for(int var3 = 0; var3 < this.aFunctionsMenu.countItems() - 1; ++var3) {
- if ((String)var1.arg == this.aFunctionsMenu.getItem(var3).getLabel()) {
- JSbxProperty[] var4 = this.GetPropertyArrayFromActModule();
- if (var4 != null) {
- this.SetCodeBlock(this.GetCodeBlockFromProperty(var4[var3]));
- this.aFunctionName = (String)var1.arg;
- this.UpDatePCodeName();
- return true;
- }
- break;
- }
- }
-
- for(int var5 = 0; var5 < this.aManagerMenu.countItems(); ++var5) {
- if ((String)var1.arg == this.aManagerMenu.getItem(var5).getLabel()) {
- JScriptManager.SelectJScriptManager(var5);
- this.UpDateIDE();
- return true;
- }
- }
- }
-
- return false;
- }
-
- public boolean handleEvent(Event var1) {
- if (var1.id == 401 && var1.target == this.aSourceEdit && this.aSourceEdit.isEditable()) {
- this.bSourceChanged = true;
- this.bNeedCompile = true;
- this.ShowStatus("source changed");
- }
-
- if (var1.id == 201) {
- this.CloseAndExit();
- return true;
- } else {
- return this.HandleAction(var1) ? true : super.handleEvent(var1);
- }
- }
-
- public boolean action(Event var1, Object var2) {
- try {
- if (var1.target == this.ButListThreads) {
- ThreadLister.listAllThreads(this.rJSManager.GetOutputPtrintStream());
- return true;
- }
-
- if (var1.target == this.ButKillAllThreads) {
- this.rJSManager.DoKillAllJobs();
- return true;
- }
-
- if (var1.target == this.ButClearOutput) {
- this.aOutputEdit.setText("");
- return true;
- }
-
- if (var1.target == this.ButClearAllWatches) {
- this.rJSManager.Browser_RemoveAllWatches();
- this.UpDateIDE();
- return true;
- }
-
- if (var1.target == this.ButNextPCodeFcn) {
- this.SetNextPCodeBlock();
- return true;
- }
-
- if (var1.target == this.ButNextBrowserMode) {
- this.rJSManager.Browser_NextMode();
- this.UpDateIDE();
- return true;
- }
-
- if (var1.target == this.ButTest) {
- this.rJSManager.CheckAllClients();
- return true;
- }
-
- if (var1.target == this.ButCompile) {
- this.DoCompile();
- return true;
- }
-
- if (var1.target == this.ButRTReset) {
- this.rJSManager.ResetRuntimeInstance();
- this.UpDateIDE();
- return true;
- }
-
- if (var1.target == this.ButToggleLineNumbers) {
- this.ToggleLineNumbers();
- return true;
- }
-
- if (var1.target == this.ButRunModule) {
- this.DoRun();
- return true;
- }
-
- if (var1.target == this.ButStartDebugger) {
- this.DoDebug();
- return true;
- }
-
- if (var1.target == this.ButStopDebugger) {
- this.rJSManager.NotifyObservers(new JScriptAction(1010));
- return true;
- }
-
- if (var1.target == this.ButStart) {
- this.rJSManager.NotifyObservers(new JScriptAction(1000));
- return true;
- }
-
- if (var1.target == this.ButUpdateBrowser) {
- this.DebugActionStarted();
- this.rJSManager.NotifyObservers(new JScriptAction(1016));
- return true;
- }
-
- if (var1.target == this.ButRun) {
- this.DebugActionStarted();
- this.ButBreak.enable();
- this.rJSManager.NotifyObservers(new JScriptAction(1005));
- return true;
- }
-
- if (var1.target == this.ButBreak) {
- this.DebugActionStarted();
- this.rJSManager.NotifyObservers(new JScriptAction(1006));
- return true;
- }
-
- if (var1.target == this.ButStepOver) {
- this.DebugActionStarted();
- this.rJSManager.NotifyObservers(new JScriptAction(1011));
- return true;
- }
-
- if (var1.target == this.ButStepOut) {
- this.DebugActionStarted();
- this.rJSManager.NotifyObservers(new JScriptAction(1012));
- return true;
- }
-
- if (var1.target == this.ButStep) {
- this.DebugActionStarted();
- this.rJSManager.NotifyObservers(new JScriptAction(1001));
- return true;
- }
-
- if (var1.target == this.ButPCodeStep) {
- this.DebugActionStarted();
- this.rJSManager.NotifyObservers(new JScriptAction(1002));
- return true;
- }
-
- if (var1.target == this.ButPCodeStepOver) {
- this.DebugActionStarted();
- this.rJSManager.NotifyObservers(new JScriptAction(1015));
- return true;
- }
-
- if (var1.target == this.ButReset) {
- this.DebugActionStarted();
- this.rJSManager.NotifyObservers(new JScriptAction(1004));
- return true;
- }
-
- if (var1.target == this.ButDoIt) {
- this.rJSManager.Browser_SetSpecialName(this.aBrowserEditField.getText());
- this.rJSManager.Browser_SetMode(2);
- this.UpDateIDE();
- return true;
- }
-
- if (var1.target == this.ButAddWatch) {
- this.rJSManager.Browser_AddWatch(this.aBrowserEditField.getText());
- this.UpDateIDE();
- return true;
- }
-
- if (var1.target == this.ButSetVariable) {
- this.rJSManager.Browser_SetVar(this.aBrowserEditField.getText());
- this.UpDateIDE();
- return true;
- }
-
- if (var1.target == this.ButAddBreakpoint) {
- int var3 = Integer.parseInt(this.aBrowserEditField.getText());
- if (this.aActCodeBlock != null) {
- JScriptPCode var4 = this.aActCodeBlock.GetPCode(var3);
- if (var4 instanceof JSP_DebugStep) {
- ((JSP_DebugStep)var4).SetBreakPoint(true);
- this.SetCodeBlock(this.aActCodeBlock);
- this.ShowStatus("set breakpoint");
- } else {
- this.ShowStatus("Error setting breakpoint (invalid statement)");
- }
- } else {
- this.ShowStatus("Error setting breakpoint (no codeblock)");
- }
-
- return true;
- }
-
- if (var1.target == this.ButToCallLevelStack || var1.target == this.ButToExprStack) {
- this.aStackCardLayout.next(this.aCardPanel);
- return true;
- }
- } catch (Exception var5) {
- System.out.println("Exception: " + var5);
- }
-
- return false;
- }
-
- public final void EnterEditState() {
- this.nState = 0;
- this.aSourceEdit.setEditable(true);
- this.ButRTReset.enable();
- this.ButNextPCodeFcn.enable();
- this.EnableFileMenu();
- this.EnableModuleSwitching();
- this.EnableManagerSwitching();
- this.EnableFunctionsSwitching();
- this.EnableCompiler();
- this.EnableRun();
- this.DisableDebugger();
- this.ButStartDebugger.enable();
- }
-
- public final void LeaveEditState() {
- this.aSourceEdit.setEditable(false);
- this.ButRTReset.disable();
- this.ButNextPCodeFcn.disable();
- this.DisableFileMenu();
- this.DisableModuleSwitching();
- this.DisableManagerSwitching();
- this.DisableFunctionsSwitching();
- this.DisableCompiler();
- this.DisableRun();
- this.ButStartDebugger.disable();
- }
-
- public final void EnterDebugState() {
- this.LeaveEditState();
- this.EnableDebugger();
- this.nState = 1;
- }
-
- public final void EnterRunState() {
- this.LeaveEditState();
- this.nState = 2;
- }
-
- public final void EnterCompileState() {
- this.LeaveEditState();
- this.nState = 3;
- }
-
- public final void DebugActionStarted() {
- this.DisableDebugger();
- this.ButStopDebugger.enable();
- }
-
- public final void DebugActionFinished() {
- this.EnableDebugger();
- }
-
- public final void ShowBrowserInfo(String var1) {
- this.aBrowserEdit.setText(var1);
- }
-
- public final void ShowBrowserTitle(String var1) {
- this.aBrowserName.setText("Browser " + var1);
- }
-
- public final void ShowBrowserWatch(String var1) {
- this.aWatchEdit.setText(var1);
- }
-
- public final void ShowStatus(String var1) {
- this.aShowStatus.setText(var1);
- }
-
- public final void ShowStatus(int var1) {
- this.aShowStatus.setText(String.valueOf(var1));
- }
-
- public final void ShowSourcePos(JScriptTokenPosition var1) {
- if (var1 != null) {
- int var2 = var1.GetStartPos();
- int var3 = var1.GetEndPos();
- this.aSourceEdit.requestFocus();
- this.aSourceEdit.select(var2, var3);
- }
-
- }
-
- public final void DoCompileStart() {
- this.ShowStatus("compiling...");
- this.EnterCompileState();
- }
-
- public final void DoCompileDone() {
- if (this.nState == 3) {
- this.bNeedCompile = false;
- this.ShowStatus("compiled.");
- this.EnterEditState();
- this.UpDateIDE();
- }
-
- }
-
- public final void DoCompileError() {
- if (this.nState == 3) {
- this.bNeedCompile = true;
- this.ShowStatus("Compiler Error");
- this.EnterEditState();
- this.UpDateIDE();
- }
-
- }
-
- public final void DoRunStart() {
- this.ShowStatus("running...");
- this.EnterRunState();
- }
-
- public final void DoRunDone() {
- if (this.nState == 2) {
- this.ShowStatus("Program finished.");
- this.EnterEditState();
- this.UpDateIDE();
- }
-
- }
-
- public final void DoDebugStart() {
- this.ShowStatus("debugger started...");
- this.EnterDebugState();
- }
-
- public final void DoDebugDone() {
- if (this.nState == 1) {
- this.DebugActionFinished();
- this.EnterEditState();
- this.ShowBrowserInfo("");
- this.ShowBrowserWatch("");
- this.ShowCallLevelStackString("");
- this.ShowExpressionStackString("");
- this.UpDateIDE();
- }
-
- }
-
- public final void UpDateBrowser() {
- this.rJSManager.Browser_UpDateInfos();
- }
-
- public final void UpDateJavaEnv() {
- Runtime var2 = Runtime.getRuntime();
- String var1 = "memory: free=" + var2.freeMemory() + " / total=" + var2.totalMemory();
- this.aJavaEnvText.setText(var1);
- }
-
- public final void UpDatePCodeName() {
- this.UpDatePCodeName(-1);
- }
-
- public final void UpDatePCodeName(int var1) {
- this.aActPCodeName.setText(this.aFunctionName + " PCode " + " PC: " + var1);
- }
-
- public final void ClrSourcePos() {
- this.aSourceEdit.select(0, 0);
- }
-
- public final void ShowPCodePos(int var1) {
- this.UpDatePCodeName(var1);
- this.aPCodeEdit.InsertText(" >>>", this.nStartPCodePos[var1]);
- }
-
- public final void ClrPCodePos() {
- this.aPCodeEdit.RestoreInsertText();
- }
-
- public final void ShowExpressionStackString(String var1) {
- if (var1 == null) {
- this.aExprStackEdit.setText("");
- } else {
- this.aExprStackEdit.setText(var1);
- }
- }
-
- public final void ShowCallLevelStackString(String var1) {
- new StringBuffer();
- if (var1 == null) {
- this.aCallLevelStackEdit.setText("");
- } else {
- this.aCallLevelStackEdit.setText(var1);
- }
- }
-
- public final void CheckAndSetSourceFromModule(JScriptModule var1) {
- if (this.aActModule != var1 && var1 != null) {
- this.aActModule = var1;
- this.SetSource(this.aActModule.GetSource());
- this.rJSManager.SetAsActModule(this.aActModule);
- this.UpDateFunctionsMenu();
- }
-
- }
-
- public final void SetSource(String var1) {
- this.aSourceEdit.setText(var1);
- }
-
- public final void CheckAndSetCodeBlock(JScriptCodeBlock var1) {
- if (this.aActCodeBlock != var1) {
- this.aActCodeBlock = var1;
- this.SetCodeBlock(this.aActCodeBlock);
- }
-
- }
-
- public final void SetCodeBlock(JScriptCodeBlock var1) {
- this.ClrPCodePos();
- if (var1 != null) {
- this.aActCodeBlock = var1;
- if (var1.GetIDString() != null) {
- this.aFunctionName = var1.GetIDString();
- } else {
- this.aFunctionName = "(main)";
- }
-
- this.aPCodeEdit.setText(var1.DEBUG_GetInfoString());
- this.nStartPCodePos = var1.DEBUG_GetStartPosArray_AfterInfoString();
- } else {
- this.aPCodeEdit.setText("");
- }
- }
-
- private void SetNextPCodeBlock() {
- JSbxProperty[] var1 = this.GetPropertyArrayFromActModule();
- if (var1 != null) {
- if (this.aFunctionName == "(main)") {
- this.SetCodeBlock(this.GetCodeBlockFromProperty(var1[0]));
- this.aFunctionName = var1[0].GetName();
- } else {
- for(int var2 = 0; var2 < var1.length; ++var2) {
- if (this.aFunctionName == var1[var2].GetName()) {
- if (var2 == var1.length - 1) {
- this.aFunctionName = "(main)";
- this.SetCodeBlock(this.rJSManager.GetActModule().GetCodeBlock());
- this.UpDateIDE();
- } else {
- this.aFunctionName = var1[var2 + 1].GetName();
- this.SetCodeBlock(this.GetCodeBlockFromProperty(var1[var2 + 1]));
- }
- break;
- }
- }
- }
-
- this.UpDatePCodeName();
- }
- }
-
- private final JScriptCodeBlock GetCodeBlockFromProperty(JSbxProperty var1) {
- JScriptMethod var2 = null;
- JSbxValue var3 = new JSbxValue();
-
- try {
- var1.Get(var3);
- JSbxBase var4 = var3.GetObject();
- if (var4 instanceof JScriptMethod) {
- var2 = (JScriptMethod)var4;
- } else {
- System.out.println("GetCodeBlockFromProperty() NO METHOD ! hided by: " + var4);
- }
- } catch (JSbxException var5) {
- }
-
- return var2 != null ? var2.GetCodeBlock() : null;
- }
-
- private final JSbxProperty[] GetPropertyArrayFromActModule() {
- return this.GetPropertyArrayFromModule(this.rJSManager.GetActModule());
- }
-
- private final JSbxProperty[] GetPropertyArrayFromModule(JScriptModule var1) {
- if (var1 == null) {
- return null;
- } else {
- JSbxNameArray var2 = ((JSbxObject)var1).DEBUG_GetNameArray();
- if (var2 == null) {
- return null;
- } else {
- JSbxProperty[] var3 = var2.GetArrayOfProperties();
- return var3;
- }
- }
- }
-
- private final void UpDateManagerMenu() {
- if (bWithMenu) {
- int var1 = this.aManagerMenu.countItems();
-
- for(int var2 = var1 - 1; var2 >= 0; --var2) {
- this.aManagerMenu.remove(var2);
- }
-
- var1 = JScriptManager.GetNoOfJScriptManagers();
-
- for(int var3 = 0; var3 < var1; ++var3) {
- this.aManagerMenu.add("Manger #" + var3);
- }
- }
-
- }
-
- private final void UpDateModuleMenu() {
- if (bWithMenu) {
- int var1 = this.aModulesMenu.countItems();
-
- for(int var2 = var1 - 1; var2 >= 0; --var2) {
- this.aModulesMenu.remove(var2);
- }
-
- var1 = this.rJSManager.GetModuleCount();
-
- for(int var3 = 0; var3 < var1; ++var3) {
- this.aModulesMenu.add(this.rJSManager.GetModuleName(var3));
- }
- }
-
- }
-
- public final void UpDateFunctionsMenu() {
- if (bWithMenu) {
- JSbxProperty[] var1 = this.GetPropertyArrayFromActModule();
- if (var1 == null) {
- return;
- }
-
- int var2 = this.aFunctionsMenu.countItems();
-
- for(int var3 = var2 - 1; var3 >= 0; --var3) {
- this.aFunctionsMenu.remove(var3);
- }
-
- for(int var4 = 0; var4 < var1.length; ++var4) {
- String var5 = var1[var4].GetName();
- JScriptCodeBlock var6 = this.GetCodeBlockFromProperty(var1[var4]);
- if (var6 != null) {
- var6.SetIDString(var5);
- }
-
- this.aFunctionsMenu.add(var5);
- }
-
- this.aFunctionsMenu.add("(main)");
- this.rJSManager.GetActModule().GetCodeBlock().SetIDString("(main)");
- }
-
- }
-
- public final void UpDateIDE() {
- if (((Component)this).isVisible()) {
- JScriptModule var1 = this.aActModule != null ? this.aActModule : this.rJSManager.GetActModule();
- if (var1 != null) {
- String var2 = var1.GetSource();
- this.SetSource(var2);
- JScriptCodeBlock var3 = this.aActCodeBlock != null ? this.aActCodeBlock : var1.GetCodeBlock();
- this.SetCodeBlock(var3);
- this.ShowModuleName(var1.GetName());
- } else {
- this.SetSource("");
- this.SetCodeBlock((JScriptCodeBlock)null);
- this.ShowModuleName("");
- }
-
- this.UpDateModuleMenu();
- this.UpDateFunctionsMenu();
- this.UpDateManagerMenu();
- this.UpDatePCodeName();
- this.UpDateBrowser();
- this.UpDateJavaEnv();
- }
- }
-
- private final void UpDateSourceCode() {
- String var1 = this.aSourceEdit.getText();
- JScriptModule var2 = this.rJSManager.GetActModule();
- if (var2 != null) {
- var2.SetSource(var1);
- } else {
- var2 = this.rJSManager.MakeModule(var1);
- var2.SetName(this.GetNewModuleName());
- this.rJSManager.SetAsActModule(var2);
- }
- }
-
- private final void NewModule() {
- this.UpDateSourceCode();
- JScriptModule var1 = this.rJSManager.MakeModule("");
- var1.SetName(this.GetNewModuleName());
- this.rJSManager.SetAsActModule(var1);
- this.SetSource("");
- this.UpDateIDE();
- }
-
- public final void LoadFile(String var1) {
- if (var1 != null && JScriptTools.ExistsFile(var1)) {
- String var2 = JScriptTools.GetStringFromFile(var1);
- JScriptModule var3 = this.rJSManager.MakeModule(var2);
- var3.SetName(var1);
- this.rJSManager.SetLastModuleAsActive();
- this.rJSManager.DoCompileActMod();
- }
-
- this.UpDateIDE();
- }
-
- private final void LoadFile() {
- FileDialog var2 = new FileDialog(this, "JScriptID Open File", 0);
- var2.setFile("*.js");
- ((Window)var2).show();
- String var1 = var2.getFile();
- this.LoadFile(var1);
- }
-
- private final void SaveFile() {
- this.UpDateSourceCode();
- JScriptTools.WriteStringToFile(this.rJSManager.GetActModule().GetName(), this.rJSManager.GetActModule().GetSource());
- this.bSourceChanged = false;
- this.ShowStatus("File saved.");
- }
-
- private final void SaveFileAs() {
- FileDialog var2 = new FileDialog(this, "JScriptID Save File As", 1);
- var2.setFile("*.js");
- ((Window)var2).show();
- String var1 = var2.getFile();
- if (var1 != null) {
- this.rJSManager.GetActModule().SetName(var1);
- this.SaveFile();
- } else {
- this.ShowStatus("WARNING: no File saved !");
- }
- }
-
- private final String GetNewModuleName() {
- return new String("Module" + NewModuleCount++);
- }
-
- private final void ShowModuleName(String var1) {
- this.aActModuleName.setText("Quelltext: " + var1);
- }
-
- private final void ToggleLineNumbers() {
- if (this.bLineNumbersOn) {
- this.aSourceEdit.setEditable(true);
- this.aSourceEdit.setText(this.aOldSourceTemp);
- } else {
- this.aSourceEdit.setEditable(false);
- this.aOldSourceTemp = this.aSourceEdit.getText();
- int var1 = 0;
- int var2 = 0;
- int var3 = 0;
-
- String var4;
- for(var4 = ""; (var3 = this.aOldSourceTemp.indexOf("\n", var2)) != -1; var2 = var3 + 1) {
- var4 = var4 + "#" + var1 + "# " + this.aOldSourceTemp.substring(var2, var3) + "\n";
- ++var1;
- }
-
- var4 = var4 + "#" + var1 + "# " + this.aOldSourceTemp.substring(var2) + "\n";
- this.aSourceEdit.setText(var4);
- }
-
- this.bLineNumbersOn = !this.bLineNumbersOn;
- }
-
- private final void DoCompile() {
- if (this.nState == 0) {
- this.UpDateSourceCode();
- this.rJSManager.DoCompileActMod();
- }
-
- }
-
- private final void DoRun() {
- if (this.nState == 0) {
- if (this.bNeedCompile) {
- this.UpDateSourceCode();
- this.rJSManager.DoCompileAndRunActMod();
- return;
- }
-
- this.rJSManager.DoRunActMod();
- }
-
- }
-
- private final void DoDebug() {
- if (this.nState == 0) {
- if (this.bNeedCompile) {
- this.UpDateSourceCode();
- this.rJSManager.DoCompileAndDebugActMod();
- return;
- }
-
- this.rJSManager.DoDebugActMod();
- }
-
- }
-
- private final void DisableFileMenu() {
- if (bWithMenu) {
- this.aFileOpen.disable();
- this.aFileNew.disable();
- this.aFileSave.disable();
- this.aFileSaveAs.disable();
- this.aFileClose.disable();
- this.aFileCloseAll.disable();
- }
-
- }
-
- private final void EnableFileMenu() {
- if (bWithMenu) {
- this.aFileOpen.enable();
- this.aFileNew.enable();
- this.aFileSave.enable();
- this.aFileSaveAs.enable();
- this.aFileClose.enable();
- this.aFileCloseAll.enable();
- this.aFileExit.enable();
- }
-
- }
-
- private final void DisableModuleSwitching() {
- if (bWithMenu) {
- this.aModulesMenu.disable();
- }
-
- }
-
- private final void EnableModuleSwitching() {
- if (bWithMenu) {
- this.aModulesMenu.enable();
- }
-
- }
-
- private final void DisableManagerSwitching() {
- if (bWithMenu) {
- this.aManagerMenu.disable();
- }
-
- }
-
- private final void EnableManagerSwitching() {
- if (bWithMenu) {
- this.aManagerMenu.enable();
- }
-
- }
-
- private final void DisableFunctionsSwitching() {
- if (bWithMenu) {
- this.aFunctionsMenu.disable();
- }
-
- }
-
- private final void EnableFunctionsSwitching() {
- if (bWithMenu) {
- this.aFunctionsMenu.enable();
- }
-
- }
-
- private final void EnableDebugger() {
- this.ButStopDebugger.enable();
- this.ButStart.enable();
- this.ButRun.enable();
- this.ButUpdateBrowser.enable();
- this.ButStepOver.enable();
- this.ButStepOut.enable();
- this.ButStep.enable();
- this.ButPCodeStep.enable();
- this.ButPCodeStepOver.enable();
- this.ButBreak.enable();
- this.ButReset.enable();
- }
-
- private final void DisableDebugger() {
- this.ButStopDebugger.disable();
- this.ButStart.disable();
- this.ButRun.disable();
- this.ButUpdateBrowser.disable();
- this.ButStepOver.disable();
- this.ButStepOut.disable();
- this.ButStep.disable();
- this.ButPCodeStep.disable();
- this.ButPCodeStepOver.disable();
- this.ButBreak.disable();
- this.ButReset.disable();
- }
-
- private final void EnableRun() {
- this.ButRunModule.enable();
- }
-
- private final void DisableRun() {
- this.ButRunModule.disable();
- }
-
- private final void EnableCompiler() {
- this.ButCompile.enable();
- if (bWithMenu) {
- this.aCompilerMenu.enable();
- }
-
- }
-
- private final void DisableCompiler() {
- this.ButCompile.disable();
- if (bWithMenu) {
- this.aCompilerMenu.disable();
- }
-
- }
- }
-