[Esbox-commits] r396 - in trunk/org.indt.esbox.launch: . src/org/indt/esbox/launch src/org/indt/esbox/launch/internal src/org/indt/esbox/launch/internal/core src/org/indt/esbox/launch/internal/core/tool src/org/indt/esbox/launch/internal/ui src/org/indt/esbox/launch/oprofile src/org/indt/esbox/launch/valgrind
raul at garage.maemo.org
raul at garage.maemo.org
Tue Jan 29 14:33:46 EET 2008
Author: raul
Date: 2008-01-29 14:33:41 +0200 (Tue, 29 Jan 2008)
New Revision: 396
Added:
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/AbstractLaunchShortcut.java
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/OPreportToolProvider.java
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/OPreportToolRunner.java
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/OProfileToolProvider.java
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/OProfileToolRunner.java
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/ValgrindToolProvider.java
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/ValgrindToolRunner.java
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/ui/OProfileMainTab.java
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/ui/ValgrindMainTab.java
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/oprofile/OProfileLaunchConfigurationTabGroup.java
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/oprofile/OProfileLaunchDelegate.java
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchConfigurationTabGroup.java
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchDelegate.java
Modified:
trunk/org.indt.esbox.launch/plugin.xml
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/oprofile/OProfileLaunchShortcut.java
trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchShortcut.java
Log:
new launch elements to valgrind and oprofile tools.
Modified: trunk/org.indt.esbox.launch/plugin.xml
===================================================================
--- trunk/org.indt.esbox.launch/plugin.xml 2008-01-29 12:26:23 UTC (rev 395)
+++ trunk/org.indt.esbox.launch/plugin.xml 2008-01-29 12:33:41 UTC (rev 396)
@@ -23,6 +23,24 @@
sourceLocatorId="org.eclipse.cdt.debug.core.sourceLocator"
sourcePathComputerId="org.eclipse.cdt.debug.core.sourcePathComputer">
</launchConfigurationType>
+ <launchConfigurationType
+ delegate="org.indt.esbox.launch.oprofile.OProfileLaunchDelegate"
+ id="oprofileLaunchType"
+ modes="run"
+ name="OProfile Profiler"
+ public="true"
+ sourceLocatorId="org.eclipse.cdt.debug.core.sourceLocator"
+ sourcePathComputerId="org.eclipse.cdt.debug.core.sourcePathComputer">
+ </launchConfigurationType>
+ <launchConfigurationType
+ delegate="org.indt.esbox.launch.valgrind.ValgrindLaunchDelegate"
+ id="valgrindLaunchType"
+ modes="run"
+ name="Valgrind Profiler"
+ public="true"
+ sourceLocatorId="org.eclipse.cdt.debug.core.sourceLocator"
+ sourcePathComputerId="org.eclipse.cdt.debug.core.sourcePathComputer">
+ </launchConfigurationType>
</extension>
<extension
id="ESboxLaunchConfigTypeImages"
@@ -37,6 +55,16 @@
icon="icons/maemo_project.png"
id="esboxRemoteLaunchImage">
</launchConfigurationTypeImage>
+ <launchConfigurationTypeImage
+ configTypeID="oprofileLaunchType"
+ icon="icons/maemo_project.png"
+ id="oprofileLaunchTypeImage">
+ </launchConfigurationTypeImage>
+ <launchConfigurationTypeImage
+ configTypeID="valgrindLaunchType"
+ icon="icons/valgrind.png"
+ id="valgrindLaunchTypeImage">
+ </launchConfigurationTypeImage>
</extension>
<extension
id="EsboxLaunchConfigTabGroup"
@@ -51,6 +79,16 @@
id="esboxRemoteRunLaunchTabGroup"
type="esboxRemoteLaunchType">
</launchConfigurationTabGroup>
+ <launchConfigurationTabGroup
+ class="org.indt.esbox.launch.oprofile.OProfileLaunchConfigurationTabGroup"
+ id="oprofileLaunchTabGroup"
+ type="oprofileLaunchType">
+ </launchConfigurationTabGroup>
+ <launchConfigurationTabGroup
+ class="org.indt.esbox.launch.valgrind.ValgrindLaunchConfigurationTabGroup"
+ id="valgrindLaunchTabGroup"
+ type="valgrindLaunchType">
+ </launchConfigurationTabGroup>
</extension>
<extension
point="org.eclipse.debug.ui.launchShortcuts">
@@ -220,6 +258,28 @@
<adapter type="org.eclipse.debug.ui.actions.ILaunchable"/>
</factory>
</extension>
+ <extension
+ point="org.indt.esbox.core.tool">
+ <tool
+ id="org.indt.esbox.tool.oprofile"
+ name="OProfile">
+ <provider
+ class="org.indt.esbox.launch.internal.core.tool.OProfileToolProvider">
+ </provider>
+ </tool>
+ <tool
+ id="org.indt.esbox.tool.valgrind"
+ name="Valgrind">
+ <provider
+ class="org.indt.esbox.launch.internal.core.tool.ValgrindToolProvider"></provider>
+ </tool>
+ <tool
+ id="org.indt.esbox.tool.opreport"
+ name="OPreport">
+ <provider
+ class="org.indt.esbox.launch.internal.core.tool.OPreportToolProvider"></provider>
+ </tool>
+ </extension>
</plugin>
Added: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/AbstractLaunchShortcut.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/AbstractLaunchShortcut.java (rev 0)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/AbstractLaunchShortcut.java 2008-01-29 12:33:41 UTC (rev 396)
@@ -0,0 +1,405 @@
+/*******************************************************************************
+ * 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.launch;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.debug.core.CDebugCorePlugin;
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+import org.eclipse.cdt.debug.core.ICDebugConfiguration;
+import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
+import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
+import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
+import org.eclipse.cdt.ui.CElementLabelProvider;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.debug.core.DebugPlugin;
+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.DebugUITools;
+import org.eclipse.debug.ui.IDebugModelPresentation;
+import org.eclipse.debug.ui.ILaunchShortcut;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.ui.dialogs.TwoPaneElementSelector;
+import org.indt.esbox.launch.remote.ESboxRemoteRunLaunchDelegate;
+
+/**
+ *
+ */
+public abstract class AbstractLaunchShortcut implements ILaunchShortcut {
+
+ public abstract void launch(IBinary bin, String mode);
+
+ public void launch(IEditorPart editor, String mode) {
+ searchAndLaunch(new Object[] { editor.getEditorInput()}, mode);
+ }
+
+ public void launch(ISelection selection, String mode) {
+ if (selection instanceof IStructuredSelection) {
+ searchAndLaunch(((IStructuredSelection) selection).toArray(), mode);
+ }
+ }
+
+ /**
+ * Locate a configuration to relaunch for the given type. If one cannot be found, create one.
+ *
+ * @return a re-useable config or <code>null</code> if none
+ */
+ protected ILaunchConfiguration findLaunchConfiguration(IBinary bin, String mode) {
+ ILaunchConfiguration configuration = null;
+ ILaunchConfigurationType configType = getCLaunchConfigType();
+ List candidateConfigs = Collections.EMPTY_LIST;
+ try {
+ ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configType);
+ candidateConfigs = new ArrayList(configs.length);
+ for (int i = 0; i < configs.length; i++) {
+ ILaunchConfiguration config = configs[i];
+ IPath programPath = AbstractCLaunchDelegate.getProgramPath(config);
+ String projectName = AbstractCLaunchDelegate.getProjectName(config);
+ IPath name = bin.getResource().getProjectRelativePath();
+ if (programPath != null && programPath.equals(name)) {
+ if (projectName != null && projectName.equals(bin.getCProject().getProject().getName())) {
+ candidateConfigs.add(config);
+ }
+ }
+ }
+ } catch (CoreException e) {
+ LaunchUIPlugin.log(e);
+ }
+
+ // If there are no existing configs associated with the IBinary, create one.
+ // If there is exactly one config associated with the IBinary, return it.
+ // Otherwise, if there is more than one config associated with the IBinary, prompt the
+ // user to choose one.
+ int candidateCount = candidateConfigs.size();
+ if (candidateCount < 1) {
+ String programCPU = bin.getCPU();
+
+ // Prompt the user if more then 1 debugger.
+ ICDebugConfiguration debugConfig = null;
+ ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
+ List debugList = new ArrayList(debugConfigs.length);
+ String os = Platform.getOS();
+ for (int i = 0; i < debugConfigs.length; i++) {
+ String platform = debugConfigs[i].getPlatform();
+ if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
+ if (platform.equals("*") || platform.equals(os)) { //$NON-NLS-1$
+ if (debugConfigs[i].supportsCPU(programCPU))
+ debugList.add(debugConfigs[i]);
+ }
+ }
+ }
+ debugConfigs = (ICDebugConfiguration[]) debugList.toArray(new ICDebugConfiguration[0]);
+ if (debugConfigs.length == 1) {
+ debugConfig = debugConfigs[0];
+ } else if (debugConfigs.length > 1) {
+ debugConfig = chooseDebugConfig(debugConfigs, mode);
+ }
+ if (debugConfig != null) {
+ configuration = createConfiguration(bin, debugConfig);
+ }
+ } else if (candidateCount == 1) {
+ configuration = (ILaunchConfiguration) candidateConfigs.get(0);
+ } else {
+ // Prompt the user to choose a config. A null result means the user
+ // cancelled the dialog, in which case this method returns null,
+ // since cancelling the dialog should also cancel launching anything.
+ configuration = chooseConfiguration(candidateConfigs, mode);
+ }
+ return configuration;
+ }
+
+ /**
+ * Method createConfiguration.
+ * @param bin
+ * @return ILaunchConfiguration
+ */
+ protected ILaunchConfiguration createConfiguration(IBinary bin, ICDebugConfiguration debugConfig) {
+ ILaunchConfiguration config = null;
+ try {
+ String projectName = bin.getResource().getProjectRelativePath().toString();
+ ILaunchConfigurationType configType = getCLaunchConfigType();
+ ILaunchConfigurationWorkingCopy wc =
+ configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(bin.getElementName()));
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, projectName);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, bin.getCProject().getElementName());
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true);
+ wc.setAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
+ ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, debugConfig.getID());
+ config = wc.doSave();
+ } catch (CoreException ce) {
+ LaunchUIPlugin.log(ce);
+ }
+ return config;
+ }
+
+ /**
+ * Method getCLaunchConfigType.
+ * @return ILaunchConfigurationType
+ */
+ protected ILaunchConfigurationType getCLaunchConfigType() {
+ return getLaunchManager().getLaunchConfigurationType(ESboxRemoteRunLaunchDelegate.ESBOX_CONFIG_TYPE); //the ID of the configuration type that we want to link with.
+ }
+
+ protected ILaunchManager getLaunchManager() {
+ return DebugPlugin.getDefault().getLaunchManager();
+ }
+
+ /**
+ * Convenience method to get the window that owns this action's Shell.
+ */
+ protected Shell getShell() {
+ return LaunchUIPlugin.getActiveWorkbenchShell();
+ }
+
+ /**
+ * Method chooseDebugConfig.
+ * @param debugConfigs
+ * @param mode
+ * @return ICDebugConfiguration
+ */
+ protected ICDebugConfiguration chooseDebugConfig(ICDebugConfiguration[] debugConfigs, String mode) {
+ ILabelProvider provider = new LabelProvider() {
+ /**
+ * The <code>LabelProvider</code> implementation of this
+ * <code>ILabelProvider</code> method returns the element's <code>toString</code>
+ * string. Subclasses may override.
+ */
+ public String getText(Object element) {
+ if (element == null) {
+ return ""; //$NON-NLS-1$
+ } else if (element instanceof ICDebugConfiguration) {
+ return ((ICDebugConfiguration) element).getName();
+ }
+ return element.toString();
+ }
+ };
+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), provider);
+ dialog.setElements(debugConfigs);
+ dialog.setTitle(getDebugConfigDialogTitleString(debugConfigs, mode));
+ dialog.setMessage(getDebugConfigDialogMessageString(debugConfigs, mode));
+ dialog.setMultipleSelection(false);
+ int result = dialog.open();
+ provider.dispose();
+ if (result == Window.OK) {
+ return (ICDebugConfiguration) dialog.getFirstResult();
+ }
+ return null;
+ }
+
+ protected String getDebugConfigDialogTitleString(ICDebugConfiguration [] configList, String mode) {
+ return LaunchMessages.getString("CApplicationLaunchShortcut.LaunchDebugConfigSelection"); //$NON-NLS-1$
+ }
+
+ protected String getDebugConfigDialogMessageString(ICDebugConfiguration [] configList, String mode) {
+ if (mode.equals(ILaunchManager.DEBUG_MODE)) {
+ return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseConfigToDebug"); //$NON-NLS-1$
+ } else if (mode.equals(ILaunchManager.RUN_MODE)) {
+ return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseConfigToRun"); //$NON-NLS-1$
+ }
+ return LaunchMessages.getString("CApplicationLaunchShortcut.Invalid_launch_mode_1"); //$NON-NLS-1$
+ }
+
+
+ /**
+ * Show a selection dialog that allows the user to choose one of the specified
+ * launch configurations. Return the chosen config, or <code>null</code> if the
+ * user cancelled the dialog.
+ */
+ protected ILaunchConfiguration chooseConfiguration(List configList, String mode) {
+ IDebugModelPresentation labelProvider = DebugUITools.newDebugModelPresentation();
+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
+ dialog.setElements(configList.toArray());
+ dialog.setTitle(getLaunchSelectionDialogTitleString(configList, mode));
+ dialog.setMessage(getLaunchSelectionDialogMessageString(configList, mode));
+ dialog.setMultipleSelection(false);
+ int result = dialog.open();
+ labelProvider.dispose();
+ if (result == Window.OK) {
+ return (ILaunchConfiguration) dialog.getFirstResult();
+ }
+ return null;
+ }
+
+ protected String getLaunchSelectionDialogTitleString(List configList, String mode) {
+ return LaunchMessages.getString("CApplicationLaunchShortcut.LaunchConfigSelection"); //$NON-NLS-1$
+ }
+
+ protected String getLaunchSelectionDialogMessageString(List binList, String mode) {
+ if (mode.equals(ILaunchManager.DEBUG_MODE)) {
+ return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLaunchConfigToDebug"); //$NON-NLS-1$
+ } else if (mode.equals(ILaunchManager.RUN_MODE)) {
+ return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLaunchConfigToRun"); //$NON-NLS-1$
+ }
+ return LaunchMessages.getString("CApplicationLaunchShortcut.Invalid_launch_mode_2"); //$NON-NLS-1$
+ }
+
+ /**
+ * Prompts the user to select a binary
+ *
+ * @return the selected binary or <code>null</code> if none.
+ */
+ protected IBinary chooseBinary(List binList, String mode) {
+ ILabelProvider programLabelProvider = new CElementLabelProvider() {
+ public String getText(Object element) {
+ if (element instanceof IBinary) {
+ IBinary bin = (IBinary)element;
+ StringBuffer name = new StringBuffer();
+ name.append(bin.getPath().lastSegment());
+ return name.toString();
+ }
+ return super.getText(element);
+ }
+ };
+
+ ILabelProvider qualifierLabelProvider = new CElementLabelProvider() {
+ public String getText(Object element) {
+ if (element instanceof IBinary) {
+ IBinary bin = (IBinary)element;
+ StringBuffer name = new StringBuffer();
+ name.append(bin.getCPU() + (bin.isLittleEndian() ? "le" : "be")); //$NON-NLS-1$ //$NON-NLS-2$
+ name.append(" - "); //$NON-NLS-1$
+ name.append(bin.getPath().toString());
+ return name.toString();
+ }
+ return super.getText(element);
+ }
+ };
+
+ TwoPaneElementSelector dialog = new TwoPaneElementSelector(getShell(), programLabelProvider, qualifierLabelProvider);
+ dialog.setElements(binList.toArray());
+ dialog.setTitle(getBinarySelectionDialogTitleString(binList, mode)); //$NON-NLS-1$
+ dialog.setMessage(getBinarySelectionDialogMessageString(binList, mode)); //$NON-NLS-1$
+ dialog.setUpperListLabel(LaunchMessages.getString("Launch.common.BinariesColon")); //$NON-NLS-1$
+ dialog.setLowerListLabel(LaunchMessages.getString("Launch.common.QualifierColon")); //$NON-NLS-1$
+ dialog.setMultipleSelection(false);
+ if (dialog.open() == Window.OK) {
+ return (IBinary) dialog.getFirstResult();
+ }
+
+ return null;
+ }
+
+ protected String getBinarySelectionDialogTitleString(List binList, String mode) {
+ return LaunchMessages.getString("CApplicationLaunchShortcut.CLocalApplication"); //$NON-NLS-1$
+ }
+
+ protected String getBinarySelectionDialogMessageString(List binList, String mode) {
+ if (mode.equals(ILaunchManager.DEBUG_MODE)) {
+ return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLocalAppToDebug"); //$NON-NLS-1$
+ } else if (mode.equals(ILaunchManager.RUN_MODE)) {
+ return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLocalAppToRun"); //$NON-NLS-1$
+ }
+ return LaunchMessages.getString("CApplicationLaunchShortcut.Invalid_launch_mode_3"); //$NON-NLS-1$
+ }
+
+ /**
+ * Method searchAndLaunch.
+ * @param objects
+ * @param mode
+ */
+ protected void searchAndLaunch(final Object[] elements, String mode) {
+ if (elements != null && elements.length > 0) {
+ IBinary bin = null;
+ if (elements.length == 1 && elements[0] instanceof IBinary) {
+ bin = (IBinary)elements[0];
+ } else {
+ final List results = new ArrayList();
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
+ IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ public void run(IProgressMonitor pm) throws InterruptedException {
+ int nElements = elements.length;
+ pm.beginTask("Looking for executables", nElements); //$NON-NLS-1$
+ try {
+ IProgressMonitor sub = new SubProgressMonitor(pm, 1);
+ for (int i = 0; i < nElements; i++) {
+ if (elements[i] instanceof IAdaptable) {
+ IResource r = (IResource) ((IAdaptable) elements[i]).getAdapter(IResource.class);
+ if (r != null) {
+ ICProject cproject = CoreModel.getDefault().create(r.getProject());
+ if (cproject != null) {
+ try {
+ IBinary[] bins = cproject.getBinaryContainer().getBinaries();
+
+ for (int j = 0; j < bins.length; j++) {
+ if (bins[j].isExecutable()) {
+ results.add(bins[j]);
+ }
+ }
+ } catch (CModelException e) {
+ }
+ }
+ }
+ }
+ if (pm.isCanceled()) {
+ throw new InterruptedException();
+ }
+ sub.done();
+ }
+ } finally {
+ pm.done();
+ }
+ }
+ };
+ try {
+ dialog.run(true, true, runnable);
+ } catch (InterruptedException e) {
+ return;
+ } catch (InvocationTargetException e) {
+ MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), e.getMessage()); //$NON-NLS-1$
+ return;
+ }
+ int count = results.size();
+ if (count == 0) {
+ MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_binaries")); //$NON-NLS-1$ //$NON-NLS-2$
+ } else if (count > 1) {
+ bin = chooseBinary(results, mode);
+ } else {
+ bin = (IBinary)results.get(0);
+ }
+ }
+ if (bin != null) {
+ launch(bin, mode);
+ }
+ } else {
+ MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_project_selected")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+
+}
Added: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/OPreportToolProvider.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/OPreportToolProvider.java (rev 0)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/OPreportToolProvider.java 2008-01-29 12:33:41 UTC (rev 396)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * 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.launch.internal.core.tool;
+
+import org.indt.esbox.core.tool.IToolProvider;
+import org.indt.esbox.core.tool.IToolRunner;
+
+/**
+ *
+ */
+public class OPreportToolProvider implements IToolProvider {
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.core.tool.IToolProvider#getRunner()
+ */
+ public IToolRunner getRunner() {
+ return new OPreportToolRunner();
+ }
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.core.tool.IToolProvider#isInstalled()
+ */
+ public boolean isInstalled() {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+}
Added: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/OPreportToolRunner.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/OPreportToolRunner.java (rev 0)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/OPreportToolRunner.java 2008-01-29 12:33:41 UTC (rev 396)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * 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.launch.internal.core.tool;
+
+import java.io.IOException;
+
+import org.eclipse.cdt.utils.pty.PTY;
+import org.eclipse.cdt.utils.spawner.ProcessFactory;
+import org.eclipse.core.runtime.IPath;
+import org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher;
+import org.indt.esbox.core.tool.IToolRunner;
+
+/**
+ *
+ */
+public class OPreportToolRunner implements IToolRunner {
+
+ private ScratchboxCommandLauncher commandLauncher = new InnerCommandLauncher();
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.core.tool.IToolRunner#getCommandLauncher()
+ */
+ public ScratchboxCommandLauncher getCommandLauncher() {
+ return commandLauncher;
+ }
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.core.tool.IToolRunner#runTool(java.lang.String[])
+ */
+ public boolean runTool(String[] args) {
+
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /**
+ *
+ */
+ private class InnerCommandLauncher extends ScratchboxCommandLauncher {
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.cdt.core.CommandLauncher#execute(org.eclipse.core.runtime.IPath, java.lang.String[], java.lang.String[], org.eclipse.core.runtime.IPath)
+ */
+ public Process execute(IPath commandPath, String[] args, String[] env, IPath changeToDirectory) {
+ try {
+ fCommandArgs = constructCommandArray(commandPath.toOSString(),args, env, changeToDirectory);
+
+ PTY pty = new PTY();
+ fProcess = ProcessFactory.getFactory().exec(fCommandArgs, new String[] {}, changeToDirectory.toFile(), new PTY());
+
+ fErrorMessage = "";
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ setErrorMessage(e.getMessage());
+ fProcess = null;
+ }
+
+ return fProcess;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher#constructCommandArray(java.lang.String, java.lang.String[], java.lang.String[], org.eclipse.core.runtime.IPath)
+ */
+ protected String[] constructCommandArray(String command,
+ String[] commandArgs, String[] env, IPath changeToDirectory)
+ throws IOException {
+
+ String argString = "";
+ // Construct commands arguments to string
+ for (int i = 0; i < commandArgs.length; i++) {
+ argString = argString.concat(" " + commandArgs[i]);
+ }
+
+ // construct whole command with exports
+ String cmd[] = constructCommandArray(command);
+
+ // Replace some pieces of original string
+ cmd[2] = cmd[2] + " " + argString;
+
+ return cmd;
+ }
+
+
+ }
+
+}
Added: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/OProfileToolProvider.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/OProfileToolProvider.java (rev 0)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/OProfileToolProvider.java 2008-01-29 12:33:41 UTC (rev 396)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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.launch.internal.core.tool;
+
+import org.indt.esbox.core.tool.IToolProvider;
+import org.indt.esbox.core.tool.IToolRunner;
+
+/**
+ *
+ */
+public class OProfileToolProvider implements IToolProvider {
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.core.tool.IToolProvider#getRunner()
+ */
+ public IToolRunner getRunner() {
+ return new OProfileToolRunner();
+ }
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.core.tool.IToolProvider#isInstalled()
+ */
+ public boolean isInstalled() {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+
+}
Added: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/OProfileToolRunner.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/OProfileToolRunner.java (rev 0)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/OProfileToolRunner.java 2008-01-29 12:33:41 UTC (rev 396)
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * 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.launch.internal.core.tool;
+
+import java.io.IOException;
+
+import org.eclipse.cdt.utils.pty.PTY;
+import org.eclipse.cdt.utils.spawner.ProcessFactory;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Preferences;
+import org.indt.esbox.core.CoreActivator;
+import org.indt.esbox.core.ESboxPreferenceConstants;
+import org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher;
+import org.indt.esbox.core.tool.IToolRunner;
+
+/**
+ *
+ */
+public class OProfileToolRunner implements IToolRunner {
+
+ private ScratchboxCommandLauncher commandLauncher = new InnerCommandLauncher();
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.core.tool.IToolRunner#getCommandLauncher()
+ */
+ public ScratchboxCommandLauncher getCommandLauncher() {
+ return commandLauncher;
+ }
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.core.tool.IToolRunner#runTool(java.lang.String[])
+ */
+ public boolean runTool(String[] args) {
+ Preferences prefs = CoreActivator.getDefault().getPluginPreferences();
+ String sbrshBinPath = prefs.getString(ESboxPreferenceConstants.SBRSH_SELECTED_BIN_PATH.toString());
+ IPath command = new Path(prefs.getString(ESboxPreferenceConstants.SBRSH_EXEC_FILE_LOCATION.toString()));
+
+ String remoteMounPoint = "";
+ String localMountPoint = "";
+ if (!sbrshBinPath.equals("")) {
+ String tokens[] = sbrshBinPath.split("#");
+ localMountPoint = tokens[1];
+ remoteMounPoint = tokens[2];
+ }
+
+ String program = "run-standalone.sh";
+
+ for (int i = 0; i < args.length; i++) {
+ String arg = args[i];
+ program += " " + arg;
+ }
+
+ String newArgs[] = new String[] { "-d", remoteMounPoint, program };
+
+ Process process = commandLauncher.execute(command, newArgs, new String[] { }, new Path("."));
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /**
+ *
+ */
+ private class InnerCommandLauncher extends ScratchboxCommandLauncher {
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.cdt.core.CommandLauncher#execute(org.eclipse.core.runtime.IPath, java.lang.String[], java.lang.String[], org.eclipse.core.runtime.IPath)
+ */
+ public Process execute(IPath commandPath, String[] args, String[] env, IPath changeToDirectory) {
+ try {
+ fCommandArgs = constructCommandArray(commandPath.toOSString(),args, env, changeToDirectory);
+
+ PTY pty = new PTY();
+ fProcess = ProcessFactory.getFactory().exec(fCommandArgs, new String[] {}, changeToDirectory.toFile(), new PTY());
+
+ fErrorMessage = "";
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ setErrorMessage(e.getMessage());
+ fProcess = null;
+ }
+
+ return fProcess;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher#constructCommandArray(java.lang.String, java.lang.String[], java.lang.String[], org.eclipse.core.runtime.IPath)
+ */
+ protected String[] constructCommandArray(String command,
+ String[] commandArgs, String[] env, IPath changeToDirectory)
+ throws IOException {
+
+ String argString = "";
+ // Construct commands arguments to string
+ for (int i = 0; i < commandArgs.length; i++) {
+ argString = argString.concat(" " + commandArgs[i]);
+ }
+
+ // construct whole command with exports
+ String cmd[] = constructCommandArray(command);
+
+ // Replace some pieces of original string
+ cmd[2] = cmd[2] + " " + argString;
+
+ return cmd;
+ }
+
+
+ }
+
+}
Added: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/ValgrindToolProvider.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/ValgrindToolProvider.java (rev 0)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/ValgrindToolProvider.java 2008-01-29 12:33:41 UTC (rev 396)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * 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.launch.internal.core.tool;
+
+import org.indt.esbox.core.tool.IToolProvider;
+import org.indt.esbox.core.tool.IToolRunner;
+
+/**
+ *
+ */
+public class ValgrindToolProvider implements IToolProvider {
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.core.tool.IToolProvider#getRunner()
+ */
+ public IToolRunner getRunner() {
+ return new ValgrindToolRunner();
+ }
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.core.tool.IToolProvider#isInstalled()
+ */
+ public boolean isInstalled() {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+}
Added: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/ValgrindToolRunner.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/ValgrindToolRunner.java (rev 0)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/core/tool/ValgrindToolRunner.java 2008-01-29 12:33:41 UTC (rev 396)
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * 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.launch.internal.core.tool;
+
+import java.io.IOException;
+
+import org.eclipse.cdt.utils.pty.PTY;
+import org.eclipse.cdt.utils.spawner.ProcessFactory;
+import org.eclipse.core.runtime.IPath;
+import org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher;
+import org.indt.esbox.core.tool.IToolRunner;
+
+/**
+ *
+ */
+public class ValgrindToolRunner implements IToolRunner {
+
+ private ScratchboxCommandLauncher commandLauncher = new InnerCommandLauncher();
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.core.tool.IToolRunner#getCommandLauncher()
+ */
+ public ScratchboxCommandLauncher getCommandLauncher() {
+ return commandLauncher;
+ }
+
+ /* (non-Javadoc)
+ * @see org.indt.esbox.core.tool.IToolRunner#runTool(java.lang.String[])
+ */
+ public boolean runTool(String[] args) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /**
+ *
+ */
+ private class InnerCommandLauncher extends ScratchboxCommandLauncher {
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.cdt.core.CommandLauncher#execute(org.eclipse.core.runtime.IPath, java.lang.String[], java.lang.String[], org.eclipse.core.runtime.IPath)
+ */
+ public Process execute(IPath commandPath, String[] args, String[] env, IPath changeToDirectory) {
+ try {
+ fCommandArgs = constructCommandArray(commandPath.toOSString(),args, env, changeToDirectory);
+
+ PTY pty = new PTY();
+ fProcess = ProcessFactory.getFactory().exec(fCommandArgs, new String[] {}, changeToDirectory.toFile(), new PTY());
+
+ fErrorMessage = "";
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ setErrorMessage(e.getMessage());
+ fProcess = null;
+ }
+
+ return fProcess;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher#constructCommandArray(java.lang.String, java.lang.String[], java.lang.String[], org.eclipse.core.runtime.IPath)
+ */
+ protected String[] constructCommandArray(String command,
+ String[] commandArgs, String[] env, IPath changeToDirectory)
+ throws IOException {
+
+ String argString = "";
+ // Construct commands arguments to string
+ for (int i = 0; i < commandArgs.length; i++) {
+ argString = argString.concat(" " + commandArgs[i]);
+ }
+
+ // construct whole command with exports
+ String cmd[] = constructCommandArray(command);
+
+ // Replace some pieces of original string
+ cmd[2] = cmd[2] + " " + argString;
+
+ return cmd;
+ }
+
+
+ }
+
+}
Added: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/ui/OProfileMainTab.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/ui/OProfileMainTab.java (rev 0)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/ui/OProfileMainTab.java 2008-01-29 12:33:41 UTC (rev 396)
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * 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.launch.internal.ui;
+
+import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
+import org.eclipse.cdt.launch.ui.CMainTab;
+import org.eclipse.cdt.utils.pty.PTY;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.Label;
+import org.eclipse.swt.widgets.Text;
+import org.indt.esbox.core.CoreActivator;
+import org.indt.esbox.core.ESboxPreferenceConstants;
+import org.indt.esbox.core.ErrorLogger;
+import org.indt.esbox.launch.IESboxCDTLaunchConfigurationConstants;
+import org.indt.esbox.launch.LaunchActivator;
+
+/**
+ *
+ */
+public class OProfileMainTab extends CMainTab {
+
+ protected Button fRunStandaloneButton;
+ protected Button fCopyButton;
+ protected Text fLocalMountPoint;
+ protected Text fRemoteMountPoint;
+
+ public OProfileMainTab() {
+ super(true);
+ }
+
+ @Override
+ protected void createTerminalOption(Composite parent, int colSpan) {
+ createTexts(parent);
+
+ Composite mainComp = new Composite(parent, SWT.NONE);
+ GridLayout mainLayout = new GridLayout();
+ mainLayout.numColumns = 1;
+ mainLayout.marginHeight = 0;
+ mainLayout.marginWidth = 0;
+ mainComp.setLayout(mainLayout);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = colSpan;
+ mainComp.setLayoutData(gd);
+
+ fTerminalButton = createCheckButton(mainComp, LaunchMessages.getString("CMainTab.UseTerminal")); //$NON-NLS-1$
+ fTerminalButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent evt) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+ fTerminalButton.setEnabled(PTY.isSupported());
+
+ fRunStandaloneButton = createCheckButton(mainComp, "Run with \"run-standalone.sh\" script"); //$NON-NLS-1$
+ fRunStandaloneButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent evt) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+ fRunStandaloneButton.setSelection(IESboxCDTLaunchConfigurationConstants.RUN_STANDALONE_DEFAULT);
+
+ fCopyButton = createCheckButton(mainComp, "Copy binary to local mount point"); //$NON-NLS-1$
+ fCopyButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent evt) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+ fCopyButton.setSelection(IESboxCDTLaunchConfigurationConstants.COPY_BINS_DEFAULT);
+ }
+
+ @Override
+ public void performApply(ILaunchConfigurationWorkingCopy config) {
+ // TODO Auto-generated method stub
+ super.performApply(config);
+ config.setAttribute(IESboxCDTLaunchConfigurationConstants.ATTR_RUN_STANDALONE, fRunStandaloneButton.getSelection());
+ config.setAttribute(IESboxCDTLaunchConfigurationConstants.ATTR_COPY_BINS, fCopyButton.getSelection());
+ }
+
+ @Override
+ public void initializeFrom(ILaunchConfiguration config) {
+ // TODO Auto-generated method stub
+ super.initializeFrom(config);
+ updateFromConfig(config);
+
+ 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);
+
+
+ }
+
+ protected void updateFromConfig(ILaunchConfiguration config) {
+ boolean isRunStandalone = IESboxCDTLaunchConfigurationConstants.RUN_STANDALONE_DEFAULT;
+ try {
+ isRunStandalone = config.getAttribute(IESboxCDTLaunchConfigurationConstants.ATTR_RUN_STANDALONE,
+ IESboxCDTLaunchConfigurationConstants.RUN_STANDALONE_DEFAULT);
+ } catch (CoreException e) {
+ ErrorLogger errorLogger = LaunchActivator.getDefault().getErrorLogger();
+ errorLogger.logAndShowError("ESbox error", e);
+ }
+ fRunStandaloneButton.setSelection(isRunStandalone);
+
+ boolean copyBinaries = IESboxCDTLaunchConfigurationConstants.COPY_BINS_DEFAULT;
+ try {
+ copyBinaries = config.getAttribute(IESboxCDTLaunchConfigurationConstants.ATTR_COPY_BINS,
+ IESboxCDTLaunchConfigurationConstants.COPY_BINS_DEFAULT);
+ } catch (CoreException e) {
+ ErrorLogger errorLogger = LaunchActivator.getDefault().getErrorLogger();
+ errorLogger.logAndShowError("ESbox error", e);
+ }
+ fRunStandaloneButton.setSelection(copyBinaries);
+ }
+
+ @Override
+ public void setDefaults(ILaunchConfigurationWorkingCopy config) {
+ // TODO Auto-generated method stub
+ super.setDefaults(config);
+ config.setAttribute(IESboxCDTLaunchConfigurationConstants.ATTR_RUN_STANDALONE,
+ IESboxCDTLaunchConfigurationConstants.RUN_STANDALONE_DEFAULT);
+ config.setAttribute(IESboxCDTLaunchConfigurationConstants.ATTR_COPY_BINS,
+ IESboxCDTLaunchConfigurationConstants.COPY_BINS_DEFAULT);
+ }
+
+ 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);
+ }
+
+
+}
Added: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/ui/ValgrindMainTab.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/ui/ValgrindMainTab.java (rev 0)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/internal/ui/ValgrindMainTab.java 2008-01-29 12:33:41 UTC (rev 396)
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * 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.launch.internal.ui;
+
+import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
+import org.eclipse.cdt.launch.ui.CMainTab;
+import org.eclipse.cdt.utils.pty.PTY;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.indt.esbox.core.ErrorLogger;
+import org.indt.esbox.launch.IESboxCDTLaunchConfigurationConstants;
+import org.indt.esbox.launch.LaunchActivator;
+
+/**
+ *
+ */
+public class ValgrindMainTab extends CMainTab {
+
+ protected Button fRunStandaloneButton;
+
+ public ValgrindMainTab() {
+ super(true);
+ }
+
+ @Override
+ protected void createTerminalOption(Composite parent, int colSpan) {
+ Composite mainComp = new Composite(parent, SWT.NONE);
+ GridLayout mainLayout = new GridLayout();
+ mainLayout.numColumns = 1;
+ mainLayout.marginHeight = 0;
+ mainLayout.marginWidth = 0;
+ mainComp.setLayout(mainLayout);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = colSpan;
+ mainComp.setLayoutData(gd);
+
+ fTerminalButton = createCheckButton(mainComp, LaunchMessages.getString("CMainTab.UseTerminal")); //$NON-NLS-1$
+ fTerminalButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent evt) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+ fTerminalButton.setEnabled(PTY.isSupported());
+
+ fRunStandaloneButton = createCheckButton(mainComp, "Run with \"run-standalone.sh\" script"); //$NON-NLS-1$
+ fRunStandaloneButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent evt) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+ fRunStandaloneButton.setSelection(IESboxCDTLaunchConfigurationConstants.RUN_STANDALONE_DEFAULT);
+ }
+
+ @Override
+ public void performApply(ILaunchConfigurationWorkingCopy config) {
+ // TODO Auto-generated method stub
+ super.performApply(config);
+ config.setAttribute(IESboxCDTLaunchConfigurationConstants.ATTR_RUN_STANDALONE, fRunStandaloneButton.getSelection());
+ }
+
+ @Override
+ public void initializeFrom(ILaunchConfiguration config) {
+ // TODO Auto-generated method stub
+ super.initializeFrom(config);
+ updateRunStandaloneFromConfig(config);
+ }
+
+ protected void updateRunStandaloneFromConfig(ILaunchConfiguration config) {
+ boolean isRunStandalone = IESboxCDTLaunchConfigurationConstants.RUN_STANDALONE_DEFAULT;
+ try {
+ isRunStandalone = config.getAttribute(IESboxCDTLaunchConfigurationConstants.ATTR_RUN_STANDALONE,
+ IESboxCDTLaunchConfigurationConstants.RUN_STANDALONE_DEFAULT);
+ } catch (CoreException e) {
+ ErrorLogger errorLogger = LaunchActivator.getDefault().getErrorLogger();
+ errorLogger.logAndShowError("ESbox error", e);
+ }
+ fRunStandaloneButton.setSelection(isRunStandalone);
+ }
+
+ @Override
+ public void setDefaults(ILaunchConfigurationWorkingCopy config) {
+ // TODO Auto-generated method stub
+ super.setDefaults(config);
+ config.setAttribute(IESboxCDTLaunchConfigurationConstants.ATTR_RUN_STANDALONE,
+ IESboxCDTLaunchConfigurationConstants.RUN_STANDALONE_DEFAULT);
+ }
+
+
+}
Added: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/oprofile/OProfileLaunchConfigurationTabGroup.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/oprofile/OProfileLaunchConfigurationTabGroup.java (rev 0)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/oprofile/OProfileLaunchConfigurationTabGroup.java 2008-01-29 12:33:41 UTC (rev 396)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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.launch.oprofile;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.indt.esbox.launch.internal.ui.OProfileMainTab;
+
+/**
+ *
+ */
+public class OProfileLaunchConfigurationTabGroup 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) {
+ ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
+ new OProfileMainTab()
+ };
+ setTabs(tabs);
+
+ }
+
+}
Added: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/oprofile/OProfileLaunchDelegate.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/oprofile/OProfileLaunchDelegate.java (rev 0)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/oprofile/OProfileLaunchDelegate.java 2008-01-29 12:33:41 UTC (rev 396)
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * 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.launch.oprofile;
+
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.indt.esbox.core.CoreActivator;
+import org.indt.esbox.core.ESboxPreferenceConstants;
+import org.indt.esbox.core.tool.ESboxToolEngine;
+import org.indt.esbox.core.tool.ITool;
+
+/**
+ *
+ */
+public class OProfileLaunchDelegate extends AbstractCLaunchDelegate {
+
+// runOProfileTool(new String[] {"--init"});
+// runOProfileTool(new String[] {"--no-vmlinux"});
+// runOProfileTool(new String[] {"--dump"});
+// runOProfileTool(new String[] {"--start"});
+//
+// runApplication(bin,mode);
+//
+// runOProfileTool(new String[] {"--stop"});
+//
+// runOPreportTool(new String[] { "" });
+//
+// IWorkbench workbench = PlatformUI.getWorkbench();
+// IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+// try {
+// workbenchWindow.getActivePage().showView("org.indt.esbox.ui.views.oProfileView");
+// } catch (PartInitException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+//}
+//
+//private void runApplication(IBinary bin, String mode) {
+// ILaunchConfiguration config = findLaunchConfiguration(bin, mode);
+//
+//// IPath exePath = verifyProgramPath(config);
+//// ICProject project = verifyCProject(config);
+//// IBinaryObject exeFile = verifyBinary(project, exePath);
+//// String arguments[] = getProgramArgumentsArray(config);
+//
+//
+// Preferences prefs = CoreActivator.getDefault().getPluginPreferences();
+// String sbrshBinPath = prefs.getString(ESboxPreferenceConstants.SBRSH_SELECTED_BIN_PATH.toString());
+//
+// String remoteMounPoint = "";
+// String localMountPoint = "";
+// if (!sbrshBinPath.equals("")) {
+// String tokens[] = sbrshBinPath.split("#");
+// localMountPoint = tokens[1];
+// remoteMounPoint = tokens[2];
+// }
+//
+//// boolean isRunStandalone = config.getAttribute(IESboxCDTLaunchConfigurationConstants.ATTR_RUN_STANDALONE, IESboxCDTLaunchConfigurationConstants.RUN_STANDALONE_DEFAULT);
+//// boolean copyBinary = config.getAttribute(IESboxCDTLaunchConfigurationConstants.ATTR_COPY_BINS, IESboxCDTLaunchConfigurationConstants.COPY_BINS_DEFAULT);
+//// if (copyBinary) {
+//// try {
+//// copyFile(exePath.toOSString(),localMountPoint + File.separatorChar + exePath.lastSegment());
+//// } catch (InterruptedException e) {
+//// ErrorLogger errorLogger = LaunchActivator.getDefault().getErrorLogger();
+//// errorLogger.logAndShowError("Scratchbox error", e);
+//// }
+//// }
+//
+//
+//}
+//
+//private void runOProfileTool(String args[]) {
+// ITool tool = ESboxToolEngine.getInstance().getTool("OProfile")[0];
+// tool.getProvider().getRunner().runTool(args);
+//}
+//
+//private void runOPreportTool(String args[]) {
+// ITool tool = ESboxToolEngine.getInstance().getTool("OPreport")[0];
+// tool.getProvider().getRunner().runTool(args);
+//}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.launch.AbstractCLaunchDelegate#getPluginID()
+ */
+ @Override
+ protected String getPluginID() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.launch.AbstractCLaunchDelegate#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
+
+ }
+
+}
Modified: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/oprofile/OProfileLaunchShortcut.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/oprofile/OProfileLaunchShortcut.java 2008-01-29 12:26:23 UTC (rev 395)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/oprofile/OProfileLaunchShortcut.java 2008-01-29 12:33:41 UTC (rev 396)
@@ -10,55 +10,21 @@
*******************************************************************************/
package org.indt.esbox.launch.oprofile;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.debug.core.CDebugCorePlugin;
-import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
-import org.eclipse.cdt.debug.core.ICDebugConfiguration;
-import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
-import org.eclipse.cdt.ui.CElementLabelProvider;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.debug.core.DebugPlugin;
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.DebugUITools;
-import org.eclipse.debug.ui.IDebugModelPresentation;
-import org.eclipse.debug.ui.ILaunchShortcut;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
-import org.eclipse.ui.dialogs.TwoPaneElementSelector;
-import org.indt.esbox.launch.remote.ESboxRemoteRunLaunchDelegate;
+import org.indt.esbox.launch.AbstractLaunchShortcut;
/**
*
*/
-public class OProfileLaunchShortcut implements ILaunchShortcut {
+public class OProfileLaunchShortcut extends AbstractLaunchShortcut {
public void launch(IEditorPart editor, String mode) {
searchAndLaunch(new Object[] { editor.getEditorInput()}, mode);
@@ -71,339 +37,15 @@
}
public void launch(IBinary bin, String mode) {
- // implementa aqui a execucao da ferramenta
-
- }
-
- /**
- * Locate a configuration to relaunch for the given type. If one cannot be found, create one.
- *
- * @return a re-useable config or <code>null</code> if none
- */
- protected ILaunchConfiguration findLaunchConfiguration(IBinary bin, String mode) {
- ILaunchConfiguration configuration = null;
- ILaunchConfigurationType configType = getCLaunchConfigType();
- List candidateConfigs = Collections.EMPTY_LIST;
try {
- ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configType);
- candidateConfigs = new ArrayList(configs.length);
- for (int i = 0; i < configs.length; i++) {
- ILaunchConfiguration config = configs[i];
- IPath programPath = AbstractCLaunchDelegate.getProgramPath(config);
- String projectName = AbstractCLaunchDelegate.getProjectName(config);
- IPath name = bin.getResource().getProjectRelativePath();
- if (programPath != null && programPath.equals(name)) {
- if (projectName != null && projectName.equals(bin.getCProject().getProject().getName())) {
- candidateConfigs.add(config);
- }
- }
+ ILaunchConfiguration config = findLaunchConfiguration(bin, mode);
+ if (config != null) {
+ DebugUITools.saveAndBuildBeforeLaunch();
+ config.launch(mode, null);
}
} catch (CoreException e) {
- LaunchUIPlugin.log(e);
+ LaunchUIPlugin.errorDialog(LaunchMessages.getString("CApplicationLaunchShortcut.LaunchFailed"), e.getStatus()); //$NON-NLS-1$
}
-
- // If there are no existing configs associated with the IBinary, create one.
- // If there is exactly one config associated with the IBinary, return it.
- // Otherwise, if there is more than one config associated with the IBinary, prompt the
- // user to choose one.
- int candidateCount = candidateConfigs.size();
- if (candidateCount < 1) {
- String programCPU = bin.getCPU();
-
- // Prompt the user if more then 1 debugger.
- ICDebugConfiguration debugConfig = null;
- ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
- List debugList = new ArrayList(debugConfigs.length);
- String os = Platform.getOS();
- for (int i = 0; i < debugConfigs.length; i++) {
- String platform = debugConfigs[i].getPlatform();
- if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
- if (platform.equals("*") || platform.equals(os)) { //$NON-NLS-1$
- if (debugConfigs[i].supportsCPU(programCPU))
- debugList.add(debugConfigs[i]);
- }
- }
- }
- debugConfigs = (ICDebugConfiguration[]) debugList.toArray(new ICDebugConfiguration[0]);
- if (debugConfigs.length == 1) {
- debugConfig = debugConfigs[0];
- } else if (debugConfigs.length > 1) {
- debugConfig = chooseDebugConfig(debugConfigs, mode);
- }
- if (debugConfig != null) {
- configuration = createConfiguration(bin, debugConfig);
- }
- } else if (candidateCount == 1) {
- configuration = (ILaunchConfiguration) candidateConfigs.get(0);
- } else {
- // Prompt the user to choose a config. A null result means the user
- // cancelled the dialog, in which case this method returns null,
- // since cancelling the dialog should also cancel launching anything.
- configuration = chooseConfiguration(candidateConfigs, mode);
- }
- return configuration;
}
- /**
- * Method createConfiguration.
- * @param bin
- * @return ILaunchConfiguration
- */
- private ILaunchConfiguration createConfiguration(IBinary bin, ICDebugConfiguration debugConfig) {
- ILaunchConfiguration config = null;
- try {
- String projectName = bin.getResource().getProjectRelativePath().toString();
- ILaunchConfigurationType configType = getCLaunchConfigType();
- ILaunchConfigurationWorkingCopy wc =
- configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(bin.getElementName()));
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, projectName);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, bin.getCProject().getElementName());
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true);
- wc.setAttribute(
- ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
- ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, debugConfig.getID());
- config = wc.doSave();
- } catch (CoreException ce) {
- LaunchUIPlugin.log(ce);
- }
- return config;
- }
-
- /**
- * Method getCLaunchConfigType.
- * @return ILaunchConfigurationType
- */
- protected ILaunchConfigurationType getCLaunchConfigType() {
- return getLaunchManager().getLaunchConfigurationType(ESboxRemoteRunLaunchDelegate.ESBOX_CONFIG_TYPE); //the ID of the configuration type that we want to link with.
- }
-
- protected ILaunchManager getLaunchManager() {
- return DebugPlugin.getDefault().getLaunchManager();
- }
-
- /**
- * Convenience method to get the window that owns this action's Shell.
- */
- protected Shell getShell() {
- return LaunchUIPlugin.getActiveWorkbenchShell();
- }
-
- /**
- * Method chooseDebugConfig.
- * @param debugConfigs
- * @param mode
- * @return ICDebugConfiguration
- */
- private ICDebugConfiguration chooseDebugConfig(ICDebugConfiguration[] debugConfigs, String mode) {
- ILabelProvider provider = new LabelProvider() {
- /**
- * The <code>LabelProvider</code> implementation of this
- * <code>ILabelProvider</code> method returns the element's <code>toString</code>
- * string. Subclasses may override.
- */
- public String getText(Object element) {
- if (element == null) {
- return ""; //$NON-NLS-1$
- } else if (element instanceof ICDebugConfiguration) {
- return ((ICDebugConfiguration) element).getName();
- }
- return element.toString();
- }
- };
- ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), provider);
- dialog.setElements(debugConfigs);
- dialog.setTitle(getDebugConfigDialogTitleString(debugConfigs, mode));
- dialog.setMessage(getDebugConfigDialogMessageString(debugConfigs, mode));
- dialog.setMultipleSelection(false);
- int result = dialog.open();
- provider.dispose();
- if (result == Window.OK) {
- return (ICDebugConfiguration) dialog.getFirstResult();
- }
- return null;
- }
-
- protected String getDebugConfigDialogTitleString(ICDebugConfiguration [] configList, String mode) {
- return LaunchMessages.getString("CApplicationLaunchShortcut.LaunchDebugConfigSelection"); //$NON-NLS-1$
- }
-
- protected String getDebugConfigDialogMessageString(ICDebugConfiguration [] configList, String mode) {
- if (mode.equals(ILaunchManager.DEBUG_MODE)) {
- return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseConfigToDebug"); //$NON-NLS-1$
- } else if (mode.equals(ILaunchManager.RUN_MODE)) {
- return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseConfigToRun"); //$NON-NLS-1$
- }
- return LaunchMessages.getString("CApplicationLaunchShortcut.Invalid_launch_mode_1"); //$NON-NLS-1$
- }
-
-
- /**
- * Show a selection dialog that allows the user to choose one of the specified
- * launch configurations. Return the chosen config, or <code>null</code> if the
- * user cancelled the dialog.
- */
- protected ILaunchConfiguration chooseConfiguration(List configList, String mode) {
- IDebugModelPresentation labelProvider = DebugUITools.newDebugModelPresentation();
- ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
- dialog.setElements(configList.toArray());
- dialog.setTitle(getLaunchSelectionDialogTitleString(configList, mode));
- dialog.setMessage(getLaunchSelectionDialogMessageString(configList, mode));
- dialog.setMultipleSelection(false);
- int result = dialog.open();
- labelProvider.dispose();
- if (result == Window.OK) {
- return (ILaunchConfiguration) dialog.getFirstResult();
- }
- return null;
- }
-
- protected String getLaunchSelectionDialogTitleString(List configList, String mode) {
- return LaunchMessages.getString("CApplicationLaunchShortcut.LaunchConfigSelection"); //$NON-NLS-1$
- }
-
- protected String getLaunchSelectionDialogMessageString(List binList, String mode) {
- if (mode.equals(ILaunchManager.DEBUG_MODE)) {
- return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLaunchConfigToDebug"); //$NON-NLS-1$
- } else if (mode.equals(ILaunchManager.RUN_MODE)) {
- return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLaunchConfigToRun"); //$NON-NLS-1$
- }
- return LaunchMessages.getString("CApplicationLaunchShortcut.Invalid_launch_mode_2"); //$NON-NLS-1$
- }
-
- /**
- * Prompts the user to select a binary
- *
- * @return the selected binary or <code>null</code> if none.
- */
- protected IBinary chooseBinary(List binList, String mode) {
- ILabelProvider programLabelProvider = new CElementLabelProvider() {
- public String getText(Object element) {
- if (element instanceof IBinary) {
- IBinary bin = (IBinary)element;
- StringBuffer name = new StringBuffer();
- name.append(bin.getPath().lastSegment());
- return name.toString();
- }
- return super.getText(element);
- }
- };
-
- ILabelProvider qualifierLabelProvider = new CElementLabelProvider() {
- public String getText(Object element) {
- if (element instanceof IBinary) {
- IBinary bin = (IBinary)element;
- StringBuffer name = new StringBuffer();
- name.append(bin.getCPU() + (bin.isLittleEndian() ? "le" : "be")); //$NON-NLS-1$ //$NON-NLS-2$
- name.append(" - "); //$NON-NLS-1$
- name.append(bin.getPath().toString());
- return name.toString();
- }
- return super.getText(element);
- }
- };
-
- TwoPaneElementSelector dialog = new TwoPaneElementSelector(getShell(), programLabelProvider, qualifierLabelProvider);
- dialog.setElements(binList.toArray());
- dialog.setTitle(getBinarySelectionDialogTitleString(binList, mode)); //$NON-NLS-1$
- dialog.setMessage(getBinarySelectionDialogMessageString(binList, mode)); //$NON-NLS-1$
- dialog.setUpperListLabel(LaunchMessages.getString("Launch.common.BinariesColon")); //$NON-NLS-1$
- dialog.setLowerListLabel(LaunchMessages.getString("Launch.common.QualifierColon")); //$NON-NLS-1$
- dialog.setMultipleSelection(false);
- if (dialog.open() == Window.OK) {
- return (IBinary) dialog.getFirstResult();
- }
-
- return null;
- }
-
- protected String getBinarySelectionDialogTitleString(List binList, String mode) {
- return LaunchMessages.getString("CApplicationLaunchShortcut.CLocalApplication"); //$NON-NLS-1$
- }
-
- protected String getBinarySelectionDialogMessageString(List binList, String mode) {
- if (mode.equals(ILaunchManager.DEBUG_MODE)) {
- return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLocalAppToDebug"); //$NON-NLS-1$
- } else if (mode.equals(ILaunchManager.RUN_MODE)) {
- return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLocalAppToRun"); //$NON-NLS-1$
- }
- return LaunchMessages.getString("CApplicationLaunchShortcut.Invalid_launch_mode_3"); //$NON-NLS-1$
- }
-
- /**
- * Method searchAndLaunch.
- * @param objects
- * @param mode
- */
- private void searchAndLaunch(final Object[] elements, String mode) {
- if (elements != null && elements.length > 0) {
- IBinary bin = null;
- if (elements.length == 1 && elements[0] instanceof IBinary) {
- bin = (IBinary)elements[0];
- } else {
- final List results = new ArrayList();
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor pm) throws InterruptedException {
- int nElements = elements.length;
- pm.beginTask("Looking for executables", nElements); //$NON-NLS-1$
- try {
- IProgressMonitor sub = new SubProgressMonitor(pm, 1);
- for (int i = 0; i < nElements; i++) {
- if (elements[i] instanceof IAdaptable) {
- IResource r = (IResource) ((IAdaptable) elements[i]).getAdapter(IResource.class);
- if (r != null) {
- ICProject cproject = CoreModel.getDefault().create(r.getProject());
- if (cproject != null) {
- try {
- IBinary[] bins = cproject.getBinaryContainer().getBinaries();
-
- for (int j = 0; j < bins.length; j++) {
- if (bins[j].isExecutable()) {
- results.add(bins[j]);
- }
- }
- } catch (CModelException e) {
- }
- }
- }
- }
- if (pm.isCanceled()) {
- throw new InterruptedException();
- }
- sub.done();
- }
- } finally {
- pm.done();
- }
- }
- };
- try {
- dialog.run(true, true, runnable);
- } catch (InterruptedException e) {
- return;
- } catch (InvocationTargetException e) {
- MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), e.getMessage()); //$NON-NLS-1$
- return;
- }
- int count = results.size();
- if (count == 0) {
- MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_binaries")); //$NON-NLS-1$ //$NON-NLS-2$
- } else if (count > 1) {
- bin = chooseBinary(results, mode);
- } else {
- bin = (IBinary)results.get(0);
- }
- }
- if (bin != null) {
- launch(bin, mode);
- }
- } else {
- MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_project_selected")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
-
-
}
Added: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchConfigurationTabGroup.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchConfigurationTabGroup.java (rev 0)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchConfigurationTabGroup.java 2008-01-29 12:33:41 UTC (rev 396)
@@ -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.launch.valgrind;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+
+/**
+ *
+ */
+public class ValgrindLaunchConfigurationTabGroup 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
+
+ }
+
+}
Added: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchDelegate.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchDelegate.java (rev 0)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchDelegate.java 2008-01-29 12:33:41 UTC (rev 396)
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * 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.launch.valgrind;
+
+import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+
+/**
+ *
+ */
+public class ValgrindLaunchDelegate extends AbstractCLaunchDelegate {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.launch.AbstractCLaunchDelegate#getPluginID()
+ */
+ @Override
+ protected String getPluginID() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.launch.AbstractCLaunchDelegate#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
+
+ }
+
+}
Modified: trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchShortcut.java
===================================================================
--- trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchShortcut.java 2008-01-29 12:26:23 UTC (rev 395)
+++ trunk/org.indt.esbox.launch/src/org/indt/esbox/launch/valgrind/ValgrindLaunchShortcut.java 2008-01-29 12:33:41 UTC (rev 396)
@@ -10,56 +10,21 @@
*******************************************************************************/
package org.indt.esbox.launch.valgrind;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.debug.core.CDebugCorePlugin;
-import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
-import org.eclipse.cdt.debug.core.ICDebugConfiguration;
-import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
-import org.eclipse.cdt.ui.CElementLabelProvider;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.debug.core.DebugPlugin;
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.DebugUITools;
-import org.eclipse.debug.ui.IDebugModelPresentation;
-import org.eclipse.debug.ui.ILaunchShortcut;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
-import org.eclipse.ui.dialogs.TwoPaneElementSelector;
-import org.indt.esbox.launch.remote.ESboxRemoteRunLaunchDelegate;
+import org.indt.esbox.launch.AbstractLaunchShortcut;
/**
- * @author raul
*
*/
-public class ValgrindLaunchShortcut implements ILaunchShortcut {
+public class ValgrindLaunchShortcut extends AbstractLaunchShortcut {
public void launch(IEditorPart editor, String mode) {
searchAndLaunch(new Object[] { editor.getEditorInput()}, mode);
@@ -72,339 +37,15 @@
}
public void launch(IBinary bin, String mode) {
- // implementa aqui a execucao da ferramenta
-
- }
-
- /**
- * Locate a configuration to relaunch for the given type. If one cannot be found, create one.
- *
- * @return a re-useable config or <code>null</code> if none
- */
- protected ILaunchConfiguration findLaunchConfiguration(IBinary bin, String mode) {
- ILaunchConfiguration configuration = null;
- ILaunchConfigurationType configType = getCLaunchConfigType();
- List candidateConfigs = Collections.EMPTY_LIST;
try {
- ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configType);
- candidateConfigs = new ArrayList(configs.length);
- for (int i = 0; i < configs.length; i++) {
- ILaunchConfiguration config = configs[i];
- IPath programPath = AbstractCLaunchDelegate.getProgramPath(config);
- String projectName = AbstractCLaunchDelegate.getProjectName(config);
- IPath name = bin.getResource().getProjectRelativePath();
- if (programPath != null && programPath.equals(name)) {
- if (projectName != null && projectName.equals(bin.getCProject().getProject().getName())) {
- candidateConfigs.add(config);
- }
- }
+ ILaunchConfiguration config = findLaunchConfiguration(bin, mode);
+ if (config != null) {
+ DebugUITools.saveAndBuildBeforeLaunch();
+ config.launch(mode, null);
}
} catch (CoreException e) {
- LaunchUIPlugin.log(e);
+ LaunchUIPlugin.errorDialog(LaunchMessages.getString("CApplicationLaunchShortcut.LaunchFailed"), e.getStatus()); //$NON-NLS-1$
}
-
- // If there are no existing configs associated with the IBinary, create one.
- // If there is exactly one config associated with the IBinary, return it.
- // Otherwise, if there is more than one config associated with the IBinary, prompt the
- // user to choose one.
- int candidateCount = candidateConfigs.size();
- if (candidateCount < 1) {
- String programCPU = bin.getCPU();
-
- // Prompt the user if more then 1 debugger.
- ICDebugConfiguration debugConfig = null;
- ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
- List debugList = new ArrayList(debugConfigs.length);
- String os = Platform.getOS();
- for (int i = 0; i < debugConfigs.length; i++) {
- String platform = debugConfigs[i].getPlatform();
- if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
- if (platform.equals("*") || platform.equals(os)) { //$NON-NLS-1$
- if (debugConfigs[i].supportsCPU(programCPU))
- debugList.add(debugConfigs[i]);
- }
- }
- }
- debugConfigs = (ICDebugConfiguration[]) debugList.toArray(new ICDebugConfiguration[0]);
- if (debugConfigs.length == 1) {
- debugConfig = debugConfigs[0];
- } else if (debugConfigs.length > 1) {
- debugConfig = chooseDebugConfig(debugConfigs, mode);
- }
- if (debugConfig != null) {
- configuration = createConfiguration(bin, debugConfig);
- }
- } else if (candidateCount == 1) {
- configuration = (ILaunchConfiguration) candidateConfigs.get(0);
- } else {
- // Prompt the user to choose a config. A null result means the user
- // cancelled the dialog, in which case this method returns null,
- // since cancelling the dialog should also cancel launching anything.
- configuration = chooseConfiguration(candidateConfigs, mode);
- }
- return configuration;
}
-
- /**
- * Method createConfiguration.
- * @param bin
- * @return ILaunchConfiguration
- */
- private ILaunchConfiguration createConfiguration(IBinary bin, ICDebugConfiguration debugConfig) {
- ILaunchConfiguration config = null;
- try {
- String projectName = bin.getResource().getProjectRelativePath().toString();
- ILaunchConfigurationType configType = getCLaunchConfigType();
- ILaunchConfigurationWorkingCopy wc =
- configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(bin.getElementName()));
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, projectName);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, bin.getCProject().getElementName());
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true);
- wc.setAttribute(
- ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
- ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, debugConfig.getID());
- config = wc.doSave();
- } catch (CoreException ce) {
- LaunchUIPlugin.log(ce);
- }
- return config;
- }
-
- /**
- * Method getCLaunchConfigType.
- * @return ILaunchConfigurationType
- */
- protected ILaunchConfigurationType getCLaunchConfigType() {
- return getLaunchManager().getLaunchConfigurationType(ESboxRemoteRunLaunchDelegate.ESBOX_CONFIG_TYPE); //the ID of the configuration type that we want to link with.
- }
-
- protected ILaunchManager getLaunchManager() {
- return DebugPlugin.getDefault().getLaunchManager();
- }
-
- /**
- * Convenience method to get the window that owns this action's Shell.
- */
- protected Shell getShell() {
- return LaunchUIPlugin.getActiveWorkbenchShell();
- }
-
- /**
- * Method chooseDebugConfig.
- * @param debugConfigs
- * @param mode
- * @return ICDebugConfiguration
- */
- private ICDebugConfiguration chooseDebugConfig(ICDebugConfiguration[] debugConfigs, String mode) {
- ILabelProvider provider = new LabelProvider() {
- /**
- * The <code>LabelProvider</code> implementation of this
- * <code>ILabelProvider</code> method returns the element's <code>toString</code>
- * string. Subclasses may override.
- */
- public String getText(Object element) {
- if (element == null) {
- return ""; //$NON-NLS-1$
- } else if (element instanceof ICDebugConfiguration) {
- return ((ICDebugConfiguration) element).getName();
- }
- return element.toString();
- }
- };
- ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), provider);
- dialog.setElements(debugConfigs);
- dialog.setTitle(getDebugConfigDialogTitleString(debugConfigs, mode));
- dialog.setMessage(getDebugConfigDialogMessageString(debugConfigs, mode));
- dialog.setMultipleSelection(false);
- int result = dialog.open();
- provider.dispose();
- if (result == Window.OK) {
- return (ICDebugConfiguration) dialog.getFirstResult();
- }
- return null;
- }
-
- protected String getDebugConfigDialogTitleString(ICDebugConfiguration [] configList, String mode) {
- return LaunchMessages.getString("CApplicationLaunchShortcut.LaunchDebugConfigSelection"); //$NON-NLS-1$
- }
- protected String getDebugConfigDialogMessageString(ICDebugConfiguration [] configList, String mode) {
- if (mode.equals(ILaunchManager.DEBUG_MODE)) {
- return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseConfigToDebug"); //$NON-NLS-1$
- } else if (mode.equals(ILaunchManager.RUN_MODE)) {
- return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseConfigToRun"); //$NON-NLS-1$
- }
- return LaunchMessages.getString("CApplicationLaunchShortcut.Invalid_launch_mode_1"); //$NON-NLS-1$
- }
-
-
- /**
- * Show a selection dialog that allows the user to choose one of the specified
- * launch configurations. Return the chosen config, or <code>null</code> if the
- * user cancelled the dialog.
- */
- protected ILaunchConfiguration chooseConfiguration(List configList, String mode) {
- IDebugModelPresentation labelProvider = DebugUITools.newDebugModelPresentation();
- ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
- dialog.setElements(configList.toArray());
- dialog.setTitle(getLaunchSelectionDialogTitleString(configList, mode));
- dialog.setMessage(getLaunchSelectionDialogMessageString(configList, mode));
- dialog.setMultipleSelection(false);
- int result = dialog.open();
- labelProvider.dispose();
- if (result == Window.OK) {
- return (ILaunchConfiguration) dialog.getFirstResult();
- }
- return null;
- }
-
- protected String getLaunchSelectionDialogTitleString(List configList, String mode) {
- return LaunchMessages.getString("CApplicationLaunchShortcut.LaunchConfigSelection"); //$NON-NLS-1$
- }
-
- protected String getLaunchSelectionDialogMessageString(List binList, String mode) {
- if (mode.equals(ILaunchManager.DEBUG_MODE)) {
- return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLaunchConfigToDebug"); //$NON-NLS-1$
- } else if (mode.equals(ILaunchManager.RUN_MODE)) {
- return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLaunchConfigToRun"); //$NON-NLS-1$
- }
- return LaunchMessages.getString("CApplicationLaunchShortcut.Invalid_launch_mode_2"); //$NON-NLS-1$
- }
-
- /**
- * Prompts the user to select a binary
- *
- * @return the selected binary or <code>null</code> if none.
- */
- protected IBinary chooseBinary(List binList, String mode) {
- ILabelProvider programLabelProvider = new CElementLabelProvider() {
- public String getText(Object element) {
- if (element instanceof IBinary) {
- IBinary bin = (IBinary)element;
- StringBuffer name = new StringBuffer();
- name.append(bin.getPath().lastSegment());
- return name.toString();
- }
- return super.getText(element);
- }
- };
-
- ILabelProvider qualifierLabelProvider = new CElementLabelProvider() {
- public String getText(Object element) {
- if (element instanceof IBinary) {
- IBinary bin = (IBinary)element;
- StringBuffer name = new StringBuffer();
- name.append(bin.getCPU() + (bin.isLittleEndian() ? "le" : "be")); //$NON-NLS-1$ //$NON-NLS-2$
- name.append(" - "); //$NON-NLS-1$
- name.append(bin.getPath().toString());
- return name.toString();
- }
- return super.getText(element);
- }
- };
-
- TwoPaneElementSelector dialog = new TwoPaneElementSelector(getShell(), programLabelProvider, qualifierLabelProvider);
- dialog.setElements(binList.toArray());
- dialog.setTitle(getBinarySelectionDialogTitleString(binList, mode)); //$NON-NLS-1$
- dialog.setMessage(getBinarySelectionDialogMessageString(binList, mode)); //$NON-NLS-1$
- dialog.setUpperListLabel(LaunchMessages.getString("Launch.common.BinariesColon")); //$NON-NLS-1$
- dialog.setLowerListLabel(LaunchMessages.getString("Launch.common.QualifierColon")); //$NON-NLS-1$
- dialog.setMultipleSelection(false);
- if (dialog.open() == Window.OK) {
- return (IBinary) dialog.getFirstResult();
- }
-
- return null;
- }
-
- protected String getBinarySelectionDialogTitleString(List binList, String mode) {
- return LaunchMessages.getString("CApplicationLaunchShortcut.CLocalApplication"); //$NON-NLS-1$
- }
-
- protected String getBinarySelectionDialogMessageString(List binList, String mode) {
- if (mode.equals(ILaunchManager.DEBUG_MODE)) {
- return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLocalAppToDebug"); //$NON-NLS-1$
- } else if (mode.equals(ILaunchManager.RUN_MODE)) {
- return LaunchMessages.getString("CApplicationLaunchShortcut.ChooseLocalAppToRun"); //$NON-NLS-1$
- }
- return LaunchMessages.getString("CApplicationLaunchShortcut.Invalid_launch_mode_3"); //$NON-NLS-1$
- }
-
- /**
- * Method searchAndLaunch.
- * @param objects
- * @param mode
- */
- private void searchAndLaunch(final Object[] elements, String mode) {
- if (elements != null && elements.length > 0) {
- IBinary bin = null;
- if (elements.length == 1 && elements[0] instanceof IBinary) {
- bin = (IBinary)elements[0];
- } else {
- final List results = new ArrayList();
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor pm) throws InterruptedException {
- int nElements = elements.length;
- pm.beginTask("Looking for executables", nElements); //$NON-NLS-1$
- try {
- IProgressMonitor sub = new SubProgressMonitor(pm, 1);
- for (int i = 0; i < nElements; i++) {
- if (elements[i] instanceof IAdaptable) {
- IResource r = (IResource) ((IAdaptable) elements[i]).getAdapter(IResource.class);
- if (r != null) {
- ICProject cproject = CoreModel.getDefault().create(r.getProject());
- if (cproject != null) {
- try {
- IBinary[] bins = cproject.getBinaryContainer().getBinaries();
-
- for (int j = 0; j < bins.length; j++) {
- if (bins[j].isExecutable()) {
- results.add(bins[j]);
- }
- }
- } catch (CModelException e) {
- }
- }
- }
- }
- if (pm.isCanceled()) {
- throw new InterruptedException();
- }
- sub.done();
- }
- } finally {
- pm.done();
- }
- }
- };
- try {
- dialog.run(true, true, runnable);
- } catch (InterruptedException e) {
- return;
- } catch (InvocationTargetException e) {
- MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), e.getMessage()); //$NON-NLS-1$
- return;
- }
- int count = results.size();
- if (count == 0) {
- MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_binaries")); //$NON-NLS-1$ //$NON-NLS-2$
- } else if (count > 1) {
- bin = chooseBinary(results, mode);
- } else {
- bin = (IBinary)results.get(0);
- }
- }
- if (bin != null) {
- launch(bin, mode);
- }
- } else {
- MessageDialog.openError(getShell(), LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_project_selected")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
-
-
}
More information about the Esbox-commits
mailing list