Skip to content

Commit 5fc1ee7

Browse files
author
Paul Verest
committed
vertx run rhino:path; use VERTX_HOME
1 parent 8023a2d commit 5fc1ee7

File tree

5 files changed

+39
-20
lines changed

5 files changed

+39
-20
lines changed

org.nodeclipse.vertx/plugin.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,12 @@ Copyright (c) 2014 Enide, Paul Verest & other Nodeclipse authors. http://www.nod
122122
</launchConfigurationTabGroup>
123123
</extension>
124124

125-
<!-- not used
126125
<extension
127126
point="org.eclipse.core.runtime.preferences">
128127
<initializer
129-
class="org.nodeclipse.phantomjs.preferences.PhantomjsPreferenceInitializer">
128+
class="org.nodeclipse.vertx.preferences.VertxPreferenceInitializer">
130129
</initializer>
131130
</extension>
132-
-->
133131
<extension
134132
point="org.eclipse.ui.preferencePages">
135133
<page

org.nodeclipse.vertx/src/org/nodeclipse/vertx/VertxConstants.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ public class VertxConstants {
88

99
public static final String PROCESS_MESSAGE = "Vert.x Process";
1010

11-
public static final String VERTX_PATH = "vertx_path";
11+
//public static final String VERTX_PATH = "vertx_path";
12+
public static final String VERTX_HOME_TO_USE = "vertx_home_to_use";
1213

1314
public static final String ATTR_ENVIRONMENT_VARIABLES = "attr_environment_variables";
1415

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.eclipse.core.resources.ResourcesPlugin;
1010
import org.eclipse.core.runtime.CoreException;
1111
import org.eclipse.core.runtime.IProgressMonitor;
12+
import org.eclipse.core.runtime.Platform;
1213
import org.eclipse.debug.core.DebugPlugin;
1314
import org.eclipse.debug.core.ILaunch;
1415
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -25,14 +26,17 @@
2526
import org.nodeclipse.vertx.VertxConstants;
2627

2728
/**
28-
* Launching `jjs` from Java 8.<br>
29+
* Launching `vertx run rhino:path` .<br>
2930
* see LaunchConfigurationDelegate in .debug and .phantomjs module for comparison.
3031
*
31-
* @since 0.7
32+
* @since 0.11
3233
* @author Paul Verest
3334
*/
3435
public class LaunchConfigurationDelegate implements ILaunchConfigurationDelegate {
3536

37+
boolean isWindows = Platform.getOS().startsWith("win");
38+
private boolean warned = false;
39+
3640
@Override
3741
public void launch(ILaunchConfiguration configuration, String mode,
3842
ILaunch launch, IProgressMonitor monitor) throws CoreException {
@@ -43,15 +47,16 @@ public void launch(ILaunchConfiguration configuration, String mode,
4347
// Using configuration to build command line
4448
List<String> cmdLine = new ArrayList<String>();
4549

46-
String executablePath= preferenceStore.getString(VertxConstants.VERTX_PATH);
47-
// Check if the node location is correctly configured
50+
String vertxHomeToUse= preferenceStore.getString(VertxConstants.VERTX_HOME_TO_USE);
51+
String executablePath= vertxHomeToUse + (isWindows?"\\bin\\vertx.bat":"/bin/vertx");
52+
// Check if the vertx location is correctly configured
4853
File executableFile = new File(executablePath);
49-
if(!executableFile.exists()){
54+
if( ("".equals(vertxHomeToUse)) || (!executableFile.exists()) ){
5055
// If the location is not valid than show a dialog which prompts the user to goto the preferences page
5156
// Dialogs.showPreferencesDialog("path to jjs util from Java 8 runtime is not correctly configured.\n\n"
5257
// + "Please goto Window -> Prefrences -> Nodeclipse and configure the correct location under 'JJS path:'");
5358
CommonDialogs.showPreferencesDialog(VertxConstants.PREFERENCES_PAGE,
54-
"Vert.x `vertx` location is not correctly configured.\n\n"
59+
"Vert.x installation is not correctly configured.\n\n"
5560
+ "Please goto Window -> Preferences -> "+VertxConstants.PREFERENCE_PAGE_NAME
5661
+" and configure the correct location");
5762
return;
@@ -63,7 +68,7 @@ public void launch(ILaunchConfiguration configuration, String mode,
6368
String file = configuration.getAttribute(VertxConstants.KEY_FILE_PATH, "");
6469
String filePath = ResourcesPlugin.getWorkspace().getRoot().findMember(file).getLocation().toOSString();
6570
// path is relative, so cannot find it, unless get absolute path
66-
cmdLine.add(filePath);
71+
cmdLine.add("rhino:"+filePath);
6772

6873
File workingPath = null;
6974
String workingDirectory = configuration.getAttribute(Constants.ATTR_WORKING_DIRECTORY, "");
@@ -94,8 +99,6 @@ public void launch(ILaunchConfiguration configuration, String mode,
9499

95100
}
96101

97-
private boolean warned = false;
98-
99102
/** Get EnvironmentVariables from ILaunchConfiguration
100103
* and adds JAVA_HOME, GRADLE_HOME, PATH, TEMP, SystemDrive, HOME
101104
* @param configuration ILaunchConfiguration
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package org.nodeclipse.vertx.preferences;
2+
3+
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
4+
import org.eclipse.jface.preference.IPreferenceStore;
5+
import org.nodeclipse.vertx.Activator;
6+
import org.nodeclipse.vertx.VertxConstants;
7+
8+
public class VertxPreferenceInitializer extends AbstractPreferenceInitializer {
9+
10+
@Override
11+
public void initializeDefaultPreferences() {
12+
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
13+
String vertxHome = System.getenv("VERTX_HOME");
14+
if (vertxHome!=null){
15+
store.setDefault(VertxConstants.VERTX_HOME_TO_USE, vertxHome );
16+
}
17+
}
18+
19+
}
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package org.nodeclipse.vertx.preferences;
22

3+
import org.eclipse.jface.preference.DirectoryFieldEditor;
34
import org.eclipse.jface.preference.FieldEditorPreferencePage;
4-
import org.eclipse.jface.preference.FileFieldEditor;
55
import org.eclipse.ui.IWorkbench;
66
import org.eclipse.ui.IWorkbenchPreferencePage;
77
import org.nodeclipse.vertx.Activator;
8-
//import org.nodeclipse.ui.Activator;
9-
//import org.nodeclipse.ui.preferences.PreferenceConstants;
108
import org.nodeclipse.vertx.VertxConstants;
119

1210
/**
@@ -15,14 +13,14 @@
1513
*/
1614
public class VertxPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
1715

18-
private FileFieldEditor vertxPath;
16+
private DirectoryFieldEditor vertxHomeToUse;
1917

2018
public VertxPreferencePage(){
2119
super(GRID);
2220
setPreferenceStore(Activator.getDefault().getPreferenceStore());
2321
setDescription(VertxConstants.PREFERENCE_PAGE_DESCRIPTION+"\n"
2422
+"Vert.x requires JDK 1.7.0 or later. Make sure the JDK bin directory is on your `PATH`.\n"
25-
+"create VERTX_HOME pointing to folder where you extracted .zip, add %VERTX_HOME%\bin; to your `PATH`");
23+
+"create VERTX_HOME pointing to folder where you extracted .zip, add %VERTX_HOME%/bin; to your `PATH`");
2624
}
2725

2826
@Override
@@ -31,7 +29,7 @@ public void init(IWorkbench workbench) {
3129

3230
@Override
3331
protected void createFieldEditors() {
34-
vertxPath = new FileFieldEditor(VertxConstants.VERTX_PATH, "`vertx` path:", getFieldEditorParent());
35-
addField(vertxPath);
32+
vertxHomeToUse = new DirectoryFieldEditor(VertxConstants.VERTX_HOME_TO_USE, "VERTX_HOME to use:", getFieldEditorParent());
33+
addField(vertxHomeToUse);
3634
}
3735
}

0 commit comments

Comments
 (0)