1 --- misc/rhino1_5R5/src/org/mozilla/javascript/DefiningClassLoader.java Thu Mar 25 21:54:34 2004
2 +++ misc/build/rhino1_5R5/src/org/mozilla/javascript/DefiningClassLoader.java Fri Mar 28 17:24:23 2008
4 package org.mozilla.javascript;
6 import java.lang.reflect.Method;
7 +import java.lang.reflect.InvocationTargetException;
10 * Load generated classes.
12 implements GeneratedClassLoader
14 public DefiningClassLoader() {
15 - this.parentLoader = getClass().getClassLoader();
16 + init(getClass().getClassLoader());
19 public DefiningClassLoader(ClassLoader parentLoader) {
24 + private void init(ClassLoader parentLoader) {
26 this.parentLoader = parentLoader;
28 + this.contextLoader = null;
29 + if (method_getContextClassLoader != null) {
31 + this.contextLoader = (ClassLoader)
32 + method_getContextClassLoader.invoke(
33 + Thread.currentThread(),
34 + ScriptRuntime.emptyArgs);
35 + } catch (IllegalAccessException ex) {
36 + } catch (InvocationTargetException ex) {
37 + } catch (SecurityException ex) {
39 + if (this.contextLoader == this.parentLoader) {
40 + this.contextLoader = null;
46 public Class defineClass(String name, byte[] data) {
49 Class cl = findLoadedClass(name);
51 - if (parentLoader != null) {
52 - cl = parentLoader.loadClass(name);
53 + // First try parent class loader and if that does not work, try
54 + // contextLoader, but that will be null if
55 + // Thread.getContextClassLoader() == parentLoader
56 + // or on JDK 1.1 due to lack Thread.getContextClassLoader().
57 + // To avoid catching and rethrowing ClassNotFoundException
58 + // in this cases, use try/catch check only if contextLoader != null.
59 + if (contextLoader == null) {
60 + cl = loadFromParent(name);
62 - cl = findSystemClass(name);
64 + cl = loadFromParent(name);
65 + } catch (ClassNotFoundException ex) {
66 + cl = contextLoader.loadClass(name);
75 + private Class loadFromParent(String name)
76 + throws ClassNotFoundException
78 + if (parentLoader != null) {
79 + return parentLoader.loadClass(name);
81 + return findSystemClass(name);
86 private ClassLoader parentLoader;
88 + private ClassLoader contextLoader;
90 + // We'd like to use "Thread.getContextClassLoader", but
91 + // that's only available on Java2.
92 + private static Method method_getContextClassLoader;
96 + // Don't use "Thread.class": that performs the lookup
97 + // in the class initializer, which doesn't allow us to
98 + // catch possible security exceptions.
99 + Class threadClass = Class.forName("java.lang.Thread");
100 + method_getContextClassLoader =
101 + threadClass.getDeclaredMethod("getContextClassLoader",
103 + } catch (ClassNotFoundException e) {
104 + } catch (NoSuchMethodException e) {
105 + } catch (SecurityException e) {
109 --- misc/rhino1_5R5/toolsrc/build.xml 2004-03-25 21:54:34.000000000 +0100
110 +++ misc/build/rhino1_5R5/toolsrc/build.xml 2009-01-17 20:46:44.000000000 +0100
113 <project name="toolsrc" default="compile" basedir=".">
115 + <condition property="boot_refID" value="macPath" else="nonMacPath">
118 + <os family="unix"/>
121 + <path id="macPath" location="${java.home}/../Classes/classes.jar"/>
122 + <!-- rhino.jar from OpenJDK breaks build -->
123 + <path id="nonMacPath">
124 + <fileset dir="${java.home}/">
125 + <include name="jre/lib/*.jar"/>
126 + <include name="lib/*.jar"/>
127 + <exclude name="jre/lib/rhino.jar"/>
128 + <exclude name="lib/rhino.jar"/>
131 + <path id="my.bootstrap.classpath" refID="${boot_refID}"/>
133 <target name="properties">
134 <property name="nest" value=".."/>
135 <property name="build.dir" value="./build"/>
137 <!-- Download source from Sun's site, unzip it, remove
138 the files we don't need, and change the package
140 - <get src="http://java.sun.com/products/jfc/tsc/articles/treetable2/downloads/src.zip" dest="${nest}/${build.dir}/swingExSrc.zip"/>
141 - <unzip src="${nest}/${build.dir}/swingExSrc.zip" dest="${src.debugger}"/>
142 + <unzip src="../../../../../download/swingExSrc.zip" dest="${src.debugger}"/>
143 <delete file="${src.debugger}/FileSystemModel2.java" />
144 <delete file="${src.debugger}/MergeSort.java" />
145 <delete file="${src.debugger}/TreeTableExample2.java" />
146 - <replace file="${src.debugger}/AbstractCellEditor.java">
147 - <replacetoken>import java.awt.Component;</replacetoken>
149 - package org.mozilla.javascript.tools.debugger;
150 - import java.awt.Component;
153 - <replace file="${src.debugger}/AbstractTreeTableModel.java">
154 - <replacetoken>import javax.swing.tree.*;</replacetoken>
156 - package org.mozilla.javascript.tools.debugger;
157 - import javax.swing.tree.*;
160 - <replace file="${src.debugger}/JTreeTable.java">
161 - <replacetoken>import javax.swing.*;</replacetoken>
163 - package org.mozilla.javascript.tools.debugger;
164 - import javax.swing.*;
167 - <replace file="${src.debugger}/TreeTableModel.java">
168 - <replacetoken>import javax.swing.tree.TreeModel;</replacetoken>
170 - package org.mozilla.javascript.tools.debugger;
171 - import javax.swing.tree.TreeModel;
174 - <replace file="${src.debugger}/TreeTableModelAdapter.java">
175 - <replacetoken>import javax.swing.JTree;</replacetoken>
177 - package org.mozilla.javascript.tools.debugger;
178 - import javax.swing.JTree;
183 <target name="compile" depends="properties,get-swing-ex">
185 includes="org/**/*.java"
188 + <compilerarg value="-Xbootclasspath:${toString:my.bootstrap.classpath}"/>
190 <copy todir="${nest}/${classes}">
191 <fileset dir="." includes="org/**/*.properties" />
192 --- misc/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/Main.java 2004-03-25 21:54:34.000000000 +0100
193 +++ misc/build/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/Main.java 2009-01-17 20:44:22.000000000 +0100
194 @@ -470,15 +470,21 @@
195 case KeyEvent.VK_BACK_SPACE:
196 case KeyEvent.VK_ENTER:
197 case KeyEvent.VK_DELETE:
198 + if (w.isEditable() == false) {
204 public void keyTyped(KeyEvent e) {
205 + if (w.isEditable() == false) {
209 public void keyReleased(KeyEvent e) {
210 + if (w.isEditable() == false) {
220 -class FileWindow extends JInternalFrame implements ActionListener {
221 +class FileWindow extends JInternalFrame implements ActionListener, DocumentListener {
224 SourceInfo sourceInfo;
225 @@ -888,15 +894,16 @@
229 + boolean isModified = false;
231 public void actionPerformed(ActionEvent e) {
232 String cmd = e.getActionCommand();
233 if (cmd.equals("Cut")) {
236 } else if (cmd.equals("Copy")) {
238 } else if (cmd.equals("Paste")) {
239 - // textArea.paste();
244 @@ -910,17 +917,73 @@
248 - Scriptable scope = db.getScope();
249 + //Scriptable scope = db.getScope();
250 + Scriptable scope = db.officeScripts.getScriptScope( getUrl() );
251 + if ( scope == null )
253 + scope = db.getScope();
256 MessageDialogWrapper.showMessageDialog(db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE);
258 String url = getUrl();
260 - new Thread(new LoadFile(db,scope,url)).start();
261 + new Thread(new LoadFile(db,scope, url, new StringReader(textArea.getText()))).start();
267 + if (getUrl() != null) {
268 + OutputStream os = null;
270 + if ( getUrl().startsWith("vnd.sun.star") )
272 + URL scriptUrl = db.officeScripts.getScriptUrl( getUrl() );
273 + if ( scriptUrl == null )
275 + throw new IOException("Can't optain stream for " + getUrl() );
277 + os = scriptUrl.openConnection().getOutputStream();
281 + os = new FileOutputStream( getUrl() );
283 + String s = textArea.getText();
284 + os.write(s.getBytes(), 0, s.length());
286 + this.isModified = false;
288 + catch (IOException ioe) {
289 + JOptionPane.showMessageDialog(this,
290 + "Error saving file: " + ioe.getMessage(),
291 + "Error", JOptionPane.ERROR_MESSAGE);
302 + catch( IOException ioe )
304 + System.err.println("Error closing stream: " + ioe.getMessage() );
305 + ioe.printStackTrace();
312 + public boolean isEditable() {
313 + return db.isSourceEditingEnabled();
317 public int getPosition(int line) {
321 fileHeader.repaint();
325 + public Main getDB() { return db; }
326 FileWindow(Main db, SourceInfo sourceInfo) {
327 super(SourceInfo.getShortName(sourceInfo.getUrl()),
328 true, true, true, true);
329 @@ -972,6 +1035,14 @@
333 + addInternalFrameListener( new InternalFrameAdapter() {
334 + public void internalFrameClosed(InternalFrameEvent e) {
335 + // clean up scriptItems and sourceNames hashes
336 + getDB().removeScript( getUrl() );
337 + // remove scripts for officeScripts
338 + getDB().officeScripts.deleteScript( getUrl() );
343 private void updateToolTip() {
344 @@ -990,7 +1061,10 @@
346 String newText = sourceInfo.getSource();
347 if (!textArea.getText().equals(newText)) {
348 + textArea.getDocument().removeDocumentListener(this);
349 textArea.setText(newText);
350 + this.isModified = false;
351 + textArea.getDocument().addDocumentListener(this);
353 if (currentPos != -1) {
355 @@ -1001,6 +1075,31 @@
356 fileHeader.repaint();
359 + /* Implementation of DocumentListener interface */
360 + public void insertUpdate(DocumentEvent e) {
364 + public void removeUpdate(DocumentEvent e) {
368 + public void changedUpdate(DocumentEvent e) {
372 + public void doChanged(DocumentEvent e) {
373 + this.isModified = true;
376 + public boolean isModified() {
377 + return this.isModified;
380 + public String getText() {
381 + return textArea.getText();
384 void setPosition(int pos) {
385 textArea.select(pos);
387 @@ -1618,7 +1717,7 @@
389 db.currentWindow = w;
391 - db.menubar.addFile(url);
392 + // db.menubar.addFile(url);
396 @@ -1752,8 +1851,10 @@
400 - String[] fileItems = {"Open...", "Run...", "", "Exit"};
401 - String[] fileCmds = {"Open", "Load", "", "Exit"};
402 + // String[] fileItems = {"Open...", "Run...", "", "Exit"};
403 + // String[] fileCmds = {"Open", "Load", "", "Exit"};
404 + String[] fileItems = {"Run", "Save", "", "Exit"};
405 + String[] fileCmds = {"Run", "Save", "", "Exit"};
406 char[] fileShortCuts = {'0', 'N', '\0', 'X'};
407 int[] fileAccelerators = {KeyEvent.VK_O,
409 @@ -1795,6 +1896,9 @@
410 KeyStroke k = KeyStroke.getKeyStroke(fileAccelerators[i], Event.CTRL_MASK);
411 item.setAccelerator(k);
413 + if (fileItems[i].equals("Save")) {
418 for (int i = 0; i < editItems.length; ++i) {
419 @@ -1849,9 +1953,9 @@
420 item.addActionListener(this);
421 windowMenu.add(item = new JMenuItem("Tile", 'T'));
422 item.addActionListener(this);
423 - windowMenu.addSeparator();
424 - windowMenu.add(item = new JMenuItem("Console", 'C'));
425 - item.addActionListener(this);
426 +// windowMenu.addSeparator();
427 +// windowMenu.add(item = new JMenuItem("Console", 'C'));
428 +// item.addActionListener(this);
432 @@ -1925,11 +2029,16 @@
433 item.addActionListener(this);
436 + public void setSaveEnabled(boolean state) {
437 + saveItem.setEnabled(state);
442 JCheckBoxMenuItem breakOnExceptions;
443 JCheckBoxMenuItem breakOnEnter;
444 JCheckBoxMenuItem breakOnReturn;
445 + JMenuItem saveItem;
448 class EnterInterrupt implements Runnable {
449 @@ -1942,6 +2051,13 @@
451 JMenu menu = db.getJMenuBar().getMenu(0);
452 //menu.getItem(0).setEnabled(false); // File->Load
454 + // disable Edit menu Cut, Copy, Paste items
455 + menu = db.getJMenuBar().getMenu(1);
456 + for (int i = 0; i < 3; i++) {
457 + menu.getItem(i).setEnabled(false);
460 menu = db.getJMenuBar().getMenu(2);
461 menu.getItem(0).setEnabled(false); // Debug->Break
462 int count = menu.getItemCount();
463 @@ -1954,6 +2070,10 @@
466 db.toolBar.setEnabled(true);
468 + // set flag to disable source editing
469 + db.setSourceEditingEnabled(false);
471 // raise the debugger window
474 @@ -1967,6 +2087,13 @@
476 JMenu menu = db.getJMenuBar().getMenu(0);
477 menu.getItem(0).setEnabled(true); // File->Load
479 + // enable Edit menu items
480 + menu = db.getJMenuBar().getMenu(1);
481 + for (int i = 0; i < 3; i++) {
482 + menu.getItem(i).setEnabled(true);
485 menu = db.getJMenuBar().getMenu(2);
486 menu.getItem(0).setEnabled(true); // Debug->Break
487 int count = menu.getItemCount() - 1;
488 @@ -1980,6 +2107,10 @@
489 db.toolBar.getComponent(ci).setEnabled(b);
493 + // set flag to enable source editing
494 + db.setSourceEditingEnabled(true);
496 //db.console.consoleTextArea.requestFocus();
499 @@ -1988,17 +2119,24 @@
503 + Reader reader = null;
504 OpenFile(Main db, String fileName)
506 this.fileName = fileName;
509 + OpenFile(Main db, String fileName, Reader reader) {
510 + this(db, fileName);
511 + this.reader = reader;
514 Context cx = Context.enter();
515 ContextData contextData = ContextData.get(cx);
516 contextData.breakNextLine = true;
518 - cx.compileReader(new FileReader(fileName), fileName, 1, null);
520 + reader == null ? new FileReader(fileName) : reader,
521 + fileName, 1, null);
522 } catch (Exception exc) {
523 String msg = exc.getMessage();
524 if (exc instanceof EcmaError) {
525 @@ -2019,29 +2157,79 @@
529 + Reader reader = null;
530 + Object result = null;
531 + Exception exception = null;
533 + boolean sfExecute = false;
535 LoadFile(Main db, Scriptable scope, String fileName) {
537 this.fileName = fileName;
541 + LoadFile(Main db, Scriptable scope, String fileName, Reader reader) {
542 + this(db, scope, fileName);
543 + this.reader = reader;
545 + LoadFile(Main db, Scriptable scope, String fileName, Reader reader, boolean sfExecute ) {
546 + this(db, scope, fileName);
547 + this.reader = reader;
548 + this.sfExecute = sfExecute;
552 + if ( db.officeScripts.isScriptRunning( fileName ) )
554 + exception = new Exception("The script is already executing");
555 + if ( !sfExecute ) {
556 + MessageDialogWrapper.showMessageDialog(db,
557 + "Script already executing",
559 + JOptionPane.ERROR_MESSAGE);
563 + db.officeScripts.setScriptRunning( fileName, true );
564 Context cx = Context.enter();
565 ContextData contextData = ContextData.get(cx);
568 + contextData.breakNextLine = false;
572 contextData.breakNextLine = true;
575 + FileWindow w = (FileWindow)db.getSelectedFrame();
578 + db.swingInvoke(new SetFilePosition(db, w, -1 ) );
581 - cx.evaluateReader(scope, new FileReader(fileName),
582 + result = cx.evaluateReader(scope,
583 + reader == null ? new FileReader(fileName) : reader,
585 } catch (Exception exc) {
587 String msg = exc.getMessage();
588 if (exc instanceof EcmaError) {
589 EcmaError err = (EcmaError)exc;
590 msg = err.getSourceName() + ", line " + err.getLineNumber() + ": " + msg;
593 + int lineNum = err.getLineNumber() ;
594 + //db.swingInvoke(new SetFilePosition(db, w, lineNum ) );
595 + if ( !sfExecute ) {
596 MessageDialogWrapper.showMessageDialog(db,
599 JOptionPane.ERROR_MESSAGE);
603 + db.officeScripts.setScriptRunning( fileName, false );
607 @@ -2416,13 +2604,13 @@
610 // this needs to be done after the window is visible
611 - console.consoleTextArea.requestFocus();
612 + // console.consoleTextArea.requestFocus();
613 context.split.setDividerLocation(0.5);
615 - console.setMaximum(true);
616 - console.setSelected(true);
618 - console.consoleTextArea.requestFocus();
619 + // console.setMaximum(true);
620 + // console.setSelected(true);
622 + // console.consoleTextArea.requestFocus();
623 } catch (Exception exc) {
626 @@ -2449,35 +2637,6 @@
628 Hashtable functionNames = new Hashtable();
630 - ScriptItem getScriptItem(DebuggableScript fnOrScript) {
631 - ScriptItem item = (ScriptItem)scriptItems.get(fnOrScript);
632 - if (item == null) {
633 - String url = getNormilizedUrl(fnOrScript);
634 - SourceInfo si = (SourceInfo)sourceNames.get(url);
636 - if (!fnOrScript.isGeneratedScript()) {
637 - // Not eval or Function, try to load it from URL
638 - String source = null;
640 - InputStream is = openSource(url);
641 - try { source = readSource(is); }
642 - finally { is.close(); }
643 - } catch (IOException ex) {
645 - ("Failed to load source from "+url+": "+ ex);
647 - if (source != null) {
648 - si = registerSource(url, source);
653 - item = registerScript(si, fnOrScript);
659 /* Debugger Interface */
661 public void handleCompilationDone(Context cx, DebuggableScript fnOrScript,
662 @@ -2490,7 +2649,7 @@
664 String getNormilizedUrl(DebuggableScript fnOrScript) {
665 String url = fnOrScript.getSourceName();
666 - if (url == null) { url = "<stdin>"; }
667 + if (url == null) { url = "document"; }
669 // Not to produce window for eval from different lines,
670 // strip line numbers, i.e. replace all #[0-9]+\(eval\) by (eval)
671 @@ -2601,7 +2760,7 @@
673 si = new SourceInfo(sourceUrl, source);
674 sourceNames.put(sourceUrl, si);
676 + } else if (!source.equals(si.getSource())) {
677 si.setSource(source);
680 @@ -2762,7 +2921,7 @@
681 desk = new JDesktopPane();
682 desk.setPreferredSize(new Dimension(600, 300));
683 desk.setMinimumSize(new Dimension(150, 50));
684 - desk.add(console = new JSInternalConsole("JavaScript Console"));
685 + // desk.add(console = new JSInternalConsole("JavaScript Console"));
686 context = new ContextWindow(this);
687 context.setPreferredSize(new Dimension(600, 120));
688 context.setMinimumSize(new Dimension(50, 50));
689 @@ -2871,7 +3030,7 @@
690 FrameHelper frame = contextData.getFrame(frameIndex);
691 String sourceName = frame.getUrl();
692 if (sourceName == null || sourceName.equals("<stdin>")) {
698 @@ -2895,6 +3054,19 @@
699 int dispatcherIsWaiting = 0;
700 Context currentContext = null;
702 + // Flag used to establish whether source code editing is allowed in
703 + // the debugger, switched on and off depending on whether a debug session
705 + boolean sourceEditingEnabled = true;
707 + public boolean isSourceEditingEnabled() {
708 + return sourceEditingEnabled;
711 + void setSourceEditingEnabled(boolean b) {
712 + sourceEditingEnabled = b;
715 Context getCurrentContext() {
716 return currentContext;
718 @@ -3028,14 +3200,14 @@
719 swingInvoke(CreateFileWindow.action(this, si, line));
722 - if (console.isVisible()) {
723 + /* if (console.isVisible()) {
724 final JSInternalConsole finalConsole = console;
725 swingInvoke(new Runnable() {
733 swingInvoke(new EnterInterrupt(this, cx));
734 swingInvoke(new UpdateContext(this, cx));
735 @@ -3217,6 +3389,14 @@
739 + } else if (cmd.equals("Run")) {
740 + FileWindow w = (FileWindow)getSelectedFrame();
743 + } else if (cmd.equals("Save")) {
744 + FileWindow w = (FileWindow)getSelectedFrame();
747 } else if (cmd.equals("More Windows...")) {
748 MoreWindows dlg = new MoreWindows(this, fileWindows,
750 @@ -3509,6 +3689,60 @@
754 + JInternalFrame getFrameForUrl( URL url )
756 + JInternalFrame[] frames = desk.getAllFrames();
757 + for (int i = 0; i < frames.length; i++) {
758 + FileWindow w = (FileWindow)frames[i];
759 + if ( url.toString().equals( w.getUrl() ) ) {
765 + public void highlighLineInSelectedWindow(URL url, int lineNum ){
766 + //FileWindow w = (FileWindow)getFrameForUrl( url );
767 + FileWindow w = (FileWindow)getSelectedFrame();
770 + if ( lineNum > -1 )
771 + swingInvoke(new SetFilePosition(this, w, lineNum ) );
774 + public Object runSelectedWindow( URL scriptUrl ) throws Exception
776 + Object result = null;
777 + FileWindow w = (FileWindow)getSelectedFrame();
778 + //FileWindow w = (FileWindow)getFrameForUrl( scriptUrl );
782 + Scriptable scope = w.db.getScope();
785 + MessageDialogWrapper.showMessageDialog(w.db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE);
790 + String url = w.getUrl();
791 + Thread executorThread = null;
794 + LoadFile executor = new LoadFile(w.db,scope, url, new StringReader(w.textArea.getText()), true );
796 + result = executor.result;
797 + if ( executor.exception != null )
799 + throw executor.exception;
811 @@ -3604,6 +3838,69 @@
812 return console.getErr();
815 + public void openFile(URL scriptUrl, Scriptable scope, Runnable closeCallback ) {
816 + if (scope == null) {
817 + MessageDialogWrapper.showMessageDialog(this,
818 + "Can't compile scripts: no scope available",
819 + "Open", JOptionPane.ERROR_MESSAGE);
821 + if (scriptUrl != null) {
824 + InputStreamReader reader = new InputStreamReader(scriptUrl.openStream());
825 + String fileName = null;
826 + if ( scriptUrl.getProtocol().startsWith("vnd.sun.star.") )
828 + fileName = scriptUrl.toString();
832 + fileName = scriptUrl.getPath();
834 + officeScripts.addScript( fileName, scriptUrl, scope, closeCallback );
835 + //new Thread(new OpenFile(this, scope, fileName, reader )).start();
836 + swingInvoke( new OpenFile(this, fileName, reader ));
838 + catch ( IOException e )
840 + MessageDialogWrapper.showMessageDialog(this,
841 + "Can't open stream for script: " + e.toString(),
842 + "Open", JOptionPane.ERROR_MESSAGE);
846 + split1.setDividerLocation(1.0);
849 + public void openFile(String fileName) {
850 + Scriptable scope = getScope();
851 + if (scope == null) {
852 + MessageDialogWrapper.showMessageDialog(this,
853 + "Can't compile scripts: no scope available",
854 + "Open", JOptionPane.ERROR_MESSAGE);
856 + if (fileName != null) {
857 + new Thread(new OpenFile(this, fileName)).start();
860 + split1.setDividerLocation(1.0);
863 + public void openStream(InputStream in) {
864 + Scriptable scope = getScope();
865 + if (scope == null) {
866 + MessageDialogWrapper.showMessageDialog(this,
867 + "Can't compile scripts: no scope available",
868 + "Open", JOptionPane.ERROR_MESSAGE);
871 + new Thread(new OpenFile(this, null, new InputStreamReader(in))).start();
874 + split1.setDividerLocation(1.0);
875 + menubar.setSaveEnabled(false);
878 public static void main(String[] args) {
880 mainThread = Thread.currentThread();
881 @@ -3635,5 +3932,162 @@
885 + // patched Office specific interface
887 + OfficeScriptInfo officeScripts = new OfficeScriptInfo();
889 + void removeScript( String url )
891 + // Remove the FileWindow from list of open sources
892 + fileWindows.remove( url );
894 + // Remove sourceInfo from sourceNames, ensures that
895 + // breakpoints etc are deleted
896 + synchronized (sourceNames) {
897 + sourceNames.remove( url );
899 + // Removes scriptItems for the script, ensures that a new open ( from openFile )
900 + // will succeed, openFile should open file but fails due to fact that
901 + synchronized ( scriptItems )
903 + Iterator iter = scriptItems.entrySet().iterator();
904 + while ( iter.hasNext() )
906 + Map.Entry me = ( Map.Entry )iter.next();
907 + ScriptItem item = (ScriptItem)me.getValue();
908 + SourceInfo si = item.getSourceInfo();
909 + if ( si.getUrl().equals( url ) )
912 + scriptItems.remove( me.getKey() );
917 + officeScripts.deleteScript( url );
921 + ScriptItem getScriptItem(DebuggableScript fnOrScript) {
922 + ScriptItem item = (ScriptItem)scriptItems.get(fnOrScript);
923 + if (item == null) {
924 + String url = getNormilizedUrl(fnOrScript);
925 + SourceInfo si = (SourceInfo)sourceNames.get(url);
927 + if (!fnOrScript.isGeneratedScript()) {
928 + // Not eval or Function, try to load it from URL
929 + String source = null;
931 + InputStream is = openSource(url);
932 + try { source = readSource(is); }
933 + finally { is.close(); }
934 + } catch (IOException ex) {
936 + ("Failed to load source from "+url+": "+ ex);
938 + if (source != null) {
939 + si = registerSource(url, source);
944 + item = registerScript(si, fnOrScript);
951 + public void showScriptWindow(URL url ){
952 + String key = url.getPath();
953 + if ( url.getProtocol().startsWith("vnd.sun.star") )
955 + key = url.toString();
957 + FileWindow w = (FileWindow)getFileWindow( key );
961 + desk.getDesktopManager().deiconifyFrame(w);
962 + desk.getDesktopManager().activateFrame(w);
968 + public void highlighLineInScriptWindow(URL url, int lineNum ){
969 + String key = url.getPath();
970 + if ( url.getProtocol().startsWith("vnd.sun.star") )
972 + key = url.getPath();
974 + FileWindow w = (FileWindow)getFileWindow( key );
977 + if ( lineNum > -1 )
978 + swingInvoke(new SetFilePosition(this, w, lineNum ) );
981 + public Object runScriptWindow( URL scriptUrl ) throws Exception
983 + String key = scriptUrl.getPath();
984 + if ( scriptUrl.getProtocol().startsWith("vnd.sun.star") )
986 + key = scriptUrl.toString();
988 + FileWindow w = (FileWindow)getFileWindow( key );
989 + Object result = null;
993 + //Scriptable scope = w.db.getScope();
994 + Scriptable scope = w.db.officeScripts.getScriptScope( key );
997 + MessageDialogWrapper.showMessageDialog(w.db, "Can't load scripts: no scope available", "Run", JOptionPane.ERROR_MESSAGE);
1002 + String url = w.getUrl();
1003 + Thread executorThread = null;
1006 + LoadFile executor = new LoadFile(w.db,scope, url, new StringReader(w.textArea.getText()), true );
1008 + result = executor.result;
1009 + if ( executor.exception != null )
1011 + throw executor.exception;
1020 + public boolean isModified( URL url )
1022 + String key = url.getPath();
1023 + if ( url.getProtocol().startsWith("vnd.sun.star") )
1025 + key = url.toString();
1027 + FileWindow w = (FileWindow)getFileWindow( key );
1028 + return w.isModified();
1031 + public String getText( URL url )
1033 + String key = url.toString();
1034 + if ( url.getProtocol().startsWith("vnd.sun.star") )
1036 + key = url.toString();
1038 + FileWindow w = (FileWindow)getFileWindow( key );
1039 + return w.getText();
1044 --- misc/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/OfficeScriptInfo.java Fri Mar 28 17:25:34 2008
1045 +++ misc/build/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/debugger/OfficeScriptInfo.java Fri Mar 28 17:24:59 2008
1048 +/*************************************************************************
1050 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1052 + * Copyright 2000, 2010 Oracle and/or its affiliates.
1054 + * OpenOffice.org - a multi-platform office productivity suite
1056 + * This file is part of OpenOffice.org.
1058 + * OpenOffice.org is free software: you can redistribute it and/or modify
1059 + * it under the terms of the GNU Lesser General Public License version 3
1060 + * only, as published by the Free Software Foundation.
1062 + * OpenOffice.org is distributed in the hope that it will be useful,
1063 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1064 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1065 + * GNU Lesser General Public License version 3 for more details
1066 + * (a copy is included in the LICENSE file that accompanied this code).
1068 + * You should have received a copy of the GNU Lesser General Public License
1069 + * version 3 along with OpenOffice.org. If not, see
1070 + * <http://www.openoffice.org/license.html>
1071 + * for a copy of the LGPLv3 License.
1073 + ************************************************************************/
1076 +package org.mozilla.javascript.tools.debugger;
1077 +import java.net.URL;
1078 +import java.util.Hashtable;
1079 +import org.mozilla.javascript.Scriptable;
1081 +public class OfficeScriptInfo
1083 + private Hashtable loadedSFScripts = new Hashtable();
1085 + public void addScript( URL url, Scriptable scope, Runnable closeCallback )
1087 + addScript( url.toString(), url, scope, closeCallback );
1090 + public void addScript( String key, URL url, Scriptable scope, Runnable closeCallback )
1092 + SFScriptInfo si = (SFScriptInfo)loadedSFScripts.get( key );
1095 + si = new SFScriptInfo();
1098 + si.closeCallback = closeCallback;
1099 + loadedSFScripts.put( key, si );
1103 + public void deleteScript( String key )
1105 + SFScriptInfo info = (SFScriptInfo)loadedSFScripts.remove( key );
1106 + if ( info != null )
1108 + if ( info.closeCallback != null )
1110 + System.out.println("** In removeSFScriptInfo have callback for " + key );
1111 + info.closeCallback.run(); // really need to do this in seperate thread????
1116 + public Scriptable getScriptScope( String key )
1118 + Scriptable result = null;
1119 + SFScriptInfo info = (SFScriptInfo)loadedSFScripts.get( key );
1120 + if ( info != null )
1122 + result = info.scope;
1127 + public URL getScriptUrl( String key )
1129 + URL result = null;
1130 + SFScriptInfo info = (SFScriptInfo)loadedSFScripts.get( key );
1131 + if ( info != null )
1133 + result = info.url;
1137 + public boolean hasScript( String key )
1139 + boolean result = true;
1140 + SFScriptInfo info = (SFScriptInfo)loadedSFScripts.get( key );
1141 + if ( info == null )
1148 + public void setScriptRunning( String key, boolean running )
1150 + SFScriptInfo info = (SFScriptInfo)loadedSFScripts.get( key );
1151 + if ( info != null )
1153 + info.isExecuting = running;
1157 + public boolean isScriptRunning( String key )
1159 + boolean result = false;
1160 + SFScriptInfo info = (SFScriptInfo)loadedSFScripts.get( key );
1161 + if ( info != null )
1163 + result = info.isExecuting;
1170 + class SFScriptInfo
1173 + boolean isExecuting;
1175 + Runnable closeCallback;
1178 --- misc/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/shell/JavaPolicySecurity.java Thu Mar 25 21:54:34 2004
1179 +++ misc/build/rhino1_5R5/toolsrc/org/mozilla/javascript/tools/shell/JavaPolicySecurity.java Fri Mar 28 17:24:23 2008
1181 package org.mozilla.javascript.tools.shell;
1183 import java.security.*;
1184 +import java.security.cert.Certificate;
1185 import java.net.MalformedURLException;
1186 import java.net.URL;
1187 import java.util.Hashtable;
1190 public JavaPolicySecurity() {
1191 // To trigger error on jdk-1.1 with lazy load
1192 - new CodeSource(null, null);
1193 + new CodeSource(null, (Certificate [])null);
1196 protected void callProcessFileSecure(final Context cx,
1200 private ProtectionDomain getUrlDomain(URL url) {
1201 - CodeSource cs = new CodeSource(url, null);
1202 + CodeSource cs = new CodeSource(url, (Certificate [])null);
1203 PermissionCollection pc = Policy.getPolicy().getPermissions(cs);
1204 return new ProtectionDomain(cs, pc);