mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 228265
Remove org.eclipse.cdt.launch dependency from org.eclipse.dd.gdb.ui Mostly copy/paste from cdt.launch. A cleanup would eventually be nice.
This commit is contained in:
parent
55369d3ccb
commit
ff33479c3d
13 changed files with 1450 additions and 14 deletions
|
@ -17,7 +17,7 @@ Require-Bundle: org.eclipse.ui,
|
||||||
org.eclipse.dd.dsf.debug,
|
org.eclipse.dd.dsf.debug,
|
||||||
org.eclipse.cdt.debug.ui,
|
org.eclipse.cdt.debug.ui,
|
||||||
org.eclipse.cdt.core,
|
org.eclipse.cdt.core,
|
||||||
org.eclipse.cdt.launch
|
org.eclipse.cdt.ui
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||||
Export-Package: org.eclipse.dd.gdb.internal.ui.launching
|
Export-Package: org.eclipse.dd.gdb.internal.ui.launching
|
||||||
|
|
BIN
plugins/org.eclipse.dd.gdb.ui/icons/full/view16/debugger_tab.gif
Normal file
BIN
plugins/org.eclipse.dd.gdb.ui/icons/full/view16/debugger_tab.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 348 B |
BIN
plugins/org.eclipse.dd.gdb.ui/icons/full/view16/main_tab.gif
Normal file
BIN
plugins/org.eclipse.dd.gdb.ui/icons/full/view16/main_tab.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 354 B |
|
@ -1,5 +1,23 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 Wind River Systems and others.
|
||||||
|
* 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:
|
||||||
|
* Wind River Systems - initial API and implementation
|
||||||
|
* Ericsson - modified to remove dependency on cdt.launch
|
||||||
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.gdb.internal.ui;
|
package org.eclipse.dd.gdb.internal.ui;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.dd.gdb.internal.provisional.launching.LaunchMessages;
|
||||||
|
import org.eclipse.jface.dialogs.ErrorDialog;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
|
@ -56,4 +74,116 @@ public class GdbUIPlugin extends AbstractUIPlugin {
|
||||||
public static BundleContext getBundleContext() {
|
public static BundleContext getBundleContext() {
|
||||||
return fgBundleContext;
|
return fgBundleContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* copied from org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin
|
||||||
|
*/
|
||||||
|
private static Shell debugDialogShell;
|
||||||
|
|
||||||
|
public static Shell getShell() {
|
||||||
|
if (getActiveWorkbenchShell() != null) {
|
||||||
|
return getActiveWorkbenchShell();
|
||||||
|
}
|
||||||
|
if (debugDialogShell != null) {
|
||||||
|
if (!debugDialogShell.isDisposed())
|
||||||
|
return debugDialogShell;
|
||||||
|
debugDialogShell = null;
|
||||||
|
}
|
||||||
|
IWorkbenchWindow[] windows = getDefault().getWorkbench().getWorkbenchWindows();
|
||||||
|
return windows[0].getShell();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setDialogShell(Shell shell) {
|
||||||
|
debugDialogShell = shell;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method which returns the unique identifier of this plugin.
|
||||||
|
*/
|
||||||
|
public static String getUniqueIdentifier() {
|
||||||
|
if (getDefault() == null) {
|
||||||
|
// If the default instance is not yet initialized,
|
||||||
|
// return a static identifier. This identifier must
|
||||||
|
// match the plugin id defined in plugin.xml
|
||||||
|
return PLUGIN_ID;
|
||||||
|
}
|
||||||
|
return getDefault().getBundle().getSymbolicName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs the specified status with this plug-in's log.
|
||||||
|
*
|
||||||
|
* @param status
|
||||||
|
* status to log
|
||||||
|
*/
|
||||||
|
public static void log(IStatus status) {
|
||||||
|
getDefault().getLog().log(status);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Logs an internal error with the specified message.
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* the error message to log
|
||||||
|
*/
|
||||||
|
public static void logErrorMessage(String message) {
|
||||||
|
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, message, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs an internal error with the specified throwable
|
||||||
|
*
|
||||||
|
* @param e
|
||||||
|
* the exception to be logged
|
||||||
|
*/
|
||||||
|
public static void log(Throwable e) {
|
||||||
|
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, e.getMessage(), e));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the active workbench window
|
||||||
|
*
|
||||||
|
* @return the active workbench window
|
||||||
|
*/
|
||||||
|
public static IWorkbenchWindow getActiveWorkbenchWindow() {
|
||||||
|
return getDefault().getWorkbench().getActiveWorkbenchWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IWorkbenchPage getActivePage() {
|
||||||
|
IWorkbenchWindow w = getActiveWorkbenchWindow();
|
||||||
|
if (w != null) {
|
||||||
|
return w.getActivePage();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the active workbench shell or <code>null</code> if none
|
||||||
|
*
|
||||||
|
* @return the active workbench shell or <code>null</code> if none
|
||||||
|
*/
|
||||||
|
public static Shell getActiveWorkbenchShell() {
|
||||||
|
IWorkbenchWindow window = getActiveWorkbenchWindow();
|
||||||
|
if (window != null) {
|
||||||
|
return window.getShell();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void errorDialog(String message, IStatus status) {
|
||||||
|
log(status);
|
||||||
|
Shell shell = getActiveWorkbenchShell();
|
||||||
|
if (shell != null) {
|
||||||
|
ErrorDialog.openError(shell, LaunchMessages.getString("LaunchUIPlugin.Error"), message, status); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void errorDialog(String message, Throwable t) {
|
||||||
|
log(t);
|
||||||
|
Shell shell = getActiveWorkbenchShell();
|
||||||
|
if (shell != null) {
|
||||||
|
IStatus status = new Status(IStatus.ERROR, getUniqueIdentifier(), 1, t.getMessage(), null);
|
||||||
|
ErrorDialog.openError(shell, LaunchMessages.getString("LaunchUIPlugin.Error"), message, status); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,346 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 QNX Software Systems and others.
|
||||||
|
* 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:
|
||||||
|
* QNX Software Systems - initial API and implementation
|
||||||
|
* IBM Corporation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.dd.gdb.internal.ui.launching;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
|
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
|
||||||
|
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||||
|
import org.eclipse.cdt.debug.ui.ICDebuggerPage;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.dd.gdb.internal.provisional.launching.LaunchMessages;
|
||||||
|
import org.eclipse.dd.gdb.internal.ui.GdbUIPlugin;
|
||||||
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
|
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||||
|
import org.eclipse.debug.ui.ILaunchConfigurationTab;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.events.SelectionListener;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Combo;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Group;
|
||||||
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
|
||||||
|
public abstract class AbstractCDebuggerTab extends CLaunchConfigurationTab {
|
||||||
|
|
||||||
|
protected ILaunchConfiguration fLaunchConfiguration;
|
||||||
|
protected ILaunchConfigurationWorkingCopy fWorkingCopy;
|
||||||
|
protected ICDebugConfiguration fCurrentDebugConfig;
|
||||||
|
|
||||||
|
// Dynamic Debugger UI widgets
|
||||||
|
protected ICDebuggerPage fDynamicTab;
|
||||||
|
protected Composite fDynamicTabHolder;
|
||||||
|
private boolean fInitDefaults;
|
||||||
|
private Combo fDCombo;
|
||||||
|
private boolean fIsInitializing = false;
|
||||||
|
private boolean fPageUpdated;
|
||||||
|
|
||||||
|
protected void setDebugConfig(ICDebugConfiguration config) {
|
||||||
|
fCurrentDebugConfig = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ICDebugConfiguration getDebugConfig() {
|
||||||
|
return fCurrentDebugConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ICDebuggerPage getDynamicTab() {
|
||||||
|
return fDynamicTab;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setDynamicTab(ICDebuggerPage tab) {
|
||||||
|
fDynamicTab = tab;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Composite getDynamicTabHolder() {
|
||||||
|
return fDynamicTabHolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setDynamicTabHolder(Composite tabHolder) {
|
||||||
|
fDynamicTabHolder = tabHolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ILaunchConfigurationWorkingCopy getLaunchConfigurationWorkingCopy() {
|
||||||
|
return fWorkingCopy;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setLaunchConfiguration(ILaunchConfiguration launchConfiguration) {
|
||||||
|
fLaunchConfiguration = launchConfiguration;
|
||||||
|
setLaunchConfigurationWorkingCopy(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ILaunchConfiguration getLaunchConfiguration() {
|
||||||
|
return fLaunchConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setLaunchConfigurationWorkingCopy(ILaunchConfigurationWorkingCopy workingCopy) {
|
||||||
|
fWorkingCopy = workingCopy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overridden here so that any error message in the dynamic UI gets
|
||||||
|
* returned.
|
||||||
|
*
|
||||||
|
* @see ILaunchConfigurationTab#getErrorMessage()
|
||||||
|
*/
|
||||||
|
public String getErrorMessage() {
|
||||||
|
ICDebuggerPage tab = getDynamicTab();
|
||||||
|
if ( (super.getErrorMessage() != null) || (tab == null)) {
|
||||||
|
return super.getErrorMessage();
|
||||||
|
}
|
||||||
|
return tab.getErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notification that the user changed the selection of the Debugger.
|
||||||
|
*/
|
||||||
|
protected void handleDebuggerChanged() {
|
||||||
|
loadDynamicDebugArea();
|
||||||
|
|
||||||
|
// always set the newly created area with defaults
|
||||||
|
ILaunchConfigurationWorkingCopy wc = getLaunchConfigurationWorkingCopy();
|
||||||
|
if (getDynamicTab() == null) {
|
||||||
|
// remove any debug specfic args from the config
|
||||||
|
if (wc == null) {
|
||||||
|
if (getLaunchConfiguration().isWorkingCopy()) {
|
||||||
|
wc = (ILaunchConfigurationWorkingCopy)getLaunchConfiguration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wc != null) {
|
||||||
|
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map)null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (wc == null) {
|
||||||
|
try {
|
||||||
|
if (getLaunchConfiguration().isWorkingCopy()) {
|
||||||
|
setLaunchConfigurationWorkingCopy((ILaunchConfigurationWorkingCopy)getLaunchConfiguration());
|
||||||
|
} else {
|
||||||
|
setLaunchConfigurationWorkingCopy(getLaunchConfiguration().getWorkingCopy());
|
||||||
|
}
|
||||||
|
wc = getLaunchConfigurationWorkingCopy();
|
||||||
|
|
||||||
|
} catch (CoreException e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (initDefaults()) {
|
||||||
|
getDynamicTab().setDefaults(wc);
|
||||||
|
}
|
||||||
|
setInitializeDefault(false);
|
||||||
|
getDynamicTab().initializeFrom(wc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the contributed piece of UI that was registered for the debugger id
|
||||||
|
* of the currently selected debugger.
|
||||||
|
*/
|
||||||
|
protected void loadDynamicDebugArea() {
|
||||||
|
// Dispose of any current child widgets in the tab holder area
|
||||||
|
Control[] children = getDynamicTabHolder().getChildren();
|
||||||
|
for (int i = 0; i < children.length; i++) {
|
||||||
|
children[i].dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve the dynamic UI for the current Debugger
|
||||||
|
ICDebugConfiguration debugConfig = getConfigForCurrentDebugger();
|
||||||
|
if (debugConfig == null) {
|
||||||
|
setDynamicTab(null);
|
||||||
|
} else {
|
||||||
|
ICDebuggerPage tab = null;
|
||||||
|
try {
|
||||||
|
tab = CDebugUIPlugin.getDefault().getDebuggerPage(debugConfig.getID());
|
||||||
|
} catch (CoreException e) {
|
||||||
|
GdbUIPlugin.errorDialog(LaunchMessages.getString("AbstractCDebuggerTab.ErrorLoadingDebuggerPage"), e.getStatus()); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
setDynamicTab(tab);
|
||||||
|
}
|
||||||
|
setDebugConfig(debugConfig);
|
||||||
|
if (getDynamicTab() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Ask the dynamic UI to create its Control
|
||||||
|
getDynamicTab().setLaunchConfigurationDialog(getLaunchConfigurationDialog());
|
||||||
|
getDynamicTab().createControl(getDynamicTabHolder());
|
||||||
|
getDynamicTab().getControl().setVisible(true);
|
||||||
|
getDynamicTabHolder().layout(true);
|
||||||
|
contentsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called whenever the controls within the Debugger tab has changed.
|
||||||
|
*/
|
||||||
|
protected void contentsChanged() {
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract public void createControl(Composite parent);
|
||||||
|
|
||||||
|
public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
|
||||||
|
ICDebuggerPage dynamicTab = getDynamicTab();
|
||||||
|
if (dynamicTab != null) {
|
||||||
|
dynamicTab.activated(workingCopy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initializeFrom(ILaunchConfiguration config) {
|
||||||
|
setLaunchConfiguration(config);
|
||||||
|
ICDebuggerPage dynamicTab = getDynamicTab();
|
||||||
|
if (dynamicTab != null) {
|
||||||
|
dynamicTab.initializeFrom(config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void performApply(ILaunchConfigurationWorkingCopy config) {
|
||||||
|
if (getDebugConfig() != null) {
|
||||||
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, getDebugConfig().getID());
|
||||||
|
ICDebuggerPage dynamicTab = getDynamicTab();
|
||||||
|
if (dynamicTab == null) {
|
||||||
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map)null);
|
||||||
|
} else {
|
||||||
|
dynamicTab.performApply(config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
|
||||||
|
setLaunchConfigurationWorkingCopy(config);
|
||||||
|
ICDebuggerPage dynamicTab = getDynamicTab();
|
||||||
|
if (dynamicTab != null) {
|
||||||
|
dynamicTab.setDefaults(config);
|
||||||
|
setInitializeDefault(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValid(ILaunchConfiguration config) {
|
||||||
|
setErrorMessage(null);
|
||||||
|
setMessage(null);
|
||||||
|
if (getDebugConfig() == null) {
|
||||||
|
setErrorMessage(LaunchMessages.getString("AbstractCDebuggerTab.No_debugger_available")); //$NON-NLS-1$
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ICDebuggerPage dynamicTab = getDynamicTab();
|
||||||
|
if (dynamicTab != null) {
|
||||||
|
return dynamicTab.isValid(config);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setInitializeDefault(boolean init) {
|
||||||
|
fInitDefaults = init;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean initDefaults() {
|
||||||
|
return fInitDefaults;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image getImage() {
|
||||||
|
return LaunchImages.get(LaunchImages.IMG_VIEW_DEBUGGER_TAB);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return LaunchMessages.getString("AbstractCDebuggerTab.Debugger"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void createDebuggerCombo(Composite parent, int colspan) {
|
||||||
|
Composite comboComp = new Composite(parent, SWT.NONE);
|
||||||
|
GridLayout layout = new GridLayout(2, false);
|
||||||
|
comboComp.setLayout(layout);
|
||||||
|
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
gd.horizontalSpan = colspan;
|
||||||
|
comboComp.setLayoutData(gd);
|
||||||
|
Label dlabel = new Label(comboComp, SWT.NONE);
|
||||||
|
dlabel.setText(LaunchMessages.getString("Launch.common.DebuggerColon")); //$NON-NLS-1$
|
||||||
|
fDCombo = new Combo(comboComp, SWT.READ_ONLY | SWT.DROP_DOWN);
|
||||||
|
fDCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||||
|
fDCombo.addSelectionListener(new SelectionListener() {
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
if (!isInitializing()) {
|
||||||
|
setInitializeDefault(true);
|
||||||
|
updateComboFromSelection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void loadDebuggerCombo(ICDebugConfiguration[] debugConfigs, String current) {
|
||||||
|
fDCombo.removeAll();
|
||||||
|
int select = -1;
|
||||||
|
for (int i = 0; i < debugConfigs.length; i++) {
|
||||||
|
fDCombo.add(debugConfigs[i].getName());
|
||||||
|
fDCombo.setData(Integer.toString(i), debugConfigs[i]);
|
||||||
|
if (debugConfigs[i].getID().equalsIgnoreCase(current)) {
|
||||||
|
select = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fPageUpdated = false;
|
||||||
|
if (select != -1) {
|
||||||
|
fDCombo.select(select);
|
||||||
|
}
|
||||||
|
//The behaviour is undefined for if the callbacks should be triggered
|
||||||
|
// for this,
|
||||||
|
//so force page update if needed.
|
||||||
|
if (!fPageUpdated) {
|
||||||
|
updateComboFromSelection();
|
||||||
|
}
|
||||||
|
fPageUpdated = false;
|
||||||
|
getControl().getParent().layout(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void createDebuggerGroup(Composite parent, int colspan) {
|
||||||
|
Group debuggerGroup = new Group(parent, SWT.SHADOW_ETCHED_IN);
|
||||||
|
debuggerGroup.setText(LaunchMessages.getString("CDebuggerTab.Debugger_Options")); //$NON-NLS-1$
|
||||||
|
setDynamicTabHolder(debuggerGroup);
|
||||||
|
GridLayout tabHolderLayout = new GridLayout();
|
||||||
|
tabHolderLayout.marginHeight = 0;
|
||||||
|
tabHolderLayout.marginWidth = 0;
|
||||||
|
tabHolderLayout.numColumns = 1;
|
||||||
|
getDynamicTabHolder().setLayout(tabHolderLayout);
|
||||||
|
GridData gd = new GridData(GridData.FILL_BOTH);
|
||||||
|
gd.horizontalSpan = colspan;
|
||||||
|
getDynamicTabHolder().setLayoutData(gd);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateComboFromSelection() {
|
||||||
|
fPageUpdated = true;
|
||||||
|
handleDebuggerChanged();
|
||||||
|
updateLaunchConfigurationDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isInitializing() {
|
||||||
|
return fIsInitializing;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setInitializing(boolean isInitializing) {
|
||||||
|
fIsInitializing = isInitializing;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the class that implements <code>ICDebuggerPage</code>
|
||||||
|
* that is registered against the debugger id of the currently selected
|
||||||
|
* debugger.
|
||||||
|
*/
|
||||||
|
protected ICDebugConfiguration getConfigForCurrentDebugger() {
|
||||||
|
int selectedIndex = fDCombo.getSelectionIndex();
|
||||||
|
return (ICDebugConfiguration)fDCombo.getData(Integer.toString(selectedIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007, 2008 QNX Software Systems and others.
|
* Copyright (c) 2008 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -35,15 +35,13 @@ import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
|
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
|
||||||
import org.eclipse.cdt.debug.core.ICDebugConstants;
|
import org.eclipse.cdt.debug.core.ICDebugConstants;
|
||||||
import org.eclipse.cdt.debug.ui.ICDebuggerPage;
|
import org.eclipse.cdt.debug.ui.ICDebuggerPage;
|
||||||
import org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab;
|
|
||||||
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
|
|
||||||
import org.eclipse.cdt.launch.ui.ICDTLaunchHelpContextIds;
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.dd.gdb.internal.provisional.IGDBLaunchConfigurationConstants;
|
import org.eclipse.dd.gdb.internal.provisional.IGDBLaunchConfigurationConstants;
|
||||||
|
import org.eclipse.dd.gdb.internal.provisional.launching.LaunchMessages;
|
||||||
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl.SessionType;
|
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl.SessionType;
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||||
|
@ -546,11 +544,6 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.launch.internal.ui.AbstractCDebuggerTab#setInitializeDefault(boolean)
|
|
||||||
*/
|
|
||||||
protected void setInitializeDefault(boolean init) {
|
protected void setInitializeDefault(boolean init) {
|
||||||
super.setInitializeDefault(init);
|
super.setInitializeDefault(init);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,147 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 QNX Software Systems and others.
|
||||||
|
* 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:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* Ken Ryall (Nokia) - bug 178731
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.dd.gdb.internal.ui.launching;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
import org.eclipse.dd.gdb.internal.ui.GdbUIPlugin;
|
||||||
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
|
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||||
|
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.ui.IEditorInput;
|
||||||
|
import org.eclipse.ui.IEditorPart;
|
||||||
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
|
|
||||||
|
public abstract class CLaunchConfigurationTab extends AbstractLaunchConfigurationTab {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current C element context from which to initialize default
|
||||||
|
* settings, or <code>null</code> if none. Note, if possible we will
|
||||||
|
* return the IBinary based on config entry as this may be more usefull then
|
||||||
|
* just the project.
|
||||||
|
*
|
||||||
|
* @return C element context.
|
||||||
|
*/
|
||||||
|
protected ICElement getContext(ILaunchConfiguration config, String platform) {
|
||||||
|
String projectName = null;
|
||||||
|
String programName = null;
|
||||||
|
IWorkbenchPage page = GdbUIPlugin.getActivePage();
|
||||||
|
Object obj = null;
|
||||||
|
try {
|
||||||
|
projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null);
|
||||||
|
programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
}
|
||||||
|
if (projectName != null && !projectName.equals("")) { //$NON-NLS-1$
|
||||||
|
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
||||||
|
ICProject cProject = CCorePlugin.getDefault().getCoreModel().create(project);
|
||||||
|
if (cProject != null && cProject.exists()) {
|
||||||
|
obj = cProject;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (page != null) {
|
||||||
|
ISelection selection = page.getSelection();
|
||||||
|
if (selection instanceof IStructuredSelection) {
|
||||||
|
IStructuredSelection ss = (IStructuredSelection)selection;
|
||||||
|
if (!ss.isEmpty()) {
|
||||||
|
obj = ss.getFirstElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (obj instanceof IResource) {
|
||||||
|
ICElement ce = CoreModel.getDefault().create((IResource)obj);
|
||||||
|
if (ce == null) {
|
||||||
|
IProject pro = ((IResource)obj).getProject();
|
||||||
|
ce = CoreModel.getDefault().create(pro);
|
||||||
|
}
|
||||||
|
obj = ce;
|
||||||
|
}
|
||||||
|
if (obj instanceof ICElement) {
|
||||||
|
if (platform != null && !platform.equals("*")) { //$NON-NLS-1$
|
||||||
|
ICDescriptor descriptor;
|
||||||
|
try {
|
||||||
|
descriptor = CCorePlugin.getDefault().getCProjectDescription( ((ICElement)obj).getCProject().getProject(),
|
||||||
|
false);
|
||||||
|
if (descriptor != null) {
|
||||||
|
String projectPlatform = descriptor.getPlatform();
|
||||||
|
if (!projectPlatform.equals(platform) && !projectPlatform.equals("*")) { //$NON-NLS-1$
|
||||||
|
obj = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (obj != null) {
|
||||||
|
if (programName == null || programName.equals("")) { //$NON-NLS-1$
|
||||||
|
return (ICElement)obj;
|
||||||
|
}
|
||||||
|
ICElement ce = (ICElement)obj;
|
||||||
|
IProject project;
|
||||||
|
project = (IProject)ce.getCProject().getResource();
|
||||||
|
IPath programFile = project.getFile(programName).getLocation();
|
||||||
|
ce = CCorePlugin.getDefault().getCoreModel().create(programFile);
|
||||||
|
if (ce != null && ce.exists()) {
|
||||||
|
return ce;
|
||||||
|
}
|
||||||
|
return (ICElement)obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IEditorPart part = page.getActiveEditor();
|
||||||
|
if (part != null) {
|
||||||
|
IEditorInput input = part.getEditorInput();
|
||||||
|
return (ICElement)input.getAdapter(ICElement.class);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the C project attribute based on the ICElement.
|
||||||
|
*/
|
||||||
|
protected void initializeCProject(ICElement cElement, ILaunchConfigurationWorkingCopy config) {
|
||||||
|
ICProject cProject = cElement.getCProject();
|
||||||
|
String name = null;
|
||||||
|
if (cProject != null && cProject.exists()) {
|
||||||
|
name = cProject.getElementName();
|
||||||
|
config.setMappedResources(new IResource[] {cProject.getProject()});
|
||||||
|
|
||||||
|
ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(cProject.getProject());
|
||||||
|
String buildConfigID = projDes.getActiveConfiguration().getId();
|
||||||
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, buildConfigID);
|
||||||
|
|
||||||
|
}
|
||||||
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, name);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getPlatform(ILaunchConfiguration config) {
|
||||||
|
String platform = Platform.getOS();
|
||||||
|
try {
|
||||||
|
return config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PLATFORM, platform);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
return platform;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,717 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 QNX Software Systems and others.
|
||||||
|
* 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:
|
||||||
|
* QNX Software Systems - initial API and implementation
|
||||||
|
* Ken Ryall (Nokia) - bug 178731
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.dd.gdb.internal.ui.launching;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.IBinaryParser;
|
||||||
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
|
import org.eclipse.cdt.core.ICExtensionReference;
|
||||||
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
||||||
|
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.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
|
import org.eclipse.cdt.ui.CElementLabelProvider;
|
||||||
|
import org.eclipse.cdt.utils.pty.PTY;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
import org.eclipse.dd.gdb.internal.provisional.launching.LaunchMessages;
|
||||||
|
import org.eclipse.dd.gdb.internal.ui.GdbUIPlugin;
|
||||||
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
|
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||||
|
import org.eclipse.debug.ui.DebugUITools;
|
||||||
|
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||||
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
|
import org.eclipse.jface.viewers.ILabelProvider;
|
||||||
|
import org.eclipse.jface.window.Window;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.custom.BusyIndicator;
|
||||||
|
import org.eclipse.swt.events.ModifyEvent;
|
||||||
|
import org.eclipse.swt.events.ModifyListener;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Button;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.swt.widgets.FileDialog;
|
||||||
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
|
||||||
|
import org.eclipse.ui.dialogs.TwoPaneElementSelector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A launch configuration tab that displays and edits project and main type name launch
|
||||||
|
* configuration attributes.
|
||||||
|
* <p>
|
||||||
|
* This class may be instantiated. This class is not intended to be subclassed.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @since 2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class CMainTab extends CLaunchConfigurationTab {
|
||||||
|
|
||||||
|
// Project UI widgets
|
||||||
|
protected Label fProjLabel;
|
||||||
|
protected Text fProjText;
|
||||||
|
protected Button fProjButton;
|
||||||
|
|
||||||
|
// Main class UI widgets
|
||||||
|
protected Label fProgLabel;
|
||||||
|
protected Text fProgText;
|
||||||
|
protected Button fSearchButton;
|
||||||
|
|
||||||
|
private final boolean fWantsTerminalOption;
|
||||||
|
protected Button fTerminalButton;
|
||||||
|
|
||||||
|
private final boolean dontCheckProgram;
|
||||||
|
|
||||||
|
protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private String filterPlatform = EMPTY_STRING;
|
||||||
|
|
||||||
|
public static final int WANTS_TERMINAL = 1;
|
||||||
|
public static final int DONT_CHECK_PROGRAM = 2;
|
||||||
|
|
||||||
|
public CMainTab() {
|
||||||
|
this(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CMainTab(boolean terminalOption) {
|
||||||
|
this(terminalOption ? WANTS_TERMINAL : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CMainTab(int flags) {
|
||||||
|
fWantsTerminalOption = (flags & WANTS_TERMINAL) != 0;
|
||||||
|
dontCheckProgram = (flags & DONT_CHECK_PROGRAM) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
|
||||||
|
*/
|
||||||
|
public void createControl(Composite parent) {
|
||||||
|
Composite comp = new Composite(parent, SWT.NONE);
|
||||||
|
setControl(comp);
|
||||||
|
|
||||||
|
GdbUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_MAIN_TAB);
|
||||||
|
|
||||||
|
GridLayout topLayout = new GridLayout();
|
||||||
|
comp.setLayout(topLayout);
|
||||||
|
|
||||||
|
createVerticalSpacer(comp, 1);
|
||||||
|
createProjectGroup(comp, 1);
|
||||||
|
createExeFileGroup(comp, 1);
|
||||||
|
createVerticalSpacer(comp, 1);
|
||||||
|
if (wantsTerminalOption() /* && ProcessFactory.supportesTerminal() */) {
|
||||||
|
createTerminalOption(comp, 1);
|
||||||
|
}
|
||||||
|
GdbUIPlugin.setDialogShell(parent.getShell());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void createProjectGroup(Composite parent, int colSpan) {
|
||||||
|
Composite projComp = new Composite(parent, SWT.NONE);
|
||||||
|
GridLayout projLayout = new GridLayout();
|
||||||
|
projLayout.numColumns = 2;
|
||||||
|
projLayout.marginHeight = 0;
|
||||||
|
projLayout.marginWidth = 0;
|
||||||
|
projComp.setLayout(projLayout);
|
||||||
|
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
gd.horizontalSpan = colSpan;
|
||||||
|
projComp.setLayoutData(gd);
|
||||||
|
|
||||||
|
fProjLabel = new Label(projComp, SWT.NONE);
|
||||||
|
fProjLabel.setText(LaunchMessages.getString("CMainTab.&ProjectColon")); //$NON-NLS-1$
|
||||||
|
gd = new GridData();
|
||||||
|
gd.horizontalSpan = 2;
|
||||||
|
fProjLabel.setLayoutData(gd);
|
||||||
|
|
||||||
|
fProjText = new Text(projComp, SWT.SINGLE | SWT.BORDER);
|
||||||
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
fProjText.setLayoutData(gd);
|
||||||
|
fProjText.addModifyListener(new ModifyListener() {
|
||||||
|
|
||||||
|
public void modifyText(ModifyEvent evt) {
|
||||||
|
updateLaunchConfigurationDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
fProjButton = createPushButton(projComp, LaunchMessages.getString("Launch.common.Browse_1"), null); //$NON-NLS-1$
|
||||||
|
fProjButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
|
public void widgetSelected(SelectionEvent evt) {
|
||||||
|
handleProjectButtonSelected();
|
||||||
|
updateLaunchConfigurationDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void createExeFileGroup(Composite parent, int colSpan) {
|
||||||
|
Composite mainComp = new Composite(parent, SWT.NONE);
|
||||||
|
GridLayout mainLayout = new GridLayout();
|
||||||
|
mainLayout.numColumns = 3;
|
||||||
|
mainLayout.marginHeight = 0;
|
||||||
|
mainLayout.marginWidth = 0;
|
||||||
|
mainComp.setLayout(mainLayout);
|
||||||
|
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
gd.horizontalSpan = colSpan;
|
||||||
|
mainComp.setLayoutData(gd);
|
||||||
|
fProgLabel = new Label(mainComp, SWT.NONE);
|
||||||
|
fProgLabel.setText(LaunchMessages.getString("CMainTab.C/C++_Application")); //$NON-NLS-1$
|
||||||
|
gd = new GridData();
|
||||||
|
gd.horizontalSpan = 3;
|
||||||
|
fProgLabel.setLayoutData(gd);
|
||||||
|
fProgText = new Text(mainComp, SWT.SINGLE | SWT.BORDER);
|
||||||
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
fProgText.setLayoutData(gd);
|
||||||
|
fProgText.addModifyListener(new ModifyListener() {
|
||||||
|
public void modifyText(ModifyEvent evt) {
|
||||||
|
updateLaunchConfigurationDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
fSearchButton = createPushButton(mainComp, LaunchMessages.getString("CMainTab.Search..."), null); //$NON-NLS-1$
|
||||||
|
fSearchButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
public void widgetSelected(SelectionEvent evt) {
|
||||||
|
handleSearchButtonSelected();
|
||||||
|
updateLaunchConfigurationDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Button fBrowseForBinaryButton;
|
||||||
|
fBrowseForBinaryButton = createPushButton(mainComp, LaunchMessages.getString("Launch.common.Browse_2"), null); //$NON-NLS-1$
|
||||||
|
fBrowseForBinaryButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
public void widgetSelected(SelectionEvent evt) {
|
||||||
|
handleBinaryBrowseButtonSelected();
|
||||||
|
updateLaunchConfigurationDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean wantsTerminalOption() {
|
||||||
|
return fWantsTerminalOption;
|
||||||
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
|
||||||
|
*/
|
||||||
|
public void initializeFrom(ILaunchConfiguration config) {
|
||||||
|
filterPlatform = getPlatform(config);
|
||||||
|
updateProjectFromConfig(config);
|
||||||
|
updateProgramFromConfig(config);
|
||||||
|
updateTerminalFromConfig(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateTerminalFromConfig(ILaunchConfiguration config) {
|
||||||
|
if (fTerminalButton != null) {
|
||||||
|
boolean useTerminal = true;
|
||||||
|
try {
|
||||||
|
useTerminal = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, ICDTLaunchConfigurationConstants.USE_TERMINAL_DEFAULT);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
GdbUIPlugin.log(e);
|
||||||
|
}
|
||||||
|
fTerminalButton.setSelection(useTerminal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateProjectFromConfig(ILaunchConfiguration config) {
|
||||||
|
String projectName = EMPTY_STRING;
|
||||||
|
try {
|
||||||
|
projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, EMPTY_STRING);
|
||||||
|
} catch (CoreException ce) {
|
||||||
|
GdbUIPlugin.log(ce);
|
||||||
|
}
|
||||||
|
fProjText.setText(projectName);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateProgramFromConfig(ILaunchConfiguration config) {
|
||||||
|
String programName = EMPTY_STRING;
|
||||||
|
try {
|
||||||
|
programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, EMPTY_STRING);
|
||||||
|
} catch (CoreException ce) {
|
||||||
|
GdbUIPlugin.log(ce);
|
||||||
|
}
|
||||||
|
fProgText.setText(programName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
|
||||||
|
*/
|
||||||
|
public void performApply(ILaunchConfigurationWorkingCopy config) {
|
||||||
|
ICProject cProject = this.getCProject();
|
||||||
|
if (cProject != null)
|
||||||
|
{
|
||||||
|
config.setMappedResources(new IResource[] { cProject.getProject() });
|
||||||
|
try { // Only initialize the build config ID once.
|
||||||
|
if (config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, "").length() == 0)//$NON-NLS-1$
|
||||||
|
{
|
||||||
|
ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(cProject.getProject());
|
||||||
|
if (projDes != null)
|
||||||
|
{
|
||||||
|
String buildConfigID = projDes.getActiveConfiguration().getId();
|
||||||
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, buildConfigID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CoreException e) { e.printStackTrace(); }
|
||||||
|
}
|
||||||
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, fProjText.getText());
|
||||||
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, fProgText.getText());
|
||||||
|
if (fTerminalButton != null) {
|
||||||
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, fTerminalButton.getSelection());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a dialog that lists all main types
|
||||||
|
*/
|
||||||
|
protected void handleSearchButtonSelected() {
|
||||||
|
|
||||||
|
if (getCProject() == null) {
|
||||||
|
MessageDialog.openInformation(getShell(), LaunchMessages.getString("CMainTab.Project_required"), //$NON-NLS-1$
|
||||||
|
LaunchMessages.getString("CMainTab.Enter_project_before_searching_for_program")); //$NON-NLS-1$
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image getImage(Object element) {
|
||||||
|
if (! (element instanceof ICElement)) {
|
||||||
|
return super.getImage(element);
|
||||||
|
}
|
||||||
|
ICElement celement = (ICElement)element;
|
||||||
|
|
||||||
|
if (celement.getElementType() == ICElement.C_BINARY) {
|
||||||
|
IBinary belement = (IBinary)celement;
|
||||||
|
if (belement.isExecutable()) {
|
||||||
|
return DebugUITools.getImage(IDebugUIConstants.IMG_ACT_RUN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getImage(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(getBinaryFiles(getCProject()));
|
||||||
|
dialog.setMessage(LaunchMessages.getString("CMainTab.Choose_program_to_run")); //$NON-NLS-1$
|
||||||
|
dialog.setTitle(LaunchMessages.getString("CMainTab.Program_Selection")); //$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);
|
||||||
|
// dialog.set
|
||||||
|
if (dialog.open() == Window.OK) {
|
||||||
|
IBinary binary = (IBinary)dialog.getFirstResult();
|
||||||
|
fProgText.setText(binary.getResource().getProjectRelativePath().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a dialog that lets the user select a project. This in turn provides context for the main
|
||||||
|
* type, allowing the user to key a main type name, or constraining the search for main types to
|
||||||
|
* the specified project.
|
||||||
|
*/
|
||||||
|
protected void handleBinaryBrowseButtonSelected() {
|
||||||
|
final ICProject cproject = getCProject();
|
||||||
|
if (cproject == null) {
|
||||||
|
MessageDialog.openInformation(getShell(), LaunchMessages.getString("CMainTab.Project_required"), //$NON-NLS-1$
|
||||||
|
LaunchMessages.getString("CMainTab.Enter_project_before_browsing_for_program")); //$NON-NLS-1$
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FileDialog fileDialog = new FileDialog(getShell(), SWT.NONE);
|
||||||
|
fileDialog.setFileName(fProgText.getText());
|
||||||
|
String text= fileDialog.open();
|
||||||
|
if (text != null) {
|
||||||
|
fProgText.setText(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterate through and suck up all of the executable files that we can find.
|
||||||
|
*/
|
||||||
|
protected IBinary[] getBinaryFiles(final ICProject cproject) {
|
||||||
|
final Display display;
|
||||||
|
if (cproject == null || !cproject.exists()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (getShell() == null) {
|
||||||
|
display = GdbUIPlugin.getShell().getDisplay();
|
||||||
|
} else {
|
||||||
|
display = getShell().getDisplay();
|
||||||
|
}
|
||||||
|
final Object[] ret = new Object[1];
|
||||||
|
BusyIndicator.showWhile(display, new Runnable() {
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
ret[0] = cproject.getBinaryContainer().getBinaries();
|
||||||
|
} catch (CModelException e) {
|
||||||
|
GdbUIPlugin.errorDialog("Launch UI internal error", e); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return (IBinary[])ret[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a dialog that lets the user select a project. This in turn provides context for the main
|
||||||
|
* type, allowing the user to key a main type name, or constraining the search for main types to
|
||||||
|
* the specified project.
|
||||||
|
*/
|
||||||
|
protected void handleProjectButtonSelected() {
|
||||||
|
ICProject project = chooseCProject();
|
||||||
|
if (project == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String projectName = project.getElementName();
|
||||||
|
fProjText.setText(projectName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Realize a C Project selection dialog and return the first selected project, or null if there
|
||||||
|
* was none.
|
||||||
|
*/
|
||||||
|
protected ICProject chooseCProject() {
|
||||||
|
try {
|
||||||
|
ICProject[] projects = getCProjects();
|
||||||
|
|
||||||
|
ILabelProvider labelProvider = new CElementLabelProvider();
|
||||||
|
ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
|
||||||
|
dialog.setTitle(LaunchMessages.getString("CMainTab.Project_Selection")); //$NON-NLS-1$
|
||||||
|
dialog.setMessage(LaunchMessages.getString("CMainTab.Choose_project_to_constrain_search_for_program")); //$NON-NLS-1$
|
||||||
|
dialog.setElements(projects);
|
||||||
|
|
||||||
|
ICProject cProject = getCProject();
|
||||||
|
if (cProject != null) {
|
||||||
|
dialog.setInitialSelections(new Object[]{cProject});
|
||||||
|
}
|
||||||
|
if (dialog.open() == Window.OK) {
|
||||||
|
return (ICProject)dialog.getFirstResult();
|
||||||
|
}
|
||||||
|
} catch (CModelException e) {
|
||||||
|
GdbUIPlugin.errorDialog("Launch UI internal error", e); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an array a ICProject whose platform match that of the runtime env.
|
||||||
|
*/
|
||||||
|
protected ICProject[] getCProjects() throws CModelException {
|
||||||
|
ICProject cproject[] = CoreModel.getDefault().getCModel().getCProjects();
|
||||||
|
ArrayList list = new ArrayList(cproject.length);
|
||||||
|
|
||||||
|
for (int i = 0; i < cproject.length; i++) {
|
||||||
|
ICDescriptor cdesciptor = null;
|
||||||
|
try {
|
||||||
|
cdesciptor = CCorePlugin.getDefault().getCProjectDescription((IProject)cproject[i].getResource(), false);
|
||||||
|
if (cdesciptor != null) {
|
||||||
|
String projectPlatform = cdesciptor.getPlatform();
|
||||||
|
if (filterPlatform.equals("*") //$NON-NLS-1$
|
||||||
|
|| projectPlatform.equals("*") //$NON-NLS-1$
|
||||||
|
|| filterPlatform.equalsIgnoreCase(projectPlatform) == true) {
|
||||||
|
list.add(cproject[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
list.add(cproject[i]);
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
list.add(cproject[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (ICProject[])list.toArray(new ICProject[list.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the ICProject corresponding to the project name in the project name text field, or
|
||||||
|
* null if the text does not match a project name.
|
||||||
|
*/
|
||||||
|
protected ICProject getCProject() {
|
||||||
|
String projectName = fProjText.getText().trim();
|
||||||
|
if (projectName.length() < 1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return CoreModel.getDefault().getCModel().getCProject(projectName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
|
||||||
|
*/
|
||||||
|
public boolean isValid(ILaunchConfiguration config) {
|
||||||
|
|
||||||
|
setErrorMessage(null);
|
||||||
|
setMessage(null);
|
||||||
|
|
||||||
|
if (dontCheckProgram)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
String name = fProjText.getText().trim();
|
||||||
|
if (name.length() == 0) {
|
||||||
|
setErrorMessage(LaunchMessages.getString("CMainTab.Project_not_specified")); //$NON-NLS-1$
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!ResourcesPlugin.getWorkspace().getRoot().getProject(name).exists()) {
|
||||||
|
setErrorMessage(LaunchMessages.getString("Launch.common.Project_does_not_exist")); //$NON-NLS-1$
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
|
||||||
|
if (!project.isOpen()) {
|
||||||
|
setErrorMessage(LaunchMessages.getString("CMainTab.Project_must_be_opened")); //$NON-NLS-1$
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
name = fProgText.getText().trim();
|
||||||
|
if (name.length() == 0) {
|
||||||
|
setErrorMessage(LaunchMessages.getString("CMainTab.Program_not_specified")); //$NON-NLS-1$
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (name.equals(".") || name.equals("..")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
IPath exePath = new Path(name);
|
||||||
|
if (!exePath.isAbsolute()) {
|
||||||
|
if (!project.getFile(name).exists()) {
|
||||||
|
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
exePath = project.getFile(name).getLocation();
|
||||||
|
} else {
|
||||||
|
if (!exePath.toFile().exists()) {
|
||||||
|
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (!isBinary(project, exePath)) {
|
||||||
|
setErrorMessage(LaunchMessages.getString("CMainTab.Program_is_not_a_recongnized_executable")); //$NON-NLS-1$
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
GdbUIPlugin.log(e);
|
||||||
|
setErrorMessage(e.getLocalizedMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param project
|
||||||
|
* @param exePath
|
||||||
|
* @return
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
protected boolean isBinary(IProject project, IPath exePath) throws CoreException {
|
||||||
|
ICExtensionReference[] parserRef = CCorePlugin.getDefault().getBinaryParserExtensions(project);
|
||||||
|
for (int i = 0; i < parserRef.length; i++) {
|
||||||
|
try {
|
||||||
|
IBinaryParser parser = (IBinaryParser)parserRef[i].createExtension();
|
||||||
|
IBinaryObject exe = (IBinaryObject)parser.getBinary(exePath);
|
||||||
|
if (exe != null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IBinaryParser parser = CCorePlugin.getDefault().getDefaultBinaryParser();
|
||||||
|
try {
|
||||||
|
IBinaryObject exe = (IBinaryObject)parser.getBinary(exePath);
|
||||||
|
return exe != null;
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
|
||||||
|
*/
|
||||||
|
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
|
||||||
|
// We set empty attributes for project & program so that when one config
|
||||||
|
// is
|
||||||
|
// compared to another, the existence of empty attributes doesn't cause
|
||||||
|
// an
|
||||||
|
// incorrect result (the performApply() method can result in empty
|
||||||
|
// values
|
||||||
|
// for these attributes being set on a config if there is nothing in the
|
||||||
|
// corresponding text boxes)
|
||||||
|
// plus getContext will use this to base context from if set.
|
||||||
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, EMPTY_STRING);
|
||||||
|
ICElement cElement = null;
|
||||||
|
cElement = getContext(config, getPlatform(config));
|
||||||
|
if (cElement != null) {
|
||||||
|
initializeCProject(cElement, config);
|
||||||
|
initializeProgramName(cElement, config);
|
||||||
|
}
|
||||||
|
if (wantsTerminalOption()) {
|
||||||
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, ICDTLaunchConfigurationConstants.USE_TERMINAL_DEFAULT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the program name attributes on the working copy based on the ICElement
|
||||||
|
*/
|
||||||
|
protected void initializeProgramName(ICElement cElement, ILaunchConfigurationWorkingCopy config) {
|
||||||
|
|
||||||
|
boolean renamed = false;
|
||||||
|
|
||||||
|
if (!(cElement instanceof IBinary))
|
||||||
|
{
|
||||||
|
cElement = cElement.getCProject();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cElement instanceof ICProject) {
|
||||||
|
|
||||||
|
IProject project = cElement.getCProject().getProject();
|
||||||
|
String name = project.getName();
|
||||||
|
ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(project);
|
||||||
|
if (projDes != null) {
|
||||||
|
String buildConfigName = projDes.getActiveConfiguration().getName();
|
||||||
|
name = name + " " + buildConfigName; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
name = getLaunchConfigurationDialog().generateName(name);
|
||||||
|
config.rename(name);
|
||||||
|
renamed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
IBinary binary = null;
|
||||||
|
if (cElement instanceof ICProject) {
|
||||||
|
IBinary[] bins = getBinaryFiles((ICProject)cElement);
|
||||||
|
if (bins != null && bins.length == 1) {
|
||||||
|
binary = bins[0];
|
||||||
|
}
|
||||||
|
} else if (cElement instanceof IBinary) {
|
||||||
|
binary = (IBinary)cElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (binary != null) {
|
||||||
|
String path;
|
||||||
|
path = binary.getResource().getProjectRelativePath().toOSString();
|
||||||
|
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, path);
|
||||||
|
if (!renamed)
|
||||||
|
{
|
||||||
|
String name = binary.getElementName();
|
||||||
|
int index = name.lastIndexOf('.');
|
||||||
|
if (index > 0) {
|
||||||
|
name = name.substring(0, index);
|
||||||
|
}
|
||||||
|
name = getLaunchConfigurationDialog().generateName(name);
|
||||||
|
config.rename(name);
|
||||||
|
renamed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!renamed)
|
||||||
|
{
|
||||||
|
String name = getLaunchConfigurationDialog().generateName(cElement.getCProject().getElementName());
|
||||||
|
config.rename(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return LaunchMessages.getString("CMainTab.Main"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
|
||||||
|
*/
|
||||||
|
public Image getImage() {
|
||||||
|
return LaunchImages.get(LaunchImages.IMG_VIEW_MAIN_TAB);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#updateLaunchConfigurationDialog()
|
||||||
|
*/
|
||||||
|
protected void updateLaunchConfigurationDialog() {
|
||||||
|
super.updateLaunchConfigurationDialog();
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,7 +10,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.gdb.internal.ui.launching;
|
package org.eclipse.dd.gdb.internal.ui.launching;
|
||||||
|
|
||||||
import org.eclipse.cdt.launch.ui.CMainTab;
|
|
||||||
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl.SessionType;
|
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl.SessionType;
|
||||||
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
||||||
import org.eclipse.debug.ui.CommonTab;
|
import org.eclipse.debug.ui.CommonTab;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005 QNX Software Systems and others.
|
* Copyright (c) 2008 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,10 +7,10 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* Ericsson - Modified for DSF
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.gdb.internal.ui.launching;
|
package org.eclipse.dd.gdb.internal.ui.launching;
|
||||||
|
|
||||||
import org.eclipse.cdt.launch.ui.CMainTab;
|
|
||||||
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl.SessionType;
|
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl.SessionType;
|
||||||
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
||||||
import org.eclipse.debug.ui.CommonTab;
|
import org.eclipse.debug.ui.CommonTab;
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.dd.gdb.internal.ui.launching;
|
package org.eclipse.dd.gdb.internal.ui.launching;
|
||||||
|
|
||||||
import org.eclipse.cdt.launch.ui.CMainTab;
|
|
||||||
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl.SessionType;
|
import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl.SessionType;
|
||||||
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
||||||
import org.eclipse.debug.ui.CommonTab;
|
import org.eclipse.debug.ui.CommonTab;
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 QNX Software Systems and others.
|
||||||
|
* 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:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.dd.gdb.internal.ui.launching;
|
||||||
|
|
||||||
|
import org.eclipse.dd.gdb.internal.ui.GdbUIPlugin;
|
||||||
|
|
||||||
|
public interface ICDTLaunchHelpContextIds {
|
||||||
|
|
||||||
|
public static final String PREFIX = GdbUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
|
||||||
|
|
||||||
|
// Launch configuration dialog pages
|
||||||
|
public static final String LAUNCH_CONFIGURATION_DIALOG_MAIN_TAB = PREFIX + "launch_configuration_dialog_main_tab"; //$NON-NLS-1$
|
||||||
|
public static final String LAUNCH_CONFIGURATION_DIALOG_ARGUMNETS_TAB = PREFIX + "launch_configuration_dialog_arguments_tab"; //$NON-NLS-1$
|
||||||
|
public static final String LAUNCH_CONFIGURATION_DIALOG_ENVIRONMENT_TAB = PREFIX + "launch_configuration_dialog_environment_tab"; //$NON-NLS-1$
|
||||||
|
public static final String LAUNCH_CONFIGURATION_DIALOG_DEBBUGER_TAB = PREFIX + "launch_configuration_dialog_debugger_tab"; //$NON-NLS-1$
|
||||||
|
public static final String LAUNCH_CONFIGURATION_DIALOG_SOURCELOOKUP_TAB = PREFIX + "launch_configuration_dialog_source_tab"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 QNX Software Systems and others.
|
||||||
|
* 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:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* Ericsson - Modified for DSF
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.dd.gdb.internal.ui.launching;
|
||||||
|
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
import org.eclipse.dd.gdb.internal.ui.GdbUIPlugin;
|
||||||
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
|
import org.eclipse.jface.resource.ImageRegistry;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
|
||||||
|
public class LaunchImages {
|
||||||
|
private static final String NAME_PREFIX= GdbUIPlugin.PLUGIN_ID + '.';
|
||||||
|
private static final int NAME_PREFIX_LENGTH= NAME_PREFIX.length();
|
||||||
|
|
||||||
|
// The plugin registry
|
||||||
|
private static ImageRegistry imageRegistry = new ImageRegistry();
|
||||||
|
|
||||||
|
// Subdirectory (under the package containing this class) where 16 color images are
|
||||||
|
private static URL fgIconBaseURL;
|
||||||
|
static {
|
||||||
|
fgIconBaseURL= Platform.getBundle(GdbUIPlugin.PLUGIN_ID).getEntry("/icons/"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String T_TABS = "full/view16/"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
public static String IMG_VIEW_MAIN_TAB = NAME_PREFIX + "main_tab.gif"; //$NON-NLS-1$
|
||||||
|
public static String IMG_VIEW_DEBUGGER_TAB = NAME_PREFIX + "debugger_tab.gif"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
public static final ImageDescriptor DESC_TAB_MAIN= createManaged(T_TABS, IMG_VIEW_MAIN_TAB);
|
||||||
|
public static final ImageDescriptor DESC_TAB_DEBUGGER = createManaged(T_TABS, IMG_VIEW_DEBUGGER_TAB);
|
||||||
|
|
||||||
|
public static void initialize() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ImageDescriptor createManaged(String prefix, String name) {
|
||||||
|
return createManaged(imageRegistry, prefix, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ImageDescriptor createManaged(ImageRegistry registry, String prefix, String name) {
|
||||||
|
ImageDescriptor result= ImageDescriptor.createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
|
||||||
|
registry.put(name, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Image get(String key) {
|
||||||
|
return imageRegistry.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static URL makeIconFileURL(String prefix, String name) {
|
||||||
|
StringBuffer buffer= new StringBuffer(prefix);
|
||||||
|
buffer.append(name);
|
||||||
|
try {
|
||||||
|
return new URL(fgIconBaseURL, buffer.toString());
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
GdbUIPlugin.log(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to access the image registry from the JavaPlugin class.
|
||||||
|
*/
|
||||||
|
static ImageRegistry getImageRegistry() {
|
||||||
|
return imageRegistry;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue