author | Eugene Ostroukhov <eugeneo@symbian.org> |
Wed, 14 Apr 2010 11:17:26 -0700 | |
changeset 304 | d92630dec325 |
parent 272 | c91ee4e0a0ad |
child 397 | e5346aff014d |
permissions | -rw-r--r-- |
2 | 1 |
/******************************************************************************* |
2 |
* Copyright (c) 2009 Symbian Foundation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Symbian Foundation - initial contribution. |
|
11 |
* Contributors: |
|
12 |
* Description: |
|
13 |
* Overview: |
|
14 |
* Details: |
|
15 |
* Platforms/Drives/Compatibility: |
|
16 |
* Assumptions/Requirement/Pre-requisites: |
|
17 |
* Failures and causes: |
|
18 |
*******************************************************************************/ |
|
19 |
package org.symbian.tools.wrttools.debug.internal.launch; |
|
20 |
||
21 |
import java.net.URI; |
|
22 |
import java.text.MessageFormat; |
|
23 |
||
24 |
import org.eclipse.core.resources.IProject; |
|
25 |
import org.eclipse.core.runtime.CoreException; |
|
26 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
27 |
import org.eclipse.debug.core.DebugPlugin; |
|
28 |
import org.eclipse.debug.core.ILaunch; |
|
29 |
import org.eclipse.debug.core.ILaunchConfiguration; |
|
30 |
import org.eclipse.debug.core.ILaunchManager; |
|
31 |
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; |
|
268
ef733cd772bb
Bug 2213 - User is not prompted to save when debug session is started
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
185
diff
changeset
|
32 |
import org.eclipse.ui.IWorkbench; |
ef733cd772bb
Bug 2213 - User is not prompted to save when debug session is started
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
185
diff
changeset
|
33 |
import org.eclipse.ui.IWorkbenchWindow; |
ef733cd772bb
Bug 2213 - User is not prompted to save when debug session is started
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
185
diff
changeset
|
34 |
import org.eclipse.ui.PlatformUI; |
2 | 35 |
import org.symbian.tools.wrttools.debug.internal.Activator; |
41
fc4a1d68260a
Preview is now feeded from the embedded HTML server
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
39
diff
changeset
|
36 |
import org.symbian.tools.wrttools.previewer.PreviewerPlugin; |
2 | 37 |
|
185
30ef4c917204
Fixed Bug 1955 - WRT Debugger "Waiting for Debugger Connection" takes an exceptionally long time
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
178
diff
changeset
|
38 |
public class WidgetLaunchDelegate implements ILaunchConfigurationDelegate { |
2 | 39 |
public static final String ID = "org.symbian.tools.wrttools.debug.widget"; |
185
30ef4c917204
Fixed Bug 1955 - WRT Debugger "Waiting for Debugger Connection" takes an exceptionally long time
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
178
diff
changeset
|
40 |
|
30ef4c917204
Fixed Bug 1955 - WRT Debugger "Waiting for Debugger Connection" takes an exceptionally long time
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
178
diff
changeset
|
41 |
public void launch(ILaunchConfiguration configuration, String mode, final ILaunch launch, IProgressMonitor monitor) |
2 | 42 |
throws CoreException { |
43 |
monitor.beginTask("Preparing WRT Debugger", IProgressMonitor.UNKNOWN); |
|
44 |
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); |
|
268
ef733cd772bb
Bug 2213 - User is not prompted to save when debug session is started
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
185
diff
changeset
|
45 |
final IWorkbench workbench = PlatformUI.getWorkbench(); |
ef733cd772bb
Bug 2213 - User is not prompted to save when debug session is started
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
185
diff
changeset
|
46 |
final IWorkbenchWindow window = workbench.getWorkbenchWindows()[0]; |
ef733cd772bb
Bug 2213 - User is not prompted to save when debug session is started
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
185
diff
changeset
|
47 |
final boolean[] retvalue = new boolean[1]; |
ef733cd772bb
Bug 2213 - User is not prompted to save when debug session is started
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
185
diff
changeset
|
48 |
window.getShell().getDisplay().syncExec(new Runnable() { |
ef733cd772bb
Bug 2213 - User is not prompted to save when debug session is started
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
185
diff
changeset
|
49 |
public void run() { |
ef733cd772bb
Bug 2213 - User is not prompted to save when debug session is started
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
185
diff
changeset
|
50 |
retvalue[0] = workbench.saveAllEditors(true); |
ef733cd772bb
Bug 2213 - User is not prompted to save when debug session is started
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
185
diff
changeset
|
51 |
} |
ef733cd772bb
Bug 2213 - User is not prompted to save when debug session is started
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
185
diff
changeset
|
52 |
}); |
ef733cd772bb
Bug 2213 - User is not prompted to save when debug session is started
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
185
diff
changeset
|
53 |
if (!retvalue[0]) { |
ef733cd772bb
Bug 2213 - User is not prompted to save when debug session is started
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
185
diff
changeset
|
54 |
launchManager.removeLaunch(launch); |
ef733cd772bb
Bug 2213 - User is not prompted to save when debug session is started
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
185
diff
changeset
|
55 |
return; |
ef733cd772bb
Bug 2213 - User is not prompted to save when debug session is started
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
185
diff
changeset
|
56 |
} |
2 | 57 |
boolean debug = mode.equals(ILaunchManager.DEBUG_MODE); |
185
30ef4c917204
Fixed Bug 1955 - WRT Debugger "Waiting for Debugger Connection" takes an exceptionally long time
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
178
diff
changeset
|
58 |
try { |
30ef4c917204
Fixed Bug 1955 - WRT Debugger "Waiting for Debugger Connection" takes an exceptionally long time
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
178
diff
changeset
|
59 |
// 1. Load all parameters |
272
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
268
diff
changeset
|
60 |
IProject project = DebugUtil.getProject(configuration); |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
268
diff
changeset
|
61 |
if (DebugUtil.isProjectDebugged(project, launchManager, launch)) { |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
268
diff
changeset
|
62 |
throw DebugUtil.createCoreException(MessageFormat.format("Project {0} is already running.", project.getName()), |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
268
diff
changeset
|
63 |
null); |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
268
diff
changeset
|
64 |
} |
2 | 65 |
|
185
30ef4c917204
Fixed Bug 1955 - WRT Debugger "Waiting for Debugger Connection" takes an exceptionally long time
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
178
diff
changeset
|
66 |
int port = PortPolicy.getPortNumber(); |
30ef4c917204
Fixed Bug 1955 - WRT Debugger "Waiting for Debugger Connection" takes an exceptionally long time
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
178
diff
changeset
|
67 |
final URI uri = prepareDebugger(project, debug, launch, port); |
30ef4c917204
Fixed Bug 1955 - WRT Debugger "Waiting for Debugger Connection" takes an exceptionally long time
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
178
diff
changeset
|
68 |
|
30ef4c917204
Fixed Bug 1955 - WRT Debugger "Waiting for Debugger Connection" takes an exceptionally long time
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
178
diff
changeset
|
69 |
Activator.getDefault().getChromeInstancesManager().startChrome(launch, port, uri.toASCIIString()); |
30ef4c917204
Fixed Bug 1955 - WRT Debugger "Waiting for Debugger Connection" takes an exceptionally long time
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
178
diff
changeset
|
70 |
} catch (CoreException e) { |
30ef4c917204
Fixed Bug 1955 - WRT Debugger "Waiting for Debugger Connection" takes an exceptionally long time
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
178
diff
changeset
|
71 |
launchManager.removeLaunch(launch); |
30ef4c917204
Fixed Bug 1955 - WRT Debugger "Waiting for Debugger Connection" takes an exceptionally long time
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
178
diff
changeset
|
72 |
throw e; |
2 | 73 |
} |
74 |
if (!debug) { |
|
75 |
launchManager.removeLaunch(launch); |
|
76 |
} |
|
77 |
monitor.done(); |
|
78 |
} |
|
79 |
||
272
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
268
diff
changeset
|
80 |
private URI prepareDebugger(IProject project, boolean debug, final ILaunch launch, final int port) { |
304
d92630dec325
Refactoring server-side preview code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
272
diff
changeset
|
81 |
DebugConnectionJob job = null; |
2 | 82 |
if (debug) { |
304
d92630dec325
Refactoring server-side preview code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
272
diff
changeset
|
83 |
job = new DebugConnectionJob(project, port, launch); |
2 | 84 |
} |
304
d92630dec325
Refactoring server-side preview code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
272
diff
changeset
|
85 |
return PreviewerPlugin.getDefault().getHttpPreviewer().previewProject(project, job); |
2 | 86 |
} |
87 |
} |