summaryrefslogtreecommitdiffstats
path: root/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ReconfigYoctoHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ReconfigYoctoHandler.java')
-rw-r--r--plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ReconfigYoctoHandler.java78
1 files changed, 78 insertions, 0 deletions
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ReconfigYoctoHandler.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ReconfigYoctoHandler.java
new file mode 100644
index 0000000..6d508d3
--- /dev/null
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ReconfigYoctoHandler.java
@@ -0,0 +1,78 @@
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 *******************************************************************************/
11package org.yocto.sdk.ide.actions;
12
13import java.lang.reflect.Method;
14
15import org.eclipse.core.commands.ExecutionEvent;
16import org.eclipse.core.commands.ExecutionException;
17import org.eclipse.core.expressions.IEvaluationContext;
18import org.eclipse.core.resources.IContainer;
19import org.eclipse.core.runtime.IStatus;
20import org.eclipse.core.runtime.Status;
21import org.eclipse.jface.dialogs.ErrorDialog;
22import org.eclipse.cdt.internal.autotools.ui.actions.AbstractAutotoolsHandler;
23import org.eclipse.cdt.internal.autotools.ui.actions.InvokeAction;
24import org.eclipse.swt.widgets.Display;
25import org.yocto.sdk.ide.YoctoSDKPlugin;
26
27
28@SuppressWarnings("restriction")
29public class ReconfigYoctoHandler extends AbstractAutotoolsHandler {
30
31 public Object execute(ExecutionEvent event) throws ExecutionException {
32 ReconfigYoctoAction action = new ReconfigYoctoAction();
33 Method method = null;
34
35 try {
36 /*
37 * This is hack to workaround upstream eclipse bug #370288
38 */
39 Class [] params = {ExecutionEvent.class, InvokeAction.class};
40 method = AbstractAutotoolsHandler.class.getDeclaredMethod("execute",params );
41 } catch (NoSuchMethodException e) {
42 //no such method, old version of plugin org.eclipse.linuxtools.autotools.ui
43 method = null;
44 } catch (Exception e) {
45 throw new ExecutionException(e.getMessage(), e);
46 }
47
48 if (method != null) {
49 //new version
50 Object [] params = {event, action};
51 try {
52 return method.invoke(this, params);
53 }catch (Exception e) {
54 throw new ExecutionException(e.getMessage(), e);
55 }
56 } else {
57 //old version
58 //display a dialog to warn the user
59 Display.getDefault().syncExec(new Runnable() {
60 public void run() {
61 ErrorDialog.openError(null, "Change Yocto Project Settings", "Please update the plugin of \"Autotools support for CDT\"!",
62 new Status(IStatus.WARNING,YoctoSDKPlugin.PLUGIN_ID,"old version of plugin \"Autotools support for CDT\" detected."));
63 }
64 });
65 //try to display the dialog in the old way
66 Object o = event.getApplicationContext();
67 if (o instanceof IEvaluationContext) {
68 IContainer container = getContainer((IEvaluationContext)o);
69 if (container != null) {
70 action.setSelectedContainer(container);
71 action.run(null);
72 }
73 }
74 }
75
76 return null;
77 }
78}