com-sun-tools-visualvm-profiling

16:34:00.219 INFO  jd.cli.Main - Decompiling com-sun-tools-visualvm-profiling.jar
package com.sun.tools.visualvm.profiling;

import com.sun.tools.visualvm.profiling.presets.ProfilerPresets;
import com.sun.tools.visualvm.profiling.snapshot.ProfilerSnapshotsSupport;
import com.sun.tools.visualvm.profiling.snapshot.diff.SnapshotDiffViewProvider;
import org.openide.modules.ModuleInstall;

final class Installer
  extends ModuleInstall
{
  public void restored()
  {
    new SnapshotDiffViewProvider().initialize();
    ProfilerSnapshotsSupport.getInstance();
    ProfilerPresets.getInstance();
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.Installer
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

class PresetSelector$1
  implements Runnable
{
  PresetSelector$1(PresetSelector paramPresetSelector1, PresetSelector paramPresetSelector2, ProfilerPreset paramProfilerPreset) {}
  
  public void run()
  {
    if (val$refSelector != null) {
      PresetSelector.access$002(val$refSelector, this$0);
    }
    PresetSelector.access$100(this$0, val$toSelect);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.PresetSelector.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

class PresetSelector$2
  implements Runnable
{
  PresetSelector$2(PresetSelector paramPresetSelector) {}
  
  public void run()
  {
    PresetSelector.access$200(this$0).run();
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.PresetSelector.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

class PresetSelector$3
  implements ActionListener
{
  PresetSelector$3(PresetSelector paramPresetSelector) {}
  
  public void actionPerformed(ActionEvent e)
  {
    PresetSelector.access$300(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.PresetSelector.3
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

import java.awt.event.ActionEvent;
import javax.swing.JButton;

class PresetSelector$4
  extends JButton
{
  PresetSelector$4(PresetSelector paramPresetSelector, String x0)
  {
    super(x0);
  }
  
  protected void fireActionPerformed(ActionEvent e)
  {
    PresetSelector.access$400(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.PresetSelector.4
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import org.openide.util.NbBundle;

public final class PresetSelector
  extends JPanel
{
  private final Runnable presetSynchronizer;
  private JLabel presetsLabel;
  private JComboBox presetsCombo;
  private JButton presetsButton;
  private PresetSelector refSelector;
  private final ProfilerPreset defaultPreset;
  private ProfilerPreset customPreset;
  private final String selector;
  private boolean savingCustom;
  private boolean customSelected;
  private boolean internalChange = false;
  
  PresetSelector(final PresetSelector refSelector, ProfilerPreset defaultPreset, ProfilerPreset customPreset, final ProfilerPreset toSelect, Runnable presetSynchronizer, String selector)
  {
    this.refSelector = refSelector;
    if (refSelector != null) {
      this.customPreset = customPreset;
    }
    this.selector = selector;
    
    this.presetSynchronizer = presetSynchronizer;
    this.defaultPreset = defaultPreset;
    this.customPreset = customPreset;
    
    initComponents(refSelector);
    
    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
        if (refSelector != null) {
          refSelectorrefSelector = PresetSelector.this;
        }
        PresetSelector.this.updatePresets(toSelect);
      }
    });
  }
  
  public ProfilerPreset getSelectedPreset()
  {
    return (ProfilerPreset)presetsCombo.getSelectedItem();
  }
  
  public ProfilerPreset customize(boolean presetValid)
  {
    if (customPreset == null)
    {
      customPreset = new ProfilerPreset(NbBundle.getMessage(PresetSelector.class, "LBL_Custom"), null);
      if (refSelector != null) {
        refSelector.customPreset = customPreset;
      }
    }
    customPreset.setValid(presetValid);
    internalChange = true;
    if ((presetsCombo.getItemCount() < 2) || (presetsCombo.getItemAt(1) != customPreset)) {
      presetsCombo.insertItemAt(customPreset, 1);
    }
    presetsCombo.setSelectedIndex(1);
    internalChange = false;
    return customPreset;
  }
  
  void presetsChanged(ProfilerPreset selectedPreset)
  {
    updatePresets(savingCustom ? selectedPreset : null);
    savingCustom = false;
  }
  
  private void selectedPresetChanged()
  {
    Object selected = presetsCombo.getSelectedItem();
    if (selected == null) {
      return;
    }
    boolean custom = selected == customPreset;
    if (customSelected != custom)
    {
      customSelected = custom;
      presetsButton.setText(custom ? NbBundle.getMessage(PresetSelector.class, "BTN_Save") : NbBundle.getMessage(PresetSelector.class, "BTN_Edit"));
    }
    updatePresetsButton(true);
    if (internalChange) {
      return;
    }
    notifySynchronizer();
  }
  
  private void actionRequested()
  {
    if (customSelected)
    {
      ProfilerPreset preset = new ProfilerPreset(customPreset);
      preset.setSelector(selector);
      savingCustom = true;
      ProfilerPresets.getInstance().savePreset(preset);
    }
    else
    {
      ProfilerPresets.getInstance().editPresets(getSelectedPreset());
    }
  }
  
  private void notifySynchronizer()
  {
    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
        presetSynchronizer.run();
      }
    });
  }
  
  private void updatePresets(ProfilerPreset toSelect)
  {
    if (toSelect == null) {
      toSelect = (ProfilerPreset)presetsCombo.getSelectedItem();
    }
    internalChange = true;
    
    presetsCombo.removeAllItems();
    presetsCombo.addItem(defaultPreset);
    if (savingCustom) {
      customPreset = null;
    }
    if (customPreset != null) {
      presetsCombo.addItem(customPreset);
    }
    ProfilerPresets.PresetsModel presets = ProfilerPresets.getInstance().getPresets();
    for (int i = 0; i < presets.size(); i++) {
      presetsCombo.addItem(presets.get(i));
    }
    if (toSelect != null) {
      presetsCombo.setSelectedItem(toSelect);
    } else {
      presetsCombo.setSelectedIndex(0);
    }
    internalChange = false;
    notifySynchronizer();
  }
  
  public void setEnabled(boolean enabled)
  {
    super.setEnabled(enabled);
    presetsLabel.setEnabled(enabled);
    presetsCombo.setEnabled(enabled);
    updatePresetsButton(enabled);
  }
  
  private void updatePresetsButton(boolean enabled)
  {
    presetsButton.setEnabled((enabled) && (getSelectedPreset().isValid()));
    if (refSelector != null) {
      refSelector.presetsButton.setEnabled(presetsButton.isEnabled());
    }
  }
  
  private void initComponents(PresetSelector refSelector)
  {
    setOpaque(false);
    setLayout(new BorderLayout(5, 0));
    
    presetsLabel = new JLabel(NbBundle.getMessage(PresetSelector.class, "LBL_Preset"));
    
    presetsLabel.setToolTipText(NbBundle.getMessage(PresetSelector.class, "TOOLTIP_Defined_presets"));
    
    add(presetsLabel, "West");
    
    presetsCombo = (refSelector == null ? new JComboBox() : new JComboBox(presetsCombo.getModel()));
    
    presetsCombo.setToolTipText(NbBundle.getMessage(PresetSelector.class, "TOOLTIP_Defined_presets"));
    
    presetsCombo.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        PresetSelector.this.selectedPresetChanged();
      }
    });
    add(presetsCombo, "Center");
    
    presetsButton = new JButton(NbBundle.getMessage(PresetSelector.class, "BTN_Save"))
    {
      protected void fireActionPerformed(ActionEvent e)
      {
        PresetSelector.this.actionRequested();
      }
    };
    presetsButton.setToolTipText(NbBundle.getMessage(PresetSelector.class, "TOOLTIP_Manage_presets"));
    
    add(presetsButton, "East");
    
    Dimension dim1 = presetsButton.getPreferredSize();
    presetsButton.setText(NbBundle.getMessage(PresetSelector.class, "BTN_Edit"));
    Dimension dim2 = presetsButton.getPreferredSize();
    width = Math.max(width, width);
    height = Math.max(height, height);
    presetsButton.setPreferredSize(dim1);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.PresetSelector
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

class ProfilerCPUPanel$1
  implements DocumentListener
{
  ProfilerCPUPanel$1(ProfilerCPUPanel paramProfilerCPUPanel) {}
  
  public void insertUpdate(DocumentEvent e)
  {
    ProfilerCPUPanel.access$000(this$0);ProfilerCPUPanel.access$100(this$0);
  }
  
  public void removeUpdate(DocumentEvent e)
  {
    ProfilerCPUPanel.access$000(this$0);ProfilerCPUPanel.access$100(this$0);
  }
  
  public void changedUpdate(DocumentEvent e)
  {
    ProfilerCPUPanel.access$000(this$0);ProfilerCPUPanel.access$100(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.ProfilerCPUPanel.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

import java.awt.event.ActionEvent;
import javax.swing.JCheckBox;

class ProfilerCPUPanel$2
  extends JCheckBox
{
  ProfilerCPUPanel$2(ProfilerCPUPanel paramProfilerCPUPanel) {}
  
  protected void fireActionPerformed(ActionEvent e)
  {
    ProfilerCPUPanel.access$100(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.ProfilerCPUPanel.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

import java.awt.event.ActionEvent;
import javax.swing.JRadioButton;

class ProfilerCPUPanel$3
  extends JRadioButton
{
  ProfilerCPUPanel$3(ProfilerCPUPanel paramProfilerCPUPanel) {}
  
  protected void fireActionPerformed(ActionEvent e)
  {
    ProfilerCPUPanel.access$100(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.ProfilerCPUPanel.3
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

import java.awt.event.ActionEvent;
import javax.swing.JRadioButton;

class ProfilerCPUPanel$4
  extends JRadioButton
{
  ProfilerCPUPanel$4(ProfilerCPUPanel paramProfilerCPUPanel) {}
  
  protected void fireActionPerformed(ActionEvent e)
  {
    ProfilerCPUPanel.access$100(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.ProfilerCPUPanel.4
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

class ProfilerCPUPanel$5
  implements DocumentListener
{
  ProfilerCPUPanel$5(ProfilerCPUPanel paramProfilerCPUPanel) {}
  
  public void insertUpdate(DocumentEvent e)
  {
    ProfilerCPUPanel.access$200(this$0);ProfilerCPUPanel.access$100(this$0);
  }
  
  public void removeUpdate(DocumentEvent e)
  {
    ProfilerCPUPanel.access$200(this$0);ProfilerCPUPanel.access$100(this$0);
  }
  
  public void changedUpdate(DocumentEvent e)
  {
    ProfilerCPUPanel.access$200(this$0);ProfilerCPUPanel.access$100(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.ProfilerCPUPanel.5
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

import java.awt.Dimension;
import javax.swing.JTextArea;

final class ProfilerCPUPanel$6
  extends ProfilerCPUPanel.TextAreaComponent
{
  ProfilerCPUPanel$6(JTextArea x0, int x1, int x2, JTextArea paramJTextArea1)
  {
    super(x0, x1, x2);
  }
  
  public Dimension getMinimumSize()
  {
    return getPreferredSize();
  }
  
  public void setEnabled(boolean enabled)
  {
    super.setEnabled(enabled);
    val$rootsArea.setEnabled(enabled);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.ProfilerCPUPanel.6
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JViewport;

class ProfilerCPUPanel$TextAreaComponent
  extends JScrollPane
{
  public ProfilerCPUPanel$TextAreaComponent(JTextArea textArea, int vPolicy, int hPolicy)
  {
    super(textArea, vPolicy, hPolicy);
  }
  
  public JTextArea getTextArea()
  {
    return (JTextArea)getViewport().getView();
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.ProfilerCPUPanel.TextAreaComponent
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import javax.swing.AbstractButton;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JViewport;
import javax.swing.UIManager;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import org.netbeans.lib.profiler.client.ClientUtils.SourceCodeSelection;
import org.netbeans.lib.profiler.common.ProfilingSettings;
import org.netbeans.lib.profiler.common.ProfilingSettingsPresets;
import org.netbeans.lib.profiler.common.filters.FilterUtils;
import org.netbeans.lib.profiler.common.filters.SimpleFilter;
import org.openide.awt.Mnemonics;
import org.openide.util.NbBundle;

public abstract class ProfilerCPUPanel
  extends JPanel
{
  private JLabel rootClassesLabel;
  private TextAreaComponent rootsArea;
  private JCheckBox runnablesCheckBox;
  private JRadioButton inclFilterRadioButton;
  private JRadioButton exclFilterRadioButton;
  private TextAreaComponent filtersArea;
  private final Runnable validator;
  private boolean rootsValid = true;
  private boolean filtersValid = true;
  private boolean internalChange;
  
  public ProfilerCPUPanel()
  {
    this(null, false);
  }
  
  ProfilerCPUPanel(Runnable validator, boolean mnemonics)
  {
    this.validator = validator;
    initComponents(mnemonics);
  }
  
  public ProfilingSettings getSettings()
  {
    ProfilingSettings settings = ProfilingSettingsPresets.createCPUPreset();
    settings.setInstrScheme(1);
    
    String instrFilterString = getFilterValue();
    SimpleFilter instrFilter = (instrFilterString.isEmpty()) || ("*".equals(instrFilterString)) ? SimpleFilter.NO_FILTER : new SimpleFilter(instrFilterString, inclFilterRadioButton.isSelected() ? 2 : 1, instrFilterString);
    
    settings.setSelectedInstrumentationFilter(instrFilter);
    
    String[] rootValues = getRootValue().split(",");
    ClientUtils.SourceCodeSelection[] roots = (rootValues.length == 1) && (rootValues[0].isEmpty()) ? new ClientUtils.SourceCodeSelection[0] : new ClientUtils.SourceCodeSelection[rootValues.length];
    for (int i = 0; i < roots.length; i++) {
      roots[i] = new ClientUtils.SourceCodeSelection(rootValues[i], "*", null);
    }
    settings.setInstrumentationRootMethods(roots);
    
    settings.setInstrumentSpawnedThreads(runnablesCheckBox.isSelected());
    
    return settings;
  }
  
  public boolean settingsValid()
  {
    return (rootsValid) && (filtersValid);
  }
  
  public void loadFromPreset(ProfilerPreset preset)
  {
    if (preset == null) {
      return;
    }
    internalChange = true;
    rootsArea.getTextArea().setText(preset.getRootsP());
    runnablesCheckBox.setSelected(preset.getRunnablesP());
    inclFilterRadioButton.setSelected(!preset.getFilterModeP());
    exclFilterRadioButton.setSelected(preset.getFilterModeP());
    filtersArea.getTextArea().setText(preset.getFilterP());
    internalChange = false;
  }
  
  public void saveToPreset(ProfilerPreset preset)
  {
    if (preset == null) {
      return;
    }
    preset.setRootsP(rootsArea.getTextArea().getText());
    preset.setRunnablesP(runnablesCheckBox.isSelected());
    preset.setFilterModeP(exclFilterRadioButton.isSelected());
    preset.setFilterP(filtersArea.getTextArea().getText());
  }
  
  public abstract void settingsChanged();
  
  private void syncUI()
  {
    if (internalChange) {
      return;
    }
    settingsChanged();
  }
  
  private void checkRootValidity()
  {
    rootsValid = isRootValueValid();
    rootsArea.getTextArea().setForeground(rootsValid ? UIManager.getColor("TextArea.foreground") : Color.RED);
    if (validator != null) {
      validator.run();
    }
  }
  
  public boolean isRootValueValid()
  {
    String[] rootParts = FilterUtils.getSeparateFilters(getRootValue());
    for (int i = 0; i < rootParts.length; i++) {
      if (!FilterUtils.isValidProfilerFilter(rootParts[i])) {
        if (rootParts[i].endsWith("**"))
        {
          if (!FilterUtils.isValidProfilerFilter(rootParts[i].substring(0, rootParts[i].length() - 1))) {
            return false;
          }
        }
        else {
          return false;
        }
      }
    }
    return true;
  }
  
  private String getRootValue()
  {
    StringBuilder convertedValue = new StringBuilder();
    
    String[] rootValues = getRootsValues();
    for (int i = 0; i < rootValues.length; i++)
    {
      String filterValue = rootValues[i].trim();
      if ((i != rootValues.length - 1) && (!filterValue.endsWith(","))) {
        filterValue = filterValue + ",";
      }
      convertedValue.append(filterValue);
    }
    return convertedValue.toString();
  }
  
  private String[] getRootsValues()
  {
    return rootsArea.getTextArea().getText().split("\\n");
  }
  
  private void checkFilterValidity()
  {
    filtersValid = isFilterValueValid();
    filtersArea.getTextArea().setForeground(filtersValid ? UIManager.getColor("TextArea.foreground") : Color.RED);
    if (validator != null) {
      validator.run();
    }
  }
  
  public boolean isFilterValueValid()
  {
    String[] filterParts = FilterUtils.getSeparateFilters(getFilterValue());
    for (int i = 0; i < filterParts.length; i++) {
      if (!FilterUtils.isValidProfilerFilter(filterParts[i])) {
        return false;
      }
    }
    return true;
  }
  
  private String getFilterValue()
  {
    StringBuilder convertedValue = new StringBuilder();
    
    String[] filterValues = getFilterValues();
    for (int i = 0; i < filterValues.length; i++)
    {
      String filterValue = filterValues[i].trim();
      if ((i != filterValues.length - 1) && (!filterValue.endsWith(","))) {
        filterValue = filterValue + ", ";
      }
      convertedValue.append(filterValue);
    }
    return convertedValue.toString();
  }
  
  private String[] getFilterValues()
  {
    return filtersArea.getTextArea().getText().split("\\n");
  }
  
  public void setEnabled(boolean enabled)
  {
    super.setEnabled(enabled);
    for (Component c : getComponents()) {
      c.setEnabled(enabled);
    }
  }
  
  private void initComponents(boolean mnemonics)
  {
    setOpaque(false);
    setLayout(new GridBagLayout());
    
    ButtonGroup filterRadiosGroup = new ButtonGroup();
    
    rootClassesLabel = new JLabel();
    setText(rootClassesLabel, NbBundle.getMessage(ProfilerCPUSettings.class, "LBL_Root_Classes"), mnemonics);
    
    Dimension d = rootClassesLabel.getPreferredSize();
    JRadioButton refRadion = new JRadioButton(NbBundle.getMessage(ProfilerCPUSettings.class, "LBL_Root_Classes"));
    refRadion.setBorder(rootClassesLabel.getBorder());
    height = Math.max(height, getPreferredSizeheight);
    rootClassesLabel.setPreferredSize(d);
    rootClassesLabel.setToolTipText(NbBundle.getMessage(ProfilerCPUSettings.class, "TOOLTIP_Root_Classes"));
    rootClassesLabel.setOpaque(false);
    GridBagConstraints constraints = new GridBagConstraints();
    gridx = 0;
    gridy = 1;
    gridwidth = 0;
    anchor = 17;
    fill = 0;
    insets = new Insets(10, 10, 5, 10);
    add(rootClassesLabel, constraints);
    
    rootsArea = createTextArea(2);
    rootClassesLabel.setLabelFor(rootsArea.getTextArea());
    rootsArea.getTextArea().setToolTipText(NbBundle.getMessage(ProfilerCPUSettings.class, "TOOLTIP_Root_Classes"));
    rootsArea.getTextArea().getDocument().addDocumentListener(new DocumentListener()
    {
      public void insertUpdate(DocumentEvent e)
      {
        ProfilerCPUPanel.this.checkRootValidity();ProfilerCPUPanel.this.syncUI();
      }
      
      public void removeUpdate(DocumentEvent e)
      {
        ProfilerCPUPanel.this.checkRootValidity();ProfilerCPUPanel.this.syncUI();
      }
      
      public void changedUpdate(DocumentEvent e)
      {
        ProfilerCPUPanel.this.checkRootValidity();ProfilerCPUPanel.this.syncUI();
      }
    });
    constraints = new GridBagConstraints();
    gridx = 0;
    gridy = 2;
    weightx = 1.0D;
    weighty = 0.65D;
    gridwidth = 0;
    anchor = 18;
    fill = 1;
    insets = new Insets(0, 10, 7, 10);
    add(rootsArea, constraints);
    
    runnablesCheckBox = new JCheckBox()
    {
      protected void fireActionPerformed(ActionEvent e)
      {
        ProfilerCPUPanel.this.syncUI();
      }
    };
    setText(runnablesCheckBox, NbBundle.getMessage(ProfilerCPUSettings.class, "LBL_Profile_Runnables"), mnemonics);
    
    runnablesCheckBox.setToolTipText(NbBundle.getMessage(ProfilerCPUSettings.class, "TOOLTIP_New_Runnables"));
    runnablesCheckBox.setOpaque(false);
    runnablesCheckBox.setBorder(rootClassesLabel.getBorder());
    constraints = new GridBagConstraints();
    gridx = 0;
    gridy = 3;
    gridwidth = 0;
    anchor = 17;
    fill = 0;
    insets = new Insets(0, 10, 10, 10);
    add(runnablesCheckBox, constraints);
    
    inclFilterRadioButton = new JRadioButton()
    {
      protected void fireActionPerformed(ActionEvent e)
      {
        ProfilerCPUPanel.this.syncUI();
      }
    };
    setText(inclFilterRadioButton, NbBundle.getMessage(ProfilerCPUSettings.class, "LBL_Profile_Incl"), mnemonics);
    
    inclFilterRadioButton.setToolTipText(NbBundle.getMessage(ProfilerCPUSettings.class, "TOOLTIP_Inclusive_Filter"));
    inclFilterRadioButton.setOpaque(false);
    inclFilterRadioButton.setBorder(rootClassesLabel.getBorder());
    filterRadiosGroup.add(inclFilterRadioButton);
    constraints = new GridBagConstraints();
    gridx = 0;
    gridy = 4;
    gridwidth = 1;
    anchor = 17;
    fill = 0;
    insets = new Insets(5, 10, 5, 5);
    add(inclFilterRadioButton, constraints);
    
    exclFilterRadioButton = new JRadioButton()
    {
      protected void fireActionPerformed(ActionEvent e)
      {
        ProfilerCPUPanel.this.syncUI();
      }
    };
    setText(exclFilterRadioButton, NbBundle.getMessage(ProfilerCPUSettings.class, "LBL_Profile_Excl"), mnemonics);
    
    exclFilterRadioButton.setToolTipText(NbBundle.getMessage(ProfilerCPUSettings.class, "TOOLTIP_Exclusive_Filter"));
    exclFilterRadioButton.setOpaque(false);
    exclFilterRadioButton.setBorder(rootClassesLabel.getBorder());
    filterRadiosGroup.add(exclFilterRadioButton);
    constraints = new GridBagConstraints();
    gridx = 1;
    gridy = 4;
    gridwidth = 1;
    anchor = 17;
    fill = 0;
    insets = new Insets(5, 5, 5, 10);
    add(exclFilterRadioButton, constraints);
    
    filtersArea = createTextArea(2);
    filtersArea.getTextArea().setToolTipText(NbBundle.getMessage(ProfilerCPUSettings.class, "TOOLTIP_Instrumentation_Filter"));
    filtersArea.getTextArea().getDocument().addDocumentListener(new DocumentListener()
    {
      public void insertUpdate(DocumentEvent e)
      {
        ProfilerCPUPanel.this.checkFilterValidity();ProfilerCPUPanel.this.syncUI();
      }
      
      public void removeUpdate(DocumentEvent e)
      {
        ProfilerCPUPanel.this.checkFilterValidity();ProfilerCPUPanel.this.syncUI();
      }
      
      public void changedUpdate(DocumentEvent e)
      {
        ProfilerCPUPanel.this.checkFilterValidity();ProfilerCPUPanel.this.syncUI();
      }
    });
    constraints = new GridBagConstraints();
    gridx = 0;
    gridy = 5;
    weighty = 0.35D;
    gridwidth = 0;
    anchor = 18;
    fill = 1;
    insets = new Insets(0, 10, 10, 10);
    add(filtersArea, constraints);
  }
  
  private static void setText(JLabel l, String text, boolean mnemonics)
  {
    if (mnemonics) {
      Mnemonics.setLocalizedText(l, text);
    } else {
      l.setText(text.replace("&", ""));
    }
  }
  
  private static void setText(AbstractButton b, String text, boolean mnemonics)
  {
    if (mnemonics) {
      Mnemonics.setLocalizedText(b, text);
    } else {
      b.setText(text.replace("&", ""));
    }
  }
  
  private static TextAreaComponent createTextArea(int rows)
  {
    final JTextArea rootsArea = new JTextArea();
    rootsArea.setFont(new Font("Monospaced", 0, UIManager.getFont("Label.font").getSize()));
    TextAreaComponent rootsAreaScrollPane = new TextAreaComponent(rootsArea, 20, 30)
    {
      public Dimension getMinimumSize()
      {
        return getPreferredSize();
      }
      
      public void setEnabled(boolean enabled)
      {
        super.setEnabled(enabled);
        rootsArea.setEnabled(enabled);
      }
    };
    rootsAreaScrollPane.setBorder(BorderFactory.createLineBorder(Color.GRAY));
    JTextArea referenceArea = new JTextArea("X");
    referenceArea.setFont(rootsArea.getFont());
    referenceArea.setRows(rows);
    Insets insets = rootsAreaScrollPane.getInsets();
    rootsAreaScrollPane.setPreferredSize(new Dimension(1, getPreferredSizeheight + (insets != null ? top + bottom : 0)));
    
    return rootsAreaScrollPane;
  }
  
  private static class TextAreaComponent
    extends JScrollPane
  {
    public TextAreaComponent(JTextArea textArea, int vPolicy, int hPolicy)
    {
      super(vPolicy, hPolicy);
    }
    
    public JTextArea getTextArea()
    {
      return (JTextArea)getViewport().getView();
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.ProfilerCPUPanel
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

class ProfilerCPUSettings$1
  extends ProfilerCPUPanel
{
  ProfilerCPUSettings$1(ProfilerCPUSettings paramProfilerCPUSettings, Runnable x0, boolean x1)
  {
    super(x0, x1);
  }
  
  public void settingsChanged()
  {
    ProfilerCPUSettings.access$100(this$0).saveToPreset(ProfilerCPUSettings.access$000(this$0));
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.ProfilerCPUSettings.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

import java.awt.BorderLayout;
import java.awt.Component;
import javax.swing.JPanel;

final class ProfilerCPUSettings
  extends JPanel
{
  private ProfilerPreset preset;
  private final ProfilerCPUPanel panel;
  
  ProfilerCPUSettings(Runnable validator)
  {
    panel = new ProfilerCPUPanel(validator, true)
    {
      public void settingsChanged()
      {
        panel.saveToPreset(preset);
      }
    };
    setLayout(new BorderLayout());
    add(panel, "Center");
  }
  
  void setPreset(ProfilerPreset preset)
  {
    this.preset = preset;
    panel.loadFromPreset(preset);
  }
  
  boolean valid()
  {
    return panel.settingsValid();
  }
  
  public void setEnabled(boolean enabled)
  {
    super.setEnabled(enabled);
    for (Component c : getComponents()) {
      c.setEnabled(enabled);
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.ProfilerCPUSettings
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

import java.awt.event.ActionEvent;
import javax.swing.JRadioButton;

class ProfilerMemoryPanel$1
  extends JRadioButton
{
  ProfilerMemoryPanel$1(ProfilerMemoryPanel paramProfilerMemoryPanel) {}
  
  protected void fireActionPerformed(ActionEvent e)
  {
    ProfilerMemoryPanel.access$000(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.ProfilerMemoryPanel.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

import java.awt.event.ActionEvent;
import javax.swing.JRadioButton;

class ProfilerMemoryPanel$2
  extends JRadioButton
{
  ProfilerMemoryPanel$2(ProfilerMemoryPanel paramProfilerMemoryPanel) {}
  
  protected void fireActionPerformed(ActionEvent e)
  {
    ProfilerMemoryPanel.access$000(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.ProfilerMemoryPanel.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

import java.awt.Component;
import java.awt.LayoutManager;
import javax.swing.JPanel;

class ProfilerMemoryPanel$3
  extends JPanel
{
  ProfilerMemoryPanel$3(ProfilerMemoryPanel paramProfilerMemoryPanel, LayoutManager x0)
  {
    super(x0);
  }
  
  public void setEnabled(boolean enabled)
  {
    super.setEnabled(enabled);
    for (Component c : getComponents()) {
      c.setEnabled(enabled);
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.ProfilerMemoryPanel.3
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

import com.sun.tools.visualvm.uisupport.JExtendedSpinner;
import java.awt.Dimension;
import java.awt.event.FocusEvent;
import javax.swing.SpinnerModel;

class ProfilerMemoryPanel$4
  extends JExtendedSpinner
{
  ProfilerMemoryPanel$4(ProfilerMemoryPanel paramProfilerMemoryPanel, SpinnerModel x0)
  {
    super(x0);
  }
  
  public Dimension getPreferredSize()
  {
    return new Dimension(55, getPreferredSizeheight);
  }
  
  public Dimension getMinimumSize()
  {
    return getPreferredSize();
  }
  
  protected void processFocusEvent(FocusEvent e)
  {
    super.processFocusEvent(e);
    ProfilerMemoryPanel.access$000(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.ProfilerMemoryPanel.4
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

class ProfilerMemoryPanel$5
  implements ChangeListener
{
  ProfilerMemoryPanel$5(ProfilerMemoryPanel paramProfilerMemoryPanel) {}
  
  public void stateChanged(ChangeEvent e)
  {
    ProfilerMemoryPanel.access$000(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.ProfilerMemoryPanel.5
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

import javax.swing.JSpinner;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

class ProfilerMemoryPanel$6
  implements DocumentListener
{
  ProfilerMemoryPanel$6(ProfilerMemoryPanel paramProfilerMemoryPanel) {}
  
  public void insertUpdate(DocumentEvent e)
  {
    try
    {
      ProfilerMemoryPanel.access$100(this$0).commitEdit();
    }
    catch (Exception ex) {}
  }
  
  public void removeUpdate(DocumentEvent e)
  {
    try
    {
      ProfilerMemoryPanel.access$100(this$0).commitEdit();
    }
    catch (Exception ex) {}
  }
  
  public void changedUpdate(DocumentEvent e)
  {
    try
    {
      ProfilerMemoryPanel.access$100(this$0).commitEdit();
    }
    catch (Exception ex) {}
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.ProfilerMemoryPanel.6
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

import java.awt.event.ActionEvent;
import javax.swing.JCheckBox;

class ProfilerMemoryPanel$7
  extends JCheckBox
{
  ProfilerMemoryPanel$7(ProfilerMemoryPanel paramProfilerMemoryPanel) {}
  
  protected void fireActionPerformed(ActionEvent e)
  {
    ProfilerMemoryPanel.access$000(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.profiling.presets.ProfilerMemoryPanel.7
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.profiling.presets;

import com.sun.tools.visualvm.core.ui.components.Spacer;
import com.sun.tools.visualvm.uisupport.JExtendedSpinner;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.FocusEvent;
import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;
import javax.swing.JCheckBox;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JSpinner;
import javax.swing.JSpinner.DefaultEditor;
import javax.swing.SpinnerModel;
import javax.swing.SpinnerNumberModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import org.netbeans.lib.profiler.common.ProfilingSettings;
import org.netbeans.lib.profiler.common.ProfilingSettingsPresets;
import org.openide.awt.Mnemonics;
import org.openide.util.NbBundle;

public abstract class ProfilerMemoryPanel
  extends JPanel
{
  private JRadioButton allocRadioButton;
  private JRadioButton livenessRadioButton;
  private JCheckBox stackTracesCheckBox;
  private JLabel trackEveryLabel1;
  private JLabel trackEveryLabel2;
  private JSpinner trackEverySpinner;
  private boolean internalChange;
  
  public ProfilerMemoryPanel()
  {
    this(false);
  }
  
  ProfilerMemoryPanel(boolean mnemonics)
  {
    initComponents(mnemonics);
  }
  
  public ProfilingSettings getSettings()
  {
    ProfilingSettings settings = allocRadioButton.isSelected() ? ProfilingSettingsPresets.createMemoryPreset(2) : ProfilingSettingsPresets.createMemoryPreset(4);
    
    settings.setAllocStackTraceLimit(stackTracesCheckBox.isSelected() ? -1 : 0);
    settings.setAllocTrackEvery(((Integer)trackEverySpinner.getValue()).intValue());
    
    return settings;
  }
  
  public boolean settingsValid()
  {
    return true;
  }
  
  public void loadFromPreset(ProfilerPreset preset)
  {
    if (preset == null) {
      return;
    }
    internalChange = true;
    allocRadioButton.setSelected(!preset.getMemoryModeP());
    livenessRadioButton.setSelected(preset.getMemoryModeP());
    stackTracesCheckBox.setSelected(preset.getStacksP());
    trackEverySpinner.setValue(Integer.valueOf(preset.getAllocP()));
    internalChange = false;
  }
  
  public void saveToPreset(ProfilerPreset preset)
  {
    if (preset == null) {
      return;
    }
    preset.setMemoryModeP(livenessRadioButton.isSelected());
    preset.setStacksP(stackTracesCheckBox.isSelected());
    preset.setAllocP(((Integer)trackEverySpinner.getValue()).intValue());
  }
  
  public abstract void settingsChanged();
  
  private void syncUI()
  {
    if (internalChange) {
      return;
    }
    settingsChanged();
  }
  
  public void setEnabled(boolean enabled)
  {
    super.setEnabled(enabled);
    for (Component c : getComponents()) {
      c.setEnabled(enabled);
    }
  }
  
  private void initComponents(boolean mnemonics)
  {
    setOpaque(false);
    setLayout(new GridBagLayout());
    
    JLabel referenceLabel = new JLabel("X");
    
    ButtonGroup modesRadioGroup = new ButtonGroup();
    
    allocRadioButton = new JRadioButton()
    {
      protected void fireActionPerformed(ActionEvent e)
      {
        ProfilerMemoryPanel.this.syncUI();
      }
    };
    setText(allocRadioButton, NbBundle.getMessage(ProfilerMemorySettings.class, "LBL_Profile_Allocations"), mnemonics);
    
    allocRadioButton.setToolTipText(NbBundle.getMessage(ProfilerMemorySettings.class, "TOOLTIP_Allocations"));
    allocRadioButton.setOpaque(false);
    allocRadioButton.setBorder(referenceLabel.getBorder());
    modesRadioGroup.add(allocRadioButton);
    GridBagConstraints constraints = new GridBagConstraints();
    gridx = 0;
    gridy = 0;
    gridwidth = 0;
    anchor = 17;
    fill = 0;
    insets = new Insets(10, 10, 10, 10);
    add(allocRadioButton, constraints);
    
    livenessRadioButton = new JRadioButton()
    {
      protected void fireActionPerformed(ActionEvent e)
      {
        ProfilerMemoryPanel.this.syncUI();
      }
    };
    setText(livenessRadioButton, NbBundle.getMessage(ProfilerMemorySettings.class, "LBL_Profile_AllocationsGC"), mnemonics);
    
    livenessRadioButton.setToolTipText(NbBundle.getMessage(ProfilerMemorySettings.class, "TOOLTIP_Allocations_GC"));
    livenessRadioButton.setOpaque(false);
    livenessRadioButton.setBorder(referenceLabel.getBorder());
    modesRadioGroup.add(livenessRadioButton);
    constraints = new GridBagConstraints();
    gridx = 0;
    gridy = 1;
    gridwidth = 0;
    anchor = 17;
    fill = 0;
    insets = new Insets(0, 10, 10, 10);
    add(livenessRadioButton, constraints);
    
    JPanel trackEveryContainer = new JPanel(new GridBagLayout())
    {
      public void setEnabled(boolean enabled)
      {
        super.setEnabled(enabled);
        for (Component c : getComponents()) {
          c.setEnabled(enabled);
        }
      }
    };
    trackEveryLabel1 = new JLabel();
    setText(trackEveryLabel1, NbBundle.getMessage(ProfilerMemorySettings.class, "LBL_Track_Every1"), mnemonics);
    
    trackEveryLabel1.setToolTipText(NbBundle.getMessage(ProfilerMemorySettings.class, "TOOLTIP_Track_Every"));
    trackEveryLabel1.setOpaque(false);
    constraints = new GridBagConstraints();
    gridx = 0;
    gridy = 0;
    gridwidth = 1;
    fill = 0;
    anchor = 17;
    insets = new Insets(0, 0, 0, 5);
    trackEveryContainer.add(trackEveryLabel1, constraints);
    
    trackEverySpinner = new JExtendedSpinner(new SpinnerNumberModel(10, 1, Integer.MAX_VALUE, 1))
    {
      public Dimension getPreferredSize()
      {
        return new Dimension(55, getPreferredSizeheight);
      }
      
      public Dimension getMinimumSize()
      {
        return getPreferredSize();
      }
      
      protected void processFocusEvent(FocusEvent e)
      {
        super.processFocusEvent(e);
        ProfilerMemoryPanel.this.syncUI();
      }
    };
    trackEverySpinner.addChangeListener(new ChangeListener()
    {
      public void stateChanged(ChangeEvent e)
      {
        ProfilerMemoryPanel.this.syncUI();
      }
    });
    JSpinner.DefaultEditor editor = (JSpinner.DefaultEditor)trackEverySpinner.getEditor();
    editor.getTextField().getDocument().addDocumentListener(new DocumentListener()
    {
      public void insertUpdate(DocumentEvent e)
      {
        try
        {
          trackEverySpinner.commitEdit();
        }
        catch (Exception ex) {}
      }
      
      public void removeUpdate(DocumentEvent e)
     
1 2 3 4 5

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