[Esbox-commits] r395 - in trunk: org.indt.esbox.python.debug/src/org/indt/esbox/python/debug/debugger org.indt.esbox.python.launch 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/local org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/remote org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind
raul at garage.maemo.org
raul at garage.maemo.org
Tue Jan 29 14:26:33 EET 2008
Author: raul
Date: 2008-01-29 14:26:23 +0200 (Tue, 29 Jan 2008)
New Revision: 395
Added:
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/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/valgrind/ValgrindPythonConfigurationDelegate.java
trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationTabGroup.java
Modified:
trunk/org.indt.esbox.python.debug/src/org/indt/esbox/python/debug/debugger/ESboxPythonDebugger.java
trunk/org.indt.esbox.python.launch/plugin.xml
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/MainRemoteModuleTab.java
trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/local/ESboxPythonLaunchConfigurationDelegate.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/remote/ESboxPythonRemoteConfigurationDelegate.java
trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonLaunchShortcut.java
Log:
Python remote debugging is implemented, but not tested. New launch elements (oprofile and valgrind)
Modified: trunk/org.indt.esbox.python.debug/src/org/indt/esbox/python/debug/debugger/ESboxPythonDebugger.java
===================================================================
--- trunk/org.indt.esbox.python.debug/src/org/indt/esbox/python/debug/debugger/ESboxPythonDebugger.java 2008-01-27 18:13:23 UTC (rev 394)
+++ trunk/org.indt.esbox.python.debug/src/org/indt/esbox/python/debug/debugger/ESboxPythonDebugger.java 2008-01-29 12:26:23 UTC (rev 395)
@@ -65,6 +65,10 @@
*/
public class ESboxPythonDebugger {
+ public static final String DEFAULT_LOCAL_CLIENT_IP = "127.0.0.1";
+
+ private String[] debugScripts;
+
/**
* Singleton pattern.
*/
@@ -74,8 +78,27 @@
* Constructor.
* @throws CoreException
*/
- private ESboxPythonDebugger() { }
+ private ESboxPythonDebugger() {
+ initDebugScriptList();
+
+ }
+ private void initDebugScriptList() {
+ debugScripts = new String[] {
+ "pydevd_additional_thread_info.py",
+ "pydevd_comm.py",
+ "pydevd_constants.py",
+ "pydevd_file_utils.py",
+ "pydevd_frame.py",
+ "pydevd_io.py",
+ "pydevd_resolver.py",
+ "pydevd_tracing.py",
+ "pydevd_vars.py",
+ "pydevd_vm_type.py",
+ "pydevd.py"
+ };
+ }
+
/**
* Returns a unique instance of ESboxPythonDebugger
*/
@@ -88,7 +111,7 @@
public void debugPython(IProject project, String mode, ILaunch launch, IProgressMonitor monitor,
IPath exePath, String arguments, String[] vmArgumentsArray, String vmArguments,
- boolean isRunStandalone) throws CoreException, IOException {
+ String clientIP, boolean isRunStandalone) throws CoreException, IOException {
String location = project.getLocation().toOSString();
String projectName = project.getName();
ILaunchConfiguration configuration = createDefaultLaunchConfiguration("esboxPythonLocalLaunchType",
@@ -100,14 +123,17 @@
IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 5);
subMonitor.beginTask("Launching python", 1);
- copyDebugScriptsToWorkspace();
+ if (clientIP.equals(DEFAULT_LOCAL_CLIENT_IP))
+ copyDebugScriptsToWorkspace();
+ else
+ copyDebugScriptsToDevice();
// Launch & connect to the debugger
RemoteDebugger debugger = new RemoteDebugger(pythonConfiguration);
debugger.startConnect(subMonitor);
subMonitor.subTask("Constructing command_line...");
String cmdLine = getCommandLineAsString(pythonConfiguration, vmArgumentsArray, arguments,
- exePath.toOSString(), isRunStandalone);
+ exePath.toOSString(), clientIP, isRunStandalone);
ScratchboxCommandLauncher launcher = new ScratchboxCommandLauncher();
Process p = launcher.execInsideSbox(cmdLine, pythonConfiguration.envp);
@@ -139,14 +165,14 @@
}
public String getCommandLineAsString(PythonRunnerConfig pythonConfiguration, String[] vmArgumentsArray, String arguments,
- String exePath, boolean isRunStandalone) throws JDTNotAvailableException, CoreException {
+ String exePath, String clientIP, boolean isRunStandalone) throws JDTNotAvailableException, CoreException {
String[] args;
- args = getCommandLine(pythonConfiguration, vmArgumentsArray, arguments, exePath, isRunStandalone);
+ args = getCommandLine(pythonConfiguration, vmArgumentsArray, arguments, exePath, clientIP, isRunStandalone);
return SimpleRunner.getCommandLineAsString(args);
}
private String[] getCommandLine(PythonRunnerConfig pythonConfiguration, String[] vmArgumentsArray, String arguments,
- String exePath, boolean isRunStandalone) throws CoreException {
+ String exePath, String clientIP, boolean isRunStandalone) throws CoreException {
List<String> cmdArgs = new ArrayList<String>();
@@ -167,7 +193,7 @@
cmdArgs.add("--vm_type");
cmdArgs.add("python");
cmdArgs.add("--client");
- cmdArgs.add("127.0.0.1");
+ cmdArgs.add(clientIP);
cmdArgs.add("--port");
cmdArgs.add(Integer.toString(pythonConfiguration.getDebugPort()));
cmdArgs.add("--file");
@@ -192,30 +218,38 @@
// TODO Auto-generated method stub
return VariablesPlugin.getDefault().getStringVariableManager();
}
+
+ private void copyDebugScriptsToDevice() {
+ Preferences prefs = CoreActivator.getDefault().getPluginPreferences();
+ String sbrshBinPath = prefs.getString(ESboxPreferenceConstants.SBRSH_SELECTED_BIN_PATH.toString());
+ String localMountPoint = "";
+ if (!sbrshBinPath.equals("")) {
+ String tokens[] = sbrshBinPath.split("#");
+ localMountPoint = tokens[1];
+ }
+
+ for (int i = 0; i < debugScripts.length; i++) {
+ verifyScript(localMountPoint + File.separatorChar + ".esbox" ,debugScripts[i]);
+ }
+ }
+
private void copyDebugScriptsToWorkspace() {
- verifyScript("pydevd_additional_thread_info.py");
- verifyScript("pydevd_comm.py");
- verifyScript("pydevd_constants.py");
- verifyScript("pydevd_file_utils.py");
- verifyScript("pydevd_frame.py");
- verifyScript("pydevd_io.py");
- verifyScript("pydevd_resolver.py");
- verifyScript("pydevd_tracing.py");
- verifyScript("pydevd_vars.py");
- verifyScript("pydevd_vm_type.py");
- verifyScript("pydevd.py");
+ Preferences preferences = CoreActivator.getDefault().getPluginPreferences();
+ String prefix = preferences.getString(ESboxPreferenceConstants.RUN_SCRIPT_LOC.toString());
+
+ for (int i = 0; i < debugScripts.length; i++) {
+ verifyScript(prefix,debugScripts[i]);
+ }
}
- private void verifyScript(String name) {
- Preferences preferences = CoreActivator.getDefault().getPluginPreferences();
- String scriptLocation = preferences.getString(ESboxPreferenceConstants.RUN_SCRIPT_LOC.toString());
- File runScript = new File(scriptLocation + File.separator + name);
+ private void verifyScript(String prefix, String name) {
+ File runScript = new File(prefix + File.separator + name);
if (!runScript.exists()) {
- File runScriptPath = new File(scriptLocation);
+ File runScriptPath = new File(prefix);
if( !runScriptPath.exists() )
runScriptPath.mkdir();
- copyScriptToWorkspace(scriptLocation + File.separator + name, name);
+ copyScriptToWorkspace(prefix + File.separator + name, name);
}
}
Modified: trunk/org.indt.esbox.python.launch/plugin.xml
===================================================================
--- trunk/org.indt.esbox.python.launch/plugin.xml 2008-01-27 18:13:23 UTC (rev 394)
+++ trunk/org.indt.esbox.python.launch/plugin.xml 2008-01-29 12:26:23 UTC (rev 395)
@@ -13,10 +13,24 @@
<launchConfigurationType
delegate="org.indt.esbox.python.launch.remote.ESboxPythonRemoteConfigurationDelegate"
id="esboxPythonRemoteLaunchType"
- modes="run"
+ modes="run,debug"
name="Python Maemo Remote Application"
public="true">
</launchConfigurationType>
+ <launchConfigurationType
+ delegate="org.indt.esbox.python.launch.oprofile.OProfilePythonConfigurationDelegate"
+ id="esboxPythonOProfileLaunchType"
+ modes="run"
+ name="OProfile Profiler"
+ public="true">
+ </launchConfigurationType>
+ <launchConfigurationType
+ delegate="org.indt.esbox.python.launch.valgrind.ValgrindPythonConfigurationDelegate"
+ id="esboxPythonValgrindLaunchType"
+ modes="run"
+ name="Valgrind Profiler"
+ public="true">
+ </launchConfigurationType>
</extension>
<extension
point="org.eclipse.debug.ui.launchConfigurationTypeImages">
@@ -30,6 +44,16 @@
icon="icons/maemo_project.png"
id="esboxPythonRemoteLaunchImage">
</launchConfigurationTypeImage>
+ <launchConfigurationTypeImage
+ configTypeID="esboxPythonOProfileLaunchType"
+ icon="icons/maemo_project.png"
+ id="esboxPythonOProfileLaunchTypeImage">
+ </launchConfigurationTypeImage>
+ <launchConfigurationTypeImage
+ configTypeID="esboxPythonValgrindLaunchType"
+ icon="icons/valgrind.png"
+ id="esboxPythonValgrindLaunchTypeImage">
+ </launchConfigurationTypeImage>
</extension>
<extension
point="org.eclipse.debug.ui.launchConfigurationTabGroups">
@@ -43,6 +67,16 @@
id="esboxPythonRemoteRunLaunchTabGroup"
type="esboxPythonRemoteLaunchType">
</launchConfigurationTabGroup>
+ <launchConfigurationTabGroup
+ class="org.indt.esbox.python.launch.oprofile.OProfilePythonConfigurationTabGroup"
+ id="esboxPythonOProfileLaunchTabGroup"
+ type="esboxPythonOProfileLaunchType">
+ </launchConfigurationTabGroup>
+ <launchConfigurationTabGroup
+ class="org.indt.esbox.python.launch.valgrind.ValgrindPythonConfigurationTabGroup"
+ id="esboxPythonValgrindLaunchTabGroup"
+ type="esboxPythonValgrindLaunchType">
+ </launchConfigurationTabGroup>
</extension>
<extension
point="org.eclipse.debug.ui.launchShortcuts">
@@ -87,7 +121,7 @@
icon="icons/maemo_project.png"
id="esboxPythonRemoteShortcut"
label="Python Maemo Remote Application"
- modes="run">
+ modes="run,debug">
<contextualLaunch>
<enablement>
<with
@@ -118,7 +152,7 @@
</perspective>
</shortcut>
<shortcut
- class="org.indt.esbox.python.launch.LaunchShortcut4"
+ class="org.indt.esbox.python.launch.valgrind.ValgrindPythonLaunchShortcut"
icon="icons/valgrind.png"
id="valgrindPythonShortcut"
label="Valgrind Profiler"
@@ -154,7 +188,7 @@
</perspective>
</shortcut>
<shortcut
- class="org.indt.esbox.python.launch.LaunchShortcut3"
+ class="org.indt.esbox.python.launch.oprofile.OProfilePythonShortcut"
icon="icons/maemo_project.png"
id="oprofilePythonShortcut"
label="OProfile Profiler"
Added: 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 (rev 0)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/AbstractLaunchShortcut.java 2008-01-29 12:26:23 UTC (rev 395)
@@ -0,0 +1,244 @@
+/*******************************************************************************
+ * 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;
+
+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.internal.core.ESboxPythonLaunchConstants;
+import org.python.pydev.ui.NotConfiguredInterpreterException;
+
+/**
+ *
+ */
+public abstract class AbstractLaunchShortcut implements ILaunchShortcut {
+
+ protected boolean fShowDialog = false; // show configuration dialog?
+
+ protected abstract void launch(IResource file, String mode, String targetAttribute);
+
+ //=============================================================================================
+ // ILaunchShortcut IMPL
+ //=============================================================================================
+ public void launch(ISelection selection, String mode) {
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection)selection;
+ Object object = structuredSelection.getFirstElement();
+ if (object instanceof IAdaptable) {
+
+ IFile resource = (IFile)((IAdaptable)object).getAdapter(IFile.class);
+ if (resource != null) {
+ launch(resource, mode, null);
+ return;
+ }
+
+ IFolder folder = (IFolder)((IAdaptable)object).getAdapter(IFolder.class);
+ if (folder != null) {
+ launch(folder, mode, null);
+ return;
+ }
+ }
+ }
+ fileNotFound();
+ }
+
+
+ public void launch(IEditorPart editor, String mode) {
+ //we have an editor to run
+ IEditorInput input = editor.getEditorInput();
+ IFile file = (IFile)input.getAdapter(IFile.class);
+ if (file != null) {
+ launch(file, mode, null);
+ return;
+ }
+ fileNotFound();
+ }
+ //=============================================================================================
+ // END ILaunchShortcut IMPL
+ //=============================================================================================
+
+ protected void fileNotFound() {
+ reportError("Unable to launch the file, not found??", null);
+ }
+
+ protected boolean verifyMode(String mode) {
+ boolean ok = mode.equals(ILaunchManager.RUN_MODE) || mode.equals(ILaunchManager.DEBUG_MODE);
+
+ if (!ok){
+ reportError("Unknown launch mode: " + mode, null);
+ }
+ return ok;
+ }
+
+
+ protected static void reportError(String message, Throwable throwable) {
+ if (message == null)
+ message = "Unexpected error";
+ IStatus status = null;
+ if (throwable instanceof CoreException) {
+ status = ((CoreException)throwable).getStatus();
+ } else {
+ status = new Status(IStatus.ERROR, "org.python.pydev.debug", 0, message, throwable);
+ }
+ ErrorDialog.openError(PythonLaunchActivator.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
+ "ESbox esbox.python.launch error", "ESbox launch failed", status);
+ }
+
+ /**
+ * COPIED/MODIFIED from AntLaunchShortcut
+ * Returns a list of existing launch configuration for the given file.
+ */
+ protected List findExistingLaunchConfigurations(IResource file) {
+ ILaunchManager manager = org.eclipse.debug.core.DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType type = manager.getLaunchConfigurationType(getLaunchConfigurationType());
+ List validConfigs = new ArrayList();
+ if (type == null)
+ return validConfigs;
+ try {
+ ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);
+ String defaultLocation = getDefaultLocation(file);
+ for (int i = 0; i < configs.length; i++) {
+ String configPath = configs[i].getAttribute(ESboxPythonLaunchConstants.ATTR_LOCATION, "");
+ if (defaultLocation.equals(configPath))
+ validConfigs.add(configs[i]);
+ }
+ } catch (CoreException e) {
+ reportError("Unexpected error", e);
+ }
+ return validConfigs;
+ }
+
+ /**
+ * @param file
+ * @return default string for the location field
+ */
+ public static String getDefaultLocation (IResource file) {
+ return file.getRawLocation().toString();
+ }
+
+ protected String getLaunchConfigurationType() {
+ return ESboxPythonLaunchConstants.ID_ESBOX_REMOTE_LAUNCH_CONFIGURATION_TYPE;
+ }
+
+ protected ILaunchConfiguration createDefaultLaunchConfiguration(IResource resource) {
+ String projName = resource.getProject().getName();
+ return createDefaultLaunchConfiguration(resource, getLaunchConfigurationType(), getDefaultLocation(resource), projName);
+ }
+
+ public static ILaunchConfiguration createDefaultLaunchConfiguration(IResource resource, String launchConfigurationType,
+ String location, String projName) {
+ return createDefaultLaunchConfiguration(resource, launchConfigurationType, location, projName, null);
+ }
+
+ /**
+ * COPIED/MODIFIED from AntLaunchShortcut
+ * @param location
+ * @param pythonInterpreterManager
+ */
+ public static ILaunchConfiguration createDefaultLaunchConfiguration(IResource resource, String launchConfigurationType,
+ String location, String projName, String vmargs) {
+
+
+ ILaunchManager manager = org.eclipse.debug.core.DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType type = manager.getLaunchConfigurationType(launchConfigurationType);
+ if (type == null) {
+ reportError("ESbox launch configuration not found", null);
+ return null;
+ }
+
+ StringBuffer buffer = new StringBuffer(projName);
+ buffer.append(" ");
+ buffer.append(resource.getName());
+ String name = buffer.toString().trim();
+ name= manager.generateUniqueLaunchConfigurationNameFrom(name);
+
+ try {
+
+ ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, name);
+ String baseDirectory = resource.getRawLocation().removeLastSegments(1).toString();
+ String arguments = "";
+
+ workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_PROJECT_NAME,projName);
+ workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_RESOURCE_TYPE,resource.getType());
+ workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_PROGRAM_NAME,location);
+ workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_INTERPRETER, ESboxPythonLaunchConstants.ATTR_INTERPRETER_DEFAULT);
+
+ workingCopy.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, false);
+ workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_LOCATION,location);
+ workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_WORKING_DIRECTORY,baseDirectory);
+ workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_PROGRAM_ARGUMENTS,arguments);
+ workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_VM_ARGUMENTS, vmargs);
+
+ // Common Tab Arguments
+ CommonTab tab = new CommonTab();
+ tab.setDefaults(workingCopy);
+ tab.dispose();
+ return workingCopy.doSave();
+ } catch (NotConfiguredInterpreterException e) {
+ reportError(e.getMessage(), e);
+ throw e;
+ } catch (CoreException e) {
+ reportError(null, e);
+ return null;
+ }
+ }
+
+ /**
+ * COPIED/MODIFIED from AntLaunchShortcut
+ */
+ protected ILaunchConfiguration chooseConfig(List configs) {
+ if (configs.isEmpty()) {
+ return null;
+ }
+ ILabelProvider labelProvider = DebugUITools.newDebugModelPresentation();
+ ElementListSelectionDialog dialog= new ElementListSelectionDialog(Display.getDefault().getActiveShell(), labelProvider);
+ dialog.setElements(configs.toArray(new ILaunchConfiguration[configs.size()]));
+ dialog.setTitle("Pick a Python configuration");
+ dialog.setMessage("Choose a python configuration to run");
+ dialog.setMultipleSelection(false);
+ int result = dialog.open();
+ labelProvider.dispose();
+ if (result == Window.OK)
+ return (ILaunchConfiguration) dialog.getFirstResult();
+ else
+ return null;
+ }
+
+ public void setShowDialog(boolean showDialog) {
+ fShowDialog = showDialog;
+ }
+
+
+}
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-01-27 18:13:23 UTC (rev 394)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/core/ESboxPythonLaunchConstants.java 2008-01-29 12:26:23 UTC (rev 395)
@@ -43,6 +43,8 @@
public static final String ATTR_DESKTOP_APPLICATION = LAUNCH_ID + ".ATTR_DESKTOP_APPLICATION";
public static final String ATTR_COPY_BINS = LAUNCH_ID + ".copy_bins"; //$NON-NLS-1$
+ public static final String ATTR_CLIENT_IP = LAUNCH_ID + ".CLIENT_IP";
+ public static final String DEFAULT_CLIENT_IP = "192.168.2.14";
public static final boolean COPY_BINS_DEFAULT = true;
/**
Modified: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/ui/MainRemoteModuleTab.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/ui/MainRemoteModuleTab.java 2008-01-27 18:13:23 UTC (rev 394)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/internal/ui/MainRemoteModuleTab.java 2008-01-29 12:26:23 UTC (rev 395)
@@ -76,6 +76,8 @@
protected Text fRemoteMountPoint;
+ protected Text fHostAddr;
+
protected Button fRunStandaloneButton;
protected Button fCopyBinsButton;
@@ -152,6 +154,7 @@
updateLaunchConfigurationDialog();
}
});
+
try {
fRunStandaloneButton.setSelection(_configuration.getAttribute(ESboxPythonLaunchConstants.ATTR_RUN_STANDALONE, true));
} catch (CoreException e) {
@@ -188,6 +191,8 @@
fLocalMountPoint.setText(localMounPoint);
fRemoteMountPoint.setText(remoteMounPoint);
+
+ fHostAddr.setText(ESboxPythonLaunchConstants.DEFAULT_CLIENT_IP);
}
public void performApply(final ILaunchConfigurationWorkingCopy _conf) {
@@ -198,12 +203,11 @@
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());
_conf.setAttribute(ESboxPythonLaunchConstants.ATTR_COPY_BINS, fCopyBinsButton.getSelection());
+
+ _conf.setAttribute(ESboxPythonLaunchConstants.ATTR_CLIENT_IP, fHostAddr.getText().trim());
}
@@ -352,6 +356,14 @@
fRemoteMountPoint.setLayoutData(data);
fRemoteMountPoint.setFont(parent.getFont());
fRemoteMountPoint.setEditable(false);
+
+ Label labelHostAddr = new Label(entriesGroup,SWT.NONE);
+ labelHostAddr.setText("Host IP:");
+ fHostAddr = new Text(entriesGroup, SWT.BORDER);
+ fHostAddr.setLayoutData(data);
+ fHostAddr.setFont(parent.getFont());
+ fHostAddr.setEditable(true);
+
}
private class WidgetListener extends SelectionAdapter implements ModifyListener, SelectionListener {
Modified: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/local/ESboxPythonLaunchConfigurationDelegate.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/local/ESboxPythonLaunchConfigurationDelegate.java 2008-01-27 18:13:23 UTC (rev 394)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/local/ESboxPythonLaunchConfigurationDelegate.java 2008-01-29 12:26:23 UTC (rev 395)
@@ -97,7 +97,7 @@
String vmArguments = super.getVMArguments(configuration);
String programArguments = super.getArguments(configuration);
debugger.debugPython(project, mode, launch, monitor, exePath, programArguments,
- vmArgumentsArray, vmArguments, isRunStandalone);
+ vmArgumentsArray, vmArguments, ESboxPythonDebugger.DEFAULT_LOCAL_CLIENT_IP, isRunStandalone);
} else {
monitor.worked(5);
Added: 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 (rev 0)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile/OProfilePythonConfigurationDelegate.java 2008-01-29 12:26:23 UTC (rev 395)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.oprofile;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.indt.esbox.python.launch.internal.core.AbstractConfigurationDelegate;
+
+/**
+ *
+ */
+public class OProfilePythonConfigurationDelegate extends
+ AbstractConfigurationDelegate {
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.python.launch.internal.core.AbstractConfigurationDelegate#getPluginID()
+ */
+ @Override
+ protected String getPluginID() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.python.launch.internal.core.AbstractConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void launch(ILaunchConfiguration configuration, String mode,
+ ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: 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 (rev 0)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile/OProfilePythonConfigurationTabGroup.java 2008-01-29 12:26:23 UTC (rev 395)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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.oprofile;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+
+/**
+ *
+ */
+public class OProfilePythonConfigurationTabGroup extends
+ AbstractLaunchConfigurationTabGroup {
+
+ /* (non-Javadoc)
+ * @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
+
+ }
+
+}
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-01-27 18:13:23 UTC (rev 394)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile/OProfilePythonShortcut.java 2008-01-29 12:26:23 UTC (rev 395)
@@ -13,6 +13,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.cdt.core.model.AbstractLanguage;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
@@ -37,6 +38,7 @@
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;
@@ -44,198 +46,9 @@
/**
*
*/
-public class OProfilePythonShortcut implements ILaunchShortcut {
+public class OProfilePythonShortcut extends AbstractLaunchShortcut {
- boolean fShowDialog = false; // show configuration dialog?
-
- //=============================================================================================
- // ILaunchShortcut IMPL
- //=============================================================================================
- public void launch(ISelection selection, String mode) {
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection)selection;
- Object object = structuredSelection.getFirstElement();
- if (object instanceof IAdaptable) {
-
- IFile resource = (IFile)((IAdaptable)object).getAdapter(IFile.class);
- if (resource != null) {
- launch(resource, mode, null);
- return;
- }
-
- IFolder folder = (IFolder)((IAdaptable)object).getAdapter(IFolder.class);
- if (folder != null) {
- launch(folder, mode, null);
- return;
- }
- }
- }
- fileNotFound();
- }
-
-
- public void launch(IEditorPart editor, String mode) {
- //we have an editor to run
- IEditorInput input = editor.getEditorInput();
- IFile file = (IFile)input.getAdapter(IFile.class);
- if (file != null) {
- launch(file, mode, null);
- return;
- }
- fileNotFound();
- }
- //=============================================================================================
- // END ILaunchShortcut IMPL
- //=============================================================================================
-
- protected void fileNotFound() {
- reportError("Unable to launch the file, not found??", null);
- }
-
- protected boolean verifyMode(String mode) {
- boolean ok = mode.equals(ILaunchManager.RUN_MODE) || mode.equals(ILaunchManager.DEBUG_MODE);
-
- if (!ok){
- reportError("Unknown launch mode: " + mode, null);
- }
- return ok;
- }
-
-
- protected static void reportError(String message, Throwable throwable) {
- if (message == null)
- message = "Unexpected error";
- IStatus status = null;
- if (throwable instanceof CoreException) {
- status = ((CoreException)throwable).getStatus();
- } else {
- status = new Status(IStatus.ERROR, "org.python.pydev.debug", 0, message, throwable);
- }
- ErrorDialog.openError(PythonLaunchActivator.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
- "ESbox esbox.python.launch error", "ESbox launch failed", status);
- }
-
/**
- * COPIED/MODIFIED from AntLaunchShortcut
- * Returns a list of existing launch configuration for the given file.
- */
- protected List findExistingLaunchConfigurations(IResource file) {
- ILaunchManager manager = org.eclipse.debug.core.DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType type = manager.getLaunchConfigurationType(getLaunchConfigurationType());
- List validConfigs = new ArrayList();
- if (type == null)
- return validConfigs;
- try {
- ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);
- String defaultLocation = getDefaultLocation(file);
- for (int i = 0; i < configs.length; i++) {
- String configPath = configs[i].getAttribute(ESboxPythonLaunchConstants.ATTR_LOCATION, "");
- if (defaultLocation.equals(configPath))
- validConfigs.add(configs[i]);
- }
- } catch (CoreException e) {
- reportError("Unexpected error", e);
- }
- return validConfigs;
- }
-
- /**
- * @param file
- * @return default string for the location field
- */
- public static String getDefaultLocation (IResource file) {
- return file.getRawLocation().toString();
- }
-
- protected String getLaunchConfigurationType() {
- return ESboxPythonLaunchConstants.ID_ESBOX_REMOTE_LAUNCH_CONFIGURATION_TYPE;
- }
-
- protected ILaunchConfiguration createDefaultLaunchConfiguration(IResource resource) {
- String projName = resource.getProject().getName();
- return createDefaultLaunchConfiguration(resource, getLaunchConfigurationType(), getDefaultLocation(resource), projName);
- }
-
- public static ILaunchConfiguration createDefaultLaunchConfiguration(IResource resource, String launchConfigurationType,
- String location, String projName) {
- return createDefaultLaunchConfiguration(resource, launchConfigurationType, location, projName, null);
- }
-
- /**
- * COPIED/MODIFIED from AntLaunchShortcut
- * @param location
- * @param pythonInterpreterManager
- */
- public static ILaunchConfiguration createDefaultLaunchConfiguration(IResource resource, String launchConfigurationType,
- String location, String projName, String vmargs) {
-
-
- ILaunchManager manager = org.eclipse.debug.core.DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType type = manager.getLaunchConfigurationType(launchConfigurationType);
- if (type == null) {
- reportError("ESbox launch configuration not found", null);
- return null;
- }
-
- StringBuffer buffer = new StringBuffer(projName);
- buffer.append(" ");
- buffer.append(resource.getName());
- String name = buffer.toString().trim();
- name= manager.generateUniqueLaunchConfigurationNameFrom(name);
-
- try {
-
- ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, name);
- String baseDirectory = resource.getRawLocation().removeLastSegments(1).toString();
- String arguments = "";
-
- workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_PROJECT_NAME,projName);
- workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_RESOURCE_TYPE,resource.getType());
- workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_PROGRAM_NAME,location);
- workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_INTERPRETER, ESboxPythonLaunchConstants.ATTR_INTERPRETER_DEFAULT);
-
- workingCopy.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, false);
- workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_LOCATION,location);
- workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_WORKING_DIRECTORY,baseDirectory);
- workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_PROGRAM_ARGUMENTS,arguments);
- workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_VM_ARGUMENTS, vmargs);
-
- // Common Tab Arguments
- CommonTab tab = new CommonTab();
- tab.setDefaults(workingCopy);
- tab.dispose();
- return workingCopy.doSave();
- } catch (NotConfiguredInterpreterException e) {
- reportError(e.getMessage(), e);
- throw e;
- } catch (CoreException e) {
- reportError(null, e);
- return null;
- }
- }
-
- /**
- * COPIED/MODIFIED from AntLaunchShortcut
- */
- protected ILaunchConfiguration chooseConfig(List configs) {
- if (configs.isEmpty()) {
- return null;
- }
- ILabelProvider labelProvider = DebugUITools.newDebugModelPresentation();
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(Display.getDefault().getActiveShell(), labelProvider);
- dialog.setElements(configs.toArray(new ILaunchConfiguration[configs.size()]));
- dialog.setTitle("Pick a Python configuration");
- dialog.setMessage("Choose a python configuration to run");
- dialog.setMultipleSelection(false);
- int result = dialog.open();
- labelProvider.dispose();
- if (result == Window.OK)
- return (ILaunchConfiguration) dialog.getFirstResult();
- else
- return null;
- }
-
- /**
* Launch the given targets in the given build file. The targets are
* launched in the given mode.
*
@@ -284,8 +97,6 @@
fileNotFound();
}
- public void setShowDialog(boolean showDialog) {
- fShowDialog = showDialog;
- }
+
}
Modified: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/remote/ESboxPythonRemoteConfigurationDelegate.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/remote/ESboxPythonRemoteConfigurationDelegate.java 2008-01-27 18:13:23 UTC (rev 394)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/remote/ESboxPythonRemoteConfigurationDelegate.java 2008-01-29 12:26:23 UTC (rev 395)
@@ -100,8 +100,9 @@
String[] vmArgumentsArray = super.getVMArgumentsAsArray(configuration);
String vmArguments = super.getVMArguments(configuration);
String programArguments = super.getArguments(configuration);
+ String clientIP = configuration.getAttribute(ESboxPythonLaunchConstants.ATTR_CLIENT_IP, ESboxPythonLaunchConstants.DEFAULT_CLIENT_IP);
debugger.debugPython(project, mode, launch, monitor, exePath, programArguments,
- vmArgumentsArray, vmArguments, isRunStandalone);
+ vmArgumentsArray, vmArguments, clientIP ,isRunStandalone);
} else {
monitor.worked(5);
Added: 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 (rev 0)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationDelegate.java 2008-01-29 12:26:23 UTC (rev 395)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.valgrind;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.indt.esbox.python.launch.internal.core.AbstractConfigurationDelegate;
+
+/**
+ *
+ */
+public class ValgrindPythonConfigurationDelegate extends
+ AbstractConfigurationDelegate {
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.python.launch.internal.core.AbstractConfigurationDelegate#getPluginID()
+ */
+ @Override
+ protected String getPluginID() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.python.launch.internal.core.AbstractConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void launch(ILaunchConfiguration configuration, String mode,
+ ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationTabGroup.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationTabGroup.java (rev 0)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationTabGroup.java 2008-01-29 12:26:23 UTC (rev 395)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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.valgrind;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+
+/**
+ *
+ */
+public class ValgrindPythonConfigurationTabGroup extends
+ AbstractLaunchConfigurationTabGroup {
+
+ /* (non-Javadoc)
+ * @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
+
+ }
+
+}
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-01-27 18:13:23 UTC (rev 394)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonLaunchShortcut.java 2008-01-29 12:26:23 UTC (rev 395)
@@ -37,6 +37,7 @@
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;
@@ -44,198 +45,9 @@
/**
*
*/
-public class ValgrindPythonLaunchShortcut implements ILaunchShortcut {
+public class ValgrindPythonLaunchShortcut extends AbstractLaunchShortcut {
- boolean fShowDialog = false; // show configuration dialog?
-
- //=============================================================================================
- // ILaunchShortcut IMPL
- //=============================================================================================
- public void launch(ISelection selection, String mode) {
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection)selection;
- Object object = structuredSelection.getFirstElement();
- if (object instanceof IAdaptable) {
-
- IFile resource = (IFile)((IAdaptable)object).getAdapter(IFile.class);
- if (resource != null) {
- launch(resource, mode, null);
- return;
- }
-
- IFolder folder = (IFolder)((IAdaptable)object).getAdapter(IFolder.class);
- if (folder != null) {
- launch(folder, mode, null);
- return;
- }
- }
- }
- fileNotFound();
- }
-
-
- public void launch(IEditorPart editor, String mode) {
- //we have an editor to run
- IEditorInput input = editor.getEditorInput();
- IFile file = (IFile)input.getAdapter(IFile.class);
- if (file != null) {
- launch(file, mode, null);
- return;
- }
- fileNotFound();
- }
- //=============================================================================================
- // END ILaunchShortcut IMPL
- //=============================================================================================
-
- protected void fileNotFound() {
- reportError("Unable to launch the file, not found??", null);
- }
-
- protected boolean verifyMode(String mode) {
- boolean ok = mode.equals(ILaunchManager.RUN_MODE) || mode.equals(ILaunchManager.DEBUG_MODE);
-
- if (!ok){
- reportError("Unknown launch mode: " + mode, null);
- }
- return ok;
- }
-
-
- protected static void reportError(String message, Throwable throwable) {
- if (message == null)
- message = "Unexpected error";
- IStatus status = null;
- if (throwable instanceof CoreException) {
- status = ((CoreException)throwable).getStatus();
- } else {
- status = new Status(IStatus.ERROR, "org.python.pydev.debug", 0, message, throwable);
- }
- ErrorDialog.openError(PythonLaunchActivator.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
- "ESbox esbox.python.launch error", "ESbox launch failed", status);
- }
-
/**
- * COPIED/MODIFIED from AntLaunchShortcut
- * Returns a list of existing launch configuration for the given file.
- */
- protected List findExistingLaunchConfigurations(IResource file) {
- ILaunchManager manager = org.eclipse.debug.core.DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType type = manager.getLaunchConfigurationType(getLaunchConfigurationType());
- List validConfigs = new ArrayList();
- if (type == null)
- return validConfigs;
- try {
- ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);
- String defaultLocation = getDefaultLocation(file);
- for (int i = 0; i < configs.length; i++) {
- String configPath = configs[i].getAttribute(ESboxPythonLaunchConstants.ATTR_LOCATION, "");
- if (defaultLocation.equals(configPath))
- validConfigs.add(configs[i]);
- }
- } catch (CoreException e) {
- reportError("Unexpected error", e);
- }
- return validConfigs;
- }
-
- /**
- * @param file
- * @return default string for the location field
- */
- public static String getDefaultLocation (IResource file) {
- return file.getRawLocation().toString();
- }
-
- protected String getLaunchConfigurationType() {
- return ESboxPythonLaunchConstants.ID_ESBOX_REMOTE_LAUNCH_CONFIGURATION_TYPE;
- }
-
- protected ILaunchConfiguration createDefaultLaunchConfiguration(IResource resource) {
- String projName = resource.getProject().getName();
- return createDefaultLaunchConfiguration(resource, getLaunchConfigurationType(), getDefaultLocation(resource), projName);
- }
-
- public static ILaunchConfiguration createDefaultLaunchConfiguration(IResource resource, String launchConfigurationType,
- String location, String projName) {
- return createDefaultLaunchConfiguration(resource, launchConfigurationType, location, projName, null);
- }
-
- /**
- * COPIED/MODIFIED from AntLaunchShortcut
- * @param location
- * @param pythonInterpreterManager
- */
- public static ILaunchConfiguration createDefaultLaunchConfiguration(IResource resource, String launchConfigurationType,
- String location, String projName, String vmargs) {
-
-
- ILaunchManager manager = org.eclipse.debug.core.DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType type = manager.getLaunchConfigurationType(launchConfigurationType);
- if (type == null) {
- reportError("ESbox launch configuration not found", null);
- return null;
- }
-
- StringBuffer buffer = new StringBuffer(projName);
- buffer.append(" ");
- buffer.append(resource.getName());
- String name = buffer.toString().trim();
- name= manager.generateUniqueLaunchConfigurationNameFrom(name);
-
- try {
-
- ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, name);
- String baseDirectory = resource.getRawLocation().removeLastSegments(1).toString();
- String arguments = "";
-
- workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_PROJECT_NAME,projName);
- workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_RESOURCE_TYPE,resource.getType());
- workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_PROGRAM_NAME,location);
- workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_INTERPRETER, ESboxPythonLaunchConstants.ATTR_INTERPRETER_DEFAULT);
-
- workingCopy.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, false);
- workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_LOCATION,location);
- workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_WORKING_DIRECTORY,baseDirectory);
- workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_PROGRAM_ARGUMENTS,arguments);
- workingCopy.setAttribute(ESboxPythonLaunchConstants.ATTR_VM_ARGUMENTS, vmargs);
-
- // Common Tab Arguments
- CommonTab tab = new CommonTab();
- tab.setDefaults(workingCopy);
- tab.dispose();
- return workingCopy.doSave();
- } catch (NotConfiguredInterpreterException e) {
- reportError(e.getMessage(), e);
- throw e;
- } catch (CoreException e) {
- reportError(null, e);
- return null;
- }
- }
-
- /**
- * COPIED/MODIFIED from AntLaunchShortcut
- */
- protected ILaunchConfiguration chooseConfig(List configs) {
- if (configs.isEmpty()) {
- return null;
- }
- ILabelProvider labelProvider = DebugUITools.newDebugModelPresentation();
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(Display.getDefault().getActiveShell(), labelProvider);
- dialog.setElements(configs.toArray(new ILaunchConfiguration[configs.size()]));
- dialog.setTitle("Pick a Python configuration");
- dialog.setMessage("Choose a python configuration to run");
- dialog.setMultipleSelection(false);
- int result = dialog.open();
- labelProvider.dispose();
- if (result == Window.OK)
- return (ILaunchConfiguration) dialog.getFirstResult();
- else
- return null;
- }
-
- /**
* Launch the given targets in the given build file. The targets are
* launched in the given mode.
*
More information about the Esbox-commits
mailing list