[Mc4j-cvs] mc4j/src/org/mc4j/console/bean/operation OperationExecuteNodeAction.java,1.9,1.10 Operati
Brought to you by:
ghinkl
From: Greg H. <gh...@us...> - 2006-04-12 19:14:39
|
Update of /cvsroot/mc4j/mc4j/src/org/mc4j/console/bean/operation In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20162/src/org/mc4j/console/bean/operation Modified Files: OperationExecuteNodeAction.java OperationSetChildren.java OperationExecutionResultsVisualPanel.java OperationExecutionVisualPanel.java OperationNode.java OperationExecuteDescriptor.java OperationSetNode.java Log Message: Merging EMS into head for the 2.0 release work Index: OperationExecuteNodeAction.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/bean/operation/OperationExecuteNodeAction.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** OperationExecuteNodeAction.java 5 Oct 2004 05:15:56 -0000 1.9 --- OperationExecuteNodeAction.java 12 Apr 2006 19:13:58 -0000 1.10 *************** *** 17,24 **** package org.mc4j.console.bean.operation; ! import java.awt.Dialog; ! ! import javax.swing.SwingUtilities; ! import org.openide.DialogDisplayer; import org.openide.ErrorManager; --- 17,21 ---- package org.mc4j.console.bean.operation; ! import org.mc4j.ems.connection.bean.operation.EmsOperation; import org.openide.DialogDisplayer; import org.openide.ErrorManager; *************** *** 29,32 **** --- 26,32 ---- import org.openide.util.actions.NodeAction; + import javax.swing.*; + import java.awt.Dialog; + /** * This action is used to execute MBean Operations against a *************** *** 39,56 **** public void performAction(Node[] nodes) { - // do work based on the current node selection, e.g.: OperationNode node = (OperationNode)nodes[0]; - // ... - // Note that casting to a type of node is often not the right - // solution; try using a CookieAction, unless it is really the - // node itself and not the underlying data that needs to be - // considered. Also remember that some tests on nodes (casts - // as well as reorderability of children etc.) will not work - // when applied to filter nodes, whereas cookies will. ! final WizardDescriptor desc = new OperationExecuteDescriptor(node.getServer(),node.getObjectName(),node.getOperationInfo()); final Dialog dlg = DialogDisplayer.getDefault().createDialog(desc); dlg.setSize(650, 600); ! // The following assumes the wizard descriptor is modal: try { --- 39,54 ---- public void performAction(Node[] nodes) { OperationNode node = (OperationNode)nodes[0]; ! performAction(node.getEmsOperation()); ! } ! ! ! public void performAction(EmsOperation operation) { ! ! final WizardDescriptor desc = new OperationExecuteDescriptor(operation); final Dialog dlg = DialogDisplayer.getDefault().createDialog(desc); dlg.setSize(650, 600); ! // The following assumes the wizard descriptor is modal: try { *************** *** 65,88 **** } if (desc.getValue() == WizardDescriptor.FINISH_OPTION) { - // Do whatever it is you want to do here. - /* - MBeanOperationInfo operationInfo = node.getOperationInfo(); - if (operationInfo.getSignature().length == 0) { - try { - - Object result = node.getServer().invoke( - node.getObjectName(), - operationInfo.getName(), - new Object[] {}, - new String[] {}); - org.openide.windows.IOProvider.getDefault().getStdOut().println("Executed operation " + - operationInfo.getName() + " on managed bean " + node.getObjectName().getCanonicalName()); - org.openide.windows.IOProvider.getDefault().getStdOut().println("Results " + result); - } catch (Exception e) { - ErrorManager.getDefault().notify(e); - } - - } - */ System.out.println("User finished the wizard"); // NOI18N --- 63,66 ---- *************** *** 90,95 **** System.out.println("User closed or cancelled the wizard"); // NOI18N } - - } --- 68,71 ---- Index: OperationNode.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/bean/operation/OperationNode.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** OperationNode.java 5 Oct 2004 05:15:56 -0000 1.8 --- OperationNode.java 12 Apr 2006 19:13:58 -0000 1.9 *************** *** 17,119 **** package org.mc4j.console.bean.operation; ! import javax.management.MBeanOperationInfo; ! import javax.management.MBeanParameterInfo; ! import javax.management.MBeanServer; ! import javax.management.ObjectInstance; ! import javax.management.ObjectName; ! import org.openide.actions.PropertiesAction; import org.openide.actions.ToolsAction; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; import org.openide.util.HelpCtx; import org.openide.util.actions.SystemAction; /** - * * @author Greg Hinkle (gh...@us...), January 2002 * @version $Revision$($Author$ / $Date$) */ ! public class OperationNode extends AbstractNode { ! ! protected MBeanServer server; ! protected ObjectInstance objectInstance; ! protected ObjectName objectName; ! protected MBeanOperationInfo operationInfo; - /** - * @deprecated just pass object name - * @param server - * @param objectInstance - * @param operationInfo - */ - public OperationNode(MBeanServer server, ObjectInstance objectInstance, MBeanOperationInfo operationInfo) { - this(server, objectInstance.getObjectName(), operationInfo); - } ! public OperationNode(MBeanServer server, ObjectName objectName, MBeanOperationInfo operationInfo) { super(Children.LEAF); ! this.server = server; ! this.operationInfo = operationInfo; ! this.objectName = objectName; ! setIconBase("org/mc4j/console/bean/operation/OperationNodeIcon"); // Set FeatureDescriptor stuff: ! setName(this.operationInfo.getName()); ! setDisplayName(this.operationInfo.getName()); ! setShortDescription(getDescription()); setDefaultAction(SystemAction.get(OperationExecuteNodeAction.class)); - - } - - private String getDescription() { - StringBuffer buf = new StringBuffer(100); - buf.append("<html><b>"); - buf.append(this.operationInfo.getName()); - buf.append("</b><br>"); - buf.append("Description: "); - buf.append(this.operationInfo.getDescription()); - - if (this.operationInfo.getSignature().length > 0) { - buf.append("<br>Parameters:<br>"); - MBeanParameterInfo[] params = this.operationInfo.getSignature(); - for (int i = 0; i < params.length; i++) { - MBeanParameterInfo param = params[i]; - buf.append(" "); - buf.append(param.getName()); - buf.append(" - "); - buf.append(param.getType()); - buf.append("<br>"); - } - } - buf.append("Return Type: "); - buf.append(this.operationInfo.getReturnType()); - buf.append("</html>"); - return buf.toString(); } // Create the popup menu: protected SystemAction[] createActions() { ! return new SystemAction[] { ! // SystemAction.get(MyFavoriteAction.class), ! // null, // separator ! /* according to what it can do: ! SystemAction.get(CutAction.class), ! SystemAction.get(CopyAction.class), ! null, ! SystemAction.get(DeleteAction.class), ! SystemAction.get(RenameAction.class), ! null, ! */ ! SystemAction.get(OperationExecuteNodeAction.class), null, ! SystemAction.get(ToolsAction.class), null, ! SystemAction.get(PropertiesAction.class), }; } --- 17,64 ---- package org.mc4j.console.bean.operation; ! import org.mc4j.ems.connection.bean.operation.EmsOperation; import org.openide.actions.PropertiesAction; import org.openide.actions.ToolsAction; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; + import org.openide.nodes.Node; import org.openide.util.HelpCtx; import org.openide.util.actions.SystemAction; /** * @author Greg Hinkle (gh...@us...), January 2002 * @version $Revision$($Author$ / $Date$) */ ! public class OperationNode extends AbstractNode implements Comparable { ! protected EmsOperation operation; ! public OperationNode(EmsOperation operation) { super(Children.LEAF); ! this.operation = operation; setIconBase("org/mc4j/console/bean/operation/OperationNodeIcon"); // Set FeatureDescriptor stuff: ! setName(this.operation.getName()); ! setDisplayName(this.operation.getName()); ! setShortDescription(this.operation.getDescription()); setDefaultAction(SystemAction.get(OperationExecuteNodeAction.class)); } + public EmsOperation getEmsOperation() { + return operation; + } // Create the popup menu: protected SystemAction[] createActions() { ! return new SystemAction[]{ ! SystemAction.get(OperationExecuteNodeAction.class), null, ! SystemAction.get(ToolsAction.class), null, ! SystemAction.get(PropertiesAction.class), }; } *************** *** 127,253 **** ! /** Getter for property server. ! * @return Value of property server. ! * ! */ ! public javax.management.MBeanServer getServer() { ! return server; ! } ! ! /** Setter for property server. ! * @param server New value of property server. ! * ! */ ! public void setServer(javax.management.MBeanServer server) { ! this.server = server; ! } ! ! /** Getter for property objectName. ! * @return Value of property objectName. ! * ! */ ! public javax.management.ObjectName getObjectName() { ! return objectName; ! } ! ! ! /** Getter for property operationInfo. ! * @return Value of property operationInfo. ! * ! */ ! public javax.management.MBeanOperationInfo getOperationInfo() { ! return operationInfo; ! } ! ! ! // RECOMMENDED - handle cloning specially (so as not to invoke the overhead of FilterNode): ! /* ! public Node cloneNode() { ! // Try to pass in similar constructor params to what you originally got: ! return new OperationNode(); ! } ! */ ! ! // Create a property sheet: ! /* ! protected Sheet createSheet() { ! Sheet sheet = super.createSheet(); ! // Make sure there is a "Properties" set: ! Sheet.Set props = sheet.get(Sheet.PROPERTIES); // get by name, not display name ! if (props == null) { ! props = Sheet.createPropertiesSet(); ! sheet.put(props); ! } ! props.put(new MyProp(someParams)); ! return sheet; ! } ! */ ! ! // Handle renaming: ! /* ! public boolean canRename() { ! return true; ! } ! public void setName(String nue) { ! // Update visible name, fire property changes: ! super.setName(nue); ! // perform additional actions, i.e. rename underlying object ! } ! */ ! ! // Handle deleting: ! /* ! public boolean canDestroy() { ! return true; ! } ! public void destroy() throws IOException { ! // Actually remove the node itself and fire property changes: ! super.destroy(); ! // perform additional actions, i.e. delete underlying object ! } ! */ ! ! // Handle copying and cutting specially: ! /* ! public boolean canCopy() { ! return true; ! } ! public boolean canCut() { ! return true; ! } ! public Transferable clipboardCopy() { ! // Add to, do not replace, the default node copy flavor: ! ExTransferable et = ExTransferable.create(super.clipboardCopy()); ! et.put(new ExTransferable.Single(DataFlavor.stringFlavor) { ! protected Object getData() { ! return OperationNode.this.getDisplayName(); ! } ! }); ! return et; ! } ! public Transferable clipboardCut() { ! // Add to, do not replace, the default node cut flavor: ! ExTransferable et = ExTransferable.create(super.clipboardCut()); ! // This is not so useful because this node will not be destroyed afterwards ! // (it is up to the paste type to decide whether to remove the "original", ! // and it is not safe to assume that getData will only be called once): ! et.put(new ExTransferable.Single(DataFlavor.stringFlavor) { ! protected Object getData() { ! return OperationNode.this.getDisplayName(); ! } ! }); ! return et; ! } ! */ ! ! // Permit user to customize whole node at once (instead of per-property): ! /* ! public boolean hasCustomizer() { ! return true; ! } ! public Component getCustomizer() { ! return new MyCustomizingPanel(this); } - */ } --- 72,79 ---- ! public int compareTo(Object o) { ! Node otherNode = (Node) o; ! return this.getDisplayName().compareTo(otherNode.getDisplayName()); } } Index: OperationExecuteDescriptor.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/bean/operation/OperationExecuteDescriptor.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** OperationExecuteDescriptor.java 5 Oct 2004 05:15:56 -0000 1.7 --- OperationExecuteDescriptor.java 12 Apr 2006 19:13:58 -0000 1.8 *************** *** 17,31 **** package org.mc4j.console.bean.operation; ! import java.awt.Toolkit; ! import java.net.MalformedURLException; ! import java.net.URL; ! ! import javax.management.MBeanOperationInfo; ! import javax.management.MBeanServer; ! import javax.management.ObjectName; ! import org.openide.WizardDescriptor; import org.openide.util.NbBundle; /** * --- 17,28 ---- package org.mc4j.console.bean.operation; ! import org.mc4j.ems.connection.bean.operation.EmsOperation; import org.openide.WizardDescriptor; import org.openide.util.NbBundle; + import java.awt.*; + import java.net.MalformedURLException; + import java.net.URL; + /** * *************** *** 38,63 **** private final OperationExecuteIterator iterator; ! ! public static final String MBEAN_SERVER = "MBeanServer"; ! public static final String OBJECT_NAME = "ObjectName"; ! public static final String OPERATION_INFO = "OperationInfo"; public static final String PARAMETER_VALUES = "ParameterValues"; /** Make a descriptor suited to use OperationExecuteIterator. * Sets up various wizard properties to follow recommended * style guidelines. */ ! public OperationExecuteDescriptor(MBeanServer server, ObjectName objectName, MBeanOperationInfo operationInfo) { this(new OperationExecuteIterator()); ! ! putProperty(MBEAN_SERVER, server); ! putProperty(OBJECT_NAME, objectName); ! putProperty(OPERATION_INFO, operationInfo); } ! private OperationExecuteDescriptor(OperationExecuteIterator iterator) { super(iterator); this.iterator = iterator; ! this.iterator.setExecuteDescriptor(this); // Set title for the dialog: --- 35,57 ---- private final OperationExecuteIterator iterator; ! ! public static final String OPERATION = "Operation"; public static final String PARAMETER_VALUES = "ParameterValues"; + /** Make a descriptor suited to use OperationExecuteIterator. * Sets up various wizard properties to follow recommended * style guidelines. */ ! public OperationExecuteDescriptor(EmsOperation operation) { this(new OperationExecuteIterator()); ! ! putProperty(OPERATION, operation); } ! private OperationExecuteDescriptor(OperationExecuteIterator iterator) { super(iterator); this.iterator = iterator; ! this.iterator.setExecuteDescriptor(this); // Set title for the dialog: *************** *** 79,83 **** putProperty("WizardPanel_leftDimension", new Dimension(100, 400)); // NOI18N */ ! // Optional: if you want a special background image for the left pane: try { --- 73,77 ---- putProperty("WizardPanel_leftDimension", new Dimension(100, 400)); // NOI18N */ ! // Optional: if you want a special background image for the left pane: try { *************** *** 88,92 **** throw new IllegalStateException(mfue.toString()); } ! } --- 82,86 ---- throw new IllegalStateException(mfue.toString()); } ! } Index: OperationExecutionVisualPanel.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/bean/operation/OperationExecutionVisualPanel.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** OperationExecutionVisualPanel.java 5 Oct 2004 05:15:56 -0000 1.7 --- OperationExecutionVisualPanel.java 12 Apr 2006 19:13:58 -0000 1.8 *************** *** 17,33 **** package org.mc4j.console.bean.operation; ! import java.awt.BorderLayout; ! import java.awt.Color; ! import java.awt.Dimension; ! import java.util.Map; ! ! import javax.management.MBeanOperationInfo; ! import javax.management.ObjectName; ! import javax.swing.BorderFactory; ! import javax.swing.JEditorPane; ! import javax.swing.JPanel; ! import javax.swing.JScrollPane; ! import javax.swing.UIManager; ! import org.openide.ErrorManager; import org.openide.explorer.propertysheet.PropertySheet; --- 17,22 ---- package org.mc4j.console.bean.operation; ! import org.mc4j.console.bean.operation.execution.ExecutionNode; ! import org.mc4j.ems.connection.bean.operation.EmsOperation; import org.openide.ErrorManager; import org.openide.explorer.propertysheet.PropertySheet; *************** *** 35,42 **** import org.openide.util.NbBundle; ! import org.mc4j.console.bean.operation.execution.ExecutionNode; /** - * * @author Greg Hinkle (gh...@us...), January 2002 * @version $Revision$($Author$ / $Date$) --- 24,32 ---- import org.openide.util.NbBundle; ! import javax.swing.*; ! import java.awt.*; ! import java.util.Map; /** * @author Greg Hinkle (gh...@us...), January 2002 * @version $Revision$($Author$ / $Date$) *************** *** 44,56 **** public class OperationExecutionVisualPanel extends javax.swing.JPanel { ! /** The wizard panel descriptor associated with this GUI panel. * If you need to fire state changes or something similar, you can * use this handle to do so. */ private final OperationExecutionPanel panel; ! private ExecutionNode executionNode; ! /** Create the wizard panel and set up some basic properties. */ public OperationExecutionVisualPanel(OperationExecutionPanel panel) { this.panel = panel; --- 34,49 ---- public class OperationExecutionVisualPanel extends javax.swing.JPanel { ! /** ! * The wizard panel descriptor associated with this GUI panel. * If you need to fire state changes or something similar, you can * use this handle to do so. */ private final OperationExecutionPanel panel; ! private ExecutionNode executionNode; ! /** ! * Create the wizard panel and set up some basic properties. ! */ public OperationExecutionVisualPanel(OperationExecutionPanel panel) { this.panel = panel; *************** *** 58,130 **** // Provide a name in the title bar. setName(NbBundle.getMessage(OperationExecutionVisualPanel.class, "TITLE_WizardPanel")); - - ! MBeanOperationInfo operationInfo = ! (MBeanOperationInfo) ! this.panel.getDescriptor().getProperty(OperationExecuteDescriptor.OPERATION_INFO); ! ObjectName objectName = ! (ObjectName) ! this.panel.getDescriptor().getProperty(OperationExecuteDescriptor.OBJECT_NAME); ! ! PropertySheet sheet = new PropertySheet(); - this.executionNode = new ExecutionNode(operationInfo); try { ! sheet.setNodes(new Node[] { ! executionNode ! }); ! } catch (Exception e) { ErrorManager.getDefault().notify(e); } ! JPanel topPanel = new JPanel(new BorderLayout()); topPanel.setBorder(BorderFactory.createCompoundBorder( ! BorderFactory.createMatteBorder(1,0,0,0,UIManager.getDefaults().getColor("control")), // NOI18N ! BorderFactory.createCompoundBorder( ! BorderFactory.createMatteBorder(0,0,1,1,UIManager.getDefaults().getColor("controlHighlight")), // NOI18N ! BorderFactory.createLineBorder(UIManager.getDefaults().getColor("controlDkShadow")) // NOI18N ! )) ); ! ! String info = ! "<font size='-1'><b>MBean: </b>" + objectName.getCanonicalName() + "<br>" + ! "<b>Operation: </b>" + operationInfo.getName() + "<br>" + ! "<b>Impact: </b>"; ! switch (operationInfo.getImpact()) { ! case MBeanOperationInfo.ACTION: ! info += "This operation alters the state of this component.<br>"; ! break; ! case MBeanOperationInfo.ACTION_INFO: ! info += "This operation alters the state of this component and returns information.<br>"; ! break; ! case MBeanOperationInfo.INFO: ! info += "This operation merly returns information.<br>"; ! break; ! case MBeanOperationInfo.UNKNOWN: ! info += "unknown<br>"; ! break; } ! info += "<b>Return Type: </b> " + operationInfo.getReturnType() + "<br>"; info += "<b>Description: </b><br>"; ! info += "<blockquote>" + operationInfo.getDescription() + "</blockquote></font>"; ! ! JEditorPane jta = new JEditorPane("text/html", info); jta.setBackground(Color.lightGray); jta.setEditable(false); jta.setPreferredSize(new Dimension(0, 150)); ! JScrollPane topPanelScrollPane = new JScrollPane(); topPanelScrollPane.setViewportView(jta); ! topPanel.add(topPanelScrollPane, BorderLayout.CENTER); add(topPanel, BorderLayout.NORTH); ! add(sheet, BorderLayout.CENTER); ! repaint(); ! } --- 51,115 ---- // Provide a name in the title bar. setName(NbBundle.getMessage(OperationExecutionVisualPanel.class, "TITLE_WizardPanel")); ! EmsOperation operation = ! (EmsOperation) this.panel.getDescriptor().getProperty(OperationExecuteDescriptor.OPERATION); + PropertySheet sheet = new PropertySheet(); + + this.executionNode = new ExecutionNode(operation); try { ! sheet.setNodes(new Node[]{ ! executionNode ! }); ! } catch (Exception e) { ! ErrorManager.getDefault().notify(e); ! } ! JPanel topPanel = new JPanel(new BorderLayout()); topPanel.setBorder(BorderFactory.createCompoundBorder( ! BorderFactory.createMatteBorder(1, 0, 0, 0, UIManager.getDefaults().getColor("control")), // NOI18N ! BorderFactory.createCompoundBorder( ! BorderFactory.createMatteBorder(0, 0, 1, 1, UIManager.getDefaults().getColor("controlHighlight")), // NOI18N ! BorderFactory.createLineBorder(UIManager.getDefaults().getColor("controlDkShadow")) // NOI18N ! )) ); ! ! String info = ! "<font size='-1'><b>MBean: </b>" + operation + "<br>" + ! "<b>Operation: </b>" + operation.getName() + "<br>" + ! "<b>Impact: </b>"; ! if (EmsOperation.Impact.ACTION.equals(operation.getImpact())) { ! info += "This operation alters the state of this component.<br>"; ! } else if (EmsOperation.Impact.ACTION_INFO.equals(operation.getImpact())) { ! info += "This operation alters the state of this component and returns information.<br>"; ! } else if (EmsOperation.Impact.ACTION.equals(operation.getImpact())) { ! info += "This operation merly returns information.<br>"; ! } else { ! info += "unknown<br>"; } ! ! info += "<b>Return Type: </b> " + operation.getReturnType() + "<br>"; info += "<b>Description: </b><br>"; ! info += "<blockquote>" + operation.getDescription() + "</blockquote></font>"; ! ! JEditorPane jta = new JEditorPane("text/html", info); jta.setBackground(Color.lightGray); jta.setEditable(false); jta.setPreferredSize(new Dimension(0, 150)); ! JScrollPane topPanelScrollPane = new JScrollPane(); topPanelScrollPane.setViewportView(jta); ! topPanel.add(topPanelScrollPane, BorderLayout.CENTER); add(topPanel, BorderLayout.NORTH); ! add(sheet, BorderLayout.CENTER); ! repaint(); ! } *************** *** 132,138 **** return this.executionNode.getParameterValues(); } ! ! ! /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is --- 117,124 ---- return this.executionNode.getParameterValues(); } ! ! ! /** ! * This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is Index: OperationExecutionResultsVisualPanel.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/bean/operation/OperationExecutionResultsVisualPanel.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** OperationExecutionResultsVisualPanel.java 5 Oct 2004 05:15:56 -0000 1.12 --- OperationExecutionResultsVisualPanel.java 12 Apr 2006 19:13:58 -0000 1.13 *************** *** 17,42 **** package org.mc4j.console.bean.operation; ! import java.awt.Rectangle; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; ! import java.util.Collection; ! import java.util.Iterator; ! import java.util.Map; import java.util.Map.Entry; - import java.util.Vector; - - import javax.management.MBeanOperationInfo; - import javax.management.MBeanParameterInfo; - import javax.management.MBeanServer; - import javax.management.ObjectName; - import javax.management.ReflectionException; - import javax.swing.JList; - import javax.swing.JPanel; - import javax.swing.JTable; - import javax.swing.SwingUtilities; - - import org.openide.util.NbBundle; - - import org.mc4j.console.util.ExceptionUtility; /** --- 17,32 ---- package org.mc4j.console.bean.operation; ! import org.mc4j.console.util.ExceptionUtility; ! import org.mc4j.ems.connection.bean.operation.EmsOperation; ! import org.mc4j.ems.connection.bean.parameter.EmsParameter; ! import org.openide.util.NbBundle; ! ! import javax.swing.*; ! import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; ! import java.util.*; ! import java.util.List; import java.util.Map.Entry; /** *************** *** 54,144 **** private Object results; ! private Throwable failure; ! /** Create the wizard panel and set up some basic properties. */ public OperationExecutionResultsVisualPanel(OperationExecutionResultsPanel panel) { this.panel = panel; initComponents(); ! this.textTypeCheckbox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { ! //if (e.getStateChange() == ItemEvent.ITEM_STATE_CHANGED) { switchView(); //} }}); ! // Provide a name in the title bar. setName(NbBundle.getMessage(OperationExecutionResultsVisualPanel.class, "TITLE_WizardPanel")); /* ! // Optional: provide a special description for this pane. ! // You must have turned on WizardDescriptor.WizardPanel_helpDisplayed ! // (see descriptor in standard iterator template for an example of this). ! try { ! putClientProperty("WizardPanel_helpURL", // NOI18N ! new URL("nbresloc:/org/mc4j/console/bean/operation/OperationExecutionResultsVisualHelp.html")); // NOI18N ! } catch (MalformedURLException mfue) { ! throw new IllegalStateException(mfue.toString()); ! } ! */ ! //executeOperation(); } ! public void executeOperation() { ! final MBeanServer server = ! (MBeanServer) ! panel.getDescriptor().getProperty(OperationExecuteDescriptor.MBEAN_SERVER); ! ! final MBeanOperationInfo operationInfo = ! (MBeanOperationInfo) ! panel.getDescriptor().getProperty(OperationExecuteDescriptor.OPERATION_INFO); ! ! final ObjectName objectName = ! (ObjectName) ! panel.getDescriptor().getProperty(OperationExecuteDescriptor.OBJECT_NAME); ! final Map parameters = (Map) panel.getDescriptor().getProperty(OperationExecuteDescriptor.PARAMETER_VALUES); ! try { ! ! MBeanParameterInfo[] params = ! operationInfo.getSignature(); ! ! final Object[] parameterValues = new Object[params.length]; ! final String[] parameterTypes = new String[params.length]; ! ! for (int i=0; i < params.length; i++) { ! String name = params[i].getName(); ! parameterValues[i] = parameters.get(name); ! parameterTypes[i] = params[i].getType(); } ! this.resultsEditorPane.setContentType("text/html"); setText("<h3>Waiting for results...</h3>"); ! Runnable execution = new Runnable() { public void run() { try { ! results = ! server.invoke( ! objectName, ! operationInfo.getName(), ! parameterValues, ! parameterTypes); resultsEditorPane.setContentType("text/html"); displayData(); - } catch (ReflectionException re) { - Throwable cause = re.getTargetException(); - if (cause != null) { - failure = cause; - } else { - failure = re; - } - setText(ExceptionUtility.printStackTracesToString(failure)); } catch (Exception e) { failure = e; --- 44,108 ---- private Object results; ! private Throwable failure; ! /** Create the wizard panel and set up some basic properties. */ public OperationExecutionResultsVisualPanel(OperationExecutionResultsPanel panel) { this.panel = panel; initComponents(); ! this.textTypeCheckbox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { ! //if (e.getStateChange() == ItemEvent.ITEM_STATE_CHANGED) { switchView(); //} }}); ! // Provide a name in the title bar. setName(NbBundle.getMessage(OperationExecutionResultsVisualPanel.class, "TITLE_WizardPanel")); /* ! // Optional: provide a special description for this pane. ! // You must have turned on WizardDescriptor.WizardPanel_helpDisplayed ! // (see descriptor in standard iterator template for an example of this). ! try { ! putClientProperty("WizardPanel_helpURL", // NOI18N ! new URL("nbresloc:/org/mc4j/console/bean/operation/OperationExecutionResultsVisualHelp.html")); // NOI18N ! } catch (MalformedURLException mfue) { ! throw new IllegalStateException(mfue.toString()); ! } ! */ ! //executeOperation(); } ! public void executeOperation() { ! ! final EmsOperation operation = (EmsOperation) panel.getDescriptor().getProperty(OperationExecuteDescriptor.OPERATION); final Map parameters = (Map) panel.getDescriptor().getProperty(OperationExecuteDescriptor.PARAMETER_VALUES); ! try { ! ! List<EmsParameter> params = operation.getParameters(); ! ! ! final Object[] arguments = new Object[params.size()]; ! for (int i = 0; i < params.size(); i++) { ! EmsParameter param = params.get(i); ! arguments[i] = parameters.get(param.getName()); } ! this.resultsEditorPane.setContentType("text/html"); setText("<h3>Waiting for results...</h3>"); ! Runnable execution = new Runnable() { public void run() { try { ! results = operation.invoke(arguments); resultsEditorPane.setContentType("text/html"); displayData(); } catch (Exception e) { failure = e; *************** *** 147,165 **** } }; ! // Need to run this outside the AWT update thread // so as not to freeze the UI in case of failed connection. (new Thread(execution, "mc4j OperationExecution")).start(); ! } catch (Exception e) { this.failure = e; setText(ExceptionUtility.printStackTracesToString(e)); ! } ! ! } private void displayData() { ! if (this.failure != null) { setText(ExceptionUtility.printStackTracesToString(this.failure)); --- 111,129 ---- } }; ! // Need to run this outside the AWT update thread // so as not to freeze the UI in case of failed connection. (new Thread(execution, "mc4j OperationExecution")).start(); ! } catch (Exception e) { this.failure = e; setText(ExceptionUtility.printStackTracesToString(e)); ! } ! ! } private void displayData() { ! if (this.failure != null) { setText(ExceptionUtility.printStackTracesToString(this.failure)); *************** *** 182,186 **** doLayout(); } else if (this.results instanceof Map) { ! Iterator iter = ((Map)this.results).entrySet().iterator(); Vector data = new Vector(); --- 146,150 ---- doLayout(); } else if (this.results instanceof Map) { ! Iterator iter = ((Map)this.results).entrySet().iterator(); Vector data = new Vector(); *************** *** 199,203 **** doLayout(); } else if (this.results.getClass().isArray()) { ! JList list = new JList((Object[]) this.results); resultsScrollPane.setViewportView(list); doLayout(); --- 163,167 ---- doLayout(); } else if (this.results.getClass().isArray()) { ! JList list = new JList((Object[]) this.results); resultsScrollPane.setViewportView(list); doLayout(); *************** *** 207,215 **** } this.textTypeCheckbox.setEnabled(!complexType); ! } validate(); this.repaint(); } ! /** This method is called from within the constructor to * initialize the form. --- 171,179 ---- } this.textTypeCheckbox.setEnabled(!complexType); ! } validate(); this.repaint(); } ! /** This method is called from within the constructor to * initialize the form. *************** *** 236,240 **** }//GEN-END:initComponents ! public void switchView() { boolean isHtml = this.textTypeCheckbox.isSelected(); --- 200,204 ---- }//GEN-END:initComponents ! public void switchView() { boolean isHtml = this.textTypeCheckbox.isSelected(); *************** *** 248,252 **** displayData(); } ! public void setText(String text) { this.resultsEditorPane.setText(text); --- 212,216 ---- displayData(); } ! public void setText(String text) { this.resultsEditorPane.setText(text); *************** *** 258,262 **** }); } ! // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JCheckBox textTypeCheckbox; --- 222,226 ---- }); } ! // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JCheckBox textTypeCheckbox; Index: OperationSetNode.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/bean/operation/OperationSetNode.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** OperationSetNode.java 5 Oct 2004 05:15:56 -0000 1.5 --- OperationSetNode.java 12 Apr 2006 19:13:58 -0000 1.6 *************** *** 25,28 **** --- 25,29 ---- import org.openide.util.NbBundle; import org.openide.util.actions.SystemAction; + import org.mc4j.ems.connection.bean.EmsBean; /** *************** *** 34,40 **** public static final String NAME = "Operations"; - public OperationSetNode() { - super(new OperationSetChildren()); //new Children.SortedArray()); setIconBase("org/mc4j/console/bean/operation/OperationSetNodeIcon"); // Set FeatureDescriptor stuff: --- 35,44 ---- public static final String NAME = "Operations"; + private EmsBean emsBean; + + public OperationSetNode(EmsBean emsBean) { + super(new OperationSetChildren(emsBean)); //new Children.SortedArray()); + this.emsBean = emsBean; setIconBase("org/mc4j/console/bean/operation/OperationSetNodeIcon"); // Set FeatureDescriptor stuff: Index: OperationSetChildren.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/bean/operation/OperationSetChildren.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OperationSetChildren.java 5 Oct 2004 05:15:56 -0000 1.4 --- OperationSetChildren.java 12 Apr 2006 19:13:58 -0000 1.5 *************** *** 17,27 **** package org.mc4j.console.bean.operation; ! import java.util.Collections; ! import java.util.LinkedList; ! import java.util.List; ! import org.openide.nodes.Children; import org.openide.nodes.Node; /** * --- 17,27 ---- package org.mc4j.console.bean.operation; ! import org.mc4j.ems.connection.bean.EmsBean; ! import org.mc4j.ems.connection.bean.operation.EmsOperation; import org.openide.nodes.Children; import org.openide.nodes.Node; + import java.util.SortedSet; + /** * *************** *** 29,83 **** * @version $Revision$($Author$ / $Date$) */ ! public class OperationSetChildren extends Children.Keys { ! /** Optional holder for the keys, to be used when changing them dynamically. */ ! protected List myKeys; ! public OperationSetChildren() { ! myKeys = null; } protected void addNotify() { super.addNotify(); - if (myKeys != null) return; - myKeys = new LinkedList(); - // add whatever keys you need - setKeys(myKeys); - } ! protected void removeNotify() { ! myKeys = null; ! setKeys(Collections.EMPTY_SET); ! super.removeNotify(); ! } ! ! protected Node[] createNodes(Object key) { ! // interpret your key here...usually one node generated, but could be zero or more ! return new Node[] { /*new MyNode((MyParameter)key) */}; ! } ! /** Optional accessor method for the keys, for use by the container node or maybe subclasses. */ ! /* ! protected addKey(Object newKey) { ! // Make sure some keys already exist: ! addNotify(); ! myKeys.add(newKey); ! // Ensure that the node(s) is displayed: ! refreshKey(newKey); ! } ! */ - /** Optional accessor method for keys, for use by the container node or maybe subclasses. */ - /* - protected void setKeys(Collection keys) { - myKeys = new LinkedList(); - myKeys.addAll(keys); - super.setKeys(keys); } - */ - - // Could also write e.g. removeKey to be used by the nodes in this children. - // Or, could listen to changes in their status (NodeAdapter.nodeDestroyed) - // and automatically remove them from the keys list here. Etc. - } --- 29,53 ---- * @version $Revision$($Author$ / $Date$) */ ! public class OperationSetChildren extends Children.SortedArray { ! private EmsBean emsBean; ! public OperationSetChildren(EmsBean emsBean) { ! this.emsBean = emsBean; } protected void addNotify() { super.addNotify(); ! SortedSet<EmsOperation> operations = emsBean.getOperations(); ! Node[] newNodes = new Node[operations.size()]; ! int i = 0; ! for (EmsOperation operation : operations) { ! OperationNode node = new OperationNode(operation); ! newNodes[i++] = node; ! } ! add(newNodes); } } |