author | stechong |
Thu, 16 Sep 2010 16:09:17 -0500 | |
changeset 2034 | 8ca82bbe1973 |
parent 2012 | df3206234d8e |
child 2045 | 00e887c4a2c8 |
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; |
2034
8ca82bbe1973
Refactored status notification from DynamicP2Installer.java to NewPluginChecker.java.
stechong
parents:
2012
diff
changeset
|
38 |
import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator; |
1434 | 39 |
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
|
40 |
|
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
41 |
public class NewPluginChecker { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
42 |
|
883 | 43 |
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
|
44 |
|
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
45 |
public static void checkForNewlyInstalledPlugins(final IWorkbench workbench){ |
643 | 46 |
|
47 |
if (WorkbenchUtils.isJUnitRunning()){ |
|
48 |
return; |
|
49 |
} |
|
50 |
||
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
51 |
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
|
52 |
if (sdkList.size() == 0){ |
283cfb261d8f
don't run new plugin checker if there are no SDKs
timkelly
parents:
2001
diff
changeset
|
53 |
return; |
283cfb261d8f
don't run new plugin checker if there are no SDKs
timkelly
parents:
2001
diff
changeset
|
54 |
} |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
55 |
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
|
56 |
@Override |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
57 |
protected IStatus run(IProgressMonitor monitor) { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
58 |
boolean installed = false; |
231
4885a40e8b9b
fix bug 9032. Only scan SDKs for plugins once for an IDE configuration lifetime.
timkelly
parents:
0
diff
changeset
|
59 |
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
|
60 |
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
|
61 |
int worked = 100 / sdkList.size(); |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
62 |
for (ISymbianSDK sdk : sdkList) { |
2008 | 63 |
if (!sdk.isEnabled()){ |
64 |
continue; // Don't bother scanning SDKs that are not enabled |
|
65 |
} |
|
1994
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
66 |
ISBSv2BuildInfo sbsv2BuildInfo = (ISBSv2BuildInfo)sdk.getBuildInfo(ISymbianBuilderID.SBSV2_BUILDER); |
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
67 |
if (sbsv2BuildInfo != null) { |
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
68 |
if (sbsv2BuildInfo.isPreviouslyScanned() == false) { |
1434 | 69 |
oneSDKWasScanned = true; |
70 |
// 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
|
71 |
sbsv2BuildInfo.setPreviouslyScanned(true); |
1434 | 72 |
File featureDir = new File(sdk.getEPOCROOT() + SDK_FEATURE_SUBDIR); |
73 |
try { |
|
2012
df3206234d8e
Added status notification after installing feature(s) from SDK.
stechong
parents:
2008
diff
changeset
|
74 |
IStatus status = DynamicP2Installer.install(sdk.getUniqueId(), featureDir, subMonitor); |
1994
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
75 |
if (status.isOK()) { |
2034
8ca82bbe1973
Refactored status notification from DynamicP2Installer.java to NewPluginChecker.java.
stechong
parents:
2012
diff
changeset
|
76 |
RemoteConnectionsActivator.getStatusDisplay().displayStatus( |
8ca82bbe1973
Refactored status notification from DynamicP2Installer.java to NewPluginChecker.java.
stechong
parents:
2012
diff
changeset
|
77 |
SDKUIPlugin.makeStatus(IStatus.INFO, "Installed features from\n" + sdk.getUniqueId(), null)); |
1994
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
78 |
installed = true; |
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
79 |
} |
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
80 |
else if (status.getSeverity() == IStatus.CANCEL) { |
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
81 |
// TODO was installed |
1434 | 82 |
installed = true; |
83 |
} |
|
84 |
} catch (Exception e) { |
|
85 |
// Boog 8383: We should fail silently, since this will not break anything and may SDKs will not have any documentation |
|
86 |
// Otherwise, these errors will be logged every time this check is done (workspace is opened) |
|
87 |
// Originally, this was used to install MBS build support, but now is only used for SDK documentation |
|
88 |
// 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
|
89 |
} finally { |
75d787292eea
Updated the dynamic p2 installer to improve progress reporting and check for cancel during install.
stechong
parents:
1994
diff
changeset
|
90 |
subMonitor.worked(worked); |
231
4885a40e8b9b
fix bug 9032. Only scan SDKs for plugins once for an IDE configuration lifetime.
timkelly
parents:
0
diff
changeset
|
91 |
} |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
92 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
93 |
} |
231
4885a40e8b9b
fix bug 9032. Only scan SDKs for plugins once for an IDE configuration lifetime.
timkelly
parents:
0
diff
changeset
|
94 |
} |
4885a40e8b9b
fix bug 9032. Only scan SDKs for plugins once for an IDE configuration lifetime.
timkelly
parents:
0
diff
changeset
|
95 |
|
4885a40e8b9b
fix bug 9032. Only scan SDKs for plugins once for an IDE configuration lifetime.
timkelly
parents:
0
diff
changeset
|
96 |
if (oneSDKWasScanned) { |
4885a40e8b9b
fix bug 9032. Only scan SDKs for plugins once for an IDE configuration lifetime.
timkelly
parents:
0
diff
changeset
|
97 |
SDKCorePlugin.getSDKManager().updateCarbideSDKCache(); |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
98 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
99 |
if (installed) { |
231
4885a40e8b9b
fix bug 9032. Only scan SDKs for plugins once for an IDE configuration lifetime.
timkelly
parents:
0
diff
changeset
|
100 |
// plugins from some SDK were installed |
1994
e9be28ae423a
Bug 10645 - add p2 install operation for docs plugins
dadubrow
parents:
1462
diff
changeset
|
101 |
//doEclipseRestartDialog(workbench); |
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
102 |
} |
231
4885a40e8b9b
fix bug 9032. Only scan SDKs for plugins once for an IDE configuration lifetime.
timkelly
parents:
0
diff
changeset
|
103 |
|
0
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
104 |
return Status.OK_STATUS; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
105 |
} |
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 |
job.schedule(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
108 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
109 |
|
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
110 |
public static void doEclipseRestartDialog(final IWorkbench workbench) { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
111 |
if (WorkbenchUtils.isJUnitRunning()){ |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
112 |
// 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
|
113 |
return; |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
114 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
115 |
workbench.getDisplay().asyncExec(new Runnable() { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
116 |
public void run() { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
117 |
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
118 |
if (window != null) { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
119 |
Shell shell = window.getShell(); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
120 |
// 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
|
121 |
RestartIDEDialog.show(shell, |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
122 |
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
|
123 |
Messages.getString("NewPluginChecker.Restart_Msg")); //$NON-NLS-1$ |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
124 |
} else { |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
125 |
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
|
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 |
}); |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
129 |
} |
fb279309251b
DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff
changeset
|
130 |
} |