com-sun-tools-visualvm-modules-appui

16:33:56.747 INFO  jd.cli.Main - Decompiling com-sun-tools-visualvm-modules-appui.jar
package com.sun.tools.visualvm.modules.appui;

import com.sun.tools.visualvm.modules.appui.about.AboutDialog;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
import org.openide.util.Enumerations;
import org.openide.util.NbBundle;
import org.openide.util.Utilities;
import org.openide.windows.WindowManager;

public final class AboutAction
  extends AbstractAction
{
  private static final Logger LOGGER = Logger.getLogger(AboutAction.class.getName());
  private String versionString = System.getProperty("java.version");
  private AboutDialog aboutDialog;
  private String buildNumber;
  private String details;
  
  public AboutAction()
  {
    putValue("Name", NbBundle.getMessage(AboutAction.class, "CTL_AboutAction"));
    putValue("noIconInMenu", Boolean.TRUE);
  }
  
  public void actionPerformed(ActionEvent e)
  {
    AboutDialog ad = getAboutDialog();
    if (ad != null) {
      ad.show();
    }
  }
  
  static AboutAction getMenuAction()
  {
    if (Utilities.isMac()) {
      return null;
    }
    return new AboutAction();
  }
  
  private AboutDialog getAboutDialog()
  {
    if (aboutDialog == null) {
      try
      {
        URL imageURL = getClass().getResource("/com/sun/tools/visualvm/modules/appui/about/image.png");
        Image splashImage = Toolkit.getDefaultToolkit().createImage(imageURL);
        aboutDialog = AboutDialog.createInstance(WindowManager.getDefault().getMainWindow(), splashImage);
        aboutDialog.setCaption(NbBundle.getMessage(AboutAction.class, "LBL_About_VisualVM"));
        aboutDialog.setBuildID(NbBundle.getMessage(AboutAction.class, "LBL_Version_Build", new Object[] { versionString, getBuildNumber() }));
        aboutDialog.setDetails(getDetails());
        aboutDialog.setLogfile(getLogfile());
      }
      catch (Exception e)
      {
        LOGGER.throwing(AboutAction.class.getName(), "getAboutDialog", e);
      }
    }
    return aboutDialog;
  }
  
  private String getBuildNumber()
  {
    if (buildNumber == null)
    {
      buildNumber = "unknown";
      try
      {
        InputStream manifestStream = getClass().getResourceAsStream("/META-INF/MANIFEST.MF");
        buildNumber = new Manifest(manifestStream).getMainAttributes().getValue("OpenIDE-Module-Implementation-Version");
      }
      catch (IOException ex) {}
    }
    return buildNumber;
  }
  
  private String getLogfile()
  {
    String sep = File.separator;
    String logfilePath = System.getProperty("netbeans.user") + sep + "var" + sep + "log" + sep + "messages.log";
    File logfile = new File(logfilePath);
    if ((logfile.exists()) && (logfile.isFile()) && (logfile.canRead())) {
      return logfile.getAbsolutePath();
    }
    return null;
  }
  
  private String getDetails()
  {
    if (details == null)
    {
      StringBuffer sb = new StringBuffer();
      
      sb.append("<table border=\"0\">");
      
      sb.append("<tr>");
      sb.append("<td valign=\"top\" nowrap><b>Version: </b></td>");
      sb.append("<td valign=\"top\" nowrap>" + versionString + " (Build 1320-" + getBuildNumber() + "); platform " + System.getProperty("netbeans.buildnumber") + "</td>");
      sb.append("</tr>");
      
      sb.append("<tr>");
      sb.append("<td valign=\"top\" nowrap><b>System: </b></td>");
      sb.append("<td valign=\"top\" nowrap>" + getOSInfo() + "</td>");
      sb.append("</tr>");
      
      sb.append("<tr>");
      sb.append("<td valign=\"top\" nowrap><b>Java: </b></td>");
      sb.append("<td valign=\"top\" nowrap>" + getJavaInfo() + "</td>");
      sb.append("</tr>");
      
      sb.append("<tr>");
      sb.append("<td valign=\"top\" nowrap><b>Vendor: </b></td>");
      sb.append("<td valign=\"top\" nowrap>" + getJavaVendor() + "</td>");
      sb.append("</tr>");
      
      sb.append("<tr>");
      sb.append("<td valign=\"top\" nowrap><b>Environment: </b></td>");
      sb.append("<td valign=\"top\" nowrap>" + getEnvironment() + "</td>");
      sb.append("</tr>");
      
      sb.append("<tr>");
      sb.append("<td valign=\"top\" nowrap><b>Userdir: </b></td>");
      sb.append("<td valign=\"top\" nowrap>" + System.getProperty("netbeans.user", "unknown") + "</td>");
      sb.append("</tr>");
      
      sb.append("<tr>");
      sb.append("<td valign=\"top\" nowrap><b>Clusters: </b></td>");
      sb.append("<td valign=\"top\" nowrap>" + getIDEInstallValue() + "</td>");
      sb.append("</tr>");
      
      sb.append("</table>");
      
      sb.append("<div style='margin: 4px; margin-top: 15px; margin-bottom: 0px;'>");
      sb.append(NbBundle.getMessage(AboutAction.class, "MSG_Html_License"));
      sb.append("</div>");
      
      details = sb.toString();
    }
    return details;
  }
  
  private static String getOSInfo()
  {
    Properties systemProperties = System.getProperties();
    String osName = systemProperties.getProperty("os.name", "&lt;not available&gt;");
    String osVersion = systemProperties.getProperty("os.version", "");
    String patchLevel = systemProperties.getProperty("sun.os.patch.level", "");
    String osArch = systemProperties.getProperty("os.arch", "&lt;not available&gt;");
    String sunArch = systemProperties.getProperty("sun.arch.data.model", "?") + "bit";
    return osName + " (" + osVersion + ") " + ("unknown".equals(patchLevel) ? "" : patchLevel) + ", " + osArch + " " + sunArch;
  }
  
  private static String getJavaInfo()
  {
    Properties systemProperties = System.getProperties();
    String javaVersion = systemProperties.getProperty("java.version", "unknown");
    String vmName = systemProperties.getProperty("java.vm.name", "&lt;not available&gt;");
    String vmVerison = systemProperties.getProperty("java.vm.version", "");
    String vmInfo = systemProperties.getProperty("java.vm.info", "");
    return javaVersion + "; " + vmName + " (" + vmVerison + ", " + vmInfo + ")";
  }
  
  private static String getJavaVendor()
  {
    Properties systemProperties = System.getProperties();
    String javaVendor = systemProperties.getProperty("java.vendor", "unknown");
    String javaVendorUrl = systemProperties.getProperty("java.vendor.url", null);
    return javaVendor + (javaVendorUrl == null ? "" : new StringBuilder().append(", ").append(javaVendorUrl).toString());
  }
  
  private static String getEnvironment()
  {
    String branding = NbBundle.getBranding();
    String encoding = System.getProperty("file.encoding", "unknown");
    String locale = Locale.getDefault().toString() + (branding == null ? "" : new StringBuilder().append(" (").append(branding).append(")").toString());
    return encoding + "; " + locale;
  }
  
  private static String getIDEInstallValue()
  {
    String nbhome = System.getProperties().getProperty("netbeans.home");
    String nbdirs = System.getProperty("netbeans.dirs");
    Enumeration<Object> more;
    Enumeration<Object> more;
    if (nbdirs != null) {
      more = new StringTokenizer(nbdirs, File.pathSeparator);
    } else {
      more = Enumerations.empty();
    }
    Enumeration<Object> all = Enumerations.concat(Enumerations.singleton(nbhome), more);
    
    Set<File> files = new HashSet();
    StringBuilder sb = new StringBuilder();
    String prefix = "";
    while (all.hasMoreElements())
    {
      String s = (String)all.nextElement();
      if (s != null)
      {
        File f = new File(s);
        if (files.add(f))
        {
          sb.append(prefix);
          try
          {
            sb.append(f.getCanonicalPath());
          }
          catch (IOException e)
          {
            sb.append(f.getAbsolutePath());
          }
          prefix = "\n";
        }
      }
    }
    return sb.toString();
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.AboutAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui;

import com.sun.tools.visualvm.modules.appui.proxysettings.ProxySettingsHack;
import org.openide.modules.ModuleInstall;

public class Install
  extends ModuleInstall
{
  public void restored() {}
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.Install
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

class AboutDialog$1
  extends WindowAdapter
{
  AboutDialog$1(AboutDialog paramAboutDialog) {}
  
  public void windowClosed(WindowEvent e)
  {
    AboutDialog.access$000(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.AboutDialog.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

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

class AboutDialog$2
  extends AbstractAction
{
  AboutDialog$2(AboutDialog paramAboutDialog) {}
  
  public void actionPerformed(ActionEvent e)
  {
    this$0.close();
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.AboutDialog.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JRootPane;
import javax.swing.KeyStroke;
import org.openide.util.NbBundle;

public class AboutDialog
{
  private static AboutDialog instance;
  private AboutDialogPanel aboutDialogPanel;
  private AboutDialogControls aboutDialogControls;
  private JDialog dialog;
  private String buildID;
  private String details;
  private String logfile;
  private Frame parentFrame;
  private Image aboutImage;
  
  public static synchronized AboutDialog createInstance(Frame parentFrame, Image aboutImage)
  {
    if (instance != null) {
      instance.close();
    }
    instance = new AboutDialog(parentFrame, aboutImage);
    instance.initComponents();
    return instance;
  }
  
  public static synchronized AboutDialog getInstance()
  {
    if (instance == null)
    {
      instance = new AboutDialog();
      instance.initComponents();
    }
    return instance;
  }
  
  public void setCaption(String caption)
  {
    dialog.setTitle(caption);
  }
  
  public String getCaption()
  {
    return dialog.getTitle();
  }
  
  public void setBuildID(String buildID)
  {
    this.buildID = buildID;
  }
  
  public String getBuildID()
  {
    return buildID;
  }
  
  public void setDetails(String details)
  {
    this.details = details;
  }
  
  public String getDetails()
  {
    return details;
  }
  
  public void setLogfile(String logfile)
  {
    this.logfile = logfile;
  }
  
  public String getLogfile()
  {
    return logfile;
  }
  
  public void show()
  {
    aboutDialogControls.updateAppearance();
    dialog.pack();
    aboutDialogControls.getDefaultButton().requestFocusInWindow();
    dialog.setLocationRelativeTo(parentFrame);
    dialog.setVisible(true);
  }
  
  public void close()
  {
    dialog.setVisible(false);
    dialog.dispose();
  }
  
  Image getAboutImage()
  {
    return aboutImage;
  }
  
  void setDefaultButton(JButton button)
  {
    dialog.getRootPane().setDefaultButton(button);
  }
  
  JDialog getDialog()
  {
    return dialog;
  }
  
  private AboutDialog()
  {
    this(null, new BufferedImage(400, 300, 1));
  }
  
  private AboutDialog(Frame parentFrame, Image aboutImage)
  {
    this.parentFrame = parentFrame;
    this.aboutImage = aboutImage;
  }
  
  private void initComponents()
  {
    dialog = new JDialog(parentFrame, NbBundle.getMessage(AboutDialog.class, "LBL_About"), true);
    dialog.addWindowListener(new WindowAdapter()
    {
      public void windowClosed(WindowEvent e)
      {
        AboutDialog.this.cleanup();
      }
    });
    JComponent contentPane = (JComponent)dialog.getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.getInputMap(1).put(KeyStroke.getKeyStroke(27, 0), "CLOSE_ACTION");
    
    contentPane.getActionMap().put("CLOSE_ACTION", new AbstractAction()
    {
      public void actionPerformed(ActionEvent e)
      {
        close();
      }
    });
    aboutDialogPanel = new AboutDialogPanel();
    aboutDialogControls = new AboutDialogControls();
    
    contentPane.add(aboutDialogPanel, "Center");
    contentPane.add(aboutDialogControls, "South");
    
    dialog.getRootPane().setDefaultButton(aboutDialogControls.getDefaultButton());
    dialog.setResizable(false);
    dialog.setDefaultCloseOperation(2);
  }
  
  private void cleanup() {}
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.AboutDialog
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

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

class AboutDialogControls$1
  implements ActionListener
{
  AboutDialogControls$1(AboutDialogControls paramAboutDialogControls) {}
  
  public void actionPerformed(ActionEvent e)
  {
    AboutDialogControls.access$000(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.AboutDialogControls.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

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

class AboutDialogControls$2
  implements ActionListener
{
  AboutDialogControls$2(AboutDialogControls paramAboutDialogControls) {}
  
  public void actionPerformed(ActionEvent e)
  {
    AboutDialogControls.access$100(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.AboutDialogControls.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

class AboutDialogControls$3$1
  implements Runnable
{
  AboutDialogControls$3$1(AboutDialogControls.3 param3) {}
  
  public void run()
  {
    AboutDialog.getInstance().close();
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.AboutDialogControls.3.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.SwingUtilities;

class AboutDialogControls$3
  implements ActionListener
{
  AboutDialogControls$3(AboutDialogControls paramAboutDialogControls) {}
  
  public void actionPerformed(ActionEvent e)
  {
    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
        AboutDialog.getInstance().close();
      }
    });
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.AboutDialogControls.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import org.openide.util.NbBundle;

class AboutDialogControls$4
  extends JButton
{
  AboutDialogControls$4(AboutDialogControls paramAboutDialogControls, TextBrowser paramTextBrowser) {}
  
  protected void fireActionPerformed(ActionEvent event)
  {
    val$tb.copyAllHtmlToClipboard();
    JOptionPane.showMessageDialog(AboutDialog.getInstance().getDialog(), NbBundle.getMessage(AboutDialogControls.class, "MSG_Copy_Clipboard"), NbBundle.getMessage(AboutDialogControls.class, "CAPTION_Copy_Clipbard"), 1);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.AboutDialogControls.4
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

import com.sun.tools.visualvm.core.ui.DesktopUtils;
import java.io.File;
import java.util.logging.Logger;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import org.openide.util.NbBundle;

class AboutDialogControls$5
  implements Runnable
{
  AboutDialogControls$5(AboutDialogControls paramAboutDialogControls) {}
  
  public void run()
  {
    AboutDialogControls.access$200(this$0).setEnabled(false);
    
    File logfile = new File(AboutDialog.getInstance().getLogfile());
    try
    {
      if ((!logfile.exists()) || (!logfile.isFile()) || (!logfile.canRead()))
      {
        JOptionPane.showMessageDialog(AboutDialog.getInstance().getDialog(), NbBundle.getMessage(AboutDialogControls.class, "LBL_Cannot_open_the_logfile", logfile.getAbsolutePath()), NbBundle.getMessage(AboutDialogControls.class, "LBL_Error"), 0);
      }
      else
      {
        TextBrowser.getInstance().setCaption(NbBundle.getMessage(AboutDialogControls.class, "LBL_Logfile_Viewer_", logfile.getAbsolutePath()));
        if (DesktopUtils.isOpenAvailable()) {
          try
          {
            DesktopUtils.open(logfile);
          }
          catch (Exception ex)
          {
            AboutDialogControls.access$300(this$0, logfile);
            AboutDialogControls.access$400().throwing(AboutDialogControls.class.getName(), "showLogFile", ex);
          }
        } else {
          AboutDialogControls.access$300(this$0, logfile);
        }
      }
    }
    catch (Exception e)
    {
      AboutDialogControls.access$400().throwing(AboutDialogControls.class.getName(), "showLogFile", e);
      JOptionPane.showMessageDialog(AboutDialog.getInstance().getDialog(), NbBundle.getMessage(AboutDialogControls.class, "LBL_Cannot_open_the_logfile", logfile.getAbsolutePath()), NbBundle.getMessage(AboutDialogControls.class, "LBL_Error"), 0);
    }
    finally
    {
      AboutDialogControls.access$200(this$0).setEnabled(true);
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.AboutDialogControls.5
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

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

class AboutDialogControls$6$1
  extends JButton
{
  AboutDialogControls$6$1(AboutDialogControls.6 param6) {}
  
  protected void fireActionPerformed(ActionEvent event)
  {
    AboutDialogControls.access$500(this$1.this$0, this$1.val$logfile);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.AboutDialogControls.6.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.io.File;
import javax.swing.JButton;
import org.openide.awt.Mnemonics;
import org.openide.util.NbBundle;

class AboutDialogControls$6
  implements Runnable
{
  AboutDialogControls$6(AboutDialogControls paramAboutDialogControls, String paramString, File paramFile) {}
  
  public void run()
  {
    String string = val$logfileContents;
    if (string.length() == 0) {
      string = NbBundle.getMessage(AboutDialogControls.class, "MSG_Logfile_notready");
    }
    TextBrowser tb = TextBrowser.getInstance();
    JButton helperButton = new JButton()
    {
      protected void fireActionPerformed(ActionEvent event)
      {
        AboutDialogControls.access$500(this$0, val$logfile);
      }
    };
    Mnemonics.setLocalizedText(helperButton, NbBundle.getMessage(AboutDialogControls.class, "BTN_Save_file"));
    helperButton.setEnabled(val$logfileContents.length() > 0);
    tb.setPreferredBrowserSize(new Dimension(700, 550));
    tb.setHelperButton(helperButton);
    tb.showCodeText(string);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.AboutDialogControls.6
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

import org.netbeans.api.progress.ProgressHandle;

class AboutDialogControls$7$1
  implements Runnable
{
  AboutDialogControls$7$1(AboutDialogControls.7 param7, ProgressHandle paramProgressHandle) {}
  
  public void run()
  {
    if (val$pHandleF != null) {
      val$pHandleF.finish();
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.AboutDialogControls.7.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

import com.sun.tools.visualvm.core.datasupport.Utils;
import java.io.File;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import org.netbeans.api.progress.ProgressHandle;
import org.netbeans.api.progress.ProgressHandleFactory;
import org.openide.util.NbBundle;

class AboutDialogControls$7
  implements Runnable
{
  AboutDialogControls$7(AboutDialogControls paramAboutDialogControls, File paramFile1, File paramFile2) {}
  
  public void run()
  {
    ProgressHandle pHandle = null;
    try
    {
      pHandle = ProgressHandleFactory.createHandle(NbBundle.getMessage(AboutDialogControls.class, "MSG_Saving_logfile", val$file.getName()));
      
      pHandle.setInitialDelay(0);
      pHandle.start();
      if (!Utils.copyFile(val$file, val$copy)) {
        JOptionPane.showMessageDialog(AboutDialog.getInstance().getDialog(), NbBundle.getMessage(AboutDialogControls.class, "MSG_Save_logfile_failed"), NbBundle.getMessage(AboutDialogControls.class, "CAPTION_Save_logfile_failed"), 0);
      }
    }
    finally
    {
      final ProgressHandle pHandleF;
      ProgressHandle pHandleF = pHandle;
      SwingUtilities.invokeLater(new Runnable()
      {
        public void run()
        {
          if (pHandleF != null) {
            pHandleF.finish();
          }
        }
      });
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.AboutDialogControls.7
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

import com.sun.tools.visualvm.core.datasupport.Utils;
import com.sun.tools.visualvm.core.ui.DesktopUtils;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.RandomAccessFile;
import java.util.logging.Logger;
import javax.accessibility.AccessibleContext;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import org.netbeans.api.progress.ProgressHandle;
import org.netbeans.api.progress.ProgressHandleFactory;
import org.openide.awt.Mnemonics;
import org.openide.util.NbBundle;
import org.openide.util.RequestProcessor;
import org.openide.windows.WindowManager;

public class AboutDialogControls
  extends JPanel
{
  private static final Logger LOGGER = Logger.getLogger(AboutDialogControls.class.getName());
  private JLabel buildIDLabel;
  private JButton closeButton;
  private JButton detailsButton;
  private JButton logfileButton;
  private JPanel buttonsContainer;
  private String lastLogfileSave;
  
  AboutDialogControls()
  {
    initComponents();
    
    lastLogfileSave = System.getProperty("user.home");
    if (!new File(lastLogfileSave).isDirectory())
    {
      lastLogfileSave = System.getProperty("java.io.tmpdir");
      if (!new File(lastLogfileSave).isDirectory()) {
        lastLogfileSave = null;
      }
    }
    if (lastLogfileSave != null) {
      lastLogfileSave = (lastLogfileSave + File.separator + "logfile.txt");
    }
  }
  
  JButton getDefaultButton()
  {
    return closeButton;
  }
  
  void updateAppearance()
  {
    int buttonsCount = 1;
    
    String buildID = AboutDialog.getInstance().getBuildID();
    String details = AboutDialog.getInstance().getDetails();
    String logfile = AboutDialog.getInstance().getLogfile();
    
    buildIDLabel.setVisible(buildID != null);
    if ("Aqua".equals(UIManager.getLookAndFeel().getID()))
    {
      Font f = buildIDLabel.getFont();
      buildIDLabel.setFont(f.deriveFont(f.getSize2D() - 1.0F));
    }
    if (buildID != null) {
      buildIDLabel.setText(buildID);
    }
    detailsButton.setVisible(details != null);
    if (details != null) {
      buttonsCount++;
    }
    logfileButton.setVisible(logfile != null);
    if (logfile != null) {
      buttonsCount++;
    }
    buttonsContainer.removeAll();
    buttonsContainer.setLayout(new GridLayout(1, buttonsCount, 6, 0));
    if (details != null) {
      buttonsContainer.add(detailsButton);
    }
    if (logfile != null) {
      buttonsContainer.add(logfileButton);
    }
    buttonsContainer.add(closeButton);
  }
  
  private void initComponents()
  {
    setLayout(new BorderLayout());
    
    buildIDLabel = new JLabel();
    buildIDLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
    buildIDLabel.setFont(buildIDLabel.getFont().deriveFont(1));
    buildIDLabel.setEnabled(false);
    
    detailsButton = new JButton();
    Mnemonics.setLocalizedText(detailsButton, NbBundle.getMessage(AboutDialogControls.class, "LBL_Details"));
    detailsButton.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(AboutDialogControls.class, "DESCR_Details"));
    detailsButton.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        AboutDialogControls.this.showDetails();
      }
    });
    logfileButton = new JButton();
    Mnemonics.setLocalizedText(logfileButton, NbBundle.getMessage(AboutDialogControls.class, "LBL_Logfile"));
    logfileButton.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(AboutDialogControls.class, "DESCR_Logfile"));
    logfileButton.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        AboutDialogControls.this.showLogfile();
      }
    });
    closeButton = new JButton();
    Mnemonics.setLocalizedText(closeButton, NbBundle.getMessage(AboutDialogControls.class, "LBL_Close"));
    closeButton.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        SwingUtilities.invokeLater(new Runnable()
        {
          public void run()
          {
            AboutDialog.getInstance().close();
          }
        });
      }
    });
    buttonsContainer = new JPanel(new GridLayout(1, 3, 6, 0));
    buttonsContainer.add(detailsButton);
    buttonsContainer.add(logfileButton);
    buttonsContainer.add(closeButton);
    
    setBorder(BorderFactory.createEmptyBorder(10, 10, 7, 10));
    add(buildIDLabel, "West");
    add(buttonsContainer, "East");
  }
  
  private void showDetails()
  {
    final TextBrowser tb = TextBrowser.getInstance();
    JButton helperButton = new JButton()
    {
      protected void fireActionPerformed(ActionEvent event)
      {
        tb.copyAllHtmlToClipboard();
        JOptionPane.showMessageDialog(AboutDialog.getInstance().getDialog(), NbBundle.getMessage(AboutDialogControls.class, "MSG_Copy_Clipboard"), NbBundle.getMessage(AboutDialogControls.class, "CAPTION_Copy_Clipbard"), 1);
      }
    };
    Mnemonics.setLocalizedText(helperButton, NbBundle.getMessage(AboutDialogControls.class, "BTN_Copy_Clipboard"));
    tb.setCaption(NbBundle.getMessage(AboutDialogControls.class, "TITLE_Details"));
    tb.setPreferredBrowserSize(new Dimension(450, 250));
    tb.setHelperButton(helperButton);
    tb.showHTMLText(AboutDialog.getInstance().getDetails());
  }
  
  private void showLogfile()
  {
    Runnable logfileDisplayer = new Runnable()
    {
      public void run()
      {
        logfileButton.setEnabled(false);
        
        File logfile = new File(AboutDialog.getInstance().getLogfile());
        try
        {
          if ((!logfile.exists()) || (!logfile.isFile()) || (!logfile.canRead()))
          {
            JOptionPane.showMessageDialog(AboutDialog.getInstance().getDialog(), NbBundle.getMessage(AboutDialogControls.class, "LBL_Cannot_open_the_logfile", logfile.getAbsolutePath()), NbBundle.getMessage(AboutDialogControls.class, "LBL_Error"), 0);
          }
          else
          {
            TextBrowser.getInstance().setCaption(NbBundle.getMessage(AboutDialogControls.class, "LBL_Logfile_Viewer_", logfile.getAbsolutePath()));
            if (DesktopUtils.isOpenAvailable()) {
              try
              {
                DesktopUtils.open(logfile);
              }
              catch (Exception ex)
              {
                AboutDialogControls.this.showLogfileInBrowser(logfile);
                AboutDialogControls.LOGGER.throwing(AboutDialogControls.class.getName(), "showLogFile", ex);
              }
            } else {
              AboutDialogControls.this.showLogfileInBrowser(logfile);
            }
          }
        }
        catch (Exception e)
        {
          AboutDialogControls.LOGGER.throwing(AboutDialogControls.class.getName(), "showLogFile", e);
          JOptionPane.showMessageDialog(AboutDialog.getInstance().getDialog(), NbBundle.getMessage(AboutDialogControls.class, "LBL_Cannot_open_the_logfile", logfile.getAbsolutePath()), NbBundle.getMessage(AboutDialogControls.class, "LBL_Error"), 0);
        }
        finally
        {
          logfileButton.setEnabled(true);
        }
      }
    };
    new Thread(logfileDisplayer).start();
  }
  
  private void showLogfileInBrowser(final File logfile)
    throws Exception
  {
    RandomAccessFile raf = null;
    try
    {
      raf = new RandomAccessFile(logfile, "r");
      byte[] buffer = new byte[(int)raf.length()];
      raf.readFully(buffer);
      final String logfileContents = new String(buffer);
      SwingUtilities.invokeAndWait(new Runnable()
      {
        public void run()
        {
          String string = logfileContents;
          if (string.length() == 0) {
            string = NbBundle.getMessage(AboutDialogControls.class, "MSG_Logfile_notready");
          }
          TextBrowser tb = TextBrowser.getInstance();
          JButton helperButton = new JButton()
          {
            protected void fireActionPerformed(ActionEvent event)
            {
              AboutDialogControls.this.saveFileAs(val$logfile);
            }
          };
          Mnemonics.setLocalizedText(helperButton, NbBundle.getMessage(AboutDialogControls.class, "BTN_Save_file"));
          helperButton.setEnabled(logfileContents.length() > 0);
          tb.setPreferredBrowserSize(new Dimension(700, 550));
          tb.setHelperButton(helperButton);
          tb.showCodeText(string);
        }
      });
    }
    finally
    {
      if (raf != null) {
        raf.close();
      }
    }
  }
  
  private void saveFileAs(final File file)
  {
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle(NbBundle.getMessage(AboutDialogControls.class, "CAPTION_Save_logfile"));
    chooser.setSelectedFile(new File(lastLogfileSave));
    if (chooser.showSaveDialog(WindowManager.getDefault().getMainWindow()) == 0)
    {
      final File copy = chooser.getSelectedFile();
      
      lastLogfileSave = copy.getAbsolutePath();
      RequestProcessor.getDefault().post(new Runnable()
      {
        public void run()
        {
          ProgressHandle pHandle = null;
          try
          {
            pHandle = ProgressHandleFactory.createHandle(NbBundle.getMessage(AboutDialogControls.class, "MSG_Saving_logfile", file.getName()));
            
            pHandle.setInitialDelay(0);
            pHandle.start();
            if (!Utils.copyFile(file, copy)) {
              JOptionPane.showMessageDialog(AboutDialog.getInstance().getDialog(), NbBundle.getMessage(AboutDialogControls.class, "MSG_Save_logfile_failed"), NbBundle.getMessage(AboutDialogControls.class, "CAPTION_Save_logfile_failed"), 0);
            }
          }
          finally
          {
            final ProgressHandle pHandleF;
            ProgressHandle pHandleF = pHandle;
            SwingUtilities.invokeLater(new Runnable()
            {
              public void run()
              {
                if (pHandleF != null) {
                  pHandleF.finish();
                }
              }
            });
          }
        }
      });
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.AboutDialogControls
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

class AboutDialogPanel$1
  implements Runnable
{
  AboutDialogPanel$1(AboutDialogPanel paramAboutDialogPanel) {}
  
  public void run()
  {
    this$0.repaint();
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.AboutDialogPanel.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

import javax.swing.SwingUtilities;

class AboutDialogPanel$2$1
  implements Runnable
{
  AboutDialogPanel$2$1(AboutDialogPanel.2 param2) {}
  
  public void run()
  {
    SwingUtilities.invokeLater(this$1.val$repainter);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.AboutDialogPanel.2.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

import java.awt.event.HierarchyEvent;
import java.awt.event.HierarchyListener;
import javax.swing.SwingUtilities;

class AboutDialogPanel$2
  implements HierarchyListener
{
  AboutDialogPanel$2(AboutDialogPanel paramAboutDialogPanel, Runnable paramRunnable) {}
  
  public void hierarchyChanged(HierarchyEvent e)
  {
    if (((e.getChangeFlags() & 0x4) != 0L) && (this$0.isShowing()))
    {
      SwingUtilities.invokeLater(val$repainter);
      SwingUtilities.invokeLater(new Runnable()
      {
        public void run()
        {
          SwingUtilities.invokeLater(val$repainter);
        }
      });
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.AboutDialogPanel.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

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

class AboutDialogPanel$3
  extends JSeparator
{
  AboutDialogPanel$3(AboutDialogPanel paramAboutDialogPanel) {}
  
  public Dimension getMinimumSize()
  {
    return getPreferredSize();
  }
  
  public Dimension getMaximumSize()
  {
    return getPreferredSize();
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.AboutDialogPanel.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.HierarchyEvent;
import java.awt.event.HierarchyListener;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.SwingUtilities;

public class AboutDialogPanel
  extends JPanel
{
  AboutDialogPanel()
  {
    initComponents();
    
    final Runnable repainter = new Runnable()
    {
      public void run()
      {
        repaint();
      }
    };
    addHierarchyListener(new HierarchyListener()
    {
      public void hierarchyChanged(HierarchyEvent e)
      {
        if (((e.getChangeFlags() & 0x4) != 0L) && (isShowing()))
        {
          SwingUtilities.invokeLater(repainter);
          SwingUtilities.invokeLater(new Runnable()
          {
            public void run()
            {
              SwingUtilities.invokeLater(val$repainter);
            }
          });
        }
      }
    });
  }
  
  private void initComponents()
  {
    JPanel splashImageContainer = new ImagePanel(AboutDialog.getInstance().getAboutImage());
    
    JSeparator separator = new JSeparator()
    {
      public Dimension getMinimumSize()
      {
        return getPreferredSize();
      }
      
      public Dimension getMaximumSize()
      {
        return getPreferredSize();
      }
    };
    JPanel licenseContainer = new JPanel(new BorderLayout());
    licenseContainer.setOpaque(false);
    licenseContainer.add(separator, "South");
    
    setLayout(new BorderLayout());
    add(splashImageContainer, "Center");
    add(licenseContainer, "South");
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.AboutDialogPanel
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.MediaTracker;
import javax.swing.JPanel;

public class ImagePanel
  extends JPanel
{
  private static MediaTracker mTracker = new MediaTracker(new JPanel());
  private Image image;
  
  public ImagePanel(Image image)
  {
    setImage(image);
  }
  
  public void setImage(Image image)
  {
    this.image = loadImage(image);
    if (this.image == null) {
      throw new RuntimeException("Failed to load image");
    }
    setPreferredSize(new Dimension(this.image.getWidth(null), this.image.getHeight(null)));
  }
  
  protected static Image loadImage(Image image)
  {
    mTracker.addImage(image, 0);
    try
    {
      mTracker.waitForID(0);
    }
    catch (InterruptedException e)
    {
      return null;
    }
    mTracker.removeImage(image, 0);
    
    return image;
  }
  
  private static final Color BACKGROUND_COLOR = Color.WHITE;
  private static final Color STRIPE_COLOR = new Color(237, 28, 36);
  
  protected void paintComponent(Graphics g)
  {
    int panelWidth = getWidth();
    int imageWidth = image.getWidth(null);
    if (imageWidth >= panelWidth)
    {
      g.drawImage(image, panelWidth - imageWidth, 0, this);
    }
    else
    {
      g.setColor(BACKGROUND_COLOR);
      g.fillRect(0, 0, panelWidth, getHeight());
      g.setColor(STRIPE_COLOR);
      g.fillRect(0, 196, panelWidth, 26);
      g.drawImage(image, (panelWidth - imageWidth) / 2, 0, this);
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.ImagePanel
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

class TextBrowser$1
  extends WindowAdapter
{
  TextBrowser$1(TextBrowser paramTextBrowser) {}
  
  public void windowClosed(WindowEvent e)
  {
    TextBrowser.access$000(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.TextBrowser.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

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

class TextBrowser$2
  extends AbstractAction
{
  TextBrowser$2(TextBrowser paramTextBrowser) {}
  
  public void actionPerformed(ActionEvent e)
  {
    this$0.close();
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.modules.appui.about.TextBrowser.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.modules.appui.about;

import com.sun.tools.visualvm.core.ui.DesktopUtils;
import com.sun.tools.visualvm.uisupport.HTMLTextArea;
import java.net.URL;
1 2 3 4

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-2017. Infinite Loop Ltd