KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > forrest > eclipse > popup > actions > StopForrest


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation or its licensors,
3  * as applicable.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.forrest.eclipse.popup.actions;
18
19 import org.apache.forrest.eclipse.job.ForrestManager;
20 import org.eclipse.core.resources.IProject;
21 import org.eclipse.core.resources.IResource;
22 import org.eclipse.core.runtime.IPath;
23 import org.eclipse.core.runtime.jobs.Job;
24 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
25 import org.eclipse.jface.action.IAction;
26 import org.eclipse.jface.viewers.ISelection;
27 import org.eclipse.jface.viewers.IStructuredSelection;
28 import org.eclipse.ui.IActionDelegate;
29 import org.eclipse.ui.IObjectActionDelegate;
30 import org.eclipse.ui.IWorkbenchPart;
31
32 public class StopForrest
33 implements IObjectActionDelegate, IJavaLaunchConfigurationConstants {
34
35     private IProject activeProject;
36     
37     /**
38      * Constructor for Action1.
39      */

40     public StopForrest() {
41         super();
42     }
43
44     /**
45      * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
46      */

47     public void setActivePart(IAction action, IWorkbenchPart targetPart) {
48     }
49
50     /**
51      * @see IActionDelegate#run(IAction)
52      */

53     public void run(IAction action) {
54         IPath workingDirectory = activeProject.getLocation();
55         Job forrest = ForrestManager.getInstance().getForrestJob(workingDirectory.toOSString(), ForrestManager.COMMAND_STOP);
56         forrest.setUser(true);
57         forrest.schedule();
58     }
59
60     /**
61      * @see IActionDelegate#selectionChanged(IAction, ISelection)
62      */

63     public void selectionChanged(IAction action, ISelection selection) {
64         if (selection instanceof IStructuredSelection) {
65             Object JavaDoc first = ((IStructuredSelection)selection).getFirstElement();
66             IResource resource = (IResource)first;
67             if (resource instanceof IProject) {
68                 activeProject = (IProject)resource;
69             }
70         }
71     }
72
73 }
Popular Tags