1 21 22 package org.apache.derby.ui.actions; 23 24 import org.apache.derby.ui.common.CommonNames; 25 import org.apache.derby.ui.common.Messages; 26 import org.apache.derby.ui.util.DerbyServerUtils; 27 import org.apache.derby.ui.util.SelectionUtil; 28 import org.eclipse.core.resources.IProject; 29 import org.eclipse.jdt.core.IJavaProject; 30 import org.eclipse.jface.action.IAction; 31 import org.eclipse.jface.dialogs.MessageDialog; 32 import org.eclipse.jface.viewers.ISelection; 33 import org.eclipse.swt.widgets.Shell; 34 import org.eclipse.ui.IObjectActionDelegate; 35 import org.eclipse.ui.IWorkbenchPart; 36 37 38 public class StopAction implements IObjectActionDelegate { 39 40 private IJavaProject currentJavaProject; 41 private IProject currentProject; 42 private Thread server=null; 43 public StopAction() { 44 super(); 45 } 46 47 public void setActivePart(IAction action, IWorkbenchPart targetPart) { 48 } 49 50 public void run(IAction action) { 51 try { 52 if(currentJavaProject!=null){ 53 currentProject=currentJavaProject.getProject(); 54 55 } 56 DerbyServerUtils.getDefault().stopDerbyServer(currentProject); 57 58 59 } 60 catch (Exception e) { 61 e.printStackTrace(); 62 Shell shell = new Shell(); 63 MessageDialog.openInformation( 64 shell, 65 CommonNames.PLUGIN_NAME, 66 Messages.D_NS_STOP_ERROR+ 67 SelectionUtil.getStatusMessages(e)); 68 } 69 } 70 71 public void selectionChanged(IAction action, ISelection selection) { 72 currentJavaProject = SelectionUtil.findSelectedJavaProject(selection); 73 if(currentJavaProject==null){ 74 currentProject=org.apache.derby.ui.util.SelectionUtil.findSelectedProject(selection); 75 } 76 } 77 } 78 | Popular Tags |