- Provide runtime show & hide of Alfresco Javascript Debugger

- Simplify Web Script home page

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5962 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2007-06-14 17:21:29 +00:00
parent 7d160bc4d9
commit ea815d8e9f

View File

@@ -24,6 +24,8 @@
*/ */
package org.alfresco.repo.jscript; package org.alfresco.repo.jscript;
import javax.swing.WindowConstants;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@@ -49,6 +51,13 @@ public class AlfrescoRhinoScriptDebugger extends Dim
// Logger // Logger
private static final Log logger = LogFactory.getLog(AlfrescoRhinoScriptDebugger.class); private static final Log logger = LogFactory.getLog(AlfrescoRhinoScriptDebugger.class);
private boolean active = false;
private boolean visible = false;
private ContextFactory factory = null;
private Global global = null;
private AlfrescoRhinoScriptDebugger dim = null;
private SwingGui gui = null;
/** /**
* Start the Debugger * Start the Debugger
@@ -57,25 +66,80 @@ public class AlfrescoRhinoScriptDebugger extends Dim
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
ContextFactory factory = ContextFactory.getGlobal(); activate();
Global global = new Global(); show();
global.init(factory); }
}
/**
* Activate the Debugger
*/
public synchronized void activate()
{
factory = ContextFactory.getGlobal();
global = new Global();
global.init(factory);
dim = new AlfrescoRhinoScriptDebugger();
dim.setScopeProvider(IProxy.newScopeProvider((Scriptable)global));
gui = new SwingGui(dim, "Alfresco JavaScript Debugger");
gui.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
active = true;
}
/**
* Show the debugger
*/
public synchronized void show()
{
if (!isActive())
{
activate();
}
AlfrescoRhinoScriptDebugger dim = new AlfrescoRhinoScriptDebugger();
dim.setBreakOnExceptions(true); dim.setBreakOnExceptions(true);
dim.setBreakOnEnter(true); dim.setBreakOnEnter(true);
dim.setBreakOnReturn(true); dim.setBreakOnReturn(true);
dim.attachTo(factory); dim.attachTo(factory);
dim.setScopeProvider(IProxy.newScopeProvider((Scriptable)global));
SwingGui gui = new SwingGui(dim, "Alfresco JavaScript Debugger");
gui.pack(); gui.pack();
gui.setSize(600, 460); gui.setSize(600, 460);
gui.setVisible(true); gui.setVisible(true);
visible = true;
}
/**
* Hide the Debugger
*/
public synchronized void hide()
{
if (isVisible())
{
dim.detach();
gui.dispose();
visible = false;
} }
} }
/**
* Is Debugger visible?
*
* @return
*/
public boolean isVisible()
{
return visible;
}
/**
* Is Debugger active?
*
* @return
*/
public boolean isActive()
{
return active;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.mozilla.javascript.tools.debugger.Dim#objectToString(java.lang.Object) * @see org.mozilla.javascript.tools.debugger.Dim#objectToString(java.lang.Object)
*/ */
@@ -117,6 +181,7 @@ public class AlfrescoRhinoScriptDebugger extends Dim
*/ */
private Scriptable scope; private Scriptable scope;
/** /**
* Creates a new IProxy. * Creates a new IProxy.
*/ */
@@ -144,7 +209,6 @@ public class AlfrescoRhinoScriptDebugger extends Dim
{ {
if (type != EXIT_ACTION) if (type != EXIT_ACTION)
Kit.codeBug(); Kit.codeBug();
System.exit(0);
} }
// ScopeProvider // ScopeProvider