From c7da892cb23d50d4d85746c9a0b6b14bf570989d Mon Sep 17 00:00:00 2001 From: Adrian Dudau Date: Thu, 26 Jun 2014 13:23:09 +0200 Subject: initial commit for Enea Linux 4.0 Migrated from the internal git server on the daisy-enea branch Signed-off-by: Adrian Dudau --- .../src/org/yocto/remote/utils/CommonHelper.java | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommonHelper.java (limited to 'plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommonHelper.java') 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 @@ +/******************************************************************************* + * Copyright (c) 2013 Intel Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel - initial API and implementation + *******************************************************************************/ +package org.yocto.remote.utils; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.swt.widgets.Display; + +public class CommonHelper { + + static public boolean isExecAvail(String exec) { + boolean ret = false; + try { + Process p = Runtime.getRuntime().exec(new String[] {"which", exec}); + p.waitFor(); + if(p.exitValue() == 0) { + ret = true; + } + } catch (Exception e) { + e.printStackTrace(); + } + return ret; + } + + public static void showErrorDialog(final String dialogTitle, final String errorMessage, final String reason) { + //needs to be run in the ui thread otherwise swt throws invalid thread access + Display.getDefault().syncExec(new Runnable() { + @Override + public void run() { + ErrorDialog.openError(null, dialogTitle, errorMessage, + new Status(IStatus.ERROR,Activator.PLUGIN_ID,reason)); + } + }); + + } + +} -- cgit v1.2.3-54-g00ecf