diff options
Diffstat (limited to 'systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools')
30 files changed, 0 insertions, 5721 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/Activator.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/Activator.java deleted file mode 100644 index 8eb6c92471..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/Activator.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.systemtap.local.callgraph; - -import java.io.IOException; -import java.net.URL; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "org.eclipse.linuxtools.systemtap.local.callgraph"; //$NON-NLS-1$ - - // The shared instance - private static Activator plugin; - - /** - * The constructor - */ - public Activator() { - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - - //TODO: Is this too slow? - CallGraphConstants.setPluginLocation(getPluginLocation()); - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - - /** - * Returns an image descriptor for the image file at the given - * plug-in relative path - * - * @param path the path - * @return the image descriptor - */ - public static ImageDescriptor getImageDescriptor(String path) { - return imageDescriptorFromPlugin(PLUGIN_ID, path); - } - - public String getPluginLocation() { - Bundle bundle = getBundle(); - - URL locationUrl = FileLocator.find(bundle,new Path("/"), null); //$NON-NLS-1$ - URL fileUrl = null; - try { - fileUrl = FileLocator.toFileURL(locationUrl); - } catch (IOException e) { - e.printStackTrace(); - } - return fileUrl.getFile(); - - } - -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/AggregateLayoutAlgorithm.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/AggregateLayoutAlgorithm.java deleted file mode 100644 index fdb2bfba10..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/AggregateLayoutAlgorithm.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.systemtap.local.callgraph; - -import java.util.ArrayList; -import java.util.TreeSet; -import java.util.Map.Entry; - -import org.eclipse.zest.layouts.algorithms.GridLayoutAlgorithm; -import org.eclipse.zest.layouts.dataStructures.InternalNode; -import org.eclipse.zest.layouts.dataStructures.InternalRelationship; - -/** - * Calculates the size and location of a node when rendering the - * Aggregate View. This avoids needing to design a Layout Algorithm - * from scratch. - */ -public class AggregateLayoutAlgorithm extends GridLayoutAlgorithm{ - - protected ArrayList<Long> sortedAggregateTimes; - protected Long totalTime; - protected int graphWidth; - - public AggregateLayoutAlgorithm(int styles, TreeSet<Entry<String, Long>> entries, Long time, int width){ - super(styles); - - this.sortedAggregateTimes = new ArrayList<Long>(); - for (Entry<String,Long> val : entries){ - this.sortedAggregateTimes.add(val.getValue()); - } - - this.totalTime = time; - this.graphWidth = width; - } - - //THIS METHOD OVERRIDES THE PARENT'S IMPLEMENTATION (WHICH IS EMPTY ANYWAYS) - protected void postLayoutAlgorithm(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider) { - Long time; - final int minimumSize = 40; - double percent; - double xcursor = 0.0; - double ycursor = 0.0; - - for (InternalNode sn : entitiesToLayout) { - time = sortedAggregateTimes.remove(0); - percent = (double) time / (double) totalTime; - double snWidth = (sn.getInternalWidth() * percent) + minimumSize; - double snHeight = (sn.getInternalHeight() * percent) + minimumSize; - - sn.setSize(snWidth, snHeight); - if (xcursor + snWidth > graphWidth) { - //reaching the end of row, move to lower column - ycursor += snHeight; - xcursor = 0; - sn.setLocation(xcursor, ycursor); - } else { - sn.setLocation(xcursor, ycursor); - xcursor += snWidth; - } - } - - } - -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/CallGraphConstants.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/CallGraphConstants.java deleted file mode 100644 index 6dc1976525..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/CallGraphConstants.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.systemtap.local.callgraph; - -public class CallGraphConstants { - - public static String PLUGIN_LOCATION = ""; //$NON-NLS-1$ - - public static void setPluginLocation(String val) { - PLUGIN_LOCATION = val; - } - - - -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/CallgraphView.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/CallgraphView.java deleted file mode 100644 index 143ae2cede..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/CallgraphView.java +++ /dev/null @@ -1,1172 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.systemtap.local.callgraph; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.Vector; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.linuxtools.systemtap.local.core.PluginConstants; -import org.eclipse.linuxtools.systemtap.local.core.SystemTapErrorHandler; -import org.eclipse.linuxtools.systemtap.local.core.SystemTapUIErrorMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyleRange; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Spinner; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; -import org.eclipse.ui.part.ViewPart; - -/** - * The SystemTap View for displaying output of the 'stap' command, and acts - * as a container for any graph to be rendered. Any buttons/controls/actions - * necessary to the smooth running of SystemTap could be placed here. - */ -public class CallgraphView extends ViewPart { - private static final String NEW_LINE = Messages.getString("CallgraphView.3"); //$NON-NLS-1$ - private static CallgraphView stapview; - private static boolean isInitialized = false; - - private Display display; - private static StyledText viewer; - private int previousEnd; - - - private static Action open_callgraph; - private static Action save_callgraph; - private static Action open_default; - private static Action error_errorLog; - private static Action error_deleteError; - private static Action view_treeview; - private static Action view_radialview; - private static Action view_aggregateview; - private static Action view_boxview; - private static Action view_refresh; - private static Action animation_slow; - private static Action animation_fast; - private static Action mode_collapsednodes; - private static Action markers_next; - private static Action markers_previous; - private static Action limits; - private static Action goto_next; - private static Action goto_previous; - private static Action goto_last; - - private static IMenuManager menu; - private static IMenuManager gotoMenu; - private static IMenuManager file; - private static IMenuManager errors; - private static IMenuManager view; - private static IMenuManager animation; - private static IMenuManager markers; //Unused - private static IMenuManager help; - @SuppressWarnings("unused") - private static Action help_about; - private static Action help_version; - public static IToolBarManager mgr; - - public static Composite masterComposite; - private static Composite graphComp; - private static Composite treeComp; - - private static StapGraphParser parser; - private static StapGraph graph; - - - /** - * The constructor. - * @return - */ - public CallgraphView() { - isInitialized = true; - } - - public static CallgraphView getSingleInstance(){ - if (isInitialized){ - return stapview; - } - return null; - } - - - public static void testFunction() { - if (masterComposite != null && !masterComposite.isDisposed()) - masterComposite.dispose(); - } - - public static void setValues(Composite graphC, Composite treeC, StapGraph g, StapGraphParser p){ - treeComp = treeC; - graphComp = graphC; - graph = g; - parser = p; - } - - - /** - * Enable or Disable the graph options - * @param visible - */ - public static void setGraphOptions (boolean visible){ - save_callgraph.setEnabled(visible); - view_treeview.setEnabled(visible); - view_radialview.setEnabled(visible); - view_aggregateview.setEnabled(visible); - view_boxview.setEnabled(visible); - view_refresh.setEnabled(visible); - limits.setEnabled(visible); - - markers_next.setEnabled(visible); - markers_previous.setEnabled(visible); - - animation_slow.setEnabled(visible); - animation_fast.setEnabled(visible); - mode_collapsednodes.setEnabled(visible); - - goto_next.setEnabled(visible); - goto_previous.setEnabled(visible); - goto_last.setEnabled(visible); - } - -/** - * @param doMaximize : true && view minimized will maximize the view, - * otherwise it will just 'refresh' - */ - public static void maximizeOrRefresh(boolean doMaximize){ - IWorkbenchPage page = CallgraphView - .getSingleInstance().getViewSite().getWorkbenchWindow().getActivePage(); - - if (doMaximize && page.getPartState(page.getActivePartReference()) != IWorkbenchPage.STATE_MAXIMIZED){ - IWorkbenchAction action = ActionFactory.MAXIMIZE.create(CallgraphView - .getSingleInstance().getViewSite().getWorkbenchWindow()); - action.run(); - }else{ - CallgraphView.layout(); - } - } - - - public static void firstTimeRefresh(){ - - graphComp.setSize(masterComposite.getSize().x ,masterComposite.getSize().y); - } - - - public static Composite makeTreeComp(int treeSize) { - if (treeComp != null && !treeComp.isDisposed()) { - return treeComp; - } - - Composite treeComp = new Composite(CallgraphView.masterComposite, SWT.NONE); - GridData treegd = new GridData(SWT.BEGINNING, SWT.FILL, false, true); - treegd.widthHint = treeSize; - treeComp.setLayout(new FillLayout()); - treeComp.setLayoutData(treegd); - return treeComp; - } - - public static Composite makeGraphComp() { -// if (graphComp != null && !graphComp.isDisposed()) { -// return graphComp; -// } - if (graphComp != null) - graphComp.dispose(); - Composite graphComp = new Composite(CallgraphView.masterComposite, SWT.NONE); - GridData graphgd = new GridData(SWT.FILL, SWT.FILL, true, true); - GridLayout gl = new GridLayout(2, false); - gl.horizontalSpacing=0; - gl.verticalSpacing=0; - - graphComp.setLayout(gl); - graphComp.setLayoutData(graphgd); - return graphComp; - } - - public static void layout() { - masterComposite.layout(); - } - - /** - * If view is not maximized it will be maximized - */ - public static void maximizeIfUnmaximized() { - IWorkbenchPage page = CallgraphView - .getSingleInstance().getViewSite().getWorkbenchWindow().getActivePage(); - - if (page.getPartState(page.getActivePartReference()) != IWorkbenchPage.STATE_MAXIMIZED){ - IWorkbenchAction action = ActionFactory.MAXIMIZE.create(CallgraphView - .getSingleInstance().getViewSite().getWorkbenchWindow()); - action.run(); - } - - } - - -// -// public static void disposeAll() { -// if (graphComp != null) { -// graphComp.setVisible(false); -// GridData gd = (GridData) graphComp.getLayoutData(); -// gd.exclude = true; -// graphComp.setLayoutData(gd); -// graphComp.dispose(); -// } -// if (treeComp != null) { -// treeComp.setVisible(false); -// GridData gd = (GridData) treeComp.getLayoutData(); -// gd.exclude = true; -// treeComp.setLayoutData(gd); -// treeComp.dispose(); -// } -// } - - /** - * This must be executed before a Graph is displayed - */ - public static void createPartControl(){ - - - setGraphOptions(true); - String text = ""; //$NON-NLS-1$ - StyleRange[] sr = null; - - - if (viewer != null && !viewer.isDisposed()) { - text = viewer.getText(); - sr = viewer.getStyleRanges(); - viewer.dispose(); - } - - - graphComp.setParent(masterComposite); - - if (treeComp != null) - treeComp.setParent(masterComposite); - - if (graph == null) { - createViewer(masterComposite); - viewer.setText(text); - viewer.setStyleRanges(sr); - } - - //MAXIMIZE THE SYSTEMTAP VIEW WHEN RENDERING A GRAPH - firstTimeRefresh(); - } - - - public static void createViewer(Composite parent){ - viewer = new StyledText(parent, SWT.READ_ONLY | SWT.MULTI - | SWT.V_SCROLL | SWT.WRAP); - - viewer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - Font font = new Font(parent.getDisplay(), "Monospace", 11, SWT.NORMAL); //$NON-NLS-1$ - viewer.setFont(font); - } - - /** - * This is a callback that will allow us to create the viewer and - * initialize it. - */ - public void createPartControl(Composite parent) { - if (masterComposite != null) - masterComposite.dispose(); - masterComposite = parent; - this.display = parent.getDisplay(); - GridLayout layout = new GridLayout(2, false); - layout.horizontalSpacing=0; - GridData gd = new GridData(100, 100); - - parent.setLayout(layout); - parent.setLayoutData(gd); - - //CREATE THE TEXT VIEWER - if (graph == null) - createViewer(parent); - - // LOAD ALL ACTIONS - createActions(); - - //MENU FOR SYSTEMTAP BUTTONS - mgr = getViewSite().getActionBars().getToolBarManager(); - - - //MENU FOR SYSTEMTAP GRAPH OPTIONS - menu = getViewSite().getActionBars().getMenuManager(); - - // ADD OPTIONS TO THE GRAPH MENU - file = new MenuManager(Messages.getString("CallgraphView.0")); //$NON-NLS-1$ - view = new MenuManager(Messages.getString("CallgraphView.1")); //$NON-NLS-1$ - errors = new MenuManager(Messages.getString("CallgraphView.Errors")); //$NON-NLS-1$ - animation = new MenuManager(Messages.getString("CallgraphView.2")); //$NON-NLS-1$ - help = new MenuManager(Messages.getString("CallgraphView.5")); //$NON-NLS-1$ - markers = new MenuManager(Messages.getString("CallgraphView.6")); //$NON-NLS-1$ - gotoMenu = new MenuManager(Messages.getString("CallgraphView.9")); //$NON-NLS-1$ - - - - menu.add(file); - menu.add(view); -// menu.add(animation); - menu.add(gotoMenu); - menu.add(errors); - menu.add(help); - - - file.add(open_callgraph); - file.add(open_default); - file.add(save_callgraph); - - - errors.add(error_errorLog); - errors.add(error_deleteError); - - - view.add(view_treeview); - view.add(view_radialview); - view.add(view_aggregateview); - view.add(view_boxview); - view.add(getView_refresh()); - view.add(mode_collapsednodes); - view.add(limits); - - - gotoMenu.add(goto_previous); - gotoMenu.add(goto_next); - gotoMenu.add(goto_last); - - - mgr.add(view_radialview); - mgr.add(view_treeview); - mgr.add(view_boxview); - mgr.add(view_aggregateview); - mgr.add(getView_refresh()); - mgr.add(mode_collapsednodes); - -// help.add(help_about); - help.add(help_version); - - markers.add(markers_next); - markers.add(markers_previous); - - animation.add(animation_slow); - animation.add(animation_fast); -// menu.add(markers); - - setGraphOptions(false); - - // Colouring helper variable - previousEnd = 0; - stapview = this; - } - - /** - * Passing the focus request to the viewer's control. - */ - public void setFocus() { - if (viewer != null && !viewer.isDisposed()) - viewer.setFocus(); - } - - /** - * Force the CallgraphView to initialize - */ - public static void forceDisplay(){ - try { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - window.getActivePage().showView("org.eclipse.linuxtools.systemtap.local.callgraph.callgraphview").setFocus(); //$NON-NLS-1$ - } catch (PartInitException e2) { - e2.printStackTrace(); - } - - } - - public void prettyPrintln(String text) { - Vector<StyleRange> styles = new Vector<StyleRange>(); - String[] txt = text.split("\\n"); //$NON-NLS-1$ - int lineOffset = 0; - int inLineOffset; - - //txt[] contains text, with one entry for each new line - for (int i = 0; i < txt.length; i++) { - - //Skip blank strings - if (txt[i].length() == 0) { - viewer.append(NEW_LINE); - continue; - } - - //Search for colour codes, if none exist then continue - String[] split_txt = txt[i].split("~\\("); //$NON-NLS-1$ - if (split_txt.length == 1) { - viewer.append(split_txt[0]); - viewer.append(NEW_LINE); - continue; - } - - inLineOffset = 0; - for (int k = 0; k < split_txt.length; k++) { - //Skip blank substrings - if (split_txt[k].length() == 0) - continue; - - //Split for the number codes - String[] coloursAndText = split_txt[k].split("\\)~"); //$NON-NLS-1$ - - //If the string is properly formatted, colours should be length 2 - //If it is not properly formatted, don't colour (just print) - if (coloursAndText.length != 2) { - for (int j = 0; j < coloursAndText.length; j++) { - viewer.append(coloursAndText[j]); - inLineOffset += coloursAndText[j].length(); - } - continue; - } - - //The first element in the array should contain the colours - String[] colours = coloursAndText[0].split(","); //$NON-NLS-1$ - if (colours.length < 3) continue; - - //The second element in the array should contain the text - viewer.append(coloursAndText[1]); - - //Create a colour based on the 3 integers (if there are any more integers, just ignore) - int R = new Integer(colours[0].replaceAll(" ", "")).intValue(); //$NON-NLS-1$ //$NON-NLS-2$ - int G = new Integer(colours[1].replaceAll(" ", "")).intValue(); //$NON-NLS-1$ //$NON-NLS-2$ - int B = new Integer(colours[2].replaceAll(" ", "")).intValue(); //$NON-NLS-1$ //$NON-NLS-2$ - - if (R > 255) R = 255; - if (G > 255) G = 255; - if (B > 255) B = 255; - - if (R < 0 ) R = 0; - if (G < 0 ) G = 0; - if (B < 0 ) B = 0; - - Color newColor = new Color(display, R, G, B); - - //Find the offset of the current line - lineOffset = viewer.getOffsetAtLine(viewer.getLineCount() - 1); - - //Create a new style that lasts no further than the length of the line - StyleRange newStyle = new StyleRange(lineOffset + inLineOffset, - coloursAndText[1].length(), - newColor, null); - styles.addElement(newStyle); - - inLineOffset+=coloursAndText[1].length(); - } - - viewer.append(NEW_LINE); - } - - //Create a new style range - StyleRange[] s = new StyleRange[styles.size()]; - styles.copyInto(s); - - int cnt = viewer.getCharCount(); - - //Using replaceStyleRanges with previousEnd, etc, effectively adds - //the StyleRange to the existing set of Style Ranges (so we don't - //waste time fudging with old style ranges that haven't changed) - viewer.replaceStyleRanges(previousEnd, cnt - previousEnd, s); - previousEnd = cnt; - - //Change focus and update - viewer.setTopIndex(viewer.getLineCount() - 1); - viewer.update(); - } - - public void println(String text) { - if (viewer != null && !viewer.isDisposed()) { - viewer.append(text); - viewer.setTopIndex(viewer.getLineCount() - 1); - viewer.update(); - } - } - - public void clearAll() { - if (viewer != null && !viewer.isDisposed()) { - previousEnd = 0; - viewer.setText(""); //$NON-NLS-1$ - viewer.update(); - } - } - - /** - * Testing convenience method to see what was printed - * - * @return viewer text - */ - public String getText() { - return viewer.getText(); - } - - - /** - * Populates the file menu - */ - public void createFileActions() { - //Opens from some location in your program - open_callgraph = new Action(Messages.getString("CallgraphView.7")){ //$NON-NLS-1$ - public void run(){ - FileDialog dialog = new FileDialog(new Shell(), SWT.DEFAULT); - String filePath = dialog.open(); - if (filePath != null){ - StapGraphParser new_parser = new StapGraphParser(); - new_parser.setFile(filePath); - new_parser.schedule(); - } - } - }; - - //Opens from the default location - open_default = new Action(Messages.getString("CallgraphView.11")){ //$NON-NLS-1$ - public void run(){ - StapGraphParser new_parser = new StapGraphParser(); - new_parser.schedule(); - } - }; - - - //Save callgraph.out - save_callgraph = new Action(Messages.getString("CallgraphView.8")){ //$NON-NLS-1$ - public void run(){ - Shell sh = new Shell(); - FileDialog dialog = new FileDialog(sh, SWT.SAVE); - String filePath = dialog.open(); - - if (filePath != null) { - parser.saveData(filePath); - } - } - }; - - } - - public void createHelpActions() { - help_version = new Action(Messages.getString("CallgraphView.13")) { //$NON-NLS-1$ - public void run() { - Runtime rt = Runtime.getRuntime(); - try { - Process pr = rt.exec("stap -V"); //$NON-NLS-1$ - BufferedReader buf = new BufferedReader(new InputStreamReader(pr - .getErrorStream())); - String line = ""; //$NON-NLS-1$ - String message = ""; //$NON-NLS-1$ - - while ((line = buf.readLine()) != null) { - message += line + NEW_LINE; //$NON-NLS-1$ - } - - try { - pr.waitFor(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - - Shell sh = new Shell(); - - MessageDialog.openInformation(sh, Messages.getString("CallgraphView.SystemTapVersionBox"), message); //$NON-NLS-1$ - - } catch (IOException e) { - e.printStackTrace(); - } - } - }; - - help_about = new Action(Messages.getString("CallgraphView.4")) { //$NON-NLS-1$ - public void run() { - Display disp = Display.getCurrent(); - if (disp == null){ - disp = Display.getDefault(); - } - - - Shell sh = new Shell(disp, SWT.MIN | SWT.MAX); - sh.setSize(425, 540); - GridLayout gl = new GridLayout(1, true); - sh.setLayout(gl); - - sh.setText(""); //$NON-NLS-1$ - - Image img = new Image(disp, PluginConstants.PLUGIN_LOCATION+"systemtap.png"); //$NON-NLS-1$ - Composite cmp = new Composite(sh, sh.getStyle()); - cmp.setLayout(gl); - GridData data = new GridData(415,100); - cmp.setLayoutData(data); - cmp.setBackgroundImage(img); - - Composite c = new Composite(sh, sh.getStyle()); - c.setLayout(gl); - GridData gd = new GridData(415,400); - c.setLayoutData(gd); - c.setLocation(0,300); - StyledText viewer = new StyledText(c, SWT.READ_ONLY | SWT.MULTI - | SWT.V_SCROLL | SWT.WRAP | SWT.BORDER); - - GridData viewerGD = new GridData(SWT.FILL, SWT.FILL, true, true); - viewer.setLayoutData(viewerGD); - Font font = new Font(sh.getDisplay(), "Monospace", 11, SWT.NORMAL); //$NON-NLS-1$ - viewer.setFont(font); - viewer.setText( - "" + //$NON-NLS-1$ - "" + //$NON-NLS-1$ - "" + //$NON-NLS-1$ - "" + //$NON-NLS-1$ - "" + //$NON-NLS-1$ - "" + //$NON-NLS-1$ - - "" + //$NON-NLS-1$ -// -// Messages.getString("LaunchAbout.9") + //$NON-NLS-1$ -// Messages.getString("LaunchAbout.10") + //$NON-NLS-1$ - - "" + //$NON-NLS-1$ - "" + //$NON-NLS-1$ - "" + //$NON-NLS-1$ - -// Messages.getString("LaunchAbout.14") + //$NON-NLS-1$ -// Messages.getString("LaunchAbout.15") + //$NON-NLS-1$ -// Messages.getString("LaunchAbout.16") + //$NON-NLS-1$ - - "" + //$NON-NLS-1$ - -// Messages.getString("LaunchAbout.18") + //$NON-NLS-1$ -// Messages.getString("LaunchAbout.19") + //$NON-NLS-1$ - - "" + //$NON-NLS-1$ - "" //$NON-NLS-1$ - ); - - - - sh.open(); - } - }; - } - - /** - * Populates the Errors menu - */ - public void createErrorActions() { - - error_errorLog = new Action(Messages.getString("CallgraphView.OpenLog")) { //$NON-NLS-1$ - public void run() { - boolean error = false; - File log = new File(PluginConstants.DEFAULT_OUTPUT + "Error.log"); //$NON-NLS-1$ - BufferedReader buff; - try { - buff = new BufferedReader(new FileReader(log)); - String logText = ""; //$NON-NLS-1$ - String line; - - while ((line = buff.readLine()) != null) { - logText+=line + PluginConstants.NEW_LINE; - } - - Shell sh = new Shell(SWT.BORDER | SWT.TITLE); - - sh.setText(Messages.getString("CallgraphView.15")); //$NON-NLS-1$ - sh.setLayout(new FillLayout()); - sh.setSize(600,600); - - StyledText txt = new StyledText(sh, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP | SWT.READ_ONLY); - - txt.setText(logText); - - sh.setText(Messages.getString("CallgraphView.21")); //$NON-NLS-1$ - - sh.open(); - txt.setTopIndex(txt.getLineCount()); - - - } catch (FileNotFoundException e) { - error = true; - } catch (IOException e) { - error = true; - } finally { - if (error) { - SystemTapUIErrorMessages mess = new SystemTapUIErrorMessages( - Messages.getString("CallgraphView.ErrorMessageName"), //$NON-NLS-1$ - Messages.getString("CallgraphView.ErrorMessageTitle"), //$NON-NLS-1$ - Messages.getString("CallgraphView.ErrorMessageBody") + //$NON-NLS-1$ - Messages.getString("CallgraphView.ErrorMessageBody2")); //$NON-NLS-1$ - mess.schedule(); - } - } - - } - }; - - - error_deleteError = new Action(Messages.getString("CallgraphView.ClearLog")) { //$NON-NLS-1$ - public void run() { - if (!MessageDialog.openConfirm(new Shell(), Messages.getString("CallgraphView.DeleteLogsTitle"), //$NON-NLS-1$ - Messages.getString("CallgraphView.DeleteLogsMessage") + //$NON-NLS-1$ - Messages.getString("CallgraphView.DeleteLogsMessage2"))) //$NON-NLS-1$ - return; - - SystemTapErrorHandler.delete(); - } - }; - - - } - - public void createViewActions() { - //Set drawmode to tree view - view_treeview = new Action(Messages.getString("CallgraphView.16")){ //$NON-NLS-1$ - public void run() { - graph.draw(StapGraph.CONSTANT_DRAWMODE_TREE, graph.getAnimationMode(), - graph.getRootVisibleNodeNumber()); - graph.scrollTo(graph.getNode(graph.getRootVisibleNodeNumber()).getLocation().x - - graph.getBounds().width / 2, graph.getNode( - graph.getRootVisibleNodeNumber()).getLocation().y); - } - }; - ImageDescriptor treeImage = ImageDescriptor.createFromImage( - new Image(Display.getCurrent(), CallGraphConstants.PLUGIN_LOCATION + "icons/tree_view.gif")); //$NON-NLS-1$ - view_treeview.setImageDescriptor(treeImage); - - - //Set drawmode to radial view - view_radialview = new Action(Messages.getString("CallgraphView.17")){ //$NON-NLS-1$ - public void run(){ - graph.draw(StapGraph.CONSTANT_DRAWMODE_RADIAL, graph.getAnimationMode(), - graph.getRootVisibleNodeNumber()); - - } - }; - ImageDescriptor d = ImageDescriptor.createFromImage( - new Image(Display.getCurrent(), - CallGraphConstants.PLUGIN_LOCATION + "/icons/radial_view.gif")); //$NON-NLS-1$ - view_radialview.setImageDescriptor(d); - - - //Set drawmode to aggregate view - view_aggregateview = new Action(Messages.getString("CallgraphView.18")){ //$NON-NLS-1$ - public void run(){ - graph.draw(StapGraph.CONSTANT_DRAWMODE_AGGREGATE, graph.getAnimationMode(), - graph.getRootVisibleNodeNumber()); - - } - }; - ImageDescriptor aggregateImage = ImageDescriptor.createFromImage( - new Image(Display.getCurrent(), - CallGraphConstants.PLUGIN_LOCATION + "/icons/view_aggregateview.gif")); //$NON-NLS-1$ - view_aggregateview.setImageDescriptor(aggregateImage); - - - //Set drawmode to box view - view_boxview = new Action(Messages.getString("CallgraphView.19")){ //$NON-NLS-1$ - public void run(){ - graph.draw(StapGraph.CONSTANT_DRAWMODE_BOX, graph.getAnimationMode(), - graph.getRootVisibleNodeNumber()); - } - }; - ImageDescriptor boxImage = ImageDescriptor.createFromImage( - new Image(Display.getCurrent(), - CallGraphConstants.PLUGIN_LOCATION + "/icons/showchild_mode.gif")); //$NON-NLS-1$ - view_boxview.setImageDescriptor(boxImage); - - - setView_refresh(new Action(Messages.getString("CallgraphView.Reset")){ //$NON-NLS-1$ - public void run(){ - graph.reset(); - } - }); - ImageDescriptor refreshImage = ImageDescriptor.createFromImage( - new Image(Display.getCurrent(), - CallGraphConstants.PLUGIN_LOCATION + "/icons/nav_refresh.gif")); //$NON-NLS-1$ - getView_refresh().setImageDescriptor(refreshImage); - - - } - - - /** - * Populates Animate menu. - */ - public void createAnimateActions() { - //Set animation mode to slow - animation_slow = new Action(Messages.getString("CallgraphView.20"), Action.AS_RADIO_BUTTON){ //$NON-NLS-1$ - public void run(){ - graph.setAnimationMode(StapGraph.CONSTANT_ANIMATION_SLOW); - this.setChecked(true); - animation_slow.setChecked(true); - animation_fast.setChecked(false); - } - }; - - animation_slow.setChecked(true); - - //Set animation mode to fast - animation_fast = new Action(Messages.getString("CallgraphView.22"), Action.AS_RADIO_BUTTON){ //$NON-NLS-1$ - public void run(){ - graph.setAnimationMode(StapGraph.CONSTANT_ANIMATION_FASTEST); - animation_slow.setChecked(false); - animation_fast.setChecked(true); - } - }; - - //Toggle collapse mode - mode_collapsednodes = new Action(Messages.getString("CallgraphView.24"), Action.AS_CHECK_BOX){ //$NON-NLS-1$ - public void run(){ - - if (graph.isCollapseMode()) { - graph.setCollapseMode(false); - graph.draw(graph.getRootVisibleNodeNumber()); - } - else { - graph.setCollapseMode(true); - graph.draw(graph.getRootVisibleNodeNumber()); - } - } - }; - - ImageDescriptor newImage = ImageDescriptor.createFromImage( - new Image(Display.getCurrent(), CallGraphConstants.PLUGIN_LOCATION + "icons/mode_collapsednodes.gif")); //$NON-NLS-1$ - mode_collapsednodes.setImageDescriptor(newImage); - - limits = new Action(Messages.getString("CallgraphView.SetLimits"), Action.AS_PUSH_BUTTON) { //$NON-NLS-1$ - private Spinner limit; - private Spinner buffer; - private Shell sh; - public void run() { - sh = new Shell(); - sh.setLayout(new GridLayout()); - sh.setSize(150, 200); - Label limitLabel = new Label(sh, SWT.NONE); - limitLabel.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, true, false)); - limitLabel.setText(Messages.getString("CallgraphView.MaxNodes")); //$NON-NLS-1$ - limit = new Spinner(sh, SWT.BORDER); - limit.setMaximum(5000); - limit.setSelection(graph.getMaxNodes()); - limit.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, true, false)); - - Label bufferLabel = new Label(sh, SWT.NONE); - bufferLabel.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, true, false)); - bufferLabel.setText(Messages.getString("CallgraphView.MaxDepth")); //$NON-NLS-1$ - buffer = new Spinner(sh, SWT.BORDER); - buffer.setMaximum(5000); - buffer.setSelection(graph.getLevelBuffer()); - buffer.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, true, false)); - - Button set_limit = new Button(sh, SWT.PUSH); - set_limit.setText(Messages.getString("CallgraphView.SetValues")); //$NON-NLS-1$ - set_limit.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, true, false)); - set_limit.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - boolean redraw = false; - if (limit.getSelection() > 0 && buffer.getSelection() > 0) { - graph.setMaxNodes(limit.getSelection()); - graph.setLevelBuffer(buffer.getSelection()); - - if (graph.changeLevelLimits(graph.getLevelOfNode(graph.getRootVisibleNodeNumber()))) { - SystemTapUIErrorMessages mess = new SystemTapUIErrorMessages( - Messages.getString("CallgraphView.BufferTooHigh"), Messages.getString("CallgraphView.BufferTooHigh"), //$NON-NLS-1$ //$NON-NLS-2$ - Messages.getString("CallgraphView.BufferMessage1") + //$NON-NLS-1$ - Messages.getString("CallgraphView.BufferMessage2") + //$NON-NLS-1$ - Messages.getString("CallgraphView.BufferMessage3") + //$NON-NLS-1$ - Messages.getString("CallgraphView.BufferMessage4") + graph.getLevelBuffer() + //$NON-NLS-1$ - Messages.getString("CallgraphView.BufferMessage5") + PluginConstants.NEW_LINE + PluginConstants.NEW_LINE + //$NON-NLS-1$ - Messages.getString("CallgraphView.BufferMessage6") + //$NON-NLS-1$ - Messages.getString("CallgraphView.BufferMessage7")); //$NON-NLS-1$ - mess.schedule(); - } - - redraw = true; - } - sh.dispose(); - - if (redraw) - graph.draw(); - } - - }); - - - sh.open(); - } - }; - - } - -/** - * Creates actions by calling the relevant functions - */ - public void createActions() { - createFileActions(); - createHelpActions(); - createErrorActions(); - createViewActions(); - createAnimateActions(); - createMarkerActions(); - createMovementActions(); -// createButtonActions(); - - mode_collapsednodes.setChecked(true); - - } - - public void createMovementActions() { - goto_next = new Action(Messages.getString("CallgraphView.Next")) { //$NON-NLS-1$ - public void run() { - if (graph.isCollapseMode()) { - graph.setCollapseMode(false); - } - int toDraw = graph.getNextCalledNode(graph.getRootVisibleNodeNumber()); - if (toDraw != -1) - graph.draw(toDraw); - } - }; - - goto_previous = new Action(Messages.getString("CallgraphView.Previous")) { //$NON-NLS-1$ - public void run() { - if (graph.isCollapseMode()) { - graph.setCollapseMode(false); - } - int toDraw = graph.getPreviousCalledNode(graph.getRootVisibleNodeNumber()); - if (toDraw != -1) - graph.draw(toDraw); - } - }; - - goto_last = new Action(Messages.getString("CallgraphView.Last")) { //$NON-NLS-1$ - public void run() { - if (graph.isCollapseMode()) - graph.setCollapseMode(false); - graph.draw(graph.getLastFunctionCalled()); - } - }; - } - - public void createMarkerActions() { - markers_next = new Action(Messages.getString("CallgraphView.nextMarker")) { //$NON-NLS-1$ - public void run() { - graph.draw(graph.getNextMarkedNode()); - } - }; - - markers_previous = new Action(Messages.getString("CallgraphView.previousMarker")) { //$NON-NLS-1$ - public void run() { - graph.draw(graph.getPreviousMarkedNode()); - } - }; - } - - - public static void disposeGraph() { - if (graphComp != null && !graphComp.isDisposed()) - graphComp.dispose(); - if (treeComp != null && !treeComp.isDisposed()) - treeComp.dispose(); - if (viewer!= null && !viewer.isDisposed()) { - String tmp = viewer.getText(); - StyleRange[] tempRange = viewer.getStyleRanges(); - viewer.dispose(); - createViewer(masterComposite); - viewer.setText(tmp); - viewer.setStyleRanges(tempRange); - } - CallgraphView.setGraphOptions(false); - //Force a redraw (.redraw() .update() not working) - CallgraphView.maximizeOrRefresh(false); - } - - public static Action getAnimation_slow() { - return animation_slow; - } - - public static void setAnimation_slow(Action animation_slow) { - CallgraphView.animation_slow = animation_slow; - } - - public static Action getAnimation_fast() { - return animation_fast; - } - - public static void setAnimation_fast(Action animation_fast) { - CallgraphView.animation_fast = animation_fast; - } - - public static IMenuManager getAnimation() { - return animation; - } - - public static void setAnimation(IMenuManager animation) { - CallgraphView.animation = animation; - } - - public static Action getMode_collapsednodes() { - return mode_collapsednodes; - } - - public static void setMode_collapsednodes(Action mode_collapsednodes) { - CallgraphView.mode_collapsednodes = mode_collapsednodes; - } - - public static void setView_refresh(Action view_refresh) { - CallgraphView.view_refresh = view_refresh; - } - - public static Action getView_refresh() { - return view_refresh; - } - - public static Action getGoto_next() { - return goto_next; - } - - public static void setGoto_next(Action gotoNext) { - goto_next = gotoNext; - } - - public static Action getGoto_previous() { - return goto_previous; - } - - public static void setGoto_parent(Action gotoParent) { - goto_previous = gotoParent; - } - - public static Action getGoto_last() { - return goto_last; - } - - public static void setGoto_last(Action gotoLast) { - goto_last = gotoLast; - } - - public static Action getOpen_callgraph() { - return open_callgraph; - } - - public static void setOpen_callgraph(Action openCallgraph) { - open_callgraph = openCallgraph; - } - - public static Action getSave_callgraph() { - return save_callgraph; - } - - public static void setSave_callgraph(Action saveCallgraph) { - save_callgraph = saveCallgraph; - } - - public static Action getError_errorLog() { - return error_errorLog; - } - - public static void setError_errorLog(Action errorErrorLog) { - error_errorLog = errorErrorLog; - } - - public static Action getError_deleteError() { - return error_deleteError; - } - - public static void setError_deleteError(Action errorDeleteError) { - error_deleteError = errorDeleteError; - } - - public static Action getView_treeview() { - return view_treeview; - } - - public static void setView_treeview(Action viewTreeview) { - view_treeview = viewTreeview; - } - - public static Action getView_radialview() { - return view_radialview; - } - - public static void setView_radialview(Action viewRadialview) { - view_radialview = viewRadialview; - } - - public static Action getView_aggregateview() { - return view_aggregateview; - } - - public static void setView_aggregateview(Action viewAggregateview) { - view_aggregateview = viewAggregateview; - } - - public static Action getView_boxview() { - return view_boxview; - } - - public static void setView_boxview(Action viewBoxview) { - view_boxview = viewBoxview; - } - - public static Action getHelp_version() { - return help_version; - } - - public static void setHelp_version(Action helpVersion) { - help_version = helpVersion; - } - - public static void setGoto_previous(Action gotoPrevious) { - goto_previous = gotoPrevious; - } - - public static StapGraph getGraph() { - return graph; - } -} - -/** - * The code graveyard: Where snippets go to die - */ -//StyleRange[] existingRange = viewer.getStyleRanges(); -// -//StyleRange[] s = new StyleRange[styles.size()]; -//StyleRange[] s2 = new StyleRange[styles.size() + existingRange.length]; -//styles.copyInto(s); -// -//for (int i = 0; i < existingRange.length; i++) -// s2[i] = existingRange[i]; -// -//for (int i = 0; i < styles.size(); i ++) -// s2[i+existingRange.length] = s[i]; diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/GraphUIJob.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/GraphUIJob.java deleted file mode 100644 index 41c6e0e495..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/GraphUIJob.java +++ /dev/null @@ -1,226 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.systemtap.local.callgraph; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.draw2d.LightweightSystem; -import org.eclipse.draw2d.parts.ScrollableThumbnail; -import org.eclipse.linuxtools.systemtap.local.callgraph.graphlisteners.AutoScrollSelectionListener; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.progress.UIJob; - -/** - * Initializes and runs a StapGraph and TreeViewer within the SystemTap View - * - * @author chwang - * - */ -public class GraphUIJob extends UIJob{ - private StapGraph g; - private StapGraphParser parser; - private static int treeSize = 200; - - - public StapGraph getGraph() { - return g; - } - - public GraphUIJob(String name, StapGraphParser parser) { - super(name); - //CREATE THE SHELL - this.parser = parser; - } - - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - - Display disp = Display.getCurrent(); - if (disp == null) - disp = Display.getDefault(); - - - //-------------Initialize shell, menu - treeSize = 200; - - - //OPEN UP THE SYSTEMTAPVIEW IF IT IS NOT ALREADY OPEN - CallgraphView.forceDisplay(); - - Composite treeComp = CallgraphView.makeTreeComp(treeSize); - Composite graphComp = CallgraphView.makeGraphComp(); - graphComp.setBackgroundMode(SWT.INHERIT_FORCE); - - - //Create papa canvas - Canvas papaCanvas = new Canvas(graphComp, SWT.BORDER); - GridLayout papaLayout = new GridLayout(1, true); - papaLayout.horizontalSpacing=0; - papaLayout.verticalSpacing=0; - papaLayout.marginHeight=0; - papaLayout.marginWidth=0; - papaCanvas.setLayout(papaLayout); - GridData papaGD = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false); - papaGD.widthHint=160; - papaCanvas.setLayoutData(papaGD); - - - //Add first button - Image image = new Image(disp, CallGraphConstants.PLUGIN_LOCATION+"icons/up.gif"); //$NON-NLS-1$ - Button up = new Button(papaCanvas, SWT.PUSH); - GridData buttonData = new GridData(SWT.CENTER, SWT.CENTER, true, false); - buttonData.widthHint = 150; - buttonData.heightHint = 20; - up.setData(buttonData); - up.setImage(image); - - - //Add thumb canvas - Canvas thumbCanvas = new Canvas(papaCanvas, SWT.NONE); - - - //Add second button - image = new Image(disp, CallGraphConstants.PLUGIN_LOCATION+"icons/down.gif"); //$NON-NLS-1$ - Button down = new Button(papaCanvas, SWT.PUSH); - buttonData = new GridData(SWT.CENTER, SWT.CENTER, true, false); - buttonData.widthHint = 150; - buttonData.heightHint = 0; - down.setData(buttonData); - down.setImage(image); - - - //Initialize graph - g = new StapGraph(graphComp, SWT.BORDER, treeComp, papaCanvas); - g.setLayoutData(new GridData(this.getDisplay().getPrimaryMonitor().getBounds().width - 200,this.getDisplay().getPrimaryMonitor().getBounds().height - 200)); - - up.addSelectionListener(new AutoScrollSelectionListener( - AutoScrollSelectionListener.AutoScroll_up, g)); - down.addSelectionListener(new AutoScrollSelectionListener( - AutoScrollSelectionListener.AutoScroll_down, g)); - - - //Initialize thumbnail - GridData thumbGD = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false); - thumbGD.widthHint=160; - thumbCanvas.setLayoutData(thumbGD); - LightweightSystem lws = new LightweightSystem(thumbCanvas); - ScrollableThumbnail thumb = new ScrollableThumbnail(g.getViewport()); - thumb.setSource(g.getContents()); - lws.setContents(thumb); - - //-------------Load graph data - g.loadData(SWT.NONE, 0, StapGraph.CONSTANT_TOP_NODE_NAME, 1, 1, -1, false, ""); //$NON-NLS-1$ - boolean marked = false; - String msg = ""; //$NON-NLS-1$ - - - for (int id_parent : parser.serialMap.keySet()) { - if (g.getData(id_parent) == null) { - if (parser.markedMap.get(id_parent) != null) { - marked = true; - msg = parser.markedMap.get(id_parent); - } - g.loadData(SWT.NONE, id_parent, parser.serialMap.get(id_parent), parser.timeMap.get(id_parent), - 1, 0, marked, msg); - } - - for (int id_child : parser.outNeighbours.get(id_parent)) { - - if (monitor.isCanceled()) { - return Status.CANCEL_STATUS; - } - - marked = false; - msg = ""; //$NON-NLS-1$ - if (parser.markedMap.get(id_child) != null) { - marked = true; - msg = parser.markedMap.get(id_child); - } - if (id_child != -1) { - if (parser.timeMap.get(id_child) == null){ - g.loadData(SWT.NONE, id_child, parser.serialMap - .get(id_child), parser.timeMap.get(0), - 1, id_parent, marked,msg); - }else{ - g.loadData(SWT.NONE, id_child, parser.serialMap - .get(id_child), parser.timeMap.get(id_child), - 1, id_parent, marked,msg); - } - } - } - - } - - - g.aggregateCount = parser.countMap; - g.aggregateTime = parser.cumulativeTimeMap; - - //Set total time - g.setTotalTime(parser.totalTime); - - //-------------Finish initializations - //Generate data for collapsed nodes - g.recursivelyCollapseAllChildrenOfNode(g.getTopNode()); - if (monitor.isCanceled()) { - return Status.CANCEL_STATUS; - } - g.initializeTree(); - g.setLastFunctionCalled(parser.lastFunctionCalled); - - - if (monitor.isCanceled()) { - return Status.CANCEL_STATUS; - } - g.setFocus(); - g.setCallOrderList(parser.callOrderList); - - g.setProject(parser.project); - - CallgraphView.setValues(graphComp, treeComp, g, parser); - CallgraphView.createPartControl(); - g.draw(StapGraph.CONSTANT_DRAWMODE_RADIAL, StapGraph.CONSTANT_ANIMATION_SLOW, - g.getFirstUsefulNode()); - - return Status.OK_STATUS; - } - - - /** - * Returns number of StapData objects created - * @return - */ - public int getNumberOfDataNodes() { - return g.getDataMapSize(); - } - - - /** - * For easier JUnit testing only. Allows public access to run method without scheduling an extra job. - * - * @param m - * @return - */ - public IStatus testRun(IProgressMonitor m) { - return runInUIThread(m); - } - - -} - diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/Messages.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/Messages.java deleted file mode 100644 index cdadf95b69..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/Messages.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.systemtap.local.callgraph; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class Messages { - private static final String BUNDLE_NAME = "org.eclipse.linuxtools.systemtap.local.callgraph.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); - - private Messages() { - } - - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/StapData.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/StapData.java deleted file mode 100644 index 1657272e78..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/StapData.java +++ /dev/null @@ -1,228 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.systemtap.local.callgraph; - -import java.util.ArrayList; -import java.util.List; -import java.util.TreeMap; - -/** - * Contains information to populate StapNodes with - * - */ -public class StapData { - public boolean expandable; - public int id; //id of the StapNode - public long time; - public int called; - public int caller; - public int style; - public int levelOfRecursion; - public String name; - public boolean noCaller; - public List<Integer> callees; - public List<Integer> collapsedCallees; - private StapGraph graph; - public boolean hasCollapsedChildren; - public boolean isCollapsed; - public boolean onlyChildWithThisName; - private boolean partOfCollapsedNode; - public int collapsedCaller; - private boolean marked; - public String markedMessage; - - public boolean isPartOfCollapsedNode() { - return partOfCollapsedNode; - } - - - - - /** - * Initialize StapData object - * - * @param graphModel - * @param style - * @param txt - * @param time - * @param called - * @param currentID - * @param caller - * @param isMarked - * @param message - */ - public StapData(StapGraph graphModel, int style, String txt, - long time, int called, int currentID, int caller, boolean isMarked, String message) { - this.time = time; - this.style = style; - this.called = called; - this.expandable = false; - callees = new ArrayList<Integer>(); - collapsedCallees = new ArrayList<Integer>(); - this.id = currentID; - this.name = txt; - this.graph = graphModel; - this.hasCollapsedChildren = false; - this.isCollapsed = false; - this.onlyChildWithThisName = false; - this.partOfCollapsedNode= false; - this.collapsedCaller = -1; - this.caller = caller; - this.levelOfRecursion = 0; - this.marked = isMarked; - this.markedMessage = message; - - - //Add this data to the caller's list of IDs - if (this.caller != -1) { - if (graphModel.getData(this.caller) != null) { - graphModel.getData(this.caller).addCallee(this.id, this.time); - this.levelOfRecursion = graphModel.getData(this.caller).levelOfRecursion + 1; - } - } - - //---------------Recursion management - //Insert new level if necessary - if (graphModel.levels.get(levelOfRecursion) == null) - graphModel.levels.put(levelOfRecursion, new ArrayList<Integer>()); - graphModel.levels.get(levelOfRecursion).add(this.id); - - //Keep track of the lowest level of recursion - if (levelOfRecursion > graphModel.getLowestLevelOfNodesAdded()) - graphModel.setLowestLevelOfNodesAdded(levelOfRecursion); - - - this.noCaller = (caller == -1) ? true : false; - } - - - /** - * Add the given id to my list of children/callees. Sort based on time - * - * @param id - * @return - */ - public int addCallee(int id, long time) { - - //TODO: This is phenomenally inefficient. We should just add them all - //then call a sort once instead of doing some crazy n! insertion :P - - //Insert id based on its time - int size = callees.size(); - - if (size ==0) { - callees.add(id); - return callees.size(); - } - int position = search(time); - - if (position == -1) callees.add(id); - else callees.add(position, id); - - return callees.size(); - } - - - /** - * Returns the proper position in callees list for the node with the given time. - * Afterwards an insert at the return value will put the node in the right spot. - * @param time - * @return location in callees - */ - private int search(long time) { - if (time > graph.getData(callees.get(0)).time) - return 0; - - for (int i = 1; i < callees.size(); i++) { - if (time < graph.getData(callees.get(i -1)).time && - time > graph.getData(callees.get(i)).time) - return i; - } - - return -1; - } - - - /** - * Creates a node in the given graphModel using this stapData - * @param graphModel - * @return the generated stapNode - */ - - public StapNode makeNode(StapGraph graphModel) { - return new StapNode(graphModel, style, this); - } - - /** - * Sort the list of callees according to time - */ - public void sortByTime(){ - TreeMap<Long,ArrayList<StapData>> tempList = new TreeMap<Long,ArrayList<StapData>>(); - //INDEX ALL THE STAPDATA INTO AN ARRAY AT THE CALCULATED INDEX - //SCATTERED INDICES : 0,1,...,5,..,10 - for (int val : collapsedCallees){ - if (tempList.get(graph.getData(val).time) == null){ - tempList.put(graph.getData(val).time, new ArrayList<StapData>()); - } - - tempList.get(graph.getData(val).time).add(graph.getData(val)); - } - - collapsedCallees.clear(); - int count = 0; - // ANOTHER PASS THROUGH TO INDEX CONTINUOUSLY 0,1,2,.. - for (long i : tempList.descendingKeySet()) { - for (StapData j : tempList.get(i)){ - collapsedCallees.add(count, j.id); - } - count++; - } - - } - - /** - * Indicate that this StapData is part of a collapsed node (will not be drawn in - * uncollapsed mode) - * @param partOfCollapsedNode - */ - public void setPartOfCollapsedNode(boolean partOfCollapsedNode) { - this.partOfCollapsedNode = partOfCollapsedNode; - } - - /** - * Indicate that this StapData was marked by the user - */ - public void setMarked() { - marked = true; - } - - /** - * Check if this StapData is marked - * @return - */ - public boolean isMarked() { - return marked; - } - - - - - public boolean isOnlyChildWithThisName() { - return onlyChildWithThisName; - } - - - - - public void setOnlyChildWithThisName(boolean onlyChildWithThisName) { - this.onlyChildWithThisName = onlyChildWithThisName; - } -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/StapGraph.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/StapGraph.java deleted file mode 100644 index c0bfe0cd16..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/StapGraph.java +++ /dev/null @@ -1,1832 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.systemtap.local.callgraph; - -import java.text.NumberFormat; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.TreeSet; -import java.util.Map.Entry; - -import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.draw2d.Animation; -import org.eclipse.draw2d.Label; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.linuxtools.systemtap.local.callgraph.graphlisteners.StapGraphKeyListener; -import org.eclipse.linuxtools.systemtap.local.callgraph.graphlisteners.StapGraphMouseListener; -import org.eclipse.linuxtools.systemtap.local.callgraph.graphlisteners.StapGraphMouseWheelListener; -import org.eclipse.linuxtools.systemtap.local.callgraph.treeviewer.StapTreeContentProvider; -import org.eclipse.linuxtools.systemtap.local.callgraph.treeviewer.StapTreeDoubleClickListener; -import org.eclipse.linuxtools.systemtap.local.callgraph.treeviewer.StapTreeLabelProvider; -import org.eclipse.linuxtools.systemtap.local.callgraph.treeviewer.StapTreeListener; -import org.eclipse.linuxtools.systemtap.local.core.MP; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.zest.core.widgets.Graph; -import org.eclipse.zest.core.widgets.GraphNode; -import org.eclipse.zest.layouts.LayoutStyles; - - -public class StapGraph extends Graph { - - public static final String CONSTANT_TOP_NODE_NAME = Messages.getString("StapGraph.0"); //$NON-NLS-1$ - public static final int CONSTANT_HORIZONTAL_SPACING = 50; - public static final int CONSTANT_DRAWMODE_BOX = 0; - public static final int CONSTANT_DRAWMODE_RADIAL = 1; - public static final int CONSTANT_DRAWMODE_TREE = 2; - public static final int CONSTANT_DRAWMODE_AGGREGATE = 3; - public static final int CONSTANT_ANIMATION_SLOW = 1; - public static final int CONSTANT_ANIMATION_FASTER = 2; - public static final int CONSTANT_ANIMATION_FASTEST = 3; - public static final int CONSTANT_MAX_NUMBER_OF_SIBLINGS = 3; - public static final int CONSTANT_MAX_NUMBER_OF_RADIAL_SIBLINGS = 15; - public static final int CONSTANT_VERTICAL_INCREMENT = 50; - public static final int CONSTANT_HORIZONTAL_SPACING_FOR_BOX = 150; - public static final Color CONSTANT_HAS_PARENT = new Color(Display.getCurrent(), 240, 200, - 200); - public static final Color CONSTANT_HAS_CHILDREN = new Color(Display.getCurrent(), 200, - 250, 200); - public static final Color CONSTANT_MARKED = new Color(Display.getCurrent(), 210, 112, 214); - private int ANIMATION_TIME = 500; - //Draw level management - private int topLevelToDraw; - private int bottomLevelToDraw; - private int topLevelOnScreen; - public static int levelBuffer = 30; - private static int maxNodes = 150; - - - private int lowestLevelOfNodesAdded; - public HashMap<Integer, List<Integer>> levels; //Level number, list of node ids - - - //Node management - private int idOfLastNode; - private HashMap<Integer, StapNode> nodeMap; // HashMap of current nodes - private HashMap<Integer, StapData> nodeDataMap; // HashMap of all data - - public List<GraphNode> aggregateNodes; - public HashMap<String, Long> aggregateTime; - public HashMap<String, Integer> aggregateCount; - private HashMap <Integer, Integer> collapsedLevelSize; - public List<Integer> markedNodes; - public List<Integer> markedCollapsedNodes; - - //Modes - private boolean collapse_mode; - private int draw_mode; - private int animation_mode; - - //Time - private long totalTime; - - //The current center/top of the nodes list - private int rootVisibleNodeNumber; - - //Special cases - private boolean killInvalidFunctions; //Toggle hiding of invalid functions - - //Tree viewer - private static TreeViewer treeViewer; - private Composite treeComp; - private static IDoubleClickListener treeDoubleListener; - public HashMap<Integer, Integer> currentPositionInLevel; - //(level, next horizontal position to place a node) - - //For cycling through marked nodes - private int nextMarkedNode; - - //Zooming factor - public double scale; - - private int counter; //All purpose counting variable - - - private ArrayList<Integer> callOrderList; - private int lastFunctionCalled; - private Canvas thumbCanvas; - - - private ICProject project; - - private int treeLevelFromRoot; - public StapGraphMouseListener getMouseListener() { - return mListener; - } - - - - public StapGraphMouseWheelListener getMouseWheelListener() { - return mwListener; - } - - - - public StapGraphKeyListener getKeyListener() { - return kListener; - } - - - - private StapGraphMouseListener mListener; - private StapGraphMouseWheelListener mwListener; - private StapGraphKeyListener kListener; - - public StapGraph(Composite parent, int style, Composite treeComp, Canvas tCanvas) { - super(parent, style); - - //-------------Initialize variables - thumbCanvas = tCanvas; - nodeMap = new HashMap<Integer, StapNode>(); - levels = new HashMap<Integer, List<Integer>>(); - nodeDataMap = new HashMap<Integer, StapData>(); - aggregateTime = new HashMap<String, Long>(); - aggregateCount = new HashMap<String, Integer>(); - currentPositionInLevel = new HashMap<Integer, Integer>(); - collapsedLevelSize = new HashMap<Integer, Integer>(); - markedNodes = new ArrayList<Integer>(); - markedCollapsedNodes = new ArrayList<Integer>(); - animation_mode = 1; - idOfLastNode = 0; - rootVisibleNodeNumber=0; - totalTime = 0; - collapse_mode = false; - killInvalidFunctions = true; - nextMarkedNode = -1; - scale = 1; - treeLevelFromRoot = 0; - - this.treeComp = treeComp; - if (treeViewer == null || treeViewer.getControl().isDisposed()) { - //Only create once - treeViewer = new TreeViewer(this.treeComp); - StapTreeListener stl = new StapTreeListener(treeViewer.getTree().getHorizontalBar()); - treeViewer.addTreeListener(stl); - } - - //-------------Add listeners - mListener = new StapGraphMouseListener(this); - kListener = new StapGraphKeyListener(this); - mwListener = new StapGraphMouseWheelListener(this); - this.addMouseListener(mListener); - this.addKeyListener(kListener); - this.addMouseWheelListener(mwListener); - - } - - - - /** - * Initialize the treeviewer with data from the graph - */ - public void initializeTree() { - if (treeViewer.getContentProvider() == null) { - StapTreeContentProvider scp = new StapTreeContentProvider(); - treeViewer.setContentProvider(scp); - } - - ((StapTreeContentProvider) treeViewer.getContentProvider()).setGraph(this); - - if (treeViewer.getLabelProvider() != null) - treeViewer.getLabelProvider().dispose(); - StapTreeLabelProvider prov = new StapTreeLabelProvider(); - treeViewer.setLabelProvider(prov); - - if (treeDoubleListener != null) { - treeViewer.removeDoubleClickListener(treeDoubleListener); - } - treeDoubleListener = new StapTreeDoubleClickListener(treeViewer, this); - treeViewer.addDoubleClickListener(treeDoubleListener); - - treeViewer.setInput(getData(getTopNode())); - treeViewer.refresh(); - } - - - /** - * Create a new StapData object with the given parameters - * - * @param style - * @param id - * @param txt - * @param time - * @param called - * @param caller - * @return - */ - public int loadData(int style, int id, String txt, long time, int called, - int caller, boolean isMarked, String message) { - //-------------Invalid function catching - // Catches some random C/C++ directive functions - if (id < 10 && killInvalidFunctions) { - if (txt.contains(")")) { //$NON-NLS-1$ - return -1; - } else if (txt.contains(".")) { //$NON-NLS-1$ - return -1; - } else if (txt.contains("\"")) { //$NON-NLS-1$ - return -1; - } - } - - //-------------Add node to appropriate map/list - StapData n = new StapData(this, style, txt, time, called, id, caller, isMarked, message); - if (isMarked) - markedNodes.add(id); - nodeDataMap.put(id, n); - - // Make no assumptions about the order that data is input - if (id > idOfLastNode) - idOfLastNode = id; - return id; - } - - /* - * Fully functional draw functions - * - * -Radial - * -Tree - */ - - /** - * Draws a 2-node-layer circle - * Draws all nodes in place. - * @param centerNode - */ - public void drawRadial(int centerNode) { - int radius = Math.min(this.getBounds().width, - this.getBounds().height) - / 2 - CONSTANT_VERTICAL_INCREMENT; - - rootVisibleNodeNumber = centerNode; - if (nodeMap.get(centerNode) == null) { - nodeMap.put(centerNode, getNodeData(centerNode).makeNode(this)); - } - - // Draw node in center - StapNode n = nodeMap.get(centerNode); - int x = this.getBounds().width / 2 - n.getSize().width/2; - int y = this.getBounds().height / 2 - n.getSize().height; - n.setLocation(x, y); - - if (getData(centerNode).isMarked()) - nodeMap.get(centerNode).setBackgroundColor(CONSTANT_MARKED); - radialHelper(centerNode, x, y, radius, 0); - } - - /** - * Helps animation of radial draw. Can be replaced by a draw and moveAll. - * - * @param centerNode - */ - public void preDrawRadial(int centerNode) { - rootVisibleNodeNumber = centerNode; - - if (nodeMap.get(centerNode) == null) { - nodeMap.put(centerNode, getNodeData(centerNode).makeNode(this)); - StapNode n = nodeMap.get(centerNode); - n.setLocation(this.getBounds().width / 2, this.getShell() - .getSize().y / 2); - } - - //Pass coordinates of the node to radialHelper - StapNode n = nodeMap.get(centerNode); - int x = n.getLocation().x; - int y = n.getLocation().y; - radialHelper(centerNode, x, y, 0, 0); - } - - /** - * Completes radial-mode draws - * - * @param id - * @param x - * @param y - * @param radius - * @param startFromChild - */ - public void radialHelper(int id, int x, int y, int radius, int startFromChild) { - //-------------Draw parent node - // Draw caller node right beside this one, in a different color - int callerID = nodeDataMap.get(id).caller; - if (callerID != -1) { - if (getNode(callerID) == null) { - nodeMap.put(callerID, getNodeData(callerID).makeNode(this)); - } - getNode(callerID).setBackgroundColor(CONSTANT_HAS_PARENT); - getNode(callerID).setLocation(x + radius / 5, y - radius / 5); - if (getNode(id).connection == null) { - getNode(id).makeConnection(SWT.NONE, getNode(callerID), getData(id).called); - } - - if (getData(callerID).isMarked()) - nodeMap.get(callerID).setBackgroundColor(CONSTANT_MARKED); - } - - - //-------------Draw children nodes - List<Integer> nodeList; - if (!collapse_mode) { - nodeList = nodeDataMap.get(id).callees; - } - else { - nodeList = nodeDataMap.get(id).collapsedCallees; - } - - int numberOfNodes; - - if (nodeList.size() >= CONSTANT_MAX_NUMBER_OF_RADIAL_SIBLINGS ) { - numberOfNodes = CONSTANT_MAX_NUMBER_OF_RADIAL_SIBLINGS; - } - else - numberOfNodes = nodeList.size(); - - - double angle; - if (numberOfNodes > 5) - angle = 2 * Math.PI / numberOfNodes; - else - angle = 2 * Math.PI / CONSTANT_MAX_NUMBER_OF_RADIAL_SIBLINGS; - - int i = 0; - - for (i = 0; i < numberOfNodes; i++) { - - - int subID = nodeList.get(i); - int yOffset = 0; - int xOffset = 0; - if (nodeMap.get(subID) == null) { - nodeMap.put(subID, getNodeData(subID).makeNode(this)); - } - - StapNode subN = nodeMap.get(subID); - if (radius != 0) { - yOffset = (int) (radius * Math.cos(angle * i)); - xOffset = (int) (radius * Math.sin(angle * i) + StapNode.getNodeSize()*Math.sin(angle*i)*3); - } - - - if (hasChildren(subID)) - subN.setBackgroundColor(CONSTANT_HAS_CHILDREN); - subN.setLocation(x + xOffset, y + yOffset); - if (subN.connection == null) { - subN.makeConnection(SWT.NONE, nodeMap.get(id), nodeDataMap - .get(subID).called); - } - - if (getData(subID).isMarked()) - subN.setBackgroundColor(CONSTANT_MARKED); - } - } - - - /** - * THE AGGREGATE VIEW FROM VIEW -> AGGREGATE VIEW - */ - public void drawAggregateView(){ - - //TEMPORARY STORAGE OF THE ENTRIES - //IMPLEMENTS A COMPARATOR TO STORE BY ORDER OF THE VALUE - TreeSet<Entry<String, Long>> sortedValues = new TreeSet<Entry<String, Long>>(StapGraph.VALUE_ORDER); - sortedValues.addAll(aggregateTime.entrySet()); - - - if (aggregateNodes == null){ - aggregateNodes = new ArrayList<GraphNode>(); - }else{ - aggregateNodes.clear(); - } - - //-------------Format numbers - float percentage_time; - float percentage_count; - int maxTimesCalled = 0; - final int colorLevels = 15; - final int colorLevelDifference = 12; - int primary; - int secondary; - - NumberFormat num = NumberFormat.getInstance(Locale.CANADA); - num.setMinimumFractionDigits(2); - num.setMaximumFractionDigits(2); - - //FIND THE MOST TIMES A FUNCTION IS CALLED - for (int val : aggregateCount.values()){ - if ( val > maxTimesCalled){ - maxTimesCalled = val; - } - } - - //-------------Draw nodes - for (Entry<String, Long> ent : sortedValues) { - - GraphNode n = new GraphNode(this.getGraphModel(),SWT.NONE); - aggregateNodes.add(n); - - percentage_count = (float)aggregateCount.get(ent.getKey()) / (float)maxTimesCalled; - percentage_time = ((float) ent.getValue() / this - .getTotalTime() * 100); - n.setText(ent.getKey() + "\n" //$NON-NLS-1$ - + num.format((float)percentage_time) + "%" + "\n" //$NON-NLS-1$ //$NON-NLS-2$ - + aggregateCount.get(ent.getKey()) + "\n") ; //$NON-NLS-1$ - n.setData("AGGREGATE_NAME", ent.getKey()); //$NON-NLS-1$ - - - primary = (int)(percentage_count * colorLevels * colorLevelDifference); - secondary = (colorLevels * colorLevelDifference) - (int)(percentage_count * colorLevels * colorLevelDifference); - - primary = Math.max(0, primary); - secondary = Math.max(0, secondary); - - primary = Math.min(primary, 255); - secondary = Math.min(secondary, 255); - - - Color c = new Color(this.getDisplay(),primary,0,secondary); - n.setBackgroundColor(c); - n.setHighlightColor(c); - n.setForegroundColor(new Color(this.getDisplay(),255,255,255)); - n.setTooltip(new Label( - Messages.getString("StapGraph.2")+ ent.getKey() + "\n" //$NON-NLS-1$ //$NON-NLS-2$ - + Messages.getString("StapGraph.3") + num.format((float)percentage_time) + "%" + "\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - + Messages.getString("StapGraph.1") + aggregateCount.get(ent.getKey()) //$NON-NLS-1$ - )); - n.setBorderWidth(2); - } - - //Set layout to gridlayout - this.setLayoutAlgorithm(new AggregateLayoutAlgorithm(LayoutStyles.NONE, sortedValues, this.getTotalTime(), this.getBounds().width), true); - } - - - - /** - * Draws a tree starting with node id, putting node id at location x,y - * @param id - * @param x - * @param y - */ - public void drawTree(int id, int x, int y) { - - //-------------Create node id - // Create and set - if (nodeMap.get(id) == null) { - nodeMap.put(id, getData(id).makeNode(this)); - } - StapNode n = getNode(id); - n.setLocation(x,y); - n.setSize(n.getSize().width/scale, n.getSize().height/scale); - - //This is the lowest level of nodes to draw, and it still has kids - if (getLevelOfNode(id) == bottomLevelToDraw && - getData(id).callees.size() > 0) - n.setBackgroundColor(CONSTANT_HAS_CHILDREN); - - if (getData(id).isMarked()) - n.setBackgroundColor(CONSTANT_MARKED); - - - //-------------Get appropriate list of children - List<Integer> callees = null; - int usefulSize = 0; - - // Determine which list of callees to use - if (!collapse_mode) - callees = getData(id).callees; - else - callees = getData(id).collapsedCallees; - if (callees == null) - return; - - int cLevel = getLevelOfNode(id) + 1; - - if (!collapse_mode) { - if (levels.get(cLevel) != null) { - usefulSize = levels.get(cLevel).size() - collapsedLevelSize.get(cLevel); - } - } - else { - if (collapsedLevelSize.get(cLevel) != null) - usefulSize = collapsedLevelSize.get(cLevel); - } - //-------------Draw all children - for (int i = 0; i < callees.size(); i++) { - //Find the number of nodes on this level for spacing purposes - int childID = callees.get(i); - int childLevel = getLevelOfNode(childID); - - - //Initialise the offset to roughly centre the nodes - if (currentPositionInLevel.get(getLevelOfNode(childID)) == null) { - int tmp = (int) (CONSTANT_HORIZONTAL_SPACING*(usefulSize-1) * -1/scale); - currentPositionInLevel.put(childLevel, getNode(rootVisibleNodeNumber) - .getLocation().x + tmp); - } - - //Recursive iteration - if (childLevel <= bottomLevelToDraw && - childLevel <= lowestLevelOfNodesAdded) { - drawTree(callees.get(i), currentPositionInLevel.get(childLevel), - y + (int)(CONSTANT_VERTICAL_INCREMENT/scale)); - - //Do not scale newSize or nodes will no longer be adjacent - int newSize = currentPositionInLevel.get(getLevelOfNode(childID)) - + getNode(childID).getSize().width; - - //Leave a small blank space between nodes for aesthetic purposes - if (i == callees.size() - 1) - newSize += CONSTANT_HORIZONTAL_SPACING/3; - currentPositionInLevel.put(getLevelOfNode(childID), newSize); - } - - } - } - - /** - * Extend the tree downwards - */ - public void extendTree() { - if (bottomLevelToDraw >= lowestLevelOfNodesAdded) - return; - - - StapData data = getData(rootVisibleNodeNumber); - if (data.callees != null) { - if (data.callees.size() < 1) { - return; - } - } - - List<Integer> list = data.callees; - if (isCollapseMode()) - list = data.collapsedCallees; - - if (list.size() == 1) { - //Special case - only one child of the root node - //Therefore change root node to this new root node - int aMode = animation_mode; - draw(CONSTANT_DRAWMODE_TREE, CONSTANT_ANIMATION_FASTEST, list.get(0)); - setAnimationMode(aMode); - return; - } - - - List<Integer> bottomList = levels.get(bottomLevelToDraw); - bottomLevelToDraw++; - - for (int i : bottomList) { - if (getNode(i) != null) { - getNode(i).setBackgroundColor(DEFAULT_NODE_COLOR); - getParentNode(i).setBackgroundColor(DEFAULT_NODE_COLOR); - drawTree(i, getNode(i).getLocation().x, getNode(i).getLocation().y); - } - } - - treeLevelFromRoot++; - } - - /** - * Removes nodes from the bottom of the tree - */ - public void shrinkTree() { - if (treeLevelFromRoot < 1) - return; - - - bottomLevelToDraw--; - deleteAll(rootVisibleNodeNumber); - - int i = rootVisibleNodeNumber; - currentPositionInLevel.clear(); - drawTree(i, getNode(i).getLocation().x, getNode(i).getLocation().y); - - treeLevelFromRoot--; - } - - /** - * Moves all nodes to the point x,y - * @param x - * @param y - */ - public void moveAllNodesTo(int x, int y) { - for (int i: nodeMap.keySet()) { - nodeMap.get(i).setLocation(x,y); - } - } - - /* - * Partially functional draw functions - * - * -Box (drawFromBottomToTop) - * Breaks when switching modes?? - */ - - - /** - * Draws a tree roughly starting from node id - */ - public void drawBox(int id, int x, int y) { - setLevelLimits(id); - int MaxLevelPixelWidth = 1; - int currPixelWidth = 1; - - // FIND THE LEVEL THAT WILL BE THE WIDEST - // WILL BE A USEFUL VALUE LATER ON - int count; - - - for (int i = topLevelToDraw; i <= bottomLevelToDraw; i++) { - count = 0; - levels.get(i).add(0, count); - int size = levels.get(i).size(); - for (int j = 1; j < size; j++){ - int val = levels.get(i).get(j); - if (collapse_mode && nodeDataMap.get(val).isPartOfCollapsedNode()) { - continue; - } - if (!collapse_mode && nodeDataMap.get(val).isCollapsed) - continue; - - currPixelWidth += nodeDataMap.get(val).name.length() * 10 + StapGraph.CONSTANT_HORIZONTAL_SPACING_FOR_BOX; - if (MaxLevelPixelWidth < currPixelWidth) { - MaxLevelPixelWidth = currPixelWidth; - } - count++; - levels.get(i).remove(0); - levels.get(i).add(0, count); - } - currPixelWidth = 1; - } - - MaxLevelPixelWidth = (int)(MaxLevelPixelWidth/scale); - counter = 0; - if (id == getFirstUsefulNode()) - nodeMap.get(id).setLocation(150 + (MaxLevelPixelWidth/2),y); - - drawFromBottomToTop(bottomLevelToDraw, y - + ((bottomLevelToDraw - topLevelToDraw ) * 3 * (int)(CONSTANT_VERTICAL_INCREMENT/scale)), - MaxLevelPixelWidth); - - if (id == getFirstUsefulNode()) - nodeMap.get(id).setLocation(150 + (MaxLevelPixelWidth/2),y); - } - - public void drawFromBottomToTop(int level, int height, - int MaxLevelPixelWidth) { - - // FINISHED DRAWING THE ROOT IN THE LAST RECURSIVE CALL - if (level == 0 || level < topLevelToDraw ) { - return; - } - - // FIND ALL THE CHILDREN AT LEVEL 'level' - int total = levels.get(level).remove(0); - int count = 1; - - //CREATE THE NODES - for (int i = 0; i < levels.get(level).size(); i ++) { - int id = levels.get(level).get(i); - - if (collapse_mode && nodeDataMap.get(id).isPartOfCollapsedNode()) { - continue; - } - if (!collapse_mode && nodeDataMap.get(id).isCollapsed) - continue; - - if (nodeMap.get(id) == null) { - nodeMap.put(id, getNodeData(id).makeNode(this)); - } - - StapNode n = nodeMap.get(id); - - n.setVisible(true); - n.setSize(n.getSize().width/scale, n.getSize().height/scale); - //Placement algorithm - if (getAnimationMode() == CONSTANT_ANIMATION_SLOW){ - - if (counter <= ANIMATION_TIME) - Animation.markBegin(); - n.setLocation(150 + (nodeMap.get(getRootVisibleNodeNumber()).getLocation().x),nodeMap.get(getRootVisibleNodeNumber()).getLocation().y); - n.setLocation(150 + (MaxLevelPixelWidth / (total + 1) * count),height); - - if (counter <= ANIMATION_TIME) { - Animation.run(ANIMATION_TIME/nodeMap.size()/3); - counter+=ANIMATION_TIME/nodeMap.size(); - } - - }else{ - n.setLocation(150 + (MaxLevelPixelWidth / (total + 1) * count),height); - } - - //IF WE CANNOT DISPLAY ALL NODES COLOUR NODES ON BOTTOM THAT STILL HAVE CHILDREN - if (level == bottomLevelToDraw && nodeDataMap.get(id).callees.size() != 0){ - n.setBackgroundColor(CONSTANT_HAS_CHILDREN); - } - - - - if (getData(n.id).isMarked()) - n.setBackgroundColor(CONSTANT_MARKED); - - - // FIND ALL THE NODES THAT THIS NODE CALLS AND MAKE CONNECTIONS - List<Integer> setOfCallees = null; - if (collapse_mode) - setOfCallees = nodeDataMap.get(id).collapsedCallees; - else - setOfCallees = nodeDataMap.get(id).callees; - - for (int val : setOfCallees) { - if (nodeMap.get(val) != null) - nodeMap.get(val).makeConnection(SWT.NONE, n, - nodeDataMap.get(val).called); - } - - count++; - } - // DRAW THE NEXT LEVEL UP - drawFromBottomToTop(level - 1, height - (3 * (int)(CONSTANT_VERTICAL_INCREMENT/scale)), - MaxLevelPixelWidth); - } - - - - /* - * Level/node management - */ - - /** - * Delete all nodes except for the node with the specified nodeID - * - * @param exception - * - id of node NOT to delete (use -1 for 'no exceptions') - */ - public void deleteAll(int exception) { - //-------------Delete aggregate nodes - if (aggregateNodes != null){ - for (GraphNode n : aggregateNodes){ - n.dispose(); - } - aggregateNodes.clear(); - } - - //-------------Save exception node's location - int x = -1; - int y = -1; - if (exception != -1 && nodeMap.get(exception) != null) { - x = nodeMap.get(exception).getLocation().x; - y = nodeMap.get(exception).getLocation().y; - } - - //-------------Delete all nodes - for (int i : nodeMap.keySet()) { - StapNode node = nodeMap.get(i); - if (node == null) - continue; - - node.unhighlight(); - node.dispose(); - } - nodeMap.clear(); - - //-------------Recreate exception - if (x != -1 && y != -1) { - StapNode n =getData(exception).makeNode(this); - n.setLocation(x,y); - n.highlight(); - nodeMap.put(exception, n); - } - } - - /** - * Delete a number of levels from the top of the graph - * - * @param numberOfLevelsToDelete - */ - private void deleteLevelsFromTop(int numberOfLevelsToDelete) { - - if (numberOfLevelsToDelete <= 0) - return; - - for (int i = 0; i < numberOfLevelsToDelete; i++) { - List<Integer> level = levels.get(topLevelToDraw); - for (int j = 0; j < level.size(); j++) { - if (nodeMap.get(level.get(j)) != null) - nodeMap.remove(level.get(j)).dispose(); - } - topLevelToDraw++; - } - } - - /** - * Delete a number of levels from the bottom of the graph - * - * @param numberOfLevelsToDelete - */ - private void deleteLevelsFromBottom(int numberOfLevelsToDelete) { - - if (numberOfLevelsToDelete <= 0) - return; - - for (int i = 0; i < numberOfLevelsToDelete; i++) { - List<Integer> level = levels.get(getBottomLevelToDraw()); - - for (int j = 0; j < level.size(); j++) { - if (nodeMap.get(level.get(j)) != null) - nodeMap.remove(level.get(j)).dispose(); - } - bottomLevelToDraw--; - } - } - - /** - * Sets top level limit to the level of id, bottom level limit to top level - * limit + CONSTANT_LEVEL_BUFFER. - * Deletes extraneous levels, changes topLevelToDraw, bottomLevelToDraw - * - * Convenience method: Calls setLevelLimitsToLevel(levelOfNode(id)) - * - * @param id - node to recenter with - */ - public void setLevelLimits(int id) { - setTopLevelTo(getLevelOfNode(id)); - } - - /** - * Sets top level limit to the given level, bottom level limit to top level - * limit + CONSTANT_LEVEL_BUFFER. - * Deletes extraneous levels, changes topLevelToDraw, bottomLevelToDraw - * - * @param id - node to recenter with - */ - - public void setTopLevelTo(int new_topLevelToDraw) { - changeLevelLimits(new_topLevelToDraw); - - int new_bottomLevelToDraw = new_topLevelToDraw + levelBuffer; - if (new_bottomLevelToDraw > lowestLevelOfNodesAdded) - new_bottomLevelToDraw = lowestLevelOfNodesAdded; - - deleteLevelsFromTop(new_topLevelToDraw - topLevelToDraw); - deleteLevelsFromBottom(getBottomLevelToDraw() - new_bottomLevelToDraw); - - topLevelToDraw = new_topLevelToDraw; - bottomLevelToDraw = new_bottomLevelToDraw; - } - - - public boolean changeLevelLimits(int lvl) { - int numberOfNodes = 0; - List<Integer> list; - - int maxLevel = min(lvl + levelBuffer, lowestLevelOfNodesAdded); - - for (int level = lvl; level < maxLevel; level++) { - for (int id : levels.get(level)) { - if (isCollapseMode()) - list = getData(id).collapsedCallees; - else - list = getData(id).callees; - - numberOfNodes += list.size(); - - if (numberOfNodes > maxNodes) { - levelBuffer = max(0,level-1); - return true; - } - } - } - - return false; - - - } - - /** - * Convenience method to redraw everything. - */ - public void draw() { - draw(getFirstUsefulNode()); - } - - /** - * Convenience method to draw with current draw parameters. Equivalent to - * draw(graph.draw_mode, graph.animation_mode, id) - * @param id - */ - public void draw(int id) { - draw(draw_mode, animation_mode, id); - } - - /** - * Convenience method to draw with current draw parameters. Equivalent to - * draw(graph.draw_mode, animation, id) - * @param id - */ - public void draw(int animation, int id) { - draw(draw_mode, animation, id); - } - - - /** - * Draws with the given modes. - * @param drawMode - * @param animationMode - * @param id - */ - public void draw(int drawMode, int animationMode, int id) { - setDrawMode(drawMode); - setAnimationMode(animationMode); - this.clearSelection(); - treeLevelFromRoot = 0; - currentPositionInLevel.clear(); - - this.setRedraw(false); - if (draw_mode == CONSTANT_DRAWMODE_RADIAL) { - //Remove thumbnail - GridData gd = (GridData) thumbCanvas.getLayoutData(); - gd.exclude = true; - thumbCanvas.setLayoutData(gd); - thumbCanvas.setVisible(false); - CallgraphView.layout(); - - - //Add treeComp - gd = (GridData) treeComp.getLayoutData(); - gd.exclude = false; - treeComp.setLayoutData(gd); - treeComp.setVisible(true); - treeViewer.collapseToLevel(getData(id), 1); - treeViewer.expandToLevel(getData(id), 1); - - - } else if (draw_mode == CONSTANT_DRAWMODE_AGGREGATE){ - //Remove treeComp - GridData gd = (GridData) treeComp.getLayoutData(); - gd.exclude = true; - treeComp.setLayoutData(gd); - treeComp.setVisible(false); - - CallgraphView.layout(); - //Remove thumbnail - gd = (GridData) thumbCanvas.getLayoutData(); - gd.exclude = true; - thumbCanvas.setLayoutData(gd); - thumbCanvas.setVisible(false); - } - else{ - //Remove treeComp - GridData gd = (GridData) treeComp.getLayoutData(); - gd.exclude = true; - treeComp.setLayoutData(gd); - treeComp.setVisible(false); - - CallgraphView.layout(); - - //Add thumbnail - gd = (GridData) thumbCanvas.getLayoutData(); - gd.exclude = true; - thumbCanvas.setLayoutData(gd); - thumbCanvas.setVisible(true); - thumbCanvas.setBackground(this.getBackground()); - - - } - //Remove treeComp - this.setRedraw(true); - - - //-------------Draw tree - if (draw_mode == CONSTANT_DRAWMODE_TREE) { - if (animation_mode == CONSTANT_ANIMATION_SLOW) { - if (nodeMap.get(id) == null) - nodeMap.put(id, getData(id).makeNode(this)); - int tempX = nodeMap.get(id).getLocation().x; - int tempY = nodeMap.get(id).getLocation().y; - Animation.markBegin(); - moveAllNodesTo(tempX, tempY); - Animation.run(ANIMATION_TIME); - - deleteAll(id); - setLevelLimits(id); - rootVisibleNodeNumber = id; - drawTree(id, this.getBounds().width / 2, 20); - currentPositionInLevel.clear(); - - this.update(); - Animation.markBegin(); - drawTree(id, this.getBounds().width / 2, 20); - - Animation.run(ANIMATION_TIME); - getNode(id).unhighlight(); - } else { - deleteAll(id); - setLevelLimits(id); - rootVisibleNodeNumber = id; - drawTree(id, this.getBounds().width / 2, 20); - getNode(id).unhighlight(); - } - } - - - //-------------Draw radial - else if (draw_mode == CONSTANT_DRAWMODE_RADIAL) { - - if (animation_mode == CONSTANT_ANIMATION_SLOW) { - rootVisibleNodeNumber = id; - deleteAll(id); - - preDrawRadial(id); - this.redraw(); - this.getLightweightSystem().getUpdateManager() - .performUpdate(); - - Animation.markBegin(); - nodeMap.get(id).setLocation(this.getBounds().width / 2, - this.getBounds().height / 2); - drawRadial(id); - Animation.run(ANIMATION_TIME); - CallgraphView.maximizeOrRefresh(false); - } - - else { - deleteAll(id); - drawRadial(id); - } - } - - //-------------Draw box - else if (draw_mode == CONSTANT_DRAWMODE_BOX) { - rootVisibleNodeNumber = id; - if (animation_mode == CONSTANT_ANIMATION_SLOW) { - if (nodeMap.get(id) == null) - nodeMap.put(id, getData(id).makeNode(this)); - - Animation.markBegin(); - moveAllNodesTo(nodeMap.get(id).getLocation().x, nodeMap.get(id).getLocation().y); - Animation.run(ANIMATION_TIME); - - deleteAll(id); - - drawBox(id, 0, 0); - - } else { - if (nodeMap.get(id) == null) - nodeMap.put(id, getData(id).makeNode(this)); - deleteAll(id); - drawBox(id, 0, 0); - - } - } - - - //-------------Draw aggregate - else if (draw_mode == CONSTANT_DRAWMODE_AGGREGATE) { - rootVisibleNodeNumber = getFirstUsefulNode(); - deleteAll(-1); - drawAggregateView(); - } - - //THIS CAUSED A NULL POINTER GOING INTO AGGREGATE VIEW - if (getNode(id) != null) - getNode(id).unhighlight(); - clearSelection(); - - //AFTER FIRST LOADING LET THE GRAPH EXPAND TO FILL THE VIEW - this.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true)); - } - - - - @SuppressWarnings("unchecked") - /** - * Unhighlights all selected nodes and sets selection to null - */ - public void clearSelection() { - List<GraphNode> list = this.getSelection(); - - for (GraphNode n : list) { - if (n != null) n.unhighlight(); - } - this.setSelection(null); - - } - - /* - * THE FOLLOWING METHODS ARE NOT WELL TESTED - * - * Some are not thoroughly tested, and some just plain don't work. Use at your peril! - */ - - /** - * Shift the given node to the given location, moving all children nodes - * accordingly - * - * - * @param id - * @param x - * @param y - */ - public void moveRecursive(int id, int xTarget, int yTarget) { - if (nodeMap.get(id) != null) { - int x = nodeMap.get(id).getLocation().x; - int y = nodeMap.get(id).getLocation().y; - nodeMap.get(id).setLocation(x + xTarget, y + yTarget); - } - //If a node is null, then its children must be null - else - return; - - List<Integer> list = null; - - if (collapse_mode) - list = nodeDataMap.get(id).collapsedCallees; - else - list = nodeDataMap.get(id).callees; - for (int i = 0; i < list.size(); i++) { - moveRecursive(list.get(i), xTarget, yTarget); - } - } - - - /** - * Moves all nodes by the given amount. Adds xDiff, yDiff to the current x,y coordinates. - * - * Currently unused. - */ - public void moveAllNodesBy(int xDiff, int yDiff) { - for (int id : nodeMap.keySet()) { - if (nodeMap.get(id) == null) continue; - - int x = nodeMap.get(id).getLocation().x; - int y = nodeMap.get(id).getLocation().y; - getNode(id).setLocation(x + xDiff, y + yDiff); - } - } - - - - /** - * Recursively collapses all children of node id, and puts them in the - * collapsedCallees list of id. - * - * At the end of this run, each collapsed node will have a list of other - * collapsed nodes AND a list of non-collapsed nodes. So will node #id. - * - * Uncollapsed nodes, however, will not have a list of collapsed nodes attached. - * - * @param ID of node to start from (use getFirstUsefulNode() to collapse everything - * @return True if successful - */ - public boolean recursivelyCollapseAllChildrenOfNode(int id) { - //-------------Initialize - //If all nodes have been collapsed, don't do anything - setCollapseMode(true); - - if (nodeDataMap.get(id).hasCollapsedChildren - || nodeDataMap.get(id).callees.size() == 0) - return true; - nodeDataMap.get(id).hasCollapsedChildren = true; - - - - // Name, id - HashMap<String, Integer> newNodeMap = new HashMap<String, Integer>(); - // id of 'collapsed' node, id of its uncollapsed twin - HashMap<Integer, Integer> collapsedNodesWithOnlyOneNodeInThem = new HashMap<Integer, Integer>(); - int size = nodeDataMap.get(id).callees.size(); - - - - //-------------Iterate - for (int i = 0; i < size; i++) { - - int childID = nodeDataMap.get(id).callees.get(i); - int childLevel = getLevelOfNode(childID); - if (collapsedLevelSize.get(childLevel) == null) - collapsedLevelSize.put(childLevel, 0); - String nodeName = nodeDataMap.get(childID).name; - - /* - * Aggregate data for the given node - */ - if (newNodeMap.get(nodeName) != null) { - int aggregateID = newNodeMap.get(nodeName); - - if (collapsedNodesWithOnlyOneNodeInThem.get(aggregateID) != null) { - - //-------------Aggregate nodes - second node to be found - // We still think this is an only child - create a new - // data node and aggregate - this.loadData(SWT.NONE, aggregateID, nodeName, nodeDataMap - .get(childID).time, nodeDataMap.get(childID).called, - id, nodeDataMap.get(childID).isMarked(), ""); //$NON-NLS-1$ - - if (getData(aggregateID).isMarked()) { - markedCollapsedNodes.add(aggregateID); - markedNodes.remove((Integer) aggregateID); - } - - nodeDataMap.get(id).callees.remove((Integer) aggregateID); - nodeDataMap.get(id).collapsedCallees.add(aggregateID); - - nodeDataMap.get(aggregateID).collapsedCaller = id; - - // Aggregate - int otherChildID = collapsedNodesWithOnlyOneNodeInThem - .get(aggregateID); - aggregateData(nodeDataMap.get(aggregateID), nodeDataMap - .get(otherChildID)); - collapsedNodesWithOnlyOneNodeInThem.remove(aggregateID); - nodeDataMap.get(aggregateID).callees.addAll(nodeDataMap - .get(otherChildID).callees); - - nodeDataMap.get(otherChildID).setPartOfCollapsedNode(true); - - } else - //-------------Aggregate - third and additional nodes - aggregateData(nodeDataMap.get(aggregateID), nodeDataMap - .get(childID)); - - - //-------------Complete aggregation - nodeDataMap.get(aggregateID).callees - .addAll(nodeDataMap.get(childID).callees); - nodeDataMap.get(aggregateID).isCollapsed = true; - - if (nodeMap.get(childID) != null) { - nodeMap.get(childID).setLocation( - nodeMap.get(id).getLocation().x - - nodeMap.get(id).getSize().width, - nodeMap.get(id).getLocation().y); - } - - nodeDataMap.get(childID).setPartOfCollapsedNode(true); - } else { - //-------------First child with this name - - idOfLastNode++; - newNodeMap.put(nodeName, idOfLastNode); - collapsedNodesWithOnlyOneNodeInThem.put(idOfLastNode, childID); - if (nodeMap.get(childID) != null) { - nodeMap.get(childID).setLocation( - nodeMap.get(id).getLocation().x, - nodeMap.get(id).getLocation().y); - } - - int tmp = collapsedLevelSize.get(childLevel) + 1; - collapsedLevelSize.put(childLevel, tmp); - } - } - - //-------------Handle nodes that only appeared once - for (int i : collapsedNodesWithOnlyOneNodeInThem.keySet()) { - int childID =collapsedNodesWithOnlyOneNodeInThem.get(i); - nodeDataMap.get(childID).onlyChildWithThisName = true; - nodeDataMap.get(id).collapsedCallees.add(childID); - newNodeMap.remove(nodeDataMap.get(childID).name); - nodeDataMap.get(childID).collapsedCaller = id; - - if (getData(childID).isMarked()) - markedCollapsedNodes.add(childID); - } - - - - //-------------Finish iterations - for (int i : nodeDataMap.get(id).collapsedCallees) { - recursivelyCollapseAllChildrenOfNode(i); - } - - nodeDataMap.get(id).sortByTime(); - - collapsedNodesWithOnlyOneNodeInThem.clear(); - newNodeMap.clear(); - - nodeDataMap.get(id).hasCollapsedChildren = true; - return true; - } - - /** - * Add time, called values for the two given nodes, storing them inside - * victim. Also adds marked collapsed nodes to markedCollapsedNodes list - * @param target - * @param victim - */ - public void aggregateData(StapData target, StapData victim) { - target.time += victim.time; - target.called += victim.called; - if (victim.isMarked() || target.isMarked()) { - target.setMarked(); - markedCollapsedNodes.add(target.id); - } - } - - /* - * Convenience methods - */ - - /** - * Prints the name of every node on the given level - * @param level - */ - public void printContents(int level) { - if (levels.get(level) != null) - return; - MP.println("Contents of level " + level + ":\n"); //$NON-NLS-1$ //$NON-NLS-2$ - for (int i = 0; i < levels.get(level).size(); i++) { - MP.println(nodeDataMap.get(levels.get(level).get(i)).name); - } - MP.println("---------------------------"); //$NON-NLS-1$ - } - - /** - * - * @param id of node - * @return StapNode - */ - public StapNode getNode(int id) { - return nodeMap.get(id); - } - - /** - * - * @param id of node - * @return StapData - */ - public StapData getNodeData(int id) { - return nodeDataMap.get(id); - } - - /** - * Recommend using getFirstUsefulNode instead. - * @return First node in level 0 - */ - public int getTopNode() { - return levels.get(topLevelToDraw).get(0); - } - - /** - * Recommend use of this function instead of getTopNode() - * @return First node that is not the dummy first node - */ - public int getFirstUsefulNode() { - int id = 0; - if (nodeDataMap.get(id).name == CONSTANT_TOP_NODE_NAME) { - id++; - } - - // Get first node that is not TOP_NODE_NAME - while (nodeDataMap.get(id) == null) { - id++; - } - - return id; - } - - /** - * - * @return Top level to draw - the level should be defined by draw algorithms - */ - public int getTopLevel() { - return topLevelToDraw; - } - - /** - * Returns the level of recursion associated with the given node. - * @param nodeID - * @return - */ - public int getLevelOfNode(int nodeID) { - return nodeDataMap.get(nodeID).levelOfRecursion; - } - - /** - * Returns true if the given node has any children. - * @param nodeID - * @return - */ - public boolean hasChildren(int nodeID) { - if (nodeDataMap.get(nodeID).callees.size() > 0) - return true; - return false; - } - - /** - * Attempts to set dimensions (not used) - * @param width - * @param height - */ - public void setDimensions(int width, int height) { - this.getBounds().width = width; - this.getBounds().height = height; - } - - /** - * Sets animation mode - all available modes are named - * StapGraph.CONSTANT_ANIMATION_* - * @param mode - */ - public void setAnimationMode(int mode) { - animation_mode = mode; - if (mode == CONSTANT_ANIMATION_SLOW){ - CallgraphView.getAnimation_slow().setChecked(true); - CallgraphView.getAnimation_fast().setChecked(false); - }else if (mode == CONSTANT_ANIMATION_FASTEST){ - CallgraphView.getAnimation_slow().setChecked(false); - CallgraphView.getAnimation_fast().setChecked(true); - } - } - - public void setCollapseMode(boolean value) { - collapse_mode = value; - nextMarkedNode = -1; - CallgraphView.getMode_collapsednodes().setChecked(value); - } - - /** - * Gets id of root visible node - * @return rootVisibleNode - ID of centre node - */ - public int getRootVisibleNodeNumber() { - return rootVisibleNodeNumber; - } - - /** - * Sets id of root visible node - * @param id - ID of centre node - */ - public void setRootVisibleNodeNumber(int id) { - this.rootVisibleNodeNumber = id; - } - - /** - * Gets to the total time spent running tapped program - * @return Time in milliseconds - */ - public long getTotalTime() { - return totalTime; - } - - /** - * Sets total time spent running tapped program - * @param totalTime - Time in milliseconds - */ - public void setTotalTime(long val) { - //Divide by 100 to save us the trouble of - //multiplying by 100 to get percentages - this.totalTime = val; - } - - /** - * - * @return Number of the lowest level in which nodes exist - */ - public int getLowestLevelOfNodesAdded() { - return lowestLevelOfNodesAdded; - } - - /** - * Set lowest level to which nodes have been added - * - * WARNING: Do not set this without adding nodes to that level first, or there - * may be null pointer exceptions. - * @param lowestLevelOfNodesAdded - */ - public void setLowestLevelOfNodesAdded(int lowestLevelOfNodesAdded) { - this.lowestLevelOfNodesAdded = lowestLevelOfNodesAdded; - } - - - public int getDrawMode() { - return draw_mode; - } - - public void setDrawMode(int draw_mode) { - this.draw_mode = draw_mode; - } - - /** - * Resets the tree and graph to center on the first useful node. - * Does NOT change draw mode, animation mode or collapse mode. - */ - public void reset() { - setSelection(null); - - draw(draw_mode, animation_mode, getFirstUsefulNode()); - if (! (draw_mode == StapGraph.CONSTANT_DRAWMODE_AGGREGATE)){ - getNode(getFirstUsefulNode()).unhighlight(); - } - if (treeViewer!=null) { - treeViewer.collapseAll(); - treeViewer.expandToLevel(2); - } - scale = 1; - nextMarkedNode = -1; - } - - - public boolean isCollapseMode() { - return this.collapse_mode; - } - - - public void setBottomLevelToDraw(int bottomLevelToDraw) { - this.bottomLevelToDraw = bottomLevelToDraw; - } - - - public int getBottomLevelToDraw() { - return bottomLevelToDraw; - } - - - public void setTopLevelOnScreen(int topLevelOnScreen) { - this.topLevelOnScreen = topLevelOnScreen; - } - - - public int getTopLevelOnScreen() { - return topLevelOnScreen; - } - - - /** - * Returns a list of all nodes at the given level. - * - * @param level - * @return List of ID's of all nodes at the given level. - */ - public List<Integer> getLevel(int level) { - if (level < 0 || level > lowestLevelOfNodesAdded) { - return null; - } - - return levels.get(level); - } - - - - /** - * Returns the StapData object with id == val. - * @param val - * @return - */ - public StapData getData(int val) { - if (val > -1) - return nodeDataMap.get(val); - else - return null; - } - - - public void setTreeViewer(TreeViewer treeview) { - StapGraph.treeViewer = treeview; - } - - - public TreeViewer getTreeViewer() { - return treeViewer; - } - - - /** - * Returns the StapNode object for the parent of node id. May be null. - * @param id - * @return - */ - public StapNode getParentNode(int id) { - return nodeMap.get(nodeDataMap.get(id).caller); - } - - - /** - * Returns a StapData object for the parent of node id. May be null. - * @param id - * @return - */ - public StapData getParentData(int id) { - return nodeDataMap.get(nodeDataMap.get(id).caller); - } - - /** - * Returns the id of the next node that was called. This is necessarily either a - * child of the current root node or of one of its ancestors' children. - * - * @param id - * @return Id of next node that was called. - */ - public int getNextCalledNode(int id) { - int returnID = -1; - - for (int count = callOrderList.indexOf((Integer)id) + 1; - count < callOrderList.size(); count++) { - if (getData(id) == null) - continue; - if (!getData(id).isCollapsed || getData(id).isOnlyChildWithThisName()) { - returnID = callOrderList.get(count); - return returnID; - } - } - - - return returnID; - } - - /** - * Returns the id of the previous node that was called. - * - * @param id - * @return Id of previous node that was called. - */ - public int getPreviousCalledNode(int id) { - int returnID = -1; - - for (int count = callOrderList.indexOf((Integer)id) - 1; - count > -1; count--) { - if (getData(id) == null) - continue; - if (!getData(id).isCollapsed || getData(id).isOnlyChildWithThisName()) { - returnID = callOrderList.get(count); - return returnID; - } - } - - - return returnID; - } - - - - /** - * Returns the id of the next marked node in current collapse mode. - * Wraps back to the first marked node. - * - * @return Node id of next marked node. - */ - public int getNextMarkedNode() { - List<Integer> list = markedNodes; - if (collapse_mode) - list = markedCollapsedNodes; - - if (list.size() == 0) - return -1; - - - nextMarkedNode++; - if (nextMarkedNode >= list.size()) - nextMarkedNode = 0; - - - return list.get(nextMarkedNode); - } - - - /** - * Returns the id of the next marked node in current collapse mode. - * Wraps back to the first marked node. - * - * @return Node id of next marked node. - */ - public int getPreviousMarkedNode() { - List<Integer> list = markedNodes; - if (collapse_mode) - list = markedCollapsedNodes; - - if (list.size() == 0) - return -1; - - nextMarkedNode--; - if (nextMarkedNode < 0) - nextMarkedNode = list.size() - 1; - - - return list.get(nextMarkedNode); - } - - - - public static final Comparator<Entry<String, Long>> VALUE_ORDER = new Comparator<Entry<String, Long>>() - { - public int compare(Entry<String, Long> a, Entry<String, Long> b){ - return ((Long)a.getValue()).compareTo(((Long)b.getValue())); - } - }; - - - /** - * Increments the scrollbars by x, y - * - * @param x - * @param y - */ - public void scrollBy(int x, int y) { - this.scrollTo(this.getHorizontalBar().getSelection() + x, - this.getVerticalBar().getSelection() + y); - } - - - /** - * Smoothly increments the scrollbars by x, y - * - * @param x - * @param y - */ - public void scrollSmoothBy(int x, int y) { - this.scrollSmoothTo(this.getHorizontalBar().getSelection() + x, - this.getVerticalBar().getSelection() + y); - } - - /** - * Retruns the number of StapData objects placed in the nodeDataMap. - * @return - */ - public int getDataMapSize() { - return nodeDataMap.size(); - } - - - public int getAnimationMode() { - return animation_mode; - } - - - public int getLevelBuffer() { - return levelBuffer; - } - - - public void setLevelBuffer(int val) { - levelBuffer = val; - } - - public int min(int a, int b) { - if (a < b) return a; - return b; - } - - public int max(int a, int b) { - if (a > b) return a; - return b; - } - - public int getMaxNodes() { - return maxNodes; - } - - public void setMaxNodes(int val) { - maxNodes = val; - } - - - - public ArrayList<Integer> getCallOrderList() { - return callOrderList; - } - - - - public void setCallOrderList(ArrayList<Integer> callOrderList) { - this.callOrderList = callOrderList; - } - - - - public int getLastFunctionCalled() { - return lastFunctionCalled; - } - - - - public void setLastFunctionCalled(int lastFunctionCalled) { - this.lastFunctionCalled = lastFunctionCalled; - } - - - - public ICProject getProject() { - return project; - } - - - - public void setProject(ICProject myProject) { - this.project = myProject; - } -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/StapGraphParser.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/StapGraphParser.java deleted file mode 100644 index 703e71f204..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/StapGraphParser.java +++ /dev/null @@ -1,368 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.systemtap.local.callgraph; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.TreeMap; - -import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.linuxtools.systemtap.local.core.Helper; -import org.eclipse.linuxtools.systemtap.local.core.SystemTapParser; -import org.eclipse.linuxtools.systemtap.local.core.SystemTapUIErrorMessages; -import org.eclipse.swt.widgets.Shell; - - -/** - * This class is used only in the case that we are rendering a graph - * using GEF (specifically Zest). - * - * After a stap command is sent to be executed, and after data is stored - * into some temporary file, the data must be parsed to be used. This class - * handles all of the parsing. All data is stored into Maps and this class - * also starts the job responsible for taking the parsed data and rendering it. - */ -public class StapGraphParser extends SystemTapParser { - - private static final String NEW_LINE = "\n"; - public HashMap<Integer, Long> timeMap; - public TreeMap<Integer, String> serialMap; - public HashMap<Integer, ArrayList<Integer>> outNeighbours; - public HashMap<String, Long> cumulativeTimeMap; - public HashMap<String, Integer> countMap; - public ArrayList<Integer> callOrderList; - public HashMap<Integer, String> markedMap; - public String markedNodes; - public int validator; - public Long endingTimeInNS; - public long totalTime; - public int lastFunctionCalled; - public ICProject project; - - - public String text; - - @Override - protected void initialize() { - //INITIALIZE MAPS - outNeighbours = new HashMap<Integer, ArrayList<Integer>>(); - timeMap = new HashMap<Integer, Long>(); - serialMap = new TreeMap<Integer, String>(); - cumulativeTimeMap = new HashMap<String, Long>(); - countMap = new HashMap<String, Integer>(); - endingTimeInNS = 0l; - callOrderList = new ArrayList<Integer>(); - markedMap = new HashMap<Integer, String>(); - lastFunctionCalled = 0; - project = null; - } - - - public IStatus executeParsing(){ - //Clear maps (in case a previous execution left values hanging) - outNeighbours.clear(); - timeMap.clear(); - serialMap.clear(); - cumulativeTimeMap.clear(); - countMap.clear(); - text = ""; //$NON-NLS-1$ - callOrderList.clear(); - - try { - BufferedReader buff = new BufferedReader(new FileReader(filePath)); - String tmp; - while ((tmp = buff.readLine()) != null) { - if (monitor.isCanceled()) { - return Status.CANCEL_STATUS; - } - - if (tmp.equals("PROBE_BEGIN")){ //$NON-NLS-1$ - tmp = buff.readLine(); - - if (tmp != null && tmp.length() > 0) { - project = CoreModel.getDefault().getCModel().getCProject(tmp); - } - else { - launchFileDialogError(); - return Status.CANCEL_STATUS; - } - - text = buff.readLine(); - - tmp = buff.readLine(); - if (tmp != null && tmp.length() > 0) - endingTimeInNS = Long.parseLong(tmp); - else { - launchFileDialogError(); - return Status.CANCEL_STATUS; - } - - tmp = buff.readLine(); - if (tmp != null && tmp.length() > 0) - totalTime = Long.parseLong(tmp); - else { - launchFileDialogError(); - return Status.CANCEL_STATUS; - } - } - } - buff.close(); - - } catch (IOException e) { - launchFileDialogError(); - return Status.CANCEL_STATUS; - } - - - if (text.length() > 0) { - - boolean encounteredMain = false; - - ArrayList<Integer> shouldGetEndingTimeForID = new ArrayList <Integer>(); - String[] callsAndReturns = text.split(";"); //$NON-NLS-1$ - String[] args; - ArrayList<String> nameList = new ArrayList<String>(); - ArrayList<Integer> idList = new ArrayList<Integer>(); - boolean skippedDirectives = false; - - String name; - int id; - long time; - long cumulativeTime; - int parentID; - int firstNode = -1; - try { - for (String s : callsAndReturns) { - switch (s.charAt(0)) { - case '<' : - - args = s.substring(1, s.length()).split(",,"); //$NON-NLS-1$ - // args[0] = name - // args[1] = id - // arsg[2] = time of event - id = Integer.parseInt(args[1]); - time = Long.parseLong(args[2]); - name = args[0]; - - //If we haven't encountered a main function yet and the name isn't clean, - //and the name contains "__", then this is probably a C directive - if (!encounteredMain && !isFunctionNameClean(name) && name.contains("__")) { //$NON-NLS-1$ - skippedDirectives = true; - break; - } - name = cleanFunctionName(name); - if (name.equals("main")) //$NON-NLS-1$ - encounteredMain = true; - if (firstNode == -1) { - firstNode = id; - } - - serialMap.put(id, name); - timeMap.put(id, time); - - if (cumulativeTimeMap.get(name) == null){ - cumulativeTimeMap.put(name, (long) 0); - } - - //IF THERE ARE PREVIOUS FUNCTIONS WITH THE SAME NAME - //WE ARE IN ONE OF THEM SO DO NOT ADD TO CUMULATIVE TIME - if (nameList.indexOf(name) == -1) { - cumulativeTime = cumulativeTimeMap.get(name) - time; - cumulativeTimeMap.put(name, cumulativeTime); - shouldGetEndingTimeForID.add(id); - } - - - if (countMap.get(name) == null){ - countMap.put(name, 0); - } - countMap.put(name, countMap.get(name) + 1); - - nameList.add(name); - idList.add(id); - - if (outNeighbours.get(id) == null){ - outNeighbours.put(id, new ArrayList<Integer>()); - } - - if (idList.size() > 1) { - parentID = idList.get(idList.size() - 2); - outNeighbours.get(parentID).add(id); - } - - callOrderList.add(id); - lastFunctionCalled = id; - - break; - case '>' : - args = s.substring(1, s.length()).split(",,"); //$NON-NLS-1$ - //args[0] = name - //args[1] = time of event - name = args[0]; - - - //If we haven't encountered a main function yet and the name isn't clean, - //and the name contains "__", then this is probably a C directive - if (!encounteredMain && !isFunctionNameClean(name) && name.contains("__")) { //$NON-NLS-1$ - skippedDirectives = true; - break; - } - name = cleanFunctionName(name); - int lastOccurance = nameList.lastIndexOf(name); - if (lastOccurance < 0) { - parsingError(Messages.getString("StapGraphParser.12") + name); //$NON-NLS-1$ - return Status.CANCEL_STATUS; - } - - nameList.remove(lastOccurance); - id = idList.remove(lastOccurance); - - - if (timeMap.get(id) == null) { - parsingError(Messages.getString("StapGraphParser.13") + name); //$NON-NLS-1$ - return Status.CANCEL_STATUS; - } - time = Long.parseLong(args[1]) - timeMap.get(id); - timeMap.put(id, time); - - - //IF AN ID IS IN THIS ARRAY IT IS BECAUSE WE NEED THE ENDING TIME - // TO BE ADDED TO THE CUMULATIVE TIME FOR FUNCTIONS OF THIS NAME - if (shouldGetEndingTimeForID.contains(id)){ - cumulativeTime = cumulativeTimeMap.get(name) + Long.parseLong(args[1]); - cumulativeTimeMap.put(name, cumulativeTime); - } - - - //Use + for end times -// cumulativeTime = cumulativeTimeMap.get(name) + Long.parseLong(args[1]); -// cumulativeTimeMap.put(name, cumulativeTime); - - break; - default : - parsingError(Messages.getString("StapGraphParser.14") + s.charAt(0) + //$NON-NLS-1$ - Messages.getString("StapGraphParser.15") ); //$NON-NLS-1$ - return Status.CANCEL_STATUS; - - } - - } - - - //CHECK FOR EXIT() CALL - if (idList.size() != 0){ - for (int val : idList){ - name = serialMap.get(val); - time = endingTimeInNS - timeMap.get(val); - timeMap.put(val, time); - if (shouldGetEndingTimeForID.contains(val)){ - cumulativeTime = cumulativeTimeMap.get(name) + endingTimeInNS; - cumulativeTimeMap.put(name, cumulativeTime); - } - -// if (name.equals("main")) { -// totalTime = time; -// } - lastFunctionCalled = val; - } - markedMap.put(lastFunctionCalled, Messages.getString("StapGraphParser.16")); //$NON-NLS-1$ - } - - //timecheck is true if the total execution time is less than 10ms - //and the first function is more than 1% off from the total time. - boolean timeCheck = totalTime < 50000000 && - (((float)timeMap.get(firstNode)/totalTime) > 1.01 || - ((float)timeMap.get(firstNode)/totalTime) < 0.99); - - - - if (skippedDirectives || timeCheck) { - totalTime = timeMap.get(firstNode); - String markedMessage = ""; //$NON-NLS-1$ - if (markedMap.containsKey(firstNode)) { - markedMessage = markedMap.get(firstNode) + "\n"; //$NON-NLS-1$ - } - if (skippedDirectives) - markedMessage += Messages.getString("StapGraphParser.19"); //$NON-NLS-1$ - if (timeCheck) - markedMessage += Messages.getString("StapGraphParser.20"); //$NON-NLS-1$ - - markedMessage += Messages.getString("StapGraphParser.21"); //$NON-NLS-1$ - - markedMap.put(firstNode, markedMessage); - } - - - } catch (NumberFormatException e) { - SystemTapUIErrorMessages mess = new SystemTapUIErrorMessages(Messages.getString("StapGraphParser.22"), //$NON-NLS-1$ - Messages.getString("StapGraphParser.23"), Messages.getString("StapGraphParser.24") + //$NON-NLS-1$ //$NON-NLS-2$ - Messages.getString("StapGraphParser.25")); //$NON-NLS-1$ - mess.schedule(); - - return Status.CANCEL_STATUS; - } - } else { - parsingError(Messages.getString("StapGraphParser.26")); //$NON-NLS-1$ - return Status.CANCEL_STATUS; - } - - //Create a UIJob to handle the rest - GraphUIJob uijob = new GraphUIJob(Messages.getString("StapGraphParser.5"), this); //$NON-NLS-1$ - uijob.schedule(); - return Status.OK_STATUS; - - } - - - @Override - public void saveData(String filePath) { - File file = new File(filePath); - String content = Messages.getString("CallgraphView.25") //$NON-NLS-1$ - + project.getElementName() - + NEW_LINE - + text - + NEW_LINE - + endingTimeInNS - + NEW_LINE - + totalTime; - try { - // WAS THE FILE CREATED OR DOES IT ALREADY EXIST - if (file.createNewFile()) { - Helper.writeToFile(filePath, content); - } else { - if (MessageDialog - .openConfirm( - new Shell(), - Messages - .getString("CallgraphView.FileExistsTitle"), //$NON-NLS-1$ - Messages - .getString("CallgraphView.FileExistsMessage"))) { //$NON-NLS-1$ - file.delete(); - file.createNewFile(); - Helper.writeToFile(filePath, content); - } - } - } catch (IOException e1) { - e1.printStackTrace(); - } - } - - - - -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/StapNode.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/StapNode.java deleted file mode 100644 index 1534844624..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/StapNode.java +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.systemtap.local.callgraph; - -import java.text.NumberFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -import org.eclipse.draw2d.Label; -import org.eclipse.linuxtools.systemtap.local.core.MP; -import org.eclipse.swt.widgets.Display; -import org.eclipse.zest.core.widgets.GraphConnection; -import org.eclipse.zest.core.widgets.GraphNode; - -public class StapNode extends GraphNode{ - - private static int nodeSize = 20; - public int id; - public GraphConnection connection; //Each node should have only one connection (to its caller) - private boolean hasButtons; //Has buttons already attached - public List<Integer> buttons; - private static NumberFormat numberFormat = NumberFormat.getInstance(Locale.CANADA); - - public StapNode(StapGraph graphModel, int style, StapData data) { - - super(graphModel, style, Messages.getString("StapNode.0")); //$NON-NLS-1$ - numberFormat.setMaximumFractionDigits(2); - numberFormat.setMinimumFractionDigits(2); - if (Display.getCurrent().getPrimaryMonitor().getBounds().width < 1000) - nodeSize = 10; - - - - if (data.name == StapGraph.CONSTANT_TOP_NODE_NAME) - this.setText(StapGraph.CONSTANT_TOP_NODE_NAME); - else { - String shortName = data.name; - if (data.name.length() > nodeSize) - shortName = data.name.substring(0, nodeSize - 3) + "..."; //$NON-NLS-1$ - this.setText(shortName + ": " + //$NON-NLS-1$ - numberFormat.format((float) data.time/graphModel.getTotalTime() * 100) - + "%"); //$NON-NLS-1$ - } - - if (data.markedMessage.length() != 0) { - Label tooltip = new Label(data.name + ": " + //$NON-NLS-1$ - numberFormat.format((float) data.time/graphModel.getTotalTime() * 100) - + "%" + "\n " + data.markedMessage); //$NON-NLS-1$ //$NON-NLS-2$ - this.setTooltip(tooltip); - } else if (data.name.length() > nodeSize) { - Label tooltip = new Label(data.name + ": " + //$NON-NLS-1$ - numberFormat.format((float) data.time/graphModel.getTotalTime() * 100) - + "%"); //$NON-NLS-1$ - this.setTooltip(tooltip); - } - - - this.id = data.id; - this.connection = null; - hasButtons = false; - buttons = new ArrayList<Integer>(); - - - if (graphModel.getNode(data.caller) != null) { - this.connection = new GraphConnection( graphModel, style, - this, graphModel.getNode(data.caller)); - if (graphModel.isCollapseMode()) - connection.setText("" + data.called); //$NON-NLS-1$ - } - - if (graphModel.getNode(data.collapsedCaller) != null) { - this.connection = new GraphConnection( graphModel, style, - this, graphModel.getNode(data.collapsedCaller)); - if (graphModel.isCollapseMode()) - connection.setText("" + data.called); //$NON-NLS-1$ - } - } - - - public void setHasButtons(boolean value) { - hasButtons = value; - } - - public boolean getHasButtons() { - return hasButtons; - } - - /** - * Returns the StapData object associated with this node. - */ - public StapData getData() { - return ((StapGraph) this.getGraphModel()).getNodeData(id); - } - - /** - * Creates a connection between this node and the - * specified node. The connection will have the int called as its text. - * - * @param graphModel - * @param style - * @param n - * @param called - */ - public void makeConnection(int style, StapNode n, int called) { - if (n == null) { - MP.println("Error! Attempting to connect null node to " + this.getText()); //$NON-NLS-1$ - } - this.connection = new GraphConnection(this.getGraphModel(), style, this, n); - if (((StapGraph)this.getGraphModel()).isCollapseMode()) - connection.setText("" + called); //$NON-NLS-1$ - } - - /** - * Returns this node's connection, or null if none exists. - * @return - */ - public GraphConnection getConnection() { - return connection; - } - - - public static int getNodeSize() { - return nodeSize; - } - - - public static void setNodeSize(int nodeSize) { - StapNode.nodeSize = nodeSize; - } - - - - -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/SystemTapCommandParser.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/SystemTapCommandParser.java deleted file mode 100644 index 19d3c27e88..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/SystemTapCommandParser.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.systemtap.local.callgraph; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; - - -public class SystemTapCommandParser extends Job { - - private String filePath; - private String returnText; - private boolean printIsDone; - public CallgraphView stapview; - private String testOutput; - public boolean useColours; - private boolean graphingMode; - private boolean processFinished; - - - public boolean isProcessFinished() { - return processFinished; - } - - - public void setProcessFinished(boolean processFinished) { - this.processFinished = processFinished; - } - - - public SystemTapCommandParser(String name, String filePath, CallgraphView sview, - boolean useColours, - boolean scheduleGraph, String configName) { - super(name); - this.filePath = filePath; - this.stapview = sview; - this.useColours = useColours; - this.graphingMode = scheduleGraph; - this.processFinished=false; - } - - - public String getCommand() { - return filePath; - } - - /** - * Convenience method to set this.filePath. - * Currently not used. - * - * @param filePath - filePath to be set - */ - public void setFilePath(String filePath) { - this.filePath = filePath; - } - - @Override - protected IStatus run(IProgressMonitor monitor) { - - if (graphingMode) { - //Delegate to graphing parser instead of this one - StapGraphParser p = new StapGraphParser(); - p.setFile(filePath); - p.schedule(); - -// String text = Helper.getMainConsoleTextByName(configName); -// returnText = " " + configName+"\n"; //$NON-NLS-1$ //$NON-NLS-2$ -// returnText += dashes() + "\n\n"; //$NON-NLS-1$ -// setText(text); -// -// -// SystemTapUIJob uijob = new SystemTapUIJob("SystemTapUIJob", this, this.useColours); //$NON-NLS-1$ -// uijob.schedule(); - - return Status.OK_STATUS; - } - - return Status.OK_STATUS; - } - - public synchronized void setText(String text) { - returnText += text; - } - - public synchronized String getText() { - String tmp = returnText; - returnText = ""; //$NON-NLS-1$ - return tmp; - } - - public synchronized void setDone() { - printIsDone = true; - } - - public synchronized void clearDone() { - printIsDone = false; - } - - public synchronized boolean checkDone() { - return printIsDone; - } - - public String getTestOutput() { - return testOutput; - } - - public IStatus testRun(IProgressMonitor m) { - return run(m); - } - - -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/actions/InsertMarkerAction.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/actions/InsertMarkerAction.java deleted file mode 100644 index 3ff14e9803..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/actions/InsertMarkerAction.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.systemtap.local.callgraph.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; -import org.eclipse.ui.texteditor.AbstractTextEditor; -import org.eclipse.ui.texteditor.IDocumentProvider; -import org.eclipse.ui.texteditor.ITextEditor; - -/** - * Our sample action implements workbench action delegate. The action proxy will - * be created by the workbench and shown in the UI. When the user tries to use - * the action, this delegate will be created and execution will be delegated to - * it. - * - * @see IWorkbenchWindowActionDelegate - */ -public class InsertMarkerAction implements IWorkbenchWindowActionDelegate { - private IWorkbenchWindow window; - private static final String SYSTEMTAP_MARKER_INSERTED = - "//SYSTEMTAP marker function - this code should appear //STAPSTAPSTAP\n" +//$NON-NLS-1$ - "//once at the top of your program //STAPSTAPSTAP\n" //$NON-NLS-1$ - + "void ___STAP_MARKER___(const char*); //STAPSTAPSTAP\n " //$NON-NLS-1$ - + "void ___STAP_MARKER___(const char* i) { //STAPSTAPSTAP\n" //$NON-NLS-1$ - + "return; //STAPSTAPSTAP\n" //$NON-NLS-1$ - + "} //STAPSTAPSTAP\n"; //$NON-NLS-1$ - - /** - * The constructor. - */ - public InsertMarkerAction() { - } - - /** - * The action has been activated. The argument of the method represents the - * 'real' action sitting in the workbench UI. - * - * @see IWorkbenchWindowActionDelegate#run - */ - public void run(IAction action) { - IWorkbenchPage page = window.getActivePage(); - IEditorPart part = page.getActiveEditor(); - if (!(part instanceof AbstractTextEditor)) - return; - ITextEditor editor = (ITextEditor) part; - IDocumentProvider dp = editor.getDocumentProvider(); - IDocument doc = dp.getDocument(editor.getEditorInput()); - - StyledText st = (StyledText) editor.getAdapter(Control.class); - - try { - int offset = st.getCaretOffset(); - doc.replace(offset, 0, "if (true) { //STAPSTAPSTAP\n" + //$NON-NLS-1$ - "\tchar* stapMarker = new char[20]; //STAPSTAPSTAP\n" + //$NON-NLS-1$ - "\tsprintf(stapMarker, \"\"); //STAPSTAPSTAP\n" + //$NON-NLS-1$ - // "\tprintf(\"%s\\n\", stapMarker); //STAPSTAPSTAP\n" - // + - "\t___STAP_MARKER___(stapMarker); //STAPSTAPSTAP\n\t} //STAPSTAPSTAP\n"); //$NON-NLS-1$ - st.setCaretOffset(offset + 68); - } catch (BadLocationException e1) { - e1.printStackTrace(); - } - // TODO: if this is too slow, fix - if (!doc.get().contains(SYSTEMTAP_MARKER_INSERTED)) { - try { - int offset; - offset = doc.getLineOffset(0); - String output = SYSTEMTAP_MARKER_INSERTED; - - doc.replace(offset, 0, output); - } catch (org.eclipse.jface.text.BadLocationException e) { - e.printStackTrace(); - } - } - } - - /** - * Selection in the workbench has been changed. We can change the state of - * the 'real' action here if we want, but this can only happen after the - * delegate has been created. - * - * @see IWorkbenchWindowActionDelegate#selectionChanged - */ - public void selectionChanged(IAction action, ISelection selection) { - } - - /** - * We can use this method to dispose of any system resources we previously - * allocated. - * - * @see IWorkbenchWindowActionDelegate#dispose - */ - public void dispose() { - } - - /** - * We will cache window object in order to be able to provide parent shell - * for the message dialog. - * - * @see IWorkbenchWindowActionDelegate#init - */ - public void init(IWorkbenchWindow window) { - this.window = window; - } -}
\ No newline at end of file diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/actions/Messages.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/actions/Messages.java deleted file mode 100644 index 98ee40fd7d..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/actions/Messages.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.systemtap.local.callgraph.actions; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class Messages { - private static final String BUNDLE_NAME = "org.eclipse.linuxtools.systemtap.local.callgraph.actions.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); - - private Messages() { - } - - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/actions/RemoveMarkerAction.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/actions/RemoveMarkerAction.java deleted file mode 100644 index de5ba330c7..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/actions/RemoveMarkerAction.java +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.systemtap.local.callgraph.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; -import org.eclipse.ui.texteditor.AbstractTextEditor; -import org.eclipse.ui.texteditor.IDocumentProvider; -import org.eclipse.ui.texteditor.ITextEditor; - -/** - * Our sample action implements workbench action delegate. The action proxy will - * be created by the workbench and shown in the UI. When the user tries to use - * the action, this delegate will be created and execution will be delegated to - * it. - * - * @see IWorkbenchWindowActionDelegate - */ -public class RemoveMarkerAction implements IWorkbenchWindowActionDelegate { - private IWorkbenchWindow window; - private String stapCommentMarker = "//STAPSTAPSTAP"; //$NON-NLS-1$ - - /** - * The constructor. - */ - public RemoveMarkerAction() { - } - - /** - * The action has been activated. The argument of the method represents the - * 'real' action sitting in the workbench UI. - * - * @see IWorkbenchWindowActionDelegate#run - */ - public void run(IAction action) { - IWorkbenchPage page = window.getActivePage(); - IEditorPart part = page.getActiveEditor(); - if (!(part instanceof AbstractTextEditor)) - return; - ITextEditor editor = (ITextEditor) part; - IDocumentProvider dp = editor.getDocumentProvider(); - IDocument doc = dp.getDocument(editor.getEditorInput()); - - for (int i = 0; i < doc.getNumberOfLines(); i++) { - try { - int start = doc.getLineOffset(i); - int length = doc.getLineLength(i); - if (doc.get(start, length).contains(stapCommentMarker)) { - doc.replace(start, length, ""); //$NON-NLS-1$ - } - } catch (BadLocationException e) { - e.printStackTrace(); - } - } - - //TODO: Figure out why I need to do this 3 times to remove all STAPSTAPSTAP... - for (int i = 0; i < doc.getNumberOfLines(); i++) { - try { - int start = doc.getLineOffset(i); - int length = doc.getLineLength(i); - if (doc.get(start, length).contains(stapCommentMarker)) { - doc.replace(start, length, ""); //$NON-NLS-1$ - } - } catch (BadLocationException e) { - e.printStackTrace(); - } - } - - for (int i = 0; i < doc.getNumberOfLines(); i++) { - try { - int start = doc.getLineOffset(i); - int length = doc.getLineLength(i); - if (doc.get(start, length).contains(stapCommentMarker)) { //$NON-NLS-1$ - doc.replace(start, length, ""); //$NON-NLS-1$ - } - } catch (BadLocationException e) { - e.printStackTrace(); - } - } - } - - /** - * Selection in the workbench has been changed. We can change the state of - * the 'real' action here if we want, but this can only happen after the - * delegate has been created. - * - * @see IWorkbenchWindowActionDelegate#selectionChanged - */ - public void selectionChanged(IAction action, ISelection selection) { - } - - /** - * We can use this method to dispose of any system resources we previously - * allocated. - * - * @see IWorkbenchWindowActionDelegate#dispose - */ - public void dispose() { - } - - /** - * We will cache window object in order to be able to provide parent shell - * for the message dialog. - * - * @see IWorkbenchWindowActionDelegate#init - */ - public void init(IWorkbenchWindow window) { - this.window = window; - } -}
\ No newline at end of file diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/actions/messages.properties b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/actions/messages.properties deleted file mode 100644 index 14b6a7aae0..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/actions/messages.properties +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# Copyright (c) 2009 Red Hat, Inc. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Red Hat - initial API and implementation -############################################################################### diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/AutoScrollHelper.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/AutoScrollHelper.java deleted file mode 100644 index 71b1414b49..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/AutoScrollHelper.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.systemtap.local.callgraph.graphlisteners; - -import org.eclipse.linuxtools.systemtap.local.callgraph.StapGraph; - -public class AutoScrollHelper { - - - - public static void scrollUp(StapGraph graph) { - - if (graph.getDrawMode() == StapGraph.CONSTANT_DRAWMODE_BOX) { - int parent = graph.getNodeData(graph.getRootVisibleNodeNumber()).caller; - if (graph.isCollapseMode()) - parent = graph.getNodeData(graph.getRootVisibleNodeNumber()).collapsedCaller; - - if (graph.getNodeData(parent) != null && graph.getNodeData(parent).levelOfRecursion > 0 ) { - int animMode = graph.getAnimationMode(); - graph.draw(graph.getDrawMode(), StapGraph.CONSTANT_ANIMATION_FASTEST, parent); - graph.setAnimationMode(animMode); - } - } else if (graph.getDrawMode() == StapGraph.CONSTANT_DRAWMODE_TREE) { - graph.shrinkTree(); - } - } - - public static void scrollDown(StapGraph graph) { - if (graph.getDrawMode() == StapGraph.CONSTANT_DRAWMODE_BOX) { - if (graph.getTopLevel() + StapGraph.levelBuffer < - graph.getLowestLevelOfNodesAdded()) { - int newLevel = graph.getTopLevel() + 1; - if (graph.levels.get(newLevel).get(0) == null) - return; - - graph.setTopLevelTo(newLevel); - int animMode = graph.getAnimationMode(); - graph.setAnimationMode(StapGraph.CONSTANT_ANIMATION_FASTEST); - graph.draw(graph.getDrawMode(), StapGraph.CONSTANT_ANIMATION_FASTEST, - graph.levels.get(newLevel).get(0)); - graph.setAnimationMode(animMode); - } - } else if (graph.getDrawMode() == StapGraph.CONSTANT_DRAWMODE_TREE) { - graph.extendTree(); - } - - } - - -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/AutoScrollSelectionListener.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/AutoScrollSelectionListener.java deleted file mode 100644 index 00d77b3b46..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/AutoScrollSelectionListener.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.systemtap.local.callgraph.graphlisteners; - -import org.eclipse.linuxtools.systemtap.local.callgraph.StapGraph; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; - -public class AutoScrollSelectionListener implements SelectionListener{ - public static final int AutoScroll_up = 0; - public static final int AutoScroll_down = 1; - public static final int AutoScroll_bar = 2; - private final int type; - private final StapGraph graph; - - public AutoScrollSelectionListener(int type, StapGraph g) { - this.type = type; - this.graph = g; - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - - } - - @Override - public void widgetSelected(SelectionEvent e) { - if (type == AutoScroll_up) - AutoScrollHelper.scrollUp(graph); - if (type == AutoScroll_down) - AutoScrollHelper.scrollDown(graph); - } - -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/Messages.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/Messages.java deleted file mode 100644 index 0fffd02a63..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/Messages.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.eclipse.linuxtools.systemtap.local.callgraph.graphlisteners; - -import org.eclipse.osgi.util.NLS; - -public class Messages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.linuxtools.systemtap.local.callgraph.graphlisteners.messages"; //$NON-NLS-1$ - public static String StapGraphMouseMoveListener_0; - public static String StapGraphMouseMoveListener_1; - public static String StapGraphMouseMoveListener_2; - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - private Messages() { - } -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/StapGraphFocusListener.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/StapGraphFocusListener.java deleted file mode 100644 index 8321868323..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/StapGraphFocusListener.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.systemtap.local.callgraph.graphlisteners; - -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; - -/** - * Set mouseDown flag to false when focus is lost (prevents the graph from - * sticking to the mouse cursor when focus is regained) - * - * - */ -public class StapGraphFocusListener implements FocusListener{ - private StapGraphMouseMoveListener listener; - - public StapGraphFocusListener(StapGraphMouseMoveListener listener) { - this.listener = listener; - } - - @Override - public void focusGained(FocusEvent e) { - } - - @Override - public void focusLost(FocusEvent e) { - listener.setStop(true); - } - -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/StapGraphKeyListener.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/StapGraphKeyListener.java deleted file mode 100644 index 4ae3d07dca..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/StapGraphKeyListener.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.systemtap.local.callgraph.graphlisteners; - -import org.eclipse.linuxtools.systemtap.local.callgraph.CallgraphView; -import org.eclipse.linuxtools.systemtap.local.callgraph.StapGraph; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.KeyListener; - -/** - * StapGraph key listener - */ -public class StapGraphKeyListener implements KeyListener { -// private StapGraph graph; - - public StapGraphKeyListener(StapGraph g) { -// graph = g; - } - - @Override - public void keyPressed(KeyEvent e) { - - } - - @Override - public void keyReleased(KeyEvent e) { - if (e.stateMask != SWT.SHIFT) { - return; - } - - //TODO: Use accelerator in menu actions instead of this hard-coded stuff - if (e.character == 'R') { - CallgraphView.getView_refresh().run(); -// }else if (e.character == '1') { -// graph.setAnimationMode(StapGraph.CONSTANT_ANIMATION_SLOW); -// }else if (e.character == '2') { -// graph.setAnimationMode(StapGraph.CONSTANT_ANIMATION_FASTER); -// }else if (e.character == '3') { -// graph.setAnimationMode(StapGraph.CONSTANT_ANIMATION_FASTEST); -// }else if (e.character == 'k') { -// Shell sh = graph.getShell(); -// graph.dispose(); -// sh.close(); -// }else if (e.character == 'n') { -// int id = graph.getNextMarkedNode(); -// graph.draw(id, 0, 0); -// graph.getTreeViewer().expandToLevel(graph.getData(id), 0); -// }else if (e.character == 'p') { -// int id = graph.getPreviousMarkedNode(); -// graph.draw(id, 0, 0); -// graph.getTreeViewer().expandToLevel(graph.getData(id), 0); -// }else if (e.character == 'd') { -// graph.deleteAll(-1); -// }else if (e.character == 'T') { -// graph.deleteAll(graph.getRootVisibleNode()); -// graph.draw(StapGraph.CONSTANT_DRAWMODE_TREE, graph.getAnimationMode(), -// graph.getRootVisibleNode()); -// graph.currentPositionInLevel.clear(); - }else if (e.character == 'C') { - CallgraphView.getMode_collapsednodes().run(); - } else if (e.character == 'N') { - CallgraphView.getGoto_next().run(); - } else if (e.character == 'P') { - CallgraphView.getGoto_previous().run(); - } else if (e.character == 'L') { - CallgraphView.getGoto_last().run(); - } - } -}; diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/StapGraphMouseExitListener.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/StapGraphMouseExitListener.java deleted file mode 100644 index 95066472f7..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/StapGraphMouseExitListener.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.systemtap.local.callgraph.graphlisteners; - -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; - -public class StapGraphMouseExitListener implements Listener{ - private StapGraphMouseMoveListener listener; - - public StapGraphMouseExitListener(StapGraphMouseMoveListener l) { - this.listener = l; - } - - @Override - public void handleEvent(Event event) { - listener.setStop(true); - } - -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/StapGraphMouseListener.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/StapGraphMouseListener.java deleted file mode 100644 index c72d55230b..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/StapGraphMouseListener.java +++ /dev/null @@ -1,278 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.systemtap.local.callgraph.graphlisteners; - -import java.util.List; - -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.linuxtools.systemtap.local.core.FileFinderOpener; -import org.eclipse.linuxtools.systemtap.local.callgraph.StapGraph; -import org.eclipse.linuxtools.systemtap.local.callgraph.StapNode; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseListener; -import org.eclipse.zest.core.widgets.GraphNode; - -@SuppressWarnings("unused") -public class StapGraphMouseListener implements MouseListener { - private int x; - private int y; - private StapGraph graph; - private StapGraphMouseMoveListener listener; - private StapGraphFocusListener focus; - private StapGraphMouseExitListener exitListener; - - public StapGraphMouseListener(StapGraph g) { - this.graph = g; - listener = new StapGraphMouseMoveListener(graph); - focus = new StapGraphFocusListener(listener); - exitListener = new StapGraphMouseExitListener(listener); - } - - @Override - public void mouseDoubleClick(MouseEvent e) { - if (e.stateMask == SWT.CONTROL) { - controlDoubleClick(); - } - - - if (graph.getDrawMode() == StapGraph.CONSTANT_DRAWMODE_RADIAL) { - StapNode node = getNodeFromSelection(); - if (node == null) - return; - - graph.getTreeViewer().collapseToLevel(node.getData(), 0); - graph.getTreeViewer().expandToLevel(node.getData(), 0); - graph.getTreeViewer().setSelection(new StructuredSelection(node.getData())); - - int id = node.getData().id; - - graph.scale = 1; - // Redraw in the current mode with the new id as the center - // The x,y parameters to draw() are irrelevant for radial mode - graph.draw(id); - - // Unhighlight the center node and give it a normal colour - node = graph.getNode(id); - node.unhighlight(); - if (graph.getData(id).isMarked()) - node.setBackgroundColor(StapGraph.CONSTANT_MARKED); - else - node.setBackgroundColor(graph.DEFAULT_NODE_COLOR); - return; - } else { - - StapNode node = getNodeFromSelection(); - if (node == null) - return; - - unhighlightall(node); - graph.setSelection(null); - graph.getTreeViewer().expandToLevel(node.getData(), 0); - graph.getTreeViewer().setSelection(new StructuredSelection(node.getData())); - // Draw in current modes with 'id' at the top - int id = node.getData().id; - graph.draw(id); - } - - graph.setSelection(null); - } - - - @Override - public void mouseDown(MouseEvent e) { -// MP.println("You clicked: " + e.x + ", " + e.y); //$NON-NLS-1$ //$NON-NLS-2$ -// MP.println("Convert to control: " + graph.toControl(e.x, e.y).x + ", " //$NON-NLS-1$ //$NON-NLS-2$ -// + graph.toControl(e.x, e.y).y); -// MP.println("Convert to display: " + graph.toDisplay(e.x, e.y).x + ", " //$NON-NLS-1$ //$NON-NLS-2$ -// + graph.toDisplay(e.x, e.y).y); -// MP.println("Bounds: " + graph.getBounds().width + ", " //$NON-NLS-1$ //$NON-NLS-2$ -// + graph.getBounds().height); - mouseDownEvent(e.x, e.y); - } - - @Override - public void mouseUp(MouseEvent e) { - mouseUpEvent(); - } - - private void unhighlightall(StapNode n) { - int id = n.id; - List<Integer> callees = null; - - if (graph.isCollapseMode()) - callees = graph.getData(id).collapsedCallees; - else - callees = graph.getData(id).callees; - for (int subID : callees) { - if (graph.getNode(subID) != null) - graph.getNode(subID).unhighlight(); - } - - if (graph.getParentNode(id) != null) { - graph.getParentNode(id).unhighlight(); - } - n.unhighlight(); - } - - - @SuppressWarnings("unchecked") - private StapNode getNodeFromSelection() { - List<GraphNode> stapNodeList = graph.getSelection(); - if (stapNodeList.isEmpty() || stapNodeList.size() != 1) { - graph.setSelection(null); - return null; - } - - StapNode node = null; - if (stapNodeList.get(0) instanceof StapNode) { - node = (StapNode) stapNodeList.remove(0); - } else { - graph.setSelection(null); - return null; - } - return node; - } - - @SuppressWarnings("unchecked") - private GraphNode getAggregateNodeFromSelection() { - List<GraphNode> graphNodeList = graph.getSelection(); - if (graphNodeList.isEmpty() || graphNodeList.size() != 1) { - graph.setSelection(null); - return null; - } - - GraphNode node = null; - if (graphNodeList.get(0) instanceof GraphNode) { - node = (GraphNode) graphNodeList.remove(0); - } else { - graph.setSelection(null); - return null; - } - return node; - } - - public String controlDoubleClick() { - String output = null; - if (graph.getDrawMode() == StapGraph.CONSTANT_DRAWMODE_AGGREGATE) { - GraphNode node = getAggregateNodeFromSelection(); - - if (node == null) - return null; - - String functionName = (String) node.getData("AGGREGATE_NAME"); //$NON-NLS-1$ - output= FileFinderOpener.findAndOpen(graph.getProject(), functionName); - } else { - StapNode node = getNodeFromSelection(); - - if (node == null) - return null; - - int caller = node.getData().caller; - - if (caller < graph.getFirstUsefulNode()) { - // The only node that satisfies this condition should be - // main - caller = graph.getFirstUsefulNode(); - } - output = FileFinderOpener.findAndOpen(graph.getProject(), graph.getData(caller).name); - } - - graph.setSelection(null); - return output; - } - - public void mouseDownEvent(int x, int y) { - List<?> list = graph.getSelection(); - if (list.size() < 1) { - listener.setPoint(x, y); - listener.setStop(false); - graph.addMouseMoveListener(listener); - graph.addListener(SWT.MouseExit, exitListener); - } - } - - @SuppressWarnings("unchecked") - public void mouseUpEvent() { - - listener.setStop(true); - graph.removeMouseMoveListener(listener); - graph.removeListener(SWT.MouseExit, exitListener); - - List<StapNode> list = graph.getSelection(); - - // ------------Debug information - if (list.size() == 1) { - int id; - if (list.get(0) instanceof StapNode) - id = list.get(0).id; - else { - graph.setSelection(null); - return; - } - graph.setSelection(null); -// MP.println("Clicked node " + graph.getData(id).name + " with id " //$NON-NLS-1$ //$NON-NLS-2$ -// + id); -// MP.println(" level: " + graph.getData(id).levelOfRecursion); //$NON-NLS-1$ -// MP.println(" called: " + graph.getData(id).called); //$NON-NLS-1$ -// MP.println(" caller: " + graph.getData(id).caller); //$NON-NLS-1$ -// MP.println(" copllapsedCaller: " //$NON-NLS-1$ -// + graph.getData(id).collapsedCaller); -// MP.println(" callees: " + graph.getData(id).callees.size()); //$NON-NLS-1$ -// MP.println(" position: " + graph.getNode(id).getLocation().x //$NON-NLS-1$ -// + ", " + graph.getNode(id).getLocation().y); //$NON-NLS-1$ - - // ------------Highlighting - if (graph.getDrawMode() == StapGraph.CONSTANT_DRAWMODE_TREE - || graph.getDrawMode() == StapGraph.CONSTANT_DRAWMODE_BOX) { - for (StapNode n : (List<StapNode>) graph.getNodes()) { - unhighlightall(n); - } - - List<Integer> callees = null; - - if (graph.isCollapseMode()) - callees = graph.getData(id).collapsedCallees; - else - callees = graph.getData(id).callees; - - for (int subID : callees) { - if (graph.getNode(subID) != null) - graph.getNode(subID).highlight(); - } - - if (graph.getParentNode(id) != null) { - graph.getParentNode(id).highlight(); - } -// graph.setSelection(null); - graph.getNode(id).highlight(); - - return; - } - - } - - else if (list.size() == 0 && ! (graph.getDrawMode() == StapGraph.CONSTANT_DRAWMODE_AGGREGATE)) { - for (StapNode n : (List<StapNode>) graph.getNodes()) { - unhighlightall(n); - } - - } - -// else { -// for (StapNode n : list) { -// unhighlightall(n); -// } -// } - -// graph.setSelection(null); - } -}; diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/StapGraphMouseMoveListener.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/StapGraphMouseMoveListener.java deleted file mode 100644 index cefeeab4b6..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/StapGraphMouseMoveListener.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.systemtap.local.callgraph.graphlisteners; - -import org.eclipse.linuxtools.systemtap.local.callgraph.StapGraph; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseMoveListener; - - -public class StapGraphMouseMoveListener implements MouseMoveListener { - private StapGraph graph; - private int prevX; - private int prevY; - private static final int INIT = -20000; - private boolean stop; - private boolean showMessage; - - public StapGraphMouseMoveListener(StapGraph graph) { - this.graph = graph; - prevX = INIT; - prevY = INIT; - showMessage = true; - } - - public void setPoint(int x, int y) { - prevX = x; - prevY = y; - } - - public void setStop(boolean val) { - stop = val; - } - - @Override - public void mouseMove(MouseEvent e) { - //-------------Panning - //TODO: Implement panning at this zoom and mode - //For some reason getting rid of some of the /scale's in drawTree - //Will fix panning, but at the cost of making the drawTree zoom look weird - - if (graph.getDrawMode() == StapGraph.CONSTANT_DRAWMODE_TREE) { -// if (graph.scale < 0.63) { - if (showMessage) { -// SystemTapUIErrorMessages mess = new SystemTapUIErrorMessages( -// Messages.StapGraphMouseMoveListener_0, Messages.StapGraphMouseMoveListener_1, -// Messages.StapGraphMouseMoveListener_2); -// mess.schedule(); - showMessage = false; - } - return; - } - - //Initialize - if (prevX == INIT && prevY == INIT) { - prevX = e.x; - prevY = e.y; - return; - } - - if (!stop) { - int yDiff, xDiff; - xDiff = prevX - e.x; - yDiff = prevY - e.y; - if (graph.scale > 1) - graph.scrollSmoothBy((int) (xDiff/graph.scale), (int) (yDiff/graph.scale)); - else - graph.scrollSmoothBy((int) (xDiff), (int) (yDiff)); - - prevX = e.x; - prevY = e.y; - } - } -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/StapGraphMouseWheelListener.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/StapGraphMouseWheelListener.java deleted file mode 100644 index 98a94bdfd3..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/StapGraphMouseWheelListener.java +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.systemtap.local.callgraph.graphlisteners; - -import org.eclipse.linuxtools.systemtap.local.callgraph.StapGraph; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseWheelListener; - -/** - * Allows the user to zoom when CTRL + mouse wheel is used - * - */ -public class StapGraphMouseWheelListener implements MouseWheelListener { -// private long snapshot; - private StapGraph graph; - - public StapGraphMouseWheelListener(StapGraph g) { - this.graph = g; - } - - - - @Override - public void mouseScrolled(MouseEvent e) { - - - if (e.stateMask != SWT.CTRL) { - // Scrolling - if (e.count > 0) { - AutoScrollHelper.scrollUp(graph); - } - - else { - AutoScrollHelper.scrollDown(graph); - } - return; - } - - if (graph.getDrawMode() != StapGraph.CONSTANT_DRAWMODE_BOX && - graph.getDrawMode() != StapGraph.CONSTANT_DRAWMODE_TREE) - return; - - - if (e.count <= 0) { - if (graph.scale < 2){ - graph.scale /= (10.0 / 11.0); - }else{ - graph.scale = (int)graph.scale + 1; - } - - }else { - if (graph.scale <= 2){ - graph.scale *= (10.0 / 11.0); - }else{ - graph.scale = (int) graph.scale - 1; - } - } - - int currentAnimationMode = graph.getAnimationMode(); - graph.draw(graph.getDrawMode(), StapGraph.CONSTANT_ANIMATION_FASTEST, - graph.getRootVisibleNodeNumber()); - graph.setAnimationMode(currentAnimationMode); - - int realeX = 3 * (int)(e.x / graph.scale); - int realeY = 3 * (int)(e.y / graph.scale); - int xDiff = (realeX - graph.getSize().x); - int yDiff = (realeY - graph.getSize().y); - - graph.scrollTo(realeX + xDiff, realeY - yDiff); -// x = graph.getNode(graph.getRootVisibleNode()).getLocation().x - x; -// y = graph.getNode(graph.getRootVisibleNode()).getLocation().y - y; -// graph.scrollBy(x/3, y); -// graph.moveAllNodesBy(graph.getBounds().width/2 - e.x, graph.getBounds().height/2 - e.y); -// System.out.println("AFTER: " + graph.getNode(graph.getRootVisibleNode()).getLocation().x + ", " +graph.getNode(graph.getRootVisibleNode()).getLocation().y + "\n\n") ; - -// // Don't scroll for circle mode -// if (graph.getDrawMode() == StapGraph.CONSTANT_DRAWMODE_CIRCLE) -// return; -// -// // Scrolling -// if (e.count > 0) { -// -// long tempSnapshot = System.currentTimeMillis(); -// if (tempSnapshot - snapshot < 100) -// return; -// snapshot = tempSnapshot; -// -// // Scrolling up -// if (graph.getBottomLevelToDraw() < graph.getLowestLevelOfNodesAdded() -// - StapGraph.CONSTANT_LEVEL_BUFFER / 2) -// graph.addLevelToTop(); -// -// graph.decreaseTopLevelOnScreen(); -// if (graph.getTopLevelOnScreen() < 0) { -// graph.setTopLevelOnScreen(0); -// } -// -// graph -// .scrollToY(graph.getNode( -// graph.getLevel(graph.getTopLevelOnScreen()).get(0)) -// .getLocation().y); -// graph.update(); -// -// } -// -// else { -// -// long tempSnapshot = System.currentTimeMillis(); -// -// if (tempSnapshot - snapshot < 100) -// return; -// snapshot = tempSnapshot; -// -// // Don't delete levels yet -// if (graph.getTopLevelOnScreen() > StapGraph.CONSTANT_LEVEL_BUFFER / 4) -// graph.addLevelToBottom(); -// -// graph.incrementTopLevelOnScreen(); -// if (graph.getTopLevelOnScreen() < 0) { -// graph.setTopLevelOnScreen(0); -// } -// -// graph -// .scrollToY(graph.getNode( -// graph.getLevel(graph.getTopLevelOnScreen()).get(0)) -// .getLocation().y); -// graph.update(); -// -// } - - } - -}; - diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/messages.properties b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/messages.properties deleted file mode 100644 index 02024a9a57..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/graphlisteners/messages.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2009 Red Hat, Inc. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Red Hat - initial API and implementation -############################################################################### -StapGraphMouseMoveListener_0=PanError -StapGraphMouseMoveListener_1=Panning disabled -StapGraphMouseMoveListener_2=We're sorry, but panning is disabled in tree mode. diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/messages.properties b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/messages.properties deleted file mode 100644 index f3ad1950bd..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/messages.properties +++ /dev/null @@ -1,82 +0,0 @@ -############################################################################### -# Copyright (c) 2009 Red Hat, Inc. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Red Hat - initial API and implementation -############################################################################### -StapGraph.0=Start of Program -StapGraph.1=number of calls : -StapGraph.2=function : -StapGraph.3=time : -StapGraphParser.12=Encountered return without matching call for function -StapGraphParser.13=No start time could be found for function -StapGraphParser.14=Unexpected symbol when parsing: ' -StapGraphParser.15=' encountered, while expecting < or >. -StapGraphParser.16=:::Program terminated here -StapGraphParser.19=\n:::SystemTap detected functions that appeared to be C directives. -StapGraphParser.20=\n:::Program terminated in less than 50ms, SystemTap overhead may be significant. -StapGraphParser.21=\n:::Total time for this run has been set to the total time taken by this node. -StapGraphParser.22=Unexpected Number -StapGraphParser.23=Unexpected symbol -StapGraphParser.24=Unexpected symbol encountered while trying to -StapGraphParser.25=process id/time values. -StapGraphParser.26=Could not find data in target file. Ensure target file contains data and try again. -StapGraphParser.5=GraphUIJob instance -StapNode.0=unnamed -CallgraphView.0=File -CallgraphView.1=View -CallgraphView.11=Open Last Run -CallgraphView.13=Version -CallgraphView.15=SystemTap Error Log -CallgraphView.16=Tree View -CallgraphView.17=Radial View -CallgraphView.18=Aggregate View -CallgraphView.19=Box View -CallgraphView.2=Animation -CallgraphView.20=Slow -CallgraphView.21=Error Log -CallgraphView.22=Fast -CallgraphView.24=Collapse mode (C) -CallgraphView.25=PROBE_BEGIN\n -CallgraphView.3=\n -CallgraphView.4=About -CallgraphView.5=Help -CallgraphView.6=Markers -CallgraphView.7=Open -CallgraphView.8=Save -CallgraphView.9=Go to -CallgraphView.BufferMessage1=Unfortunately the requested setting for level buffer -CallgraphView.BufferMessage2=could not be processed due to the maximum number of nodes. -CallgraphView.BufferMessage3=Setting levelBuffer to the maximum number of levels possible -CallgraphView.BufferMessage4=without hitting the max nodes( -CallgraphView.BufferMessage5=). -CallgraphView.BufferMessage6=If you really want to see more levels, increment max nodes. -CallgraphView.BufferMessage7=This may cause lag on some systems. -CallgraphView.BufferTooHigh=LevelBuffer too high -CallgraphView.ClearLog=Clear log -CallgraphView.DeleteLogsMessage=This will permanently clear the SystemTap Eclipse error -CallgraphView.DeleteLogsMessage2=logs. Are you sure you want to continue? -CallgraphView.DeleteLogsTitle=Delete logs? -CallgraphView.ErrorMessageBody=Error log could not be read, most likely this is because -CallgraphView.ErrorMessageBody2=\ the log file could not be found. -CallgraphView.ErrorMessageName=ErrorLog reading error -CallgraphView.ErrorMessageTitle=Error reading error log -CallgraphView.Errors=Errors -CallgraphView.FileExistsMessage=Overwrite existing file? -CallgraphView.FileExistsTitle=File Already Exists -CallgraphView.Last=Last (L) -CallgraphView.MaxDepth=Max depth: -CallgraphView.MaxNodes=Max nodes: -CallgraphView.Next=Next (N) -CallgraphView.nextMarker=(n)ext -CallgraphView.OpenLog=Open log -CallgraphView.Previous=Previous (P) -CallgraphView.previousMarker=(p)revious -CallgraphView.Reset=Reset (R) -CallgraphView.SetLimits=Set limits -CallgraphView.SetValues=Set values -CallgraphView.SystemTapVersionBox=SystemTap Version diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/treeviewer/StapTreeContentProvider.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/treeviewer/StapTreeContentProvider.java deleted file mode 100644 index 99fb4aa63f..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/treeviewer/StapTreeContentProvider.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.systemtap.local.callgraph.treeviewer; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.linuxtools.systemtap.local.callgraph.StapData; -import org.eclipse.linuxtools.systemtap.local.callgraph.StapGraph; - -public class StapTreeContentProvider implements ITreeContentProvider{ - - private StapGraph graph; - - @Override - public Object[] getChildren(Object parentElement) { - List<StapData> EMPTY = new ArrayList<StapData>(); - if (parentElement instanceof StapData) { - StapData parent = ((StapData) parentElement); - List<Integer> childrenIDs = parent.collapsedCallees; - for (int val : childrenIDs) { - if (graph.getData(val) != null) { - EMPTY.add(graph.getData(val)); - } - } - } - return EMPTY.toArray(); - } - - @Override - public Object getParent(Object element) { - if (element instanceof StapData) { - return graph.getData(((StapData) element).collapsedCaller); - } - return null; - } - - @Override - public boolean hasChildren(Object element) { - if (element instanceof StapData) - return element == null ? false : - ((StapData) element).callees.size() > 0; - return false; - } - - @Override - public Object[] getElements(Object inputElement) { - return getChildren(inputElement); - } - - @Override - public void dispose() { - - } - - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - - public void setGraph(StapGraph graph) { - this.graph = graph; - } - -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/treeviewer/StapTreeDoubleClickListener.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/treeviewer/StapTreeDoubleClickListener.java deleted file mode 100644 index cd20cb3d7f..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/treeviewer/StapTreeDoubleClickListener.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.systemtap.local.callgraph.treeviewer; - -import java.util.Iterator; - -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.linuxtools.systemtap.local.callgraph.CallgraphView; -import org.eclipse.linuxtools.systemtap.local.callgraph.StapData; -import org.eclipse.linuxtools.systemtap.local.callgraph.StapGraph; - -public class StapTreeDoubleClickListener implements IDoubleClickListener { - - private StapGraph graph; - private TreeViewer viewer; - - public StapTreeDoubleClickListener(TreeViewer t , StapGraph g) { - this.graph = g; - this.viewer = t; - } - - @Override - public void doubleClick(DoubleClickEvent event) { - if (!(event.getSelection() instanceof IStructuredSelection)) - return; - IStructuredSelection selection = (IStructuredSelection) event.getSelection(); - if (selection.size() != 1) return; - - - //Expand the current node in the tree viewer and on the graph - for (Iterator<?> iterator = selection.iterator(); iterator.hasNext();) { - StapData data = (StapData) iterator.next(); - viewer.collapseToLevel(data, 1); - viewer.expandToLevel(data, 1); - graph.setCollapseMode(true); - graph.draw(data.id); - graph.getNode(data.id).unhighlight(); - } - - CallgraphView.maximizeIfUnmaximized(); - graph.setFocus(); - } - -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/treeviewer/StapTreeLabelProvider.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/treeviewer/StapTreeLabelProvider.java deleted file mode 100644 index ae29eb0eea..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/treeviewer/StapTreeLabelProvider.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.systemtap.local.callgraph.treeviewer; - -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.linuxtools.systemtap.local.callgraph.CallGraphConstants; -import org.eclipse.linuxtools.systemtap.local.callgraph.StapData; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; - -public class StapTreeLabelProvider implements ILabelProvider { - - @Override - public Image getImage(Object element) { - Image im = null; - if ( ((StapData) element).isMarked()) - im = new Image(Display.getCurrent(), CallGraphConstants.PLUGIN_LOCATION + "/icons/public_co.gif"); //$NON-NLS-1$ - else - im = new Image(Display.getCurrent(), CallGraphConstants.PLUGIN_LOCATION + "/icons/compare_method.gif"); //$NON-NLS-1$ - return im; - } - - @Override - public String getText(Object element) { - return ((StapData) element).called + ": " + ((StapData) element).name; //$NON-NLS-1$ - } - - @Override - public void addListener(ILabelProviderListener listener) { - } - - - @Override - public void dispose() { - } - - @Override - public boolean isLabelProperty(Object element, String property) { - return false; - } - - @Override - public void removeListener(ILabelProviderListener listener) { - } - -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/treeviewer/StapTreeListener.java b/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/treeviewer/StapTreeListener.java deleted file mode 100644 index 8337cfd10e..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.local.callgraph/src/org/eclipse/linuxtools/systemtap/local/callgraph/treeviewer/StapTreeListener.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.systemtap.local.callgraph.treeviewer; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import org.eclipse.jface.viewers.ITreeViewerListener; -import org.eclipse.jface.viewers.TreeExpansionEvent; -import org.eclipse.linuxtools.systemtap.local.callgraph.StapData; -import org.eclipse.swt.widgets.ScrollBar; - -public class StapTreeListener implements ITreeViewerListener{ - private static final int INCREMENT = 15; - - private int highestLevelOfExpansion; - private ScrollBar scrollbar; - private HashMap<Integer, List<Integer>> highestLevelNodes; - //Level of recursion, list of nodes at that level currently displayed in tree - - - /** - * Autoscroll the horizontal scrollbar when there is a collapse event. - * - */ - @Override - public void treeCollapsed(TreeExpansionEvent event) { - StapData data = (StapData) event.getElement(); - if (highestLevelNodes.get(highestLevelOfExpansion) != null) { - if (highestLevelNodes.get(highestLevelOfExpansion).remove((Integer) data.id)) { - scrollbar.setSelection(scrollbar.getSelection() - INCREMENT); - // scrollbar.setMaximum(scrollbar.getMaximum() - scrollbar.getThumb() - INCREMENT); - // if (highestLevelNodes.size() == 0) { - highestLevelOfExpansion--; - // } - } - } - - } - - /** - * Autoscroll the horizontal scrollbar when there is an expand event. - * - */ - @Override - public void treeExpanded(TreeExpansionEvent event) { - StapData d = ((StapData) event.getElement()); - if (d.levelOfRecursion > highestLevelOfExpansion) { - scrollbar.setSelection(scrollbar.getSelection() + INCREMENT); - highestLevelOfExpansion = ((StapData) event.getElement()).levelOfRecursion; - } - - int lvl = d.levelOfRecursion; - if (highestLevelNodes.get(lvl) == null) - highestLevelNodes.put(lvl, new ArrayList<Integer>()); - highestLevelNodes.get(lvl).add(d.id); - } - - public StapTreeListener(ScrollBar bar) { - this.highestLevelOfExpansion=0; - this.scrollbar = bar; - highestLevelNodes = new HashMap<Integer, List<Integer>>(); - } -} |