Author: rob.stryker(a)jboss.com
Date: 2009-03-02 00:58:08 -0500 (Mon, 02 Mar 2009)
New Revision: 13908
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.java
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.properties
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/DefaultConnectionWizardPage.java
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/NewConnectionWizard.java
Log:
JBIDE-3829 - error handling in JMX ui
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.java 2009-03-02
04:52:15 UTC (rev 13907)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.java 2009-03-02
05:58:08 UTC (rev 13908)
@@ -24,6 +24,9 @@
public static String DefaultConnectionWizardPage_Username;
public static String DefaultConnectionWizardPage_Password;
public static String DefaultConnectionWizardPage_JMX_URL;
+ public static String DefaultConnectionWizardPage_Blank_Invalid;
+ public static String DefaultConnectionWizardPage_Invalid_Connection;
+ public static String DefaultConnectionWizardPage_Name_In_Use;
public static String DeleteConnection;
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.properties
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.properties 2009-03-02
04:52:15 UTC (rev 13907)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/Messages.properties 2009-03-02
05:58:08 UTC (rev 13908)
@@ -12,6 +12,9 @@
DefaultConnectionWizardPage_Username=Username
DefaultConnectionWizardPage_Password=Password
DefaultConnectionWizardPage_JMX_URL=JMX URL
+DefaultConnectionWizardPage_Blank_Invalid=One or more fields are blank or invalid
+DefaultConnectionWizardPage_Invalid_Connection=The connection could not be created: {0}
+DefaultConnectionWizardPage_Name_In_Use=The connection name is already taken.
AttributeControlFactory_updateButtonTitle=Update
AttributeDetails_title=Attribute Details
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/DefaultConnectionWizardPage.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/DefaultConnectionWizardPage.java 2009-03-02
04:52:15 UTC (rev 13907)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/DefaultConnectionWizardPage.java 2009-03-02
05:58:08 UTC (rev 13908)
@@ -88,6 +88,7 @@
}
public DefaultConnectionWizardPage() {
super(_BLANK_);
+ setTitle(Messages.NewConnectionWizard_CreateNewConnection);
setDescription(Messages.DefaultConnectionWizardPage_Description);
}
@@ -246,32 +247,24 @@
userName = userNameText.getText();
password = passwordText.getText();
if (hostText.getText().equals(_BLANK_)) {
- showError("",
- "");
+ showError(Messages.DefaultConnectionWizardPage_Blank_Invalid);
return;
}
try {
InetAddress.getByName(hostText.getText());
} catch (UnknownHostException e) {
- showError("",
- "");
+ showError(e.getMessage());
return;
}
String host = hostText.getText();
if (portText.getText().equals(_BLANK_)) {
- showError("",
- "");
+ showError(Messages.DefaultConnectionWizardPage_Blank_Invalid);
return;
}
int port;
- try {
- port = Integer.parseInt(portText.getText());
- if (port < 1 || port > 0xffff) {
- throw new NumberFormatException();
- }
- } catch (NumberFormatException e) {
- showError("",
- "");
+ port = Integer.parseInt(portText.getText());
+ if (port < 1 || port > 0xffff) {
+ showError(Messages.DefaultConnectionWizardPage_Blank_Invalid);
return;
}
url = "service:jmx:rmi:///jndi/rmi://" + host + ":" + port +
"/jmxrmi"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -281,8 +274,7 @@
password = advancedPasswordText.getText();
if (urlText.getText().equals(_BLANK_)) {
- showError("",
- "");
+ showError(Messages.DefaultConnectionWizardPage_Blank_Invalid);
return;
}
url = urlText.getText();
@@ -290,20 +282,31 @@
// now validate name
if( name == null || nameTaken(name)) {
- showError("", "");
+ showError(Messages.DefaultConnectionWizardPage_Name_In_Use);
return;
}
+
+ try {
+ getConnection();
+ } catch( CoreException ce ) {
+ showError(ce.getMessage());
+ return;
+ }
clearMessage();
}
protected void clearMessage() {
setErrorMessage(null);
+ setPageComplete(true);
getContainer().updateMessage();
+ getContainer().updateButtons();
}
- protected void showError(String one, String two) {
- setErrorMessage("There's an error somewhere");
+ protected void showError(String message) {
+ setErrorMessage(message);
+ setPageComplete(false);
getContainer().updateMessage();
+ getContainer().updateButtons();
}
protected boolean nameTaken(String s) {
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/NewConnectionWizard.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/NewConnectionWizard.java 2009-03-02
04:52:15 UTC (rev 13907)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/wizards/NewConnectionWizard.java 2009-03-02
05:58:08 UTC (rev 13908)
@@ -86,7 +86,7 @@
if( active != null ) {
if( active.length > 0 ) {
if( active[active.length-1] == getContainer().getCurrentPage())
- return true;
+ return super.canFinish();
return false;
}
}
@@ -142,7 +142,7 @@
TreeViewer viewer;
public FirstPage() {
super(Messages.NewConnectionWizard);
- setDescription(Messages.NewConnectionWizard_CreateNewConnection);
+ setTitle(Messages.NewConnectionWizard_CreateNewConnection);
}
public void createControl(Composite parent) {
Composite main = new Composite(parent, SWT.NONE);
Show replies by date