Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.wildwebdeveloper.embedder.node.feature"
label="%name"
version="1.2.5.qualifier"
version="1.2.6.qualifier"
provider-name="Eclipse Wild Web Developer project"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.wildwebdeveloper.embedder.node.feature/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<version>1.0.0-SNAPSHOT</version>
</parent>
<packaging>eclipse-feature</packaging>
<version>1.2.5-SNAPSHOT</version>
<version>1.2.6-SNAPSHOT</version>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Manager for embedded Node.js
Bundle-SymbolicName: org.eclipse.wildwebdeveloper.embedder.node
Bundle-Version: 1.0.8.qualifier
Bundle-Version: 1.0.9.qualifier
Bundle-License: EPL-2.0;link="http://www.eclipse.org/legal/epl-2.0"
Bundle-Vendor: Eclipse Wild Web Developer
Automatic-Module-Name: org.eclipse.wildwebdeveloper.embedder.node
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.wildwebdeveloper.embedder.node/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<version>1.0.0-SNAPSHOT</version>
</parent>
<packaging>eclipse-plugin</packaging>
<version>1.0.8-SNAPSHOT</version>
<version>1.0.9-SNAPSHOT</version>

<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,19 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.swt.widgets.Display;
import org.osgi.service.prefs.BackingStoreException;

public class NodeJSManager {
public static final String NODE_ROOT_DIRECTORY = ".node";

private static final String MACOS_DSCL_SHELL_PREFIX = "UserShell: ";
private static final String ALREADY_WARNED_NODEJS_MISSING = "alreadyWarnedNodeJsMissing";

private static boolean alreadyWarned;
private static Properties cachedNodeJsInfoProperties;
private static final Object EXPAND_LOCK = new Object();

Expand Down Expand Up @@ -100,10 +103,9 @@ public static File getNodeJsLocation() {
if (res != null) {
validateNodeVersion(res);
return res;
} else if (!alreadyWarned) {
warnNodeJSMissing();
alreadyWarned = true;
}
warnNodeJSMissing();

return null;
}

Expand Down Expand Up @@ -332,20 +334,34 @@ private static void validateNodeVersion(File nodeJsLocation) {
}

private static void warnNodeJSMissing() {
if (!alreadyWarned) {
if (!hasAlreadyWarnedNodeJsMissing()) {
Display.getDefault().asyncExec(() -> MessageDialog.openWarning(Display.getCurrent().getActiveShell(),
"Missing node.js", "Could not find node.js. This will result in editors missing key features.\n"
+ "Please make sure node.js is installed and that your PATH environment variable contains the location to the `node` executable."));
setAlreadyWarnedNodeJsMissing();
}
alreadyWarned = true;
}

private static void warnNodeJSVersionCouldNotBeDetermined() {
if (!alreadyWarned) {
if (!hasAlreadyWarnedNodeJsMissing()) {
Display.getDefault().asyncExec(() -> MessageDialog.openWarning(Display.getCurrent().getActiveShell(),
"Node.js version could not be determined",
"Node.js version could not be determined. Please make sure a recent version of node.js is installed, editors may be missing key features otherwise.\n"));
setAlreadyWarnedNodeJsMissing();
}
alreadyWarned = true;
}

private static boolean hasAlreadyWarnedNodeJsMissing() {
return Platform.getPreferencesService().getBoolean(Activator.PLUGIN_ID, ALREADY_WARNED_NODEJS_MISSING, false, null);
}

private static void setAlreadyWarnedNodeJsMissing() {
try {
IEclipsePreferences workspacePreferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
workspacePreferences.putBoolean(ALREADY_WARNED_NODEJS_MISSING, true);
workspacePreferences.flush();
} catch (BackingStoreException e) {
ILog.get().error(e.getMessage(), e);
}
}
}
Loading