2525import org .eclipse .swt .widgets .Control ;
2626import org .eclipse .swt .widgets .FileDialog ;
2727import org .eclipse .swt .widgets .Group ;
28+ import org .eclipse .swt .widgets .Label ;
29+ import org .eclipse .swt .widgets .Text ;
2830import org .eclipse .ui .preferences .IWorkbenchPreferenceContainer ;
2931
3032import ts .eclipse .ide .core .TypeScriptCorePlugin ;
3739import ts .eclipse .ide .internal .ui .dialogs .WorkspaceResourceSelectionDialog .Mode ;
3840import ts .eclipse .ide .ui .preferences .OptionsConfigurationBlock ;
3941import ts .eclipse .ide .ui .preferences .ScrolledPageContent ;
42+ import ts .utils .FileUtils ;
4043import 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