1717import org .eclipse .debug .core .ILaunchManager ;
1818import org .eclipse .debug .core .model .ILaunchConfigurationDelegate ;
1919import org .eclipse .debug .core .model .RuntimeProcess ;
20+ import org .eclipse .jface .dialogs .MessageDialog ;
21+ import org .eclipse .jface .preference .PreferenceDialog ;
22+ import org .eclipse .swt .widgets .Display ;
23+ import org .eclipse .swt .widgets .Shell ;
24+ import org .eclipse .ui .PlatformUI ;
25+ import org .eclipse .ui .dialogs .PreferencesUtil ;
2026import org .nodeclipse .debug .util .Constants ;
2127import org .nodeclipse .debug .util .NodeDebugUtil ;
2228import org .nodeclipse .ui .Activator ;
@@ -43,10 +49,20 @@ public void launch(ILaunchConfiguration configuration, String mode,
4349 }
4450
4551 // Using configuration to build command line
52+
53+ String nodePath = Activator .getDefault ().getPreferenceStore ().getString (PreferenceConstants .NODE_PATH );
54+
55+ // Check if the node location is correctly configured
56+ File nodeFile = new File (nodePath );
57+ if (!nodeFile .exists ()){
58+ // If the location is not valid than show a dialog which prompts the user to goto the preferences page
59+ showPreferencesDialog ();
60+ return ;
61+ }
62+
4663 List <String > cmdLine = new ArrayList <String >();
4764 // Application path should be stored in preference.
48- cmdLine .add (Activator .getDefault ().getPreferenceStore ()
49- .getString (PreferenceConstants .NODE_PATH ));
65+ cmdLine .add (nodePath );
5066 if (mode .equals (ILaunchManager .DEBUG_MODE )) {
5167 cmdLine .add ("--debug-brk=5858" );
5268 }
@@ -87,6 +103,23 @@ public void launch(ILaunchConfiguration configuration, String mode,
87103 }
88104 nodeProcess = process ;
89105 }
106+
107+ private void showPreferencesDialog () {
108+ Display .getDefault ().syncExec (new Runnable () {
109+ public void run () {
110+ Shell shell = PlatformUI .getWorkbench ().getActiveWorkbenchWindow ().getShell ();
111+
112+ MessageDialog dialog = new MessageDialog (shell , "Nodeclipse" , null , "Node.js runtime not correctly configured.\n \n "
113+ + "Please goto Window -> Prefrences -> Nodeclipse and configure the correct location" , MessageDialog .ERROR , new String [] { "Open Prefrences ..." , "Cancel" }, 0 );
114+ int result = dialog .open ();
115+ if (result == 0 ) {
116+ PreferenceDialog pref = PreferencesUtil .createPreferenceDialogOn (shell , PreferenceConstants .PREFERENCES_PAGE , null , null );
117+ if (pref != null )
118+ pref .open ();
119+ }
120+ }
121+ });
122+ }
90123
91124 public static void terminateNodeProcess () {
92125 if (nodeProcess != null ) {
0 commit comments