# HG changeset patch # User Eugene Ostroukhov # Date 1268931101 25200 # Node ID d236e890687c2b3b55d67abe029103ab40f786c0 # Parent b1f63c2c240c142a4d72e10d4be342c572f7fd3a Bug 2123 - Enable use of Web Inspector diff -r b1f63c2c240c -r d236e890687c org.symbian.tools.wrttools.debug.core/plugin.xml --- a/org.symbian.tools.wrttools.debug.core/plugin.xml Tue Mar 16 18:01:11 2010 -0700 +++ b/org.symbian.tools.wrttools.debug.core/plugin.xml Thu Mar 18 09:51:41 2010 -0700 @@ -305,5 +305,12 @@ label="chrome debug widget"> + + + + diff -r b1f63c2c240c -r d236e890687c org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/session/TerminateSession.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/session/TerminateSession.java Thu Mar 18 09:51:41 2010 -0700 @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of the License "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Symbian Foundation - initial contribution. + * Contributors: + * Description: + * Overview: + * Details: + * Platforms/Drives/Compatibility: + * Assumptions/Requirement/Pre-requisites: + * Failures and causes: + */ +package org.symbian.tools.wrttools.debug.internal.session; + +import java.util.Map; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchManager; +import org.symbian.tools.wrttools.debug.internal.Activator; +import org.symbian.tools.wrttools.debug.internal.IConstants; +import org.symbian.tools.wrttools.debug.internal.launch.WidgetLaunchDelegate; +import org.symbian.tools.wrttools.previewer.IPreviewerCommandHandler; + +public class TerminateSession implements IPreviewerCommandHandler { + @SuppressWarnings("unchecked") + public void handle(String commandName, String projectName, Map parameters) { + ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); + for (ILaunch launch : launchManager.getLaunches()) { + try { + if (!launch.isTerminated()) { + ILaunchConfiguration lc = launch.getLaunchConfiguration(); + if (WidgetLaunchDelegate.ID.equals(lc.getType().getIdentifier()) + && projectName.equals(lc.getAttribute(IConstants.PROP_PROJECT_NAME, ""))) { + launch.terminate(); + } + } + } catch (CoreException e) { + Activator.log(e); + } + } + } + +} diff -r b1f63c2c240c -r d236e890687c org.symbian.tools.wrttools.previewer/plugin.xml --- a/org.symbian.tools.wrttools.previewer/plugin.xml Tue Mar 16 18:01:11 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/plugin.xml Thu Mar 18 09:51:41 2010 -0700 @@ -1,6 +1,7 @@ + +
+
To open Google Chrome Developer Tolls you need to: +
    +
  1. Disconnect debugger from Chrome browser.
  2. +
  3. Press Ctrl+Shift+I to open inspector.
  4. +
+
+
@@ -221,6 +229,7 @@
+
diff -r b1f63c2c240c -r d236e890687c org.symbian.tools.wrttools.previewer/schema/commands.exsd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools.previewer/schema/commands.exsd Thu Mar 18 09:51:41 2010 -0700 @@ -0,0 +1,112 @@ + + + + + + + + + This extension point allows customizing the previewer by handling special commands. To call command from previewer send AJAX GET request to following URL: +http://${host}:${port}/preview/${project}/__sym_command/${commandname}[?${params}] + +${project} and ${params} will be passed to command handler. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + One-word command name + + + + + + + Class that will handle commands + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + diff -r b1f63c2c240c -r d236e890687c org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/CommandHandlerManager.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/CommandHandlerManager.java Thu Mar 18 09:51:41 2010 -0700 @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of the License "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Symbian Foundation - initial contribution. + * Contributors: + * Description: + * Overview: + * Details: + * Platforms/Drives/Compatibility: + * Assumptions/Requirement/Pre-requisites: + * Failures and causes: + */ +package org.symbian.tools.wrttools.previewer; + +import java.text.MessageFormat; +import java.util.Map; +import java.util.TreeMap; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.InvalidRegistryObjectException; +import org.eclipse.core.runtime.Platform; + +public class CommandHandlerManager { + + private Map handlers = null; + + @SuppressWarnings("unchecked") + public void handle(String commandName, String projectName, Map parameters) { + final IPreviewerCommandHandler commandHandler = getCommandMap().get(commandName); + if (commandHandler == null) { + PreviewerPlugin.log(MessageFormat.format("Command {0} is not handled", commandName), null); + } else { + commandHandler.handle(commandName, projectName, parameters); + } + } + + private synchronized Map getCommandMap() { + if (handlers == null) { + handlers = new TreeMap(); + IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor( + PreviewerPlugin.PLUGIN_ID, "commands"); + for (IConfigurationElement element : elements) { + final String name = element.getAttribute("name"); + try { + handlers.put(name, (IPreviewerCommandHandler) element.createExecutableExtension("handler")); + } catch (InvalidRegistryObjectException e) { + PreviewerPlugin.log(MessageFormat.format("Command: {0}, handler: {1}", name, element + .getAttribute("handler")), e); + } catch (CoreException e) { + PreviewerPlugin.log(MessageFormat.format("Command: {0}, handler: {1}", name, element + .getAttribute("handler")), e); + } + } + } + return handlers; + } + +} diff -r b1f63c2c240c -r d236e890687c org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/IPreviewerCommandHandler.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/IPreviewerCommandHandler.java Thu Mar 18 09:51:41 2010 -0700 @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of the License "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Symbian Foundation - initial contribution. + * Contributors: + * Description: + * Overview: + * Details: + * Platforms/Drives/Compatibility: + * Assumptions/Requirement/Pre-requisites: + * Failures and causes: + */ +package org.symbian.tools.wrttools.previewer; + +import java.util.Map; + +public interface IPreviewerCommandHandler { + @SuppressWarnings("unchecked") + void handle(String commandName, String projectName, Map parameters); +} diff -r b1f63c2c240c -r d236e890687c org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/PreviewerPlugin.java --- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/PreviewerPlugin.java Tue Mar 16 18:01:11 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/PreviewerPlugin.java Thu Mar 18 09:51:41 2010 -0700 @@ -53,7 +53,8 @@ // The shared instance private static PreviewerPlugin plugin; - private HttpPreviewer previewer = new HttpPreviewer(); + private final CommandHandlerManager handlerManager = new CommandHandlerManager(); + private final HttpPreviewer previewer = new HttpPreviewer(); /* * (non-Javadoc) @@ -118,4 +119,7 @@ return previewer; } + public CommandHandlerManager getCommandHandlerManager() { + return handlerManager; + } } diff -r b1f63c2c240c -r d236e890687c org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WorkspaceResourcesServlet.java --- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WorkspaceResourcesServlet.java Tue Mar 16 18:01:11 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WorkspaceResourcesServlet.java Thu Mar 18 09:51:41 2010 -0700 @@ -29,6 +29,7 @@ import java.net.URLDecoder; import java.net.URLEncoder; import java.text.MessageFormat; +import java.util.Map; import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -52,6 +53,7 @@ public class WorkspaceResourcesServlet extends HttpServlet { private static final String PREVIEW_START = "/preview/wrt_preview.html"; private static final String PREVIEW_PATH = "preview"; + private static final Object COMMAND_PATH = "__sym_command"; private static final String STARTING_PAGE = "preview-frame.html"; private static final String INDEX_PAGE = "wrt_preview_main.html"; private static final long serialVersionUID = -3217197074249607950L; @@ -69,7 +71,7 @@ IPath path = new Path(req.getPathInfo()); InputStream contents = null; try { - contents = getSpecialResource(path); + contents = getSpecialResource(path, req.getParameterMap()); if (contents == null) { contents = getWorkspaceResourceContents(path); } @@ -92,7 +94,8 @@ } } - private InputStream getSpecialResource(IPath path) throws IOException, + @SuppressWarnings("unchecked") + private InputStream getSpecialResource(IPath path, Map parameters) throws IOException, CoreException { IPath relativePath = path.removeFirstSegments(1); if (relativePath.segmentCount() == 1) { @@ -104,6 +107,11 @@ } } else if (PREVIEW_PATH.equals(relativePath.segment(0))) { return getPluginResourceStream(relativePath.makeAbsolute()); + } else if (COMMAND_PATH.equals(relativePath.segment(0))) { + if (path.segmentCount() == 3) { + PreviewerPlugin.getDefault().getCommandHandlerManager().handle(path.segment(2), path.segment(0), + parameters); + } } return null; } diff -r b1f63c2c240c -r d236e890687c org.symbian.tools.wrttools/plugin.xml --- a/org.symbian.tools.wrttools/plugin.xml Tue Mar 16 18:01:11 2010 -0700 +++ b/org.symbian.tools.wrttools/plugin.xml Thu Mar 18 09:51:41 2010 -0700 @@ -1,6 +1,7 @@ + @@ -127,7 +128,6 @@ -