FileDocCategorySizeDatePackage
ViewObjectsPanel.javaAPI DocphoneME MR2 API (J2ME)8897Wed May 02 17:59:48 BST 2007view

ViewObjectsPanel

public class ViewObjectsPanel extends JPanel

Fields Summary
private JLabel
address_label
private JTextField
address_field
private JLabel
type_label
private JTextField
type_field
private JTable
references
private JTable
referees
private com.sun.cldchi.tools.memoryprofiler.data.JavaObject
_obj
private com.sun.cldchi.tools.memoryprofiler.data.MPDataProvider
_provider
private JButton
_root_path
private JList
_object_list
private JButton
_stack_location
private Object[]
_objects
Constructors Summary
public ViewObjectsPanel(com.sun.cldchi.tools.memoryprofiler.data.MPDataProvider provider)


     
    _provider = provider;
  
Methods Summary
public voidinitUI(boolean add_show_root_path_button)

    setLayout(new GridBagLayout());
    JPanel top_panel = new JPanel();
    top_panel.add(address_label);
    top_panel.add(address_field);
    address_field.setEditable(false);
    type_field.setEditable(false);
    address_field.setPreferredSize(new Dimension(80, 20));
    type_field.setPreferredSize(new Dimension(120, 20));

    top_panel.add(type_label);
    top_panel.add(type_field);
    if (add_show_root_path_button) {
      _root_path = new JButton("Show path from the root") {
        public Dimension getPreferredSize() {
          return new Dimension(160, 20);
        }
      };
      _root_path.addActionListener(new ShowRootPathListener());

      _root_path.setFont(_root_path.getFont().deriveFont(9.0f));
      _root_path.setEnabled(false);
      top_panel.add(_root_path);
    } else { //this is show path from the root object
        _stack_location = new JButton("Show stack trace") {
          public Dimension getPreferredSize() {
            return new Dimension(160, 20);
          }
        };
        _stack_location.addActionListener(new ShowStackTraceListener());
  
        _stack_location.setFont(_stack_location.getFont().deriveFont(9.0f));
        _stack_location.setEnabled(false);
        top_panel.add(_stack_location);
  
    }
    add(top_panel, new GridBagConstraints(0, 0, 1, 1, 1, 1,
           GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
    JPanel bottom_panel = new JPanel();
    JScrollPane pane = new JScrollPane() {
      public Dimension getPreferredSize() {return new Dimension(100, 220);}
    };
    _object_list = new JList();
    _object_list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    _object_list.addListSelectionListener(new ObjectListSelectionListener());
    pane.getViewport().setView(_object_list);

    bottom_panel.setLayout(new GridBagLayout());
    bottom_panel.add(pane, new GridBagConstraints(0, 0, 1, 2, 1, 1,
           GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
    bottom_panel.add(new JLabel("Referees"), new GridBagConstraints(1, 0, 1, 1, 1, 1,
           GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
    bottom_panel.add(new JLabel("References"), new GridBagConstraints(2, 0, 1, 1, 1, 1,
           GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
    pane = new JScrollPane() {
      public Dimension getPreferredSize() {
        return new Dimension(220, 200);
      }
    };
    pane.getViewport().setView(referees);
    bottom_panel.add(pane, new GridBagConstraints(1, 1, 1, 1, 1, 21,
             GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
    pane = new JScrollPane() {
        public Dimension getPreferredSize() {
          return new Dimension(220, 200);
        }
      };
    pane.getViewport().setView(references);
    bottom_panel.add(pane, new GridBagConstraints(2, 1, 1, 1, 1, 21,
           GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
  
    add(bottom_panel, new GridBagConstraints(0, 1, 1, 1, 1, 20,
           GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));

  
private voidsetObject(com.sun.cldchi.tools.memoryprofiler.data.JavaObject obj)

    _obj = obj;
    ObjectListTableModel refs = (ObjectListTableModel)references.getModel();
    ObjectListTableModel refes = (ObjectListTableModel)referees.getModel();
    if (obj != null) {
      address_field.setText(obj.toString());
      type_field.setText(_provider.getObjectTypeName(obj));
      refs.setData(obj.get_references());
      refes.setData(obj.get_referees());
      if (_root_path != null) {
        _root_path.setEnabled(obj.getRootDistance() != -1);
      }
      if (_stack_location != null) {
        _stack_location.setEnabled(obj.object_type == MPDataProvider.STACK_OBJECT);
      }
    } else {
      address_field.setText("");
      type_field.setText("");
      refs.setData(null);
      refes.setData(null);
      if (_root_path != null) {
        _root_path.setEnabled(false);
      }
    }
    refs.fireTableDataChanged();
    refes.fireTableDataChanged();
  
public voidsetObjects(java.lang.Object[] objects)

    _object_list.setListData(objects);
    _objects = objects;
    repaint();