author | Eugene Ostroukhov <eugeneo@symbian.org> |
Tue, 16 Mar 2010 17:22:32 -0700 | |
changeset 272 | c91ee4e0a0ad |
child 275 | 12c2ea2194c7 |
permissions | -rw-r--r-- |
272
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1 |
/** |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
2 |
* Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies). |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
3 |
* All rights reserved. |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
8 |
* |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
10 |
* Symbian Foundation - initial contribution. |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
11 |
* Contributors: |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
12 |
* Description: |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
13 |
* Overview: |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
14 |
* Details: |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
15 |
* Platforms/Drives/Compatibility: |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
16 |
* Assumptions/Requirement/Pre-requisites: |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
17 |
* Failures and causes: |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
18 |
*/ |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
19 |
package org.symbian.tools.wrttools.debug.internal.launch; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
20 |
|
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
21 |
import java.util.Collection; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
22 |
import java.util.HashSet; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
23 |
|
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
24 |
import org.eclipse.core.resources.IProject; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
25 |
import org.eclipse.core.resources.IResource; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
26 |
import org.eclipse.core.resources.IResourceChangeEvent; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
27 |
import org.eclipse.core.resources.IResourceChangeListener; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
28 |
import org.eclipse.core.resources.IResourceDelta; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
29 |
import org.eclipse.core.resources.IResourceDeltaVisitor; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
30 |
import org.eclipse.core.resources.ResourcesPlugin; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
31 |
import org.eclipse.core.runtime.CoreException; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
32 |
import org.eclipse.debug.core.DebugPlugin; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
33 |
import org.eclipse.debug.core.ILaunchManager; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
34 |
import org.eclipse.jface.dialogs.MessageDialogWithToggle; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
35 |
import org.eclipse.swt.widgets.Display; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
36 |
import org.eclipse.ui.PlatformUI; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
37 |
import org.symbian.tools.wrttools.debug.internal.Activator; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
38 |
import org.symbian.tools.wrttools.debug.internal.IConstants; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
39 |
|
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
40 |
public class ResourcesChangeListener implements IResourceChangeListener { |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
41 |
public class ProjectListGatherer implements IResourceDeltaVisitor { |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
42 |
public final Collection<IProject> projects = new HashSet<IProject>(); |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
43 |
private final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
44 |
|
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
45 |
public boolean visit(IResourceDelta delta) throws CoreException { |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
46 |
if (delta.getResource().getType() == IResource.PROJECT) { |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
47 |
IProject project = delta.getResource().getProject(); |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
48 |
if (DebugUtil.isProjectDebugged(project, launchManager, null)) { |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
49 |
projects.add(project); |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
50 |
} |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
51 |
return false; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
52 |
} |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
53 |
return true; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
54 |
} |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
55 |
|
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
56 |
} |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
57 |
|
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
58 |
public void resourceChanged(IResourceChangeEvent event) { |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
59 |
if (event.getDelta() != null |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
60 |
&& !MessageDialogWithToggle.ALWAYS.equals(Activator.getDefault().getPreferenceStore().getString( |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
61 |
IConstants.PREF_SHOW_RESOURCE_CHANGE_ERROR))) { |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
62 |
ProjectListGatherer gatherer = new ProjectListGatherer(); |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
63 |
try { |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
64 |
event.getDelta().accept(gatherer); |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
65 |
} catch (CoreException e) { |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
66 |
Activator.log(e); |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
67 |
} |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
68 |
int size = gatherer.projects.size(); |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
69 |
if (size > 0) { |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
70 |
Display.getDefault().asyncExec(new Runnable() { |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
71 |
public void run() { |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
72 |
String message = "Debug browser is not updated when the files are updated. You may notice discrepancies between your workspace contents and debug session. You should either refresh the browser or restart debugging session to see the latest changes made to the workspace."; |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
73 |
MessageDialogWithToggle.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow() |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
74 |
.getShell(), "WebRuntime Debugger", message, |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
75 |
"Do not show this warning on code changes", false, Activator.getDefault() |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
76 |
.getPreferenceStore(), IConstants.PREF_SHOW_RESOURCE_CHANGE_ERROR); |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
77 |
ResourcesPlugin.getWorkspace().removeResourceChangeListener(ResourcesChangeListener.this); |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
78 |
} |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
79 |
}); |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
80 |
} |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
81 |
} |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
82 |
} |
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
83 |
|
c91ee4e0a0ad
Bug 2214 - Debugger is not updated when JS file is edited.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
84 |
} |