sysperfana/analyzetoolext/com.nokia.s60tools.analyzetool/src/com/nokia/s60tools/analyzetool/ui/MainView.java
changeset 15 0367d2db2c06
parent 6 f65f740e69f9
equal deleted inserted replaced
14:bb339882c6e9 15:0367d2db2c06
   335 					return notBuild;
   335 					return notBuild;
   336 				}
   336 				}
   337 				// module not belong to selected project
   337 				// module not belong to selected project
   338 				return outside;
   338 				return outside;
   339 			}
   339 			}
   340 
       
   341 			return element;
   340 			return element;
   342 		}
   341 		}
   343 
   342 
   344 		/**
   343 		/**
   345 		 * Gets current tree view object name.
   344 		 * Gets current tree view object name.
   372 	/** Tree parent object which not shown to user. */
   371 	/** Tree parent object which not shown to user. */
   373 	private TreeParent invisibleRoot;
   372 	private TreeParent invisibleRoot;
   374 
   373 
   375 	/** Double click action. */
   374 	/** Double click action. */
   376 	private Action doubleClickAction;
   375 	private Action doubleClickAction;
       
   376 
   377 	/** Click action. */
   377 	/** Click action. */
   378 	private Action clickAction;
   378 	private Action clickAction;
       
   379 
   379 	/** Change detail level action. */
   380 	/** Change detail level action. */
   380 	public Action changeDetails;
   381 	public Action changeDetails;
       
   382 
   381 	/** Select S60 log file action. */
   383 	/** Select S60 log file action. */
   382 	private Action s60LogTargetAction;
   384 	private Action s60LogTargetAction;
       
   385 
   383 	/** Select TraceViewer connection action. */
   386 	/** Select TraceViewer connection action. */
   384 	private Action externalLogTargetAction;
   387 	// private Action externalLogTargetAction;
       
   388 
   385 	/** Select fast data gathering mode */
   389 	/** Select fast data gathering mode */
   386 	private Action externalFastLogTargetAction;
   390 	private Action externalFastLogTargetAction;
       
   391 
   387 	/** Select Ask always action. */
   392 	/** Select Ask always action. */
   388 	private Action askLogTargetAction;
   393 	private Action askLogTargetAction;
       
   394 
   389 	/** Save report file action. */
   395 	/** Save report file action. */
   390 	private Action saveReportAction;
   396 	private Action saveReportAction;
       
   397 
   391 	/** Save test run action. */
   398 	/** Save test run action. */
   392 	private Action saveDataFileAction;
   399 	private Action saveDataFileAction;
       
   400 
   393 	/** AnalyzeTool results action. */
   401 	/** AnalyzeTool results action. */
   394 	private Action analyzeResults;
   402 	private Action analyzeResults;
       
   403 
   395 	/** Activate AnalyzeTool build action. */
   404 	/** Activate AnalyzeTool build action. */
   396 	public Action buildWithAtool;
   405 	public Action buildWithAtool;
       
   406 
   397 	/** Clean AnalyzeTool changes action. */
   407 	/** Clean AnalyzeTool changes action. */
   398 	private Action cleanAtoolChanges;
   408 	private Action cleanAtoolChanges;
       
   409 
   399 	/** Start/Stop trace action. */
   410 	/** Start/Stop trace action. */
   400 	public Action traceAction;
   411 	public Action traceAction;
       
   412 
   401 	/** Start subtest action. */
   413 	/** Start subtest action. */
   402 	private Action startSubtest;
   414 	private Action startSubtest;
       
   415 
   403 	/** Stop subtest action. */
   416 	/** Stop subtest action. */
   404 	private Action stopSubtest;
   417 	private Action stopSubtest;
       
   418 
   405 	/** Refresh(re-creates) project results */
   419 	/** Refresh(re-creates) project results */
   406 	private Action refreshResults;
   420 	private Action refreshResults;
       
   421 
   407 	/** Copies selected memory leak item info to the clipboard. */
   422 	/** Copies selected memory leak item info to the clipboard. */
   408 	private Action copyAction;
   423 	private Action copyAction;
       
   424 
   409 	/** Action to open AnalyzeTool preference page. */
   425 	/** Action to open AnalyzeTool preference page. */
   410 	private Action openPrefs;
   426 	private Action openPrefs;
       
   427 
   411 	/**
   428 	/**
   412 	 * Clears selected project results without removing temporary files
   429 	 * Clears selected project results without removing temporary files
   413 	 */
   430 	 */
   414 	private Action clearProjectResults;
   431 	private Action clearProjectResults;
   415 
   432 
   508 			if (bUtil.isNatureEnabled(project)) {
   525 			if (bUtil.isNatureEnabled(project)) {
   509 				bUtil.disableNatures(project);
   526 				bUtil.disableNatures(project);
   510 			} else {
   527 			} else {
   511 				bUtil.enableNatures(project);
   528 				bUtil.enableNatures(project);
   512 			}
   529 			}
   513 
   530 		}
   514 		}
       
   515 
       
   516 		// update build state
   531 		// update build state
   517 		updateBuildState(project);
   532 		updateBuildState(project);
   518 
       
   519 	}
   533 	}
   520 
   534 
   521 	/*
   535 	/*
   522 	 * (non-Javadoc)
   536 	 * (non-Javadoc)
   523 	 * 
   537 	 * 
   536 		if (datafile != null && runView != null) {
   550 		if (datafile != null && runView != null) {
   537 
   551 
   538 			// need to check is data file available in the disk
   552 			// need to check is data file available in the disk
   539 			FileInputStream fis = null;
   553 			FileInputStream fis = null;
   540 			try {
   554 			try {
   541 
       
   542 				// get existing file stream
   555 				// get existing file stream
   543 				fis = new FileInputStream(datafile);
   556 				fis = new FileInputStream(datafile);
   544 
   557 
   545 				// if file is empty => do nothing
   558 				// if file is empty => do nothing
   546 				if (fis.available() == 0) {
   559 				if (fis.available() == 0) {
   581 						analyzeDataFile(Constants.ANALYZE_USE_DATA_FILE,
   594 						analyzeDataFile(Constants.ANALYZE_USE_DATA_FILE,
   582 								datafile, false);
   595 								datafile, false);
   583 					}
   596 					}
   584 				});
   597 				});
   585 			}
   598 			}
   586 
       
   587 		}
   599 		}
   588 	}
   600 	}
   589 
   601 
   590 	/**
   602 	/**
   591 	 * Opens file dialog and analyzing data file for given location.
   603 	 * Opens file dialog and analyzing data file for given location.
   634 			AbstractList<MMPInfo> modules = Util
   646 			AbstractList<MMPInfo> modules = Util
   635 					.loadProjectTargetsInfo(project);
   647 					.loadProjectTargetsInfo(project);
   636 			projectModules.put(project, modules);
   648 			projectModules.put(project, modules);
   637 
   649 
   638 			boolean xmlFile = Util.isFileXML(selectedFile);
   650 			boolean xmlFile = Util.isFileXML(selectedFile);
   639 			// if file is xml file
   651 			// if file is XML file
   640 			// no need to analyze data file
   652 			// no need to analyze data file
   641 			// => just create results from xml file
   653 			// => just create results from XML file
   642 			if (xmlFile) {
   654 			if (xmlFile) {
   643 				Job analyzingXMLJob = new Job(Constants.ANALYZE_TOOL_TITLE) {
   655 				Job analyzingXMLJob = new Job(Constants.ANALYZE_TOOL_TITLE) {
   644 					@Override
   656 					@Override
   645 					protected IStatus run(IProgressMonitor monitor) {
   657 					protected IStatus run(IProgressMonitor monitor) {
   646 
   658 
   708 				|| analyzeJob.getResult().getCode() == IStatus.CANCEL
   720 				|| analyzeJob.getResult().getCode() == IStatus.CANCEL
   709 				|| analyzeJob.getResult().getCode() == IStatus.ERROR) {
   721 				|| analyzeJob.getResult().getCode() == IStatus.ERROR) {
   710 			analyzeJob = new Job(Constants.ANALYZE_TOOL_TITLE) {
   722 			analyzeJob = new Job(Constants.ANALYZE_TOOL_TITLE) {
   711 				@Override
   723 				@Override
   712 				protected IStatus run(IProgressMonitor monitor) {
   724 				protected IStatus run(IProgressMonitor monitor) {
   713 					// inform progressdialog that task execution starts
   725 					// inform progress dialog that task execution starts
   714 					// this make progressdialog visible on the UI
   726 					// this make progress dialog visible on the UI
   715 					monitor.beginTask(Constants.PROGRESSDIALOG_ATOOL,
   727 					monitor.beginTask(Constants.PROGRESSDIALOG_ATOOL,
   716 							IProgressMonitor.UNKNOWN);
   728 							IProgressMonitor.UNKNOWN);
   717 					
   729 
   718 					fileOpenHistory.setFileName(usedFile);
   730 					fileOpenHistory.setFileName(usedFile);
   719 					// add2UserActionHistory( "File opened: " + usedFile );
   731 					// add2UserActionHistory( "File opened: " + usedFile );
   720 
   732 
   721 					// set used datafile name
   733 					// set used datafile name
   722 					usedDataFileName = usedFile;
   734 					usedDataFileName = usedFile;
   723 
   735 
   724 					if (chart != null) {
   736 					if (chart != null) {
   725 						resetGraphView();// clear out the graph view
   737 						resetGraphView();// clear out the graph view
   726 					}
   738 					}
   727 					
   739 
   728 					// create atool object and execute atool
   740 					// create atool object and execute atool
   729 					UseAtool atool = new UseAtool();
   741 					UseAtool atool = new UseAtool();
   730 
   742 
   731 					// create xml file
   743 					// create XML file
   732 					Constants.COMMAND_LINE_ERROR_CODE errorCode = atool
   744 					Constants.COMMAND_LINE_ERROR_CODE errorCode = atool
   733 							.createXMLFileToCarbide(monitor, projectRef,
   745 							.createXmlAndCleanDatFilesToCarbide(monitor,
   734 									usedFile, "-a");
   746 									projectRef, usedFile, "-a");
   735 					String xmlFileLocation = null;
   747 
   736 					xmlFileLocation = atool.getDataFileName();
   748 					String xmlFileLocation = atool.getXmlFilePath();
       
   749 					String cleanDatFileLocation = atool.getCleanDatFilePath();
   737 
   750 
   738 					// if some error occurs display it to user.
   751 					// if some error occurs display it to user.
   739 					if (errorCode != Constants.COMMAND_LINE_ERROR_CODE.OK) {
   752 					if (errorCode != Constants.COMMAND_LINE_ERROR_CODE.OK) {
   740 						fileOpenHistory.removeFileName(usedFile);
   753 						fileOpenHistory.removeFileName(usedFile);
   741 						Util.displayCommandLineError(errorCode);
   754 						Util.displayCommandLineError(errorCode);
   742 					}
   755 					}
       
   756 
   743 					// if XML file generation failed => info to the user
   757 					// if XML file generation failed => info to the user
   744 					else if (xmlFileLocation == null) {
   758 					else if (xmlFileLocation == null) {
   745 						fileOpenHistory.removeFileName(usedFile);
   759 						fileOpenHistory.removeFileName(usedFile);
   746 						if (showErrorInfo) {
   760 						if (showErrorInfo) {
   747 							showErrorMessage(Constants.INFO_FILE_INVALID);
   761 							showErrorMessage(Constants.INFO_FILE_INVALID);
   748 						}
   762 						}
   749 					} else {
   763 					} else {
   750 						// Parse the xml file
   764 						// Parse the XML file
   751 						ParseXMLFileSAX dataFileParser = new ParseXMLFileSAX(
   765 						ParseXMLFileSAX dataFileParser = new ParseXMLFileSAX(
   752 								project, xmlFileLocation, projectResults);
   766 								project, xmlFileLocation, projectResults);
   753 						boolean error = dataFileParser.parse();
   767 						boolean error = dataFileParser.parse();
   754 						if (showErrorInfo && !error) {
   768 						if (showErrorInfo && !error) {
   755 							fileOpenHistory.removeFileName(usedFile);
   769 							fileOpenHistory.removeFileName(usedFile);
   765 						refreshView();
   779 						refreshView();
   766 					}
   780 					}
   767 
   781 
   768 					updateChangeDetailState(projectRef);
   782 					updateChangeDetailState(projectRef);
   769 
   783 
   770 					// //this only generates statistics and this feature is
       
   771 					// currently disabled
       
   772 					// if( !monitor.isCanceled() ) {
       
   773 					//
       
   774 					// IPreferenceStore store = Activator.getPreferences();
       
   775 					// boolean generateStatistic =
       
   776 					// store.getBoolean(Constants.CREATE_STATISTIC);
       
   777 					// //used file data file create statistic also
       
   778 					// if( generateStatistic && UseAtool.checkFileType(usedFile)
       
   779 					// == Constants.DATAFILE_TRACE )
       
   780 					// {
       
   781 					// monitor.setTaskName(Constants.STATISTICS_GENERATING_PROG_TITLE);
       
   782 					//
       
   783 					// ReadFile fileReader = new ReadFile();
       
   784 					// boolean error = fileReader.readFile(usedFile);
       
   785 					// if( error && statisticView != null) {
       
   786 					// AbstractList<ProcessInfo> processes =
       
   787 					// fileReader.getStatistic();
       
   788 					// statisticView.setData( project, processes);
       
   789 					// fileReader.finish();
       
   790 					// }
       
   791 					//
       
   792 					// }
       
   793 					// }
       
   794 					if (!monitor.isCanceled()) {
   784 					if (!monitor.isCanceled()) {
   795 
       
   796 						// create the job for loading the graph model
   785 						// create the job for loading the graph model
   797 						// but only schedule it when the user gets to the graph
   786 						// but only schedule it when the user gets to the graph
   798 						// tab
   787 						// tab
   799 						graphLoadJob = new GraphLoadJob(usedFile);
   788 						graphLoadJob = new GraphLoadJob(cleanDatFileLocation);
   800 						graphLoadJob.setUser(true);// set progress bar
   789 						graphLoadJob.setUser(true);// set progress bar
   801 						graphLoadJob.setPriority(Job.LONG);
   790 						graphLoadJob.setPriority(Job.LONG);
   802 
   791 
   803 						// run the following in UI thread, since widgets get
   792 						// run the following in UI thread, since widgets get
   804 						// accessed
   793 						// accessed
   805 						PlatformUI.getWorkbench().getDisplay().syncExec(
   794 						PlatformUI.getWorkbench().getDisplay().syncExec(
   806 								new Runnable() {
   795 								new Runnable() {
   807 									public void run() {
   796 									public void run() {
   808 										if (((CTabFolder) chart.getParent())
   797 										if (((CTabFolder) chart.getParent())
   809 												.getSelection() != null && ((CTabFolder) chart.getParent())
   798 												.getSelection() != null
   810 												.getSelection().getControl() == chart) {
   799 												&& ((CTabFolder) chart
       
   800 														.getParent())
       
   801 														.getSelection()
       
   802 														.getControl() == chart) {
   811 											// chart tab is currently selected
   803 											// chart tab is currently selected
   812 											// so we can run the load job
   804 											// so we can run the load job
   813 											// straight away
   805 											// straight away
   814 											graphLoadJob.schedule();
   806 											graphLoadJob.schedule();
   815 										}
   807 										}
   820 					return new Status(IStatus.OK, Constants.ANALYZE_CONSOLE_ID,
   812 					return new Status(IStatus.OK, Constants.ANALYZE_CONSOLE_ID,
   821 							IStatus.OK,
   813 							IStatus.OK,
   822 							Constants.PROGRESSDIALOG_ANALYZE_COMPLETE, null);
   814 							Constants.PROGRESSDIALOG_ANALYZE_COMPLETE, null);
   823 				}
   815 				}
   824 			};
   816 			};
   825 			
   817 
   826 			if (graphLoadJob != null && graphLoadJob.getState() == Job.RUNNING) {
   818 			if (graphLoadJob != null && graphLoadJob.getState() == Job.RUNNING) {
   827 				graphLoadJob.cancel();
   819 				graphLoadJob.cancel();
   828 			}
   820 			}
   829 			graphLoadJob = null;			
   821 			graphLoadJob = null;
   830 
   822 
   831 			analyzeJob.setUser(true);
   823 			analyzeJob.setUser(true);
   832 			analyzeJob.setPriority(Job.LONG);
   824 			analyzeJob.setPriority(Job.LONG);
   833 			analyzeJob.schedule();
   825 			analyzeJob.schedule();
   834 
   826 
   835 		} else { // if existing job is running display info to user
   827 		} else {
       
   828 			// if existing job is running display info to user
   836 			showMessage(Constants.INFO_ALLREADY_RUNNING);
   829 			showMessage(Constants.INFO_ALLREADY_RUNNING);
   837 		}
   830 		}
   838 	}
   831 	}
   839 
   832 
   840 	/**
   833 	/**
   882 					} else {
   875 					} else {
   883 						// set selection to correct item
   876 						// set selection to correct item
   884 						runView.setSelection(new StructuredSelection(
   877 						runView.setSelection(new StructuredSelection(
   885 								activeTreeItem), true);
   878 								activeTreeItem), true);
   886 					}
   879 					}
   887 
       
   888 				}
   880 				}
   889 
   881 
   890 				if (callstackView != null) {
   882 				if (callstackView != null) {
   891 					// update view callstack view content
   883 					// update view callstack view content
   892 					callstackView.setInput(getCallStack(activeTreeItem));
   884 					callstackView.setInput(getCallStack(activeTreeItem));
   893 
   885 
   894 					// expand all the trees on call stack view
   886 					// expand all the trees on call stack view
   895 					callstackView.expandAll();
   887 					callstackView.expandAll();
   896 
   888 
   897 				}
   889 				}
   898 
       
   899 				// change tooltip
   890 				// change tooltip
   900 				changeReportActionTooltip();
   891 				changeReportActionTooltip();
   901 
       
   902 			}
   892 			}
   903 		});
   893 		});
   904 
       
   905 	}
   894 	}
   906 
   895 
   907 	/**
   896 	/**
   908 	 * Change logging mode.
   897 	 * Change logging mode.
   909 	 * 
   898 	 * 
   918 
   907 
   919 		// get preference store
   908 		// get preference store
   920 		IPreferenceStore store = Activator.getPreferences();
   909 		IPreferenceStore store = Activator.getPreferences();
   921 		String usedLoggingMode = "";
   910 		String usedLoggingMode = "";
   922 
   911 
   923 		// if no loggingmode given get it from the AnalyzeTool preferences
   912 		// if no logging mode given get it from the AnalyzeTool preferences
   924 		if (loggingMode == null) {
   913 		if (loggingMode == null) {
   925 			usedLoggingMode = store.getString(Constants.LOGGING_MODE);
   914 			usedLoggingMode = store.getString(Constants.LOGGING_MODE);
   926 		}
   915 		}
   927 		// logging mode is given => so start to use it
   916 		// logging mode is given => so start to use it
   928 		else {
   917 		else {
   929 			store.setValue(Constants.LOGGING_MODE, loggingMode);
   918 			store.setValue(Constants.LOGGING_MODE, loggingMode);
   930 			usedLoggingMode = loggingMode;
   919 			usedLoggingMode = loggingMode;
   931 		}
   920 		}
   932 
   921 
   933 		// current logging mode is external change it to external
   922 		if (Constants.LOGGING_S60.equals(usedLoggingMode)) {
   934 		if (Constants.LOGGING_EXT.equals(usedLoggingMode)) {
       
   935 			logTargetMenu.setImageDescriptor(Activator
       
   936 					.getImageDescriptor(Constants.BUTTON_COMPUTER));
       
   937 			logTargetMenu
       
   938 					.setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_EXT);
       
   939 			if (loggingMode == null) {
       
   940 				externalLogTargetAction.setChecked(true);
       
   941 				s60LogTargetAction.setChecked(false);
       
   942 				externalFastLogTargetAction.setChecked(false);
       
   943 				askLogTargetAction.setChecked(false);
       
   944 			}
       
   945 		}
       
   946 		// current logging mode is s60 change it to s60
       
   947 		else if (Constants.LOGGING_S60.equals(usedLoggingMode)) {
       
   948 
   923 
   949 			logTargetMenu.setImageDescriptor(Activator
   924 			logTargetMenu.setImageDescriptor(Activator
   950 					.getImageDescriptor(Constants.BUTTON_CELLURAR));
   925 					.getImageDescriptor(Constants.BUTTON_CELLURAR));
   951 			logTargetMenu
   926 			logTargetMenu
   952 					.setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_S60);
   927 					.setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_S60);
   953 			if (loggingMode == null) {
   928 			if (loggingMode == null) {
   954 				externalLogTargetAction.setChecked(false);
       
   955 				s60LogTargetAction.setChecked(true);
   929 				s60LogTargetAction.setChecked(true);
   956 				externalFastLogTargetAction.setChecked(false);
   930 				externalFastLogTargetAction.setChecked(false);
   957 				askLogTargetAction.setChecked(false);
   931 				askLogTargetAction.setChecked(false);
   958 			}
   932 			}
   959 		}
   933 		} else if (Constants.LOGGING_EXT_FAST.equals(usedLoggingMode)) {
   960 
       
   961 		else if (Constants.LOGGING_EXT_FAST.equals(usedLoggingMode)) {
       
   962 			logTargetMenu.setImageDescriptor(Activator
   934 			logTargetMenu.setImageDescriptor(Activator
   963 					.getImageDescriptor(Constants.BUTTON_COMPUTER_FAST));
   935 					.getImageDescriptor(Constants.BUTTON_COMPUTER_FAST));
   964 			logTargetMenu
   936 			logTargetMenu
   965 					.setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_FAST);
   937 					.setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_FAST);
   966 			if (loggingMode == null) {
   938 			if (loggingMode == null) {
   967 				externalLogTargetAction.setChecked(false);
       
   968 				s60LogTargetAction.setChecked(false);
   939 				s60LogTargetAction.setChecked(false);
   969 				externalFastLogTargetAction.setChecked(true);
   940 				externalFastLogTargetAction.setChecked(true);
   970 				askLogTargetAction.setChecked(false);
   941 				askLogTargetAction.setChecked(false);
   971 			}
   942 			}
   972 		}
   943 		}
   975 			logTargetMenu.setImageDescriptor(Activator
   946 			logTargetMenu.setImageDescriptor(Activator
   976 					.getImageDescriptor(Constants.BUTTON_ASK));
   947 					.getImageDescriptor(Constants.BUTTON_ASK));
   977 			logTargetMenu
   948 			logTargetMenu
   978 					.setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_ASK);
   949 					.setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_ASK);
   979 			if (loggingMode == null) {
   950 			if (loggingMode == null) {
   980 				externalLogTargetAction.setChecked(false);
       
   981 				s60LogTargetAction.setChecked(false);
   951 				s60LogTargetAction.setChecked(false);
   982 				externalFastLogTargetAction.setChecked(false);
   952 				externalFastLogTargetAction.setChecked(false);
   983 				askLogTargetAction.setChecked(true);
   953 				askLogTargetAction.setChecked(true);
   984 			}
   954 			}
   985 		}
   955 		}
  1020 			changeDetails.setImageDescriptor(Activator
   990 			changeDetails.setImageDescriptor(Activator
  1021 					.getImageDescriptor(Constants.BUTTON_DETAILS_TOPMOST));
   991 					.getImageDescriptor(Constants.BUTTON_DETAILS_TOPMOST));
  1022 			changeDetails
   992 			changeDetails
  1023 					.setToolTipText(Constants.ACTION_CHANGE_REPORT_LEVEL_TOPMOST);
   993 					.setToolTipText(Constants.ACTION_CHANGE_REPORT_LEVEL_TOPMOST);
  1024 		}
   994 		}
  1025 
       
  1026 	}
   995 	}
  1027 
   996 
  1028 	/**
   997 	/**
  1029 	 * Change view title.
   998 	 * Change view title.
  1030 	 * 
   999 	 * 
  1132 		if (clearProjectResults != null && clearProjectResults != null) {
  1101 		if (clearProjectResults != null && clearProjectResults != null) {
  1133 			clearProjectResults.setEnabled(false);
  1102 			clearProjectResults.setEnabled(false);
  1134 		} else if (clearProjectResults != null) {
  1103 		} else if (clearProjectResults != null) {
  1135 			updateChangeDetailState(projectRef);
  1104 			updateChangeDetailState(projectRef);
  1136 		}
  1105 		}
  1137 
       
  1138 	}
  1106 	}
  1139 
  1107 
  1140 	/**
  1108 	/**
  1141 	 * Clears callstack view contents.
  1109 	 * Clears callstack view contents.
  1142 	 */
  1110 	 */
  1152 				if (callstackView != null) {
  1120 				if (callstackView != null) {
  1153 					callstackView.setInput(null);
  1121 					callstackView.setInput(null);
  1154 				}
  1122 				}
  1155 			}
  1123 			}
  1156 		});
  1124 		});
  1157 
       
  1158 	}
  1125 	}
  1159 
  1126 
  1160 	/**
  1127 	/**
  1161 	 * Contributes action bar.
  1128 	 * Contributes action bar.
  1162 	 */
  1129 	 */
  1174 	 * it.
  1141 	 * it.
  1175 	 */
  1142 	 */
  1176 	@Override
  1143 	@Override
  1177 	public void createPartControl(Composite parent) {
  1144 	public void createPartControl(Composite parent) {
  1178 
  1145 
  1179 		// create new Tab
  1146 		// create a new Tab
  1180 		final CTabFolder mainFolder = new CTabFolder(parent, SWT.TOP);
  1147 		final CTabFolder mainFolder = new CTabFolder(parent, SWT.TOP);
  1181 
  1148 
  1182 		// create main view and add it tab
  1149 		// create main view and add it tab
  1183 		createMainView(mainFolder);
  1150 		createMainView(mainFolder);
  1184 
  1151 
  1185 		// create new statistic view
       
  1186 		// createMemoryView( mainFolder );
       
  1187 		// create graph
  1152 		// create graph
  1188 		createGraphView(mainFolder);
  1153 		createGraphView(mainFolder);
  1189 
  1154 
  1190 		// set initial selection
  1155 		// set initial selection
  1191 		mainFolder.setSelection(mainTab);
  1156 		mainFolder.setSelection(mainTab);
  1195 			public void widgetDefaultSelected(SelectionEvent e) {
  1160 			public void widgetDefaultSelected(SelectionEvent e) {
  1196 				widgetSelected(e);
  1161 				widgetSelected(e);
  1197 			}
  1162 			}
  1198 
  1163 
  1199 			public void widgetSelected(SelectionEvent e) {
  1164 			public void widgetSelected(SelectionEvent e) {
  1200 				// if we changed to the graph tab and the graph load job isn't already running
  1165 				// if we changed to the graph tab and the graph load job isn't
       
  1166 				// already running
  1201 				// schedule it now
  1167 				// schedule it now
  1202 				if (graphLoadJob != null
  1168 				if (graphLoadJob != null
  1203 						&& graphLoadJob.getState() != Job.RUNNING
  1169 						&& graphLoadJob.getState() != Job.RUNNING
  1204 						&& mainFolder.getSelection() != null
  1170 						&& mainFolder.getSelection() != null
  1205 						&& mainFolder.getSelection().getControl() == chart) {
  1171 						&& mainFolder.getSelection().getControl() == chart) {
  1206 					graphLoadJob.schedule();
  1172 					graphLoadJob.schedule();
  1207 				}
  1173 				}
  1208 
  1174 
  1209 				
       
  1210 				if (mainFolder.getSelectionIndex() == 1) {
  1175 				if (mainFolder.getSelectionIndex() == 1) {
  1211 					changeDetails.setEnabled(false);
  1176 					changeDetails.setEnabled(false);
  1212 				} else {
  1177 				} else {
  1213 					changeDetails.setEnabled(true);
  1178 					changeDetails.setEnabled(true);
  1214 					
       
  1215 				}
  1179 				}
  1216 			}
  1180 			}
  1217 		});
  1181 		});
  1218 		
  1182 
  1219 		// stop any jobs that may be scheduled
  1183 		// stop any jobs that may be scheduled
  1220 		mainFolder.addDisposeListener(new DisposeListener(){
  1184 		mainFolder.addDisposeListener(new DisposeListener() {
  1221 			public void widgetDisposed(DisposeEvent e) {
  1185 			public void widgetDisposed(DisposeEvent e) {
  1222 				if (graphLoadJob != null){
  1186 				if (graphLoadJob != null) {
  1223 					graphLoadJob.cancel();		
  1187 					graphLoadJob.cancel();
  1224 					graphLoadJob = null;
  1188 					graphLoadJob = null;
  1225 				}
  1189 				}
  1226 				if (analyzeJob != null){
  1190 				if (analyzeJob != null) {
  1227 					analyzeJob.cancel();
  1191 					analyzeJob.cancel();
  1228 					analyzeJob = null;
  1192 					analyzeJob = null;
  1229 				}
  1193 				}
  1230 			}
  1194 			}
  1231 		});
  1195 		});
  1232 		
       
  1233 	}
  1196 	}
  1234 
  1197 
  1235 	/**
  1198 	/**
  1236 	 * Creates graph view and add it to graph tab
  1199 	 * Creates graph view and add it to graph tab
  1237 	 * 
  1200 	 * 
  1256 	 * Clears the graph by setting an empty model and causing paint events
  1219 	 * Clears the graph by setting an empty model and causing paint events
  1257 	 */
  1220 	 */
  1258 	private void resetGraphView() {
  1221 	private void resetGraphView() {
  1259 		if (chart != null) {
  1222 		if (chart != null) {
  1260 			chart.setInput(project, AnalyzeFactory.getEmptyModel());
  1223 			chart.setInput(project, AnalyzeFactory.getEmptyModel());
  1261 			// chart.update();
       
  1262 		}
  1224 		}
  1263 	}
  1225 	}
  1264 
  1226 
  1265 	/**
  1227 	/**
  1266 	 * Creates new statistic view and add it to memory tab
  1228 	 * Creates new statistic view and add it to memory tab
  1297 		SashForm callstackForm = new SashForm(sashForm, SWT.VERTICAL);
  1259 		SashForm callstackForm = new SashForm(sashForm, SWT.VERTICAL);
  1298 
  1260 
  1299 		// set content and label providers
  1261 		// set content and label providers
  1300 		runView.setContentProvider(new ViewContentProvider());
  1262 		runView.setContentProvider(new ViewContentProvider());
  1301 		runView.setLabelProvider(new ViewLabelProvider());
  1263 		runView.setLabelProvider(new ViewLabelProvider());
  1302 		// runView.addFilter( new ATFilter() );
  1264 
  1303 		// get init content
  1265 		// get init content
  1304 		runView.setInput(getStartupContent());
  1266 		runView.setInput(getStartupContent());
  1305 
  1267 
  1306 		// add listener to provide selection change events
  1268 		// add listener to provide selection change events
  1307 		runView.addTreeListener(this);
  1269 		runView.addTreeListener(this);
  1366 				AnalyzeToolHelpContextIDs.ANALYZE_MAIN);
  1328 				AnalyzeToolHelpContextIDs.ANALYZE_MAIN);
  1367 
  1329 
  1368 		ResourcesPlugin.getWorkspace().addResourceChangeListener(
  1330 		ResourcesPlugin.getWorkspace().addResourceChangeListener(
  1369 				new ATResourceListener());
  1331 				new ATResourceListener());
  1370 
  1332 
  1371 		// get used command line engine version
       
  1372 		String version = Util.getAtoolVersionNumber(Util
       
  1373 				.getAtoolInstallFolder());
       
  1374 
       
  1375 		// compare current version to min version
       
  1376 		int comp = Util.compareVersionNumber(Constants.CS_SUPPORT_MIN_VERSION,
       
  1377 				version);
       
  1378 
       
  1379 		IPreferenceStore store = Activator.getPreferences();
  1333 		IPreferenceStore store = Activator.getPreferences();
  1380 		// if current version is same or higher than required version => set
  1334 		store.setValue(Constants.LOGGING_FAST_ENABLED, true);
  1381 		// flag to true
       
  1382 		if (comp == Constants.VERSION_NUMBERS_EQUALS
       
  1383 				|| comp == Constants.VERSION_NUMBERS_SECOND) {
       
  1384 			store.setValue(Constants.LOGGING_FAST_ENABLED, true);
       
  1385 		} else {
       
  1386 			store.setValue(Constants.LOGGING_FAST_ENABLED, false);
       
  1387 		}
       
  1388 
  1335 
  1389 		// get default value for logging mode
  1336 		// get default value for logging mode
  1390 		preferenceChanged();
  1337 		preferenceChanged();
  1391 	}
  1338 	}
  1392 
  1339 
  1398 	 * 
  1345 	 * 
  1399 	 * @param disable
  1346 	 * @param disable
  1400 	 *            Boolean state of trace action
  1347 	 *            Boolean state of trace action
  1401 	 */
  1348 	 */
  1402 	public void disableTraceActions(final boolean disable) {
  1349 	public void disableTraceActions(final boolean disable) {
  1403 
       
  1404 		if (traceAction != null && disable) {
  1350 		if (traceAction != null && disable) {
  1405 			// enable trace action
  1351 			// enable trace action
  1406 			traceAction.setToolTipText(Constants.ACTION_START_TRACE);
  1352 			traceAction.setToolTipText(Constants.ACTION_START_TRACE);
  1407 			traceAction.setEnabled(disable);
  1353 			traceAction.setEnabled(disable);
  1408 		} else if (traceAction != null && !disable) {
  1354 		} else if (traceAction != null && !disable) {
  1409 			// disable trace action
  1355 			// disable trace action
  1410 			traceAction.setToolTipText(Constants.TRACE_NOT_FOUND);
  1356 			traceAction.setToolTipText(Constants.TRACE_NOT_FOUND);
  1411 			traceAction.setEnabled(disable);
  1357 			traceAction.setEnabled(disable);
  1412 		}
  1358 		}
  1413 
       
  1414 		traceActive = false;
  1359 		traceActive = false;
  1415 	}
  1360 	}
  1416 
  1361 
  1417 	/**
  1362 	/**
  1418 	 * Fills context menu.
  1363 	 * Fills context menu.
  1419 	 * 
  1364 	 * 
  1420 	 * @param manager
  1365 	 * @param manager
  1421 	 *            Menu manager
  1366 	 *            Menu manager
  1422 	 */
  1367 	 */
  1423 	private void fillContextMenu(IMenuManager manager) {
  1368 	private void fillContextMenu(IMenuManager manager) {
  1424 
       
  1425 		manager.add(buildWithAtool);
  1369 		manager.add(buildWithAtool);
  1426 		manager.add(new Separator());
  1370 		manager.add(new Separator());
  1427 		manager.add(traceAction);
  1371 		manager.add(traceAction);
  1428 		manager.add(startSubtest);
  1372 		manager.add(startSubtest);
  1429 		manager.add(stopSubtest);
  1373 		manager.add(stopSubtest);
  1468 	private void fillLocalToolBar(IToolBarManager manager) {
  1412 	private void fillLocalToolBar(IToolBarManager manager) {
  1469 
  1413 
  1470 		logTargetMenu = new DropDownMenu(Constants.ACTION_SAVE, this, false,
  1414 		logTargetMenu = new DropDownMenu(Constants.ACTION_SAVE, this, false,
  1471 				false);
  1415 				false);
  1472 		makeLogTargetActions();
  1416 		makeLogTargetActions();
       
  1417 		logTargetMenu.addAction(externalFastLogTargetAction);
  1473 		logTargetMenu.addAction(s60LogTargetAction);
  1418 		logTargetMenu.addAction(s60LogTargetAction);
  1474 		logTargetMenu.addAction(externalLogTargetAction);
       
  1475 		logTargetMenu.addAction(externalFastLogTargetAction);
       
  1476 		logTargetMenu.addAction(askLogTargetAction);
  1419 		logTargetMenu.addAction(askLogTargetAction);
  1477 		manager.add(logTargetMenu);
  1420 		manager.add(logTargetMenu);
  1478 
  1421 
  1479 		manager.add(buildWithAtool);
  1422 		manager.add(buildWithAtool);
  1480 		manager.add(new Separator());
  1423 		manager.add(new Separator());
  1611 					IProject tempProject = projects[i];
  1554 					IProject tempProject = projects[i];
  1612 					if (tempProject.isOpen()) {
  1555 					if (tempProject.isOpen()) {
  1613 						tempProject.accept(visitor);
  1556 						tempProject.accept(visitor);
  1614 					}
  1557 					}
  1615 				}
  1558 				}
  1616 
       
  1617 			} else { // project is selected
  1559 			} else { // project is selected
  1618 				// if project is open => accept resource visitor
  1560 				// if project is open => accept resource visitor
  1619 				if (projectRef.isOpen()) {
  1561 				if (projectRef.isOpen()) {
  1620 					projectRef.accept(visitor);
  1562 					projectRef.accept(visitor);
  1621 				}
  1563 				}
  1622 			}
  1564 			}
  1623 		} catch (CoreException e) {
  1565 		} catch (CoreException e) {
  1624 			e.printStackTrace();
  1566 			e.printStackTrace();
  1625 
       
  1626 		}
  1567 		}
  1627 	}
  1568 	}
  1628 
  1569 
  1629 	/**
  1570 	/**
  1630 	 * Gets project results.
  1571 	 * Gets project results.
  1676 	 * @return Object memory leak analysis results
  1617 	 * @return Object memory leak analysis results
  1677 	 */
  1618 	 */
  1678 	private Object getResults(final boolean showErrorInfo) {
  1619 	private Object getResults(final boolean showErrorInfo) {
  1679 
  1620 
  1680 		try {
  1621 		try {
  1681 			// create new tree paretn
  1622 			// create a new tree parent
  1682 			TreeParent testRuns = new TreeParent(Constants.TEST_RUNS_TREE_TITLE);
  1623 			TreeParent testRuns = new TreeParent(Constants.TEST_RUNS_TREE_TITLE);
  1683 			invisibleRoot = null;
  1624 			invisibleRoot = null;
  1684 			invisibleRoot = new TreeParent(Constants.TREE_TITLE);
  1625 			invisibleRoot = new TreeParent(Constants.TREE_TITLE);
  1685 			invisibleRoot.addChild(testRuns);
  1626 			invisibleRoot.addChild(testRuns);
  1686 
  1627 
  1715 
  1656 
  1716 				// display info to user
  1657 				// display info to user
  1717 				if (showErrorInfo) {
  1658 				if (showErrorInfo) {
  1718 					showErrorMessage(Constants.INFO_FILE_INVALID);
  1659 					showErrorMessage(Constants.INFO_FILE_INVALID);
  1719 				}
  1660 				}
  1720 
       
  1721 				return getStartupContent();
  1661 				return getStartupContent();
  1722 			}
  1662 			}
  1723 
  1663 
  1724 			IPreferenceStore store = Activator.getPreferences();
  1664 			IPreferenceStore store = Activator.getPreferences();
  1725 
  1665 
  1750 				// get active item
  1690 				// get active item
  1751 				// active must ask from the TreeHelper class
  1691 				// active must ask from the TreeHelper class
  1752 				// because it can be filtered out when creating new tree model
  1692 				// because it can be filtered out when creating new tree model
  1753 				activeTreeItem = helper.getActiveItem();
  1693 				activeTreeItem = helper.getActiveItem();
  1754 				testRuns.addChild(oneRunTree);
  1694 				testRuns.addChild(oneRunTree);
  1755 
  1695 			}
  1756 			}
       
  1757 
       
  1758 		} catch (java.lang.NullPointerException npe) {
  1696 		} catch (java.lang.NullPointerException npe) {
  1759 			npe.printStackTrace();
  1697 			npe.printStackTrace();
  1760 			return null;
  1698 			return null;
  1761 		}
  1699 		}
  1762 
       
  1763 		// expand to runs level
  1700 		// expand to runs level
  1764 		runView.setAutoExpandLevel(2);
  1701 		runView.setAutoExpandLevel(2);
  1765 
  1702 
  1766 		return invisibleRoot;
  1703 		return invisibleRoot;
  1767 	}
  1704 	}
  1802 		Menu menu = menuMgr.createContextMenu(runView.getControl());
  1739 		Menu menu = menuMgr.createContextMenu(runView.getControl());
  1803 		runView.getControl().setMenu(menu);
  1740 		runView.getControl().setMenu(menu);
  1804 		if (getSite() != null) {
  1741 		if (getSite() != null) {
  1805 			getSite().registerContextMenu(menuMgr, runView);
  1742 			getSite().registerContextMenu(menuMgr, runView);
  1806 		}
  1743 		}
  1807 
       
  1808 	}
  1744 	}
  1809 
  1745 
  1810 	/**
  1746 	/**
  1811 	 * Hook double click actions.
  1747 	 * Hook double click actions.
  1812 	 */
  1748 	 */
  1835 			ActiveSubtests oneSubtest = subTestIter.next();
  1771 			ActiveSubtests oneSubtest = subTestIter.next();
  1836 			if (oneSubtest.getName().equals(subTestName)
  1772 			if (oneSubtest.getName().equals(subTestName)
  1837 					&& oneSubtest.getTargetName().equals(target)) {
  1773 					&& oneSubtest.getTargetName().equals(target)) {
  1838 				return true;
  1774 				return true;
  1839 			}
  1775 			}
  1840 
       
  1841 		}
  1776 		}
  1842 		return false;
  1777 		return false;
  1843 	}
  1778 	}
  1844 
  1779 
  1845 	/**
  1780 	/**
  1896 						copyAction.setEnabled(false);
  1831 						copyAction.setEnabled(false);
  1897 					} else {
  1832 					} else {
  1898 						callstackView.setInput(resultObject);
  1833 						callstackView.setInput(resultObject);
  1899 						copyAction.setEnabled(true);
  1834 						copyAction.setEnabled(true);
  1900 					}
  1835 					}
  1901 
       
  1902 				}
  1836 				}
  1903 
  1837 
  1904 				// expand all the trees on call stack view
  1838 				// expand all the trees on call stack view
  1905 				callstackView.expandAll();
  1839 				callstackView.expandAll();
  1906 
  1840 
  2206 		s60LogTargetAction
  2140 		s60LogTargetAction
  2207 				.setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_S60);
  2141 				.setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_S60);
  2208 		s60LogTargetAction.setImageDescriptor(Activator
  2142 		s60LogTargetAction.setImageDescriptor(Activator
  2209 				.getImageDescriptor(Constants.BUTTON_CELLURAR));
  2143 				.getImageDescriptor(Constants.BUTTON_CELLURAR));
  2210 
  2144 
  2211 		externalLogTargetAction = new Action(Constants.LOGGING_EXT,
       
  2212 				IAction.AS_RADIO_BUTTON) {
       
  2213 			@Override
       
  2214 			public void run() {
       
  2215 				changeLogTarget(Constants.LOGGING_EXT);
       
  2216 			}
       
  2217 		};
       
  2218 		externalLogTargetAction.setText(Constants.PREFS_EXT);
       
  2219 		externalLogTargetAction
       
  2220 				.setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_EXT);
       
  2221 		externalLogTargetAction.setImageDescriptor(Activator
       
  2222 				.getImageDescriptor(Constants.BUTTON_COMPUTER));
       
  2223 
       
  2224 		externalFastLogTargetAction = new Action(Constants.LOGGING_EXT_FAST,
  2145 		externalFastLogTargetAction = new Action(Constants.LOGGING_EXT_FAST,
  2225 				IAction.AS_RADIO_BUTTON) {
  2146 				IAction.AS_RADIO_BUTTON) {
  2226 			@Override
  2147 			@Override
  2227 			public void run() {
  2148 			public void run() {
  2228 				changeLogTarget(Constants.LOGGING_EXT_FAST);
  2149 				changeLogTarget(Constants.LOGGING_EXT_FAST);
  2239 			@Override
  2160 			@Override
  2240 			public void run() {
  2161 			public void run() {
  2241 				changeLogTarget(Constants.LOGGING_ASK_ALLWAYS);
  2162 				changeLogTarget(Constants.LOGGING_ASK_ALLWAYS);
  2242 			}
  2163 			}
  2243 		};
  2164 		};
  2244 
       
  2245 		askLogTargetAction.setText(Constants.PREFS_ASK_ALWAYS);
  2165 		askLogTargetAction.setText(Constants.PREFS_ASK_ALWAYS);
  2246 		askLogTargetAction
  2166 		askLogTargetAction
  2247 				.setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_ASK);
  2167 				.setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_ASK);
  2248 		askLogTargetAction.setImageDescriptor(Activator
  2168 		askLogTargetAction.setImageDescriptor(Activator
  2249 				.getImageDescriptor(Constants.BUTTON_ASK));
  2169 				.getImageDescriptor(Constants.BUTTON_ASK));
  2250 
       
  2251 	}
  2170 	}
  2252 
  2171 
  2253 	/**
  2172 	/**
  2254 	 * Displays selected callstack item location on default file editor.
  2173 	 * Displays selected callstack item location on default file editor.
  2255 	 * 
  2174 	 * 
  2371 					clearProjectResults.setEnabled(true);
  2290 					clearProjectResults.setEnabled(true);
  2372 				} else {
  2291 				} else {
  2373 					clearProjectResults.setEnabled(false);
  2292 					clearProjectResults.setEnabled(false);
  2374 				}
  2293 				}
  2375 				updateChangeDetailState(project);
  2294 				updateChangeDetailState(project);
  2376 
       
  2377 			}
  2295 			}
  2378 		});
  2296 		});
  2379 	}
  2297 	}
  2380 
  2298 
  2381 	/**
  2299 	/**
  2414 	/**
  2332 	/**
  2415 	 * Copies existing report or data file to the new location. Asks from user
  2333 	 * Copies existing report or data file to the new location. Asks from user
  2416 	 * new location where to copy the file.
  2334 	 * new location where to copy the file.
  2417 	 * 
  2335 	 * 
  2418 	 * @param type
  2336 	 * @param type
  2419 	 *            Which kind of type the file is. Possible types xml or data
  2337 	 *            Which kind of type the file is. Possible types XML or data
  2420 	 *            file
  2338 	 *            file
  2421 	 * 
  2339 	 * 
  2422 	 * @return True if saving successfully otherwise false
  2340 	 * @return True if saving successfully otherwise false
  2423 	 */
  2341 	 */
  2424 	public final boolean saveReportFile(final int type) {
  2342 	public final boolean saveReportFile(final int type) {
  2465 				usedFile = targetPath;
  2383 				usedFile = targetPath;
  2466 			} else {
  2384 			} else {
  2467 				Util.showMessage(Constants.INFO_NO_RESULTS_FILE);
  2385 				Util.showMessage(Constants.INFO_NO_RESULTS_FILE);
  2468 				return success;
  2386 				return success;
  2469 			}
  2387 			}
  2470 
       
  2471 		}
  2388 		}
  2472 		// save data file
  2389 		// save data file
  2473 		else {
  2390 		else {
  2474 			String dataFile = Util.isDataFileAvailable(project);
  2391 			String dataFile = Util.isDataFileAvailable(project);
  2475 			// check is there data file which can be used
  2392 			// check is there data file which can be used
  2492 			names[0] = "*.dat";
  2409 			names[0] = "*.dat";
  2493 			names[1] = "*.*";
  2410 			names[1] = "*.*";
  2494 
  2411 
  2495 			Shell shell = null;
  2412 			Shell shell = null;
  2496 
  2413 
  2497 			// get shell from teh active view
  2414 			// get shell from the active view
  2498 			if (runView != null) {
  2415 			if (runView != null) {
  2499 				shell = runView.getControl().getShell();
  2416 				shell = runView.getControl().getShell();
  2500 			}
  2417 			}
  2501 
  2418 
  2502 			// if for some reason shell is null => leave
  2419 			// if for some reason shell is null => leave
  2503 			if (shell == null) {
  2420 			if (shell == null) {
  2504 				return success;
  2421 				return success;
  2505 			}
  2422 			}
  2506 
  2423 
  2507 			// ask user where to save xml report file
  2424 			// ask user where to save XML report file
  2508 			folder = Util.fileSaveDialog(Constants.DIALOG_SAVE_TRACE, names,
  2425 			folder = Util.fileSaveDialog(Constants.DIALOG_SAVE_TRACE, names,
  2509 					shell);
  2426 					shell);
  2510 		}
  2427 		}
  2511 
  2428 
  2512 		// no folder selected
  2429 		// no folder selected
  2576 
  2493 
  2577 			// resource found => get resource project
  2494 			// resource found => get resource project
  2578 			if (resource != null) {
  2495 			if (resource != null) {
  2579 				selectedProject = resource.getProject();
  2496 				selectedProject = resource.getProject();
  2580 			}
  2497 			}
  2581 
       
  2582 		}
  2498 		}
  2583 		// first item is null => update build state
  2499 		// first item is null => update build state
  2584 		else if (element == null) {
  2500 		else if (element == null) {
  2585 			updateBuildState(null);
  2501 			updateBuildState(null);
  2586 		}
  2502 		}
  2612 	 * Passing the focus request to the viewer's control.
  2528 	 * Passing the focus request to the viewer's control.
  2613 	 */
  2529 	 */
  2614 	@Override
  2530 	@Override
  2615 	public void setFocus() {
  2531 	public void setFocus() {
  2616 		runView.getControl().setFocus();
  2532 		runView.getControl().setFocus();
  2617 
       
  2618 	}
  2533 	}
  2619 
  2534 
  2620 	/**
  2535 	/**
  2621 	 * Sets text to information label.
  2536 	 * Sets text to information label.
  2622 	 */
  2537 	 */
  2646 						+ " \nEnd time: FAILED");
  2561 						+ " \nEnd time: FAILED");
  2647 			} else {
  2562 			} else {
  2648 				buffer.append("\nStart time: " + oneRunResults.getStartTime()
  2563 				buffer.append("\nStart time: " + oneRunResults.getStartTime()
  2649 						+ " \nEnd time: " + oneRunResults.getEndTime());
  2564 						+ " \nEnd time: " + oneRunResults.getEndTime());
  2650 			}
  2565 			}
  2651 
       
  2652 			updateInformationLabel(buffer.toString());
  2566 			updateInformationLabel(buffer.toString());
  2653 
  2567 		}
  2654 		}
       
  2655 
       
  2656 	}
  2568 	}
  2657 
  2569 
  2658 	/**
  2570 	/**
  2659 	 * Shows error message.
  2571 	 * Shows error message.
  2660 	 * 
  2572 	 * 
  2685 
  2597 
  2686 	/**
  2598 	/**
  2687 	 * Starts traceviewer connection.
  2599 	 * Starts traceviewer connection.
  2688 	 */
  2600 	 */
  2689 	private void start() {
  2601 	private void start() {
  2690 		// check is project selected and open
  2602 
       
  2603 		// check if the project is selected and open
  2691 		if (!checkProjectValidity()) {
  2604 		if (!checkProjectValidity()) {
  2692 			return;
  2605 			return;
  2693 		}
  2606 		}
  2694 
  2607 
  2695 		// get project file infos
  2608 		// get project file infos
  2819 						IStatus.OK, "Trace started", null);
  2732 						IStatus.OK, "Trace started", null);
  2820 			}
  2733 			}
  2821 		};
  2734 		};
  2822 		activateTrace.setUser(true);
  2735 		activateTrace.setUser(true);
  2823 		activateTrace.schedule();
  2736 		activateTrace.schedule();
  2824 
       
  2825 	}
  2737 	}
  2826 
  2738 
  2827 	/**
  2739 	/**
  2828 	 * Starts subtests.
  2740 	 * Starts subtests.
  2829 	 */
  2741 	 */
  2890 				processID);
  2802 				processID);
  2891 		startedSubtest.add(subtes);
  2803 		startedSubtest.add(subtes);
  2892 
  2804 
  2893 		// start subtest
  2805 		// start subtest
  2894 		parser.parse(Constants.PREFIX + " " + subtes.getProcessID()
  2806 		parser.parse(Constants.PREFIX + " " + subtes.getProcessID()
  2895 				+ " TEST_START 0000 " + subTestName);
  2807 				+ " TSS 0000 " + subTestName);
  2896 		updateSubtestInfoText(Constants.SUBTEST_STARTED + target
  2808 		updateSubtestInfoText(Constants.SUBTEST_STARTED + target
  2897 				+ Constants.ENRULE + subTestName);
  2809 				+ Constants.ENRULE + subTestName);
  2898 
  2810 
  2899 		stopSubtest.setEnabled(true);
  2811 		stopSubtest.setEnabled(true);
  2900 	}
  2812 	}
  2954 			ite.printStackTrace();
  2866 			ite.printStackTrace();
  2955 
  2867 
  2956 		} catch (InstantiationException iv) {
  2868 		} catch (InstantiationException iv) {
  2957 			iv.printStackTrace();
  2869 			iv.printStackTrace();
  2958 		}
  2870 		}
  2959 
       
  2960 	}
  2871 	}
  2961 
  2872 
  2962 	/**
  2873 	/**
  2963 	 * Updates button states and creates results for project.
  2874 	 * Updates button states and creates results for project.
  2964 	 */
  2875 	 */
  2973 		// close any active subtests
  2884 		// close any active subtests
  2974 		if (!startedSubtest.isEmpty()) {
  2885 		if (!startedSubtest.isEmpty()) {
  2975 			for (int j = 0; j < startedSubtest.size(); j++) {
  2886 			for (int j = 0; j < startedSubtest.size(); j++) {
  2976 				ActiveSubtests oneSubtest = startedSubtest.get(j);
  2887 				ActiveSubtests oneSubtest = startedSubtest.get(j);
  2977 				parser.parse(Constants.PREFIX + " " + oneSubtest.getProcessID()
  2888 				parser.parse(Constants.PREFIX + " " + oneSubtest.getProcessID()
  2978 						+ " TEST_END" + " 0000 " + oneSubtest.getName());
  2889 						+ " TSE 0000 " + oneSubtest.getName());
  2979 			}
  2890 			}
  2980 			startedSubtest.clear();
  2891 			startedSubtest.clear();
  2981 		}
  2892 		}
  2982 
  2893 
  2983 		// tell parser to finish => write data to file
  2894 		// tell parser to finish => write data to file
  3012 		} else {
  2923 		} else {
  3013 			// only one subtest no need to ask for users
  2924 			// only one subtest no need to ask for users
  3014 			if (startedSubtest.size() == 1) {
  2925 			if (startedSubtest.size() == 1) {
  3015 				ActiveSubtests oneSubtest = startedSubtest.get(0);
  2926 				ActiveSubtests oneSubtest = startedSubtest.get(0);
  3016 				parser.parse(Constants.PREFIX + " " + oneSubtest.getProcessID()
  2927 				parser.parse(Constants.PREFIX + " " + oneSubtest.getProcessID()
  3017 						+ " TEST_END" + " 0000 " + oneSubtest.getName());
  2928 						+ " TSE 0000 " + oneSubtest.getName());
  3018 				updateSubtestInfoText(Constants.SUBTEST_ENDED
  2929 				updateSubtestInfoText(Constants.SUBTEST_ENDED
  3019 						+ oneSubtest.getTargetName() + Constants.ENRULE
  2930 						+ oneSubtest.getTargetName() + Constants.ENRULE
  3020 						+ oneSubtest.getName());
  2931 						+ oneSubtest.getName());
  3021 				startedSubtest.remove(0);
  2932 				startedSubtest.remove(0);
  3022 				stopSubtest.setEnabled(false);
  2933 				stopSubtest.setEnabled(false);
  3046 
  2957 
  3047 					// if user selected subtest name and current subtest equals
  2958 					// if user selected subtest name and current subtest equals
  3048 					if (splittedText[2].equals(oneSubtest.getName())) {
  2959 					if (splittedText[2].equals(oneSubtest.getName())) {
  3049 						// write subtest end tag to data file
  2960 						// write subtest end tag to data file
  3050 						parser.parse(Constants.PREFIX + " "
  2961 						parser.parse(Constants.PREFIX + " "
  3051 								+ oneSubtest.getProcessID() + " TEST_END"
  2962 								+ oneSubtest.getProcessID() + " TSE 0000 "
  3052 								+ " 0000 " + oneSubtest.getName());
  2963 								+ oneSubtest.getName());
  3053 						updateSubtestInfoText(Constants.SUBTEST_ENDED
  2964 						updateSubtestInfoText(Constants.SUBTEST_ENDED
  3054 								+ oneSubtest.getTargetName() + Constants.ENRULE
  2965 								+ oneSubtest.getTargetName() + Constants.ENRULE
  3055 								+ oneSubtest.getName());
  2966 								+ oneSubtest.getName());
  3056 						// remove current subtest from active subtest
  2967 						// remove current subtest from active subtest
  3057 						// AbstractList
  2968 						// AbstractList
  3058 						startedSubtest.remove(k);
  2969 						startedSubtest.remove(k);
  3059 						break;
  2970 						break;
  3060 					}
  2971 					}
  3061 				}
  2972 				}
  3062 
       
  3063 				if (startedSubtest.isEmpty()) {
  2973 				if (startedSubtest.isEmpty()) {
  3064 					stopSubtest.setEnabled(false);
  2974 					stopSubtest.setEnabled(false);
  3065 				}
  2975 				}
  3066 			}
  2976 			}
  3067 		}
  2977 		}
  3102 	public final void updateAllocNumber() {
  3012 	public final void updateAllocNumber() {
  3103 
  3013 
  3104 		runView.getControl().getDisplay().syncExec(new Runnable() {
  3014 		runView.getControl().getDisplay().syncExec(new Runnable() {
  3105 			public void run() {
  3015 			public void run() {
  3106 
  3016 
  3107 				// if lable is created
  3017 				// if label is created
  3108 				if (informationLabel != null) {
  3018 				if (informationLabel != null) {
  3109 					// get existing label text
  3019 					// get existing label text
  3110 					String tmpText = informationLabel.getText();
  3020 					String tmpText = informationLabel.getText();
  3111 
  3021 
  3112 					// split existing text
  3022 					// split existing text
  3133 					} else {
  3043 					} else {
  3134 						informationLabel.setText(tmpText + lineFeed
  3044 						informationLabel.setText(tmpText + lineFeed
  3135 								+ Constants.INFO_ALLOCATED_MEM
  3045 								+ Constants.INFO_ALLOCATED_MEM
  3136 								+ parser.getAllocationsSize());
  3046 								+ parser.getAllocationsSize());
  3137 					}
  3047 					}
  3138 
  3048 				}
  3139 				}
       
  3140 
       
  3141 			}
  3049 			}
  3142 		});
  3050 		});
  3143 
       
  3144 	}
  3051 	}
  3145 
  3052 
  3146 	/**
  3053 	/**
  3147 	 * Update build action icon and tooltip text.
  3054 	 * Update build action icon and tooltip text.
  3148 	 * 
  3055 	 * 
  3170 		} else {
  3077 		} else {
  3171 			buildWithAtool.setText(Constants.ACTION_AT_BUILD_DEACTIVE);
  3078 			buildWithAtool.setText(Constants.ACTION_AT_BUILD_DEACTIVE);
  3172 			buildWithAtool.setToolTipText(Constants.ACTION_AT_BUILD_DEACTIVE);
  3079 			buildWithAtool.setToolTipText(Constants.ACTION_AT_BUILD_DEACTIVE);
  3173 			buildWithAtool.setChecked(false);
  3080 			buildWithAtool.setChecked(false);
  3174 		}
  3081 		}
  3175 
       
  3176 	}
  3082 	}
  3177 
  3083 
  3178 	/**
  3084 	/**
  3179 	 * Indicates the target (emulator/device) by inspecting the given projects
  3085 	 * Indicates the target (emulator/device) by inspecting the given projects
  3180 	 * build configuration.
  3086 	 * build configuration.
  3223 
  3129 
  3224 		String dataFile = projectResults.getDataFileName(projectRef);
  3130 		String dataFile = projectResults.getDataFileName(projectRef);
  3225 		if (dataFile != null) {
  3131 		if (dataFile != null) {
  3226 			int fileType = UseAtool.checkFileType(dataFile);
  3132 			int fileType = UseAtool.checkFileType(dataFile);
  3227 			if (fileType == Constants.DATAFILE_TRACE
  3133 			if (fileType == Constants.DATAFILE_TRACE
  3228 					|| fileType == Constants.DATAFILE_LOG) {
  3134 					|| fileType == Constants.DATAFILE_LOG
       
  3135 					|| fileType == Constants.DATAFILE_BINARY) {
  3229 				refreshResults.setEnabled(true);
  3136 				refreshResults.setEnabled(true);
  3230 			} else {
  3137 			} else {
  3231 				refreshResults.setEnabled(false);
  3138 				refreshResults.setEnabled(false);
  3232 			}
  3139 			}
  3233 		} else {
  3140 		} else {
  3272 			public void run() {
  3179 			public void run() {
  3273 				// if informationlabel exists set text
  3180 				// if informationlabel exists set text
  3274 				if (informationLabel != null) {
  3181 				if (informationLabel != null) {
  3275 					informationLabel.setText(oneLine);
  3182 					informationLabel.setText(oneLine);
  3276 				}
  3183 				}
  3277 
       
  3278 			}
  3184 			}
  3279 		});
  3185 		});
  3280 
       
  3281 	}
  3186 	}
  3282 
  3187 
  3283 	/**
  3188 	/**
  3284 	 * Updates Subtest info to the information label.
  3189 	 * Updates Subtest info to the information label.
  3285 	 * 
  3190 	 * 
  3317 						// set new text to information label
  3222 						// set new text to information label
  3318 						informationLabel.setText(tmpBuffer.toString());
  3223 						informationLabel.setText(tmpBuffer.toString());
  3319 					} else {
  3224 					} else {
  3320 						informationLabel.setText(origText + newText);
  3225 						informationLabel.setText(origText + newText);
  3321 					}
  3226 					}
  3322 
  3227 				}
  3323 				}
       
  3324 
       
  3325 			}
  3228 			}
  3326 		});
  3229 		});
  3327 	}
  3230 	}
  3328 
  3231 
  3329 	/**
  3232 	/**
  3382 		// if ctrl and c key pressed => run copy action
  3285 		// if ctrl and c key pressed => run copy action
  3383 		if (ctrlPressed & cPressed) {
  3286 		if (ctrlPressed & cPressed) {
  3384 			// Triggering copy action
  3287 			// Triggering copy action
  3385 			copyAction.run();
  3288 			copyAction.run();
  3386 		}
  3289 		}
  3387 
       
  3388 	}
  3290 	}
  3389 
  3291 
  3390 	/**
  3292 	/**
  3391 	 * (non-Javadoc)
  3293 	 * (non-Javadoc)
  3392 	 * 
  3294 	 * 
  3436 							DeferredCallstackManager callstackManager = new DeferredCallstackManager(
  3338 							DeferredCallstackManager callstackManager = new DeferredCallstackManager(
  3437 									datFileLocation);
  3339 									datFileLocation);
  3438 							callstackManager.setProcesses(processes);
  3340 							callstackManager.setProcesses(processes);
  3439 							model.setCallstackManager(callstackManager);
  3341 							model.setCallstackManager(callstackManager);
  3440 						} else {
  3342 						} else {
  3441 							model.setCallstackManager(new SimpleCallstackManager());
  3343 							model
       
  3344 									.setCallstackManager(new SimpleCallstackManager());
  3442 						}
  3345 						}
  3443 					}
  3346 					}
  3444 					if (!monitor.isCanceled()) {
  3347 					if (!monitor.isCanceled()) {
  3445 						chart.setInput(project, model);
  3348 						chart.setInput(project, model);
  3446 						model.addProcesses(processes);
  3349 						model.addProcesses(processes);
  3447 					}
  3350 					}
  3448 					fileReader.finish();
  3351 					fileReader.finish();
  3449 				}
  3352 				}
  3450 
       
  3451 			} catch (OutOfMemoryError oome) {
  3353 			} catch (OutOfMemoryError oome) {
  3452 				Activator
  3354 				Activator
  3453 						.getDefault()
  3355 						.getDefault()
  3454 						.logInfo(IStatus.ERROR, IStatus.ERROR,
  3356 						.logInfo(IStatus.ERROR, IStatus.ERROR,
  3455 								"Can not allocate enough memory for the memory usage graph model.");
  3357 								"Can not allocate enough memory for the memory usage graph model.");
  3458 						"Error while generating graph model", e);
  3360 						"Error while generating graph model", e);
  3459 			}
  3361 			}
  3460 			graphLoadJob = null;
  3362 			graphLoadJob = null;
  3461 			return Status.OK_STATUS;
  3363 			return Status.OK_STATUS;
  3462 		}
  3364 		}
  3463 
       
  3464 	}
  3365 	}
  3465 }
  3366 }