Skip to content

Commit a0be51b

Browse files
author
angelozerr
committed
Add node Path in the node.js configuration preferences page.
1 parent 514fa4d commit a0be51b

File tree

3 files changed

+51
-6
lines changed

3 files changed

+51
-6
lines changed

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/internal/ui/TypeScriptUIMessages.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class TypeScriptUIMessages extends NLS {
6161
public static String NodejsConfigurationBlock_nodejs_group_label;
6262
public static String NodejsConfigurationBlock_embedded_checkbox_label;
6363
public static String NodejsConfigurationBlock_installed_checkbox_label;
64-
64+
public static String NodejsConfigurationBlock_nodePath_label;
6565
// tsserver
6666
public static String ServerConfigurationBlock_typescript_group_label;
6767
public static String ServerConfigurationBlock_embedded_checkbox_label;
@@ -115,6 +115,7 @@ public class TypeScriptUIMessages extends NLS {
115115
public static String TypeScriptBuilder_enable_Error_message;
116116
public static String TypeScriptBuilder_disable_Error_message;
117117

118+
118119
public static ResourceBundle getResourceBundle() {
119120
try {
120121
if (fResourceBundle == null)

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/internal/ui/TypeScriptUIMessages.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ TypeScriptHyperlink_text=TypeScript - Go to definition
2424
TypeScriptConsoleJob_name=TypeScript Console Job
2525
ConsoleTerminateAction_tooltipText=Stop tsserver of [{0}] project.
2626

27-
# Preferencesory
27+
# Preferences
2828
TypeScriptMainPropertyPage_enable_builder_checkbox_label=Enable TypeScript B&uilder?
2929
TypeScriptMainPropertyPage_enable_builder_checkbox_description=Builder is required to <a href=\"compile\">compile/build on save</a> and <a href=\"tslint\">validate with tslint</a>.
3030

@@ -40,7 +40,7 @@ PropertyAndPreferencePage_useprojectsettings_label=Enable pr&oject specific sett
4040
NodejsConfigurationBlock_nodejs_group_label=Consume TypeScript tsserver, tsc with
4141
NodejsConfigurationBlock_embedded_checkbox_label=Embedded node.js
4242
NodejsConfigurationBlock_installed_checkbox_label=Installed node.js
43-
43+
NodejsConfigurationBlock_nodePath_label=Path:
4444
ServerConfigurationBlock_typescript_group_label=Consume TypeScript tsserver with
4545
ServerConfigurationBlock_embedded_checkbox_label=Embedded TypeScript
4646
ServerConfigurationBlock_installed_checkbox_label=Installed TypeScript

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/internal/ui/preferences/NodejsConfigurationBlock.java

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import org.eclipse.swt.widgets.Control;
2626
import org.eclipse.swt.widgets.FileDialog;
2727
import org.eclipse.swt.widgets.Group;
28+
import org.eclipse.swt.widgets.Label;
29+
import org.eclipse.swt.widgets.Text;
2830
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
2931

3032
import ts.eclipse.ide.core.TypeScriptCorePlugin;
@@ -37,6 +39,7 @@
3739
import ts.eclipse.ide.internal.ui.dialogs.WorkspaceResourceSelectionDialog.Mode;
3840
import ts.eclipse.ide.ui.preferences.OptionsConfigurationBlock;
3941
import ts.eclipse.ide.ui.preferences.ScrolledPageContent;
42+
import ts.utils.FileUtils;
4043
import ts.utils.StringUtils;
4144

4245
/**
@@ -59,6 +62,8 @@ public class NodejsConfigurationBlock extends OptionsConfigurationBlock {
5962

6063
private Button browseFileSystemButton;
6164
private Button browseWorkspaceButton;
65+
private Label nodePathTitle;
66+
private Text nodePath;
6267

6368
public NodejsConfigurationBlock(IStatusChangeListener context, IProject project,
6469
IWorkbenchPreferenceContainer container) {
@@ -102,7 +107,7 @@ private Composite createUI(Composite parent) {
102107

103108
controlsComposite = new Composite(composite, SWT.NONE);
104109
controlsComposite.setFont(composite.getFont());
105-
controlsComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
110+
controlsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
106111

107112
layout = new GridLayout();
108113
layout.marginHeight = 0;
@@ -117,13 +122,15 @@ private Composite createUI(Composite parent) {
117122
Group group = new Group(controlsComposite, SWT.NONE);
118123
group.setFont(controlsComposite.getFont());
119124
group.setText(TypeScriptUIMessages.NodejsConfigurationBlock_nodejs_group_label);
120-
group.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
125+
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
121126
group.setLayout(layout);
122127

123128
// Embedded node.js
124129
createEmbeddedNodejsField(group);
125130
// Installed node.js
126131
createInstalledNodejsField(group);
132+
// Path info.
133+
createNodePathInfo(composite);
127134
updateComboBoxes();
128135
return pageContent;
129136
}
@@ -168,7 +175,12 @@ public void widgetSelected(SelectionEvent e) {
168175
String[] defaultPaths = IDENodejsProcessHelper.getDefaultNodejsPaths();
169176
installedComboBox = newComboControl(parent, PREF_NODEJS_PATH, defaultPaths, defaultPaths, false);
170177
installedComboBox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
171-
178+
installedComboBox.addSelectionListener(new SelectionAdapter() {
179+
@Override
180+
public void widgetSelected(SelectionEvent e) {
181+
updatePath();
182+
}
183+
});
172184
// Create Browse buttons.
173185
createBrowseButtons(parent, installedComboBox);
174186

@@ -219,12 +231,44 @@ public void widgetSelected(SelectionEvent e) {
219231
});
220232
}
221233

234+
private void createNodePathInfo(Composite parent) {
235+
Composite composite = new Composite(parent, SWT.NONE);
236+
composite.setLayout(new GridLayout());
237+
GridData gridData = new GridData(GridData.FILL_BOTH);
238+
composite.setLayoutData(gridData);
239+
240+
// Node path label
241+
nodePathTitle = new Label(composite, SWT.NONE);
242+
nodePathTitle.setText(TypeScriptUIMessages.NodejsConfigurationBlock_nodePath_label);
243+
gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
244+
nodePathTitle.setLayoutData(gridData);
245+
246+
nodePath = new Text(composite, SWT.WRAP | SWT.READ_ONLY);
247+
nodePath.setText(""); //$NON-NLS-1$
248+
gridData = new GridData(GridData.FILL_BOTH);
249+
gridData.horizontalSpan = 2;
250+
gridData.widthHint = 200;
251+
nodePath.setLayoutData(gridData);
252+
}
253+
222254
private void updateComboBoxes() {
223255
boolean embedded = useEmbedNodeJs.getSelection();
224256
embeddedComboBox.setEnabled(embedded);
225257
installedComboBox.setEnabled(!embedded);
226258
browseFileSystemButton.setEnabled(!embedded);
227259
browseWorkspaceButton.setEnabled(!embedded);
260+
updatePath();
261+
}
262+
263+
private void updatePath() {
264+
boolean embedded = useEmbedNodeJs.getSelection();
265+
if (embedded) {
266+
IEmbeddedNodejs[] installs = TypeScriptCorePlugin.getNodejsInstallManager().getNodejsInstalls();
267+
IEmbeddedNodejs install = installs[embeddedComboBox.getSelectionIndex()];
268+
nodePath.setText(FileUtils.getPath(install.getPath()));
269+
} else {
270+
nodePath.setText(installedComboBox.getText());
271+
}
228272
}
229273

230274
@Override

0 commit comments

Comments
 (0)