sysperfana/perfinvestigator/com.nokia.carbide.cpp.pi.graphicsmemory/src/com/nokia/carbide/cpp/pi/graphicsmemory/GraphicsMemoryProcessTable.java
author Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
Wed, 23 Jun 2010 15:05:09 +0300
changeset 12 ae255c9aa552
permissions -rw-r--r--
Performance Investigator Carbide extension 2.4.0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
     1
/*
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
     2
 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
     3
 * All rights reserved.
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
     8
 *
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
     9
 * Initial Contributors:
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    11
 *
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    12
 * Contributors:
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    13
 *
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    14
 * Description: 
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    15
 *
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    16
 */
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    17
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    18
package com.nokia.carbide.cpp.pi.graphicsmemory;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    19
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    20
import java.awt.Toolkit;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    21
import java.awt.datatransfer.Clipboard;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    22
import java.awt.datatransfer.StringSelection;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    23
import java.awt.event.ActionEvent;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    24
import java.awt.event.FocusEvent;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    25
import java.awt.event.MouseEvent;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    26
import java.text.DecimalFormat;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    27
import java.util.ArrayList;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    28
import java.util.Enumeration;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    29
import java.util.HashSet;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    30
import java.util.Iterator;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    31
import java.util.SortedMap;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    32
import java.util.TreeMap;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    33
import java.util.Vector;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    34
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    35
import org.eclipse.jface.action.Action;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    36
import org.eclipse.jface.action.ActionContributionItem;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    37
import org.eclipse.jface.action.IAction;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    38
import org.eclipse.jface.action.IContributionManager;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    39
import org.eclipse.jface.action.IMenuManager;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    40
import org.eclipse.jface.action.SubMenuManager;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    41
import org.eclipse.jface.viewers.CheckStateChangedEvent;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    42
import org.eclipse.jface.viewers.CheckboxTableViewer;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    43
import org.eclipse.jface.viewers.ICheckStateListener;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    44
import org.eclipse.jface.viewers.IStructuredContentProvider;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    45
import org.eclipse.jface.viewers.ITableLabelProvider;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    46
import org.eclipse.jface.viewers.LabelProvider;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    47
import org.eclipse.jface.viewers.Viewer;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    48
import org.eclipse.jface.viewers.ViewerSorter;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    49
import org.eclipse.swt.SWT;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    50
import org.eclipse.swt.events.FocusListener;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    51
import org.eclipse.swt.events.MouseListener;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    52
import org.eclipse.swt.events.SelectionAdapter;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    53
import org.eclipse.swt.events.SelectionEvent;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    54
import org.eclipse.swt.graphics.Image;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    55
import org.eclipse.swt.layout.GridData;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    56
import org.eclipse.swt.layout.GridLayout;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    57
import org.eclipse.swt.widgets.Composite;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    58
import org.eclipse.swt.widgets.Display;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    59
import org.eclipse.swt.widgets.Label;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    60
import org.eclipse.swt.widgets.Menu;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    61
import org.eclipse.swt.widgets.MenuItem;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    62
import org.eclipse.swt.widgets.Table;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    63
import org.eclipse.swt.widgets.TableColumn;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    64
import org.eclipse.swt.widgets.TableItem;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    65
import org.eclipse.ui.IActionBars;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    66
import org.eclipse.ui.actions.ActionFactory;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    67
import org.eclipse.ui.ide.IIDEActionConstants;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    68
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    69
import com.nokia.carbide.cpp.internal.pi.interfaces.ISaveSamples;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    70
import com.nokia.carbide.cpp.internal.pi.visual.GenericTable;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    71
import com.nokia.carbide.cpp.internal.pi.visual.PIEvent;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    72
import com.nokia.carbide.cpp.pi.editors.PIPageEditor;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    73
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    74
public class GraphicsMemoryProcessTable extends GenericTable {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    75
	private static final int COLUMN_ID_GRAPHICS_MEMORY_PRIVATE = 14;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    76
	private static final int COLUMN_ID_GRAPHICS_MEMORY_SHARED = 15;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    77
	private static final int COLUMN_ID_GRAPHICS_MEMORY_TOTAL = 16;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    78
	private static final int COLUMN_ID_GRAPHICS_MEMORY_NAME = 17;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    79
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    80
	// sort direction
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    81
	private boolean sortAscending = true;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    82
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    83
	private GraphicsMemoryTraceGraph myGraph;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    84
	private Composite parent;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    85
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    86
	// override
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    87
	protected Vector<GraphicsMemoryProcess> tableItemData;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    88
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    89
	// menu items
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    90
	private Action selectAllAction;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    91
	private Action copyTableAction;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    92
	private Action copyAction;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    93
	private Action saveTableAction;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    94
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    95
	// class to pass sample data to the save wizard
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    96
	public class SaveSampleString implements ISaveSamples {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    97
		boolean done = false;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    98
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
    99
		public SaveSampleString() {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   100
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   101
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   102
		public String getData() {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   103
			if (done)
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   104
				return null;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   105
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   106
			String returnString = getSampleString();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   107
			done = true;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   108
			return returnString;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   109
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   110
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   111
		public String getData(int size) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   112
			return getData();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   113
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   114
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   115
		public int getIndex() {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   116
			return done ? 1 : 0;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   117
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   118
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   119
		public void clear() {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   120
			done = false;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   121
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   122
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   123
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   124
	/*
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   125
	 * return the graphics memory samples selected in the interval
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   126
	 */
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   127
	protected String getSampleString() {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   128
		int startTime = (int) (PIPageEditor.currentPageEditor().getStartTime() * 1000.0 + 0.0005);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   129
		int endTime = (int) (PIPageEditor.currentPageEditor().getEndTime() * 1000.0 + 0.0005);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   130
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   131
		GraphicsMemoryTrace trace = this.myGraph.getMemTrace();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   132
		String returnString = Messages
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   133
				.getString("GraphicsMemoryProcessTable.saveSamplesHeading"); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   134
		if (trace.getVersion() == 100) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   135
			TreeMap<Long, ArrayList<GraphicsMemorySample>> sorted = new TreeMap<Long, ArrayList<GraphicsMemorySample>>();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   136
			Enumeration<TreeMap<Long, GraphicsMemorySample>> enume = trace
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   137
					.getDrawDataByMemProcess().elements();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   138
			while (enume.hasMoreElements()) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   139
				TreeMap<Long, GraphicsMemorySample> map = enume.nextElement();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   140
				Iterator<GraphicsMemorySample> iterator = map.values()
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   141
						.iterator();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   142
				while (iterator.hasNext()) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   143
					GraphicsMemorySample memSample = iterator.next();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   144
					if(memSample.process.isEnabled(myGraph.getGraphIndex()) && !memSample.process.fullName
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   145
							.equals(GraphicsMemoryTraceParser.SAMPLE_TOTAL_MEMORY_PROCESS_NAME)){
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   146
						ArrayList<GraphicsMemorySample> memList = sorted
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   147
							.get(memSample.sampleSynchTime);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   148
						if (memList == null) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   149
							memList = new ArrayList<GraphicsMemorySample>();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   150
						}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   151
						memList.add(memSample);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   152
						sorted.put(memSample.sampleSynchTime, memList);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   153
					}else{
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   154
						break;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   155
					}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   156
				}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   157
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   158
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   159
			SortedMap<Long, ArrayList<GraphicsMemorySample>> selectionAreaMap = sorted
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   160
					.subMap((long) startTime, (long) endTime);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   161
			Iterator<ArrayList<GraphicsMemorySample>> iterator = selectionAreaMap
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   162
					.values().iterator();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   163
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   164
			while (iterator.hasNext()) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   165
				ArrayList<GraphicsMemorySample> memSamples = iterator.next();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   166
				for (GraphicsMemorySample memSample : memSamples) {			
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   167
					returnString += memSample.sampleSynchTime
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   168
							+ Messages
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   169
									.getString("GraphicsMemoryProcessTable.comma") //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   170
							+ memSample.process.fullName
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   171
							+ Messages
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   172
									.getString("GraphicsMemoryProcessTable.comma") //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   173
							+ ((memSample.privateSize + 512) / 1024)
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   174
							+ Messages
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   175
									.getString("GraphicsMemoryProcessTable.comma") //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   176
							+ ((memSample.sharedSize + 512) / 1024) + "\n"; //$NON-NLS-1$		
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   177
				}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   178
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   179
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   180
		return returnString;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   181
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   182
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   183
	protected MenuItem getSaveSamplesItem(Menu menu, boolean enabled) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   184
		MenuItem saveSamplesItem = new MenuItem(menu, SWT.PUSH);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   185
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   186
		saveSamplesItem.setText(Messages
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   187
				.getString("GraphicsMemoryProcessTable.saveCheckedSamples")); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   188
		saveSamplesItem.setEnabled(enabled);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   189
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   190
		if (enabled) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   191
			saveSamplesItem.addSelectionListener(new SelectionAdapter() {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   192
				public void widgetSelected(SelectionEvent e) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   193
					action("saveSamples"); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   194
				}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   195
			});
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   196
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   197
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   198
		return saveSamplesItem;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   199
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   200
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   201
	public GraphicsMemoryProcessTable(GraphicsMemoryTraceGraph myGraph,
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   202
			Composite parent) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   203
		Composite composite = new Composite(parent, SWT.NONE);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   204
		GridLayout gl = new GridLayout();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   205
		gl.marginHeight = 0;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   206
		gl.marginWidth = 0;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   207
		gl.marginLeft = 0;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   208
		gl.marginRight = 0;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   209
		composite.setLayout(gl);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   210
		this.myGraph = myGraph;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   211
		this.parent = composite;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   212
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   213
		Label label = new Label(composite, SWT.CENTER);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   214
		label.setBackground(composite.getDisplay().getSystemColor(
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   215
				SWT.COLOR_WHITE));
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   216
		label.setFont(PIPageEditor.helvetica_8);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   217
		label.setText(Messages.getString("GraphicsMemoryProcessTable.title")); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   218
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   219
		label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   220
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   221
		this.tableViewer = CheckboxTableViewer.newCheckList(composite,
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   222
				SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   223
						| SWT.FULL_SELECTION);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   224
		this.table = this.tableViewer.getTable();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   225
		this.table.setLayoutData(new GridData(GridData.FILL_BOTH));
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   226
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   227
		// add the check state handler, label provider and content provider
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   228
		this.tableViewer.addCheckStateListener(new CheckHandler());
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   229
		this.tableViewer.setLabelProvider(new SharedLabelProvider(this.table));
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   230
		this.tableViewer.setContentProvider(new MemoryTableContentProvider());
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   231
		this.tableViewer.setSorter(new SharedSorter());
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   232
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   233
		// give the table a heading for possible use in copying and exported
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   234
		this.table.setData(Messages
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   235
				.getString("GraphicsMemoryProcessTable.memory")); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   236
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   237
		// create the columns
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   238
		TableColumn column;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   239
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   240
		// data associated with the TableViewer will note which columns contain
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   241
		// hex values
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   242
		// Keep this in the order in which columns have been created
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   243
		boolean[] isHex = { false, false, false, false };
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   244
		this.table.setData("isHex", isHex); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   245
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   246
		// select/deselect column
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   247
		column = new TableColumn(this.table, SWT.CENTER);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   248
		column.setText(COLUMN_HEAD_GRAPHICS_MEMORY_NAME);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   249
		column.setWidth(COLUMN_WIDTH_GRAPHICS_MEMORY_NAME); 
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   250
		column.setData(Integer.valueOf(COLUMN_ID_GRAPHICS_MEMORY_NAME));
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   251
		column.setMoveable(true);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   252
		column.setResizable(true);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   253
		column.addSelectionListener(new ColumnSelectionHandler());
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   254
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   255
		column = new TableColumn(tableViewer.getTable(), SWT.RIGHT);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   256
		column.setText(COLUMN_HEAD_GRAPHICS_MEMORY_PRIVATE);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   257
		column.setWidth(COLUMN_WIDTH_GRAPHICS_MEMORY_PRIVATE);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   258
		column.setData(Integer.valueOf(COLUMN_ID_GRAPHICS_MEMORY_PRIVATE));
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   259
		column.setMoveable(true);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   260
		column.setResizable(true);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   261
		column.addSelectionListener(new ColumnSelectionHandler());
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   262
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   263
		column = new TableColumn(tableViewer.getTable(), SWT.RIGHT);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   264
		column.setText(COLUMN_HEAD_GRAPHICS_MEMORY_SHARED);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   265
		column.setWidth(COLUMN_WIDTH_GRAPHICS_MEMORY_SHARED);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   266
		column.setData(Integer.valueOf(COLUMN_ID_GRAPHICS_MEMORY_SHARED));
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   267
		column.setMoveable(true);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   268
		column.setResizable(true);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   269
		column.addSelectionListener(new ColumnSelectionHandler());
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   270
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   271
		column = new TableColumn(tableViewer.getTable(), SWT.RIGHT);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   272
		column.setText(COLUMN_HEAD_MEMORY_TOTAL);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   273
		column.setWidth(COLUMN_WIDTH_MEMORY_TOTAL);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   274
		column.setData(Integer.valueOf(COLUMN_ID_GRAPHICS_MEMORY_TOTAL));
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   275
		column.setMoveable(true);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   276
		column.setResizable(true);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   277
		column.addSelectionListener(new ColumnSelectionHandler());
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   278
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   279
		// initially, all rows are checked
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   280
		this.tableViewer.setAllChecked(true);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   281
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   282
		this.table.addMouseListener(new TableMouseListener());
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   283
		this.table.setHeaderVisible(true);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   284
		this.table.setLinesVisible(true);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   285
		this.table.setRedraw(true);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   286
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   287
		updateItemData(true);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   288
		((SharedSorter) tableViewer.getSorter())
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   289
				.doSort(COLUMN_ID_GRAPHICS_MEMORY_NAME);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   290
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   291
		// initially, all rows are checked
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   292
		this.tableViewer.setAllChecked(true);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   293
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   294
		createDefaultActions();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   295
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   296
		// listen for key sequences such as Ctrl-A and Ctrl-C
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   297
		table.addKeyListener(new TableKeyListener());
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   298
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   299
		table.addFocusListener(new FocusListener() {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   300
			IAction oldSelectAllAction = null;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   301
			IAction oldCopyAction = null;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   302
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   303
			public void focusGained(org.eclipse.swt.events.FocusEvent arg0) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   304
				IActionBars bars = PIPageEditor.getActionBars();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   305
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   306
				oldSelectAllAction = PIPageEditor.getActionBars()
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   307
						.getGlobalActionHandler(
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   308
								ActionFactory.SELECT_ALL.getId());
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   309
				oldCopyAction = PIPageEditor.getActionBars()
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   310
						.getGlobalActionHandler(ActionFactory.COPY.getId());
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   311
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   312
				bars.setGlobalActionHandler(ActionFactory.COPY.getId(),
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   313
						copyAction);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   314
				bars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(),
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   315
						selectAllAction);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   316
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   317
				copyAction.setEnabled(table.getSelectionCount() > 0);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   318
				selectAllAction.setEnabled(table.getItemCount() > 0);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   319
				bars.updateActionBars();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   320
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   321
				// add to the Edit menu
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   322
				IMenuManager editMenuManager = bars.getMenuManager()
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   323
						.findMenuUsingPath(IIDEActionConstants.M_EDIT);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   324
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   325
				if (editMenuManager instanceof SubMenuManager) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   326
					IContributionManager editManager = ((SubMenuManager) editMenuManager)
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   327
							.getParent();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   328
					ActionContributionItem item;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   329
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   330
					editMenuManager.remove("PICopyTable"); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   331
					copyTableAction.setEnabled(table.getItemCount() > 0);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   332
					item = new ActionContributionItem(copyTableAction);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   333
					item.setVisible(true);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   334
					editManager.prependToGroup(IIDEActionConstants.CUT_EXT,
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   335
							item);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   336
				}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   337
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   338
				// add to the File menu
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   339
				IMenuManager fileMenuManager = bars.getMenuManager()
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   340
						.findMenuUsingPath(IIDEActionConstants.M_FILE);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   341
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   342
				if (fileMenuManager instanceof SubMenuManager) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   343
					IContributionManager fileManager = ((SubMenuManager) fileMenuManager)
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   344
							.getParent();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   345
					ActionContributionItem item;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   346
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   347
					fileMenuManager.remove("PISaveTable"); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   348
					saveTableAction.setEnabled(table.getItemCount() > 0);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   349
					item = new ActionContributionItem(saveTableAction);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   350
					item.setVisible(true);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   351
					fileManager.insertAfter("saveAll", item); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   352
				}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   353
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   354
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   355
			public void focusLost(org.eclipse.swt.events.FocusEvent arg0) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   356
				IActionBars bars = PIPageEditor.getActionBars();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   357
				bars.setGlobalActionHandler(ActionFactory.COPY.getId(),
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   358
						oldCopyAction);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   359
				bars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(),
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   360
						oldSelectAllAction);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   361
				bars.updateActionBars();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   362
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   363
				SubMenuManager editMenuManager = (SubMenuManager) PIPageEditor
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   364
						.getMenuManager().find(IIDEActionConstants.M_EDIT);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   365
				editMenuManager.remove("PICopyTable"); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   366
				editMenuManager.update();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   367
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   368
				SubMenuManager fileMenuManager = (SubMenuManager) PIPageEditor
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   369
						.getMenuManager().find(IIDEActionConstants.M_FILE);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   370
				fileMenuManager.remove("PISaveTable"); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   371
				fileMenuManager.update();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   372
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   373
		});
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   374
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   375
		tableViewer.refresh();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   376
		table.redraw();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   377
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   378
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   379
	private class TableMouseListener implements MouseListener {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   380
		public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   381
			if (e.button == MouseEvent.BUTTON1) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   382
				TableItem[] selectedItems = table.getSelection();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   383
				if (selectedItems.length == 0)
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   384
					return;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   385
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   386
				if (selectedItems[0].getData() instanceof GraphicsMemoryProcess) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   387
					GraphicsMemoryProcess memProcess = (GraphicsMemoryProcess) (selectedItems[0]
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   388
							.getData());
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   389
					if (memProcess.isEnabled(myGraph.getGraphIndex()))
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   390
						action("remove"); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   391
					else
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   392
						action("add"); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   393
				}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   394
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   395
			selectAllAction.setEnabled(table.getItemCount() > 0);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   396
			copyAction.setEnabled(table.getSelectionCount() > 0);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   397
			copyTableAction.setEnabled(table.getItemCount() > 0);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   398
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   399
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   400
		public void mouseDown(org.eclipse.swt.events.MouseEvent e) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   401
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   402
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   403
		public void mouseUp(org.eclipse.swt.events.MouseEvent e) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   404
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   405
			selectAllAction.setEnabled(table.getItemCount() > 0);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   406
			copyAction.setEnabled(table.getSelectionCount() > 0);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   407
			copyTableAction.setEnabled(table.getItemCount() > 0);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   408
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   409
			if (e.button == MouseEvent.BUTTON3) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   410
				// get rid of last Menu created so we don't have double menu
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   411
				// on click
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   412
				if (contextMenu != null) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   413
					contextMenu.dispose();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   414
				}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   415
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   416
				contextMenu = new Menu(table.getShell(), SWT.POP_UP);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   417
				getCheckRows(contextMenu, table.getSelectionCount() > 0);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   418
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   419
				// select all, copy, and copy all
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   420
				new MenuItem(contextMenu, SWT.SEPARATOR);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   421
				getSelectAllItem(contextMenu, table.getItemCount() > 0);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   422
				getCopyItem(contextMenu, table.getSelectionCount() > 0);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   423
				getCopyTableItem(contextMenu, table.getItemCount() > 0);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   424
				selectAllAction.setEnabled(table.getItemCount() > 0);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   425
				copyAction.setEnabled(table.getSelectionCount() > 0);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   426
				copyTableAction.setEnabled(table.getItemCount() > 0);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   427
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   428
				// save all
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   429
				new MenuItem(contextMenu, SWT.SEPARATOR);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   430
				getSaveTableItem(contextMenu, table.getItemCount() > 0);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   431
				saveTableAction.setEnabled(table.getItemCount() > 0);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   432
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   433
				// save samples
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   434
				int startTime = (int) (PIPageEditor.currentPageEditor()
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   435
						.getStartTime() * 1000.0f);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   436
				int endTime = (int) (PIPageEditor.currentPageEditor()
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   437
						.getEndTime() * 1000.0f);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   438
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   439
				getSaveSamplesItem(contextMenu, myGraph.haveEnabled()
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   440
						&& (startTime != -1) && (endTime != -1)
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   441
						&& (startTime != endTime));
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   442
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   443
				contextMenu.setLocation(parent.toDisplay(e.x
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   444
						+ table.getLocation().x, e.y + table.getLocation().y));
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   445
				contextMenu.setVisible(true);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   446
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   447
				new MenuItem(contextMenu, SWT.SEPARATOR);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   448
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   449
				MenuItem memoryStatsItem = new MenuItem(contextMenu, SWT.PUSH);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   450
				memoryStatsItem.setText(Messages
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   451
						.getString("GraphicsMemoryPlugin.memoryStats")); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   452
				memoryStatsItem.addSelectionListener(new SelectionAdapter() {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   453
					public void widgetSelected(SelectionEvent e) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   454
						new GraphicsMemoryStatisticsDialog(Display.getCurrent());
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   455
					}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   456
				});
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   457
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   458
				table.setMenu(contextMenu);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   459
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   460
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   461
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   462
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   463
	private static class MemoryTableContentProvider implements
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   464
			IStructuredContentProvider {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   465
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   466
		public MemoryTableContentProvider() {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   467
			super();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   468
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   469
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   470
		@SuppressWarnings("unchecked")
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   471
		public Object[] getElements(Object inputElement) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   472
			return ((Vector<GraphicsMemoryProcess>) inputElement).toArray();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   473
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   474
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   475
		public void dispose() {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   476
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   477
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   478
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   479
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   480
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   481
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   482
	private class CheckHandler implements ICheckStateListener {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   483
		public void checkStateChanged(CheckStateChangedEvent event) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   484
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   485
			if (!(event.getElement() instanceof GraphicsMemoryProcess))
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   486
				return;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   487
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   488
			// set the stored value to the checkbox value
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   489
			GraphicsMemoryProcess memProcess = (GraphicsMemoryProcess) event
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   490
					.getElement();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   491
			memProcess.setEnabled(myGraph.getGraphIndex(), event.getChecked());
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   492
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   493
			selectionChangeNotify();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   494
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   495
			table.deselectAll();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   496
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   497
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   498
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   499
	void selectionChangeNotify() {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   500
		this.tableViewer.refresh();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   501
		this.table.redraw();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   502
		PIEvent be = new PIEvent(null, PIEvent.CHANGED_MEMORY_TABLE);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   503
		myGraph.piEventReceived(be);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   504
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   505
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   506
	private class SharedLabelProvider extends LabelProvider implements
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   507
			ITableLabelProvider {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   508
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   509
		private DecimalFormat decimalFormat = new DecimalFormat(Messages
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   510
				.getString("GraphicsMemoryProcessTable.kbFormat")); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   511
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   512
		Table table;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   513
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   514
		public SharedLabelProvider(Table table) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   515
			super();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   516
			this.table = table;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   517
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   518
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   519
		public String getColumnText(Object element, int columnIndex) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   520
			int columnId = ((Integer) table.getColumn(columnIndex).getData())
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   521
					.intValue();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   522
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   523
			if (!(element instanceof GraphicsMemoryProcess))
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   524
				return ""; //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   525
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   526
			GraphicsMemoryProcess profiledItem = (GraphicsMemoryProcess) element;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   527
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   528
			switch (columnId) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   529
			case COLUMN_ID_GRAPHICS_MEMORY_NAME: {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   530
				return profiledItem.fullName;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   531
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   532
			case COLUMN_ID_GRAPHICS_MEMORY_PRIVATE: {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   533
				double startTime = PIPageEditor.currentPageEditor()
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   534
						.getStartTime();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   535
				double endTime = PIPageEditor.currentPageEditor().getEndTime();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   536
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   537
				if ((startTime == -1) || (endTime == -1)
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   538
						|| (startTime == endTime))
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   539
					return ""; //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   540
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   541
				return decimalFormat
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   542
						.format((profiledItem.maxMemoryItem.maxPrivate + 512) / 1024);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   543
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   544
			case COLUMN_ID_GRAPHICS_MEMORY_SHARED: {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   545
				double startTime = PIPageEditor.currentPageEditor()
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   546
						.getStartTime();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   547
				double endTime = PIPageEditor.currentPageEditor().getEndTime();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   548
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   549
				if ((startTime == -1) || (endTime == -1)
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   550
						|| (startTime == endTime))
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   551
					return ""; //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   552
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   553
				return decimalFormat
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   554
						.format((profiledItem.maxMemoryItem.maxShared + 512) / 1024);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   555
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   556
			case COLUMN_ID_GRAPHICS_MEMORY_TOTAL: {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   557
				double startTime = PIPageEditor.currentPageEditor()
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   558
						.getStartTime();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   559
				double endTime = PIPageEditor.currentPageEditor().getEndTime();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   560
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   561
				if ((startTime == -1) || (endTime == -1)
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   562
						|| (startTime == endTime))
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   563
					return ""; //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   564
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   565
				return decimalFormat
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   566
						.format((profiledItem.maxMemoryItem.maxTotal + 512) / 1024);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   567
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   568
			default: {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   569
				break;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   570
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   571
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   572
			// should never get here
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   573
			return ""; //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   574
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   575
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   576
		public Image getColumnImage(Object element, int columnIndex) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   577
			return null;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   578
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   579
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   580
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   581
	/*
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   582
	 * TableViewer sorter for the called-by and called function tableviewers
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   583
	 */
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   584
	private class SharedSorter extends ViewerSorter {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   585
		// last column sorted
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   586
		private int column = -1;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   587
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   588
		/*
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   589
		 * decide on which column to sort by, and the sort ordering
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   590
		 */
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   591
		public void doSort(int column) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   592
			// ignore the column passed in and use the id set by the column
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   593
			// selection handler
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   594
			if (column == this.column) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   595
				// sort in other order
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   596
				sortAscending = !sortAscending;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   597
			} else {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   598
				// changed columns, so sort in the default order
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   599
				switch (column) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   600
				case COLUMN_ID_GRAPHICS_MEMORY_NAME: {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   601
					// sort in ascending order
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   602
					sortAscending = true;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   603
					break;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   604
				}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   605
				case COLUMN_ID_GRAPHICS_MEMORY_PRIVATE:
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   606
				case COLUMN_ID_GRAPHICS_MEMORY_SHARED:
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   607
				case COLUMN_ID_GRAPHICS_MEMORY_TOTAL: {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   608
					// sort in descending order
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   609
					sortAscending = false;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   610
					break;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   611
				}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   612
				default: {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   613
					// ignore the column
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   614
					return;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   615
				}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   616
				}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   617
				this.column = column;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   618
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   619
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   620
			// find the TableColumn corresponding to column, and give it a
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   621
			// column direction
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   622
			TableColumn sortByColumn = null;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   623
			for (int i = 0; i < table.getColumnCount(); i++) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   624
				if (table.getColumn(i).getData() instanceof Integer) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   625
					if (((Integer) table.getColumn(i).getData()) == column) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   626
						sortByColumn = table.getColumn(i);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   627
						break;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   628
					}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   629
				}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   630
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   631
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   632
			if (sortByColumn != null) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   633
				table.setSortColumn(sortByColumn);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   634
				table.setSortDirection(sortAscending ? SWT.UP : SWT.DOWN);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   635
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   636
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   637
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   638
		/*
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   639
		 * compare two items from a table column
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   640
		 */
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   641
		@SuppressWarnings("unchecked")
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   642
		public int compare(Viewer viewer, Object e1, Object e2) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   643
			int returnCode = 0;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   644
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   645
			GraphicsMemoryProcess elem1 = (GraphicsMemoryProcess) e1;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   646
			GraphicsMemoryProcess elem2 = (GraphicsMemoryProcess) e2;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   647
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   648
			// find the memory information for the two processes
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   649
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   650
			// compare based on the memory information
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   651
			switch (column) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   652
			case COLUMN_ID_GRAPHICS_MEMORY_PRIVATE:
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   653
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   654
				returnCode = elem1.maxMemoryItem.maxPrivate > elem2.maxMemoryItem.maxPrivate ? 1
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   655
						: -1;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   656
				break;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   657
			case COLUMN_ID_GRAPHICS_MEMORY_SHARED:
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   658
				returnCode = elem1.maxMemoryItem.maxShared > elem2.maxMemoryItem.maxShared ? 1
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   659
						: -1;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   660
				break;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   661
			case COLUMN_ID_GRAPHICS_MEMORY_TOTAL:
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   662
				returnCode = elem1.maxMemoryItem.maxTotal > elem2.maxMemoryItem.maxTotal ? 1
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   663
						: -1;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   664
				break;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   665
			case COLUMN_ID_GRAPHICS_MEMORY_NAME: {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   666
				returnCode = this.getComparator().compare(elem1.fullName,
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   667
						elem2.fullName);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   668
				break;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   669
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   670
			default:
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   671
				break;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   672
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   673
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   674
			// for descending order, reverse the sense of the compare
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   675
			if (!sortAscending)
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   676
				returnCode = -returnCode;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   677
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   678
			return returnCode;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   679
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   680
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   681
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   682
	public void actionPerformed(ActionEvent e) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   683
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   684
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   685
	public void action(String actionString) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   686
		int graphIndex = this.myGraph.getGraphIndex();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   687
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   688
		if (actionString.equals("add") //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   689
				|| actionString.equals("remove")) //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   690
		{
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   691
			actionAddRemove(actionString, graphIndex);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   692
		} else if (actionString.equals("addall") //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   693
				|| actionString.equals("removeall")) //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   694
		{
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   695
			actionAddRemoveAll(actionString, graphIndex);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   696
		} else if (actionString.equals("copy")) //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   697
		{
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   698
			actionCopyOrSave(true, this.table, CHECKBOX_TEXT, false, "\t", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   699
			return; // no redraw needed
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   700
		} else if (actionString.equals("copyTable")) //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   701
		{
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   702
			actionCopyOrSave(true, this.table, CHECKBOX_TEXT, true, "\t", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   703
			return; // no redraw needed
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   704
		} else if (actionString.equals("selectAll")) //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   705
		{
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   706
			actionSelectAll();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   707
			return;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   708
		} else if (actionString.equals("saveTable")) //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   709
		{
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   710
			actionCopyOrSave(false, this.table, CHECKBOX_TEXT, true, ",", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   711
			return; // no redraw needed
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   712
		} else if (actionString.equals("saveSamples")) //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   713
		{
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   714
			SaveSampleString saveSampleString = new SaveSampleString();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   715
			actionSaveSamples(saveSampleString); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   716
			return;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   717
		} else if (actionString.equals("saveTableTest")) //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   718
		{
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   719
			// copy save file contents to the clipboard for easy viewing
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   720
			Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   721
			SaveTableString getString = new SaveTableString(this.table,
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   722
					CHECKBOX_TEXT, ",", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   723
			String copyString = getString.getData();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   724
			StringSelection contents = new StringSelection(copyString);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   725
			cb.setContents(contents, contents);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   726
			return;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   727
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   728
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   729
		tableViewer.refresh();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   730
		table.redraw();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   731
		this.myGraph.repaint();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   732
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   733
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   734
	private void actionAddRemove(String actionString, int graphIndex) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   735
		GraphicsMemoryProcess memProcess;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   736
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   737
		// true for "add", false for "remove"
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   738
		boolean addIt = actionString.equals("add"); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   739
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   740
		TableItem[] selectedItems = this.table.getSelection();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   741
		for (int i = 0; i < selectedItems.length; i++) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   742
			selectedItems[i].setChecked(addIt);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   743
			memProcess = (GraphicsMemoryProcess) ((TableItem) selectedItems[i])
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   744
					.getData();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   745
			memProcess.setEnabled(graphIndex, addIt);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   746
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   747
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   748
		// this table's set of checkbox-selected rows has changed,
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   749
		// so propagate that information
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   750
		if (selectedItems.length != 0)
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   751
			selectionChangeNotify();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   752
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   753
		this.table.deselectAll();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   754
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   755
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   756
	private void actionAddRemoveAll(String actionString, int graphIndex) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   757
		GraphicsMemoryProcess memProcess;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   758
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   759
		// true for "add", false for "remove"
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   760
		boolean addIt = actionString.equals("addall"); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   761
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   762
		TableItem[] selectedItems = this.table.getItems();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   763
		for (int i = 0; i < selectedItems.length; i++) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   764
			selectedItems[i].setChecked(addIt);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   765
			memProcess = (GraphicsMemoryProcess) ((TableItem) selectedItems[i])
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   766
					.getData();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   767
			memProcess.setEnabled(graphIndex, addIt);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   768
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   769
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   770
		// this table's set of checkbox-selected rows has changed,
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   771
		// so propagate that information
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   772
		selectionChangeNotify();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   773
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   774
		this.table.deselectAll();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   775
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   776
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   777
	public void focusGained(FocusEvent e) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   778
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   779
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   780
	public void focusLost(FocusEvent e) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   781
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   782
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   783
	public void piEventReceived(PIEvent be) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   784
		if (be.getType() == PIEvent.SELECTION_AREA_CHANGED2) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   785
			this.tableViewer.refresh();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   786
			this.table.redraw();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   787
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   788
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   789
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   790
	public void updateItemData(boolean setInput) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   791
		HashSet<GraphicsMemoryProcess> noDuplicateMemProcesses = myGraph
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   792
				.getMemTrace().getNoDuplicateMemProcesses();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   793
		if (tableItemData == null)
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   794
			tableItemData = new Vector<GraphicsMemoryProcess>(
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   795
					noDuplicateMemProcesses.size());
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   796
		else
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   797
			tableItemData.clear();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   798
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   799
		// tableItemData contains one entry per table row
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   800
		// the first profiled process is the system-wide total memory information
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   801
		for (Iterator<GraphicsMemoryProcess> iter = noDuplicateMemProcesses
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   802
				.iterator(); iter.hasNext();) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   803
			GraphicsMemoryProcess memProcess = iter.next();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   804
			if ((memProcess.processId != GraphicsMemoryTraceParser.SAMPLE_TOTAL_MEMORY_PROCESS_ID)) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   805
				tableItemData.add(memProcess);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   806
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   807
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   808
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   809
		// refresh the table, if needed
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   810
		if (setInput)
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   811
			refreshTableViewer();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   812
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   813
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   814
	public void refreshTableViewer() {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   815
		this.tableViewer.setInput(tableItemData);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   816
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   817
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   818
	public void sortOnColumnSelection(TableColumn tableColumn) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   819
		int columnID = ((Integer) tableColumn.getData()).intValue();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   820
		((SharedSorter) tableViewer.getSorter()).doSort(columnID);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   821
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   822
		tableViewer.refresh();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   823
		table.redraw();
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   824
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   825
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   826
	private class ColumnSelectionHandler extends SelectionAdapter {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   827
		public void widgetSelected(SelectionEvent e) {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   828
			if (!(e.widget instanceof TableColumn))
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   829
				return;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   830
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   831
			sortOnColumnSelection((TableColumn) e.widget);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   832
		}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   833
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   834
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   835
	public CheckboxTableViewer getTableViewer() {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   836
		return this.tableViewer;
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   837
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   838
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   839
	protected void createDefaultActions() {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   840
		selectAllAction = new Action("SelectAll") { //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   841
			public void run() {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   842
				action("selectAll"); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   843
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   844
		};
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   845
		selectAllAction.setEnabled(true);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   846
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   847
		copyAction = new Action("Copy") { //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   848
			public void run() {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   849
				action("copy"); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   850
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   851
		};
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   852
		copyAction.setEnabled(false);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   853
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   854
		copyTableAction = new Action("CopyTable") { //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   855
			public void run() {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   856
				action("copyTable"); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   857
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   858
		};
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   859
		copyTableAction.setEnabled(true);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   860
		copyTableAction.setId("PICopyTable"); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   861
		copyTableAction.setText(Messages
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   862
				.getString("GraphicsMemoryProcessTable.copyTable")); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   863
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   864
		saveTableAction = new Action("SaveTable") { //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   865
			public void run() {
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   866
				action("saveTable"); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   867
			}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   868
		};
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   869
		saveTableAction.setEnabled(true);
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   870
		saveTableAction.setId("PISaveTable"); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   871
		saveTableAction.setText(Messages
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   872
				.getString("GraphicsMemoryProcessTable.SaveTable")); //$NON-NLS-1$
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   873
	}
ae255c9aa552 Performance Investigator Carbide extension 2.4.0
Toni Pulkkinen <ext-toni.p.pulkkinen@nokia.com>
parents:
diff changeset
   874
}