diff options
Diffstat (limited to 'plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopHandler.java')
-rw-r--r-- | plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopHandler.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopHandler.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopHandler.java new file mode 100644 index 0000000..152f142 --- /dev/null +++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/PowertopHandler.java | |||
@@ -0,0 +1,48 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010 Intel Corporation. | ||
3 | * All rights reserved. This program and the accompanying materials | ||
4 | * are made available under the terms of the Eclipse Public License v1.0 | ||
5 | * which accompanies this distribution, and is available at | ||
6 | * http://www.eclipse.org/legal/epl-v10.html | ||
7 | * | ||
8 | * Contributors: | ||
9 | * Intel - initial API and implementation | ||
10 | *******************************************************************************/ | ||
11 | package org.yocto.sdk.remotetools.actions; | ||
12 | |||
13 | import org.eclipse.core.commands.AbstractHandler; | ||
14 | import org.eclipse.core.commands.ExecutionEvent; | ||
15 | import org.eclipse.core.commands.ExecutionException; | ||
16 | import org.eclipse.jface.dialogs.MessageDialog; | ||
17 | import org.eclipse.ui.IWorkbenchWindow; | ||
18 | import org.eclipse.ui.PlatformUI; | ||
19 | import org.eclipse.ui.handlers.HandlerUtil; | ||
20 | import org.eclipse.ui.progress.IProgressService; | ||
21 | |||
22 | public class PowertopHandler extends AbstractHandler { | ||
23 | |||
24 | public Object execute(ExecutionEvent event) throws ExecutionException { | ||
25 | IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); | ||
26 | |||
27 | PowertopSettingDialog setting=new PowertopSettingDialog( | ||
28 | window.getShell() | ||
29 | ); | ||
30 | |||
31 | if(setting.open()==BaseSettingDialog.OK) { | ||
32 | IProgressService progressService = PlatformUI.getWorkbench().getProgressService(); | ||
33 | PowertopModel op=new PowertopModel(setting.getHost(),setting.getTime(),setting.getShowPid(),window.getShell().getDisplay()); | ||
34 | try { | ||
35 | progressService.busyCursorWhile(op); | ||
36 | }catch (InterruptedException e) { | ||
37 | //user cancelled | ||
38 | }catch (Exception e) { | ||
39 | e.printStackTrace(); | ||
40 | MessageDialog.openError(window.getShell(), | ||
41 | "Powertop", | ||
42 | (e.getCause() != null) ? e.getCause().getMessage() : e.getMessage()); | ||
43 | } | ||
44 | } | ||
45 | return null; | ||
46 | } | ||
47 | |||
48 | } | ||