KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > omg > lifl > eclipse > plugin > shell > actions > ShellAction


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2003 USTL - LIFL - GOAL
5 Contact: openccm-team@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jerome Offroy.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26 package org.omg.lifl.eclipse.plugin.shell.actions;
27
28 import java.io.IOException JavaDoc;
29
30 import org.eclipse.jface.action.IAction;
31 import org.eclipse.jface.viewers.ISelection;
32 import org.eclipse.ui.IWorkbenchWindow;
33 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
34
35 /**
36  * Our sample action implements workbench action delegate.
37  * The action proxy will be created by the workbench and
38  * shown in the UI. When the user tries to use the action,
39  * this delegate will be created and execution will be
40  * delegated to it.
41  * @see IWorkbenchWindowActionDelegate
42  */

43 public class ShellAction implements IWorkbenchWindowActionDelegate {
44     private IWorkbenchWindow window;
45     /**
46      * The constructor.
47      */

48     public ShellAction() {
49     }
50
51     /**
52      * The action has been activated. The argument of the
53      * method represents the 'real' action sitting
54      * in the workbench UI.
55      * @see IWorkbenchWindowActionDelegate#run
56      */

57     public void run(IAction action) {
58             String JavaDoc filename = "cmd.exe /c start cmd.exe";
59         try {
60             Runtime.getRuntime().exec(filename);
61         } catch (IOException JavaDoc e) {
62             e.printStackTrace();
63         }
64     }
65
66     /**
67      * Selection in the workbench has been changed. We
68      * can change the state of the 'real' action here
69      * if we want, but this can only happen after
70      * the delegate has been created.
71      * @see IWorkbenchWindowActionDelegate#selectionChanged
72      */

73     public void selectionChanged(IAction action, ISelection selection) {
74     }
75
76     /**
77      * We can use this method to dispose of any system
78      * resources we previously allocated.
79      * @see IWorkbenchWindowActionDelegate#dispose
80      */

81     public void dispose() {
82     }
83
84     /**
85      * We will cache window object in order to
86      * be able to provide parent shell for the message dialog.
87      * @see IWorkbenchWindowActionDelegate#init
88      */

89     public void init(IWorkbenchWindow window) {
90         this.window = window;
91     }
92 }
Popular Tags