|
Lines 1-40
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 200, 2005 IBM Corporation and others. |
2 |
* Copyright (c) 200, 2005 IBM Corporation and others. All rights reserved. This |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* program and the accompanying materials are made available under the terms of |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* the Eclipse Public License v1.0 which accompanies this distribution, and is |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* available at http://www.eclipse.org/legal/epl-v10.html |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
6 |
* |
| 7 |
* |
7 |
* Contributors: IBM Corporation - initial API and implementation |
| 8 |
* Contributors: |
8 |
******************************************************************************/ |
| 9 |
* IBM Corporation - initial API and implementation |
|
|
| 10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.platform.internal; |
9 |
package org.eclipse.platform.internal; |
| 12 |
|
10 |
|
| 13 |
import java.util.Properties; |
11 |
import java.util.Properties; |
| 14 |
|
12 |
|
|
|
13 |
import org.eclipse.core.commands.Command; |
| 14 |
import org.eclipse.core.commands.ExecutionEvent; |
| 15 |
import org.eclipse.core.commands.ExecutionException; |
| 16 |
import org.eclipse.core.commands.NotEnabledException; |
| 17 |
import org.eclipse.core.commands.NotHandledException; |
| 18 |
import org.eclipse.core.commands.common.NotDefinedException; |
| 19 |
import org.eclipse.core.internal.registry.BundleHelper; |
| 20 |
import org.eclipse.core.runtime.Platform; |
| 21 |
import org.eclipse.core.runtime.internal.adaptor.PluginParser.PluginInfo; |
| 15 |
import org.eclipse.swt.widgets.Shell; |
22 |
import org.eclipse.swt.widgets.Shell; |
| 16 |
import org.eclipse.ui.PlatformUI; |
23 |
import org.eclipse.ui.PlatformUI; |
|
|
24 |
import org.eclipse.ui.commands.ICommandService; |
| 25 |
import org.eclipse.ui.handlers.IHandlerService; |
| 26 |
import org.eclipse.ui.internal.util.BundleUtility; |
| 17 |
import org.eclipse.ui.intro.IIntroSite; |
27 |
import org.eclipse.ui.intro.IIntroSite; |
| 18 |
import org.eclipse.ui.intro.config.IIntroAction; |
28 |
import org.eclipse.ui.intro.config.IIntroAction; |
| 19 |
import org.eclipse.update.ui.UpdateManagerUI; |
29 |
import org.eclipse.update.ui.UpdateManagerUI; |
|
|
30 |
import org.osgi.framework.Bundle; |
| 20 |
|
31 |
|
| 21 |
public class LaunchUpdateIntroAction implements IIntroAction { |
32 |
public class LaunchUpdateIntroAction implements IIntroAction { |
| 22 |
|
33 |
|
| 23 |
public LaunchUpdateIntroAction() { |
34 |
private static final String COMMAND_P2 = "org.eclipse.equinox.p2.ui.sdk.update"; |
| 24 |
} |
35 |
private static final String COMMAND_UPDATE_MANAGER = "org.eclipse.ui.update.findAndInstallUpdates"; |
| 25 |
|
36 |
private static final String P2_BUNDLE = "org.eclipse.equinox.p2.ui.sdk"; |
| 26 |
public void run(IIntroSite site, Properties params) { |
37 |
|
| 27 |
|
38 |
public LaunchUpdateIntroAction() { |
| 28 |
Runnable r = new Runnable() { |
39 |
} |
| 29 |
public void run() { |
40 |
|
| 30 |
Shell currentShell = PlatformUI.getWorkbench() |
41 |
public void run(IIntroSite site, Properties params) { |
| 31 |
.getActiveWorkbenchWindow().getShell(); |
42 |
Bundle bundle = Platform.getBundle(P2_BUNDLE); |
| 32 |
UpdateManagerUI.openInstaller(currentShell); |
43 |
ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); |
| 33 |
} |
44 |
IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class); |
| 34 |
}; |
45 |
Command command; |
| 35 |
|
46 |
if (bundle == null) { |
| 36 |
Shell currentShell = PlatformUI.getWorkbench() |
47 |
command = commandService.getCommand(COMMAND_UPDATE_MANAGER); |
| 37 |
.getActiveWorkbenchWindow().getShell(); |
48 |
} else { |
| 38 |
currentShell.getDisplay().asyncExec(r); |
49 |
command = commandService.getCommand(COMMAND_P2); |
| 39 |
} |
50 |
} |
|
|
51 |
ExecutionEvent executionEvent = handlerService.createExecutionEvent(command, null); |
| 52 |
try { |
| 53 |
command.executeWithChecks(executionEvent); |
| 54 |
} catch (ExecutionException e) { |
| 55 |
} catch (NotDefinedException e) { |
| 56 |
} catch (NotEnabledException e) { |
| 57 |
} catch (NotHandledException e) { |
| 58 |
} |
| 59 |
} |
| 40 |
} |
60 |
} |