Lines 34-41
Link Here
|
34 |
* |
34 |
* |
35 |
* @author jrojcek |
35 |
* @author jrojcek |
36 |
*/ |
36 |
*/ |
37 |
class IDESettingsPanel extends javax.swing.JPanel |
37 |
public final class IDESettingsPanel extends javax.swing.JPanel |
38 |
implements PropertyChangeListener { |
38 |
implements PropertyChangeListener, java.awt.event.ItemListener, javax.swing.event.DocumentListener { |
39 |
|
39 |
|
40 |
/** See org.openide.WizardDescriptor.PROP_CONTENT_SELECTED_INDEX |
40 |
/** See org.openide.WizardDescriptor.PROP_CONTENT_SELECTED_INDEX |
41 |
*/ |
41 |
*/ |
Lines 56-64
Link Here
|
56 |
|
56 |
|
57 |
/** holds init data for async initialization */ |
57 |
/** holds init data for async initialization */ |
58 |
private InitData initData; |
58 |
private InitData initData; |
|
|
59 |
/** it this panel listening on immediate changes or not */ |
60 |
private boolean immediate; |
59 |
|
61 |
|
60 |
/** Creates new form IDESettingsPanel */ |
62 |
/** Creates new form IDESettingsPanel */ |
61 |
public IDESettingsPanel() { |
63 |
IDESettingsPanel() { |
62 |
//XXX if we could kill the |
64 |
//XXX if we could kill the |
63 |
initComponents(); |
65 |
initComponents(); |
64 |
|
66 |
|
Lines 89-94
Link Here
|
89 |
Utilities.attachInitJob(this, new AsyncGUIJobImpl ()); |
91 |
Utilities.attachInitJob(this, new AsyncGUIJobImpl ()); |
90 |
} |
92 |
} |
91 |
|
93 |
|
|
|
94 |
/** Create a panel to be used inside Tools/Options |
95 |
*/ |
96 |
public static JPanel toolsOptions () { |
97 |
IDESettingsPanel ide = new IDESettingsPanel (); |
98 |
ide.initializePanel (true); |
99 |
return ide; |
100 |
} |
101 |
|
92 |
//A couple static methods to fix NPEs on GTK |
102 |
//A couple static methods to fix NPEs on GTK |
93 |
|
103 |
|
94 |
private static Font fetchFont(String key) { |
104 |
private static Font fetchFont(String key) { |
Lines 352-357
Link Here
|
352 |
|
362 |
|
353 |
private void changeProxyEnabled(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeProxyEnabled |
363 |
private void changeProxyEnabled(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeProxyEnabled |
354 |
setProxySettingEnabled(proxyCheckBox.isSelected()); |
364 |
setProxySettingEnabled(proxyCheckBox.isSelected()); |
|
|
365 |
|
366 |
if (immediate) { |
367 |
storeValues (); |
368 |
} |
355 |
}//GEN-LAST:event_changeProxyEnabled |
369 |
}//GEN-LAST:event_changeProxyEnabled |
356 |
|
370 |
|
357 |
private void setProxySettingEnabled(boolean b) { |
371 |
private void setProxySettingEnabled(boolean b) { |
Lines 373-378
Link Here
|
373 |
} else { |
387 |
} else { |
374 |
uiMode = 1; // sdi |
388 |
uiMode = 1; // sdi |
375 |
} |
389 |
} |
|
|
390 |
if (immediate) { |
391 |
storeValues (); |
392 |
} |
376 |
}//GEN-LAST:event_changeWindowMode |
393 |
}//GEN-LAST:event_changeWindowMode |
377 |
|
394 |
|
378 |
|
395 |
|
Lines 407-426
Link Here
|
407 |
public void initFromSettings(WizardDescriptor wd) { |
424 |
public void initFromSettings(WizardDescriptor wd) { |
408 |
wd.addPropertyChangeListener(this); |
425 |
wd.addPropertyChangeListener(this); |
409 |
if (Boolean.TRUE.equals(wd.getProperty("initializePanel"))) { |
426 |
if (Boolean.TRUE.equals(wd.getProperty("initializePanel"))) { |
410 |
initializePanel(); |
427 |
initializePanel(false); |
411 |
} |
428 |
} |
412 |
} |
429 |
} |
413 |
|
430 |
|
414 |
/** Initialize panel from NB setting |
431 |
/** Initialize panel from NB setting |
415 |
*/ |
432 |
*/ |
416 |
private void initializePanel() { |
433 |
private void initializePanel(boolean listenOnChanges) { |
417 |
// asycnhronous refresh |
434 |
// asycnhronous refresh |
418 |
Utilities.attachInitJob(this, new AsyncGUIJobImpl ()); |
435 |
Utilities.attachInitJob(this, new AsyncGUIJobImpl ()); |
419 |
IDESettings settings = (IDESettings)IDESettings.findObject (IDESettings.class, true); |
436 |
IDESettings settings = (IDESettings)IDESettings.findObject (IDESettings.class, true); |
420 |
uiMode = settings.getUIMode(); |
437 |
uiMode = settings.getUIMode(); |
421 |
sdiRadioButton.setSelected(uiMode == 1); // SDI |
438 |
sdiRadioButton.setSelected(uiMode == 1); // SDI |
422 |
mdiRadioButton.setSelected(uiMode == 2); // MDI |
439 |
mdiRadioButton.setSelected(uiMode == 2); // MDI |
423 |
|
440 |
|
424 |
// web browser, proxy init... |
441 |
// web browser, proxy init... |
425 |
browserLabel.setDisplayedMnemonic (bundle.getString ("CTL_BrowserLabel_mnemonic").charAt (0)); |
442 |
browserLabel.setDisplayedMnemonic (bundle.getString ("CTL_BrowserLabel_mnemonic").charAt (0)); |
426 |
try { |
443 |
try { |
Lines 433-438
Link Here
|
433 |
} catch (RuntimeException ex) { |
450 |
} catch (RuntimeException ex) { |
434 |
ErrorManager.getDefault ().notify (ex); |
451 |
ErrorManager.getDefault ().notify (ex); |
435 |
} |
452 |
} |
|
|
453 |
|
454 |
if (listenOnChanges) { |
455 |
immediate = true; |
456 |
serverField.getDocument ().addDocumentListener (this); |
457 |
portField.getDocument ().addDocumentListener (this); |
458 |
browserComboBox.addItemListener (this); |
459 |
} |
460 |
|
436 |
} |
461 |
} |
437 |
|
462 |
|
438 |
/** Handling of property changes in node structure and setup wizard descriptor |
463 |
/** Handling of property changes in node structure and setup wizard descriptor |
Lines 444-470
Link Here
|
444 |
WizardDescriptor wd = (WizardDescriptor)evt.getSource(); |
469 |
WizardDescriptor wd = (WizardDescriptor)evt.getSource(); |
445 |
if (wd.getValue() == wd.FINISH_OPTION) { |
470 |
if (wd.getValue() == wd.FINISH_OPTION) { |
446 |
wd.removePropertyChangeListener(this); |
471 |
wd.removePropertyChangeListener(this); |
447 |
// set proxy |
472 |
storeValues (); |
448 |
IDESettings settings = (IDESettings)IDESettings.findObject(IDESettings.class, true); |
473 |
} |
449 |
settings.setProxyHost(serverField.getText()); |
474 |
} |
450 |
settings.setProxyPort(portField.getText()); |
475 |
} |
451 |
settings.setUseProxy(proxyCheckBox.isSelected()); |
476 |
|
452 |
// set ui mode |
477 |
private void storeValues () { |
453 |
settings.setUIMode(uiMode); |
478 |
// set proxy |
454 |
// set web browser |
479 |
IDESettings settings = (IDESettings)IDESettings.findObject(IDESettings.class, true); |
455 |
if (editor != null) { |
480 |
settings.setProxyHost(serverField.getText()); |
456 |
try { |
481 |
settings.setProxyPort(portField.getText()); |
457 |
Object o = browserComboBox.getSelectedItem (); |
482 |
settings.setUseProxy(proxyCheckBox.isSelected()); |
458 |
if (o instanceof String && (o != null)) { |
483 |
// set ui mode |
459 |
editor.setAsText ((String)o); |
484 |
settings.setUIMode(uiMode); |
460 |
settings.setWWWBrowser ((org.openide.awt.HtmlBrowser.Factory)editor.getValue ()); |
485 |
// set web browser |
461 |
} |
486 |
if (editor != null) { |
462 |
} |
487 |
try { |
463 |
catch (RuntimeException ex) { |
488 |
Object o = browserComboBox.getSelectedItem (); |
464 |
ErrorManager.getDefault ().notify (ex); |
489 |
if (o instanceof String && (o != null)) { |
465 |
} |
490 |
editor.setAsText ((String)o); |
|
|
491 |
settings.setWWWBrowser ((org.openide.awt.HtmlBrowser.Factory)editor.getValue ()); |
466 |
} |
492 |
} |
467 |
} |
493 |
} |
|
|
494 |
catch (RuntimeException ex) { |
495 |
ErrorManager.getDefault ().notify (ex); |
496 |
} |
468 |
} |
497 |
} |
469 |
} |
498 |
} |
470 |
|
499 |
|
Lines 479-484
Link Here
|
479 |
mdiRadioButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_mdiRadioButton")); //NOI18N |
508 |
mdiRadioButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_mdiRadioButton")); //NOI18N |
480 |
serverField.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_serverField")); |
509 |
serverField.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_serverField")); |
481 |
portField.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_portField")); |
510 |
portField.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_portField")); |
|
|
511 |
} |
512 |
|
513 |
public void insertUpdate(javax.swing.event.DocumentEvent e) { |
514 |
storeValues (); |
515 |
} |
516 |
|
517 |
public void removeUpdate(javax.swing.event.DocumentEvent e) { |
518 |
storeValues (); |
519 |
} |
520 |
|
521 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
522 |
storeValues (); |
523 |
} |
524 |
|
525 |
public void changedUpdate(javax.swing.event.DocumentEvent e) { |
526 |
storeValues (); |
482 |
} |
527 |
} |
483 |
|
528 |
|
484 |
private class AsyncGUIJobImpl implements AsyncGUIJob { |
529 |
private class AsyncGUIJobImpl implements AsyncGUIJob { |