src/share/classes/sun/tools/jconsole/inspector/OperationEntry.java

Print this page
rev 5340 : 7017818: NLS: JConsoleResources.java cannot be handled by translation team
Reviewed-by: duke


   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.tools.jconsole.inspector;
  27 
  28 // java import
  29 import java.awt.*;
  30 import java.awt.event.*;
  31 import java.awt.dnd.*;
  32 import java.lang.reflect.*;
  33 import java.io.*;
  34 //
  35 
  36 // swing import
  37 import javax.swing.border.*;
  38 import javax.swing.event.*;
  39 import javax.swing.*;
  40 //
  41 
  42 // jmx import
  43 import javax.management.*;
  44 //
  45 
  46 
  47 @SuppressWarnings("serial")
  48 public class OperationEntry extends JPanel {
  49     private MBeanOperationInfo operation;
  50     private JComboBox sigs;
  51     private Dimension preferredSize;
  52     private XTextField inputs[];
  53 
  54     public OperationEntry (MBeanOperationInfo operation,
  55                            boolean isCallable,
  56                            JButton button,
  57                            XOperations xoperations) {
  58         super(new BorderLayout());
  59         this.operation = operation;
  60         setLayout(new FlowLayout(FlowLayout.LEFT));
  61         setPanel(isCallable, button, xoperations);
  62     }
  63 
  64     /**
  65      * This method chops off the throws exceptions, removes "java.lang".
  66      */
  67     private String preProcessSignature(String signature) {
  68         int index;
  69         if ((index=signature.indexOf(" throws"))>0) {
  70             signature = signature.substring(0,index);
  71         }
  72         while ((index = signature.indexOf("java.lang."))>0) {
  73             signature = signature.substring(0,index)+
  74                 signature.substring(index+10,signature.length());
  75         }
  76         return signature;
  77     }
  78 
  79     private void setPanel(boolean isCallable,
  80                           JButton button,
  81                           XOperations xoperations) {
  82         try {
  83             String defaultVal;
  84             MBeanParameterInfo params[] = operation.getSignature();
  85             add(new JLabel("(",JLabel.CENTER));
  86             inputs = new XTextField[params.length];
  87             for (int i = 0; i < params.length; i++) {
  88                 if(params[i].getName() != null) {
  89                     JLabel name =
  90                         new JLabel(params[i].getName(), JLabel.CENTER);
  91                     name.setToolTipText(params[i].getDescription());
  92                     add(name);
  93                 }
  94 
  95                 String defaultTextValue =
  96                     Utils.getDefaultValue(params[i].getType());
  97                 int fieldWidth = defaultTextValue.length();
  98                 if (fieldWidth > 15) fieldWidth = 15;
  99                 else
 100                     if (fieldWidth < 10) fieldWidth = 10;
 101 
 102                 add(inputs[i] =
 103                         new XTextField(Utils.getReadableClassName(defaultTextValue),




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.tools.jconsole.inspector;
  27 

  28 import java.awt.*;









  29 import javax.swing.*;



  30 import javax.management.*;


  31 
  32 @SuppressWarnings("serial")
  33 public class OperationEntry extends JPanel {
  34     private MBeanOperationInfo operation;
  35     private JComboBox sigs;

  36     private XTextField inputs[];
  37 
  38     public OperationEntry (MBeanOperationInfo operation,
  39                            boolean isCallable,
  40                            JButton button,
  41                            XOperations xoperations) {
  42         super(new BorderLayout());
  43         this.operation = operation;
  44         setLayout(new FlowLayout(FlowLayout.LEFT));
  45         setPanel(isCallable, button, xoperations);
  46     }
  47 















  48      private void setPanel(boolean isCallable,
  49                           JButton button,
  50                           XOperations xoperations) {
  51         try {

  52             MBeanParameterInfo params[] = operation.getSignature();
  53             add(new JLabel("(",JLabel.CENTER));
  54             inputs = new XTextField[params.length];
  55             for (int i = 0; i < params.length; i++) {
  56                 if(params[i].getName() != null) {
  57                     JLabel name =
  58                         new JLabel(params[i].getName(), JLabel.CENTER);
  59                     name.setToolTipText(params[i].getDescription());
  60                     add(name);
  61                 }
  62 
  63                 String defaultTextValue =
  64                     Utils.getDefaultValue(params[i].getType());
  65                 int fieldWidth = defaultTextValue.length();
  66                 if (fieldWidth > 15) fieldWidth = 15;
  67                 else
  68                     if (fieldWidth < 10) fieldWidth = 10;
  69 
  70                 add(inputs[i] =
  71                         new XTextField(Utils.getReadableClassName(defaultTextValue),