KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > terracotta > dso > actions > MakeConfigFileAction


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package org.terracotta.dso.actions;
5
6 import org.eclipse.core.resources.IFile;
7 import org.eclipse.core.resources.IProject;
8 import org.eclipse.jface.action.Action;
9 import org.eclipse.jface.action.IAction;
10 import org.eclipse.jface.viewers.ISelection;
11 import org.eclipse.jface.viewers.IStructuredSelection;
12 import org.eclipse.ui.IActionDelegate;
13 import org.eclipse.ui.IWorkbenchWindow;
14 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
15 import org.terracotta.dso.TcPlugin;
16
17 public class MakeConfigFileAction extends Action
18   implements IActionDelegate,
19              IWorkbenchWindowActionDelegate
20 {
21   private IFile m_file;
22   
23   public MakeConfigFileAction() {
24     super("Make Current Config File");
25   }
26
27   public void run(IAction action) {
28     TcPlugin plugin = TcPlugin.getDefault();
29     String JavaDoc filePath = m_file.getProjectRelativePath().toString();
30     IProject project = m_file.getProject();
31
32     plugin.clearConfigurationSessionProperties(project);
33     plugin.setConfigurationFilePath(project, filePath);
34     plugin.reloadConfiguration(project);
35   }
36
37   public void selectionChanged(IAction action, ISelection selection) {
38     if(selection instanceof IStructuredSelection) {
39       m_file = (IFile)((IStructuredSelection)selection).getFirstElement();
40     }
41   }
42
43   public void dispose() {/**/}
44   public void init(IWorkbenchWindow window) {/**/}
45 }
46
Popular Tags