--- a/core.ui/src/org/netbeans/core/ui/options/general/AdvancedProxyPanel.form
+++ a/core.ui/src/org/netbeans/core/ui/options/general/AdvancedProxyPanel.form
@@ -6,8 +6,12 @@
+
+
+
+
--- a/core.ui/src/org/netbeans/core/ui/options/general/AdvancedProxyPanel.java
+++ a/core.ui/src/org/netbeans/core/ui/options/general/AdvancedProxyPanel.java
@@ -42,6 +42,8 @@
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
+import org.openide.DialogDescriptor;
+import org.openide.NotificationLineSupport;
/**
*
@@ -53,6 +55,11 @@
private String oldHttpsPort;
private String oldSocksHost;
private String oldSocksPort;
+ private DialogDescriptor dd = null;
+
+ public void setDialogDescriptor(DialogDescriptor dd) {
+ this.dd = dd;
+ }
/** Creates new form AdvancedProxyPanel */
AdvancedProxyPanel (GeneralOptionsModel model) {
@@ -84,6 +91,33 @@
followHttpPortIfDemand ();
}
});
+ tfHttpsProxyPort.getDocument().addDocumentListener (new DocumentListener () {
+ public void insertUpdate(DocumentEvent arg0) {
+ validatePortValue(tfHttpsProxyPort.getText ());
+ }
+
+ public void removeUpdate(DocumentEvent arg0) {
+ validatePortValue(tfHttpsProxyPort.getText ());
+ }
+
+ public void changedUpdate(DocumentEvent arg0) {
+ validatePortValue(tfHttpsProxyPort.getText ());
+ }
+ });
+ tfSocksPort.getDocument().addDocumentListener (new DocumentListener () {
+ public void insertUpdate(DocumentEvent arg0) {
+ validatePortValue(tfSocksPort.getText ());
+ }
+
+ public void removeUpdate(DocumentEvent arg0) {
+ validatePortValue(tfSocksPort.getText ());
+ }
+
+ public void changedUpdate(DocumentEvent arg0) {
+ validatePortValue(tfSocksPort.getText ());
+ }
+ });
+
}
// helps implement OptionsPanelController
@@ -176,12 +210,51 @@
}
private void followHttpPortIfDemand () {
+ String port = tfHttpProxyPort.getText ();
+ validatePortValue( port );
+
if (! cbSameProxySettings.isSelected ()) {
return ;
}
- String port = tfHttpProxyPort.getText ();
+
tfHttpsProxyPort.setText (port);
tfSocksPort.setText (port);
+
+ }
+
+ private void validatePortValue (String port) {
+ clearError();
+ if( port != null && port.length() > 0 ) {
+ try {
+ Integer.parseInt(port);
+ } catch( NumberFormatException nfex) {
+ showError(org.openide.util.NbBundle.getMessage(
+ AdvancedProxyPanel.class,
+ "LBL_AdvancedProxyPanel_PortError")); // NOI18N
+ }
+ }
+ }
+
+ private void showError(String message) {
+ if( dd != null ) {
+ NotificationLineSupport notificationLineSupport =
+ dd.getNotificationLineSupport();
+ if( notificationLineSupport != null ) {
+ notificationLineSupport.setErrorMessage(message);
+ }
+ dd.setValid(false);
+ }
+ }
+
+ private void clearError() {
+ if( dd != null ) {
+ NotificationLineSupport notificationLineSupport =
+ dd.getNotificationLineSupport();
+ if( notificationLineSupport != null ) {
+ notificationLineSupport.clearMessages();
+ }
+ dd.setValid(true);
+ }
}
/** This method is called from within the constructor to
--- a/core.ui/src/org/netbeans/core/ui/options/general/Bundle.properties
+++ a/core.ui/src/org/netbeans/core/ui/options/general/Bundle.properties
@@ -150,6 +150,8 @@
LBL_GeneralOptionsPanel_bMoreProxy.AN=Advanced Proxy Settings
LBL_GeneralOptionsPanel_bMoreProxy.AD=Open Advanced Proxy Settings
+LBL_GeneralOptionsPanel_PortError=Port number must be an integer value.
+
LBL_GeneralOptionsPanel_lWebProxy=Proxy Settings\:
LBL_AdvancedProxyPanel_lHttpProxyHost=HTTP &Proxy\:
@@ -173,6 +175,7 @@
LBL_AdvancedProxyPanel_cbSameProxySettings=Use the same proxy settings for &all protocols
LBL_AdvancedProxyPanel_Title=Advanced Proxy Options
+LBL_AdvancedProxyPanel_PortError=Port number must be an integer value.
GeneralOptionsPanel.rbUseSystemProxy.text=&Use System Proxy Settings
GeneralOptionsPanel.lWebBrowser.text=&Web Browser\:
GeneralOptionsPanel.rbNoProxy.text=&No Proxy
@@ -259,3 +262,4 @@
General.Options.Export.Category.displayName=General
General.Options.Export.displayName=General
Other.Options.Export.displayName=All Other Unspecified
+GeneralOptionsPanel.errorLabel.text=errorLabel
--- a/core.ui/src/org/netbeans/core/ui/options/general/GeneralOptionsPanel.form
+++ a/core.ui/src/org/netbeans/core/ui/options/general/GeneralOptionsPanel.form
@@ -1,6 +1,9 @@
--- a/core.ui/src/org/netbeans/core/ui/options/general/GeneralOptionsPanel.java
+++ a/core.ui/src/org/netbeans/core/ui/options/general/GeneralOptionsPanel.java
@@ -41,17 +41,23 @@
package org.netbeans.core.ui.options.general;
+import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeSupport;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;
import javax.swing.JLabel;
import javax.swing.JPanel;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
import org.netbeans.beaninfo.editors.HtmlBrowser;
+import org.netbeans.spi.options.OptionsPanelController;
import org.openide.DialogDescriptor;
import org.openide.DialogDisplayer;
import org.openide.awt.Mnemonics;
@@ -69,6 +75,8 @@
private GeneralOptionsModel model;
private HtmlBrowser.FactoryEditor editor;
private AdvancedProxyPanel advancedPanel;
+ private PropertyChangeSupport support = new PropertyChangeSupport(this);
+ private boolean valid = true;
/**
@@ -76,6 +84,9 @@
*/
public GeneralOptionsPanel () {
initComponents ();
+
+ errorLabel.setForeground(new Color(153,0,0));
+ errorLabel.setVisible(false);
loc (lWebBrowser, "Web_Browser");
loc (lWebProxy, "Web_Proxy");
@@ -95,6 +106,21 @@
cbWebBrowser.addActionListener (this);
tfProxyHost.addActionListener (this);
tfProxyPort.addActionListener (this);
+
+ tfProxyPort.getDocument().addDocumentListener(new DocumentListener(){
+
+ public void insertUpdate(DocumentEvent e) {
+ validatePortValue();
+ }
+
+ public void removeUpdate(DocumentEvent e) {
+ validatePortValue();
+ }
+
+ public void changedUpdate(DocumentEvent e) {
+ validatePortValue();
+ }
+ });
ButtonGroup bgProxy = new ButtonGroup ();
bgProxy.add (rbNoProxy);
@@ -138,6 +164,46 @@
//if (System.getProperty("netbeans.system_http_proxy") == null) // NOI18N
//rbUseSystemProxy.setEnabled(false);
}
+
+ private void validatePortValue () {
+ clearError();
+
+ boolean oldValid = valid;
+ valid = isPortValid();
+ if( !valid ) {
+ showError(loc ("LBL_GeneralOptionsPanel_PortError")); // NOI18N
+ }
+
+ if( oldValid != valid ) {
+ support.firePropertyChange(
+ new PropertyChangeEvent(this,
+ OptionsPanelController.PROP_VALID, oldValid, valid));
+ }
+ }
+
+ private boolean isPortValid() {
+ String port = tfProxyPort.getText ();
+ boolean portStatus = true;
+ if( port != null && port.length() > 0 ) {
+ try {
+ Integer.parseInt(port);
+ } catch( NumberFormatException nfex) {
+ portStatus = false;
+ }
+ }
+
+ return portStatus;
+ }
+
+ private void showError(String message) {
+ errorLabel.setVisible(true);
+ errorLabel.setText(message);
+ }
+
+ private void clearError() {
+ errorLabel.setText("");
+ errorLabel.setVisible(false);
+ }
/** This method is called from within the constructor to
* initialize the form.
@@ -165,6 +231,7 @@
jUsageCheck = new javax.swing.JCheckBox();
lblUsageInfo = new javax.swing.JLabel();
lblLearnMore = new javax.swing.JLabel();
+ errorLabel = new javax.swing.JLabel();
lWebBrowser.setLabelFor(cbWebBrowser);
org.openide.awt.Mnemonics.setLocalizedText(lWebBrowser, org.openide.util.NbBundle.getMessage(GeneralOptionsPanel.class, "GeneralOptionsPanel.lWebBrowser.text")); // NOI18N
@@ -236,6 +303,8 @@
}
});
+ org.openide.awt.Mnemonics.setLocalizedText(errorLabel, org.openide.util.NbBundle.getMessage(GeneralOptionsPanel.class, "GeneralOptionsPanel.errorLabel.text")); // NOI18N
+
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -246,7 +315,7 @@
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(lWebBrowser)
.add(18, 18, 18)
- .add(cbWebBrowser, 0, 1131, Short.MAX_VALUE)
+ .add(cbWebBrowser, 0, 1132, Short.MAX_VALUE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(editBrowserButton))
.add(jSeparator2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1291, Short.MAX_VALUE)
@@ -260,11 +329,14 @@
.add(layout.createSequentialGroup()
.add(17, 17, 17)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(bMoreProxy)
+ .add(layout.createSequentialGroup()
+ .add(bMoreProxy)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(errorLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1105, Short.MAX_VALUE))
.add(layout.createSequentialGroup()
.add(lProxyHost)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
- .add(tfProxyHost, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 957, Short.MAX_VALUE)
+ .add(tfProxyHost, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1016, Short.MAX_VALUE)
.add(12, 12, 12)
.add(lProxyPort)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
@@ -274,10 +346,10 @@
.add(lUsage)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(lblUsageInfo, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1171, Short.MAX_VALUE)
+ .add(lblUsageInfo, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1205, Short.MAX_VALUE)
.add(layout.createSequentialGroup()
.add(jUsageCheck)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 690, Short.MAX_VALUE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 838, Short.MAX_VALUE))
.add(lblLearnMore))))
.add(0, 0, 0))
);
@@ -307,7 +379,9 @@
.add(tfProxyHost, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(lProxyPort))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(bMoreProxy)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(bMoreProxy)
+ .add(errorLabel))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(jSeparator3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
@@ -358,6 +432,8 @@
advancedPanel = new AdvancedProxyPanel (model);
}
DialogDescriptor dd = new DialogDescriptor (advancedPanel, loc ("LBL_AdvancedProxyPanel_Title"));
+ advancedPanel.setDialogDescriptor(dd);
+ dd.createNotificationLineSupport();
advancedPanel.update (tfProxyHost.getText (), tfProxyPort.getText ());
DialogDisplayer.getDefault ().createDialog (dd).setVisible (true);
if (DialogDescriptor.OK_OPTION.equals (dd.getValue ())) {
@@ -407,6 +483,7 @@
private javax.swing.JButton bMoreProxy;
private javax.swing.JComboBox cbWebBrowser;
private javax.swing.JButton editBrowserButton;
+ private javax.swing.JLabel errorLabel;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JSeparator jSeparator3;
private javax.swing.JCheckBox jUsageCheck;
@@ -560,7 +637,7 @@
}
boolean dataValid () {
- return true;
+ return isPortValid();
}
boolean isChanged () {
@@ -569,6 +646,14 @@
if (!tfProxyPort.getText ().equals (model.getHttpProxyPort ())) return true;
return changed;
}
+
+ public void addPropertyChangeListener(java.beans.PropertyChangeListener l) {
+ support.addPropertyChangeListener(l);
+ }
+
+ public void removePropertyChangeListener(java.beans.PropertyChangeListener l) {
+ support.removePropertyChangeListener(l);
+ }
public void actionPerformed (ActionEvent e) {
changed = true;