Author: rob.stryker(a)jboss.com
Date: 2007-11-05 17:37:26 -0500 (Mon, 05 Nov 2007)
New Revision: 4723
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/AttributeGroup.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXPropertySheetPage.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXViewProvider.java
Log:
cleaning up JMX in case I get lucky and finish it in time tonight =D
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/AttributeGroup.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/AttributeGroup.java 2007-11-05
20:56:12 UTC (rev 4722)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/AttributeGroup.java 2007-11-05
22:37:26 UTC (rev 4723)
@@ -21,6 +21,8 @@
*/
package org.jboss.ide.eclipse.as.ui.views.server.providers.jmx;
+import java.util.ArrayList;
+
import javax.management.Attribute;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
@@ -43,7 +45,6 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
@@ -134,6 +135,14 @@
final WrappedMBeanAttributeInfo attInfo = (WrappedMBeanAttributeInfo) item
.getData();
+ // If we can't create one of these objects via a string,
+ // handle it through a wizard instead.
+ if( !isSimpleType(attInfo.getInfo().getType())) {
+ handleComplexType(attInfo);
+ return;
+ }
+
+
final int column = 3;
boolean isCarbon = SWT.getPlatform().equals("carbon");
final Composite composite = new Composite(tree, SWT.NONE);
@@ -200,22 +209,32 @@
}
}
-
- protected void saveAttributeChange(final WrappedMBeanAttributeInfo attInfo, Text text)
{
- if (text.isDisposed())
- return;
- final String text2 = text.getText();
- final Attribute att = createAttribute(attInfo, text2);
- final Boolean[] errorBool = new Boolean[1];
+
+ protected void saveAttributeChange(WrappedMBeanAttributeInfo attInfo, Text text) {
+ if (!text.isDisposed()) {
+ Attribute att = createAttribute(attInfo, text.getText());
+ if( att == null ) {
+ // throw up a message box and say no can do, for now
+ MessageBox messageBox = new MessageBox (new Shell(), SWT.OK);
+ messageBox.setText ("Cannot update bean");
+ messageBox.setMessage ("Bean update cannot proceed. Plug-in cannot convert
" + text.getText() + " into " + attInfo.getInfo().getType());
+ messageBox.open();
+ return;
+ }
+ saveAttributeChange(attInfo, att);
+ }
+ }
+
+ protected void saveAttributeChange(final WrappedMBeanAttributeInfo attInfo, final
Attribute att) {
if( att == null ) {
// throw up a message box and say no can do, for now
MessageBox messageBox = new MessageBox (new Shell(), SWT.OK);
messageBox.setText ("Cannot update bean");
- messageBox.setMessage ("Bean update cannot proceed. Plug-in cannot convert "
+ text2 + " into " + attInfo.getInfo().getType());
+ messageBox.setMessage ("Bean update cannot proceed. Plug-in cannot convert "
+ att.getValue().toString() + " into " + attInfo.getInfo().getType());
messageBox.open();
return;
}
-
+ final Boolean[] errorBool = new Boolean[1];
final JMXRunnable run = new JMXRunnable() {
public void run(MBeanServerConnection connection) {
try {
@@ -249,15 +268,39 @@
Object val = null;
if( type != null ) {
- if( type.equals("java.lang.String")) val = text;
- else if( type.equals("boolean")) val = new Boolean(text);
- else if( type.equals("int")) val = new Integer(text);
- else if( type.equals("long")) val = new Long(text);
+ try {
+ if( type.equals("java.lang.String")) val = text;
+ else if( type.equals("boolean")) val = new Boolean(text);
+ else if( type.equals("int")) val = new Integer(text);
+ else if( type.equals("long")) val = new Long(text);
+ } catch( Exception e ) {}
}
return val == null ? null :
new Attribute(attInfo.getInfo().getName(), val);
}
+ protected ArrayList<String> simpleTypeList = null;
+ protected boolean isSimpleType(String fullClassName) {
+ if( simpleTypeList == null ) {
+ simpleTypeList = new ArrayList<String>();
+ simpleTypeList.add("java.lang.String");
+ simpleTypeList.add("boolean");
+ simpleTypeList.add("int");
+ simpleTypeList.add("long");
+ }
+ return simpleTypeList.contains(fullClassName);
+ }
+
+ protected void handleComplexType(WrappedMBeanAttributeInfo info) {
+ // throw up a message box and say no can do, for now
+ MessageBox messageBox = new MessageBox (new Shell(), SWT.OK);
+ messageBox.setText ("Cannot update bean");
+ messageBox.setMessage ("Bean update cannot proceed. Plug-in cannot create
instances of " + info.getInfo().getType() + " at this time.");
+ messageBox.open();
+ return;
+ }
+
+
protected class AttributeViewerContentProvider implements
ITreeContentProvider {
public Object[] getChildren(Object parentElement) {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXPropertySheetPage.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXPropertySheetPage.java 2007-11-05
20:56:12 UTC (rev 4722)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXPropertySheetPage.java 2007-11-05
22:37:26 UTC (rev 4723)
@@ -153,6 +153,7 @@
protected void setInputObject(Object obj) {
if (obj instanceof JMXDomain) {
showDomainComposite((JMXDomain) obj);
+ setBean(null);
} else if (obj instanceof JMXBean) {
setBean((JMXBean) obj);
} else if (obj instanceof JMXAttributesWrapper
@@ -168,9 +169,6 @@
&& bean.getException() == null;
boolean hasError = bean.getOperations() == null
&& bean.getException() != null;
- boolean currentBeanLoading = bean == this.bean
- && pulldown.getItems().length == 1
- && pulldown.getItems()[0].equals(JMXViewProvider.LOADING_STRING_ARRAY[0]);
boolean finishedLoading = bean.getOperations() != null;
this.bean = bean;
@@ -193,6 +191,10 @@
+ bean.getAttributes().length + " attributes)");
}
main.layout();
+ } else {
+ beanLabel.setText("Please select an mbean from the JBoss Servers View");
+ pulldown.setItems(JMXViewProvider.SELECT_MBEAN_ARRAY);
+ pulldown.select(0); // select Loading...
}
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXViewProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXViewProvider.java 2007-11-05
20:56:12 UTC (rev 4722)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/jmx/JMXViewProvider.java 2007-11-05
22:37:26 UTC (rev 4723)
@@ -53,6 +53,7 @@
public class JMXViewProvider extends JBossServerViewExtension {
public static final Object LOADING = new Object();
public static final String[] LOADING_STRING_ARRAY = new String[] {
"Loading..." };
+ public static final String[] SELECT_MBEAN_ARRAY = new String[] { "Please select an
MBean from the JBoss Server's View"};
public static final String ATTRIBUTES_STRING = "Attributes...";
public static final Object CLASSLOADING_TOKEN = new Object();
Show replies by date