sa-jdi

1
 */
package sun.jvm.hotspot.ui;

import javax.swing.JEditorPane;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.swing.text.ElementIterator;

public class SAEditorPane
  extends JEditorPane
{
  public SAEditorPane()
  {
    setEditable(false);
    setContentType("text/html");
  }
  
  public String getSelectedText()
  {
    StringBuffer result = new StringBuffer();
    Document doc = getDocument();
    
    int start = getSelectionStart();
    int end = getSelectionEnd();
    try
    {
      ElementIterator it = new ElementIterator(doc.getDefaultRootElement());
      
      String separator = System.getProperty("line.separator");
      Element e;
      while ((e = it.next()) != null) {
        if (e.isLeaf())
        {
          int rangeStart = e.getStartOffset();
          int rangeEnd = e.getEndOffset();
          if ((rangeEnd >= start) && (rangeStart <= end))
          {
            if (end < rangeEnd) {
              rangeEnd = end;
            }
            if (start > rangeStart) {
              rangeStart = start;
            }
            try
            {
              String line = getText(rangeStart, rangeEnd - rangeStart);
              if (e.getName().equals("br")) {
                result.append(separator);
              } else {
                result.append(line);
              }
            }
            catch (BadLocationException ex) {}
          }
        }
      }
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    return result.toString();
  }
  
  public void setText(String text)
  {
    super.setText(text);
    
    setCaretPosition(0);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.SAEditorPane
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui;

import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.runtime.JavaThread;
import sun.jvm.hotspot.ui.tree.SimpleTreeNode;
import sun.jvm.hotspot.utilities.LivenessPathList;

public abstract interface SAListener
{
  public abstract void showThreadOopInspector(JavaThread paramJavaThread);
  
  public abstract void showInspector(SimpleTreeNode paramSimpleTreeNode);
  
  public abstract void showThreadStackMemory(JavaThread paramJavaThread);
  
  public abstract void showThreadInfo(JavaThread paramJavaThread);
  
  public abstract void showJavaStackTrace(JavaThread paramJavaThread);
  
  public abstract void showCodeViewer(Address paramAddress);
  
  public abstract void showLiveness(Oop paramOop, LivenessPathList paramLivenessPathList);
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.SAListener
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.swing.JPanel;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.runtime.JavaThread;
import sun.jvm.hotspot.ui.tree.OopTreeNodeAdapter;
import sun.jvm.hotspot.ui.tree.SimpleTreeNode;

public class SAPanel
  extends JPanel
{
  protected List listeners = new ArrayList();
  
  public void addPanelListener(SAListener listener)
  {
    listeners.add(listener);
  }
  
  public void removePanelListener(SAListener listener)
  {
    listeners.remove(listener);
  }
  
  public void showThreadOopInspector(JavaThread t)
  {
    for (Iterator iter = listeners.iterator(); iter.hasNext();)
    {
      SAListener listener = (SAListener)iter.next();
      listener.showThreadOopInspector(t);
    }
  }
  
  public void showInspector(Oop oop)
  {
    showInspector(new OopTreeNodeAdapter(oop, null));
  }
  
  public void showInspector(SimpleTreeNode node)
  {
    for (Iterator iter = listeners.iterator(); iter.hasNext();)
    {
      SAListener listener = (SAListener)iter.next();
      listener.showInspector(node);
    }
  }
  
  public void showThreadStackMemory(JavaThread t)
  {
    for (Iterator iter = listeners.iterator(); iter.hasNext();)
    {
      SAListener listener = (SAListener)iter.next();
      listener.showThreadStackMemory(t);
    }
  }
  
  public void showJavaStackTrace(JavaThread t)
  {
    for (Iterator iter = listeners.iterator(); iter.hasNext();)
    {
      SAListener listener = (SAListener)iter.next();
      listener.showJavaStackTrace(t);
    }
  }
  
  public void showThreadInfo(JavaThread t)
  {
    for (Iterator iter = listeners.iterator(); iter.hasNext();)
    {
      SAListener listener = (SAListener)iter.next();
      listener.showThreadInfo(t);
    }
  }
  
  public void showCodeViewer(Address address)
  {
    for (Iterator iter = listeners.iterator(); iter.hasNext();)
    {
      SAListener listener = (SAListener)iter.next();
      listener.showCodeViewer(address);
    }
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.SAPanel
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui;

import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import javax.swing.JTextArea;
import javax.swing.text.Caret;

final class SourceCodePanel$1
  extends FocusAdapter
{
  private final SourceCodePanel this$0;
  
  SourceCodePanel$1(SourceCodePanel paramSourceCodePanel) {}
  
  public void focusGained(FocusEvent e)
  {
    SourceCodePanel.access$400(this$0).getCaret().setVisible(true);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.SourceCodePanel.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

final class SourceCodePanel$2
  extends KeyAdapter
{
  private final SourceCodePanel this$0;
  
  SourceCodePanel$2(SourceCodePanel paramSourceCodePanel) {}
  
  public void keyPressed(KeyEvent e)
  {
    if (e.getKeyCode() == 120)
    {
      int lineNo = this$0.getCurrentLineNumber();
      
      SourceCodePanel.access$600(this$0).toggleBreakpointAtLine(SourceCodePanel.access$500(this$0), lineNo);
    }
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.SourceCodePanel.2
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui;

import java.awt.event.HierarchyBoundsAdapter;
import java.awt.event.HierarchyEvent;

final class SourceCodePanel$RowHeader$1
  extends HierarchyBoundsAdapter
{
  private final SourceCodePanel.RowHeader this$1;
  
  SourceCodePanel$RowHeader$1(SourceCodePanel.RowHeader paramRowHeader, SourceCodePanel paramSourceCodePanel) {}
  
  public void ancestorResized(HierarchyEvent e)
  {
    this$1.recomputeSize();
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.SourceCodePanel.RowHeader.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.HierarchyBoundsAdapter;
import java.awt.event.HierarchyEvent;
import java.util.Set;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JViewport;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.Position;

class SourceCodePanel$RowHeader
  extends JPanel
{
  private JViewport view;
  private boolean showLineNumbers;
  private int width;
  private int rowHeight;
  private boolean initted;
  private final SourceCodePanel this$0;
  
  public SourceCodePanel$RowHeader(final SourceCodePanel paramSourceCodePanel)
  {
    initted = true;
    addHierarchyBoundsListener(new HierarchyBoundsAdapter()
    {
      public void ancestorResized(HierarchyEvent e)
      {
        recomputeSize();
      }
    });
  }
  
  public void paint(Graphics g)
  {
    super.paint(g);
    if (getShowLineNumbers())
    {
      Rectangle clip = g.getClipBounds();
      
      int start = y / rowHeight;
      int end = start + (height + (rowHeight - 1)) / rowHeight;
      
      FontMetrics fm = getFontMetrics(getFont());
      int ascent = fm.getMaxAscent();
      for (int i = start; i <= end; i++)
      {
        String str = Integer.toString(i + 1);
        int strWidth = GraphicsUtilities.getStringWidth(str, fm);
        g.drawString(str, width - strWidth - 4, ascent + rowHeight * i);
        if (SourceCodePanel.access$000(this$0).contains(new Integer(i))) {
          SourceCodePanel.access$100().paintIcon(this, g, 4, rowHeight * i);
        }
        if (i == SourceCodePanel.access$200(this$0)) {
          SourceCodePanel.access$300().paintIcon(this, g, 4, rowHeight * i);
        }
      }
    }
  }
  
  public boolean getShowLineNumbers()
  {
    return showLineNumbers;
  }
  
  public void setShowLineNumbers(boolean val)
  {
    if (val != showLineNumbers)
    {
      showLineNumbers = val;
      recomputeSize();
      
      invalidate();
      validate();
    }
  }
  
  public void setFont(Font f)
  {
    super.setFont(f);
    rowHeight = getFontMetrics(f).getHeight();
    recomputeSize();
  }
  
  void setViewport(JViewport view)
  {
    this.view = view;
  }
  
  void recomputeSize()
  {
    if (!initted) {
      return;
    }
    if (view == null) {
      return;
    }
    width = 20;
    try
    {
      int numLines = 1 + SourceCodePanel.access$400(this$0).getLineOfOffset(SourceCodePanel.access$400(this$0).getDocument().getEndPosition().getOffset() - 1);
      String str = Integer.toString(numLines);
      if (getShowLineNumbers()) {
        width += GraphicsUtilities.getStringWidth(str, getFontMetrics(getFont())) + 4;
      }
      Dimension d = new Dimension(width, numLines * getFontMetrics(getFont()).getHeight());
      setSize(d);
      setPreferredSize(d);
    }
    catch (BadLocationException e)
    {
      e.printStackTrace();
    }
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.SourceCodePanel.RowHeader
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.HierarchyBoundsAdapter;
import java.awt.event.HierarchyEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;
import java.util.HashSet;
import java.util.Set;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JViewport;
import javax.swing.text.BadLocationException;
import javax.swing.text.Caret;
import javax.swing.text.Document;
import javax.swing.text.Position;

public class SourceCodePanel
  extends JPanel
{
  private JTextArea source;
  private RowHeader header;
  private String filename;
  private static final int LINE_NO_SPACE = 4;
  private static final int ICON_SIZE = 12;
  private static Icon topFrameCurLine;
  private static Icon lowerFrameCurLine;
  private static Icon breakpoint;
  private int highlightedLine = -1;
  private Set breakpoints = new HashSet();
  private EditorCommands comm;
  private Editor parent;
  
  class RowHeader
    extends JPanel
  {
    private JViewport view;
    private boolean showLineNumbers;
    private int width;
    private int rowHeight;
    private boolean initted;
    
    public RowHeader()
    {
      initted = true;
      addHierarchyBoundsListener(new HierarchyBoundsAdapter()
      {
        public void ancestorResized(HierarchyEvent e)
        {
          recomputeSize();
        }
      });
    }
    
    public void paint(Graphics g)
    {
      super.paint(g);
      if (getShowLineNumbers())
      {
        Rectangle clip = g.getClipBounds();
        
        int start = y / rowHeight;
        int end = start + (height + (rowHeight - 1)) / rowHeight;
        
        FontMetrics fm = getFontMetrics(getFont());
        int ascent = fm.getMaxAscent();
        for (int i = start; i <= end; i++)
        {
          String str = Integer.toString(i + 1);
          int strWidth = GraphicsUtilities.getStringWidth(str, fm);
          g.drawString(str, width - strWidth - 4, ascent + rowHeight * i);
          if (breakpoints.contains(new Integer(i))) {
            SourceCodePanel.breakpoint.paintIcon(this, g, 4, rowHeight * i);
          }
          if (i == highlightedLine) {
            SourceCodePanel.topFrameCurLine.paintIcon(this, g, 4, rowHeight * i);
          }
        }
      }
    }
    
    public boolean getShowLineNumbers()
    {
      return showLineNumbers;
    }
    
    public void setShowLineNumbers(boolean val)
    {
      if (val != showLineNumbers)
      {
        showLineNumbers = val;
        recomputeSize();
        
        invalidate();
        validate();
      }
    }
    
    public void setFont(Font f)
    {
      super.setFont(f);
      rowHeight = getFontMetrics(f).getHeight();
      recomputeSize();
    }
    
    void setViewport(JViewport view)
    {
      this.view = view;
    }
    
    void recomputeSize()
    {
      if (!initted) {
        return;
      }
      if (view == null) {
        return;
      }
      width = 20;
      try
      {
        int numLines = 1 + source.getLineOfOffset(source.getDocument().getEndPosition().getOffset() - 1);
        String str = Integer.toString(numLines);
        if (getShowLineNumbers()) {
          width += GraphicsUtilities.getStringWidth(str, getFontMetrics(getFont())) + 4;
        }
        Dimension d = new Dimension(width, numLines * getFontMetrics(getFont()).getHeight());
        setSize(d);
        setPreferredSize(d);
      }
      catch (BadLocationException e)
      {
        e.printStackTrace();
      }
    }
  }
  
  public SourceCodePanel()
  {
    maybeLoadIcons();
    
    setLayout(new BorderLayout());
    source = new JTextArea();
    source.setEditable(false);
    source.getCaret().setVisible(true);
    header = new RowHeader();
    header.setShowLineNumbers(true);
    JScrollPane scroller = new JScrollPane(source);
    JViewport rowView = new JViewport();
    rowView.setView(header);
    header.setViewport(rowView);
    rowView.setScrollMode(0);
    scroller.setRowHeader(rowView);
    add(scroller, "Center");
    
    setFont(getFont());
    
    source.addFocusListener(new FocusAdapter()
    {
      public void focusGained(FocusEvent e)
      {
        source.getCaret().setVisible(true);
      }
    });
    source.addKeyListener(new KeyAdapter()
    {
      public void keyPressed(KeyEvent e)
      {
        if (e.getKeyCode() == 120)
        {
          int lineNo = getCurrentLineNumber();
          
          comm.toggleBreakpointAtLine(parent, lineNo);
        }
      }
    });
  }
  
  public void setFont(Font f)
  {
    super.setFont(f);
    if (source != null) {
      source.setFont(f);
    }
    if (header != null) {
      header.setFont(f);
    }
  }
  
  public boolean getShowLineNumbers()
  {
    return header.getShowLineNumbers();
  }
  
  public void setShowLineNumbers(boolean val)
  {
    header.setShowLineNumbers(val);
  }
  
  public boolean openFile(String filename)
  {
    try
    {
      this.filename = filename;
      File file = new File(filename);
      int len = (int)file.length();
      StringBuffer buf = new StringBuffer(len);
      char[] tmp = new char['?'];
      FileReader in = new FileReader(file);
      int res = 0;
      do
      {
        res = in.read(tmp, 0, tmp.length);
        if (res >= 0) {
          buf.append(tmp, 0, res);
        }
      } while (res != -1);
      in.close();
      String text = buf.toString();
      source.setText(text);
      header.recomputeSize();
      return true;
    }
    catch (IOException e) {}
    return false;
  }
  
  public String getSourceFileName()
  {
    return filename;
  }
  
  public int getCurrentLineNumber()
  {
    try
    {
      return 1 + source.getLineOfOffset(source.getCaretPosition());
    }
    catch (BadLocationException e) {}
    return 0;
  }
  
  public void showLineNumber(int lineNo)
  {
    try
    {
      int offset = source.getLineStartOffset(lineNo - 1);
      Rectangle rect = source.modelToView(offset);
      if (rect == null) {
        return;
      }
      source.scrollRectToVisible(rect);
    }
    catch (BadLocationException e)
    {
      e.printStackTrace();
    }
  }
  
  public void highlightLineNumber(int lineNo)
  {
    highlightedLine = (lineNo - 1);
  }
  
  public void showBreakpointAtLine(int lineNo)
  {
    breakpoints.add(new Integer(lineNo - 1));repaint();
  }
  
  public boolean hasBreakpointAtLine(int lineNo)
  {
    return breakpoints.contains(new Integer(lineNo - 1));
  }
  
  public void clearBreakpointAtLine(int lineNo)
  {
    breakpoints.remove(new Integer(lineNo - 1));repaint();
  }
  
  public void clearBreakpoints()
  {
    breakpoints.clear();repaint();
  }
  
  public void setEditorCommands(EditorCommands comm, Editor parent)
  {
    this.comm = comm;
    this.parent = parent;
  }
  
  public void requestFocus()
  {
    source.requestFocus();
  }
  
  private void maybeLoadIcons()
  {
    if (topFrameCurLine == null)
    {
      topFrameCurLine = loadIcon("resources/arrow.png");
      lowerFrameCurLine = loadIcon("resources/triangle.png");
      breakpoint = loadIcon("resources/breakpoint.png");
    }
  }
  
  private Icon loadIcon(String which)
  {
    URL url = getClass().getResource(which);
    return new ImageIcon(url);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.SourceCodePanel
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui;

import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;

class StringTransferable
  implements Transferable
{
  private static final DataFlavor[] supported = { DataFlavor.stringFlavor };
  private String str;
  
  public StringTransferable(String str)
  {
    this.str = str;
  }
  
  public DataFlavor[] getTransferDataFlavors()
  {
    return supported;
  }
  
  public boolean isDataFlavorSupported(DataFlavor flavor)
  {
    return DataFlavor.stringFlavor.equals(flavor);
  }
  
  public Object getTransferData(DataFlavor flavor)
    throws UnsupportedFlavorException, IOException
  {
    if (!isDataFlavorSupported(flavor)) {
      throw new UnsupportedFlavorException(flavor);
    }
    return str;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.StringTransferable
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui;

import java.awt.BorderLayout;
import java.util.Enumeration;
import java.util.Properties;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import sun.jvm.hotspot.runtime.VM;

public class SysPropsPanel
  extends JPanel
{
  private SAEditorPane flagsPane;
  
  public SysPropsPanel()
  {
    initUI();
  }
  
  private void initUI()
  {
    setLayout(new BorderLayout());
    flagsPane = new SAEditorPane();
    flagsPane.setText(getFlags());
    
    add(new JScrollPane(flagsPane), "Center");
  }
  
  private String getFlags()
  {
    StringBuffer buf = new StringBuffer();
    buf.append("<html><head><title>System Properties</title></head><body>");
    buf.append("<table border='1'>");
    
    Properties sysProps = VM.getVM().getSystemProperties();
    if (sysProps != null)
    {
      Enumeration keys = sysProps.keys();
      while (keys.hasMoreElements())
      {
        Object key = keys.nextElement();
        buf.append("<tr><td>");
        buf.append(key.toString());
        buf.append("</td><td>");
        buf.append(sysProps.get(key).toString());
        buf.append("</td></tr>");
      }
    }
    else
    {
      buf.append("<tr><td>System Properties info not available!</td></tr>");
    }
    buf.append("</table>");
    buf.append("</body></html>");
    return buf.toString();
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.SysPropsPanel
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.table;

import java.awt.Component;
import javax.swing.JFormattedTextField;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableCellRenderer;

public class LongCellRenderer
  extends DefaultTableCellRenderer
{
  private JFormattedTextField textField;
  
  public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
  {
    if (textField == null)
    {
      textField = new JFormattedTextField();
      textField.setFont(table.getFont());
      textField.setHorizontalAlignment(4);
    }
    textField.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
    
    textField.setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
    if (hasFocus) {
      textField.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
    } else {
      textField.setBorder(noFocusBorder);
    }
    textField.setValue((Long)value);
    
    return textField;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.table.LongCellRenderer
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.table;

import java.util.Collections;
import java.util.List;
import javax.swing.event.TableModelEvent;
import javax.swing.table.AbstractTableModel;

public abstract class SortableTableModel
  extends AbstractTableModel
{
  private TableModelComparator comparator;
  protected List elements;
  
  public void setComparator(TableModelComparator comparator)
  {
    this.comparator = comparator;
  }
  
  public void sortByColumn(int column, boolean ascending)
  {
    comparator.addColumn(column);
    comparator.setAscending(ascending);
    
    Collections.sort(elements, comparator);
    
    fireTableChanged(new TableModelEvent(this));
  }
  
  public boolean isAscending()
  {
    return comparator.isAscending();
  }
  
  public int getColumn()
  {
    return comparator.getColumn();
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.table.SortableTableModel
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.table;

import java.awt.Component;
import java.net.URL;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.JTableHeader;

public class SortHeaderCellRenderer
  extends DefaultTableCellRenderer
{
  private Icon descendingIcon;
  private Icon ascendingIcon;
  private SortableTableModel model;
  
  public SortHeaderCellRenderer(JTableHeader header, SortableTableModel model)
  {
    this.model = model;
    
    descendingIcon = getIcon("navigation/Down16.gif");
    ascendingIcon = getIcon("navigation/Up16.gif");
    
    setForeground(header.getForeground());
    setBackground(header.getBackground());
    setFont(header.getFont());
    
    setBorder(UIManager.getBorder("TableHeader.cellBorder"));
    setHorizontalAlignment(0);
  }
  
  public ImageIcon getIcon(String name)
  {
    String imagePath = "/toolbarButtonGraphics/" + name;
    URL url = getClass().getResource(imagePath);
    if (url != null) {
      return new ImageIcon(url);
    }
    return null;
  }
  
  public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
  {
    setText(value == null ? "" : value.toString());
    
    Icon icon = null;
    if (column == model.getColumn()) {
      if (model.isAscending()) {
        icon = ascendingIcon;
      } else {
        icon = descendingIcon;
      }
    }
    setIcon(icon);
    
    return this;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.table.SortHeaderCellRenderer
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.table;

import com.sun.java.swing.ui.CommonUI;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.TableColumnModel;

public class SortHeaderMouseAdapter
  extends MouseAdapter
{
  private SortableTableModel model;
  private JTable table;
  
  public SortHeaderMouseAdapter(JTable table, SortableTableModel model)
  {
    this.model = model;
    this.table = table;
  }
  
  public void mouseClicked(MouseEvent evt)
  {
    CommonUI.setWaitCursor(SwingUtilities.getRoot(table));
    
    TableColumnModel columnModel = table.getColumnModel();
    int viewColumn = columnModel.getColumnIndexAtX(evt.getX());
    int column = table.convertColumnIndexToModel(viewColumn);
    if ((evt.getClickCount() == 1) && (column != -1)) {
      model.sortByColumn(column, !model.isAscending());
    }
    CommonUI.setDefaultCursor(SwingUtilities.getRoot(table));
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.table.SortHeaderMouseAdapter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.table;

import java.util.Comparator;
import javax.swing.table.TableModel;

public abstract class TableModelComparator
  implements Comparator
{
  private boolean ascending;
  protected TableModel model;
  private int[] columns;
  
  public TableModelComparator(TableModel model)
  {
    this.model = model;
    
    columns = new int[model.getColumnCount()];
    columns[0] = -1;
  }
  
  public void addColumn(int column)
  {
    int[] tempArray = new int[model.getColumnCount()];
    System.arraycopy(columns, 1, tempArray, 0, columns.length - 1);
    
    columns = tempArray;
    columns[0] = column;
  }
  
  public int getColumn()
  {
    return columns[0];
  }
  
  public void setAscending(boolean ascending)
  {
    this.ascending = ascending;
  }
  
  public boolean isAscending()
  {
    return ascending;
  }
  
  public int compare(Object row1, Object row2)
  {
    for (int i = 0; i < columns.length; i++)
    {
      Object o1 = getValueForColumn(row1, columns[i]);
      Object o2 = getValueForColumn(row2, columns[i]);
      if ((o1 == null) && (o2 == null)) {
        return 0;
      }
      if (o1 == null) {
        return -1;
      }
      if (o2 == null) {
        return 1;
      }
      int result = 0;
      if ((o1 instanceof Comparable))
      {
        Comparable c1 = (Comparable)o1;
        Comparable c2 = (Comparable)o2;
        
        result = c1.compareTo(c2);
      }
      if (result != 0) {
        return ascending ? result : -result;
      }
    }
    return 0;
  }
  
  public abstract Object getValueForColumn(Object paramObject, int paramInt);
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.table.TableModelComparator
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui;

import java.awt.BorderLayout;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JViewport;
import sun.jvm.hotspot.runtime.JavaThread;

public class ThreadInfoPanel
  extends JPanel
{
  private JTextArea textArea;
  
  public ThreadInfoPanel()
  {
    initUI();
  }
  
  private void initUI()
  {
    setLayout(new BorderLayout());
    
    JScrollPane scroller = new JScrollPane();
    textArea = new JTextArea();
    textArea.setEditable(false);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    scroller.getViewport().add(textArea);
    add(scroller, "Center");
  }
  
  public ThreadInfoPanel(JavaThread thread)
  {
    initUI();
    setJavaThread(thread);
  }
  
  public void setJavaThread(JavaThread thread)
  {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    PrintStream tty = new PrintStream(bos);
    tty.println("Thread Info: " + thread.getThreadName());
    thread.printInfoOn(tty);
    
    textArea.setText(bos.toString());
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.ThreadInfoPanel
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.tree;

import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.oops.FieldIdentifier;

public class BadAddressTreeNodeAdapter
  extends FieldTreeNodeAdapter
{
  private boolean usingAddress;
  private Address addr;
  private long addrValue;
  
  public BadAddressTreeNodeAdapter(Address addr, FieldIdentifier id)
  {
    this(addr, id, false);
  }
  
  public BadAddressTreeNodeAdapter(Address addr, FieldIdentifier id, boolean treeTableMode)
  {
    super(id, treeTableMode);
    this.addr = addr;
    usingAddress = true;
  }
  
  public BadAddressTreeNodeAdapter(long addr, FieldIdentifier id)
  {
    this(addr, id, false);
  }
  
  public BadAddressTreeNodeAdapter(long addrValue, FieldIdentifier id, boolean treeTableMode)
  {
    super(id, treeTableMode);
    this.addrValue = addrValue;
    usingAddress = false;
  }
  
  public int getChildCount()
  {
    return 0;
  }
  
  public SimpleTreeNode getChild(int index)
  {
    throw new RuntimeException("Should not call this");
  }
  
  public boolean isLeaf()
  {
    return true;
  }
  
  public int getIndexOfChild(SimpleTreeNode child)
  {
    throw new RuntimeException("Should not call this");
  }
  
  public String getValue()
  {
    String addrString = null;
    if (usingAddress)
    {
      if (addr == null) {
        addrString = "0x0";
      } else {
        addrString = addr.toString();
      }
    }
    else {
      addrString = "0x" + Long.toHexString(addrValue);
    }
    return "** BAD ADDRESS " + addrString + " **";
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.tree.BadAddressTreeNodeAdapter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.tree;

import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.oops.FieldIdentifier;

public class BadOopTreeNodeAdapter
  extends FieldTreeNodeAdapter
{
  private OopHandle oop;
  
  public BadOopTreeNodeAdapter(OopHandle oop, FieldIdentifier id)
  {
    this(oop, id, false);
  }
  
  public BadOopTreeNodeAdapter(OopHandle oop, FieldIdentifier id, boolean treeTableMode)
  {
    super(id, treeTableMode);
    this.oop = oop;
  }
  
  public int getChildCount()
  {
    return 0;
  }
  
  public SimpleTreeNode getChild(int index)
  {
    throw new RuntimeException("Should not call this");
  }
  
  public boolean isLeaf()
  {
    return true;
  }
  
  public int getIndexOfChild(SimpleTreeNode child)
  {
    throw new RuntimeException("Should not call this");
  }
  
  public String getValue()
  {
    return "** BAD OOP " + oop + " **";
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.tree.BadOopTreeNodeAdapter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.tree;

import sun.jvm.hotspot.oops.FieldIdentifier;

public class BooleanTreeNodeAdapter
  extends FieldTreeNodeAdapter
{
  private boolean val;
  
  public BooleanTreeNodeAdapter(boolean val, FieldIdentifier id)
  {
    this(val, id, false);
  }
  
  public BooleanTreeNodeAdapter(boolean val, FieldIdentifier id, boolean treeTableMode)
  {
    super(id, treeTableMode);
    this.val = val;
  }
  
  public int getChildCount()
  {
    return 0;
  }
  
  public SimpleTreeNode getChild(int index)
  {
    return null;
  }
  
  public boolean isLeaf()
  {
    return true;
  }
  
  public int getIndexOfChild(SimpleTreeNode child)
  {
    return 0;
  }
  
  public String getValue()
  {
    return val ? "true" : "false";
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.tree.BooleanTreeNodeAdapter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.tree;

import sun.jvm.hotspot.oops.FieldIdentifier;

public class CharTreeNodeAdapter
  extends FieldTreeNodeAdapter
{
  private char val;
  
  public CharTreeNodeAdapter(char val, FieldIdentifier id)
  {
    this(val, id, false);
  }
  
  public CharTreeNodeAdapter(char val, FieldIdentifier id, boolean treeTableMode)
  {
    super(id, treeTableMode);
    this.val = val;
  }
  
  public int getChildCount()
  {
    return 0;
  }
  
  public SimpleTreeNode getChild(int index)
  {
    return null;
  }
  
  public boolean isLeaf()
  {
    return true;
  }
  
  public int getIndexOfChild(SimpleTreeNode child)
  {
    return 0;
  }
  
  public String getValue()
  {
    return "'" + val + "'";
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.tree.CharTreeNodeAdapter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.tree;

import sun.jvm.hotspot.oops.FieldIdentifier;

public class CStringTreeNodeAdapter
  extends FieldTreeNodeAdapter
{
  private String val;
  
  public CStringTreeNodeAdapter(String val, FieldIdentifier id)
  {
    this(val, id, false);
  }
  
  public CStringTreeNodeAdapter(String val, FieldIdentifier id, boolean treeTableMode)
  {
    super(id, treeTableMode);
    this.val = val;
  }
  
  public int getChildCount()
  {
    return 0;
  }
  
  public SimpleTreeNode getChild(int index)
  {
    return null;
  }
  
  public boolean isLeaf()
  {
    return true;
  }
  
  public int getIndexOfChild(SimpleTreeNode child)
  {
    return 0;
  }
  
  public String getValue()
  {
    return "\"" + val + "\"";
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.tree.CStringTreeNodeAdapter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.tree;

import sun.jvm.hotspot.oops.FieldIdentifier;
import sun.jvm.hotspot.types.Field;
import sun.jvm.hotspot.types.Type;

class CTypeTreeNodeAdapter$CTypeFieldIdentifier
  extends FieldIdentifier
{
  private final Field field;
  private final Type holder;
  
  CTypeTreeNodeAdapter$CTypeFieldIdentifier(Type t, Field f)
  {
    holder = t;
    field = f;
  }
  
  public Field getField()
  {
    return field;
  }
  
  public String getName()
  {
    return field.getType().getName() + " " + holder.getName() + "::" + field.getName();
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.ui.tree.CTypeTreeNodeAdapter.CTypeFieldIdentifier
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.ui.tree;

import java.util.ArrayList;
import java.util.Iterator;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.AddressException;
import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.oops.FieldIdentifier;
import sun.jvm.hotspot.oops.ObjectHeap;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.oops.UnknownOopException;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.types.CIntegerType;
import sun.jvm.hotspot.types.Field;
import sun.jvm.hotspot.types.JBooleanField;
import sun.jvm.hotspot.types.JByteField;
import sun.jvm.hotspot.types.JCharField;
import sun.jvm.hotspot.types.JDoubleField;
import sun.jvm.hotspot.types.JFloatField;
import sun.jvm.hotspot.types.JIntField;
import sun.jvm.hotspot.types.JLongField;
import sun.jvm.hotspot.types.JShortField;
import sun.jvm.hotspot.types.PointerType;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.utilities.CStringUtilities;

public class CTypeTreeNodeAdapter
  extends FieldTreeNodeAdapter
{
  private final Address addr;
  private final Type type;
  private CTypeFieldIdentifier[] fields = null;
  
  private void collectFields(Type type, ArrayList list, boolean statics, boolean recurse)
  {
    Type supertype = type.getSuperclass();
    if ((supertype != null) && (recurse)) {
      collectFields(supertype, list, statics, recurse);
    }
    Iterator i = type.getFields();
    while (i.hasNext())
    {
      Field f = (Field)i.next();
      if (f.isStatic() == statics) {
        list.add(new CTypeFieldIdentifier(type, f));
      }
    }
  }
  
  private CTypeFieldIdentifier[] getFields()
  {
    if (fields == null)
    {
      ArrayList f = new ArrayList();
      collectFields(type, f, false, true);
      fields = ((CTypeFieldIdentifier[])f.toArray(new CTypeFieldIdentifier[0]));
    }
    return fields;
  }
  
  static class CTypeFieldIdentifier
    extends FieldIdentifier
  {
    private final Field field;
    private final Type holder;
    
    CTypeFieldIdentifier(Type t, Field f)
    {
      holder = t;
      field = f;
    }
    
    public Field getField()
    {
      return field;
    }
    
    public String getName()
    {
      return field.getType().getName() + " " + holder.getName() + "::" + field.getName();
    }
  }
  
  public CTypeTreeNodeAdapter(Address a, Type t, FieldIdentifier id)
  {
    this(a, t, id, false);
  }
  
  public CTypeTreeNodeAdapter(Address a, Type t, FieldIdentifier id, boolean treeTableMode)
  {
    super(id, treeTableMode);
    type = t;
    addr = a;
  }
  
  public CTypeTreeNodeAdapter(Type t)
  {
    super(null, false);
    type = t;
    addr = null;
    ArrayList statics = new ArrayList();
    collectFields(type, statics, true, false);
    fields = ((CTypeFieldIdentifier[])statics.toArray(new CTypeFieldIdentifier[0]));
  }
  
  public CTypeTreeNodeAdapter(Iterator types)
  {
    super(null, false);
    addr = null;
    type = null;
    ArrayList statics = new ArrayList();
    while (types.hasNext()) {
      collectFields((Type)types.next(), statics, true, false);
    }
    fields = ((CTypeFieldIdentifier[])statics.toArray(new CTypeFieldIdentifier[0]));
  }
  
  public int getChildCount()
  {
    return getFields().length;
  }
  
  public SimpleTreeNode getChild(int index)
  {
    CTypeFieldIdentifier cf = getFields()[index];
    Field f = cf.getField();
    Type t = f.getType();
    try
    {
      if (t.isOopType())
      {
        OopHandle handle;
        OopHandle handle;
        if (f.isStatic()) {
          handle = f.getOopHandle();
        } else {
          handle = f.getOopHandle(addr);
        }
        try
        {
          Oop oop = VM.getVM().getObjectHeap().newOop(handle);
          return new OopTreeNodeAdapter(oop, cf, getTreeTableMode());
        }
        catch (AddressException e)
        {
          return new BadOopTreeNodeAdapter(handle, new CTypeFieldIdentifier(type, f), getTreeTableMode());
        }
        catch (UnknownOopException e)
        {
          return new BadOopTreeNodeAdapter(handle, new CTypeFieldIdentifier(type, f), getTreeTableMode());
        }
      }
      if (t.isCIntegerType())
      {
        long value = 0L;
        if (f.isStatic()) {
          value = f.getCInteger((CIntegerType)t);
        } else {
          value = f.getCInteger(addr, (CIntegerType)t);
        }
        return new LongTreeNodeAdapter(value, cf, getTreeTableMode());
      }
      if (t.isJavaPrimitiveType())
      {
        boolean isStatic = f.isStatic();
        if ((f instanceof JByteField))
        {
          long value = isStatic ? f.getJByte() : f.getJByte(addr);
          return new LongTreeNodeAdapter(value, cf, getTreeTableMode());
        }
        if ((f instanceof JShortField))
        {
          long value = isStatic ? f.getJShort() : f.getJShort(addr);
          return new LongTreeNodeAdapter(value, cf, getTreeTableMode());
        }
        if ((f instanceof JIntField))
        {
          long value = isStatic ? f.getJInt() : f.getJInt(addr);
          return new LongTreeNodeAdapter(value, cf, getTreeTableMode());
        }
        if ((f instanceof JLongField))
        {
          long value = isStatic ? f.getJLong() : f.getJLong(addr);
          return new LongTreeNodeAdapter(value, cf, getTreeTableMode());
        }
        if ((f instanceof JCharField))
        {
          char value = isStatic ? f.getJChar() : f.getJChar(addr);
          re
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd