author | timkelly |
Wed, 15 Sep 2010 09:33:14 -0500 | |
changeset 2008 | 549473f3167e |
parent 2007 | 283cfb261d8f |
child 2012 | df3206234d8e |
permissions | -rw-r--r-- |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
1 |
/* |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
8 |
* |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
11 |
* |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
13 |
* |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
14 |
* Description: |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
15 |
* |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
16 |
*/ |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
17 |
package com.nokia.carbide.cpp.internal.sdk.ui; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
18 |
|
1434 | 19 |
import java.io.File; |
20 |
import java.util.List; |
|
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
21 |
|
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
22 |
import org.eclipse.core.resources.ResourcesPlugin; |
1434 | 23 |
import org.eclipse.core.runtime.IProgressMonitor; |
24 |
import org.eclipse.core.runtime.IStatus; |
|
25 |
import org.eclipse.core.runtime.Status; |
|
2001
75d787292eea
Updated the dynamic p2 installer to improve progress reporting and check for cancel during install.
stechong
parents:
1994
diff
changeset
|
26 |
import org.eclipse.core.runtime.SubMonitor; |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
27 |
import org.eclipse.core.runtime.jobs.Job; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
28 |
import org.eclipse.swt.widgets.Shell; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
29 |
import org.eclipse.ui.IWorkbench; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
30 |
import org.eclipse.ui.IWorkbenchWindow; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
31 |
|
1994
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
32 |
import com.nokia.carbide.cpp.internal.api.sdk.ISBSv2BuildInfo; |
1434 | 33 |
import com.nokia.carbide.cpp.sdk.core.ISymbianBuilderID; |
34 |
import com.nokia.carbide.cpp.sdk.core.ISymbianSDK; |
|
35 |
import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin; |
|
36 |
import com.nokia.carbide.cpp.sdk.ui.SDKUIPlugin; |
|
1994
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
37 |
import com.nokia.carbide.internal.discovery.ui.p2.DynamicP2Installer; |
1434 | 38 |
import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils; |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
39 |
|
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
40 |
public class NewPluginChecker { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
41 |
|
883 | 42 |
private static final String SDK_FEATURE_SUBDIR = "epoc32/kit"; //$NON-NLS-1$ |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
43 |
|
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
44 |
public static void checkForNewlyInstalledPlugins(final IWorkbench workbench){ |
643 | 45 |
|
46 |
if (WorkbenchUtils.isJUnitRunning()){ |
|
47 |
return; |
|
48 |
} |
|
49 |
||
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
50 |
final List<ISymbianSDK> sdkList = SDKCorePlugin.getSDKManager().getSDKList(); |
2007
283cfb261d8f
don't run new plugin checker if there are no SDKs
timkelly
parents:
2001
diff
changeset
|
51 |
if (sdkList.size() == 0){ |
283cfb261d8f
don't run new plugin checker if there are no SDKs
timkelly
parents:
2001
diff
changeset
|
52 |
return; |
283cfb261d8f
don't run new plugin checker if there are no SDKs
timkelly
parents:
2001
diff
changeset
|
53 |
} |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
54 |
Job job = new Job("Checking installed SDKs for plugins") { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
55 |
@Override |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
56 |
protected IStatus run(IProgressMonitor monitor) { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
57 |
boolean installed = false; |
231
4885a40e8b9b
fix bug 9032. Only scan SDKs for plugins once for an IDE configuration lifetime.
timkelly
parents:
0
diff
changeset
|
58 |
boolean oneSDKWasScanned = false; |
2001
75d787292eea
Updated the dynamic p2 installer to improve progress reporting and check for cancel during install.
stechong
parents:
1994
diff
changeset
|
59 |
SubMonitor subMonitor = SubMonitor.convert(monitor, 100); |
75d787292eea
Updated the dynamic p2 installer to improve progress reporting and check for cancel during install.
stechong
parents:
1994
diff
changeset
|
60 |
int worked = 100 / sdkList.size(); |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
61 |
for (ISymbianSDK sdk : sdkList) { |
2008 | 62 |
if (!sdk.isEnabled()){ |
63 |
continue; // Don't bother scanning SDKs that are not enabled |
|
64 |
} |
|
1994
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
65 |
ISBSv2BuildInfo sbsv2BuildInfo = (ISBSv2BuildInfo)sdk.getBuildInfo(ISymbianBuilderID.SBSV2_BUILDER); |
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
66 |
if (sbsv2BuildInfo != null) { |
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
67 |
if (sbsv2BuildInfo.isPreviouslyScanned() == false) { |
1434 | 68 |
oneSDKWasScanned = true; |
69 |
// XML was parsed, now try to run the feature installer |
|
1994
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
70 |
sbsv2BuildInfo.setPreviouslyScanned(true); |
1434 | 71 |
File featureDir = new File(sdk.getEPOCROOT() + SDK_FEATURE_SUBDIR); |
72 |
try { |
|
2001
75d787292eea
Updated the dynamic p2 installer to improve progress reporting and check for cancel during install.
stechong
parents:
1994
diff
changeset
|
73 |
IStatus status = DynamicP2Installer.install(featureDir, subMonitor); |
1994
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
74 |
if (status.isOK()) { |
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
75 |
// TODO advise user?? |
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
76 |
installed = true; |
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
77 |
} |
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
78 |
else if (status.getSeverity() == IStatus.CANCEL) { |
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
79 |
// TODO was installed |
1434 | 80 |
installed = true; |
81 |
} |
|
82 |
} catch (Exception e) { |
|
83 |
// Boog 8383: We should fail silently, since this will not break anything and may SDKs will not have any documentation |
|
84 |
// Otherwise, these errors will be logged every time this check is done (workspace is opened) |
|
85 |
// Originally, this was used to install MBS build support, but now is only used for SDK documentation |
|
86 |
// ResourcesPlugin.getPlugin().getLog().log(new Status(IStatus.ERROR, SDKCorePlugin.PLUGIN_ID, IStatus.ERROR, "Unable to install plug-ins dynamically.", e)); |
|
2001
75d787292eea
Updated the dynamic p2 installer to improve progress reporting and check for cancel during install.
stechong
parents:
1994
diff
changeset
|
87 |
} finally { |
75d787292eea
Updated the dynamic p2 installer to improve progress reporting and check for cancel during install.
stechong
parents:
1994
diff
changeset
|
88 |
subMonitor.worked(worked); |
231
4885a40e8b9b
fix bug 9032. Only scan SDKs for plugins once for an IDE configuration lifetime.
timkelly
parents:
0
diff
changeset
|
89 |
} |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
90 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
91 |
} |
231
4885a40e8b9b
fix bug 9032. Only scan SDKs for plugins once for an IDE configuration lifetime.
timkelly
parents:
0
diff
changeset
|
92 |
} |
4885a40e8b9b
fix bug 9032. Only scan SDKs for plugins once for an IDE configuration lifetime.
timkelly
parents:
0
diff
changeset
|
93 |
|
4885a40e8b9b
fix bug 9032. Only scan SDKs for plugins once for an IDE configuration lifetime.
timkelly
parents:
0
diff
changeset
|
94 |
if (oneSDKWasScanned) { |
4885a40e8b9b
fix bug 9032. Only scan SDKs for plugins once for an IDE configuration lifetime.
timkelly
parents:
0
diff
changeset
|
95 |
SDKCorePlugin.getSDKManager().updateCarbideSDKCache(); |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
96 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
97 |
if (installed) { |
231
4885a40e8b9b
fix bug 9032. Only scan SDKs for plugins once for an IDE configuration lifetime.
timkelly
parents:
0
diff
changeset
|
98 |
// plugins from some SDK were installed |
1994
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
99 |
//doEclipseRestartDialog(workbench); |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
100 |
} |
231
4885a40e8b9b
fix bug 9032. Only scan SDKs for plugins once for an IDE configuration lifetime.
timkelly
parents:
0
diff
changeset
|
101 |
|
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
102 |
return Status.OK_STATUS; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
103 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
104 |
}; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
105 |
job.schedule(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
106 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
107 |
|
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
108 |
public static void doEclipseRestartDialog(final IWorkbench workbench) { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
109 |
if (WorkbenchUtils.isJUnitRunning()){ |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
110 |
// Don't show the restart dialog if JUnit is running |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
111 |
return; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
112 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
113 |
workbench.getDisplay().asyncExec(new Runnable() { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
114 |
public void run() { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
115 |
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
116 |
if (window != null) { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
117 |
Shell shell = window.getShell(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
118 |
// Possible Enhancement: Set the SDKs that have new features so they can be displayed to the user |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
119 |
RestartIDEDialog.show(shell, |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
120 |
Messages.getString("NewPluginChecker.New_Plugins_Installed") + //$NON-NLS-1$ |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
121 |
Messages.getString("NewPluginChecker.Restart_Msg")); //$NON-NLS-1$ |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
122 |
} else { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
123 |
ResourcesPlugin.getPlugin().getLog().log(new Status(IStatus.WARNING, SDKUIPlugin.PLUGIN_ID, IStatus.WARNING, Messages.getString("NewPluginChecker.Restart_Error"), null)); //$NON-NLS-1$ |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
124 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
125 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
126 |
}); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
127 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
128 |
} |