diff options
Diffstat (limited to 'plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommonHelper.java')
-rw-r--r-- | plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommonHelper.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommonHelper.java b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommonHelper.java new file mode 100644 index 0000000..23afd38 --- /dev/null +++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommonHelper.java | |||
@@ -0,0 +1,46 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2013 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.remote.utils; | ||
12 | |||
13 | import org.eclipse.core.runtime.IStatus; | ||
14 | import org.eclipse.core.runtime.Status; | ||
15 | import org.eclipse.jface.dialogs.ErrorDialog; | ||
16 | import org.eclipse.swt.widgets.Display; | ||
17 | |||
18 | public class CommonHelper { | ||
19 | |||
20 | static public boolean isExecAvail(String exec) { | ||
21 | boolean ret = false; | ||
22 | try { | ||
23 | Process p = Runtime.getRuntime().exec(new String[] {"which", exec}); | ||
24 | p.waitFor(); | ||
25 | if(p.exitValue() == 0) { | ||
26 | ret = true; | ||
27 | } | ||
28 | } catch (Exception e) { | ||
29 | e.printStackTrace(); | ||
30 | } | ||
31 | return ret; | ||
32 | } | ||
33 | |||
34 | public static void showErrorDialog(final String dialogTitle, final String errorMessage, final String reason) { | ||
35 | //needs to be run in the ui thread otherwise swt throws invalid thread access | ||
36 | Display.getDefault().syncExec(new Runnable() { | ||
37 | @Override | ||
38 | public void run() { | ||
39 | ErrorDialog.openError(null, dialogTitle, errorMessage, | ||
40 | new Status(IStatus.ERROR,Activator.PLUGIN_ID,reason)); | ||
41 | } | ||
42 | }); | ||
43 | |||
44 | } | ||
45 | |||
46 | } | ||