Author: rob.stryker(a)jboss.com
Date: 2007-09-18 02:23:07 -0400 (Tue, 18 Sep 2007)
New Revision: 3672
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/JMXViewProvider.java
Log:
Properties page being fleshed out.
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/JMXViewProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/JMXViewProvider.java 2007-09-18
06:21:59 UTC (rev 3671)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/JMXViewProvider.java 2007-09-18
06:23:07 UTC (rev 3672)
@@ -1,112 +1,185 @@
package org.jboss.ide.eclipse.as.ui.views.server.providers;
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.security.Principal;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Set;
+import java.util.ArrayList;
+import java.util.Arrays;
-import javax.management.MBeanServerConnection;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.naming.InitialContext;
-
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.jdt.internal.ui.JavaPluginImages;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
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.ui.IActionBars;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.IServerLifecycleListener;
import org.eclipse.wst.server.core.IServerListener;
import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.ServerEvent;
import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXClassLoaderRepository;
-import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXAttributesWrapper;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXBean;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXDomain;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.JMXException;
+import org.jboss.ide.eclipse.as.core.extensions.jmx.JMXModel.WrappedMBeanOperationInfo;
+import org.jboss.ide.eclipse.as.ui.views.server.JBossServerView;
+import org.jboss.ide.eclipse.as.ui.views.server.ExtensionTableViewer.ContentWrapper;
import org.jboss.ide.eclipse.as.ui.views.server.extensions.JBossServerViewExtension;
import org.jboss.ide.eclipse.as.ui.views.server.extensions.ServerViewProvider;
+import org.jboss.ide.eclipse.as.ui.views.server.util.ViewUtilityMethods;
public class JMXViewProvider extends JBossServerViewExtension {
protected static final Object LOADING = new Object();
-
+ protected static final String[] LOADING_STRING_ARRAY = new String[] {
"Loading..." };
+ protected static final String ATTRIBUTES_STRING = "Attributes...";
+
+ protected JMXPropertySheetPage propertyPage;
protected JMXServerLifecycleListener lcListener;
protected JMXServerListener serverListener;
protected JMXTreeContentProvider contentProvider;
protected JMXLabelProvider labelProvider;
protected IServer server;
protected JMXModel model;
+
public JMXViewProvider() {
model = new JMXModel();
-
+ addListeners();
+ }
+
+ protected void addListeners() {
+ JBossServerView.addExtensionFrameListener(
+ new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ Object o = JBossServerView.getDefault()
+ .getExtensionFrame().getViewer()
+ .getSelectedElement();
+ if (o instanceof JMXBean) {
+ ViewUtilityMethods.activatePropertiesView(null);
+ }
+ }
+ });
+
// make sure we know about server events
serverListener = new JMXServerListener();
lcListener = new JMXServerLifecycleListener();
ServerCore.addServerLifecycleListener(lcListener);
IServer[] servers = ServerCore.getServers();
- for( int i = 0; i < servers.length; i++ ) {
+ for (int i = 0; i < servers.length; i++) {
servers[i].addServerListener(serverListener);
}
+
}
-
- protected class JMXServerLifecycleListener implements IServerLifecycleListener {
+
+ protected class JMXServerLifecycleListener implements
+ IServerLifecycleListener {
public void serverAdded(IServer server) {
server.addServerListener(serverListener);
}
+
public void serverChanged(IServer server) {
}
+
public void serverRemoved(IServer server) {
server.removeServerListener(serverListener);
- JMXClassLoaderRepository.getDefault().
- removeConcerned(server, model);
+ JMXClassLoaderRepository.getDefault()
+ .removeConcerned(server, model);
}
}
-
-
+
protected class JMXServerListener implements IServerListener {
public void serverChanged(ServerEvent event) {
- if((event.getKind() & ServerEvent.SERVER_CHANGE) != 0) {
- if((event.getKind() & ServerEvent.STATE_CHANGE) != 0) {
- if( event.getState() == IServer.STATE_STARTED) {
- JMXClassLoaderRepository.getDefault().
- addConcerned(event.getServer(), model);
+ if ((event.getKind() & ServerEvent.SERVER_CHANGE) != 0) {
+ if ((event.getKind() & ServerEvent.STATE_CHANGE) != 0) {
+ if (event.getState() == IServer.STATE_STARTED) {
+ JMXClassLoaderRepository.getDefault().addConcerned(
+ event.getServer(), model);
} else {
- JMXClassLoaderRepository.getDefault().
- removeConcerned(event.getServer(), model);
+ JMXClassLoaderRepository.getDefault().removeConcerned(
+ event.getServer(), model);
}
}
}
}
}
-
+
+ public IPropertySheetPage getPropertySheetPage() {
+ if (propertyPage == null) {
+ propertyPage = new JMXPropertySheetPage(this);
+ }
+ return propertyPage;
+ }
+
public ITreeContentProvider getContentProvider() {
- if( contentProvider == null )
+ if (contentProvider == null)
contentProvider = new JMXTreeContentProvider();
return contentProvider;
}
+
public LabelProvider getLabelProvider() {
- if( labelProvider == null )
+ if (labelProvider == null)
labelProvider = new JMXLabelProvider();
return labelProvider;
}
-
+
class JMXLabelProvider extends LabelProvider {
public String getText(Object obj) {
- if( obj instanceof JMXDomain )
- return ((JMXDomain)obj).getName();
- if( obj instanceof JMXBean) {
- return ((JMXBean)obj).getName().substring(((JMXBean)obj).getDomain().length()+1);
+ if (obj instanceof JMXDomain)
+ return ((JMXDomain) obj).getName();
+ if (obj instanceof JMXBean) {
+ return ((JMXBean) obj).getName().substring(
+ ((JMXBean) obj).getDomain().length() + 1);
}
- if( obj == LOADING )
+ if (obj instanceof WrappedMBeanOperationInfo) {
+ return ((WrappedMBeanOperationInfo) obj).getInfo().getName();
+ }
+
+ if (obj instanceof JMXException) {
+ String message = "";
+ message += ((JMXException) obj).getException().getClass()
+ .getName()
+ + ": ";
+ message += ((JMXException) obj).getException().getMessage();
+ return message;
+ }
+ if (obj instanceof JMXAttributesWrapper) {
+ return "Attributes";
+ }
+ if (obj == LOADING)
return "loading...";
- return "not sure yet";
+ return "not sure yet: " + obj.getClass().getName();
}
+
public Image getImage(Object obj) {
+ if (obj instanceof JMXException) {
+ return PlatformUI.getWorkbench().getSharedImages().getImage(
+ ISharedImages.IMG_OBJS_ERROR_TSK);
+ }
+ if (obj instanceof WrappedMBeanOperationInfo)
+ return JavaPluginImages.get(JavaPluginImages.IMG_MISC_PUBLIC);
+ if (obj instanceof JMXAttributesWrapper) {
+ return JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PUBLIC);
+ }
+
return null;
}
@@ -115,257 +188,350 @@
public class JMXTreeContentProvider implements ITreeContentProvider {
public Object[] getChildren(Object parentElement) {
- if( parentElement instanceof ServerViewProvider ) {
- if( server == null ) return new Object[]{};
- if( server.getServerState() != IServer.STATE_STARTED ) {
+ if (parentElement instanceof ServerViewProvider) {
+ if (server == null)
+ return new Object[] {};
+ if (server.getServerState() != IServer.STATE_STARTED) {
model.clearModel(server);
- return new Object[]{};
+ return new Object[] {};
}
JMXDomain[] domains = model.getModel(server).getDomains();
- if( domains == null ) {
- loadChildren(parentElement);
- return new Object[]{LOADING};
+ if (domains == null
+ && model.getModel(server).getException() == null) {
+ loadChildrenRefreshViewer(parentElement);
+ return new Object[] { LOADING };
+ } else if (domains == null
+ && model.getModel(server).getException() != null) {
+ return new Object[] { model.getModel(server).getException() };
}
return domains;
}
- if( parentElement instanceof JMXDomain ) {
- JMXBean[] beans = ((JMXDomain)parentElement).getBeans();
- if( beans == null ) {
- loadChildren(parentElement);
- return new Object[]{LOADING};
+ if (parentElement instanceof JMXDomain) {
+ JMXBean[] beans = ((JMXDomain) parentElement).getBeans();
+ if (beans == null
+ && ((JMXDomain) parentElement).getException() == null) {
+ loadChildrenRefreshViewer(parentElement);
+ return new Object[] { LOADING };
+ } else if (beans == null
+ && ((JMXDomain) parentElement).getException() != null) {
+ return new Object[] { ((JMXDomain) parentElement)
+ .getException() };
}
return beans;
}
+ if (parentElement instanceof JMXBean) {
+ WrappedMBeanOperationInfo[] operations = ((JMXBean) parentElement)
+ .getOperations();
+ if (operations == null
+ && ((JMXBean) parentElement).getException() == null) {
+ loadChildrenRefreshViewer(parentElement);
+ return new Object[] { LOADING };
+ } else if (operations == null
+ && ((JMXBean) parentElement).getException() != null) {
+ return new Object[] { ((JMXBean) parentElement)
+ .getException() };
+ }
+ // add the Attributes element
+ ArrayList<Object> list = new ArrayList<Object>();
+ list.add(new JMXAttributesWrapper((JMXBean) parentElement));
+ list.addAll(Arrays.asList(operations));
+ return (Object[]) list.toArray(new Object[list.size()]);
+ }
return new Object[0];
}
+
public Object getParent(Object element) {
return null; // unused
}
+
public boolean hasChildren(Object element) {
+ if (element instanceof ServerViewProvider) {
+ if (server == null
+ || server.getServerState() != IServer.STATE_STARTED) {
+ return false;
+ }
+ return true;
+ }
+ if (element instanceof JMXException)
+ return false;
+ if (element instanceof WrappedMBeanOperationInfo)
+ return false;
+ if (element instanceof JMXAttributesWrapper)
+ return false;
return true; // always true?
}
+
public Object[] getElements(Object inputElement) {
return null; // unused here
}
+
public void dispose() {
}
+
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if( oldInput != newInput ) {
- server = (IServer)newInput;
+ if (oldInput != newInput) {
+ server = (IServer) newInput;
}
}
-
- protected void loadChildren(final Object parent) {
- new Thread() {
- public void run() {
- if( parent instanceof ServerViewProvider )
- model.getModel(server).loadDomains();
- else if( parent instanceof JMXDomain )
- ((JMXDomain)parent).loadBeans();
- else if( parent instanceof JMXBean )
- ((JMXBean)parent).getName(); // temp
-
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- refreshViewer(parent);
- }
- });
- }
- }.start();
- }
-
}
-
-
-
-
-
-
- protected class JMXModel {
- protected HashMap<String, JMXModelRoot> root;
- public JMXModel() {
- root = new HashMap<String, JMXModelRoot>();
- }
- public JMXModelRoot getModel(IServer server) {
- if( root.get(server.getId()) == null ) {
- JMXModelRoot serverRoot = new JMXModelRoot(server);
- root.put(server.getId(), serverRoot);
+
+ protected void loadChildrenRefreshViewer(final Object parent) {
+ new Thread() {
+ public void run() {
+ loadChildren(parent);
+ refreshViewerAsync(parent);
}
- return root.get(server.getId());
+ }.start();
+ }
+
+ protected void loadChildren(Object parent) {
+ if (parent instanceof ServerViewProvider)
+ model.getModel(server).loadDomains();
+ else if (parent instanceof JMXDomain)
+ ((JMXDomain) parent).loadBeans();
+ else if (parent instanceof JMXBean)
+ ((JMXBean) parent).loadInfo();
+ }
+
+ protected void refreshViewerAsync(final Object parent) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ refreshViewer(parent);
+ }
+ });
+ }
+
+ public void refreshModel(Object object) {
+ if( object instanceof ContentWrapper )
+ object = ((ContentWrapper)object).getElement();
+ if (object instanceof ServerViewProvider) {
+ model.clearModel(server);
+ } else if (object instanceof JMXDomain) {
+ ((JMXDomain) object).resetChildren();
+ } else if (object instanceof JMXBean) {
+ ((JMXBean) object).resetChildren();
}
- public void clearModel(IServer server) {
- root.remove(server.getId());
- }
}
- protected static class JMXModelRoot {
- protected IServer server;
- protected JMXDomain[] domains = null;
- public JMXModelRoot(IServer server) {
- this.server = server;
+ public class JMXPropertySheetPage implements IPropertySheetPage {
+
+ // data
+ protected JMXViewProvider provider;
+ protected JMXBean bean;
+ protected WrappedMBeanOperationInfo[] operations;
+
+ // ui pieces
+ protected Composite main;
+ protected Combo pulldown;
+ protected PageBook book;
+ protected ErrorGroup errorGroup;
+ protected OperationGroup operationGroup;
+ protected AttributeGroup attributeGroup;
+
+ public JMXPropertySheetPage(JMXViewProvider provider) {
+ this.provider = provider;
}
- public JMXDomain[] getDomains() {
- return domains;
- }
- protected void loadDomains() {
- JMXRunnable run = new JMXRunnable() {
- public void run(MBeanServerConnection connection) {
- try {
- String[] domainNames = connection.getDomains();
- JMXDomain[] domains = new JMXDomain[domainNames.length];
- for( int i = 0; i < domainNames.length; i++ ) {
- domains[i] = new JMXDomain(server, domainNames[i]);
- }
- JMXModelRoot.this.domains = domains;
- } catch( IOException ioe ) {
- JMXModelRoot.this.domains = new JMXDomain[0];
+
+ public void createControl(Composite parent) {
+ main = new Composite(parent, SWT.NONE);
+ main.setLayout(new FormLayout());
+
+ pulldown = new Combo(main, SWT.READ_ONLY);
+ FormData pulldownData = new FormData();
+ pulldownData.left = new FormAttachment(0, 10);
+ // pulldownData.right = new FormAttachment(0,300);
+ pulldownData.top = new FormAttachment(0, 10);
+ pulldown.setLayoutData(pulldownData);
+
+
+ Listener listener = new Listener() {
+ public void handleEvent(Event event) {
+ switch(event.type) {
+ case SWT.Selection:
+ case SWT.Modify:
+ pulldownSelectionChanged();
+ break;
}
}
};
- JMXSafeRunner.run(server, run);
+ pulldown.addListener(SWT.Selection, listener);
+ pulldown.addListener(SWT.Modify, listener);
+
+ book = new PageBook(main, SWT.NONE);
+ FormData bookData = new FormData();
+ bookData.top = new FormAttachment(pulldown, 10);
+ bookData.left = new FormAttachment(0,5);
+ bookData.right = new FormAttachment(100,-5);
+ bookData.bottom = new FormAttachment(100, -5);
+ book.setLayoutData(bookData);
+
+ errorGroup = new ErrorGroup(book, SWT.NONE);
+ operationGroup = new OperationGroup(book, SWT.NONE);
+ attributeGroup = new AttributeGroup(book, SWT.NONE);
}
- }
-
- protected static class JMXDomain {
- protected String name;
- protected IServer server;
- public JMXBean[] mbeans = null;
- public JMXDomain(IServer server, String name) {
- this.server = server;
- this.name = name;
+
+ public void dispose() {
}
- public String getName() { return name; }
- public JMXBean[] getBeans() {
- return mbeans;
+
+ public Control getControl() {
+ return main;
}
- protected void loadBeans() {
- // etc
- JMXRunnable run = new JMXRunnable() {
- public void run(MBeanServerConnection connection) {
- try {
- String query = name + ":*";
- Set s = connection.queryMBeans(new ObjectName(name + ":*"), null);
- Iterator i = s.iterator();
- JMXBean[] beans = new JMXBean[s.size()];
- int count = 0;
- while(i.hasNext()) {
- ObjectInstance tmp = (ObjectInstance)i.next();
- beans[count++] = new JMXBean(server, tmp);
- }
- mbeans = beans;
- } catch( MalformedObjectNameException mone) {
- } catch (IOException e) {
- }
- }
- };
- JMXSafeRunner.run(server, run);
+
+ public void setActionBars(IActionBars actionBars) {
}
- }
-
- protected static class JMXBean {
- protected String domain;
- protected String name;
- protected String clazz;
- protected IServer server;
- public JMXBean(IServer server, ObjectInstance instance) {
- this.server = server;
- this.domain = instance.getObjectName().getDomain();
- this.clazz = instance.getClassName();
- this.name = instance.getObjectName().getCanonicalName();
+
+ public void setFocus() {
}
- public String getDomain() {
- return domain;
+
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ Object obj = ((IStructuredSelection) selection)
+ .getFirstElement();
+ if (obj instanceof ContentWrapper)
+ obj = ((ContentWrapper) obj).getElement();
+
+ if (obj == null)
+ return;
+ setInputObject(obj);
+ }
}
- public String getName() {
- return name;
+
+ protected void setInputObject(Object obj) {
+ if (obj instanceof JMXDomain) {
+ showDomainComposite((JMXDomain) obj);
+ } else if (obj instanceof JMXBean) {
+ setBean((JMXBean) obj);
+ } else if (obj instanceof JMXAttributesWrapper
+ || obj instanceof WrappedMBeanOperationInfo) {
+ setBean(getBeanFromInput(obj));
+ setComboSelectionFromInput(obj);
+ }
}
- public String getClazz() {
- return clazz;
+
+ protected void setBean(JMXBean bean) {
+ if (bean != null ) {
+ boolean requiresLoading = bean.getOperations() == null && bean.getException()
== null;
+ boolean hasError = bean.getOperations() == null && bean.getException() !=
null;
+ boolean currentBeanLoading = bean == this.bean && pulldown.getItems().length
== 1 && pulldown.getItems()[0].equals(LOADING_STRING_ARRAY[0]);
+ boolean finishedLoading = bean.getOperations() != null;
+
+ this.bean = bean;
+ if( requiresLoading ) {
+ pulldown.setItems(LOADING_STRING_ARRAY);
+ pulldown.select(0); // select Loading...
+ loadChildrenRefreshProperties(bean);
+ } else if( hasError ) {
+ // some error
+ showErrorComposite();
+ } else if( finishedLoading ) {
+ // finished loading
+ operations = bean.getOperations();
+ pulldown.setItems(pulldownItems());
+ pulldown.select(0); // select Loading...
+ }
+ main.layout();
+ }
}
- public IServer getServer() {
- return server;
+
+ protected JMXBean getBeanFromInput(Object obj) {
+ return obj instanceof JMXAttributesWrapper ?
+ ((JMXAttributesWrapper) obj).getBean() :
+ ((WrappedMBeanOperationInfo) obj).getBean();
}
-
- }
- protected interface JMXRunnable {
- public void run(MBeanServerConnection connection);
- }
- protected static class JMXSafeRunner {
- public static void run(IServer s, JMXRunnable r) {
- ClassLoader currentLoader = Thread.currentThread().getContextClassLoader();
- ClassLoader newLoader = JMXClassLoaderRepository.getDefault().getClassLoader(s);
- Thread.currentThread().setContextClassLoader(newLoader);
- InitialContext ic = null;
- try {
- setCredentials(s);
- Properties p = getProperties(s);
- ic = new InitialContext(p);
- Object obj = ic.lookup("jmx/invoker/RMIAdaptor");
- ic.close();
- if (obj instanceof MBeanServerConnection) {
- MBeanServerConnection connection = (MBeanServerConnection) obj;
- r.run(connection);
+ protected void setComboSelectionFromInput(Object obj) {
+ int index = -1;
+ if (obj instanceof WrappedMBeanOperationInfo)
+ index = pulldown
+ .indexOf(getStringForOperation(((WrappedMBeanOperationInfo) obj)));
+ if (index == -1)
+ index = 0;
+ pulldown.select(index);
+ }
+
+ // get the list of combo items based on the bean
+ // The list should be Two larger than the number of operations
+ // ex: {Attributes..., ------, op1, op2, op3... etc}
+ protected String[] pulldownItems() {
+ WrappedMBeanOperationInfo[] ops = bean.getOperations();
+ String[] vals = null;
+ if (ops != null) {
+ if( ops.length == 0 ) return new String[]{ATTRIBUTES_STRING};
+ vals = new String[ops.length + 2];
+ vals[0] = ATTRIBUTES_STRING;
+ vals[1] = "---------------";
+ for (int i = 0; i < ops.length; i++) {
+ vals[i + 2] = getStringForOperation(ops[i]);
}
- } catch( Exception e ) {
}
- Thread.currentThread().setContextClassLoader(currentLoader);
+ return vals;
}
- protected static Properties getProperties(IServer s) {
- int port = ServerConverter.getJBossServer(s).getJNDIPort();
- Properties props = new Properties();
- props.put("java.naming.factory.initial",
- "org.jnp.interfaces.NamingContextFactory");
- props.put("java.naming.factory.url.pkgs",
- "org.jboss.naming:org.jnp.interfaces");
- props.put("java.naming.provider.url", "jnp://"
- + s.getHost() + ":" + port);
- return props;
+ protected String getStringForOperation(WrappedMBeanOperationInfo op) {
+ return op.getInfo().getReturnType() + " " + op.getInfo().getName();
}
+
+ protected void loadChildrenRefreshProperties(final Object bean) {
+ new Thread() {
+ public void run() {
+ loadChildren(bean);
+ Display.getDefault().asyncExec(new Runnable() { public void run() {
+ setInputObject(bean);
+ }});
+ }
+ }.start();
+ }
- protected static void setCredentials(IServer s) {
- Exception temp = null;
- try {
- ILaunchConfiguration lc = s.getLaunchConfiguration(true,
- new NullProgressMonitor());
- // get user from the IServer, but override with launch
- // configuration
- String user = ServerConverter.getJBossServer(s).getUsername();
-
- // get password from the IServer, but override with launch
- // configuration
- String pass = ServerConverter.getJBossServer(s).getPassword();
-
- // get our methods
- Class simplePrincipal = Thread.currentThread()
- .getContextClassLoader().loadClass(
- "org.jboss.security.SimplePrincipal");
- Class securityAssoc = Thread.currentThread()
- .getContextClassLoader().loadClass(
- "org.jboss.security.SecurityAssociation");
- securityAssoc.getMethods(); // force-init the methods since the
- // class hasn't been initialized yet.
+ protected void showDomainComposite(JMXDomain domain) {
+ // nothing
+ }
+ protected void showErrorComposite() {
+ book.showPage(errorGroup);
+ }
+
+ protected void pulldownSelectionChanged() {
+ if( pulldown.getSelectionIndex() != -1 ) {
+ int index = pulldown.getSelectionIndex();
+ if( index == 0 && pulldown.getItem(0).equals(ATTRIBUTES_STRING)) {
+ book.showPage(attributeGroup);
+ } else if( index != 1 && index <= operations.length) {
+ book.showPage(operationGroup);
+ }
+ String selected = pulldown.getItem(pulldown.getSelectionIndex());
+ System.out.println(selected);
+ }
+ }
- Constructor newSimplePrincipal = simplePrincipal
- .getConstructor(new Class[] { String.class });
- Object newPrincipalInstance = newSimplePrincipal
- .newInstance(new Object[] { user });
+ }
+
+ protected static class ErrorGroup extends Composite {
+ protected Group group;
+ public ErrorGroup(Composite parent, int style) {
+ super(parent, style);
+ setLayout(new FillLayout());
+ group = new Group(this, SWT.NONE);
+ group.setText("Error");
+ }
+ }
- // set the principal
- Method setPrincipalMethod = securityAssoc.getMethod(
- "setPrincipal", new Class[] { Principal.class });
- setPrincipalMethod.invoke(null,
- new Object[] { newPrincipalInstance });
+ protected static class OperationGroup extends Composite {
+ protected Group group;
+ public OperationGroup(Composite parent, int style) {
+ super(parent, style);
+ setLayout(new FillLayout());
+ group = new Group(this, SWT.NONE);
+ group.setText("Operation");
+ }
+ }
- // set the credential
- Method setCredentialMethod = securityAssoc.getMethod(
- "setCredential", new Class[] { Object.class });
- setCredentialMethod.invoke(null, new Object[] { pass });
- } catch (Exception e) {}
+ protected static class AttributeGroup extends Composite {
+ protected Group group;
+ public AttributeGroup(Composite parent, int style) {
+ super(parent, style);
+ setLayout(new FillLayout());
+ group = new Group(this, SWT.NONE);
+ group.setText("Attributes");
}
+ }
-
- }
-
}