Skip to content

Commit be88304

Browse files
committed
Issue #39: Improve Node.js debug dialogs and preferences
1 parent 07bbf0c commit be88304

File tree

4 files changed

+33
-17
lines changed

4 files changed

+33
-17
lines changed

dev/com.ibm.microclimate.ui/src/com/ibm/microclimate/ui/internal/debug/NodeJsBrowserDialog.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ protected Control createDialogArea(Composite PARENT) {
6868
Text l = new Text(composite, SWT.READ_ONLY | SWT.WRAP);
6969
l.setText(Messages.NodeJsBrowserDialogPasteMessage);
7070
l.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
71+
l.setBackground(composite.getBackground());
72+
l.setForeground(composite.getForeground());
7173

7274
// Text for the URL
7375
Text l2 = new Text(composite, SWT.BORDER);
@@ -120,7 +122,6 @@ public void widgetSelected(SelectionEvent e) {
120122
protected boolean isResizable() {
121123
return true;
122124
}
123-
124125

125126
protected void launchWebBrowser(String browserName, String urlStr) {
126127
MCLogger.log("Launch web browser " + browserName + " with url: " + url); //$NON-NLS-1$ //$NON-NLS-2$

dev/com.ibm.microclimate.ui/src/com/ibm/microclimate/ui/internal/debug/WebBrowserSelectionDialog.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ protected Control createCustomArea(Composite parent)
7171

7272
Text label = new Text(composite, SWT.READ_ONLY | SWT.SINGLE );
7373
label.setText(Messages.BrowserSelectionListLabel);
74+
label.setBackground(composite.getBackground());
75+
label.setForeground(composite.getForeground());
7476

7577
updateWebBrowserCombo(composite);
7678

@@ -148,31 +150,36 @@ protected void updateWebBrowserCombo(Composite composite){
148150
webBrowserCombo.add(tempBrowser.getName());
149151
String location = tempBrowser.getLocation();
150152
// Try to select the first Chrome browser that can be found (use location to determine if it's Chrome)
151-
if (location != null && location.indexOf("chrome") >= 0){ //$NON-NLS-1$
153+
if (location != null && location.toLowerCase().indexOf("chrome") >= 0){ //$NON-NLS-1$
152154
selectedIndex = i;
153155
}
154156
}
155-
}
157+
}
156158

159+
// Only enable the OK button if something is selected
157160
Button okButton = this.getButton(IDialogConstants.OK_ID);
158-
159-
// Only show the OK button enabled if there is a browser to select
160-
if(okButton != null){
161-
okButton.setEnabled(len > 0);
161+
if (okButton != null) {
162+
okButton.setEnabled(selectedIndex >= 0);
162163
}
163-
164+
164165
if (selectedIndex >= 0){
165166
webBrowserCombo.select(selectedIndex);
166167
browserName = validBrowsers.get(selectedIndex).getName();
167168
}
168169

169170
webBrowserCombo.addSelectionListener(new SelectionAdapter() {
170171
public void widgetSelected(SelectionEvent e) {
172+
boolean valid = false;
171173
if (validBrowsers != null){
172174
if (webBrowserCombo.getSelectionIndex() >= 0){
173175
browserName = validBrowsers.get(webBrowserCombo.getSelectionIndex()).getName();
176+
valid = true;
174177
}
175178
}
179+
Button okButton = getButton(IDialogConstants.OK_ID);
180+
if (okButton != null) {
181+
okButton.setEnabled(valid);
182+
}
176183
}
177184
});
178185
}
@@ -189,10 +196,10 @@ public String getBrowserName(){
189196
}
190197

191198
public int open(){
192-
// Make sure the OK button is disabled if no valid browser exists
199+
// Make sure the OK button is only enabled if there is a selection
193200
Button okButton = this.getButton(IDialogConstants.OK_ID);
194-
if (okButton != null && validBrowsers != null){
195-
okButton.setEnabled(validBrowsers.size() > 0);
201+
if (okButton != null) {
202+
okButton.setEnabled(webBrowserCombo != null && webBrowserCombo.getSelectionIndex() >= 0);
196203
}
197204

198205
return super.open();

dev/com.ibm.microclimate.ui/src/com/ibm/microclimate/ui/internal/messages/messages.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ NodeJSDebugURLError=Failed to get the debug URL for the {0} application.
9797

9898
BrowserSelectionTitle=Launch the Node.js Debugger
9999
BrowserSelectionDescription=Select a Chromium based web browser for launching the Node.js debugger.
100-
BrowserSelectionLabel=Select a Chromium based web browser for launching the Node.js debugger
100+
BrowserSelectionLabel=Select a Chromium based web browser for launching the Node.js debugger:
101101
BrowserSelectionAlwaysUseMsg=Always use selected Chromium based web browser for Node.js debugging
102102
BrowserSelectionManageButtonText=Manage...
103103
BrowserSelectionListLabel=Web browser:

dev/com.ibm.microclimate.ui/src/com/ibm/microclimate/ui/internal/prefs/MicroclimatePrefsParentPage.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,21 +99,29 @@ public void modifyText(ModifyEvent arg0) {
9999
Label separator = new Label(composite, SWT.HORIZONTAL);
100100
separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL, GridData.CENTER, true, false, 2, 1));
101101

102-
final Group selectWebBrowserComposite = new Group(composite, SWT.NONE);
102+
Text browserSelectionLabel = new Text(composite, SWT.READ_ONLY | SWT.SINGLE);
103+
browserSelectionLabel.setText(Messages.BrowserSelectionLabel);
104+
browserSelectionLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 3, 1));
105+
browserSelectionLabel.setBackground(composite.getBackground());
106+
browserSelectionLabel.setForeground(composite.getForeground());
107+
108+
109+
final Composite selectWebBrowserComposite = new Composite(composite, SWT.NONE);
103110
layout = new GridLayout();
104111
layout.horizontalSpacing = convertHorizontalDLUsToPixels(4);
105112
layout.verticalSpacing = convertVerticalDLUsToPixels(3);
106113
layout.marginWidth = 20;
107-
layout.marginHeight = 10;
114+
layout.marginHeight = 2;
108115
layout.numColumns = 3;
109116
selectWebBrowserComposite.setLayout(layout);
110-
selectWebBrowserComposite.setText(Messages.BrowserSelectionLabel);
111117
selectWebBrowserComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
112118

113119
selectWebBrowserLabel = new Text(selectWebBrowserComposite, SWT.READ_ONLY | SWT.SINGLE );
114120
selectWebBrowserLabel.setText(Messages.BrowserSelectionListLabel);
115-
selectWebBrowserLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.FILL, false, false, 1, 1));
116-
121+
selectWebBrowserLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 1, 1));
122+
selectWebBrowserLabel.setBackground(selectWebBrowserComposite.getBackground());
123+
selectWebBrowserLabel.setForeground(selectWebBrowserComposite.getForeground());
124+
117125
webBrowserCombo = new Combo(selectWebBrowserComposite, SWT.BORDER | SWT.READ_ONLY);
118126

119127
refreshPreferencesPage();

0 commit comments

Comments
 (0)