[yocto] [PATCH 07/12] Move CommonHelper to org.yocto.remote.utils separate plugin
Ioana Grigoropol
ioanax.grigoropol at intel.com
Wed May 8 05:57:13 PDT 2013
- common helper is better suited to org.yocto.remote.utils since it is used for:
- running commands
- displaying error dialogs
Signed-off-by: Ioana Grigoropol <ioanax.grigoropol at intel.com>
---
.../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
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..c01e866
--- /dev/null
+++ b/plugins/org.yocto.remote.utils/src/org/yocto/remote/utils/CommonHelper.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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));
+ }
+ });
+
+ }
+
+}
--
1.7.9.5
More information about the yocto
mailing list