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.eclipse.core.resources.IProject; 28 import org.eclipse.core.runtime.CoreException; 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 39 public class StartAction implements IObjectActionDelegate { 40 41 private IJavaProject currentJavaProject; 42 private IProject currentProject; 43 44 public StartAction() { 45 super(); 46 } 47 48 public void setActivePart(IAction action, IWorkbenchPart targetPart) { 49 } 50 51 public void run(IAction action) { 52 try { 53 if(currentJavaProject!=null){ 54 currentProject=currentJavaProject.getProject(); 55 } 56 DerbyServerUtils.getDefault().startDerbyServer(currentProject); 57 58 } 59 catch (CoreException e) { 60 Shell shell = new Shell(); 61 MessageDialog.openInformation( 62 shell, 63 CommonNames.PLUGIN_NAME, 64 Messages.D_NS_START_ERROR + 65 org.apache.derby.ui.util.SelectionUtil.getStatusMessages(e)); 66 } 67 } 68 69 public void selectionChanged(IAction action, ISelection selection) { 70 currentJavaProject = org.apache.derby.ui.util.SelectionUtil.findSelectedJavaProject(selection); 71 72 if(currentJavaProject==null){ 73 currentProject=org.apache.derby.ui.util.SelectionUtil.findSelectedProject(selection); 74 } 75 76 } 77 78 } 79 | Popular Tags |