Package com.onpositive.gae.profiler

Source Code of com.onpositive.gae.profiler.ProfilingAction$CaptureSnapshot

package com.onpositive.gae.profiler;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.FileEditorInput;

import com.onpositive.gae.profiler.core.TakeSnapshot;

public class ProfilingAction implements IWorkbenchWindowActionDelegate,
    IWorkbenchWindowPulldownDelegate2 {

  public static final class CaptureSnapshot implements Runnable {
    private final TakeSnapshot takeSnapshot;

    CaptureSnapshot(TakeSnapshot takeSnapshot) {
      this.takeSnapshot = takeSnapshot;
    }

    public void run() {
      IWorkbenchWindow activeWorkbenchWindow = PlatformUI
          .getWorkbench()
          .getActiveWorkbenchWindow();
      if (activeWorkbenchWindow == null) {
        activeWorkbenchWindow = PlatformUI
            .getWorkbench()
            .getWorkbenchWindows()[0];
      }
      IWorkbenchPage activePage = activeWorkbenchWindow
          .getActivePage();
      if (activePage == null) {
        activePage = activeWorkbenchWindow
            .getPages()[0];
      }

      try {
        activePage
            .openEditor(new FileEditorInput(
                takeSnapshot.getFile()),
                "com.onpositive.gae.profiler.editor1");
      } catch (PartInitException e) {
        Activator.getDefault().log(e);
      }
    }
  }

  public void dispose() {

  }

  public void init(IWorkbenchWindow window) {

  }

  public void run(IAction action) {

  }

  public void selectionChanged(IAction action, ISelection selection) {

  }

  public Menu getMenu(Menu parent) {
    return null;
  }

  public Menu getMenu(Control parent) {
    MenuManager man = new MenuManager();
    man.add(new Action("Start Profiling") {

      public void run() {
        new StartProfilingAction().run(null);
      }
    });
    man.add(new Action("Stop Profiling") {
      public void run() {
        new StopProfilingAction().run(null);
      }
    });
    man.add(new CaptureSnapshotAction("Capture snapshot"));
    man.add(new ClearProfilingDataAction("Clear profiling data"));   
    return man.createContextMenu(parent);
  }

}
TOP

Related Classes of com.onpositive.gae.profiler.ProfilingAction$CaptureSnapshot

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.