From bda7fb6c9a1a6ed7dcd972d8542e335a2c6167a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BCdiger=20Timm?= Date: Fri, 11 Apr 2008 06:03:06 +0000 Subject: [PATCH] INTEGRATION: CWS changefileheader (1.2.4); FILE MERGED 2008/03/28 16:27:36 rt 1.2.4.1: #i87441# Change license header to LPGL v3. --- rhino/rhino1_5R5.patch | 2605 ++++++++++++++++++---------------------- 1 file changed, 1170 insertions(+), 1435 deletions(-) diff --git a/rhino/rhino1_5R5.patch b/rhino/rhino1_5R5.patch index 1a63b0ab0353..98e6e10b9508 100644 --- a/rhino/rhino1_5R5.patch +++ b/rhino/rhino1_5R5.patch @@ -1,1441 +1,1176 @@ -*** misc/rhino1_5R5/src/org/mozilla/javascript/DefiningClassLoader.java Tue Mar 22 13:20:47 2005 ---- misc/build/rhino1_5R5/src/org/mozilla/javascript/DefiningClassLoader.java Tue Jul 4 14:59:43 2006 -*************** -*** 38,43 **** ---- 38,44 ---- - package org.mozilla.javascript; - - import java.lang.reflect.Method; -+ import java.lang.reflect.InvocationTargetException; - - /** - * Load generated classes. -*************** -*** 49,59 **** - implements GeneratedClassLoader - { - public DefiningClassLoader() { -! this.parentLoader = getClass().getClassLoader(); - } - - public DefiningClassLoader(ClassLoader parentLoader) { - this.parentLoader = parentLoader; - } - - public Class defineClass(String name, byte[] data) { ---- 49,82 ---- - implements GeneratedClassLoader - { - public DefiningClassLoader() { -! init(getClass().getClassLoader()); - } - - public DefiningClassLoader(ClassLoader parentLoader) { -+ -+ init(parentLoader); -+ } -+ -+ private void init(ClassLoader parentLoader) { -+ - this.parentLoader = parentLoader; -+ -+ this.contextLoader = null; -+ if (method_getContextClassLoader != null) { -+ try { -+ this.contextLoader = (ClassLoader) -+ method_getContextClassLoader.invoke( -+ Thread.currentThread(), -+ ScriptRuntime.emptyArgs); -+ } catch (IllegalAccessException ex) { -+ } catch (InvocationTargetException ex) { -+ } catch (SecurityException ex) { -+ } -+ if (this.contextLoader == this.parentLoader) { -+ this.contextLoader = null; -+ } -+ } -+ - } - - public Class defineClass(String name, byte[] data) { -*************** -*** 69,78 **** - { - Class cl = findLoadedClass(name); - if (cl == null) { -! if (parentLoader != null) { -! cl = parentLoader.loadClass(name); - } else { -! cl = findSystemClass(name); - } - } - if (resolve) { ---- 92,111 ---- - { - Class cl = findLoadedClass(name); - if (cl == null) { -! // First try parent class loader and if that does not work, try -! // contextLoader, but that will be null if -! // Thread.getContextClassLoader() == parentLoader -! // or on JDK 1.1 due to lack Thread.getContextClassLoader(). -! // To avoid catching and rethrowing ClassNotFoundException -! // in this cases, use try/catch check only if contextLoader != null. -! if (contextLoader == null) { -! cl = loadFromParent(name); - } else { -! try { -! cl = loadFromParent(name); -! } catch (ClassNotFoundException ex) { -! cl = contextLoader.loadClass(name); -! } - } - } - if (resolve) { -*************** -*** 81,85 **** ---- 114,150 ---- - return cl; - } - -+ private Class loadFromParent(String name) -+ throws ClassNotFoundException -+ { -+ if (parentLoader != null) { -+ return parentLoader.loadClass(name); -+ } else { -+ return findSystemClass(name); -+ } -+ -+ } -+ - private ClassLoader parentLoader; -+ -+ private ClassLoader contextLoader; -+ -+ // We'd like to use "Thread.getContextClassLoader", but -+ // that's only available on Java2. -+ private static Method method_getContextClassLoader; -+ -+ static { -+ try { -+ // Don't use "Thread.class": that performs the lookup -+ // in the class initializer, which doesn't allow us to -+ // catch possible security exceptions. -+ Class threadClass = Class.forName("java.lang.Thread"); -+ method_getContextClassLoader = -+ threadClass.getDeclaredMethod("getContextClassLoader", -+ new Class[0]); -+ } catch (ClassNotFoundException e) { -+ } catch (NoSuchMethodException e) { -+ } catch (SecurityException e) { -+ } -+ } - } -*** misc/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/OfficeScriptInfo.java Tue Jul 4 15:14:27 2006 ---- misc/build/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/OfficeScriptInfo.java Tue Jul 4 14:59:43 2006 -*************** -*** 1 **** -! dummy ---- 1,136 ---- -! /************************************************************************* -! * -! * $RCSfile: rhino1_5R5.patch,v $ -! * -! * $Revision: 1.2 $ -! * -! * last change: $Author: obo $ $Date: 2008-01-04 15:22:56 $ -! * -! * The Contents of this file are made available subject to -! * the terms of GNU Lesser General Public License Version 2.1. -! * -! * -! * GNU Lesser General Public License Version 2.1 -! * ============================================= -! * Copyright 2005 by Sun Microsystems, Inc. -! * 901 San Antonio Road, Palo Alto, CA 94303, USA -! * -! * This library is free software; you can redistribute it and/or -! * modify it under the terms of the GNU Lesser General Public -! * License version 2.1, as published by the Free Software Foundation. -! * -! * This library is distributed in the hope that it will be useful, -! * but WITHOUT ANY WARRANTY; without even the implied warranty of -! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -! * Lesser General Public License for more details. -! * -! * You should have received a copy of the GNU Lesser General Public -! * License along with this library; if not, write to the Free Software -! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, -! * MA 02111-1307 USA -! * -! ************************************************************************/ -! -! -! package org.mozilla.javascript.tools.debugger; -! import java.net.URL; -! import java.util.Hashtable; -! import org.mozilla.javascript.Scriptable; -! -! public class OfficeScriptInfo -! { -! private Hashtable loadedSFScripts = new Hashtable(); -! -! public void addScript( URL url, Scriptable scope, Runnable closeCallback ) -! { -! addScript( url.toString(), url, scope, closeCallback ); -! } -! -! public void addScript( String key, URL url, Scriptable scope, Runnable closeCallback ) -! { -! SFScriptInfo si = (SFScriptInfo)loadedSFScripts.get( key ); -! if ( si == null ) -! { -! si = new SFScriptInfo(); -! si.url = url; -! si.scope = scope; -! si.closeCallback = closeCallback; -! loadedSFScripts.put( key, si ); -! } -! } -! -! public void deleteScript( String key ) -! { -! SFScriptInfo info = (SFScriptInfo)loadedSFScripts.remove( key ); -! if ( info != null ) -! { -! if ( info.closeCallback != null ) -! { -! System.out.println("** In removeSFScriptInfo have callback for " + key ); -! info.closeCallback.run(); // really need to do this in seperate thread???? -! } -! } -! } -! -! public Scriptable getScriptScope( String key ) -! { -! Scriptable result = null; -! SFScriptInfo info = (SFScriptInfo)loadedSFScripts.get( key ); -! if ( info != null ) -! { -! result = info.scope; -! } -! return result; -! } -! -! public URL getScriptUrl( String key ) -! { -! URL result = null; -! SFScriptInfo info = (SFScriptInfo)loadedSFScripts.get( key ); -! if ( info != null ) -! { -! result = info.url; -! } -! return result; -! } -! public boolean hasScript( String key ) -! { -! boolean result = true; -! SFScriptInfo info = (SFScriptInfo)loadedSFScripts.get( key ); -! if ( info == null ) -! { -! result = false; -! } -! return result; -! } -! -! public void setScriptRunning( String key, boolean running ) -! { -! SFScriptInfo info = (SFScriptInfo)loadedSFScripts.get( key ); -! if ( info != null ) -! { -! info.isExecuting = running; -! } -! } -! -! public boolean isScriptRunning( String key ) -! { -! boolean result = false; -! SFScriptInfo info = (SFScriptInfo)loadedSFScripts.get( key ); -! if ( info != null ) -! { -! result = info.isExecuting; -! } -! return result; -! } -! -! -! -! class SFScriptInfo -! { -! Scriptable scope; -! boolean isExecuting; -! URL url; -! Runnable closeCallback; -! } -! } -*** misc/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/shell/JavaPolicySecurity.java Tue Mar 22 13:20:49 2005 ---- misc/build/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/shell/JavaPolicySecurity.java Tue Jul 4 14:59:43 2006 -*************** -*** 36,41 **** ---- 36,42 ---- - package org.mozilla.javascript.tools.shell; - - import java.security.*; -+ import java.security.cert.Certificate; - import java.net.MalformedURLException; - import java.net.URL; - import java.util.Hashtable; -*************** -*** 124,130 **** - - public JavaPolicySecurity() { - // To trigger error on jdk-1.1 with lazy load -! new CodeSource(null, null); - } - - protected void callProcessFileSecure(final Context cx, ---- 125,131 ---- - - public JavaPolicySecurity() { - // To trigger error on jdk-1.1 with lazy load -! new CodeSource(null, (Certificate [])null); - } - - protected void callProcessFileSecure(final Context cx, -*************** -*** 167,173 **** - } - - private ProtectionDomain getUrlDomain(URL url) { -! CodeSource cs = new CodeSource(url, null); - PermissionCollection pc = Policy.getPolicy().getPermissions(cs); - return new ProtectionDomain(cs, pc); - } ---- 168,174 ---- - } - - private ProtectionDomain getUrlDomain(URL url) { -! CodeSource cs = new CodeSource(url, (Certificate [])null); - PermissionCollection pc = Policy.getPolicy().getPermissions(cs); - return new ProtectionDomain(cs, pc); - } -*** misc/rhino1_5R5/toolsrc/build.xml 2007-11-30 13:22:35.000000000 +0000 ---- misc/build/rhino1_5R5/toolsrc/build.xml 2007-11-30 13:24:25.000000000 +0000 -*************** -*** 20,65 **** - -! -! - - - -- -- import java.awt.Component; -- -- package org.mozilla.javascript.tools.debugger; -- import java.awt.Component; -- -- -- -- import javax.swing.tree.*; -- -- package org.mozilla.javascript.tools.debugger; -- import javax.swing.tree.*; -- -- -- -- import javax.swing.*; -- -- package org.mozilla.javascript.tools.debugger; -- import javax.swing.*; -- -- -- -- import javax.swing.tree.TreeModel; -- -- package org.mozilla.javascript.tools.debugger; -- import javax.swing.tree.TreeModel; -- -- -- -- import javax.swing.JTree; -- -- package org.mozilla.javascript.tools.debugger; -- import javax.swing.JTree; -- -- - - - ---- 20,29 ---- - -! - - - - - - -*** misc/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/Main.java Tue Mar 22 13:20:49 2005 ---- misc/build/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/Main.java Tue Jul 4 14:59:43 2006 -*************** -*** 470,484 **** ---- 470,490 ---- - case KeyEvent.VK_BACK_SPACE: - case KeyEvent.VK_ENTER: - case KeyEvent.VK_DELETE: -+ if (w.isEditable() == false) { - e.consume(); -+ } - break; - } - } - public void keyTyped(KeyEvent e) { -+ if (w.isEditable() == false) { - e.consume(); -+ } - } - public void keyReleased(KeyEvent e) { -+ if (w.isEditable() == false) { - e.consume(); -+ } - } - } - -*************** -*** 879,885 **** - } - }; - -! class FileWindow extends JInternalFrame implements ActionListener { - - Main db; - SourceInfo sourceInfo; ---- 885,891 ---- - } - }; - -! class FileWindow extends JInternalFrame implements ActionListener, DocumentListener { - - Main db; - SourceInfo sourceInfo; -*************** -*** 888,902 **** - JScrollPane p; - int currentPos; - JLabel statusBar; - - public void actionPerformed(ActionEvent e) { - String cmd = e.getActionCommand(); - if (cmd.equals("Cut")) { -! // textArea.cut(); - } else if (cmd.equals("Copy")) { - textArea.copy(); - } else if (cmd.equals("Paste")) { -! // textArea.paste(); - } - } - ---- 894,909 ---- - JScrollPane p; - int currentPos; - JLabel statusBar; -+ boolean isModified = false; - - public void actionPerformed(ActionEvent e) { - String cmd = e.getActionCommand(); - if (cmd.equals("Cut")) { -! textArea.cut(); - } else if (cmd.equals("Copy")) { - textArea.copy(); - } else if (cmd.equals("Paste")) { -! textArea.paste(); - } - } - -*************** -*** 910,926 **** - } - - void load() { -! Scriptable scope = db.getScope(); - if (scope == null) { - MessageDialogWrapper.showMessageDialog(db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE); - } else { - String url = getUrl(); - if (url != null) { -! new Thread(new LoadFile(db,scope,url)).start(); - } - } - } - - public int getPosition(int line) { - int result = -1; - try { ---- 917,989 ---- - } - - void load() { -! //Scriptable scope = db.getScope(); -! Scriptable scope = db.officeScripts.getScriptScope( getUrl() ); -! if ( scope == null ) -! { -! scope = db.getScope(); -! } - if (scope == null) { - MessageDialogWrapper.showMessageDialog(db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE); - } else { - String url = getUrl(); - if (url != null) { -! new Thread(new LoadFile(db,scope, url, new StringReader(textArea.getText()))).start(); - } - } - } - -+ void save() { -+ if (getUrl() != null) { -+ OutputStream os = null; -+ try { -+ if ( getUrl().startsWith("vnd.sun.star") ) -+ { -+ URL scriptUrl = db.officeScripts.getScriptUrl( getUrl() ); -+ if ( scriptUrl == null ) -+ { -+ throw new IOException("Can't optain stream for " + getUrl() ); -+ } -+ os = scriptUrl.openConnection().getOutputStream(); -+ } -+ else -+ { -+ os = new FileOutputStream( getUrl() ); -+ } -+ String s = textArea.getText(); -+ os.write(s.getBytes(), 0, s.length()); -+ -+ this.isModified = false; -+ } -+ catch (IOException ioe) { -+ JOptionPane.showMessageDialog(this, -+ "Error saving file: " + ioe.getMessage(), -+ "Error", JOptionPane.ERROR_MESSAGE); -+ } -+ finally -+ { -+ if ( os != null ) -+ { -+ try -+ { -+ os.close(); -+ os = null; -+ } -+ catch( IOException ioe ) -+ { -+ System.err.println("Error closing stream: " + ioe.getMessage() ); -+ ioe.printStackTrace(); -+ } -+ } -+ } -+ } +--- misc/rhino1_5R5/src/org/mozilla/javascript/DefiningClassLoader.java Thu Mar 25 21:54:34 2004 ++++ misc/build/rhino1_5R5/src/org/mozilla/javascript/DefiningClassLoader.java Fri Mar 28 17:24:23 2008 +@@ -38,6 +38,7 @@ + package org.mozilla.javascript; + + import java.lang.reflect.Method; ++import java.lang.reflect.InvocationTargetException; + + /** + * Load generated classes. +@@ -48,11 +49,34 @@ + implements GeneratedClassLoader + { + public DefiningClassLoader() { +- this.parentLoader = getClass().getClassLoader(); ++ init(getClass().getClassLoader()); + } + + public DefiningClassLoader(ClassLoader parentLoader) { ++ ++ init(parentLoader); + } -+ -+ public boolean isEditable() { -+ return db.isSourceEditingEnabled(); ++ ++ private void init(ClassLoader parentLoader) { ++ + this.parentLoader = parentLoader; ++ ++ this.contextLoader = null; ++ if (method_getContextClassLoader != null) { ++ try { ++ this.contextLoader = (ClassLoader) ++ method_getContextClassLoader.invoke( ++ Thread.currentThread(), ++ ScriptRuntime.emptyArgs); ++ } catch (IllegalAccessException ex) { ++ } catch (InvocationTargetException ex) { ++ } catch (SecurityException ex) { ++ } ++ if (this.contextLoader == this.parentLoader) { ++ this.contextLoader = null; ++ } ++ } ++ + } + + public Class defineClass(String name, byte[] data) { +@@ -68,10 +92,20 @@ + { + Class cl = findLoadedClass(name); + if (cl == null) { +- if (parentLoader != null) { +- cl = parentLoader.loadClass(name); ++ // First try parent class loader and if that does not work, try ++ // contextLoader, but that will be null if ++ // Thread.getContextClassLoader() == parentLoader ++ // or on JDK 1.1 due to lack Thread.getContextClassLoader(). ++ // To avoid catching and rethrowing ClassNotFoundException ++ // in this cases, use try/catch check only if contextLoader != null. ++ if (contextLoader == null) { ++ cl = loadFromParent(name); + } else { +- cl = findSystemClass(name); ++ try { ++ cl = loadFromParent(name); ++ } catch (ClassNotFoundException ex) { ++ cl = contextLoader.loadClass(name); ++ } + } + } + if (resolve) { +@@ -80,5 +114,37 @@ + return cl; + } + ++ private Class loadFromParent(String name) ++ throws ClassNotFoundException ++ { ++ if (parentLoader != null) { ++ return parentLoader.loadClass(name); ++ } else { ++ return findSystemClass(name); ++ } ++ + } -+ -+ - public int getPosition(int line) { - int result = -1; - try { -*************** -*** 953,959 **** - fileHeader.repaint(); - } - } -! - FileWindow(Main db, SourceInfo sourceInfo) { - super(SourceInfo.getShortName(sourceInfo.getUrl()), - true, true, true, true); ---- 1016,1022 ---- - fileHeader.repaint(); - } - } -! public Main getDB() { return db; } - FileWindow(Main db, SourceInfo sourceInfo) { - super(SourceInfo.getShortName(sourceInfo.getUrl()), - true, true, true, true); -*************** -*** 972,977 **** ---- 1035,1048 ---- - pack(); - updateText(); - textArea.select(0); -+ addInternalFrameListener( new InternalFrameAdapter() { -+ public void internalFrameClosed(InternalFrameEvent e) { -+ // clean up scriptItems and sourceNames hashes -+ getDB().removeScript( getUrl() ); -+ // remove scripts for officeScripts -+ getDB().officeScripts.deleteScript( getUrl() ); -+ } -+ } ); - } - - private void updateToolTip() { -*************** -*** 990,996 **** ---- 1061,1070 ---- - void updateText() { - String newText = sourceInfo.getSource(); - if (!textArea.getText().equals(newText)) { -+ textArea.getDocument().removeDocumentListener(this); - textArea.setText(newText); -+ this.isModified = false; -+ textArea.getDocument().addDocumentListener(this); - int pos = 0; - if (currentPos != -1) { - pos = currentPos; -*************** -*** 1001,1006 **** ---- 1075,1105 ---- - fileHeader.repaint(); - } - -+ /* Implementation of DocumentListener interface */ -+ public void insertUpdate(DocumentEvent e) { -+ doChanged(e); -+ } -+ -+ public void removeUpdate(DocumentEvent e) { -+ doChanged(e); -+ } -+ -+ public void changedUpdate(DocumentEvent e) { -+ doChanged(e); -+ } -+ -+ public void doChanged(DocumentEvent e) { -+ this.isModified = true; -+ } -+ -+ public boolean isModified() { -+ return this.isModified; -+ } -+ -+ public String getText() { -+ return textArea.getText(); -+ } -+ - void setPosition(int pos) { - textArea.select(pos); - currentPos = pos; -*************** -*** 1618,1624 **** - if (line != -1) { - db.currentWindow = w; - } -! db.menubar.addFile(url); - w.setVisible(true); - if (activate) { - try { ---- 1717,1723 ---- - if (line != -1) { - db.currentWindow = w; - } -! // db.menubar.addFile(url); - w.setVisible(true); - if (activate) { - try { -*************** -*** 1752,1759 **** - Menubar(Main db) { - super(); - this.db = db; -! String[] fileItems = {"Open...", "Run...", "", "Exit"}; -! String[] fileCmds = {"Open", "Load", "", "Exit"}; - char[] fileShortCuts = {'0', 'N', '\0', 'X'}; - int[] fileAccelerators = {KeyEvent.VK_O, - KeyEvent.VK_N, ---- 1851,1860 ---- - Menubar(Main db) { - super(); - this.db = db; -! // String[] fileItems = {"Open...", "Run...", "", "Exit"}; -! // String[] fileCmds = {"Open", "Load", "", "Exit"}; -! String[] fileItems = {"Run", "Save", "", "Exit"}; -! String[] fileCmds = {"Run", "Save", "", "Exit"}; - char[] fileShortCuts = {'0', 'N', '\0', 'X'}; - int[] fileAccelerators = {KeyEvent.VK_O, - KeyEvent.VK_N, -*************** -*** 1795,1800 **** ---- 1896,1904 ---- - KeyStroke k = KeyStroke.getKeyStroke(fileAccelerators[i], Event.CTRL_MASK); - item.setAccelerator(k); - } -+ if (fileItems[i].equals("Save")) { -+ saveItem = item; -+ } - } - } - for (int i = 0; i < editItems.length; ++i) { -*************** -*** 1849,1857 **** - item.addActionListener(this); - windowMenu.add(item = new JMenuItem("Tile", 'T')); - item.addActionListener(this); -! windowMenu.addSeparator(); -! windowMenu.add(item = new JMenuItem("Console", 'C')); -! item.addActionListener(this); - add(windowMenu); - - } ---- 1953,1961 ---- - item.addActionListener(this); - windowMenu.add(item = new JMenuItem("Tile", 'T')); - item.addActionListener(this); -! // windowMenu.addSeparator(); -! // windowMenu.add(item = new JMenuItem("Console", 'C')); -! // item.addActionListener(this); - add(windowMenu); - - } -*************** -*** 1925,1935 **** ---- 2029,2044 ---- - item.addActionListener(this); - } - -+ public void setSaveEnabled(boolean state) { -+ saveItem.setEnabled(state); -+ } -+ - Main db; - JMenu windowMenu; - JCheckBoxMenuItem breakOnExceptions; - JCheckBoxMenuItem breakOnEnter; - JCheckBoxMenuItem breakOnReturn; -+ JMenuItem saveItem; - }; - - class EnterInterrupt implements Runnable { -*************** -*** 1942,1947 **** ---- 2051,2063 ---- - public void run() { - JMenu menu = db.getJMenuBar().getMenu(0); - //menu.getItem(0).setEnabled(false); // File->Load -+ -+ // disable Edit menu Cut, Copy, Paste items -+ menu = db.getJMenuBar().getMenu(1); -+ for (int i = 0; i < 3; i++) { -+ menu.getItem(i).setEnabled(false); -+ } -+ - menu = db.getJMenuBar().getMenu(2); - menu.getItem(0).setEnabled(false); // Debug->Break - int count = menu.getItemCount(); -*************** -*** 1954,1959 **** ---- 2070,2079 ---- - b = true; - } - db.toolBar.setEnabled(true); -+ -+ // set flag to disable source editing -+ db.setSourceEditingEnabled(false); -+ - // raise the debugger window - db.toFront(); - } -*************** -*** 1967,1972 **** ---- 2087,2099 ---- - public void run() { - JMenu menu = db.getJMenuBar().getMenu(0); - menu.getItem(0).setEnabled(true); // File->Load -+ -+ // enable Edit menu items -+ menu = db.getJMenuBar().getMenu(1); -+ for (int i = 0; i < 3; i++) { -+ menu.getItem(i).setEnabled(true); -+ } -+ - menu = db.getJMenuBar().getMenu(2); - menu.getItem(0).setEnabled(true); // Debug->Break - int count = menu.getItemCount() - 1; -*************** -*** 1980,1985 **** ---- 2107,2116 ---- - db.toolBar.getComponent(ci).setEnabled(b); - b = false; - } -+ -+ // set flag to enable source editing -+ db.setSourceEditingEnabled(true); -+ - //db.console.consoleTextArea.requestFocus(); - } - }; -*************** -*** 1988,2004 **** - { - String fileName; - Main db; - OpenFile(Main db, String fileName) - { - this.fileName = fileName; - this.db = db; - } - public void run() { - Context cx = Context.enter(); - ContextData contextData = ContextData.get(cx); - contextData.breakNextLine = true; - try { -! cx.compileReader(new FileReader(fileName), fileName, 1, null); - } catch (Exception exc) { - String msg = exc.getMessage(); - if (exc instanceof EcmaError) { ---- 2119,2142 ---- - { - String fileName; - Main db; -+ Reader reader = null; - OpenFile(Main db, String fileName) - { - this.fileName = fileName; - this.db = db; - } -+ OpenFile(Main db, String fileName, Reader reader) { -+ this(db, fileName); -+ this.reader = reader; -+ } - public void run() { - Context cx = Context.enter(); - ContextData contextData = ContextData.get(cx); - contextData.breakNextLine = true; - try { -! cx.compileReader( -! reader == null ? new FileReader(fileName) : reader, -! fileName, 1, null); - } catch (Exception exc) { - String msg = exc.getMessage(); - if (exc instanceof EcmaError) { -*************** -*** 2019,2047 **** - Scriptable scope; - String fileName; - Main db; - LoadFile(Main db, Scriptable scope, String fileName) { - this.scope = scope; - this.fileName = fileName; - this.db = db; - } - public void run() { - Context cx = Context.enter(); - ContextData contextData = ContextData.get(cx); - contextData.breakNextLine = true; - try { -! cx.evaluateReader(scope, new FileReader(fileName), - fileName, 1, null); - } catch (Exception exc) { - String msg = exc.getMessage(); - if (exc instanceof EcmaError) { - EcmaError err = (EcmaError)exc; - msg = err.getSourceName() + ", line " + err.getLineNumber() + ": " + msg; -! } - MessageDialogWrapper.showMessageDialog(db, - msg, - "Run", - JOptionPane.ERROR_MESSAGE); - } finally { - cx.exit(); - } - } ---- 2157,2235 ---- - Scriptable scope; - String fileName; - Main db; -+ Reader reader = null; -+ Object result = null; -+ Exception exception = null; -+ int lineNum = -1; -+ boolean sfExecute = false; -+ - LoadFile(Main db, Scriptable scope, String fileName) { - this.scope = scope; - this.fileName = fileName; - this.db = db; - } -+ -+ LoadFile(Main db, Scriptable scope, String fileName, Reader reader) { -+ this(db, scope, fileName); -+ this.reader = reader; -+ } -+ LoadFile(Main db, Scriptable scope, String fileName, Reader reader, boolean sfExecute ) { -+ this(db, scope, fileName); -+ this.reader = reader; -+ this.sfExecute = sfExecute; -+ } -+ - public void run() { -+ if ( db.officeScripts.isScriptRunning( fileName ) ) -+ { -+ exception = new Exception("The script is already executing"); -+ if ( !sfExecute ) { -+ MessageDialogWrapper.showMessageDialog(db, -+ "Script already executing", -+ "Run", -+ JOptionPane.ERROR_MESSAGE); -+ } -+ return; -+ } -+ db.officeScripts.setScriptRunning( fileName, true ); - Context cx = Context.enter(); - ContextData contextData = ContextData.get(cx); -+ if ( sfExecute ) -+ { -+ contextData.breakNextLine = false; -+ } -+ else -+ { - contextData.breakNextLine = true; -+ } -+ /* -+ FileWindow w = (FileWindow)db.getSelectedFrame(); -+ if ( sfExecute ) -+ { -+ db.swingInvoke(new SetFilePosition(db, w, -1 ) ); -+ }*/ - try { -! result = cx.evaluateReader(scope, -! reader == null ? new FileReader(fileName) : reader, - fileName, 1, null); - } catch (Exception exc) { -+ exception = exc; - String msg = exc.getMessage(); - if (exc instanceof EcmaError) { - EcmaError err = (EcmaError)exc; - msg = err.getSourceName() + ", line " + err.getLineNumber() + ": " + msg; -! -! int lineNum = err.getLineNumber() ; -! //db.swingInvoke(new SetFilePosition(db, w, lineNum ) ); -! if ( !sfExecute ) { - MessageDialogWrapper.showMessageDialog(db, - msg, - "Run", - JOptionPane.ERROR_MESSAGE); -+ } -+ } - } finally { -+ db.officeScripts.setScriptRunning( fileName, false ); - cx.exit(); - } - } -*************** -*** 2416,2428 **** - super.setVisible(b); - if (b) { - // this needs to be done after the window is visible -! console.consoleTextArea.requestFocus(); - context.split.setDividerLocation(0.5); - try { -! console.setMaximum(true); -! console.setSelected(true); -! console.show(); -! console.consoleTextArea.requestFocus(); - } catch (Exception exc) { - } - } ---- 2604,2616 ---- - super.setVisible(b); - if (b) { - // this needs to be done after the window is visible -! // console.consoleTextArea.requestFocus(); - context.split.setDividerLocation(0.5); - try { -! // console.setMaximum(true); -! // console.setSelected(true); -! // console.show(); -! // console.consoleTextArea.requestFocus(); - } catch (Exception exc) { - } - } -*************** -*** 2449,2483 **** - - Hashtable functionNames = new Hashtable(); - -- ScriptItem getScriptItem(DebuggableScript fnOrScript) { -- ScriptItem item = (ScriptItem)scriptItems.get(fnOrScript); -- if (item == null) { -- String url = getNormilizedUrl(fnOrScript); -- SourceInfo si = (SourceInfo)sourceNames.get(url); -- if (si == null) { -- if (!fnOrScript.isGeneratedScript()) { -- // Not eval or Function, try to load it from URL -- String source = null; -- try { -- InputStream is = openSource(url); -- try { source = readSource(is); } -- finally { is.close(); } -- } catch (IOException ex) { -- System.err.println -- ("Failed to load source from "+url+": "+ ex); -- } -- if (source != null) { -- si = registerSource(url, source); -- } -- } -- } -- if (si != null) { -- item = registerScript(si, fnOrScript); -- } -- } -- return item; -- } -- - /* Debugger Interface */ - - public void handleCompilationDone(Context cx, DebuggableScript fnOrScript, ---- 2637,2642 ---- -*************** -*** 2490,2496 **** - - String getNormilizedUrl(DebuggableScript fnOrScript) { - String url = fnOrScript.getSourceName(); -! if (url == null) { url = ""; } - else { - // Not to produce window for eval from different lines, - // strip line numbers, i.e. replace all #[0-9]+\(eval\) by (eval) ---- 2649,2655 ---- - - String getNormilizedUrl(DebuggableScript fnOrScript) { - String url = fnOrScript.getSourceName(); -! if (url == null) { url = "document"; } - else { - // Not to produce window for eval from different lines, - // strip line numbers, i.e. replace all #[0-9]+\(eval\) by (eval) -*************** -*** 2601,2607 **** - if (si == null) { - si = new SourceInfo(sourceUrl, source); - sourceNames.put(sourceUrl, si); -! } else { - si.setSource(source); - } - } ---- 2760,2766 ---- - if (si == null) { - si = new SourceInfo(sourceUrl, source); - sourceNames.put(sourceUrl, si); -! } else if (!source.equals(si.getSource())) { - si.setSource(source); - } - } -*************** -*** 2762,2768 **** - desk = new JDesktopPane(); - desk.setPreferredSize(new Dimension(600, 300)); - desk.setMinimumSize(new Dimension(150, 50)); -! desk.add(console = new JSInternalConsole("JavaScript Console")); - context = new ContextWindow(this); - context.setPreferredSize(new Dimension(600, 120)); - context.setMinimumSize(new Dimension(50, 50)); ---- 2921,2927 ---- - desk = new JDesktopPane(); - desk.setPreferredSize(new Dimension(600, 300)); - desk.setMinimumSize(new Dimension(150, 50)); -! // desk.add(console = new JSInternalConsole("JavaScript Console")); - context = new ContextWindow(this); - context.setPreferredSize(new Dimension(600, 120)); - context.setMinimumSize(new Dimension(50, 50)); -*************** -*** 2871,2877 **** - FrameHelper frame = contextData.getFrame(frameIndex); - String sourceName = frame.getUrl(); - if (sourceName == null || sourceName.equals("")) { -! console.show(); - helper.reset(); - return; - } ---- 3030,3036 ---- - FrameHelper frame = contextData.getFrame(frameIndex); - String sourceName = frame.getUrl(); - if (sourceName == null || sourceName.equals("")) { -! // console.show(); - helper.reset(); - return; - } -*************** -*** 2895,2900 **** ---- 3054,3072 ---- - int dispatcherIsWaiting = 0; - Context currentContext = null; - -+ // Flag used to establish whether source code editing is allowed in -+ // the debugger, switched on and off depending on whether a debug session -+ // is active -+ boolean sourceEditingEnabled = true; -+ -+ public boolean isSourceEditingEnabled() { -+ return sourceEditingEnabled; -+ } -+ -+ void setSourceEditingEnabled(boolean b) { -+ sourceEditingEnabled = b; -+ } -+ - Context getCurrentContext() { - return currentContext; - } -*************** -*** 3028,3041 **** - swingInvoke(CreateFileWindow.action(this, si, line)); - } - } else { -! if (console.isVisible()) { - final JSInternalConsole finalConsole = console; - swingInvoke(new Runnable() { - public void run() { - finalConsole.show(); - } - }); -! } - } - swingInvoke(new EnterInterrupt(this, cx)); - swingInvoke(new UpdateContext(this, cx)); ---- 3200,3213 ---- - swingInvoke(CreateFileWindow.action(this, si, line)); - } - } else { -! /* if (console.isVisible()) { - final JSInternalConsole finalConsole = console; - swingInvoke(new Runnable() { - public void run() { - finalConsole.show(); - } - }); -! } */ - } - swingInvoke(new EnterInterrupt(this, cx)); - swingInvoke(new UpdateContext(this, cx)); -*************** -*** 3217,3222 **** ---- 3389,3402 ---- - fileName)).start(); - } - } -+ } else if (cmd.equals("Run")) { -+ FileWindow w = (FileWindow)getSelectedFrame(); -+ if (w != null) -+ w.load(); -+ } else if (cmd.equals("Save")) { -+ FileWindow w = (FileWindow)getSelectedFrame(); -+ if (w != null) -+ w.save(); - } else if (cmd.equals("More Windows...")) { - MoreWindows dlg = new MoreWindows(this, fileWindows, - "Window", "Files"); -*************** -*** 3509,3514 **** ---- 3689,3748 ---- - } - } - -+ JInternalFrame getFrameForUrl( URL url ) -+ { -+ JInternalFrame[] frames = desk.getAllFrames(); -+ for (int i = 0; i < frames.length; i++) { -+ FileWindow w = (FileWindow)frames[i]; -+ if ( url.toString().equals( w.getUrl() ) ) { -+ return w; ++ + private ClassLoader parentLoader; ++ ++ private ClassLoader contextLoader; ++ ++ // We'd like to use "Thread.getContextClassLoader", but ++ // that's only available on Java2. ++ private static Method method_getContextClassLoader; ++ ++ static { ++ try { ++ // Don't use "Thread.class": that performs the lookup ++ // in the class initializer, which doesn't allow us to ++ // catch possible security exceptions. ++ Class threadClass = Class.forName("java.lang.Thread"); ++ method_getContextClassLoader = ++ threadClass.getDeclaredMethod("getContextClassLoader", ++ new Class[0]); ++ } catch (ClassNotFoundException e) { ++ } catch (NoSuchMethodException e) { ++ } catch (SecurityException e) { ++ } ++ } + } +--- misc/rhino1_5R5/toolsrc/build.xml Thu Mar 25 21:54:34 2004 ++++ misc/build/rhino1_5R5/toolsrc/build.xml Fri Mar 28 17:24:23 2008 +@@ -20,46 +20,10 @@ + +- +- ++ + + + +- +- import java.awt.Component; +- +- package org.mozilla.javascript.tools.debugger; +- import java.awt.Component; +- +- +- +- import javax.swing.tree.*; +- +- package org.mozilla.javascript.tools.debugger; +- import javax.swing.tree.*; +- +- +- +- import javax.swing.*; +- +- package org.mozilla.javascript.tools.debugger; +- import javax.swing.*; +- +- +- +- import javax.swing.tree.TreeModel; +- +- package org.mozilla.javascript.tools.debugger; +- import javax.swing.tree.TreeModel; +- +- +- +- import javax.swing.JTree; +- +- package org.mozilla.javascript.tools.debugger; +- import javax.swing.JTree; +- +- + + + +--- misc/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/Main.java Thu Mar 25 21:54:34 2004 ++++ misc/build/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/Main.java Fri Mar 28 17:24:23 2008 +@@ -470,15 +470,21 @@ + case KeyEvent.VK_BACK_SPACE: + case KeyEvent.VK_ENTER: + case KeyEvent.VK_DELETE: ++ if (w.isEditable() == false) { + e.consume(); ++ } + break; + } + } + public void keyTyped(KeyEvent e) { ++ if (w.isEditable() == false) { + e.consume(); ++ } + } + public void keyReleased(KeyEvent e) { ++ if (w.isEditable() == false) { + e.consume(); ++ } + } + } + +@@ -879,7 +885,7 @@ + } + }; + +-class FileWindow extends JInternalFrame implements ActionListener { ++class FileWindow extends JInternalFrame implements ActionListener, DocumentListener { + + Main db; + SourceInfo sourceInfo; +@@ -888,15 +894,16 @@ + JScrollPane p; + int currentPos; + JLabel statusBar; ++ boolean isModified = false; + + public void actionPerformed(ActionEvent e) { + String cmd = e.getActionCommand(); + if (cmd.equals("Cut")) { +- // textArea.cut(); ++ textArea.cut(); + } else if (cmd.equals("Copy")) { + textArea.copy(); + } else if (cmd.equals("Paste")) { +- // textArea.paste(); ++ textArea.paste(); + } + } + +@@ -910,17 +917,73 @@ + } + + void load() { +- Scriptable scope = db.getScope(); ++ //Scriptable scope = db.getScope(); ++ Scriptable scope = db.officeScripts.getScriptScope( getUrl() ); ++ if ( scope == null ) ++ { ++ scope = db.getScope(); ++ } + if (scope == null) { + MessageDialogWrapper.showMessageDialog(db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE); + } else { + String url = getUrl(); + if (url != null) { +- new Thread(new LoadFile(db,scope,url)).start(); ++ new Thread(new LoadFile(db,scope, url, new StringReader(textArea.getText()))).start(); + } + } + } + ++ void save() { ++ if (getUrl() != null) { ++ OutputStream os = null; ++ try { ++ if ( getUrl().startsWith("vnd.sun.star") ) ++ { ++ URL scriptUrl = db.officeScripts.getScriptUrl( getUrl() ); ++ if ( scriptUrl == null ) ++ { ++ throw new IOException("Can't optain stream for " + getUrl() ); ++ } ++ os = scriptUrl.openConnection().getOutputStream(); ++ } ++ else ++ { ++ os = new FileOutputStream( getUrl() ); ++ } ++ String s = textArea.getText(); ++ os.write(s.getBytes(), 0, s.length()); ++ ++ this.isModified = false; ++ } ++ catch (IOException ioe) { ++ JOptionPane.showMessageDialog(this, ++ "Error saving file: " + ioe.getMessage(), ++ "Error", JOptionPane.ERROR_MESSAGE); ++ } ++ finally ++ { ++ if ( os != null ) ++ { ++ try ++ { ++ os.close(); ++ os = null; ++ } ++ catch( IOException ioe ) ++ { ++ System.err.println("Error closing stream: " + ioe.getMessage() ); ++ ioe.printStackTrace(); ++ } + } + } -+ return null; -+ } -+ public void highlighLineInSelectedWindow(URL url, int lineNum ){ -+ //FileWindow w = (FileWindow)getFrameForUrl( url ); -+ FileWindow w = (FileWindow)getSelectedFrame(); -+ if (w != null) -+ { -+ if ( lineNum > -1 ) -+ swingInvoke(new SetFilePosition(this, w, lineNum ) ); -+ } -+ } -+ public Object runSelectedWindow( URL scriptUrl ) throws Exception -+ { -+ Object result = null; -+ FileWindow w = (FileWindow)getSelectedFrame(); -+ //FileWindow w = (FileWindow)getFrameForUrl( scriptUrl ); -+ w.toFront(); -+ if (w != null) -+ { -+ Scriptable scope = w.db.getScope(); -+ if (scope == null) -+ { -+ MessageDialogWrapper.showMessageDialog(w.db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE); -+ result = null; -+ } -+ else -+ { -+ String url = w.getUrl(); -+ Thread executorThread = null; -+ if (url != null) -+ { -+ LoadFile executor = new LoadFile(w.db,scope, url, new StringReader(w.textArea.getText()), true ); -+ executor.run(); -+ result = executor.result; -+ if ( executor.exception != null ) -+ { -+ throw executor.exception; -+ } -+ } -+ } -+ } -+ return result; ++ } ++ } ++ ++ public boolean isEditable() { ++ return db.isSourceEditingEnabled(); ++ } ++ ++ + public int getPosition(int line) { + int result = -1; + try { +@@ -953,7 +1016,7 @@ + fileHeader.repaint(); + } + } +- ++ public Main getDB() { return db; } + FileWindow(Main db, SourceInfo sourceInfo) { + super(SourceInfo.getShortName(sourceInfo.getUrl()), + true, true, true, true); +@@ -972,6 +1035,14 @@ + pack(); + updateText(); + textArea.select(0); ++ addInternalFrameListener( new InternalFrameAdapter() { ++ public void internalFrameClosed(InternalFrameEvent e) { ++ // clean up scriptItems and sourceNames hashes ++ getDB().removeScript( getUrl() ); ++ // remove scripts for officeScripts ++ getDB().officeScripts.deleteScript( getUrl() ); ++ } ++ } ); + } + + private void updateToolTip() { +@@ -990,7 +1061,10 @@ + void updateText() { + String newText = sourceInfo.getSource(); + if (!textArea.getText().equals(newText)) { ++ textArea.getDocument().removeDocumentListener(this); + textArea.setText(newText); ++ this.isModified = false; ++ textArea.getDocument().addDocumentListener(this); + int pos = 0; + if (currentPos != -1) { + pos = currentPos; +@@ -1001,6 +1075,31 @@ + fileHeader.repaint(); + } + ++ /* Implementation of DocumentListener interface */ ++ public void insertUpdate(DocumentEvent e) { ++ doChanged(e); ++ } ++ ++ public void removeUpdate(DocumentEvent e) { ++ doChanged(e); ++ } ++ ++ public void changedUpdate(DocumentEvent e) { ++ doChanged(e); ++ } ++ ++ public void doChanged(DocumentEvent e) { ++ this.isModified = true; ++ } ++ ++ public boolean isModified() { ++ return this.isModified; ++ } ++ ++ public String getText() { ++ return textArea.getText(); ++ } ++ + void setPosition(int pos) { + textArea.select(pos); + currentPos = pos; +@@ -1618,7 +1717,7 @@ + if (line != -1) { + db.currentWindow = w; + } +- db.menubar.addFile(url); ++ // db.menubar.addFile(url); + w.setVisible(true); + if (activate) { + try { +@@ -1752,8 +1851,10 @@ + Menubar(Main db) { + super(); + this.db = db; +- String[] fileItems = {"Open...", "Run...", "", "Exit"}; +- String[] fileCmds = {"Open", "Load", "", "Exit"}; ++ // String[] fileItems = {"Open...", "Run...", "", "Exit"}; ++ // String[] fileCmds = {"Open", "Load", "", "Exit"}; ++ String[] fileItems = {"Run", "Save", "", "Exit"}; ++ String[] fileCmds = {"Run", "Save", "", "Exit"}; + char[] fileShortCuts = {'0', 'N', '\0', 'X'}; + int[] fileAccelerators = {KeyEvent.VK_O, + KeyEvent.VK_N, +@@ -1795,6 +1896,9 @@ + KeyStroke k = KeyStroke.getKeyStroke(fileAccelerators[i], Event.CTRL_MASK); + item.setAccelerator(k); + } ++ if (fileItems[i].equals("Save")) { ++ saveItem = item; ++ } + } + } + for (int i = 0; i < editItems.length; ++i) { +@@ -1849,9 +1953,9 @@ + item.addActionListener(this); + windowMenu.add(item = new JMenuItem("Tile", 'T')); + item.addActionListener(this); +- windowMenu.addSeparator(); +- windowMenu.add(item = new JMenuItem("Console", 'C')); +- item.addActionListener(this); ++// windowMenu.addSeparator(); ++// windowMenu.add(item = new JMenuItem("Console", 'C')); ++// item.addActionListener(this); + add(windowMenu); + + } +@@ -1925,11 +2029,16 @@ + item.addActionListener(this); + } + ++ public void setSaveEnabled(boolean state) { ++ saveItem.setEnabled(state); ++ } ++ + Main db; + JMenu windowMenu; + JCheckBoxMenuItem breakOnExceptions; + JCheckBoxMenuItem breakOnEnter; + JCheckBoxMenuItem breakOnReturn; ++ JMenuItem saveItem; + }; + + class EnterInterrupt implements Runnable { +@@ -1942,6 +2051,13 @@ + public void run() { + JMenu menu = db.getJMenuBar().getMenu(0); + //menu.getItem(0).setEnabled(false); // File->Load ++ ++ // disable Edit menu Cut, Copy, Paste items ++ menu = db.getJMenuBar().getMenu(1); ++ for (int i = 0; i < 3; i++) { ++ menu.getItem(i).setEnabled(false); ++ } ++ + menu = db.getJMenuBar().getMenu(2); + menu.getItem(0).setEnabled(false); // Debug->Break + int count = menu.getItemCount(); +@@ -1954,6 +2070,10 @@ + b = true; + } + db.toolBar.setEnabled(true); ++ ++ // set flag to disable source editing ++ db.setSourceEditingEnabled(false); ++ + // raise the debugger window + db.toFront(); + } +@@ -1967,6 +2087,13 @@ + public void run() { + JMenu menu = db.getJMenuBar().getMenu(0); + menu.getItem(0).setEnabled(true); // File->Load ++ ++ // enable Edit menu items ++ menu = db.getJMenuBar().getMenu(1); ++ for (int i = 0; i < 3; i++) { ++ menu.getItem(i).setEnabled(true); ++ } ++ + menu = db.getJMenuBar().getMenu(2); + menu.getItem(0).setEnabled(true); // Debug->Break + int count = menu.getItemCount() - 1; +@@ -1980,6 +2107,10 @@ + db.toolBar.getComponent(ci).setEnabled(b); + b = false; + } ++ ++ // set flag to enable source editing ++ db.setSourceEditingEnabled(true); ++ + //db.console.consoleTextArea.requestFocus(); + } + }; +@@ -1988,17 +2119,24 @@ + { + String fileName; + Main db; ++ Reader reader = null; + OpenFile(Main db, String fileName) + { + this.fileName = fileName; + this.db = db; + } ++ OpenFile(Main db, String fileName, Reader reader) { ++ this(db, fileName); ++ this.reader = reader; ++ } + public void run() { + Context cx = Context.enter(); + ContextData contextData = ContextData.get(cx); + contextData.breakNextLine = true; + try { +- cx.compileReader(new FileReader(fileName), fileName, 1, null); ++ cx.compileReader( ++ reader == null ? new FileReader(fileName) : reader, ++ fileName, 1, null); + } catch (Exception exc) { + String msg = exc.getMessage(); + if (exc instanceof EcmaError) { +@@ -2019,29 +2157,79 @@ + Scriptable scope; + String fileName; + Main db; ++ Reader reader = null; ++ Object result = null; ++ Exception exception = null; ++ int lineNum = -1; ++ boolean sfExecute = false; ++ + LoadFile(Main db, Scriptable scope, String fileName) { + this.scope = scope; + this.fileName = fileName; + this.db = db; + } ++ ++ LoadFile(Main db, Scriptable scope, String fileName, Reader reader) { ++ this(db, scope, fileName); ++ this.reader = reader; ++ } ++ LoadFile(Main db, Scriptable scope, String fileName, Reader reader, boolean sfExecute ) { ++ this(db, scope, fileName); ++ this.reader = reader; ++ this.sfExecute = sfExecute; ++ } ++ + public void run() { ++ if ( db.officeScripts.isScriptRunning( fileName ) ) ++ { ++ exception = new Exception("The script is already executing"); ++ if ( !sfExecute ) { ++ MessageDialogWrapper.showMessageDialog(db, ++ "Script already executing", ++ "Run", ++ JOptionPane.ERROR_MESSAGE); ++ } ++ return; ++ } ++ db.officeScripts.setScriptRunning( fileName, true ); + Context cx = Context.enter(); + ContextData contextData = ContextData.get(cx); ++ if ( sfExecute ) ++ { ++ contextData.breakNextLine = false; ++ } ++ else ++ { + contextData.breakNextLine = true; ++ } ++ /* ++ FileWindow w = (FileWindow)db.getSelectedFrame(); ++ if ( sfExecute ) ++ { ++ db.swingInvoke(new SetFilePosition(db, w, -1 ) ); ++ }*/ + try { +- cx.evaluateReader(scope, new FileReader(fileName), ++ result = cx.evaluateReader(scope, ++ reader == null ? new FileReader(fileName) : reader, + fileName, 1, null); + } catch (Exception exc) { ++ exception = exc; + String msg = exc.getMessage(); + if (exc instanceof EcmaError) { + EcmaError err = (EcmaError)exc; + msg = err.getSourceName() + ", line " + err.getLineNumber() + ": " + msg; +- } ++ ++ int lineNum = err.getLineNumber() ; ++ //db.swingInvoke(new SetFilePosition(db, w, lineNum ) ); ++ if ( !sfExecute ) { + MessageDialogWrapper.showMessageDialog(db, + msg, + "Run", + JOptionPane.ERROR_MESSAGE); ++ } ++ } + } finally { ++ db.officeScripts.setScriptRunning( fileName, false ); + cx.exit(); + } + } +@@ -2416,13 +2604,13 @@ + super.setVisible(b); + if (b) { + // this needs to be done after the window is visible +- console.consoleTextArea.requestFocus(); ++ // console.consoleTextArea.requestFocus(); + context.split.setDividerLocation(0.5); + try { +- console.setMaximum(true); +- console.setSelected(true); +- console.show(); +- console.consoleTextArea.requestFocus(); ++ // console.setMaximum(true); ++ // console.setSelected(true); ++ // console.show(); ++ // console.consoleTextArea.requestFocus(); + } catch (Exception exc) { + } + } +@@ -2449,35 +2637,6 @@ + + Hashtable functionNames = new Hashtable(); + +- ScriptItem getScriptItem(DebuggableScript fnOrScript) { +- ScriptItem item = (ScriptItem)scriptItems.get(fnOrScript); +- if (item == null) { +- String url = getNormilizedUrl(fnOrScript); +- SourceInfo si = (SourceInfo)sourceNames.get(url); +- if (si == null) { +- if (!fnOrScript.isGeneratedScript()) { +- // Not eval or Function, try to load it from URL +- String source = null; +- try { +- InputStream is = openSource(url); +- try { source = readSource(is); } +- finally { is.close(); } +- } catch (IOException ex) { +- System.err.println +- ("Failed to load source from "+url+": "+ ex); +- } +- if (source != null) { +- si = registerSource(url, source); +- } +- } +- } +- if (si != null) { +- item = registerScript(si, fnOrScript); +- } +- } +- return item; +- } +- + /* Debugger Interface */ + + public void handleCompilationDone(Context cx, DebuggableScript fnOrScript, +@@ -2490,7 +2649,7 @@ + + String getNormilizedUrl(DebuggableScript fnOrScript) { + String url = fnOrScript.getSourceName(); +- if (url == null) { url = ""; } ++ if (url == null) { url = "document"; } + else { + // Not to produce window for eval from different lines, + // strip line numbers, i.e. replace all #[0-9]+\(eval\) by (eval) +@@ -2601,7 +2760,7 @@ + if (si == null) { + si = new SourceInfo(sourceUrl, source); + sourceNames.put(sourceUrl, si); +- } else { ++ } else if (!source.equals(si.getSource())) { + si.setSource(source); + } + } +@@ -2762,7 +2921,7 @@ + desk = new JDesktopPane(); + desk.setPreferredSize(new Dimension(600, 300)); + desk.setMinimumSize(new Dimension(150, 50)); +- desk.add(console = new JSInternalConsole("JavaScript Console")); ++ // desk.add(console = new JSInternalConsole("JavaScript Console")); + context = new ContextWindow(this); + context.setPreferredSize(new Dimension(600, 120)); + context.setMinimumSize(new Dimension(50, 50)); +@@ -2871,7 +3030,7 @@ + FrameHelper frame = contextData.getFrame(frameIndex); + String sourceName = frame.getUrl(); + if (sourceName == null || sourceName.equals("")) { +- console.show(); ++ // console.show(); + helper.reset(); + return; + } +@@ -2895,6 +3054,19 @@ + int dispatcherIsWaiting = 0; + Context currentContext = null; + ++ // Flag used to establish whether source code editing is allowed in ++ // the debugger, switched on and off depending on whether a debug session ++ // is active ++ boolean sourceEditingEnabled = true; ++ ++ public boolean isSourceEditingEnabled() { ++ return sourceEditingEnabled; ++ } ++ ++ void setSourceEditingEnabled(boolean b) { ++ sourceEditingEnabled = b; ++ } ++ + Context getCurrentContext() { + return currentContext; + } +@@ -3028,14 +3200,14 @@ + swingInvoke(CreateFileWindow.action(this, si, line)); + } + } else { +- if (console.isVisible()) { ++ /* if (console.isVisible()) { + final JSInternalConsole finalConsole = console; + swingInvoke(new Runnable() { + public void run() { + finalConsole.show(); + } + }); +- } ++ } */ + } + swingInvoke(new EnterInterrupt(this, cx)); + swingInvoke(new UpdateContext(this, cx)); +@@ -3217,6 +3389,14 @@ + fileName)).start(); + } + } ++ } else if (cmd.equals("Run")) { ++ FileWindow w = (FileWindow)getSelectedFrame(); ++ if (w != null) ++ w.load(); ++ } else if (cmd.equals("Save")) { ++ FileWindow w = (FileWindow)getSelectedFrame(); ++ if (w != null) ++ w.save(); + } else if (cmd.equals("More Windows...")) { + MoreWindows dlg = new MoreWindows(this, fileWindows, + "Window", "Files"); +@@ -3509,6 +3689,60 @@ + } + } + ++ JInternalFrame getFrameForUrl( URL url ) ++ { ++ JInternalFrame[] frames = desk.getAllFrames(); ++ for (int i = 0; i < frames.length; i++) { ++ FileWindow w = (FileWindow)frames[i]; ++ if ( url.toString().equals( w.getUrl() ) ) { ++ return w; ++ } ++ } ++ return null; ++ } ++ public void highlighLineInSelectedWindow(URL url, int lineNum ){ ++ //FileWindow w = (FileWindow)getFrameForUrl( url ); ++ FileWindow w = (FileWindow)getSelectedFrame(); ++ if (w != null) ++ { ++ if ( lineNum > -1 ) ++ swingInvoke(new SetFilePosition(this, w, lineNum ) ); ++ } ++ } ++ public Object runSelectedWindow( URL scriptUrl ) throws Exception ++ { ++ Object result = null; ++ FileWindow w = (FileWindow)getSelectedFrame(); ++ //FileWindow w = (FileWindow)getFrameForUrl( scriptUrl ); ++ w.toFront(); ++ if (w != null) ++ { ++ Scriptable scope = w.db.getScope(); ++ if (scope == null) ++ { ++ MessageDialogWrapper.showMessageDialog(w.db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE); ++ result = null; ++ } ++ else ++ { ++ String url = w.getUrl(); ++ Thread executorThread = null; ++ if (url != null) ++ { ++ LoadFile executor = new LoadFile(w.db,scope, url, new StringReader(w.textArea.getText()), true ); ++ executor.run(); ++ result = executor.result; ++ if ( executor.exception != null ) ++ { ++ throw executor.exception; ++ } ++ } ++ } ++ } ++ return result; ++ ++ } ++ + // + // public interface + // +@@ -3604,6 +3838,69 @@ + return console.getErr(); + } + ++ public void openFile(URL scriptUrl, Scriptable scope, Runnable closeCallback ) { ++ if (scope == null) { ++ MessageDialogWrapper.showMessageDialog(this, ++ "Can't compile scripts: no scope available", ++ "Open", JOptionPane.ERROR_MESSAGE); ++ } else { ++ if (scriptUrl != null) { ++ try ++ { ++ InputStreamReader reader = new InputStreamReader(scriptUrl.openStream()); ++ String fileName = null; ++ if ( scriptUrl.getProtocol().startsWith("vnd.sun.star.") ) ++ { ++ fileName = scriptUrl.toString(); ++ } ++ else ++ { ++ fileName = scriptUrl.getPath(); ++ } ++ officeScripts.addScript( fileName, scriptUrl, scope, closeCallback ); ++ //new Thread(new OpenFile(this, scope, fileName, reader )).start(); ++ swingInvoke( new OpenFile(this, fileName, reader )); ++ } ++ catch ( IOException e ) ++ { ++ MessageDialogWrapper.showMessageDialog(this, ++ "Can't open stream for script: " + e.toString(), ++ "Open", JOptionPane.ERROR_MESSAGE); ++ } ++ } ++ } ++ split1.setDividerLocation(1.0); ++ } ++ ++ public void openFile(String fileName) { ++ Scriptable scope = getScope(); ++ if (scope == null) { ++ MessageDialogWrapper.showMessageDialog(this, ++ "Can't compile scripts: no scope available", ++ "Open", JOptionPane.ERROR_MESSAGE); ++ } else { ++ if (fileName != null) { ++ new Thread(new OpenFile(this, fileName)).start(); ++ } ++ } ++ split1.setDividerLocation(1.0); ++ } ++ ++ public void openStream(InputStream in) { ++ Scriptable scope = getScope(); ++ if (scope == null) { ++ MessageDialogWrapper.showMessageDialog(this, ++ "Can't compile scripts: no scope available", ++ "Open", JOptionPane.ERROR_MESSAGE); ++ } else { ++ if (in != null) { ++ new Thread(new OpenFile(this, null, new InputStreamReader(in))).start(); ++ } ++ } ++ split1.setDividerLocation(1.0); ++ menubar.setSaveEnabled(false); ++ } ++ + public static void main(String[] args) { + try { + mainThread = Thread.currentThread(); +@@ -3633,6 +3930,163 @@ + } catch (Exception exc) { + exc.printStackTrace(); + } ++ } ++ ++ // patched Office specific interface + -+ } -+ - // - // public interface - // -*************** -*** 3604,3609 **** ---- 3838,3906 ---- - return console.getErr(); - } - -+ public void openFile(URL scriptUrl, Scriptable scope, Runnable closeCallback ) { -+ if (scope == null) { -+ MessageDialogWrapper.showMessageDialog(this, -+ "Can't compile scripts: no scope available", -+ "Open", JOptionPane.ERROR_MESSAGE); -+ } else { -+ if (scriptUrl != null) { -+ try -+ { -+ InputStreamReader reader = new InputStreamReader(scriptUrl.openStream()); -+ String fileName = null; -+ if ( scriptUrl.getProtocol().startsWith("vnd.sun.star.") ) -+ { -+ fileName = scriptUrl.toString(); -+ } -+ else -+ { -+ fileName = scriptUrl.getPath(); -+ } -+ officeScripts.addScript( fileName, scriptUrl, scope, closeCallback ); -+ //new Thread(new OpenFile(this, scope, fileName, reader )).start(); -+ swingInvoke( new OpenFile(this, fileName, reader )); -+ } -+ catch ( IOException e ) -+ { -+ MessageDialogWrapper.showMessageDialog(this, -+ "Can't open stream for script: " + e.toString(), -+ "Open", JOptionPane.ERROR_MESSAGE); -+ } -+ } -+ } -+ split1.setDividerLocation(1.0); -+ } -+ -+ public void openFile(String fileName) { -+ Scriptable scope = getScope(); -+ if (scope == null) { -+ MessageDialogWrapper.showMessageDialog(this, -+ "Can't compile scripts: no scope available", -+ "Open", JOptionPane.ERROR_MESSAGE); -+ } else { -+ if (fileName != null) { -+ new Thread(new OpenFile(this, fileName)).start(); -+ } -+ } -+ split1.setDividerLocation(1.0); -+ } -+ -+ public void openStream(InputStream in) { -+ Scriptable scope = getScope(); -+ if (scope == null) { -+ MessageDialogWrapper.showMessageDialog(this, -+ "Can't compile scripts: no scope available", -+ "Open", JOptionPane.ERROR_MESSAGE); -+ } else { -+ if (in != null) { -+ new Thread(new OpenFile(this, null, new InputStreamReader(in))).start(); -+ } -+ } -+ split1.setDividerLocation(1.0); -+ menubar.setSaveEnabled(false); -+ } -+ - public static void main(String[] args) { - try { - mainThread = Thread.currentThread(); -*************** -*** 3635,3639 **** ---- 3932,4093 ---- - } - } - -+ // patched Office specific interface ++ OfficeScriptInfo officeScripts = new OfficeScriptInfo(); ++ ++ void removeScript( String url ) ++ { ++ // Remove the FileWindow from list of open sources ++ fileWindows.remove( url ); ++ ++ // Remove sourceInfo from sourceNames, ensures that ++ // breakpoints etc are deleted ++ synchronized (sourceNames) { ++ sourceNames.remove( url ); ++ } ++ // Removes scriptItems for the script, ensures that a new open ( from openFile ) ++ // will succeed, openFile should open file but fails due to fact that ++ synchronized ( scriptItems ) ++ { ++ Iterator iter = scriptItems.entrySet().iterator(); ++ while ( iter.hasNext() ) ++ { ++ Map.Entry me = ( Map.Entry )iter.next(); ++ ScriptItem item = (ScriptItem)me.getValue(); ++ SourceInfo si = item.getSourceInfo(); ++ if ( si.getUrl().equals( url ) ) ++ { ++ //match ++ scriptItems.remove( me.getKey() ); ++ break; ++ } ++ } ++ } ++ officeScripts.deleteScript( url ); ++ } ++ ++ ++ ScriptItem getScriptItem(DebuggableScript fnOrScript) { ++ ScriptItem item = (ScriptItem)scriptItems.get(fnOrScript); ++ if (item == null) { ++ String url = getNormilizedUrl(fnOrScript); ++ SourceInfo si = (SourceInfo)sourceNames.get(url); ++ if (si == null) { ++ if (!fnOrScript.isGeneratedScript()) { ++ // Not eval or Function, try to load it from URL ++ String source = null; ++ try { ++ InputStream is = openSource(url); ++ try { source = readSource(is); } ++ finally { is.close(); } ++ } catch (IOException ex) { ++ System.err.println ++ ("Failed to load source from "+url+": "+ ex); ++ } ++ if (source != null) { ++ si = registerSource(url, source); ++ } ++ } ++ } ++ if (si != null) { ++ item = registerScript(si, fnOrScript); ++ } ++ } ++ ++ return item; ++ } ++ ++ public void showScriptWindow(URL url ){ ++ String key = url.getPath(); ++ if ( url.getProtocol().startsWith("vnd.sun.star") ) ++ { ++ key = url.toString(); ++ } ++ FileWindow w = (FileWindow)getFileWindow( key ); ++ if ( w != null ) ++ { ++ //w.maximize(); ++ desk.getDesktopManager().deiconifyFrame(w); ++ desk.getDesktopManager().activateFrame(w); ++ w.show(); ++ w.toFront(); ++ } ++ } ++ ++ public void highlighLineInScriptWindow(URL url, int lineNum ){ ++ String key = url.getPath(); ++ if ( url.getProtocol().startsWith("vnd.sun.star") ) ++ { ++ key = url.getPath(); ++ } ++ FileWindow w = (FileWindow)getFileWindow( key ); ++ if (w != null) ++ { ++ if ( lineNum > -1 ) ++ swingInvoke(new SetFilePosition(this, w, lineNum ) ); ++ } ++ } ++ public Object runScriptWindow( URL scriptUrl ) throws Exception ++ { ++ String key = scriptUrl.getPath(); ++ if ( scriptUrl.getProtocol().startsWith("vnd.sun.star") ) ++ { ++ key = scriptUrl.toString(); ++ } ++ FileWindow w = (FileWindow)getFileWindow( key ); ++ Object result = null; ++ w.toFront(); ++ if (w != null) ++ { ++ //Scriptable scope = w.db.getScope(); ++ Scriptable scope = w.db.officeScripts.getScriptScope( key ); ++ if (scope == null) ++ { ++ MessageDialogWrapper.showMessageDialog(w.db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE); ++ result = null; ++ } ++ else ++ { ++ String url = w.getUrl(); ++ Thread executorThread = null; ++ if (url != null) ++ { ++ LoadFile executor = new LoadFile(w.db,scope, url, new StringReader(w.textArea.getText()), true ); ++ executor.run(); ++ result = executor.result; ++ if ( executor.exception != null ) ++ { ++ throw executor.exception; ++ } ++ } ++ } ++ } ++ return result; ++ ++ } ++ ++ public boolean isModified( URL url ) ++ { ++ String key = url.getPath(); ++ if ( url.getProtocol().startsWith("vnd.sun.star") ) ++ { ++ key = url.toString(); ++ } ++ FileWindow w = (FileWindow)getFileWindow( key ); ++ return w.isModified(); ++ } ++ ++ public String getText( URL url ) ++ { ++ String key = url.toString(); ++ if ( url.getProtocol().startsWith("vnd.sun.star") ) ++ { ++ key = url.toString(); ++ } ++ FileWindow w = (FileWindow)getFileWindow( key ); ++ return w.getText(); + } + + } +--- misc/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/OfficeScriptInfo.java Fri Mar 28 17:25:34 2008 ++++ misc/build/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/OfficeScriptInfo.java Fri Mar 28 17:24:59 2008 +@@ -1 +1,133 @@ +-dummy ++/************************************************************************* ++ * ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * Copyright 2008 by Sun Microsystems, Inc. ++ * ++ * OpenOffice.org - a multi-platform office productivity suite ++ * ++ * $RCSfile: rhino1_5R5.patch,v $ ++ * $Revision: 1.3 $ ++ * ++ * This file is part of OpenOffice.org. ++ * ++ * OpenOffice.org is free software: you can redistribute it and/or modify ++ * it under the terms of the GNU Lesser General Public License version 3 ++ * only, as published by the Free Software Foundation. ++ * ++ * OpenOffice.org is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU Lesser General Public License version 3 for more details ++ * (a copy is included in the LICENSE file that accompanied this code). ++ * ++ * You should have received a copy of the GNU Lesser General Public License ++ * version 3 along with OpenOffice.org. If not, see ++ * ++ * for a copy of the LGPLv3 License. ++ * ++ ************************************************************************/ ++ ++ ++package org.mozilla.javascript.tools.debugger; ++import java.net.URL; ++import java.util.Hashtable; ++import org.mozilla.javascript.Scriptable; ++ ++public class OfficeScriptInfo ++{ ++ private Hashtable loadedSFScripts = new Hashtable(); ++ ++ public void addScript( URL url, Scriptable scope, Runnable closeCallback ) ++ { ++ addScript( url.toString(), url, scope, closeCallback ); ++ } ++ ++ public void addScript( String key, URL url, Scriptable scope, Runnable closeCallback ) ++ { ++ SFScriptInfo si = (SFScriptInfo)loadedSFScripts.get( key ); ++ if ( si == null ) ++ { ++ si = new SFScriptInfo(); ++ si.url = url; ++ si.scope = scope; ++ si.closeCallback = closeCallback; ++ loadedSFScripts.put( key, si ); ++ } ++ } ++ ++ public void deleteScript( String key ) ++ { ++ SFScriptInfo info = (SFScriptInfo)loadedSFScripts.remove( key ); ++ if ( info != null ) ++ { ++ if ( info.closeCallback != null ) ++ { ++ System.out.println("** In removeSFScriptInfo have callback for " + key ); ++ info.closeCallback.run(); // really need to do this in seperate thread???? ++ } ++ } ++ } ++ ++ public Scriptable getScriptScope( String key ) ++ { ++ Scriptable result = null; ++ SFScriptInfo info = (SFScriptInfo)loadedSFScripts.get( key ); ++ if ( info != null ) ++ { ++ result = info.scope; ++ } ++ return result; ++ } + -+ OfficeScriptInfo officeScripts = new OfficeScriptInfo(); -+ -+ void removeScript( String url ) -+ { -+ // Remove the FileWindow from list of open sources -+ fileWindows.remove( url ); -+ -+ // Remove sourceInfo from sourceNames, ensures that -+ // breakpoints etc are deleted -+ synchronized (sourceNames) { -+ sourceNames.remove( url ); -+ } -+ // Removes scriptItems for the script, ensures that a new open ( from openFile ) -+ // will succeed, openFile should open file but fails due to fact that -+ synchronized ( scriptItems ) -+ { -+ Iterator iter = scriptItems.entrySet().iterator(); -+ while ( iter.hasNext() ) -+ { -+ Map.Entry me = ( Map.Entry )iter.next(); -+ ScriptItem item = (ScriptItem)me.getValue(); -+ SourceInfo si = item.getSourceInfo(); -+ if ( si.getUrl().equals( url ) ) -+ { -+ //match -+ scriptItems.remove( me.getKey() ); -+ break; -+ } -+ } -+ } -+ officeScripts.deleteScript( url ); -+ } -+ -+ -+ ScriptItem getScriptItem(DebuggableScript fnOrScript) { -+ ScriptItem item = (ScriptItem)scriptItems.get(fnOrScript); -+ if (item == null) { -+ String url = getNormilizedUrl(fnOrScript); -+ SourceInfo si = (SourceInfo)sourceNames.get(url); -+ if (si == null) { -+ if (!fnOrScript.isGeneratedScript()) { -+ // Not eval or Function, try to load it from URL -+ String source = null; -+ try { -+ InputStream is = openSource(url); -+ try { source = readSource(is); } -+ finally { is.close(); } -+ } catch (IOException ex) { -+ System.err.println -+ ("Failed to load source from "+url+": "+ ex); -+ } -+ if (source != null) { -+ si = registerSource(url, source); -+ } -+ } -+ } -+ if (si != null) { -+ item = registerScript(si, fnOrScript); -+ } -+ } -+ -+ return item; -+ } -+ -+ public void showScriptWindow(URL url ){ -+ String key = url.getPath(); -+ if ( url.getProtocol().startsWith("vnd.sun.star") ) -+ { -+ key = url.toString(); -+ } -+ FileWindow w = (FileWindow)getFileWindow( key ); -+ if ( w != null ) -+ { -+ //w.maximize(); -+ desk.getDesktopManager().deiconifyFrame(w); -+ desk.getDesktopManager().activateFrame(w); -+ w.show(); -+ w.toFront(); -+ } -+ } -+ -+ public void highlighLineInScriptWindow(URL url, int lineNum ){ -+ String key = url.getPath(); -+ if ( url.getProtocol().startsWith("vnd.sun.star") ) -+ { -+ key = url.getPath(); -+ } -+ FileWindow w = (FileWindow)getFileWindow( key ); -+ if (w != null) -+ { -+ if ( lineNum > -1 ) -+ swingInvoke(new SetFilePosition(this, w, lineNum ) ); -+ } -+ } -+ public Object runScriptWindow( URL scriptUrl ) throws Exception -+ { -+ String key = scriptUrl.getPath(); -+ if ( scriptUrl.getProtocol().startsWith("vnd.sun.star") ) -+ { -+ key = scriptUrl.toString(); -+ } -+ FileWindow w = (FileWindow)getFileWindow( key ); -+ Object result = null; -+ w.toFront(); -+ if (w != null) -+ { -+ //Scriptable scope = w.db.getScope(); -+ Scriptable scope = w.db.officeScripts.getScriptScope( key ); -+ if (scope == null) -+ { -+ MessageDialogWrapper.showMessageDialog(w.db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE); -+ result = null; -+ } -+ else -+ { -+ String url = w.getUrl(); -+ Thread executorThread = null; -+ if (url != null) -+ { -+ LoadFile executor = new LoadFile(w.db,scope, url, new StringReader(w.textArea.getText()), true ); -+ executor.run(); -+ result = executor.result; -+ if ( executor.exception != null ) -+ { -+ throw executor.exception; -+ } -+ } -+ } -+ } -+ return result; -+ -+ } -+ -+ public boolean isModified( URL url ) -+ { -+ String key = url.getPath(); -+ if ( url.getProtocol().startsWith("vnd.sun.star") ) -+ { -+ key = url.toString(); -+ } -+ FileWindow w = (FileWindow)getFileWindow( key ); -+ return w.isModified(); -+ } -+ -+ public String getText( URL url ) -+ { -+ String key = url.toString(); -+ if ( url.getProtocol().startsWith("vnd.sun.star") ) -+ { -+ key = url.toString(); -+ } -+ FileWindow w = (FileWindow)getFileWindow( key ); -+ return w.getText(); -+ } -+ - } - ++ public URL getScriptUrl( String key ) ++ { ++ URL result = null; ++ SFScriptInfo info = (SFScriptInfo)loadedSFScripts.get( key ); ++ if ( info != null ) ++ { ++ result = info.url; ++ } ++ return result; ++ } ++ public boolean hasScript( String key ) ++ { ++ boolean result = true; ++ SFScriptInfo info = (SFScriptInfo)loadedSFScripts.get( key ); ++ if ( info == null ) ++ { ++ result = false; ++ } ++ return result; ++ } ++ ++ public void setScriptRunning( String key, boolean running ) ++ { ++ SFScriptInfo info = (SFScriptInfo)loadedSFScripts.get( key ); ++ if ( info != null ) ++ { ++ info.isExecuting = running; ++ } ++ } ++ ++ public boolean isScriptRunning( String key ) ++ { ++ boolean result = false; ++ SFScriptInfo info = (SFScriptInfo)loadedSFScripts.get( key ); ++ if ( info != null ) ++ { ++ result = info.isExecuting; ++ } ++ return result; ++ } ++ ++ ++ ++ class SFScriptInfo ++ { ++ Scriptable scope; ++ boolean isExecuting; ++ URL url; ++ Runnable closeCallback; ++ } ++} +--- misc/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/shell/JavaPolicySecurity.java Thu Mar 25 21:54:34 2004 ++++ misc/build/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/shell/JavaPolicySecurity.java Fri Mar 28 17:24:23 2008 +@@ -36,6 +36,7 @@ + package org.mozilla.javascript.tools.shell; + + import java.security.*; ++import java.security.cert.Certificate; + import java.net.MalformedURLException; + import java.net.URL; + import java.util.Hashtable; +@@ -124,7 +125,7 @@ + + public JavaPolicySecurity() { + // To trigger error on jdk-1.1 with lazy load +- new CodeSource(null, null); ++ new CodeSource(null, (Certificate [])null); + } + + protected void callProcessFileSecure(final Context cx, +@@ -167,7 +168,7 @@ + } + + private ProtectionDomain getUrlDomain(URL url) { +- CodeSource cs = new CodeSource(url, null); ++ CodeSource cs = new CodeSource(url, (Certificate [])null); + PermissionCollection pc = Policy.getPolicy().getPermissions(cs); + return new ProtectionDomain(cs, pc); + }