1 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 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 |