sysperfana/perfinvestigator/com.nokia.carbide.cpp.pi/src/com/nokia/carbide/cpp/internal/pi/test/PIAnalyser.java
changeset 2 b9ab3b238396
equal deleted inserted replaced
1:1050670c6980 2:b9ab3b238396
       
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of the License "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description: 
       
    15  *
       
    16  */
       
    17 
       
    18 package com.nokia.carbide.cpp.internal.pi.test;
       
    19 
       
    20 import java.awt.Frame;
       
    21 import java.awt.event.WindowAdapter;
       
    22 import java.awt.event.WindowEvent;
       
    23 
       
    24 import javax.swing.JFileChooser;
       
    25 import javax.swing.JFrame;
       
    26 
       
    27 import com.nokia.carbide.cpp.internal.pi.manager.PluginRegisterer;
       
    28 import com.nokia.carbide.cpp.pi.core.SessionPreferences;
       
    29 
       
    30 
       
    31 public class PIAnalyser extends JFrame 
       
    32 {
       
    33 	private static final long serialVersionUID = 1L;
       
    34 
       
    35 	public static final String version = "1.1";  //$NON-NLS-1$	// version number is part of program logic, do not externalize
       
    36 	public static final String releaseDate = Messages.getString("PIAnalyser.date"); //$NON-NLS-1$
       
    37 	public static final String releaseYear = Messages.getString("PIAnalyser.year"); //$NON-NLS-1$
       
    38 	
       
    39 //	private static boolean disableAllPrintsInGUIRun = true;
       
    40 	
       
    41 	//this is used to identify changes in NPI file format
       
    42 	//update this when new traces are added or old ones modified
       
    43 //    public static final String NPIFileFormat = "1.1"; //Performance Investigator 1.0 framework  //$NON-NLS-1$ // version number is part of program logic, do not externalize
       
    44 //    public static final String NPIFileFormat = "1.2"; //Performance Investigator 2.0 M1 framework  //$NON-NLS-1$ // version number is part of program logic, do not externalize
       
    45     public static final String NPIFileFormat = "1.3"; //Performance Investigator 2.0 framework  //$NON-NLS-1$ // version number is part of program logic, do not externalize
       
    46     //public static String profilerVersion = "Unknown";
       
    47 	public final static boolean VIEWER_MODE = false;
       
    48 //	public final static boolean INCLUDE_PLUGINS = true; //if this is set dsp, perf framework
       
    49 														//and others are enabled
       
    50 	
       
    51 	//private TestGUI testGUI = null;
       
    52 	private String analyserName;
       
    53 //	private JFileChooser crashPreventingFileChooser;
       
    54 	
       
    55 	private static JFrame frame = null;
       
    56 	/**
       
    57 	 * This is the default constructor
       
    58 	 */
       
    59 	private static void setFrame(JFrame newFrame)
       
    60 	{
       
    61 		frame = newFrame;
       
    62 	}
       
    63 
       
    64 	public PIAnalyser() 
       
    65 	{
       
    66         analyserName = Messages.getString("PIAnalyser.0") + PIAnalyser.version; //$NON-NLS-1$
       
    67 	    
       
    68 	    this.setTitle(analyserName);
       
    69 	    
       
    70 		initialize();
       
    71 		setFrame(this);
       
    72 	
       
    73 		Exception ex = null;
       
    74 		JFileChooser crashPreventingFileChooser;
       
    75 		for (int i=0;i<10;i++)
       
    76 		{
       
    77 			try
       
    78 			{
       
    79 				crashPreventingFileChooser = new JFileChooser();
       
    80 				if (crashPreventingFileChooser != null) break;
       
    81 				System.out.println(Messages.getString("PIAnalyser.ok")); //$NON-NLS-1$
       
    82 			}
       
    83 			catch (Exception e)
       
    84 			{
       
    85 				ex = e;
       
    86 			}
       
    87 		}
       
    88 		if (ex != null)
       
    89 		{
       
    90 			System.out.println(Messages.getString("PIAnalyser.cannotInitializeJFileChooser")); //$NON-NLS-1$
       
    91 			ex.printStackTrace();
       
    92 		}
       
    93 	}
       
    94 	/**
       
    95 	 * This method initializes this
       
    96 	 * 
       
    97 	 * @return void
       
    98 	 */
       
    99 	private void initialize() {
       
   100 		PluginRegisterer.registerAllPlugins(); //setting up static plugin registry before generating the GUI
       
   101 
       
   102 //		this.setContentPane(getJContentPane());
       
   103 //		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       
   104 		//configData.loadData();
       
   105 
       
   106 		int width = SessionPreferences.getInstance().getWindowWidth();
       
   107 		int height = SessionPreferences.getInstance().getWindowHeight();
       
   108 
       
   109 		this.addCloseListener();
       
   110 		this.setSize(width, height);
       
   111 		this.setVisible(true);
       
   112 	}
       
   113 	
       
   114 	private void addCloseListener()
       
   115 	{
       
   116 	    this.addWindowListener(
       
   117 	        new WindowAdapter()
       
   118 	    {
       
   119 	      public void windowClosed(WindowEvent we)
       
   120 	      {
       
   121 	      	System.out.println(Messages.getString("PIAnalyser.closingAnalyser")); //$NON-NLS-1$
       
   122 	      	//ConfigurationPanel config = ConfigurationPanel.getInstance();
       
   123 	      	//config.saveConfig();
       
   124 	      	//JButton button = config.getJButton3();
       
   125 	      	//button.doClick();
       
   126 	      	
       
   127 			//configData.loadData();
       
   128 			int width = frame.getWidth();
       
   129 			int height = frame.getHeight();
       
   130 			SessionPreferences.getInstance().setWindowWidth(width);
       
   131 			SessionPreferences.getInstance().setWindowHeight(height);
       
   132 			try {
       
   133 //				configData.saveData();
       
   134 				throw new Exception(Messages.getString("PIAnalyser.fixException")); //$NON-NLS-1$
       
   135 			} catch (Exception e) {
       
   136 				e.printStackTrace();
       
   137 			}
       
   138 	      	
       
   139 	        System.exit(0);
       
   140 	      }
       
   141 	      public void windowClosing(WindowEvent we)
       
   142 		  {
       
   143 	      	((Frame)we.getSource()).dispose(); 
       
   144 	      }
       
   145 	    });
       
   146 
       
   147 	 }
       
   148 	
       
   149 	public static JFrame getFrame()
       
   150 	{
       
   151 	    return frame;
       
   152 	}
       
   153 	
       
   154 // 	public static void main(String args[])
       
   155 //	{
       
   156 // 	    if (args.length > 0)
       
   157 //        {
       
   158 // 	        System.out.println("Commandline parameter: "+args[0]);
       
   159 // 	        analyserNoGUI(args);
       
   160 //        }
       
   161 //        else
       
   162 //        {
       
   163 //    		try {
       
   164 //    			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
       
   165 //    		} catch (Exception e) {
       
   166 //    			e.printStackTrace();
       
   167 //    		}
       
   168 //    		
       
   169 //    		// disable all debug prints in releases
       
   170 //    		if (PIAnalyser.disableAllPrintsInGUIRun)
       
   171 //    		{
       
   172 //    			PrintStream nullStream = new PrintStream(
       
   173 //    					new OutputStream()
       
   174 //    					{
       
   175 //    						public void write(){}
       
   176 //    						public void write(int i){}
       
   177 //    					});
       
   178 //    			System.setOut(nullStream);
       
   179 //    		}
       
   180 //    		
       
   181 //            new PIAnalyser();
       
   182 //        }
       
   183 //
       
   184 //        analyserNoGUI(args);
       
   185 //        
       
   186 //	}
       
   187 //    private static void analyserNoGUI(String args[])
       
   188 //    {
       
   189 //        if (args.length>2)
       
   190 //        {
       
   191 //            System.out.println("\n\n*********************************************");
       
   192 //            System.out.println("Performing scripted analysis");
       
   193 //            System.out.println("Symbol file: ("+args[0].toString()+") hmms");
       
   194 //            System.out.println("Stream file: "+args[1].toString());
       
   195 //            System.out.println("Output file: "+args[2].toString());
       
   196 //            System.out.println("*********************************************\n\n");
       
   197 //
       
   198 //            PluginRegisterer.registerAllPlugins(); //setting up plugin registry
       
   199 //            new AnalyseTab(args);
       
   200 //        }
       
   201 //        else
       
   202 //        {
       
   203 //            System.out.println("Guidelines: java -mx1200m -jar Analyser_v131.jar <symbol file> <stream file> <output file>");
       
   204 //            System.exit(0);
       
   205 //        }
       
   206 //    }
       
   207     
       
   208  }