HPCCallStackView.java
Go to the documentation of this file.00001 package edu.rice.cs.hpc.traceviewer.misc;
00002
00003 import java.util.Map;
00004
00005 import org.eclipse.swt.SWT;
00006 import org.eclipse.swt.events.SelectionEvent;
00007 import org.eclipse.swt.events.SelectionListener;
00008 import org.eclipse.swt.layout.GridData;
00009 import org.eclipse.swt.layout.GridLayout;
00010 import org.eclipse.swt.widgets.Composite;
00011 import org.eclipse.swt.widgets.Label;
00012 import org.eclipse.swt.widgets.Spinner;
00013 import org.eclipse.ui.ISizeProvider;
00014 import org.eclipse.ui.ISourceProvider;
00015 import org.eclipse.ui.ISourceProviderListener;
00016 import org.eclipse.ui.part.ViewPart;
00017 import org.eclipse.ui.services.ISourceProviderService;
00018
00019 import edu.rice.cs.hpc.traceviewer.services.DataService;
00020 import edu.rice.cs.hpc.traceviewer.spaceTimeData.SpaceTimeDataController;
00021
00023
00024 public class HPCCallStackView extends ViewPart implements ISizeProvider
00025 {
00026
00027 public static final String ID = "hpccallstackview.view";
00028
00029 CallStackViewer csViewer;
00030
00032 SpaceTimeMiniCanvas miniCanvas;
00033
00034 Spinner depthEditor;
00035
00036
00037 public void createPartControl(Composite master)
00038 {
00039 setupEverything(master);
00040 setListener();
00041 }
00042
00043 private void setupEverything(Composite master)
00044 {
00045
00046
00047
00048
00049 master.setLayout(new GridLayout());
00050 master.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, true));
00051
00052
00053
00054
00055 depthEditor = new Spinner(master, SWT.EMBEDDED);
00056 depthEditor.setMinimum(0);
00057 depthEditor.setPageIncrement(1);
00058 depthEditor.setLayout(new GridLayout());
00059 GridData depthData = new GridData(SWT.CENTER, SWT.TOP, true, false);
00060 depthData.widthHint = 140;
00061 depthEditor.setLayoutData(depthData);
00062 depthEditor.setVisible(false);
00063 depthEditor.addSelectionListener(new SelectionListener() {
00064 public void widgetSelected(SelectionEvent e) {
00065 String string = depthEditor.getText();
00066 int value;
00067 if (string.length()<1)
00068
00069
00070
00071
00072 return;
00073 else
00074 value = Integer.valueOf(string);
00075 int maximum = depthEditor.getMaximum();
00076 int minimum = 0;
00077 if (value > maximum)
00078 value = maximum;
00079 if (value < minimum)
00080 value = minimum;
00081 csViewer.setDepth(value);
00082 }
00083
00084 public void widgetDefaultSelected(SelectionEvent e) {
00085 }
00086 });
00087
00088
00089
00090
00091 csViewer = new CallStackViewer(master, this);
00092
00093
00094
00095
00096
00097 Label l = new Label(master, SWT.SINGLE);
00098 l.setText("Mini Map");
00099 miniCanvas = new SpaceTimeMiniCanvas(master);
00100 miniCanvas.setLayout(new GridLayout());
00101 GridData miniCanvasData = new GridData(SWT.CENTER, SWT.BOTTOM, true, false);
00102 miniCanvasData.heightHint = 100;
00103 miniCanvasData.widthHint = 140;
00104 miniCanvas.setLayoutData(miniCanvasData);
00105
00106 miniCanvas.setVisible(false);
00107 }
00108
00109 private void setListener() {
00110 ISourceProviderService service = (ISourceProviderService)getSite().getService(ISourceProviderService.class);
00111 ISourceProvider serviceProvider = service.getSourceProvider(DataService.DATA_UPDATE);
00112 serviceProvider.addSourceProviderListener( new ISourceProviderListener(){
00113
00114 public void sourceChanged(int sourcePriority, Map sourceValuesByName) { }
00115 public void sourceChanged(int sourcePriority, String sourceName,
00116 Object sourceValue) {
00117
00118
00119 if (sourceName.equals(DataService.DATA_UPDATE)) {
00120 if (sourceValue instanceof SpaceTimeDataController) {
00121
00122 csViewer.updateView();
00123 } else if (sourceValue instanceof Boolean) {
00124
00125
00126 miniCanvas.updateView();
00127
00128
00129
00130
00131 }
00132 }
00133 }
00134 });
00135 }
00136
00137
00138 public void updateView(SpaceTimeDataController _stData)
00139 {
00140 depthEditor.setMaximum(_stData.getMaxDepth());
00141 depthEditor.setSelection(0);
00142 depthEditor.setVisible(true);
00143
00144
00145
00146
00147
00148
00149 csViewer.getTable().setVisible(true);
00150
00151 this.miniCanvas.updateView(_stData);
00152
00153 miniCanvas.setVisible(true);
00154 }
00155
00156
00157
00158
00159
00160 public void setFocus()
00161 {
00162
00163 this.csViewer.getTable().setFocus();
00164 }
00165
00166
00167
00168
00169
00170 public int computePreferredSize(boolean width, int availableParallel, int availablePerpendicular, int preferredSize)
00171 {
00172 return preferredSize;
00173 }
00174
00175
00176
00177
00178
00179 public int getSizeFlags(boolean width)
00180 {
00181 return width ? SWT.MAX : 0;
00182 }
00183 }