diff options
author | Adrian Dudau <adrian.dudau@enea.com> | 2013-12-12 13:36:50 +0100 |
---|---|---|
committer | Adrian Dudau <adrian.dudau@enea.com> | 2013-12-12 15:25:03 +0100 |
commit | 41ac47d732eed8392d60d0f6773e5a279d49b999 (patch) | |
tree | cf19d099db9cfdb8d73aa21c31e7aa1cc86ff860 /plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ReconfigYoctoHandler.java | |
download | eclipse-poky-juno-41ac47d732eed8392d60d0f6773e5a279d49b999.tar.gz |
Migrated from the internal git server on the dora-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
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.java | 78 |
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 | *******************************************************************************/ | ||
11 | package org.yocto.sdk.ide.actions; | ||
12 | |||
13 | import java.lang.reflect.Method; | ||
14 | |||
15 | import org.eclipse.core.commands.ExecutionEvent; | ||
16 | import org.eclipse.core.commands.ExecutionException; | ||
17 | import org.eclipse.core.expressions.IEvaluationContext; | ||
18 | import org.eclipse.core.resources.IContainer; | ||
19 | import org.eclipse.core.runtime.IStatus; | ||
20 | import org.eclipse.core.runtime.Status; | ||
21 | import org.eclipse.jface.dialogs.ErrorDialog; | ||
22 | import org.eclipse.cdt.internal.autotools.ui.actions.AbstractAutotoolsHandler; | ||
23 | import org.eclipse.cdt.internal.autotools.ui.actions.InvokeAction; | ||
24 | import org.eclipse.swt.widgets.Display; | ||
25 | import org.yocto.sdk.ide.YoctoSDKPlugin; | ||
26 | |||
27 | |||
28 | @SuppressWarnings("restriction") | ||
29 | public 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 | } | ||