[Esbox-commits] r407 - in trunk: org.indt.esbox.python.launch/src/org/indt/esbox/python/launch org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/core org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/ui org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind org.indt.esbox.ui/src/org/indt/esbox/ui/views org.indt.esbox.ui/src/org/indt/esbox/ui/wizards
raul at garage.maemo.org
raul at garage.maemo.org
Thu Feb 14 21:39:05 EET 2008
Author: raul
Date: 2008-02-14 21:38:59 +0200 (Thu, 14 Feb 2008)
New Revision: 407
Added:
trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/ui/OProfileMainTab.java
Modified:
trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/AbstractLaunchShortcut.java
trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/core/AbstractConfigurationDelegate.java
trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/core/ESboxPythonLaunchConstants.java
trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/ui/MainModuleTab.java
trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile/OProfilePythonConfigurationDelegate.java
trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile/OProfilePythonConfigurationTabGroup.java
trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile/OProfilePythonShortcut.java
trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationDelegate.java
trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonLaunchShortcut.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/views/OProfileView.java
trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/DeployDebianPackageWizard.java
Log:
bugs fixed.
Modified: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/AbstractLaunchShortcut.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/AbstractLaunchShortcut.java 2008-02-14 19:28:34 UTC (rev 406)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/AbstractLaunchShortcut.java 2008-02-14 19:38:59 UTC (rev 407)
@@ -148,9 +148,7 @@
return file.getRawLocation().toString();
}
- protected String getLaunchConfigurationType() {
- return ESboxPythonLaunchConstants.ID_ESBOX_REMOTE_LAUNCH_CONFIGURATION_TYPE;
- }
+ protected abstract String getLaunchConfigurationType();
protected ILaunchConfiguration createDefaultLaunchConfiguration(IResource resource) {
String projName = resource.getProject().getName();
Modified: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/core/AbstractConfigurationDelegate.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/core/AbstractConfigurationDelegate.java 2008-02-14 19:28:34 UTC (rev 406)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/core/AbstractConfigurationDelegate.java 2008-02-14 19:38:59 UTC (rev 407)
@@ -153,7 +153,7 @@
}
public static String getProgramName(ILaunchConfiguration configuration) throws CoreException {
- return configuration.getAttribute(ESboxPythonLaunchConstants.ATTR_PROGRAM_NAME, (String)null);
+ return configuration.getAttribute(ESboxPythonLaunchConstants.ATTR_LOCATION, (String)null);
}
public static String getInterpreter(ILaunchConfiguration configuration) throws CoreException {
Modified: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/core/ESboxPythonLaunchConstants.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/core/ESboxPythonLaunchConstants.java 2008-02-14 19:28:34 UTC (rev 406)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/core/ESboxPythonLaunchConstants.java 2008-02-14 19:38:59 UTC (rev 407)
@@ -26,6 +26,8 @@
public static final String ESBOX_RUN_LAUNCH_GROUP = "org.indt.esbox.python.launch.launchGroup.run";
public static final String ID_ESBOX_LAUNCH_CONFIGURATION_TYPE = "esboxPythonLocalLaunchType";
public static final String ID_ESBOX_REMOTE_LAUNCH_CONFIGURATION_TYPE = "esboxPythonRemoteLaunchType";
+ public static final String ID_ESBOX_VALGRIND_LAUNCH_CONFIGURATION_TYPE = "esboxPythonValgrindLaunchType";
+ public static final String ID_ESBOX_OPROFILE_LAUNCH_CONFIGURATION_TYPE = "esboxPythonOProfileLaunchType";
public static final String PROCESS_TYPE = "ESBOX.PYTHON";
public static final String ATTR_VM_ARGUMENTS = "org.indt.esbox.debug.vm.arguments";
Modified: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/ui/MainModuleTab.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/ui/MainModuleTab.java 2008-02-14 19:28:34 UTC (rev 406)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/ui/MainModuleTab.java 2008-02-14 19:38:59 UTC (rev 407)
@@ -81,10 +81,6 @@
private Text projectText, mainModuleText;
private Button browseProjectButton, browseModuleButton;
-
-// private Button desktopButton;
-//
-// private Button consoleButton;
protected Button fRunStandaloneButton;
@@ -104,7 +100,6 @@
composite.setLayout(gridLayout);
this.createProjectEditor(composite);
-// this.createProgramEditor(composite);
fRunStandaloneButton = createCheckButton(composite, "Run with \"run-standalone.sh\" script"); //$NON-NLS-1$
}
@@ -149,15 +144,6 @@
} catch (CoreException e) {
projectText.setText("");
}
-
-// try {
-// boolean desktopApplication = _configuration.getAttribute(ESboxPythonLaunchConstants.ATTR_DESKTOP_APPLICATION, true);
-// desktopButton.setSelection(desktopApplication == true);
-// consoleButton.setSelection(desktopApplication == false);
-// } catch (CoreException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
fRunStandaloneButton.addSelectionListener(new SelectionAdapter() {
@@ -179,10 +165,7 @@
value = mainModuleText.getText().trim();
this.setAttribute(_conf, ESboxPythonLaunchConstants.ATTR_LOCATION, value);
-
-// _conf.setAttribute(ESboxPythonLaunchConstants.ATTR_DESKTOP_APPLICATION, desktopButton.getSelection());
-
-// boolean val = fRunStandaloneButton.get;
+
_conf.setAttribute(ESboxPythonLaunchConstants.ATTR_RUN_STANDALONE, fRunStandaloneButton.getSelection());
}
@@ -283,27 +266,6 @@
});
}
-// private void createProgramEditor(final Composite _parent) {
-// Group group = new Group(_parent, SWT.NONE);
-// Font font = _parent.getFont();
-// GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
-// GridLayout gridLayout = new GridLayout();
-//
-// group.setText("Program to Run");
-// group.setFont(font);
-// group.setLayoutData(gridData);
-// gridLayout.numColumns = 1;
-// group.setLayout(gridLayout);
-//
-// desktopButton = new Button(group, SWT.RADIO);
-// desktopButton.setText("Run a desktop application");
-// desktopButton.addSelectionListener(widgetListener);
-//
-// consoleButton = new Button(group, SWT.RADIO);
-// consoleButton.setText("Run a console application");
-// consoleButton.addSelectionListener(widgetListener);
-// }
-
/**
* sets attributes in the working copy
*/
Added: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/ui/OProfileMainTab.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/ui/OProfileMainTab.java (rev 0)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/ui/OProfileMainTab.java 2008-02-14 19:38:59 UTC (rev 407)
@@ -0,0 +1,392 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT.
+ * 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:
+ * Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *******************************************************************************/
+package org.indt.esbox.python.launch.internal.ui;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Font;
+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.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+import org.indt.esbox.core.CoreActivator;
+import org.indt.esbox.core.ESboxPreferenceConstants;
+import org.indt.esbox.core.ESboxPythonProjectNature;
+import org.indt.esbox.python.launch.PythonLaunchActivator;
+import org.indt.esbox.python.launch.internal.core.ESboxPythonLaunchConstants;
+import org.python.pydev.ui.dialogs.PythonModulePickerDialog;
+
+/**
+ *
+ */
+public class OProfileMainTab extends AbstractLaunchConfigurationTab {
+
+ WidgetListener widgetListener = new WidgetListener();
+
+ protected ModifyListener modifyListener = new ModifyListener() {
+ public void modifyText(final ModifyEvent _event) {
+ if(_event.getSource() == mainModuleText){
+ File file = new File(mainModuleText.getText());
+ if(!file.isFile()){
+ setErrorMessage("The file in the Main Module does not exist.");
+ }
+ }
+ updateLaunchConfigurationDialog();
+ }
+ };
+
+ private Text projectText, mainModuleText;
+
+ private Button browseProjectButton, browseModuleButton;
+
+ protected Text fLocalMountPoint;
+
+ protected Text fRemoteMountPoint;
+
+ protected Button fRunStandaloneButton;
+
+ protected Button fCopyBinsButton;
+
+ public OProfileMainTab() {
+ }
+
+ /**
+ * creates the widgets
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite _parent) {
+ Composite composite = new Composite(_parent, SWT.NONE);
+ GridLayout gridLayout = new GridLayout ();
+
+ super.setControl(composite);
+ gridLayout.numColumns = 1;
+ composite.setLayout(gridLayout);
+
+ this.createProjectEditor(composite);
+
+ createTexts(composite);
+
+ fRunStandaloneButton = createCheckButton(composite, "Run with \"run-standalone.sh\" script");
+ fCopyBinsButton = createCheckButton(composite, "Copy binary to local mount point");
+ }
+
+ /**
+ * ok, choose project button just pressed
+ */
+ public void handleProjectButtonSelected() {
+ IProject project = this.chooseProject();
+ if (project == null) {
+ return;
+ }
+
+ boolean isESboxProject = ESboxPythonProjectNature.isESboxPythonProject(project);
+ if(!isESboxProject){
+ //the project does not have an associated python nature...
+ String msg = "The selected project must have the ESbox Python nature associated.";
+ String title = "Invalid project (no ESbox Python nature associated).";
+ ErrorDialog.openError(getShell(), title, msg,
+ new Status(IStatus.ERROR,PythonLaunchActivator.PLUGIN_ID,IStatus.ERROR,msg,null));
+ return;
+ }
+
+ projectText.setText(project.getName());
+
+ }
+
+ public void setDefaults(final ILaunchConfigurationWorkingCopy _configuration) {
+ //Default values are being defined at the method initializeFrom.
+ }
+
+ public void initializeFrom(final ILaunchConfiguration _configuration) {
+ try {
+ String location = _configuration.getAttribute(ESboxPythonLaunchConstants.ATTR_LOCATION, "");
+ mainModuleText.setText(location);
+ } catch(CoreException e) {
+ mainModuleText.setText("");
+ }
+
+ try {
+ projectText.setText(_configuration.getAttribute(ESboxPythonLaunchConstants.ATTR_PROJECT_NAME, ""));
+ } catch (CoreException e) {
+ projectText.setText("");
+ }
+
+ fRunStandaloneButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent evt) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ try {
+ fRunStandaloneButton.setSelection(_configuration.getAttribute(ESboxPythonLaunchConstants.ATTR_RUN_STANDALONE, true));
+ } catch (CoreException e) {
+ fRunStandaloneButton.setSelection(true);
+ }
+
+ fCopyBinsButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent evt) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+ try {
+ fCopyBinsButton.setSelection(_configuration.getAttribute(ESboxPythonLaunchConstants.ATTR_COPY_BINS, ESboxPythonLaunchConstants.COPY_BINS_DEFAULT));
+ } catch (CoreException e) {
+ fCopyBinsButton.setSelection(true);
+ }
+
+ initText();
+ }
+
+
+ private void initText() {
+ Preferences prefs = CoreActivator.getDefault().getPluginPreferences();
+ String sbrshBinPath = prefs.getString(ESboxPreferenceConstants.SBRSH_SELECTED_BIN_PATH.toString());
+
+ String localMounPoint = "";
+ String remoteMounPoint = "";
+ if (!sbrshBinPath.equals("")) {
+ String tokens[] = sbrshBinPath.split("#");
+ localMounPoint = tokens[1];
+ remoteMounPoint = tokens[2];
+ }
+
+ fLocalMountPoint.setText(localMounPoint);
+ fRemoteMountPoint.setText(remoteMounPoint);
+ }
+
+ public void performApply(final ILaunchConfigurationWorkingCopy _conf) {
+ String value;
+ value = projectText.getText().trim();
+ this.setAttribute(_conf, ESboxPythonLaunchConstants.ATTR_PROJECT_NAME, value);
+
+ value = mainModuleText.getText().trim();
+ this.setAttribute(_conf, ESboxPythonLaunchConstants.ATTR_LOCATION, value);
+
+ _conf.setAttribute(ESboxPythonLaunchConstants.ATTR_RUN_STANDALONE, fRunStandaloneButton.getSelection());
+
+ _conf.setAttribute(ESboxPythonLaunchConstants.ATTR_COPY_BINS, fCopyBinsButton.getSelection());
+ }
+
+
+ /**
+ * the name for this tab
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
+ */
+ public String getName() {
+ return "Main";
+ }
+
+ /**
+ * make a dialog and return a project (does no validation) and may return null.
+ */
+ private IProject chooseProject() {
+ ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), null, false, "Choose the project for the run");
+ dialog.open();
+ Object[] objects = dialog.getResult();
+ if(objects != null && objects.length == 1){
+ if(objects[0] instanceof IPath){
+ IPath p = (IPath) objects[0];
+ if(p.segmentCount() > 0){
+ String string = p.segment(0);
+ IWorkspace w = ResourcesPlugin.getWorkspace();
+ return w.getRoot().getProject(string);
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Creates the widgets for specifying a main type.
+ *
+ * @param parent the parent composite
+ */
+ private void createProjectEditor(final Composite parent) {
+ Font font= parent.getFont();
+ Group group= new Group(parent, SWT.NONE);
+ group.setText("Project");
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ group.setLayoutData(gd);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ group.setLayout(layout);
+ group.setFont(font);
+
+ // Project chooser
+ projectText = new Text(group, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ projectText.setLayoutData(gd);
+ projectText.setFont(font);
+ projectText.addModifyListener(widgetListener);
+
+ browseProjectButton = createPushButton(group, "Browse...", null); //$NON-NLS-1$
+ browseProjectButton.addSelectionListener(widgetListener);
+
+ // Main module group
+ group= new Group(parent, SWT.NONE);
+ group.setText("Main Module");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ group.setLayoutData(gd);
+ layout = new GridLayout();
+ layout.numColumns = 2;
+ group.setLayout(layout);
+ group.setFont(font);
+
+ // Main module chooser
+ mainModuleText = new Text (group, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ mainModuleText.setLayoutData (gd);
+ mainModuleText.setFont(font);
+ mainModuleText.addModifyListener(modifyListener);
+
+ browseModuleButton = createPushButton(group, "Browse...", null);
+ browseModuleButton.setText("Browse");
+ browseModuleButton.setEnabled(false);
+ browseModuleButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ IProject project = getProjectFromTextWidget();
+ PythonModulePickerDialog dialog = new PythonModulePickerDialog(
+ parent.getShell(),
+ "Main Module",
+ "Choose Python module which starts execution",
+ project);
+ int result = dialog.open();
+
+ if(result == PythonModulePickerDialog.OK) {
+ Object results[] = dialog.getResult();
+ System.out.println("Results:" + results.length);
+ if(results.length == 1) {
+ IFile file = (IFile) results[0];
+ mainModuleText.setText(file.getRawLocation().toOSString());
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ * sets attributes in the working copy
+ */
+ private void setAttribute(final ILaunchConfigurationWorkingCopy _conf, final String _name, final String _value) {
+ if (_value == null || _value.length() == 0){
+ _conf.setAttribute(_name, (String)null);
+ } else {
+ _conf.setAttribute(_name, _value);
+ }
+ }
+
+ /**
+ * @return
+ */
+ private IProject getProjectFromTextWidget() {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IResource project = workspace.getRoot().findMember(projectText.getText());
+ if(project instanceof IProject){
+ return (IProject) project;
+ }
+ return null;
+ }
+
+ @Override
+ public Image getImage() {
+ return PythonLaunchActivator.getImageCache().get("icons/python.gif");
+ }
+
+ protected void createTexts(Composite parent) {
+ Composite entriesGroup = new Composite(parent, SWT.NONE);
+ entriesGroup.setLayout(new GridLayout(5, false));
+ entriesGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 4;
+ data.minimumWidth = 240;
+
+ Label labelLocal = new Label(entriesGroup,SWT.NONE);
+ labelLocal.setText("Local Mount Point:");
+ fLocalMountPoint = new Text(entriesGroup, SWT.BORDER);
+ fLocalMountPoint.setLayoutData(data);
+ fLocalMountPoint.setFont(parent.getFont());
+ fLocalMountPoint.setEditable(false);
+
+ Label labelRemote = new Label(entriesGroup,SWT.NONE);
+ labelRemote.setText("Remote Mount Point:");
+ fRemoteMountPoint = new Text(entriesGroup, SWT.BORDER);
+ fRemoteMountPoint.setLayoutData(data);
+ fRemoteMountPoint.setFont(parent.getFont());
+ fRemoteMountPoint.setEditable(false);
+
+ }
+
+ private class WidgetListener extends SelectionAdapter implements ModifyListener, SelectionListener {
+
+ public void modifyText(final ModifyEvent _event) {
+ setErrorMessage(null);
+ setMessage(null);
+ browseModuleButton.setEnabled(false);
+
+ Object source = _event.getSource();
+ if(source == projectText){
+ IProject project = getProjectFromTextWidget();
+
+ if(project == null){
+ setErrorMessage("invalid project");
+ } else {
+ boolean isESboxProject = ESboxPythonProjectNature.isESboxPythonProject((IProject)project);
+ if(!isESboxProject){
+ setErrorMessage("Invalid project (no python nature associated).");
+ }
+ browseModuleButton.setEnabled(true);
+ }
+ updateLaunchConfigurationDialog();
+ }else{
+ updateLaunchConfigurationDialog();
+ }
+ }
+
+ public void widgetSelected(final SelectionEvent _event) {
+ Object source = _event.getSource();
+ if (source == browseProjectButton) {
+ handleProjectButtonSelected();
+ }else{
+ updateLaunchConfigurationDialog();
+ }
+ }
+
+ }
+
+
+}
Modified: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile/OProfilePythonConfigurationDelegate.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile/OProfilePythonConfigurationDelegate.java 2008-02-14 19:28:34 UTC (rev 406)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile/OProfilePythonConfigurationDelegate.java 2008-02-14 19:38:59 UTC (rev 407)
@@ -10,27 +10,40 @@
*******************************************************************************/
package org.indt.esbox.python.launch.oprofile;
+import java.io.File;
+import java.util.ArrayList;
import java.util.List;
+import org.eclipse.cdt.core.CommandLauncher;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Preferences;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
+import org.indt.esbox.core.CoreActivator;
import org.indt.esbox.core.ESboxException;
-import org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher;
+import org.indt.esbox.core.ESboxPreferenceConstants;
+import org.indt.esbox.core.ErrorLogger;
+import org.indt.esbox.core.scratchbox.ESboxCommonCommandLauncher;
import org.indt.esbox.core.tool.ESboxToolEngine;
import org.indt.esbox.core.tool.ITool;
import org.indt.esbox.core.tool.IToolListener;
import org.indt.esbox.core.tool.ToolRunnerInfo;
-import org.indt.esbox.core.tool.valgrind.ValgrindToolRunner;
+import org.indt.esbox.core.tool.oprofile.OPreportToolRunner;
import org.indt.esbox.python.launch.PythonLaunchActivator;
import org.indt.esbox.python.launch.internal.core.AbstractConfigurationDelegate;
import org.indt.esbox.python.launch.internal.core.ESboxPythonLaunchConstants;
import org.indt.esbox.ui.UIActivator;
+import org.indt.esbox.ui.dialogs.PasswordInputDialog;
/**
*
@@ -56,37 +69,119 @@
monitor = new NullProgressMonitor();
}
- monitor.beginTask("Launching the application on Device", 10);
+ monitor.beginTask("Running OProfile on Device", 10);
+
// check for cancellation
if (monitor.isCanceled()) {
return;
}
IPath exePath = verifyProgramPath(configuration);
+ IProject project = verifyProject(configuration);
- ITool valgrind = ESboxToolEngine.getInstance().getTool("Valgrind")[0];
- ToolRunnerInfo valgrindInfo = null;
+ File wd = getWorkingDirectory(configuration);
+ if (wd == null) {
+ wd = new File(System.getProperty("user.home", ".")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
- try {
- valgrindInfo = valgrind.getProvider().getRunner().createToolRunnerInfo();
- } catch (ESboxException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Preferences prefs = CoreActivator.getDefault().getPluginPreferences();
+ String sbrshBinPath = prefs.getString(ESboxPreferenceConstants.SBRSH_SELECTED_BIN_PATH.toString());
+
+ String localMountPoint = "";
+ String remoteMounPoint = "";
+ if (!sbrshBinPath.equals("")) {
+ String tokens[] = sbrshBinPath.split("#");
+ localMountPoint = tokens[1];
+ remoteMounPoint = tokens[2];
}
- boolean isRunStandalone = configuration.getAttribute(ESboxPythonLaunchConstants.ATTR_RUN_STANDALONE, ESboxPythonLaunchConstants.RUN_STANDALONE_DEFAULT);
+ boolean isRunStandalone = configuration.getAttribute(ESboxPythonLaunchConstants.ATTR_RUN_STANDALONE, ESboxPythonLaunchConstants.RUN_STANDALONE_DEFAULT);
+ boolean copyBinary = configuration.getAttribute(ESboxPythonLaunchConstants.ATTR_COPY_BINS, ESboxPythonLaunchConstants.COPY_BINS_DEFAULT);
+ if (copyBinary) {
+ try {
+ copyFile(exePath.toOSString(),localMountPoint + File.separatorChar + exePath.lastSegment());
+ } catch (InterruptedException e) {
+ ErrorLogger errorLogger = PythonLaunchActivator.getDefault().getErrorLogger();
+ errorLogger.logAndShowError("Scratchbox error", e);
+ }
+ }
+
+ monitor.worked(2);
+
+ IPath command = new Path(prefs.getString(ESboxPreferenceConstants.SBRSH_EXEC_FILE_LOCATION.toString()));
+ ESboxCommonCommandLauncher launcher = new ESboxCommonCommandLauncher();
+ String program = isRunStandalone ? "run-standalone.sh " : "" + "./" + exePath.lastSegment();
+ String args[] = new String[] { "-d", remoteMounPoint, program };
+
+ String password = promptPassword();
+ if (password == null)
+ return;
+
+ try{
+ monitor.worked(4);
- String args[] = new String[] { "-q --tool=memcheck --leak-check=yes", isRunStandalone ? "run-standalone.sh " : "" , exePath.toOSString() };
+ startOProfile(password);
+ monitor.worked(6);
+
+ Process process = launcher.execute(command, args, new String[] { }, new Path(wd.getAbsolutePath()));
+ DebugPlugin.newProcess(launch, process, renderProcessLabel(exePath.toOSString()));
+
+ monitor.worked(8);
+ stopOProfile(password);
+
+ monitor.worked(9);
+ runOPreport();
+ } catch (ESboxException e) {
+ e.printStackTrace();
+ }
- List<String> cmdArray = valgrindInfo.getCommandLine();
- for (int i = 0; i < args.length; i++) {
- cmdArray.add(args[i]);
- }
+ monitor.worked(10);
+ }
+
+ private void startOProfile(String password) throws ESboxException {
+ ESboxCommonCommandLauncher launcher = new ESboxCommonCommandLauncher();
+ ITool oprofile = ESboxToolEngine.getInstance().getTool("OProfile")[0];
+ ToolRunnerInfo oprofileInfo = oprofile.getProvider().getRunner().createToolRunnerInfo();
+ changeToolInfo(oprofileInfo,password);
+
+ List<String> cmdLine = oprofileInfo.getCommandLine();
+ cmdLine.add("--init");
+ Process process = launcher.execute(oprofileInfo);
+ oprofile.getProvider().getRunner().trackProcess(process);
+
+ cmdLine.remove(cmdLine.size() - 1);
+ cmdLine.add("--no-vmlinux");
+ process = launcher.execute(oprofileInfo);
+ oprofile.getProvider().getRunner().trackProcess(process);
+
+ cmdLine.remove(cmdLine.size() - 1);
+ cmdLine.add("--start");
+ process = launcher.execute(oprofileInfo);
+ oprofile.getProvider().getRunner().trackProcess(process);
+
+ }
+
+ private void stopOProfile(String password) throws ESboxException {
+ ESboxCommonCommandLauncher launcher = new ESboxCommonCommandLauncher();
+
+ ITool oprofile = ESboxToolEngine.getInstance().getTool("OProfile")[0];
+ ToolRunnerInfo oprofileInfo = oprofile.getProvider().getRunner().createToolRunnerInfo();
+ changeToolInfo(oprofileInfo,password);
+
+ List<String> cmdLine = oprofileInfo.getCommandLine();
+ cmdLine.add("--stop");
+ Process process = launcher.execute(oprofileInfo);
+ oprofile.getProvider().getRunner().trackProcess(process);
+
+ }
+
+ private void runOPreport() throws ESboxException {
+
PythonLaunchActivator.getDefault().getWorkbench().getDisplay().syncExec(new Runnable() {
public void run() {
try {
- ValgrindToolRunner.getInstance().addListener((IToolListener)UIActivator.getDefault().getView("org.indt.esbox.ui.views.valgrindView"));
+ OPreportToolRunner.getInstance().addListener((IToolListener)UIActivator.getDefault().getView("org.indt.esbox.ui.views.oProfileView"));
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -94,19 +189,82 @@
}
});
- ScratchboxCommandLauncher launcher = new ScratchboxCommandLauncher();
- Process process = launcher.execute(valgrindInfo);
- try {
- valgrind.getProvider().getRunner().trackProcess(process);
- } catch (ESboxException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ ESboxCommonCommandLauncher launcher = new ESboxCommonCommandLauncher();
+ Preferences prefs = CoreActivator.getDefault().getPluginPreferences();
+ IPath command = new Path(prefs.getString(ESboxPreferenceConstants.SBRSH_EXEC_FILE_LOCATION.toString()));
+
+ final ITool oprofile = ESboxToolEngine.getInstance().getTool("OPreport")[0];
+ ToolRunnerInfo opreportInfo = oprofile.getProvider().getRunner().createToolRunnerInfo();
+
+ List<String> cmdLine = opreportInfo.getCommandLine();
+ cmdLine.add(0, command.toOSString());
+ cmdLine.add("-a");
+ cmdLine.add("-l");
+ cmdLine.add("-g");
+ final Process process = launcher.execute(opreportInfo);
+
+ oprofile.getProvider().getRunner().trackProcess(process);
+ }
+
+ private void copyFile(String src, String dst) throws InterruptedException {
+ CommandLauncher launcher = new CommandLauncher();
+ Process process = launcher.execute(new Path("cp"), new String[] {src, dst} , new String[] {} , new Path("."));
+
+ process.waitFor();
+ }
+
+ private void changeToolInfo(ToolRunnerInfo info, String password) {
+ Preferences prefs = CoreActivator.getDefault().getPluginPreferences();
+ String sbrshBinPath = prefs.getString(ESboxPreferenceConstants.SBRSH_SELECTED_BIN_PATH.toString());
+
+ String remoteMounPoint = "";
+ if (!sbrshBinPath.equals("")) {
+ String tokens[] = sbrshBinPath.split("#");
+ remoteMounPoint = tokens[2];
}
- monitor.worked(3);
- DebugPlugin.newProcess(launch, process, renderProcessLabel(exePath.toOSString()));
-
-
+ IPath command = new Path(prefs.getString(ESboxPreferenceConstants.SBRSH_EXEC_FILE_LOCATION.toString()));
+ String args[] = new String[] { "echo", "\"" + password + "\"", "|", "sudo", "-S", command.toOSString(), "-d", remoteMounPoint };
+ List<String> listArgs = new ArrayList<String>();
+ for (String string : args) {
+ listArgs.add(string);
+ }
+
+ info.getCommandLine().addAll(0, listArgs);
}
+
+ private String promptPassword() {
+ PasswordDialog runnable = new PasswordDialog();
+ PythonLaunchActivator.getDefault().getWorkbench().getDisplay().syncExec(runnable);
+
+ return runnable.getPassword();
+ }
+
+ private Shell getShell() {
+ return UIActivator.getDefault().getWorkbench().getDisplay().getActiveShell();
+ }
+
+ class PasswordDialog implements Runnable {
+
+ private String password;
+
+ public void run() {
+ // TODO Auto-generated method stub
+ IWorkbenchWindow window = PythonLaunchActivator.getDefault().getWorkbench().getActiveWorkbenchWindow();
+ Shell shell = null;
+
+ if (window != null)
+ shell = window.getShell();
+
+ PasswordInputDialog dialog = new PasswordInputDialog(getShell(),"Password","Insert root password to execute commands with superuser privileges");
+ if (dialog.open() == Window.OK)
+ password = dialog.getPassword();
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ }
}
Modified: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile/OProfilePythonConfigurationTabGroup.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile/OProfilePythonConfigurationTabGroup.java 2008-02-14 19:28:34 UTC (rev 406)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile/OProfilePythonConfigurationTabGroup.java 2008-02-14 19:38:59 UTC (rev 407)
@@ -12,6 +12,8 @@
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.indt.esbox.python.launch.internal.ui.OProfileMainTab;
/**
*
@@ -23,8 +25,9 @@
* @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
*/
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
- // TODO Auto-generated method stub
-
+ ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
+ new OProfileMainTab()};
+ setTabs(tabs);
}
}
Modified: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile/OProfilePythonShortcut.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile/OProfilePythonShortcut.java 2008-02-14 19:28:34 UTC (rev 406)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile/OProfilePythonShortcut.java 2008-02-14 19:38:59 UTC (rev 407)
@@ -48,6 +48,10 @@
*/
public class OProfilePythonShortcut extends AbstractLaunchShortcut {
+ protected String getLaunchConfigurationType() {
+ return ESboxPythonLaunchConstants.ID_ESBOX_OPROFILE_LAUNCH_CONFIGURATION_TYPE;
+ }
+
/**
* Launch the given targets in the given build file. The targets are
* launched in the given mode.
Modified: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationDelegate.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationDelegate.java 2008-02-14 19:28:34 UTC (rev 406)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationDelegate.java 2008-02-14 19:38:59 UTC (rev 407)
@@ -57,17 +57,20 @@
monitor = new NullProgressMonitor();
}
- monitor.beginTask("Launching the application on Device", 10);
+ monitor.beginTask("Running Valgrind profiler", 8);
+
// check for cancellation
if (monitor.isCanceled()) {
return;
}
- IPath exePath = verifyProgramPath(configuration);
+ IPath exePath = super.verifyProgramPath(configuration);
ITool valgrind = ESboxToolEngine.getInstance().getTool("Valgrind")[0];
ToolRunnerInfo valgrindInfo = null;
+ monitor.worked(2);
+
try {
valgrindInfo = valgrind.getProvider().getRunner().createToolRunnerInfo();
} catch (ESboxException e) {
@@ -84,6 +87,8 @@
cmdArray.add(args[i]);
}
+ monitor.worked(4);
+
PythonLaunchActivator.getDefault().getWorkbench().getDisplay().syncExec(new Runnable() {
public void run() {
try {
@@ -104,9 +109,10 @@
e.printStackTrace();
}
- monitor.worked(3);
+ monitor.worked(6);
DebugPlugin.newProcess(launch, process, renderProcessLabel(exePath.toOSString()));
+ monitor.worked(8);
}
}
Modified: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonLaunchShortcut.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonLaunchShortcut.java 2008-02-14 19:28:34 UTC (rev 406)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonLaunchShortcut.java 2008-02-14 19:38:59 UTC (rev 407)
@@ -10,43 +10,24 @@
*******************************************************************************/
package org.indt.esbox.python.launch.valgrind;
-import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.ui.CommonTab;
import org.eclipse.debug.ui.DebugUITools;
-import org.eclipse.debug.ui.IDebugUIConstants;
-import org.eclipse.debug.ui.ILaunchShortcut;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.indt.esbox.python.launch.AbstractLaunchShortcut;
import org.indt.esbox.python.launch.PythonLaunchActivator;
import org.indt.esbox.python.launch.internal.core.ESboxPythonLaunchConstants;
-import org.python.pydev.ui.NotConfiguredInterpreterException;
/**
*
*/
public class ValgrindPythonLaunchShortcut extends AbstractLaunchShortcut {
+ protected String getLaunchConfigurationType() {
+ return ESboxPythonLaunchConstants.ID_ESBOX_VALGRIND_LAUNCH_CONFIGURATION_TYPE;
+ }
+
/**
* Launch the given targets in the given build file. The targets are
* launched in the given mode.
Modified: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/views/OProfileView.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/views/OProfileView.java 2008-02-14 19:28:34 UTC (rev 406)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/views/OProfileView.java 2008-02-14 19:38:59 UTC (rev 407)
@@ -211,7 +211,7 @@
}
public void initTable() {
- columnNames = new String[] { "Samples", "Cum. Samples (%)", "%", "Cum. (%)", "Line Info", "Image Name", "Application Name", "Symbol Name" };
+ columnNames = new String[] { "Samples", "Cum. Samples (%)", "%", "Cum. (%)", "Line Info", "Application Name", "Symbol Name" };
columns = new TableColumn[columnNames.length];
for(int i = 0; i < columnNames.length; i++) {
Modified: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/DeployDebianPackageWizard.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/DeployDebianPackageWizard.java 2008-02-14 19:28:34 UTC (rev 406)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/DeployDebianPackageWizard.java 2008-02-14 19:38:59 UTC (rev 407)
@@ -93,7 +93,7 @@
// print all output to console
new StreamMonitor(process.getInputStream(), true, "Installing .deb package");
// print all errors to console
- new StreamMonitor(process.getErrorStream(), true, "Installing .deb package");
+ new StreamMonitor(process.getErrorStream(), false, "Installing .deb package");
try {
process.waitFor();
} catch (InterruptedException e) {
More information about the Esbox-commits
mailing list