Author: rob.stryker(a)jboss.com
Date: 2009-02-05 03:30:56 -0500 (Thu, 05 Feb 2009)
New Revision: 13481
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/AttributeDetails.java
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/OperationDetails.java
Log:
JBIDE-3277 - operation / attribute changes in JMX now launch in new thread and async
update the UI
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/AttributeDetails.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/AttributeDetails.java 2009-02-05
05:07:00 UTC (rev 13480)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/AttributeDetails.java 2009-02-05
08:30:56 UTC (rev 13481)
@@ -18,12 +18,9 @@
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanServerConnection;
-
-import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
@@ -31,6 +28,7 @@
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.AbstractFormPart;
@@ -41,7 +39,6 @@
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
import org.jboss.tools.jmx.core.MBeanAttributeInfoWrapper;
-import org.jboss.tools.jmx.ui.JMXUIActivator;
import org.jboss.tools.jmx.ui.Messages;
import org.jboss.tools.jmx.ui.extensions.IWritableAttributeHandler;
import org.jboss.tools.jmx.ui.internal.JMXImages;
@@ -67,19 +64,27 @@
private MBeanAttributeInfoWrapper wrapper;
private final IWritableAttributeHandler updateAttributeHandler = new
IWritableAttributeHandler() {
- public void write(Object newValue) {
- try {
- MBeanServerConnection mbsc = wrapper.getMBeanServerConnection();
- String attrName = wrapper.getMBeanAttributeInfo().getName();
- Attribute attr = new Attribute(attrName, newValue);
- mbsc.setAttribute(wrapper.getObjectName(), attr);
- masterSection.refresh();
- } catch (Exception e) {
- MessageDialog.openError(getManagedForm().getForm().getDisplay()
- .getActiveShell(),
- Messages.AttributeDetailsSection_errorTitle, e
- .getLocalizedMessage());
- }
+ public void write(final Object newValue) {
+ new Thread() {
+ public void run() {
+ try {
+ MBeanServerConnection mbsc = wrapper.getMBeanServerConnection();
+ String attrName = wrapper.getMBeanAttributeInfo().getName();
+ Attribute attr = new Attribute(attrName, newValue);
+ mbsc.setAttribute(wrapper.getObjectName(), attr);
+ Display.getDefault().asyncExec(new Runnable() { public void run() {
+ masterSection.refresh();
+ }});
+ } catch (final Exception e) {
+ Display.getDefault().asyncExec(new Runnable() { public void run() {
+ MessageDialog.openError(getManagedForm().getForm().getDisplay()
+ .getActiveShell(),
+ Messages.AttributeDetailsSection_errorTitle, e
+ .getLocalizedMessage());
+ }});
+ }
+ }
+ }.start();
}
};
Modified:
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/OperationDetails.java
===================================================================
---
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/OperationDetails.java 2009-02-05
05:07:00 UTC (rev 13480)
+++
trunk/jmx/plugins/org.jboss.tools.jmx.ui/src/org/jboss/tools/jmx/ui/internal/editors/OperationDetails.java 2009-02-05
08:30:56 UTC (rev 13481)
@@ -13,7 +13,6 @@
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
-
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
@@ -26,6 +25,7 @@
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.AbstractFormPart;
@@ -185,16 +185,26 @@
}
@Override
- public void widgetSelected(SelectionEvent event) {
+ public void widgetSelected(final SelectionEvent event) {
+ final String[] strs = textParams == null ? null : new
String[textParams.length];
+ if (textParams != null) {
+ for (int i = 0; i < strs.length; i++) {
+ strs[i] = textParams[i].getText();
+ }
+ }
+ new Thread() {
+ public void run() {
+ widgetSelected2(strs);
+ }
+ }.start();
+ }
+
+ protected void widgetSelected2(String[] strs) {
try {
MBeanParameterInfo[] paramInfos = opInfoWrapper
.getMBeanOperationInfo().getSignature();
Object[] paramList = null;
if (textParams != null) {
- String[] strs = new String[textParams.length];
- for (int i = 0; i < strs.length; i++) {
- strs[i] = textParams[i].getText();
- }
paramList = MBeanUtils.getParameters(strs, paramInfos);
}
MBeanServerConnection mbsc = opInfoWrapper
@@ -216,12 +226,17 @@
}
if ("void".equals(opInfoWrapper.getMBeanOperationInfo()
//$NON-NLS-1$
.getReturnType())) {
- MessageDialog.openInformation(container.getShell(),
- Messages.OperationDetails_invocationResult,
- Messages.OperationDetails_invocationSuccess);
+ Display.getDefault().asyncExec(new Runnable() { public void run() {
+ MessageDialog.openInformation(container.getShell(),
+ Messages.OperationDetails_invocationResult,
+ Messages.OperationDetails_invocationSuccess);
+ }});
return;
} else {
- OperationInvocationResultDialog.open(container.getShell(), result);
+ final Object result2 = result;
+ Display.getDefault().asyncExec(new Runnable() { public void run() {
+ OperationInvocationResultDialog.open(container.getShell(), result2);
+ }});
}
} catch (Exception e) {
String message = e.getClass().getName() + ": " +
e.getLocalizedMessage();
@@ -234,8 +249,11 @@
if (e.getCause() != null) {
message = e.getCause().getClass().getName() + ": " +
e.getCause().getLocalizedMessage();
}
- MessageDialog.openError(container.getShell(),
- Messages.OperationDetails_invocationError, message);
+ final String message2 = message;
+ Display.getDefault().asyncExec(new Runnable() { public void run() {
+ MessageDialog.openError(container.getShell(),
+ Messages.OperationDetails_invocationError, message2);
+ }});
}
}
}
Show replies by date