sysperfana/perfinvestigator/com.nokia.carbide.cpp.pi.address/src/com/nokia/carbide/cpp/pi/address/AddrThreadTable.java
changeset 5 844b047e260d
parent 2 b9ab3b238396
child 12 ae255c9aa552
equal deleted inserted replaced
4:615035072f7e 5:844b047e260d
    57 import org.eclipse.swt.widgets.Sash;
    57 import org.eclipse.swt.widgets.Sash;
    58 import org.eclipse.swt.widgets.Table;
    58 import org.eclipse.swt.widgets.Table;
    59 import org.eclipse.swt.widgets.TableColumn;
    59 import org.eclipse.swt.widgets.TableColumn;
    60 import org.eclipse.swt.widgets.TableItem;
    60 import org.eclipse.swt.widgets.TableItem;
    61 
    61 
       
    62 import com.nokia.carbide.cpp.internal.pi.address.GppModelAdapter;
    62 import com.nokia.carbide.cpp.internal.pi.analyser.NpiInstanceRepository;
    63 import com.nokia.carbide.cpp.internal.pi.analyser.NpiInstanceRepository;
    63 import com.nokia.carbide.cpp.internal.pi.analyser.ProfileVisualiser;
    64 import com.nokia.carbide.cpp.internal.pi.analyser.ProfileVisualiser;
    64 import com.nokia.carbide.cpp.internal.pi.interfaces.ISaveSamples;
    65 import com.nokia.carbide.cpp.internal.pi.interfaces.ISaveSamples;
    65 import com.nokia.carbide.cpp.internal.pi.model.ProfiledBinary;
       
    66 import com.nokia.carbide.cpp.internal.pi.model.ProfiledFunction;
       
    67 import com.nokia.carbide.cpp.internal.pi.model.ProfiledGeneric;
    66 import com.nokia.carbide.cpp.internal.pi.model.ProfiledGeneric;
    68 import com.nokia.carbide.cpp.internal.pi.model.ProfiledThread;
    67 import com.nokia.carbide.cpp.internal.pi.model.ProfiledThread;
    69 import com.nokia.carbide.cpp.internal.pi.model.ProfiledThreshold;
    68 import com.nokia.carbide.cpp.internal.pi.model.ProfiledThreshold;
    70 import com.nokia.carbide.cpp.internal.pi.visual.Defines;
    69 import com.nokia.carbide.cpp.internal.pi.visual.Defines;
    71 import com.nokia.carbide.cpp.internal.pi.visual.PIEvent;
    70 import com.nokia.carbide.cpp.internal.pi.visual.PIEvent;
    83 	// changes made to support priority plugin
    82 	// changes made to support priority plugin
    84 	private boolean priorityAdded = false;
    83 	private boolean priorityAdded = false;
    85 	private Hashtable<Integer,String> priorityTable;
    84 	private Hashtable<Integer,String> priorityTable;
    86 	private Hashtable<Integer,Integer> priorityValues;
    85 	private Hashtable<Integer,Integer> priorityValues;
    87 
    86 
    88 	public AddrThreadTable(GppTraceGraph myGraph, Composite parent)
    87 	public AddrThreadTable(GppTraceGraph myGraph, Composite parent, GppModelAdapter adapter)
    89 	{
    88 	{
    90 		this.myGraph = myGraph;
    89 		super(myGraph, parent, adapter);
    91 		this.parent  = parent;
       
    92 	}
    90 	}
    93 
    91 
    94 	public void createTableViewer(int drawMode)
    92 	public void createTableViewer(int drawMode)
    95 	{
    93 	{
    96 		if (this.parent == null)
    94 		if (this.parent == null)
   130 		this.tableViewer = CheckboxTableViewer.newCheckList(this.parent,
   128 		this.tableViewer = CheckboxTableViewer.newCheckList(this.parent,
   131   				SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
   129   				SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
   132 
   130 
   133 		// add the check state handler, label provider and content provider
   131 		// add the check state handler, label provider and content provider
   134 		tableViewer.addCheckStateListener(new SharedCheckHandler());
   132 		tableViewer.addCheckStateListener(new SharedCheckHandler());
   135 		tableViewer.setLabelProvider(new shownThreadsLabelProvider());
   133 		tableViewer.setLabelProvider(new ShownThreadsLabelProvider());
   136 		tableViewer.setContentProvider(new shownThreadsContentProvider());
   134 		tableViewer.setContentProvider(new ShownThreadsContentProvider());
   137 		tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
   135 		tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
   138 			public void selectionChanged(SelectionChangedEvent arg0) {
   136 			public void selectionChanged(SelectionChangedEvent arg0) {
   139 				if (copyAction == null)
   137 				if (copyAction == null)
   140 					return;
   138 					return;
   141 
   139 
   168 
   166 
   169 		// select/deselect column
   167 		// select/deselect column
   170 		column = new TableColumn(table, SWT.CENTER);
   168 		column = new TableColumn(table, SWT.CENTER);
   171 		column.setText(COLUMN_HEAD_SHOW);
   169 		column.setText(COLUMN_HEAD_SHOW);
   172 		column.setWidth(COLUMN_WIDTH_SHOW);
   170 		column.setWidth(COLUMN_WIDTH_SHOW);
   173 		column.setData(new Integer(COLUMN_ID_SHOW));
   171 		column.setData(Integer.valueOf(COLUMN_ID_SHOW));
   174 		column.setMoveable(true);
   172 		column.setMoveable(true);
   175 		column.setResizable(true);
   173 		column.setResizable(true);
   176 		column.addSelectionListener(new ColumnSelectionHandler());
   174 		column.addSelectionListener(new ColumnSelectionHandler());
   177 
   175 
   178 		// percent load column
   176 		// percent load column
   179 		column = new TableColumn(table, SWT.RIGHT);
   177 		column = new TableColumn(table, SWT.RIGHT);
   180 		column.setText(COLUMN_HEAD_PERCENT_LOAD);
   178 		column.setText(COLUMN_HEAD_PERCENT_LOAD);
   181 		column.setWidth(COLUMN_WIDTH_PERCENT_LOAD);
   179 		column.setWidth(COLUMN_WIDTH_PERCENT_LOAD);
   182 		column.setData(new Integer(COLUMN_ID_PERCENT_LOAD));
   180 		column.setData(Integer.valueOf(COLUMN_ID_PERCENT_LOAD));
   183 		column.setMoveable(true);
   181 		column.setMoveable(true);
   184 		column.setResizable(true);
   182 		column.setResizable(true);
   185 		column.addSelectionListener(new ColumnSelectionHandler());
   183 		column.addSelectionListener(new ColumnSelectionHandler());
   186 
   184 
   187 		// thread name column
   185 		// thread name column
   188 		column = new TableColumn(table, SWT.LEFT);
   186 		column = new TableColumn(table, SWT.LEFT);
   189 		column.setText(COLUMN_HEAD_THREAD);
   187 		column.setText(COLUMN_HEAD_THREAD);
   190 		column.setWidth(COLUMN_WIDTH_THREAD_NAME);
   188 		column.setWidth(COLUMN_WIDTH_THREAD_NAME);
   191 		column.setData(new Integer(COLUMN_ID_THREAD));
   189 		column.setData(Integer.valueOf(COLUMN_ID_THREAD));
   192 		column.setMoveable(true);
   190 		column.setMoveable(true);
   193 		column.setResizable(true);
   191 		column.setResizable(true);
   194 		column.addSelectionListener(new ColumnSelectionHandler());
   192 		column.addSelectionListener(new ColumnSelectionHandler());
   195 
   193 
   196 		// sample count column
   194 		// sample count column
   197 		column = new TableColumn(table, SWT.CENTER);
   195 		column = new TableColumn(table, SWT.CENTER);
   198 		column.setText(COLUMN_HEAD_SAMPLE_COUNT);
   196 		column.setText(COLUMN_HEAD_SAMPLE_COUNT);
   199 		column.setWidth(COLUMN_WIDTH_SAMPLE_COUNT);
   197 		column.setWidth(COLUMN_WIDTH_SAMPLE_COUNT);
   200 		column.setData(new Integer(COLUMN_ID_SAMPLE_COUNT));
   198 		column.setData(Integer.valueOf(COLUMN_ID_SAMPLE_COUNT));
   201 		column.setMoveable(true);
   199 		column.setMoveable(true);
   202 		column.setResizable(true);
   200 		column.setResizable(true);
   203 		column.addSelectionListener(new ColumnSelectionHandler());
   201 		column.addSelectionListener(new ColumnSelectionHandler());
   204 
   202 
   205 		// priority column
   203 		// priority column
   311 		}
   309 		}
   312 
   310 
   313 		table.redraw();
   311 		table.redraw();
   314 	}
   312 	}
   315 
   313 
   316 	private static class shownThreadsContentProvider implements IStructuredContentProvider {
   314 	private static class ShownThreadsContentProvider implements IStructuredContentProvider {
   317 
   315 
   318 		public shownThreadsContentProvider() {
   316 		public ShownThreadsContentProvider() {
   319 			super();
   317 			super();
   320 		}
   318 		}
   321 
   319 
   322 		public Object[] getElements(Object inputElement) {
   320 		public Object[] getElements(Object inputElement) {
   323 			return ((Vector) inputElement).toArray();
   321 			return ((Vector) inputElement).toArray();
   328 
   326 
   329 		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
   327 		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
   330 		}
   328 		}
   331 	}
   329 	}
   332 
   330 
   333 	private class shownThreadsLabelProvider extends LabelProvider implements ITableLabelProvider {
   331 	private class ShownThreadsLabelProvider extends LabelProvider implements ITableLabelProvider {
   334 
   332 
   335         public shownThreadsLabelProvider() {
   333         public ShownThreadsLabelProvider() {
   336 			super();
   334 			super();
   337 		}
   335 		}
   338 
   336 
       
   337 		/* (non-Javadoc)
       
   338 		 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
       
   339 		 */
   339 		public String getColumnText(Object element, int columnIndex) {
   340 		public String getColumnText(Object element, int columnIndex) {
   340 
   341 
   341 			int graphIndex = myGraph.getGraphIndex();
   342 			int graphIndex = myGraph.getGraphIndex();
   342 	        int columnId = ((Integer) table.getColumn(columnIndex).getData()).intValue();
   343 	        int columnId = ((Integer) table.getColumn(columnIndex).getData()).intValue();
   343 
   344 
   371 					}
   372 					}
   372 					case COLUMN_ID_THREAD:
   373 					case COLUMN_ID_THREAD:
   373 					{
   374 					{
   374 						DecimalFormat timeFormat = new DecimalFormat(Messages.getString("AddrThreadTable.decimalFormat")); //$NON-NLS-1$
   375 						DecimalFormat timeFormat = new DecimalFormat(Messages.getString("AddrThreadTable.decimalFormat")); //$NON-NLS-1$
   375 
   376 
   376 						int count = pThreshold.getItemCount(graphIndex);
   377 						int count = pThreshold.getItemCount();
   377 
   378 
   378 						return count + (count > 1 ? Messages.getString("AddrThreadTable.thresholdMsg1") : Messages.getString("AddrThreadTable.thresholdMsg2"))   //$NON-NLS-1$ //$NON-NLS-2$
   379 						return count + (count > 1 ? Messages.getString("AddrThreadTable.thresholdMsg1") : Messages.getString("AddrThreadTable.thresholdMsg2"))   //$NON-NLS-1$ //$NON-NLS-2$
   379 								+ timeFormat.format((Double)NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.thresholdLoadThread") * 100.0) + Messages.getString("AddrThreadTable.thresholdMsg3") //$NON-NLS-1$ //$NON-NLS-2$ 
   380 								+ timeFormat.format((Double)NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.thresholdLoadThread") * 100.0) + Messages.getString("AddrThreadTable.thresholdMsg3") //$NON-NLS-1$ //$NON-NLS-2$ 
   380 								+ (Integer)NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.thresholdCountThread") + Messages.getString("AddrThreadTable.thresholdMsg4"); //$NON-NLS-1$ //$NON-NLS-2$ 
   381 								+ (Integer)NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.thresholdCountThread") + Messages.getString("AddrThreadTable.thresholdMsg4"); //$NON-NLS-1$ //$NON-NLS-2$ 
   381 					}
   382 					}
   421 					return String.valueOf(profiledItem.getSampleCount(graphIndex));
   422 					return String.valueOf(profiledItem.getSampleCount(graphIndex));
   422 				}
   423 				}
   423 				case COLUMN_ID_PRIORITY:
   424 				case COLUMN_ID_PRIORITY:
   424 			    {
   425 			    {
   425 					if (priorityAdded) {
   426 					if (priorityAdded) {
   426 				        String priority = priorityTable.get(new Integer(profiledItem.getThreadId()));
   427 				        String priority = priorityTable.get(Integer.valueOf(profiledItem.getThreadId()));
   427 				        if (priority == null)
   428 				        if (priority == null)
   428 				        	return Messages.getString("AddrThreadTable.unknownPriority"); //$NON-NLS-1$
   429 				        	return Messages.getString("AddrThreadTable.unknownPriority"); //$NON-NLS-1$
   429 				        else
   430 				        else
   430 				        	return priority;
   431 				        	return priority;
   431 					}
   432 					}
   557 		{
   558 		{
   558 			// let the function page action handler handle it
   559 			// let the function page action handler handle it
   559 			this.myGraph.getFunctionTable().action(actionString);
   560 			this.myGraph.getFunctionTable().action(actionString);
   560 			return;
   561 			return;
   561 		}
   562 		}
   562 		else if (actionString.equals("changeThresholdThread")) //$NON-NLS-1$
   563 		else if (actionString.equals(IGppTraceGraph.ACTION_CHANGE_THRESHOLD_THREAD))
   563 		{
   564 		{
   564 			ProfiledThreshold threshold = this.myGraph.getThresholdThread();
   565 			ProfiledThreshold threshold = this.myGraph.getThresholdThread();
   565 			boolean enabled = threshold.isEnabled(graphIndex);
   566 			boolean enabled = threshold.isEnabled(graphIndex);
   566 
   567 
   567 			this.tableItemData.clear();
   568 			this.tableItemData.clear();
   568 			this.profiledThreads.clear();
   569 			this.profiledThreads.clear();
   569 			this.myGraph.getSortedThreads().clear();
   570 			this.myGraph.getSortedThreads().clear();
   570 			if (threshold.getItems(graphIndex) != null)
   571 			if (threshold.getItems() != null)
   571 				threshold.getItems(graphIndex).clear();
   572 				threshold.getItems().clear();
   572 			threshold.initAll();
   573 			adapter.init(threshold, graphIndex);
   573 
   574 
   574 			// if this appears, it needs to be the first item, so that it is drawn at the bottom
   575 			// if this appears, it needs to be the first item, so that it is drawn at the bottom
   575 			myGraph.getSortedThreads().add(threshold);
   576 			myGraph.getSortedThreads().add(threshold);
   576 
   577 
   577 			int threadThreshold = (Integer) NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.thresholdCountThread"); //$NON-NLS-1$
   578 			int threadThreshold = (Integer) NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.thresholdCountThread"); //$NON-NLS-1$
   578 			for (int i = 0; i < this.myGraph.getGppTrace().getSortedThreads().size(); i++) {
   579 			for (int i = 0; i < this.myGraph.getGppTrace().getSortedThreads().size(); i++) {
   579 				ProfiledGeneric nextElement = (ProfiledGeneric)this.myGraph.getGppTrace().getSortedThreads().get(i);
   580 				ProfiledGeneric nextElement = (ProfiledGeneric)this.myGraph.getGppTrace().getSortedThreads().get(i);
   580 				if (nextElement.getTotalSampleCount() < threadThreshold) {
   581 				if (adapter.getTotalSampleCount(nextElement) < threadThreshold) {
   581 					nextElement.setEnabled(graphIndex, enabled);
   582 					nextElement.setEnabled(graphIndex, enabled);
   582 					threshold.addItem(graphIndex, nextElement, 0);
   583 					adapter.addItem(threshold, graphIndex, nextElement, 0);
   583 				} else {
   584 				} else {
   584 					tableItemData.add(nextElement);
   585 					tableItemData.add(nextElement);
   585 					profiledThreads.add(nextElement);
   586 					profiledThreads.add(nextElement);
   586 					myGraph.getSortedThreads().add(nextElement);
   587 					myGraph.getSortedThreads().add(nextElement);
   587 				}
   588 				}
   588 			}
   589 			}
   589 
   590 
   590 			if (threshold.getItemCount(graphIndex) != 0) {
   591 			if (threshold.getItemCount() != 0) {
   591 				tableItemData.add(threshold);
   592 				tableItemData.add(threshold);
   592 				profiledThreads.add(threshold);
   593 				profiledThreads.add(threshold);
   593 			} else {
   594 			} else {
   594 				// remove the threshold item
   595 				// remove the threshold item
   595 				myGraph.getSortedThreads().remove(0);
   596 				myGraph.getSortedThreads().remove(0);
   658 				totalSamples += pGeneric.getSampleCount(graphIndex);
   659 				totalSamples += pGeneric.getSampleCount(graphIndex);
   659    				
   660    				
   660    				if (item instanceof ProfiledThreshold)
   661    				if (item instanceof ProfiledThreshold)
   661    				{
   662    				{
   662    					ProfiledThreshold pThreshold = (ProfiledThreshold)item;
   663    					ProfiledThreshold pThreshold = (ProfiledThreshold)item;
   663    					ArrayList<ProfiledGeneric> items = pThreshold.getItems(graphIndex);
   664    					for (ProfiledGeneric p : pThreshold.getItems())
   664    					for (int j = 0; j < items.size(); j++)
   665    						p.setEnabled(graphIndex, addIt);
   665    						items.get(j).setEnabled(graphIndex, addIt);
       
   666    				}
   666    				}
   667 			}
   667 			}
   668 		}
   668 		}
   669 
   669 
   670         // this table's set of checkbox-selected rows has changed,
   670         // this table's set of checkbox-selected rows has changed,
   711    				nameList[i] = pGeneric.getNameString();
   711    				nameList[i] = pGeneric.getNameString();
   712    				
   712    				
   713    				if (item instanceof ProfiledThreshold)
   713    				if (item instanceof ProfiledThreshold)
   714    				{
   714    				{
   715    					ProfiledThreshold pThreshold = (ProfiledThreshold)item;
   715    					ProfiledThreshold pThreshold = (ProfiledThreshold)item;
   716    					ArrayList<ProfiledGeneric> items = pThreshold.getItems(graphIndex);
   716    					for (ProfiledGeneric p : pThreshold.getItems())
   717    					for (int j = 0; j < items.size(); j++)
   717    						p.setEnabled(graphIndex, addIt);
   718    						items.get(j).setEnabled(graphIndex, addIt);
       
   719    				}
   718    				}
   720 			}
   719 			}
   721 		}
   720 		}
   722 
   721 
   723         // this table's set of checkbox-selected rows has changed,
   722         // this table's set of checkbox-selected rows has changed,
   758 					if (!(pGeneric instanceof ProfiledThreshold)) {
   757 					if (!(pGeneric instanceof ProfiledThreshold)) {
   759 						PIPageEditor.currentPageEditor().setDirty();
   758 						PIPageEditor.currentPageEditor().setDirty();
   760 						pGeneric.setColor(color);
   759 						pGeneric.setColor(color);
   761 					} else {
   760 					} else {
   762 						// for the threshold item, we must change every graph's thread threshold item
   761 						// for the threshold item, we must change every graph's thread threshold item
       
   762 						// CH: refactor! This could be done via an observer pattern. This class should not have knowledge of all other graphs  
   763 						gppTrace.getGppGraph(PIPageEditor.THREADS_PAGE,   uid).getThresholdThread().setColor(color);
   763 						gppTrace.getGppGraph(PIPageEditor.THREADS_PAGE,   uid).getThresholdThread().setColor(color);
   764 						gppTrace.getGppGraph(PIPageEditor.BINARIES_PAGE,  uid).getThresholdThread().setColor(color);
   764 						gppTrace.getGppGraph(PIPageEditor.BINARIES_PAGE,  uid).getThresholdThread().setColor(color);
   765 						gppTrace.getGppGraph(PIPageEditor.FUNCTIONS_PAGE, uid).getThresholdThread().setColor(color);
   765 						gppTrace.getGppGraph(PIPageEditor.FUNCTIONS_PAGE, uid).getThresholdThread().setColor(color);
       
   766 						if (gppTrace.getCPUCount() > 1){ //SMP
       
   767 							for (int cpu = 0; cpu < gppTrace.getCPUCount(); cpu++) {
       
   768 								gppTrace.getGppGraph(3 + cpu, uid).getThresholdThread().setColor(color);															
       
   769 							}
       
   770 						}
   766 					}
   771 					}
   767 				}
   772 				}
   768 
   773 
   769 				// recoloring should only be done in a draw mode that displays this table's colors
   774 				// recoloring should only be done in a draw mode that displays this table's colors
   770 				selectedItems[i].setBackground(COLOR_COLUMN_INDEX, palette.getColor(nameKey));
   775 				selectedItems[i].setBackground(COLOR_COLUMN_INDEX, palette.getColor(nameKey));
   778 		this.myGraph.repaint();
   783 		this.myGraph.repaint();
   779 		this.myGraph.setGraphImageChanged(true);	// any selection change to drill down will change graph
   784 		this.myGraph.setGraphImageChanged(true);	// any selection change to drill down will change graph
   780 		
   785 		
   781 		// if any other tabs are displaying this type of graph, they need to be scheduled for redrawing
   786 		// if any other tabs are displaying this type of graph, they need to be scheduled for redrawing
   782 		for (int i = 0; i < 3; i++) {
   787 		for (int i = 0; i < 3; i++) {
   783 			GppTraceGraph graph = gppTrace.getGppGraph(i, uid);
   788 			IGppTraceGraph graph = gppTrace.getGppGraph(i, uid);
   784 
   789 
   785 			if (graph == this.myGraph)
   790 			if (graph == this.myGraph)
   786 				continue;
   791 				continue;
   787 
   792 
   788 			int drawMode = graph.getDrawMode();
   793 			int drawMode = graph.getDrawMode();
   814 			return;
   819 			return;
   815 		}
   820 		}
   816 		
   821 		
   817 		setIsDrilldown(false);
   822 		setIsDrilldown(false);
   818 
   823 
   819 		// set the page's graph title
       
   820 		ProfileVisualiser pV =  NpiInstanceRepository.getInstance().getProfilePage(this.myGraph.getUid(), this.myGraph.getGraphIndex());
       
   821 		pV.getTitle().setText(Messages.getString("AddrThreadTable.threadLoad")); //$NON-NLS-1$
       
   822 		pV.getTitle2().setText(""); //$NON-NLS-1$
       
   823 
       
   824 		// get rid of any existing tables and sashes
   824 		// get rid of any existing tables and sashes
   825 		if (this.myGraph.getLeftSash() != null) {
   825 		if (this.myGraph.getLeftSash() != null) {
   826 			this.myGraph.getLeftSash().dispose();
   826 			this.myGraph.getLeftSash().dispose();
   827 			this.myGraph.setLeftSash(null);
   827 			this.myGraph.setLeftSash(null);
   828 
   828 
   871 		}
   871 		}
   872 		
   872 		
   873 		setIsDrilldown(true);
   873 		setIsDrilldown(true);
   874 
   874 
   875 		if (drawMode == Defines.THREADS) {
   875 		if (drawMode == Defines.THREADS) {
   876 			// set the page's graph title
       
   877 			ProfileVisualiser pV =  NpiInstanceRepository.getInstance().getProfilePage(this.myGraph.getUid(), this.myGraph.getGraphIndex());
       
   878 			pV.getTitle().setText(Messages.getString("AddrThreadTable.binaryLoad")); //$NON-NLS-1$
       
   879 			pV.getTitle2().setText(Messages.getString("AddrThreadTable.threadTo")); //$NON-NLS-1$
       
   880 
   876 
   881 			// set the draw mode before populating table viewers, since the
   877 			// set the draw mode before populating table viewers, since the
   882 			// color column depends on the draw mode
   878 			// color column depends on the draw mode
   883 			this.myGraph.setDrawMode(Defines.THREADS_BINARIES);
   879 			this.myGraph.setDrawMode(Defines.THREADS_BINARIES);
   884 
   880 
   887 			binaryTable.createTableViewer(Defines.THREADS_BINARIES);
   883 			binaryTable.createTableViewer(Defines.THREADS_BINARIES);
   888 			binaryTable.setIsDrilldown(true);
   884 			binaryTable.setIsDrilldown(true);
   889 
   885 
   890 			// create a reduced set of binary entries based on enabled thread entries
   886 			// create a reduced set of binary entries based on enabled thread entries
   891 			GppTrace gppTrace = (GppTrace) this.myGraph.getTrace();
   887 			GppTrace gppTrace = (GppTrace) this.myGraph.getTrace();
   892 			Vector<ProfiledGeneric> binaries = gppTrace.setThreadBinary(graphIndex);
   888 			gppTrace.setThreadBinary(graphIndex, adapter, this.myGraph.getProfiledBinaries());
   893 			this.myGraph.setProfiledBinaries(binaries);
       
   894 
   889 
   895 			// put check marks on all rows, and sort by sample count
   890 			// put check marks on all rows, and sort by sample count
   896 			binaryTable.quickSort(COLUMN_ID_SAMPLE_COUNT, this.myGraph.getProfiledBinaries());
   891 			binaryTable.quickSort(COLUMN_ID_SAMPLE_COUNT, this.myGraph.getProfiledBinaries());
   897 			binaryTable.updateProfiledAndItemData(true);
   892 			binaryTable.updateProfiledAndItemData(true);
   898 			binaryTable.getTableViewer().setAllChecked(true);
   893 			binaryTable.getTableViewer().setAllChecked(true);
   947 			this.parent.layout();
   942 			this.parent.layout();
   948 
   943 
   949 			this.myGraph.repaint();
   944 			this.myGraph.repaint();
   950 
   945 
   951 		} else if (drawMode == Defines.THREADS_BINARIES_FUNCTIONS) {
   946 		} else if (drawMode == Defines.THREADS_BINARIES_FUNCTIONS) {
   952 			// set the page's graph title
       
   953 			ProfileVisualiser pV =  NpiInstanceRepository.getInstance().getProfilePage(this.myGraph.getUid(), this.myGraph.getGraphIndex());
       
   954 			pV.getTitle().setText(Messages.getString("AddrThreadTable.binaryLoad")); //$NON-NLS-1$
       
   955 			pV.getTitle2().setText(Messages.getString("AddrThreadTable.threadTo")); //$NON-NLS-1$
       
   956 
   947 
   957 			// get rid of the function table and its sash
   948 			// get rid of the function table and its sash
   958 			if (this.myGraph.getRightSash() != null) {
   949 			if (this.myGraph.getRightSash() != null) {
   959 				this.myGraph.getRightSash().dispose();
   950 				this.myGraph.getRightSash().dispose();
   960 				this.myGraph.setRightSash(null);
   951 				this.myGraph.setRightSash(null);
   967 
   958 
   968 			// get rid of the middle table's connection to the sash
   959 			// get rid of the middle table's connection to the sash
   969 			try {
   960 			try {
   970 				FormData formData = (FormData) this.myGraph.getBinaryTable().getTable().getLayoutData();
   961 				FormData formData = (FormData) this.myGraph.getBinaryTable().getTable().getLayoutData();
   971 				formData.right = new FormAttachment(100);
   962 				formData.right = new FormAttachment(100);
   972 			} catch (ClassCastException e1) {
   963 			} catch (ClassCastException e1) { //CH: refactor!  Runtime exceptions should not be caught!
   973 			}
   964 			}
   974 
   965 
   975 			// move the left sash to the middle
   966 			// move the left sash to the middle
   976 			try {
   967 			try {
   977 				FormData formData = (FormData) this.myGraph.getLeftSash().getLayoutData();
   968 				FormData formData = (FormData) this.myGraph.getLeftSash().getLayoutData();
   978 				formData.left = new FormAttachment(50); // middle
   969 				formData.left = new FormAttachment(50); // middle
   979 			} catch (ClassCastException e1) {
   970 			} catch (ClassCastException e1) { //CH: refactor!  Runtime exceptions should not be caught!
   980 			}
   971 			}
   981 
   972 
   982 			// set the draw mode
   973 			// set the draw mode
   983 			this.myGraph.setDrawMode(Defines.THREADS_BINARIES);
   974 			this.myGraph.setDrawMode(Defines.THREADS_BINARIES);
   984 
   975 
  1004 			// this case should be drawMode == Defines.THREADS_BINARIES_FUNCTIONS
   995 			// this case should be drawMode == Defines.THREADS_BINARIES_FUNCTIONS
  1005 			return;
   996 			return;
  1006 		}
   997 		}
  1007 
   998 
  1008 		setIsDrilldown(true);
   999 		setIsDrilldown(true);
  1009 
       
  1010 		// set the page's graph title
       
  1011 		ProfileVisualiser pV =  NpiInstanceRepository.getInstance().getProfilePage(this.myGraph.getUid(), this.myGraph.getGraphIndex());
       
  1012 		pV.getTitle().setText(Messages.getString("AddrThreadTable.functionLoad")); //$NON-NLS-1$
       
  1013 		pV.getTitle2().setText(Messages.getString("AddrThreadTable.threadToBinaryTo")); //$NON-NLS-1$
       
  1014 
  1000 
  1015 		// set the draw mode before populating table viewers, since the
  1001 		// set the draw mode before populating table viewers, since the
  1016 		// color column depends on the draw mode
  1002 		// color column depends on the draw mode
  1017 		this.myGraph.setDrawMode(Defines.THREADS_BINARIES_FUNCTIONS);
  1003 		this.myGraph.setDrawMode(Defines.THREADS_BINARIES_FUNCTIONS);
  1018 
  1004 
  1021 		functionTable.createTableViewer(Defines.THREADS_BINARIES_FUNCTIONS);
  1007 		functionTable.createTableViewer(Defines.THREADS_BINARIES_FUNCTIONS);
  1022 		functionTable.setIsDrilldown(true);
  1008 		functionTable.setIsDrilldown(true);
  1023 
  1009 
  1024 		// create a reduced set of function entries based on enabled thread and binary entries
  1010 		// create a reduced set of function entries based on enabled thread and binary entries
  1025 		GppTrace gppTrace = (GppTrace) this.myGraph.getTrace();
  1011 		GppTrace gppTrace = (GppTrace) this.myGraph.getTrace();
  1026 		Vector<ProfiledGeneric> functions = gppTrace.setThreadBinaryFunction(graphIndex);
  1012 		gppTrace.setThreadBinaryFunction(graphIndex, adapter, this.myGraph.getProfiledFunctions());
  1027 		this.myGraph.setProfiledFunctions(functions);
       
  1028 
  1013 
  1029 		// put check marks on all rows, and sort by sample count
  1014 		// put check marks on all rows, and sort by sample count
  1030 		functionTable.quickSort(COLUMN_ID_SAMPLE_COUNT, this.myGraph.getProfiledFunctions());
  1015 		functionTable.quickSort(COLUMN_ID_SAMPLE_COUNT, this.myGraph.getProfiledFunctions());
  1031 		functionTable.updateProfiledAndItemData(true);
  1016 		functionTable.updateProfiledAndItemData(true);
  1032 		functionTable.getTableViewer().setAllChecked(true);
  1017 		functionTable.getTableViewer().setAllChecked(true);
  1095 		}
  1080 		}
  1096 
  1081 
  1097 		setIsDrilldown(true);
  1082 		setIsDrilldown(true);
  1098 
  1083 
  1099 		if (drawMode == Defines.THREADS) {
  1084 		if (drawMode == Defines.THREADS) {
  1100 			// set the page's graph title
       
  1101 			ProfileVisualiser pV =  NpiInstanceRepository.getInstance().getProfilePage(this.myGraph.getUid(), this.myGraph.getGraphIndex());
       
  1102 			pV.getTitle().setText(Messages.getString("AddrThreadTable.functionLoad")); //$NON-NLS-1$
       
  1103 			pV.getTitle2().setText(Messages.getString("AddrThreadTable.threadTo")); //$NON-NLS-1$
       
  1104 
  1085 
  1105 			// set the draw mode
  1086 			// set the draw mode
  1106 			this.myGraph.setDrawMode(Defines.THREADS_FUNCTIONS);
  1087 			this.myGraph.setDrawMode(Defines.THREADS_FUNCTIONS);
  1107 
  1088 
  1108 			// create the function graph table viewer
  1089 			// create the function graph table viewer
  1110 			functionTable.createTableViewer(Defines.THREADS_FUNCTIONS);
  1091 			functionTable.createTableViewer(Defines.THREADS_FUNCTIONS);
  1111 			functionTable.setIsDrilldown(true);
  1092 			functionTable.setIsDrilldown(true);
  1112 
  1093 
  1113 			// create a reduced set of function entries based on enabled thread and binary entries
  1094 			// create a reduced set of function entries based on enabled thread and binary entries
  1114 			GppTrace gppTrace = (GppTrace) this.myGraph.getTrace();
  1095 			GppTrace gppTrace = (GppTrace) this.myGraph.getTrace();
  1115 			Vector<ProfiledGeneric> functions = gppTrace.setThreadFunction(graphIndex);
  1096 			gppTrace.setThreadFunction(graphIndex, adapter, this.myGraph.getProfiledFunctions());
  1116 			this.myGraph.setProfiledFunctions(functions);
       
  1117 
  1097 
  1118 			// put check marks on all rows, and sort by sample count
  1098 			// put check marks on all rows, and sort by sample count
  1119 			functionTable.quickSort(COLUMN_ID_SAMPLE_COUNT, this.myGraph.getProfiledFunctions());
  1099 			functionTable.quickSort(COLUMN_ID_SAMPLE_COUNT, this.myGraph.getProfiledFunctions());
  1120 			functionTable.updateProfiledAndItemData(true);
  1100 			functionTable.updateProfiledAndItemData(true);
  1121 			functionTable.getTableViewer().setAllChecked(true);
  1101 			functionTable.getTableViewer().setAllChecked(true);
  1163 			this.parent.layout();
  1143 			this.parent.layout();
  1164 
  1144 
  1165 			this.myGraph.repaint();
  1145 			this.myGraph.repaint();
  1166 
  1146 
  1167 		} else if (drawMode == Defines.THREADS_FUNCTIONS_BINARIES) {
  1147 		} else if (drawMode == Defines.THREADS_FUNCTIONS_BINARIES) {
  1168 			// set the page's graph title
       
  1169 			ProfileVisualiser pV =  NpiInstanceRepository.getInstance().getProfilePage(this.myGraph.getUid(), this.myGraph.getGraphIndex());
       
  1170 			pV.getTitle().setText(Messages.getString("AddrThreadTable.functionLoad")); //$NON-NLS-1$
       
  1171 			pV.getTitle2().setText(Messages.getString("AddrThreadTable.threadTo")); //$NON-NLS-1$
       
  1172 
       
  1173 			// get rid of the binary table and its sash
  1148 			// get rid of the binary table and its sash
  1174 			if (this.myGraph.getRightSash() != null) {
  1149 			if (this.myGraph.getRightSash() != null) {
  1175 				this.myGraph.getRightSash().dispose();
  1150 				this.myGraph.getRightSash().dispose();
  1176 				this.myGraph.setRightSash(null);
  1151 				this.myGraph.setRightSash(null);
  1177 			}
  1152 			}
  1221 			return;
  1196 			return;
  1222 		}
  1197 		}
  1223 
  1198 
  1224 		setIsDrilldown(true);
  1199 		setIsDrilldown(true);
  1225 
  1200 
  1226 		// set the page's graph title
       
  1227 		ProfileVisualiser pV =  NpiInstanceRepository.getInstance().getProfilePage(this.myGraph.getUid(), this.myGraph.getGraphIndex());
       
  1228 		pV.getTitle().setText(Messages.getString("AddrThreadTable.binaryLoad")); //$NON-NLS-1$
       
  1229 		pV.getTitle2().setText(Messages.getString("AddrThreadTable.threadToFunctionTo")); //$NON-NLS-1$
       
  1230 
       
  1231 		// set the draw mode
  1201 		// set the draw mode
  1232 		this.myGraph.setDrawMode(Defines.THREADS_FUNCTIONS_BINARIES);
  1202 		this.myGraph.setDrawMode(Defines.THREADS_FUNCTIONS_BINARIES);
  1233 
  1203 
  1234 		// create the binary graph table viewer
  1204 		// create the binary graph table viewer
  1235 		AddrBinaryTable binaryTable = this.myGraph.getBinaryTable();
  1205 		AddrBinaryTable binaryTable = this.myGraph.getBinaryTable();
  1236 		binaryTable.createTableViewer(Defines.THREADS_FUNCTIONS_BINARIES);
  1206 		binaryTable.createTableViewer(Defines.THREADS_FUNCTIONS_BINARIES);
  1237 		binaryTable.setIsDrilldown(true);
  1207 		binaryTable.setIsDrilldown(true);
  1238 
  1208 
  1239 		// create a reduced set of binary entries based on enabled thread and function entries
  1209 		// create a reduced set of binary entries based on enabled thread and function entries
  1240 		GppTrace gppTrace = (GppTrace) this.myGraph.getTrace();
  1210 		GppTrace gppTrace = (GppTrace) this.myGraph.getTrace();
  1241 		Vector<ProfiledGeneric> binaries = gppTrace.setThreadFunctionBinary(graphIndex);
  1211 		gppTrace.setThreadFunctionBinary(graphIndex, adapter, this.myGraph.getProfiledBinaries());
  1242 		this.myGraph.setProfiledBinaries(binaries);
       
  1243 
  1212 
  1244 		// put check marks on all rows, and sort by sample count
  1213 		// put check marks on all rows, and sort by sample count
  1245 		binaryTable.quickSort(COLUMN_ID_SAMPLE_COUNT, this.myGraph.getProfiledBinaries());
  1214 		binaryTable.quickSort(COLUMN_ID_SAMPLE_COUNT, this.myGraph.getProfiledBinaries());
  1246 		binaryTable.updateProfiledAndItemData(true);
  1215 		binaryTable.updateProfiledAndItemData(true);
  1247 		binaryTable.getTableViewer().setAllChecked(true);
  1216 		binaryTable.getTableViewer().setAllChecked(true);
  1335 				int thresholdCount = (Integer)NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.thresholdCountThread"); //$NON-NLS-1$
  1304 				int thresholdCount = (Integer)NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.thresholdCountThread"); //$NON-NLS-1$
  1336 				if (thresholdCount > 0) {
  1305 				if (thresholdCount > 0) {
  1337 					Vector<ProfiledGeneric> pGeneric = this.myGraph.getProfiledThreads();
  1306 					Vector<ProfiledGeneric> pGeneric = this.myGraph.getProfiledThreads();
  1338 					int sampleCount = 0;
  1307 					int sampleCount = 0;
  1339 					for (int i = 0; i < pGeneric.size(); i++)
  1308 					for (int i = 0; i < pGeneric.size(); i++)
  1340 						if (pGeneric.elementAt(i).getTotalSampleCount() < thresholdCount)
  1309 						if (adapter.getTotalSampleCount(pGeneric.elementAt(i)) < thresholdCount)
  1341 							sampleCount += pGeneric.elementAt(i).getSampleCount(graphIndex);
  1310 							sampleCount += pGeneric.elementAt(i).getSampleCount(graphIndex);
  1342 					this.myGraph.getThresholdThread().setSampleCount(graphIndex, sampleCount);
  1311 					this.myGraph.getThresholdThread().setSampleCount(graphIndex, sampleCount);
  1343 				}
  1312 				}
  1344 			}
  1313 			}
  1345 
  1314 
  1361 			int drawMode = this.myGraph.getDrawMode();
  1330 			int drawMode = this.myGraph.getDrawMode();
  1362 			if (drawMode == Defines.THREADS)
  1331 			if (drawMode == Defines.THREADS)
  1363 				return;
  1332 				return;
  1364 
  1333 
  1365 			GppTrace trace = (GppTrace)(this.myGraph.getTrace());
  1334 			GppTrace trace = (GppTrace)(this.myGraph.getTrace());
  1366 			Vector<ProfiledGeneric> traceThreads = trace.getIndexedThreads();
       
  1367 
       
  1368 			int startSampleIndex = trace.getStartSampleIndex();
       
  1369 			int endSampleIndex   = trace.getEndSampleIndex();
       
  1370 			double percentPerSample;
       
  1371 			if (startSampleIndex == endSampleIndex)
       
  1372 				percentPerSample = 0.0;
       
  1373 			else
       
  1374 				percentPerSample = 100.0 / ((double)(endSampleIndex - startSampleIndex));
       
  1375 
       
  1376 			PIEvent be3 = new PIEvent(be.getValueObject(), PIEvent.SELECTION_AREA_CHANGED3);
  1335 			PIEvent be3 = new PIEvent(be.getValueObject(), PIEvent.SELECTION_AREA_CHANGED3);
  1377 
  1336 
  1378 			switch (drawMode) {
  1337 			switch (drawMode) {
  1379 				case Defines.THREADS_BINARIES:
  1338 				case Defines.THREADS_BINARIES:
  1380 				{
  1339 				{
  1381 					// get new binary counts and loads
  1340 					trace.setThreadBinary(graphIndex, adapter, this.myGraph.getProfiledBinaries());
  1382 					Vector<ProfiledGeneric> traceBinaries = trace.getIndexedBinaries();
       
  1383 					Vector<ProfiledGeneric> graphBinaries  = this.myGraph.getProfiledBinaries();
       
  1384 					Hashtable<String,String> foundBinaries  = new Hashtable<String,String>();
       
  1385 
       
  1386 					// previous binaries are not necessarily graphed this time
       
  1387 					Enumeration<ProfiledGeneric> enu = graphBinaries.elements();
       
  1388 					while (enu.hasMoreElements()) {
       
  1389 						ProfiledBinary pBinary = (ProfiledBinary) enu.nextElement();
       
  1390 						pBinary.setEnabled(graphIndex, false);
       
  1391 					}
       
  1392 					graphBinaries.clear();
       
  1393 
       
  1394 					ProfiledThreshold thresholdBinary = this.myGraph.getThresholdBinary();
       
  1395 
       
  1396 					if (thresholdBinary.isEnabled(graphIndex)) {
       
  1397 						ArrayList<ProfiledGeneric> items = thresholdBinary.getItems(graphIndex);
       
  1398 						// disable all items below the threshold
       
  1399 						for (int i = 0; i < items.size(); i++) {
       
  1400 							items.get(i).setEnabled(graphIndex, false);
       
  1401 						}
       
  1402 					}
       
  1403 
       
  1404 					GppSample[] sortedSamples = trace.getSortedGppSamples();
       
  1405 
       
  1406 					// set up in case we find binaries below the threshold
       
  1407 					boolean lowBinary;
       
  1408 					thresholdBinary.init(graphIndex);
       
  1409 					
       
  1410 					int binaryThreshold = (Integer) NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.thresholdCountBinary"); //$NON-NLS-1$
       
  1411 					for (int i = startSampleIndex; i < endSampleIndex; i++) {
       
  1412 						GppSample sample = sortedSamples[i];
       
  1413 
       
  1414 						ProfiledThread pThread = (ProfiledThread) traceThreads.elementAt(sample.threadIndex);
       
  1415 						if (pThread.isEnabled(graphIndex)) {
       
  1416 							// binary list is based on threads
       
  1417 							ProfiledBinary pBinary = (ProfiledBinary) traceBinaries.elementAt(sample.binaryIndex);
       
  1418 							String binaryName = pBinary.getNameString();
       
  1419 
       
  1420 							lowBinary = pBinary.getTotalSampleCount() < binaryThreshold;
       
  1421 
       
  1422 							if (!foundBinaries.containsKey(binaryName)) {
       
  1423 								foundBinaries.put(binaryName, binaryName);
       
  1424 								if (lowBinary) {
       
  1425 									thresholdBinary.addItem(graphIndex, pBinary, 1);
       
  1426 								} else {
       
  1427 									pBinary.setEnabled(graphIndex, true);
       
  1428 									pBinary.setSampleCount(graphIndex, 1);
       
  1429 									graphBinaries.add(pBinary);
       
  1430 								}
       
  1431 							} else {
       
  1432 								if (lowBinary)
       
  1433 									thresholdBinary.incSampleCount(graphIndex);
       
  1434 								else
       
  1435 									pBinary.incSampleCount(graphIndex);
       
  1436 							}
       
  1437 						}
       
  1438 					}
       
  1439 
       
  1440 					// set the % load
       
  1441 					for (int i = 0; i < graphBinaries.size(); i++) {
       
  1442 						ProfiledBinary pBinary = (ProfiledBinary) graphBinaries.elementAt(i);
       
  1443 						pBinary.setLoadAndString(graphIndex, (float)(pBinary.getSampleCount(graphIndex)*percentPerSample));
       
  1444 					}
       
  1445 					thresholdBinary.setLoadAndString(graphIndex,
       
  1446 							(float)(thresholdBinary.getSampleCount(graphIndex)*percentPerSample));
       
  1447 
  1341 
  1448 					// update the table items and redraw the table
  1342 					// update the table items and redraw the table
  1449 					this.myGraph.getBinaryTable().piEventReceived(be3);
  1343 					this.myGraph.getBinaryTable().piEventReceived(be3);
  1450 					break;
  1344 					break;
  1451 				}
  1345 				}
  1452 				case Defines.THREADS_BINARIES_FUNCTIONS:
  1346 				case Defines.THREADS_BINARIES_FUNCTIONS:
  1453 				{
  1347 				{
  1454 					// get new binary and function counts and loads
  1348 					// previous binaries are not necessarily graphed this time - reset
  1455 					Vector<ProfiledGeneric> traceBinaries   = trace.getIndexedBinaries();
  1349 					trace.setThreadBinary(graphIndex, adapter, this.myGraph.getProfiledBinaries());
  1456 					Vector<ProfiledGeneric> traceFunctions  = trace.getIndexedFunctions();
  1350 					// previous functions are not necessarily graphed this time - reset
  1457 					Vector<ProfiledGeneric> graphBinaries   = this.myGraph.getProfiledBinaries();
  1351 					trace.setThreadBinaryFunction(graphIndex, adapter, this.myGraph.getProfiledFunctions());
  1458 					Vector<ProfiledGeneric> graphFunctions  = this.myGraph.getProfiledFunctions();
       
  1459 					Hashtable<String,String> foundBinaries  = new Hashtable<String,String>();
       
  1460 					Hashtable<String,String> foundFunctions = new Hashtable<String,String>();
       
  1461 
       
  1462 					// previous functions are not necessarily graphed this time
       
  1463 					Enumeration<ProfiledGeneric> enuFunctions = graphFunctions.elements();
       
  1464 					while (enuFunctions.hasMoreElements()) {
       
  1465 						ProfiledFunction pFunction = (ProfiledFunction) enuFunctions.nextElement();
       
  1466 						pFunction.setEnabled(graphIndex, false);
       
  1467 					}
       
  1468 					graphFunctions.clear();
       
  1469 
       
  1470 					ProfiledThreshold thresholdFunction = this.myGraph.getThresholdFunction();
       
  1471 
       
  1472 					if (thresholdFunction.isEnabled(graphIndex)) {
       
  1473 						ArrayList<ProfiledGeneric> items = thresholdFunction.getItems(graphIndex);
       
  1474 						// disable all items below the threshold
       
  1475 						for (int i = 0; i < items.size(); i++) {
       
  1476 							items.get(i).setEnabled(graphIndex, false);
       
  1477 						}
       
  1478 					}
       
  1479 
       
  1480 					// previous binaries are not necessarily graphed this time
       
  1481 					Enumeration<ProfiledGeneric> enuBinary = graphBinaries.elements();
       
  1482 					while (enuBinary.hasMoreElements()) {
       
  1483 						ProfiledBinary pBinary = (ProfiledBinary) enuBinary.nextElement();
       
  1484 						pBinary.setEnabled(graphIndex, false);
       
  1485 					}
       
  1486 					graphBinaries.clear();
       
  1487 
       
  1488 					ProfiledThreshold thresholdBinary = this.myGraph.getThresholdBinary();
       
  1489 
       
  1490 					if (thresholdBinary.isEnabled(graphIndex)) {
       
  1491 						ArrayList<ProfiledGeneric> items = thresholdBinary.getItems(graphIndex);
       
  1492 						// disable all items below the threshold
       
  1493 						for (int i = 0; i < items.size(); i++) {
       
  1494 							items.get(i).setEnabled(graphIndex, false);
       
  1495 						}
       
  1496 					}
       
  1497 
       
  1498 					GppSample[] sortedSamples = trace.getSortedGppSamples();
       
  1499 
       
  1500 					// set up in case we find functions below the threshold
       
  1501 					boolean lowFunction;
       
  1502 					thresholdFunction.init(graphIndex);
       
  1503 
       
  1504 					// set up in case we find binaries below the threshold
       
  1505 					boolean lowBinary;
       
  1506 					thresholdBinary.init(graphIndex);
       
  1507 
       
  1508 					int binaryThreshold = (Integer) NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.thresholdCountBinary"); //$NON-NLS-1$
       
  1509 					for (int i = startSampleIndex; i < endSampleIndex; i++) {
       
  1510 						GppSample sample = sortedSamples[i];
       
  1511 
       
  1512 						ProfiledThread pThread = (ProfiledThread) traceThreads.elementAt(sample.threadIndex);
       
  1513 						if (pThread.isEnabled(graphIndex)) {
       
  1514 							// binary list is based on threads
       
  1515 							ProfiledBinary pBinary = (ProfiledBinary) traceBinaries.elementAt(sample.binaryIndex);
       
  1516 							String binaryName = pBinary.getNameString();
       
  1517 
       
  1518 							lowBinary = pBinary.getTotalSampleCount() < binaryThreshold;
       
  1519 
       
  1520 							if (!foundBinaries.containsKey(binaryName)) {
       
  1521 								foundBinaries.put(binaryName, binaryName);
       
  1522 								if (lowBinary) {
       
  1523 									thresholdBinary.addItem(graphIndex, pBinary, 1);
       
  1524 								} else {
       
  1525 									pBinary.setEnabled(graphIndex, true);
       
  1526 									pBinary.setSampleCount(graphIndex, 1);
       
  1527 									graphBinaries.add(pBinary);
       
  1528 								}
       
  1529 							} else {
       
  1530 								if (lowBinary)
       
  1531 									thresholdBinary.incSampleCount(graphIndex);
       
  1532 								else
       
  1533 									pBinary.incSampleCount(graphIndex);
       
  1534 							}
       
  1535 
       
  1536 							// function list is based on threads and binaries
       
  1537 							ProfiledFunction pFunction = (ProfiledFunction) traceFunctions.elementAt(sample.functionIndex);
       
  1538 							String functionName = pFunction.getNameString();
       
  1539 
       
  1540 							lowFunction = pFunction.getTotalSampleCount() < (Integer)NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.thresholdCountFunction"); //$NON-NLS-1$
       
  1541 
       
  1542 							if (!foundFunctions.containsKey(functionName)) {
       
  1543 								foundFunctions.put(functionName, functionName);
       
  1544 								if (lowFunction) {
       
  1545 									thresholdFunction.addItem(graphIndex, pFunction, 1);
       
  1546 								} else {
       
  1547 									pFunction.setEnabled(graphIndex, true);
       
  1548 									pFunction.setSampleCount(graphIndex, 1);
       
  1549 									graphFunctions.add(pFunction);
       
  1550 								}
       
  1551 							} else {
       
  1552 								if (lowFunction)
       
  1553 									thresholdFunction.incSampleCount(graphIndex);
       
  1554 								else
       
  1555 									pFunction.incSampleCount(graphIndex);
       
  1556 							}
       
  1557 						}
       
  1558 					}
       
  1559 
       
  1560 					// set the % load
       
  1561 					for (int i = 0; i < graphBinaries.size(); i++) {
       
  1562 						ProfiledBinary pBinary = (ProfiledBinary) graphBinaries.elementAt(i);
       
  1563 						pBinary.setLoadAndString(graphIndex, (float)(pBinary.getSampleCount(graphIndex)*percentPerSample));
       
  1564 					}
       
  1565 					thresholdBinary.setLoadAndString(graphIndex,
       
  1566 							(float)(thresholdBinary.getSampleCount(graphIndex)*percentPerSample));
       
  1567 
       
  1568 					for (int i = 0; i < graphFunctions.size(); i++) {
       
  1569 						ProfiledFunction pFunction = (ProfiledFunction) graphFunctions.elementAt(i);
       
  1570 						pFunction.setLoadAndString(graphIndex, (float)(pFunction.getSampleCount(graphIndex)*percentPerSample));
       
  1571 					}
       
  1572 					thresholdFunction.setLoadAndString(graphIndex,
       
  1573 							(float)(thresholdFunction.getSampleCount(graphIndex)*percentPerSample));
       
  1574 
  1352 
  1575 					// update the table items and redraw the table
  1353 					// update the table items and redraw the table
  1576 					this.myGraph.getBinaryTable().piEventReceived(be3);
  1354 					this.myGraph.getBinaryTable().piEventReceived(be3);
  1577 					this.myGraph.getFunctionTable().piEventReceived(be3);
  1355 					this.myGraph.getFunctionTable().piEventReceived(be3);
  1578 					break;
  1356 					break;
  1579 				}
  1357 				}
  1580 				case Defines.THREADS_FUNCTIONS:
  1358 				case Defines.THREADS_FUNCTIONS:
  1581 				{
  1359 				{
  1582 					// get new function counts and loads
       
  1583 					Vector<ProfiledGeneric> traceFunctions  = trace.getIndexedFunctions();
       
  1584 					Vector<ProfiledGeneric> graphFunctions  = this.myGraph.getProfiledFunctions();
       
  1585 					Hashtable<String,String> foundFunctions = new Hashtable<String,String>();
       
  1586 
       
  1587 					// previous functions are not necessarily graphed this time
  1360 					// previous functions are not necessarily graphed this time
  1588 					Enumeration<ProfiledGeneric> enu = graphFunctions.elements();
  1361 					trace.setThreadFunction(graphIndex, adapter, this.myGraph.getProfiledFunctions());
  1589 					while (enu.hasMoreElements()) {
       
  1590 						ProfiledFunction pFunction = (ProfiledFunction) enu.nextElement();
       
  1591 						pFunction.setEnabled(graphIndex, false);
       
  1592 					}
       
  1593 					graphFunctions.clear();
       
  1594 
       
  1595 					ProfiledThreshold thresholdFunction = this.myGraph.getThresholdFunction();
       
  1596 
       
  1597 					if (thresholdFunction.isEnabled(graphIndex)) {
       
  1598 						ArrayList<ProfiledGeneric> items = thresholdFunction.getItems(graphIndex);
       
  1599 						// disable all items below the threshold
       
  1600 						for (int i = 0; i < items.size(); i++) {
       
  1601 							items.get(i).setEnabled(graphIndex, false);
       
  1602 						}
       
  1603 					}
       
  1604 
       
  1605 					GppSample[] sortedSamples = trace.getSortedGppSamples();
       
  1606 
       
  1607 					// set up in case we find functions below the threshold
       
  1608 					boolean lowFunction;
       
  1609 					thresholdFunction.init(graphIndex);
       
  1610 
       
  1611 					int functionThreshold = (Integer) NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.thresholdCountFunction"); //$NON-NLS-1$
       
  1612 					for (int i = startSampleIndex; i < endSampleIndex; i++) {
       
  1613 						GppSample sample = sortedSamples[i];
       
  1614 
       
  1615 						ProfiledThread pThread = (ProfiledThread) traceThreads.elementAt(sample.threadIndex);
       
  1616 						if (pThread.isEnabled(graphIndex)) {
       
  1617 							// function list is based on threads
       
  1618 							ProfiledFunction pFunction = (ProfiledFunction) traceFunctions.elementAt(sample.functionIndex);
       
  1619 							String functionName = pFunction.getNameString();
       
  1620 
       
  1621 							lowFunction = pFunction.getTotalSampleCount() < functionThreshold;
       
  1622 
       
  1623 							if (!foundFunctions.containsKey(functionName)) {
       
  1624 								foundFunctions.put(functionName, functionName);
       
  1625 								if (lowFunction) {
       
  1626 									thresholdFunction.addItem(graphIndex, pFunction, 1);
       
  1627 								} else {
       
  1628 									pFunction.setEnabled(graphIndex, true);
       
  1629 									pFunction.setSampleCount(graphIndex, 1);
       
  1630 									graphFunctions.add(pFunction);
       
  1631 								}
       
  1632 							} else {
       
  1633 								if (lowFunction)
       
  1634 									thresholdFunction.incSampleCount(graphIndex);
       
  1635 								else
       
  1636 									pFunction.incSampleCount(graphIndex);
       
  1637 							}
       
  1638 						}
       
  1639 					}
       
  1640 
       
  1641 					// set the % load
       
  1642 					for (int i = 0; i < graphFunctions.size(); i++) {
       
  1643 						ProfiledFunction pFunction = (ProfiledFunction) graphFunctions.elementAt(i);
       
  1644 						pFunction.setLoadAndString(graphIndex, (float)(pFunction.getSampleCount(graphIndex)*percentPerSample));
       
  1645 					}
       
  1646 					thresholdFunction.setLoadAndString(graphIndex,
       
  1647 							(float)(thresholdFunction.getSampleCount(graphIndex)*percentPerSample));
       
  1648 
  1362 
  1649 					// update the table items and redraw the table
  1363 					// update the table items and redraw the table
  1650 					this.myGraph.getFunctionTable().piEventReceived(be3);
  1364 					this.myGraph.getFunctionTable().piEventReceived(be3);
  1651 					break;
  1365 					break;
  1652 				}
  1366 				}
  1653 				case Defines.THREADS_FUNCTIONS_BINARIES:
  1367 				case Defines.THREADS_FUNCTIONS_BINARIES:
  1654 				{
  1368 				{
  1655 					// get new function and binary counts and loads
  1369 					// previous functions and binaries are not necessarily graphed this time
  1656 					Vector<ProfiledGeneric> traceBinaries   = trace.getIndexedBinaries();
  1370 					trace.setThreadFunction(graphIndex, adapter, this.myGraph.getProfiledFunctions());
  1657 					Vector<ProfiledGeneric> traceFunctions  = trace.getIndexedFunctions();
  1371 					trace.setThreadFunctionBinary(graphIndex, adapter, this.myGraph.getProfiledBinaries());
  1658 					Vector<ProfiledGeneric> graphBinaries   = this.myGraph.getProfiledBinaries();
       
  1659 					Vector<ProfiledGeneric> graphFunctions  = this.myGraph.getProfiledFunctions();
       
  1660 					Hashtable<String,String> foundBinaries  = new Hashtable<String,String>();
       
  1661 					Hashtable<String,String> foundFunctions = new Hashtable<String,String>();
       
  1662 
       
  1663 					// previous binaries are not necessarily graphed this time
       
  1664 					Enumeration<ProfiledGeneric> enuBinaries = graphBinaries.elements();
       
  1665 					while (enuBinaries.hasMoreElements()) {
       
  1666 						ProfiledBinary pBinary = (ProfiledBinary) enuBinaries.nextElement();
       
  1667 						pBinary.setEnabled(graphIndex, false);
       
  1668 					}
       
  1669 					graphBinaries.clear();
       
  1670 
       
  1671 					ProfiledThreshold thresholdBinary = this.myGraph.getThresholdBinary();
       
  1672 
       
  1673 					if (thresholdBinary.isEnabled(graphIndex)) {
       
  1674 						ArrayList<ProfiledGeneric> items = thresholdBinary.getItems(graphIndex);
       
  1675 						// disable all items below the threshold
       
  1676 						for (int i = 0; i < items.size(); i++) {
       
  1677 							items.get(i).setEnabled(graphIndex, false);
       
  1678 						}
       
  1679 					}
       
  1680 
       
  1681 					// previous functions are not necessarily graphed this time
       
  1682 					Enumeration<ProfiledGeneric> enuFunctions = graphFunctions.elements();
       
  1683 					while (enuFunctions.hasMoreElements()) {
       
  1684 						ProfiledFunction pFunction = (ProfiledFunction) enuFunctions.nextElement();
       
  1685 						pFunction.setEnabled(graphIndex, false);
       
  1686 					}
       
  1687 					graphFunctions.clear();
       
  1688 
       
  1689 					ProfiledThreshold thresholdFunction = this.myGraph.getThresholdFunction();
       
  1690 
       
  1691 					if (thresholdFunction.isEnabled(graphIndex)) {
       
  1692 						ArrayList<ProfiledGeneric> items = thresholdFunction.getItems(graphIndex);
       
  1693 						// disable all items below the threshold
       
  1694 						for (int i = 0; i < items.size(); i++) {
       
  1695 							items.get(i).setEnabled(graphIndex, false);
       
  1696 						}
       
  1697 					}
       
  1698 
       
  1699 					GppSample[] sortedSamples = trace.getSortedGppSamples();
       
  1700 
       
  1701 					// set up in case we find binaries below the threshold
       
  1702 					boolean lowBinary;
       
  1703 					thresholdBinary.init(graphIndex);
       
  1704 
       
  1705 					// set up in case we find functions below the threshold
       
  1706 					boolean lowFunction;
       
  1707 					thresholdFunction.init(graphIndex);
       
  1708 
       
  1709 					int functionThreshold = (Integer) NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.thresholdCountFunction"); //$NON-NLS-1$
       
  1710 					for (int i = startSampleIndex; i < endSampleIndex; i++) {
       
  1711 						GppSample sample = sortedSamples[i];
       
  1712 
       
  1713 						ProfiledThread pThread = (ProfiledThread) traceThreads.elementAt(sample.threadIndex);
       
  1714 						if (pThread.isEnabled(graphIndex)) {
       
  1715 							// function list is based on threads
       
  1716 							ProfiledFunction pFunction = (ProfiledFunction) traceFunctions.elementAt(sample.functionIndex);
       
  1717 							String functionName = pFunction.getNameString();
       
  1718 
       
  1719 							lowFunction = pFunction.getTotalSampleCount() < functionThreshold;
       
  1720 
       
  1721 							if (!foundFunctions.containsKey(functionName)) {
       
  1722 								foundFunctions.put(functionName, functionName);
       
  1723 								if (lowFunction) {
       
  1724 									thresholdFunction.addItem(graphIndex, pFunction, 1);
       
  1725 								} else {
       
  1726 									pFunction.setEnabled(graphIndex, true);
       
  1727 									pFunction.setSampleCount(graphIndex, 1);
       
  1728 									graphFunctions.add(pFunction);
       
  1729 								}
       
  1730 							} else {
       
  1731 								if (lowFunction)
       
  1732 									thresholdFunction.incSampleCount(graphIndex);
       
  1733 								else
       
  1734 									pFunction.incSampleCount(graphIndex);
       
  1735 							}
       
  1736 
       
  1737 							// binary list is based on threads and functions
       
  1738 							ProfiledBinary pBinary = (ProfiledBinary) traceBinaries.elementAt(sample.binaryIndex);
       
  1739 							String binaryName = pBinary.getNameString();
       
  1740 
       
  1741 							lowBinary = pBinary.getTotalSampleCount() < (Integer)NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.thresholdCountBinary"); //$NON-NLS-1$
       
  1742 
       
  1743 							if (!foundBinaries.containsKey(binaryName)) {
       
  1744 								foundBinaries.put(binaryName, binaryName);
       
  1745 								if (lowBinary) {
       
  1746 									thresholdBinary.addItem(graphIndex, pBinary, 1);
       
  1747 								} else {
       
  1748 									pBinary.setEnabled(graphIndex, true);
       
  1749 									pBinary.setSampleCount(graphIndex, 1);
       
  1750 									graphBinaries.add(pBinary);
       
  1751 								}
       
  1752 							} else {
       
  1753 								if (lowBinary)
       
  1754 									thresholdBinary.incSampleCount(graphIndex);
       
  1755 								else
       
  1756 									pBinary.incSampleCount(graphIndex);
       
  1757 							}
       
  1758 						}
       
  1759 					}
       
  1760 
       
  1761 					// set the % load
       
  1762 					for (int i = 0; i < graphBinaries.size(); i++) {
       
  1763 						ProfiledBinary pBinary = (ProfiledBinary) graphBinaries.elementAt(i);
       
  1764 						pBinary.setLoadAndString(graphIndex, (float)(pBinary.getSampleCount(graphIndex)*percentPerSample));
       
  1765 					}
       
  1766 					thresholdBinary.setLoadAndString(graphIndex,
       
  1767 							(float)(thresholdBinary.getSampleCount(graphIndex)*percentPerSample));
       
  1768 
       
  1769 					for (int i = 0; i < graphFunctions.size(); i++) {
       
  1770 						ProfiledFunction pFunction = (ProfiledFunction) graphFunctions.elementAt(i);
       
  1771 						pFunction.setLoadAndString(graphIndex, (float)(pFunction.getSampleCount(graphIndex)*percentPerSample));
       
  1772 					}
       
  1773 					thresholdFunction.setLoadAndString(graphIndex,
       
  1774 							(float)(thresholdFunction.getSampleCount(graphIndex)*percentPerSample));
       
  1775 
  1372 
  1776 					// update the table items and redraw the table
  1373 					// update the table items and redraw the table
  1777 					this.myGraph.getBinaryTable().piEventReceived(be3);
  1374 					this.myGraph.getBinaryTable().piEventReceived(be3);
  1778 					this.myGraph.getFunctionTable().piEventReceived(be3);
  1375 					this.myGraph.getFunctionTable().piEventReceived(be3);
  1779 					break;
  1376 					break;
  1789 			// This routine enables all entries in the next table
  1386 			// This routine enables all entries in the next table
  1790 
  1387 
  1791 			int drawMode = this.myGraph.getDrawMode();
  1388 			int drawMode = this.myGraph.getDrawMode();
  1792 			if (drawMode != Defines.THREADS_BINARIES_FUNCTIONS)
  1389 			if (drawMode != Defines.THREADS_BINARIES_FUNCTIONS)
  1793 				return;
  1390 				return;
  1794 
  1391 			
  1795 			// we don't need to redraw the thread table, since it has not changed
  1392 			// we don't need to redraw the thread table, since it has not changed
  1796 
  1393 			PIEvent be3 = new PIEvent(be.getValueObject(), PIEvent.SELECTION_AREA_CHANGED3);
  1797 			GppTrace trace = (GppTrace)(this.myGraph.getTrace());
  1394 			GppTrace trace = (GppTrace)(this.myGraph.getTrace());
  1798 			Vector<ProfiledGeneric> traceBinaries  = trace.getIndexedBinaries();
       
  1799 
       
  1800 			int graphIndex = this.myGraph.getGraphIndex();
  1395 			int graphIndex = this.myGraph.getGraphIndex();
  1801 			int startSampleIndex = trace.getStartSampleIndex();
  1396 			trace.setThreadBinaryFunction(graphIndex, adapter, this.myGraph.getProfiledFunctions());
  1802 			int endSampleIndex   = trace.getEndSampleIndex();
       
  1803 			double percentPerSample;
       
  1804 			if (startSampleIndex == endSampleIndex)
       
  1805 				percentPerSample = 0.0;
       
  1806 			else
       
  1807 				percentPerSample = 100.0 / ((double)(endSampleIndex - startSampleIndex));
       
  1808 
       
  1809 			PIEvent be3 = new PIEvent(be.getValueObject(), PIEvent.SELECTION_AREA_CHANGED3);
       
  1810 
       
  1811 			// get new function counts and loads
       
  1812 			Vector<ProfiledGeneric> traceFunctions = trace.getIndexedFunctions();
       
  1813 			Vector<ProfiledGeneric> graphFunctions = this.myGraph.getProfiledFunctions();
       
  1814 			Hashtable<String,String> foundFunctions = new Hashtable<String,String>();
       
  1815 
       
  1816 			// previous functions are not necessarily graphed this time
       
  1817 			Enumeration<ProfiledGeneric> enu = graphFunctions.elements();
       
  1818 			while (enu.hasMoreElements()) {
       
  1819 				ProfiledFunction pFunction = (ProfiledFunction) enu.nextElement();
       
  1820 				pFunction.setEnabled(graphIndex, false);
       
  1821 			}
       
  1822 			graphFunctions.clear();
       
  1823 
       
  1824 			ProfiledThreshold thresholdFunction = this.myGraph.getThresholdFunction();
       
  1825 
       
  1826 			if (thresholdFunction.isEnabled(graphIndex)) {
       
  1827 				ArrayList<ProfiledGeneric> items = thresholdFunction.getItems(graphIndex);
       
  1828 				// disable all items below the threshold
       
  1829 				for (int i = 0; i < items.size(); i++) {
       
  1830 					items.get(i).setEnabled(graphIndex, false);
       
  1831 				}
       
  1832 			}
       
  1833 
       
  1834 			GppSample[] sortedSamples = trace.getSortedGppSamples();
       
  1835 
       
  1836 			// set up in case we find functions below the threshold
       
  1837 			boolean lowFunction;
       
  1838 			thresholdFunction.init(graphIndex);
       
  1839 
       
  1840 			for (int i = startSampleIndex; i < endSampleIndex; i++) {
       
  1841 				GppSample sample = sortedSamples[i];
       
  1842 
       
  1843 				ProfiledBinary pBinary = (ProfiledBinary) traceBinaries.elementAt(sample.binaryIndex);
       
  1844 				if (pBinary.isEnabled(graphIndex)) {
       
  1845 					// function list is based on binaries
       
  1846 					ProfiledFunction pFunction = (ProfiledFunction) traceFunctions.elementAt(sample.functionIndex);
       
  1847 					String functionName = pFunction.getNameString();
       
  1848 
       
  1849 					lowFunction = pFunction.getTotalSampleCount() < (Integer)NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.thresholdCountFunction"); //$NON-NLS-1$
       
  1850 
       
  1851 					if (!foundFunctions.containsKey(functionName)) {
       
  1852 						foundFunctions.put(functionName, functionName);
       
  1853 						if (lowFunction) {
       
  1854 							thresholdFunction.addItem(graphIndex, pFunction, 1);
       
  1855 						} else {
       
  1856 							pFunction.setEnabled(graphIndex, true);
       
  1857 							pFunction.setSampleCount(graphIndex, 1);
       
  1858 							graphFunctions.add(pFunction);
       
  1859 						}
       
  1860 					} else {
       
  1861 						if (lowFunction)
       
  1862 							thresholdFunction.incSampleCount(graphIndex);
       
  1863 						else
       
  1864 							pFunction.incSampleCount(graphIndex);
       
  1865 					}
       
  1866 				}
       
  1867 			}
       
  1868 
       
  1869 			// set the % load
       
  1870 			for (int i = 0; i < graphFunctions.size(); i++) {
       
  1871 				ProfiledFunction pFunction = (ProfiledFunction) graphFunctions.elementAt(i);
       
  1872 				pFunction.setLoadAndString(graphIndex, (float)(pFunction.getSampleCount(graphIndex)*percentPerSample));
       
  1873 			}
       
  1874 			thresholdFunction.setLoadAndString(graphIndex,
       
  1875 					(float)(thresholdFunction.getSampleCount(graphIndex)*percentPerSample));
       
  1876 
  1397 
  1877 			// update the table items and redraw the table
  1398 			// update the table items and redraw the table
  1878 			this.myGraph.getFunctionTable().piEventReceived(be3);
  1399 			this.myGraph.getFunctionTable().piEventReceived(be3);
  1879 		}
  1400 		}
  1880 		else if (be.getType() == PIEvent.CHANGED_FUNCTION_TABLE)
  1401 		else if (be.getType() == PIEvent.CHANGED_FUNCTION_TABLE)
  1884 			int drawMode = this.myGraph.getDrawMode();
  1405 			int drawMode = this.myGraph.getDrawMode();
  1885 			if (drawMode != Defines.THREADS_FUNCTIONS_BINARIES)
  1406 			if (drawMode != Defines.THREADS_FUNCTIONS_BINARIES)
  1886 				return;
  1407 				return;
  1887 
  1408 
  1888 			// we don't need to redraw the thread table, since it has not changed
  1409 			// we don't need to redraw the thread table, since it has not changed
  1889 
  1410 			PIEvent be3 = new PIEvent(be.getValueObject(), PIEvent.SELECTION_AREA_CHANGED3);
  1890 			GppTrace trace = (GppTrace)(this.myGraph.getTrace());
  1411 			GppTrace trace = (GppTrace)(this.myGraph.getTrace());
  1891 			Vector<ProfiledGeneric> traceFunctions = trace.getIndexedFunctions();
       
  1892 
       
  1893 			int graphIndex = this.myGraph.getGraphIndex();
  1412 			int graphIndex = this.myGraph.getGraphIndex();
  1894 			int startSampleIndex = trace.getStartSampleIndex();
  1413 			trace.setThreadFunctionBinary(graphIndex, adapter, this.myGraph.getProfiledBinaries());
  1895 			int endSampleIndex   = trace.getEndSampleIndex();
       
  1896 			double percentPerSample;
       
  1897 			if (startSampleIndex == endSampleIndex)
       
  1898 				percentPerSample = 0.0;
       
  1899 			else
       
  1900 				percentPerSample = 100.0 / ((double)(endSampleIndex - startSampleIndex));
       
  1901 
       
  1902 			PIEvent be3 = new PIEvent(be.getValueObject(), PIEvent.SELECTION_AREA_CHANGED3);
       
  1903 
       
  1904 			// get new counts and loads
       
  1905 			Vector<ProfiledGeneric> traceBinaries   = trace.getIndexedBinaries();
       
  1906 			Vector<ProfiledGeneric> graphBinaries   = this.myGraph.getProfiledBinaries();
       
  1907 			Hashtable<String,String> foundBinaries  = new Hashtable<String,String>();
       
  1908 
       
  1909 			// previous binaries are not necessarily graphed this time
       
  1910 			Enumeration<ProfiledGeneric> enu = graphBinaries.elements();
       
  1911 			while (enu.hasMoreElements()) {
       
  1912 				ProfiledBinary pBinary = (ProfiledBinary) enu.nextElement();
       
  1913 				pBinary.setEnabled(graphIndex, false);
       
  1914 			}
       
  1915 			graphBinaries.clear();
       
  1916 
       
  1917 			ProfiledThreshold thresholdBinary = this.myGraph.getThresholdBinary();
       
  1918 
       
  1919 			if (thresholdBinary.isEnabled(graphIndex)) {
       
  1920 				ArrayList<ProfiledGeneric> items = thresholdBinary.getItems(graphIndex);
       
  1921 				// disable all items below the threshold
       
  1922 				for (int i = 0; i < items.size(); i++) {
       
  1923 					items.get(i).setEnabled(graphIndex, false);
       
  1924 				}
       
  1925 			}
       
  1926 
       
  1927 			GppSample[] sortedSamples = trace.getSortedGppSamples();
       
  1928 
       
  1929 			// set up in case we find binaries below the threshold
       
  1930 			boolean lowBinary;
       
  1931 			thresholdBinary.init(graphIndex);
       
  1932 
       
  1933 			int binaryThreshold = (Integer) NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.address.thresholdCountBinary"); //$NON-NLS-1$
       
  1934 			for (int i = startSampleIndex; i < endSampleIndex; i++) {
       
  1935 				GppSample sample = sortedSamples[i];
       
  1936 
       
  1937 				ProfiledFunction pFunction = (ProfiledFunction) traceFunctions.elementAt(sample.functionIndex);
       
  1938 				if (pFunction.isEnabled(graphIndex)) {
       
  1939 					// binary list is based on functions
       
  1940 					ProfiledBinary pBinary = (ProfiledBinary) traceBinaries.elementAt(sample.binaryIndex);
       
  1941 					String binaryName = pBinary.getNameString();
       
  1942 
       
  1943 					lowBinary = pBinary.getTotalSampleCount() < binaryThreshold;
       
  1944 
       
  1945 					if (!foundBinaries.containsKey(binaryName)) {
       
  1946 						foundBinaries.put(binaryName, binaryName);
       
  1947 						if (lowBinary) {
       
  1948 							thresholdBinary.addItem(graphIndex, pBinary, 1);
       
  1949 						} else {
       
  1950 							pBinary.setEnabled(graphIndex, true);
       
  1951 							pBinary.setSampleCount(graphIndex, 1);
       
  1952 							graphBinaries.add(pBinary);
       
  1953 						}
       
  1954 					} else {
       
  1955 						if (lowBinary)
       
  1956 							thresholdBinary.incSampleCount(graphIndex);
       
  1957 						else
       
  1958 							pBinary.incSampleCount(graphIndex);
       
  1959 					}
       
  1960 				}
       
  1961 			}
       
  1962 
       
  1963 			// set the % load
       
  1964 			for (int i = 0; i < graphBinaries.size(); i++) {
       
  1965 				ProfiledBinary pBinary = (ProfiledBinary) graphBinaries.elementAt(i);
       
  1966 				pBinary.setLoadAndString(graphIndex, (float)(pBinary.getSampleCount(graphIndex)*percentPerSample));
       
  1967 			}
       
  1968 			thresholdBinary.setLoadAndString(graphIndex,
       
  1969 					(float)(thresholdBinary.getSampleCount(graphIndex)*percentPerSample));
       
  1970 
  1414 
  1971 			// update the table items and redraw the table
  1415 			// update the table items and redraw the table
  1972 			this.myGraph.getBinaryTable().piEventReceived(be3);
  1416 			this.myGraph.getBinaryTable().piEventReceived(be3);
  1973 		}
  1417 		}
  1974 	}
  1418 	}
  1975 
  1419 
  1976 	public void setSelectedNames()
  1420 	/**
       
  1421 	 * this table's set of checkbox-selected rows has changed, so propagate that information
       
  1422 	 */
       
  1423 	private void setSelectedNames()
  1977 	{
  1424 	{
  1978 		Object[] selectedValues = this.tableViewer.getCheckedElements();
  1425 		Object[] selectedValues = this.tableViewer.getCheckedElements();
  1979         String[] threadNames = new String[selectedValues.length];
  1426         String[] threadNames = new String[selectedValues.length];
  1980 
  1427 
  1981         for (int i = 0; i < selectedValues.length; i++)
  1428         for (int i = 0; i < selectedValues.length; i++)
  2053 			quickSort(sortColumn, profiledThreads);
  1500 			quickSort(sortColumn, profiledThreads);
  2054 	}
  1501 	}
  2055 
  1502 
  2056 	private class ColumnSelectionHandler extends SelectionAdapter
  1503 	private class ColumnSelectionHandler extends SelectionAdapter
  2057 	{
  1504 	{
       
  1505 		/* (non-Javadoc)
       
  1506 		 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
       
  1507 		 */
       
  1508 		@Override
  2058 		public void widgetSelected(SelectionEvent e)
  1509 		public void widgetSelected(SelectionEvent e)
  2059         {
  1510         {
  2060         	// wait for the previous sort to finish
  1511         	// wait for the previous sort to finish
  2061         	if (sorting || !(e.widget instanceof TableColumn))
  1512         	if (sorting || !(e.widget instanceof TableColumn))
  2062         		return;
  1513         		return;
  2063 
  1514 
  2064         	sortOnColumnSelection((TableColumn) e.widget);
  1515         	sortOnColumnSelection((TableColumn) e.widget);
  2065         }
  1516         }
  2066 	}
  1517 	}
  2067 
  1518 
       
  1519 	/**
       
  1520 	 * Adds ProfiledGenerics and threshold items to the table data
       
  1521 	 * (this.tableItemData and this.profiledThreads). Sorts the ProfiledGenerics
       
  1522 	 * according to load; and sets the graph's sorted list accordingly. Refreshes
       
  1523 	 * the TableViewer if parameter setInput is true.
       
  1524 	 * 
       
  1525 	 * @param setInput
       
  1526 	 *            if true, reset the TableViewer
       
  1527 	 */
  2068 	public void updateProfiledAndItemData(boolean setInput)
  1528 	public void updateProfiledAndItemData(boolean setInput)
  2069 	{
  1529 	{
  2070 		tableItemData.clear();
  1530 		tableItemData.clear();
  2071 		profiledThreads.clear();
  1531 		profiledThreads.clear();
  2072 
  1532 
  2077 			ProfiledThread nextElement = (ProfiledThread)enu.nextElement();
  1537 			ProfiledThread nextElement = (ProfiledThread)enu.nextElement();
  2078 			tableItemData.add(nextElement);
  1538 			tableItemData.add(nextElement);
  2079 			profiledThreads.add(nextElement);
  1539 			profiledThreads.add(nextElement);
  2080 		}
  1540 		}
  2081 
  1541 
  2082 		if (myGraph.getThresholdThread().getItemCount(myGraph.getGraphIndex()) != 0) {
  1542 		if (myGraph.getThresholdThread().getItemCount() != 0) {
  2083 			tableItemData.add(myGraph.getThresholdThread());
  1543 			tableItemData.add(myGraph.getThresholdThread());
  2084 			profiledThreads.add(myGraph.getThresholdThread());
  1544 			profiledThreads.add(myGraph.getThresholdThread());
  2085 		}
  1545 		}
  2086 		
  1546 		
  2087 		// now sort the items in increasing total sample count, so that they graph correctly
  1547 		// now sort the items in increasing total sample count, so that they graph correctly
  2089 		Arrays.sort(sorted, new Comparator<Object>() {
  1549 		Arrays.sort(sorted, new Comparator<Object>() {
  2090 			
  1550 			
  2091 			public int compare(Object arg0, Object arg1)
  1551 			public int compare(Object arg0, Object arg1)
  2092 			{
  1552 			{
  2093 				if (arg0 instanceof ProfiledGeneric && arg1 instanceof ProfiledGeneric)
  1553 				if (arg0 instanceof ProfiledGeneric && arg1 instanceof ProfiledGeneric)
  2094 					return ((ProfiledGeneric)arg0).getTotalSampleCount() -
  1554 					return (adapter.getTotalSampleCount((ProfiledGeneric)arg0)) -
  2095 							((ProfiledGeneric)arg1).getTotalSampleCount();
  1555 							adapter.getTotalSampleCount(((ProfiledGeneric)arg1));
  2096 				else
  1556 				return 0;
  2097 					return 0;
       
  2098 			}
  1557 			}
  2099 		});
  1558 		});
  2100 
  1559 
  2101 		// now create the sorted list used to draw the graph
  1560 		// now create the sorted list used to draw the graph
  2102 		myGraph.getSortedThreads().clear();
  1561 		myGraph.getSortedThreads().clear();
  2103 
  1562 
  2104 		if (myGraph.getThresholdThread().getItemCount(myGraph.getGraphIndex()) != 0)
  1563 		if (myGraph.getThresholdThread().getItemCount() != 0)
  2105 			myGraph.getSortedThreads().add(myGraph.getThresholdThread());
  1564 			myGraph.getSortedThreads().add(myGraph.getThresholdThread());
  2106 
  1565 
  2107 		for (int i = 0; i < sorted.length; i++)
  1566 		for (int i = 0; i < sorted.length; i++)
  2108 			myGraph.getSortedThreads().add((ProfiledGeneric) sorted[i]);
  1567 			myGraph.getSortedThreads().add((ProfiledGeneric) sorted[i]);
  2109 
  1568 
  2117 		if (profiled.size() == 0)
  1576 		if (profiled.size() == 0)
  2118 			return;
  1577 			return;
  2119 
  1578 
  2120 		this.sorting = true;
  1579 		this.sorting = true;
  2121 
  1580 
       
  1581 		//if the last element is a threshold element - remove it
  2122 		ProfiledGeneric pGeneric = profiled.elementAt(profiled.size() - 1);
  1582 		ProfiledGeneric pGeneric = profiled.elementAt(profiled.size() - 1);
  2123 
  1583 
  2124 		if (pGeneric instanceof ProfiledThreshold) {
  1584 		if (pGeneric instanceof ProfiledThreshold) {
  2125 			profiled.removeElementAt(profiled.size() - 1);
  1585 			profiled.removeElementAt(profiled.size() - 1);
  2126 		}
  1586 		}
  2208 		saveSamplesItem.setText(Messages.getString("AddrThreadTable.savePrioritySamples")); //$NON-NLS-1$
  1668 		saveSamplesItem.setText(Messages.getString("AddrThreadTable.savePrioritySamples")); //$NON-NLS-1$
  2209 		saveSamplesItem.setEnabled(enabled);
  1669 		saveSamplesItem.setEnabled(enabled);
  2210 		
  1670 		
  2211 		if (enabled) {
  1671 		if (enabled) {
  2212 			saveSamplesItem.addSelectionListener(new SelectionAdapter() { 
  1672 			saveSamplesItem.addSelectionListener(new SelectionAdapter() { 
       
  1673 				@Override
  2213 				public void widgetSelected(SelectionEvent e) {
  1674 				public void widgetSelected(SelectionEvent e) {
  2214 					action("savePrioritySamples"); //$NON-NLS-1$
  1675 					action("savePrioritySamples"); //$NON-NLS-1$
  2215 				}
  1676 				}
  2216 			});
  1677 			});
  2217 		}
  1678 		}
  2218 
  1679 
  2219 		return saveSamplesItem;
  1680 		return saveSamplesItem;
  2220 	}
  1681 	}
  2221 
  1682 
       
  1683 	@Override
  2222 	protected Menu getTableMenu(Decorations parent, int graphIndex, int drawMode) {
  1684 	protected Menu getTableMenu(Decorations parent, int graphIndex, int drawMode) {
  2223 
  1685 
  2224 		// get rid of last Menu created so we don't have double menu
  1686 		// get rid of last Menu created so we don't have double menu
  2225 		// in on click
  1687 		// in on click
  2226 		if (contextMenu != null) {
  1688 		if (contextMenu != null) {
  2364 	{
  1826 	{
  2365 		TableColumn column;
  1827 		TableColumn column;
  2366 		column = new TableColumn(tableViewer.getTable(), SWT.LEFT);
  1828 		column = new TableColumn(tableViewer.getTable(), SWT.LEFT);
  2367 		column.setText(COLUMN_HEAD_PRIORITY);
  1829 		column.setText(COLUMN_HEAD_PRIORITY);
  2368 		column.setWidth(COLUMN_WIDTH_PRIORITY);
  1830 		column.setWidth(COLUMN_WIDTH_PRIORITY);
  2369 		column.setData(new Integer(COLUMN_ID_PRIORITY));
  1831 		column.setData(Integer.valueOf(COLUMN_ID_PRIORITY));
  2370 		column.setMoveable(true);
  1832 		column.setMoveable(true);
  2371 		column.setResizable(true);
  1833 		column.setResizable(true);
  2372 		column.addSelectionListener(new ColumnSelectionHandler());
  1834 		column.addSelectionListener(new ColumnSelectionHandler());
  2373 	}
  1835 	}
  2374 
  1836 
  2375 	private Integer parsePriorityValue(String priorityString)
  1837 	private Integer parsePriorityValue(String priorityString)
  2376 	{
  1838 	{
  2377 		if (priorityString == null || priorityString.equals(Messages.getString("AddrThreadTable.unsolvedPriority"))) //$NON-NLS-1$
  1839 		if (priorityString == null || priorityString.equals(Messages.getString("AddrThreadTable.unsolvedPriority"))) //$NON-NLS-1$
  2378 			return new Integer(Integer.MIN_VALUE);
  1840 			return Integer.MIN_VALUE;
  2379 		else
  1841 		else
  2380 		{
  1842 		{
  2381 			int endIndex = priorityString.indexOf(Messages.getString("AddrThreadTable.priorityStringEnding")); //$NON-NLS-1$
  1843 			int endIndex = priorityString.indexOf(Messages.getString("AddrThreadTable.priorityStringEnding")); //$NON-NLS-1$
  2382 			int beginIndex = priorityString.indexOf(Messages.getString("AddrThreadTable.priorityStringStart")); //$NON-NLS-1$
  1844 			int beginIndex = priorityString.indexOf(Messages.getString("AddrThreadTable.priorityStringStart")); //$NON-NLS-1$
  2383 			String value = priorityString.substring(beginIndex+2, endIndex);
  1845 			String value = priorityString.substring(beginIndex+2, endIndex);
  2384 			return new Integer(Integer.parseInt(value));
  1846 			return Integer.parseInt(value);
  2385 		}
  1847 		}
  2386 	}
  1848 	}
  2387 
  1849 
  2388     // class to pass sample data to the save wizard
  1850     /** class to pass sample data to the save wizard */
  2389     public class SavePrioritySampleString implements ISaveSamples {
  1851     public class SavePrioritySampleString implements ISaveSamples {
  2390     	int graphIndex;
  1852     	int graphIndex;
  2391     	int drawMode;
  1853     	int drawMode;
  2392     	boolean done = false;
  1854     	boolean done = false;
  2393     	
  1855     	
       
  1856     	/**
       
  1857     	 * Constructor
       
  1858     	 * @param graphIndex
       
  1859     	 * @param drawMode
       
  1860     	 */
  2394     	public SavePrioritySampleString(int graphIndex, int drawMode) {
  1861     	public SavePrioritySampleString(int graphIndex, int drawMode) {
  2395     		this.graphIndex = graphIndex;
  1862     		this.graphIndex = graphIndex;
  2396     		this.drawMode   = drawMode;
  1863     		this.drawMode   = drawMode;
  2397 		}
  1864 		}
  2398 
  1865 
       
  1866     	/* (non-Javadoc)
       
  1867     	 * @see com.nokia.carbide.cpp.internal.pi.interfaces.ISaveSamples#getData()
       
  1868     	 */
  2399     	public String getData() {
  1869     	public String getData() {
  2400     		if (done)
  1870     		if (done)
  2401     			return null;
  1871     			return null;
  2402     		
  1872     		
  2403 			String returnString = getPrioritySampleString(graphIndex, drawMode);
  1873 			String returnString = getPrioritySampleString(graphIndex, drawMode);
  2407 
  1877 
  2408 		public String getData(int size) {
  1878 		public String getData(int size) {
  2409  			return getData();
  1879  			return getData();
  2410 		}
  1880 		}
  2411 
  1881 
       
  1882 		/* (non-Javadoc)
       
  1883 		 * @see com.nokia.carbide.cpp.internal.pi.interfaces.ISaveSamples#getIndex()
       
  1884 		 */
  2412 		public int getIndex() {
  1885 		public int getIndex() {
  2413 			return done ? 1 : 0;
  1886 			return done ? 1 : 0;
  2414 		}
  1887 		}
  2415 
  1888 
       
  1889 		/* (non-Javadoc)
       
  1890 		 * @see com.nokia.carbide.cpp.internal.pi.interfaces.ISaveSamples#clear()
       
  1891 		 */
  2416 		public void clear() {
  1892 		public void clear() {
  2417 			done = false;
  1893 			done = false;
  2418 		}
  1894 		}
  2419     }
  1895     }
  2420     
  1896     
  2431     }
  1907     }
  2432 
  1908 
  2433     protected void createPrioritySample(ArrayList<PrioritySample> prioritySamples, int graphIndex, ProfiledThread pt, int startTime, int endTime) {
  1909     protected void createPrioritySample(ArrayList<PrioritySample> prioritySamples, int graphIndex, ProfiledThread pt, int startTime, int endTime) {
  2434     	PrioritySample localSample = null;
  1910     	PrioritySample localSample = null;
  2435     	boolean addedLocalSample = false;
  1911     	boolean addedLocalSample = false;
  2436     	String priority = priorityTable.get(new Integer(pt.getThreadId()));
  1912     	String priority = priorityTable.get(Integer.valueOf(pt.getThreadId()));
  2437 		
  1913 		
  2438 		if (priority == null) {
  1914 		if (priority == null) {
  2439 			prioritySamples.add(new PrioritySample(0, pt, Messages.getString("AddrThreadTable.unknownPriority"))); //$NON-NLS-1$
  1915 			prioritySamples.add(new PrioritySample(0, pt, Messages.getString("AddrThreadTable.unknownPriority"))); //$NON-NLS-1$
  2440 			return;
  1916 			return;
  2441 		}
  1917 		}
  2516 				pt = (ProfiledThread) profiledThreads.get(i);
  1992 				pt = (ProfiledThread) profiledThreads.get(i);
  2517 
  1993 
  2518 				createPrioritySample(prioritySamples, graphIndex, pt, startIndex, endIndex); 
  1994 				createPrioritySample(prioritySamples, graphIndex, pt, startIndex, endIndex); 
  2519 			} else if (profiledThreads.get(i) instanceof ProfiledThreshold) {
  1995 			} else if (profiledThreads.get(i) instanceof ProfiledThreshold) {
  2520 				ProfiledThreshold pth = (ProfiledThreshold) profiledThreads.get(i);
  1996 				ProfiledThreshold pth = (ProfiledThreshold) profiledThreads.get(i);
  2521 				for (int j = 0; j < pth.getItems(graphIndex).size(); j++) {
  1997 				for (int j = 0; j < pth.getItems().size(); j++) {
  2522 					pt = (ProfiledThread) pth.getItems(graphIndex).get(j);
  1998 					pt = (ProfiledThread) pth.getItems().get(j);
  2523 					
  1999 					
  2524 					if (pt.isEnabled(graphIndex) && pt.getSampleCount(graphIndex) > 0)
  2000 					if (pt.isEnabled(graphIndex) && pt.getSampleCount(graphIndex) > 0)
  2525 						createPrioritySample(prioritySamples, graphIndex, pt, startIndex, endIndex); 
  2001 						createPrioritySample(prioritySamples, graphIndex, pt, startIndex, endIndex); 
  2526 				}
  2002 				}
  2527 			}
  2003 			}
  2536 								+ sample.priorityString + "\n";  //$NON-NLS-1$ //$NON-NLS-2$
  2012 								+ sample.priorityString + "\n";  //$NON-NLS-1$ //$NON-NLS-2$
  2537 			}
  2013 			}
  2538 		
  2014 		
  2539 		return returnString;
  2015 		return returnString;
  2540 	}
  2016 	}
       
  2017 	
  2541 }
  2018 }