Skip to content

Commit 439d494

Browse files
committed
Merge https://github.com/pushkar85/nodeclipse-1 into pull-request-master
2 parents 736aa59 + 6f026d8 commit 439d494

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

org.nodeclipse.debug/src/org/nodeclipse/debug/launch/LaunchConfigurationDelegate.java

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
import org.eclipse.debug.core.ILaunchManager;
1818
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
1919
import 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;
2026
import org.nodeclipse.debug.util.Constants;
2127
import org.nodeclipse.debug.util.NodeDebugUtil;
2228
import 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) {

org.nodeclipse.ui/src/org/nodeclipse/ui/preferences/PreferenceConstants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ public class PreferenceConstants {
1212
public static final String EXPRESS_PATH = "express_pass";
1313
public static final String EXPRESS_VERSION = "express_version";
1414
public static final String COMPLETIONS_JSON_PATH = "completionsjson_path";
15+
public static final String PREFERENCES_PAGE = "org.nodeclipse.ui.preferences.NodePreferencePage";
16+
1517

1618
}

0 commit comments

Comments
 (0)