cdt/cdt_6_0_x/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java
author ryall
Mon, 03 Aug 2009 17:19:13 -0500
changeset 47 4c12a1ced0aa
parent 37 c2bce6dd59e7
child 49 e82f98a34bed
permissions -rw-r--r--
Build for Eclipse 3.5 and CDT 6.0.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     1
/*******************************************************************************
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     2
 * Copyright (c) 2005, 2009 QNX Software Systems and others.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     3
 * All rights reserved. This program and the accompanying materials
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     4
 * are made available under the terms of the Eclipse Public License v1.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     5
 * which accompanies this distribution, and is available at
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     6
 * http://www.eclipse.org/legal/epl-v10.html
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     7
 *
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     8
 * Contributors:
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     9
 *     QNX Software Systems - initial API and implementation
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    10
 *     Ken Ryall (Nokia) - bug 178731
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    11
 *	   IBM Corporation
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    12
 *******************************************************************************/
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    13
package org.eclipse.cdt.launch.ui;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    14
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    15
import java.util.ArrayList;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    16
import java.util.HashMap;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    17
import java.util.HashSet;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    18
import java.util.List;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    19
import java.util.Map;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    20
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    21
import org.eclipse.cdt.core.CCorePlugin;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    22
import org.eclipse.cdt.core.ICDescriptor;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    23
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    24
import org.eclipse.cdt.core.model.CModelException;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    25
import org.eclipse.cdt.core.model.CoreModel;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    26
import org.eclipse.cdt.core.model.IBinary;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    27
import org.eclipse.cdt.core.model.ICElement;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    28
import org.eclipse.cdt.core.model.ICProject;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    29
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    30
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    31
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    32
import org.eclipse.cdt.launch.LaunchUtils;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    33
import org.eclipse.cdt.launch.internal.ui.LaunchImages;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    34
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    35
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    36
import org.eclipse.cdt.ui.CElementLabelProvider;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    37
import org.eclipse.cdt.ui.newui.CDTPropertyManager;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    38
import org.eclipse.cdt.utils.pty.PTY;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    39
import org.eclipse.core.resources.IFile;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    40
import org.eclipse.core.resources.IProject;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    41
import org.eclipse.core.resources.IResource;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    42
import org.eclipse.core.resources.ResourcesPlugin;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    43
import org.eclipse.core.runtime.CoreException;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    44
import org.eclipse.core.runtime.IPath;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    45
import org.eclipse.core.runtime.Path;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    46
import org.eclipse.debug.core.ILaunchConfiguration;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    47
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    48
import org.eclipse.debug.core.ILaunchDelegate;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    49
import org.eclipse.debug.ui.DebugUITools;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    50
import org.eclipse.debug.ui.IDebugUIConstants;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    51
import org.eclipse.jface.dialogs.MessageDialog;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    52
import org.eclipse.jface.viewers.ILabelProvider;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    53
import org.eclipse.jface.window.Window;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    54
import org.eclipse.swt.SWT;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    55
import org.eclipse.swt.custom.BusyIndicator;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    56
import org.eclipse.swt.events.ModifyEvent;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    57
import org.eclipse.swt.events.ModifyListener;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    58
import org.eclipse.swt.events.SelectionAdapter;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    59
import org.eclipse.swt.events.SelectionEvent;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    60
import org.eclipse.swt.events.SelectionListener;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    61
import org.eclipse.swt.graphics.Image;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    62
import org.eclipse.swt.layout.GridData;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    63
import org.eclipse.swt.layout.GridLayout;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    64
import org.eclipse.swt.widgets.Button;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    65
import org.eclipse.swt.widgets.Combo;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    66
import org.eclipse.swt.widgets.Composite;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    67
import org.eclipse.swt.widgets.Display;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    68
import org.eclipse.swt.widgets.FileDialog;
47
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
    69
import org.eclipse.swt.widgets.Group;
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    70
import org.eclipse.swt.widgets.Label;
47
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
    71
import org.eclipse.swt.widgets.Link;
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    72
import org.eclipse.swt.widgets.Text;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    73
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
47
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
    74
import org.eclipse.ui.dialogs.PreferencesUtil;
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    75
import org.eclipse.ui.dialogs.TwoPaneElementSelector;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    76
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    77
/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    78
 * A launch configuration tab that displays and edits project and main type name launch
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    79
 * configuration attributes.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    80
 * <p>
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    81
 * This class may be instantiated. This class is not intended to be subclassed.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    82
 * </p>
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    83
 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    84
 * @since 2.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    85
 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    86
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    87
public class CMainTab extends CLaunchConfigurationTab {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    88
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    89
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    90
     * Tab identifier used for ordering of tabs added using the 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    91
     * <code>org.eclipse.debug.ui.launchConfigurationTabs</code>
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    92
     * extension point.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    93
     *   
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    94
     * @since 6.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    95
     */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    96
    public static final String TAB_ID = "org.eclipse.cdt.cdi.launch.mainTab"; //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    97
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    98
	// Project UI widgets
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    99
	protected Label fProjLabel;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   100
	protected Text fProjText;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   101
	protected Button fProjButton;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   102
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   103
	// Main class UI widgets
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   104
	protected Label fProgLabel;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   105
	protected Text fProgText;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   106
	protected Button fSearchButton;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   107
	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   108
	// Core file UI widgets
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   109
	/** @since 6.0 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   110
	protected Label fCoreLabel;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   111
	/** @since 6.0 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   112
	protected Text fCoreText;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   113
	/** @since 6.0 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   114
	protected Button fCoreButton;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   115
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   116
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   117
	 * @since 6.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   118
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   119
	protected Combo fBuildConfigCombo;
47
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   120
	// Build option UI widgets
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   121
	protected Button fDisableBuildButton;
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   122
	protected Button fEnableBuildButton;
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   123
	protected Button fWorkspaceSettingsButton;
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   124
	protected Link fWorkpsaceSettingsLink;
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   125
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   126
	private final boolean fWantsTerminalOption;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   127
	protected Button fTerminalButton;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   128
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   129
	private final boolean dontCheckProgram;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   130
	private final boolean fSpecifyCoreFile;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   131
	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   132
	protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   133
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   134
	private String filterPlatform = EMPTY_STRING;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   135
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   136
	public static final int WANTS_TERMINAL = 1;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   137
	public static final int DONT_CHECK_PROGRAM = 2;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   138
	/** @since 6.0 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   139
	public static final int SPECIFY_CORE_FILE = 4;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   140
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   141
	private final Map<IPath, Boolean> fBinaryExeCache = new HashMap<IPath, Boolean>();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   142
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   143
	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   144
	public CMainTab() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   145
		this(WANTS_TERMINAL);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   146
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   147
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   148
	public CMainTab(boolean terminalOption) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   149
		this(terminalOption ? WANTS_TERMINAL : 0);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   150
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   151
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   152
	public CMainTab(int flags) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   153
		fWantsTerminalOption = (flags & WANTS_TERMINAL) != 0;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   154
		dontCheckProgram = (flags & DONT_CHECK_PROGRAM) != 0;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   155
		fSpecifyCoreFile = (flags & SPECIFY_CORE_FILE) != 0;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   156
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   157
	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   158
	/*
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   159
	 * (non-Javadoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   160
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   161
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   162
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   163
	public void createControl(Composite parent) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   164
		Composite comp = new Composite(parent, SWT.NONE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   165
		setControl(comp);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   166
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   167
		LaunchUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_MAIN_TAB);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   168
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   169
		GridLayout topLayout = new GridLayout();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   170
		comp.setLayout(topLayout);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   171
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   172
		createVerticalSpacer(comp, 1);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   173
		createProjectGroup(comp, 1);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   174
		createBuildConfigCombo(comp, 1);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   175
		createExeFileGroup(comp, 1);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   176
		createVerticalSpacer(comp, 1);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   177
		if (fSpecifyCoreFile) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   178
			createCoreFileGroup(comp, 1);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   179
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   180
		if (wantsTerminalOption() /* && ProcessFactory.supportesTerminal() */) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   181
			createTerminalOption(comp, 1);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   182
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   183
		LaunchUIPlugin.setDialogShell(parent.getShell());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   184
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   185
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   186
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   187
	 * @since 6.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   188
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   189
	protected void createProjectGroup(Composite parent, int colSpan) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   190
		Composite projComp = new Composite(parent, SWT.NONE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   191
		GridLayout projLayout = new GridLayout();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   192
		projLayout.numColumns = 2;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   193
		projLayout.marginHeight = 0;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   194
		projLayout.marginWidth = 0;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   195
		projComp.setLayout(projLayout);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   196
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   197
		gd.horizontalSpan = colSpan;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   198
		projComp.setLayoutData(gd);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   199
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   200
		fProjLabel = new Label(projComp, SWT.NONE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   201
		fProjLabel.setText(LaunchMessages.getString("CMainTab.&ProjectColon")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   202
		gd = new GridData();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   203
		gd.horizontalSpan = 2;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   204
		fProjLabel.setLayoutData(gd);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   205
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   206
		fProjText = new Text(projComp, SWT.SINGLE | SWT.BORDER);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   207
		gd = new GridData(GridData.FILL_HORIZONTAL);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   208
		fProjText.setLayoutData(gd);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   209
		fProjText.addModifyListener(new ModifyListener() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   210
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   211
			public void modifyText(ModifyEvent evt) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   212
				updateBuildConfigCombo(EMPTY_STRING);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   213
				updateLaunchConfigurationDialog();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   214
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   215
		});
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   216
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   217
		fProjButton = createPushButton(projComp, LaunchMessages.getString("Launch.common.Browse_1"), null); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   218
		fProjButton.addSelectionListener(new SelectionAdapter() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   219
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   220
			@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   221
			public void widgetSelected(SelectionEvent evt) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   222
				handleProjectButtonSelected();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   223
				updateLaunchConfigurationDialog();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   224
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   225
		});
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   226
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   227
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   228
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   229
	 * @since 6.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   230
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   231
	protected void updateBuildConfigCombo(String selectedConfigID) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   232
		if (fBuildConfigCombo != null)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   233
		{
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   234
			fBuildConfigCombo.removeAll();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   235
			fBuildConfigCombo.add(LaunchMessages.getString("CMainTab.Use_Active")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   236
			fBuildConfigCombo.setData("0", EMPTY_STRING); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   237
			fBuildConfigCombo.select(0);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   238
			ICProject cproject = getCProject();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   239
			if (cproject != null){
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   240
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   241
				ICProjectDescription projDes = CDTPropertyManager.getProjectDescription(cproject.getProject());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   242
				if (projDes != null)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   243
				{
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   244
					int selIndex = 0;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   245
					ICConfigurationDescription[] configurations = projDes.getConfigurations();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   246
					ICConfigurationDescription selectedConfig = projDes.getConfigurationById(selectedConfigID);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   247
					for (int i = 0; i < configurations.length; i++) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   248
						String configName = configurations[i].getName();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   249
						fBuildConfigCombo.add(configName);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   250
						fBuildConfigCombo.setData(Integer.toString(i + 1), configurations[i].getId());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   251
						if (selectedConfig != null && selectedConfigID.equals(configurations[i].getId()))
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   252
							selIndex = i + 1;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   253
					}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   254
					fBuildConfigCombo.select(selIndex);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   255
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   256
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   257
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   258
			
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   259
		}	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   260
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   261
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   262
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   263
	 * @since 6.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   264
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   265
	protected void createBuildConfigCombo(Composite parent, int colspan) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   266
		Composite comboComp = new Composite(parent, SWT.NONE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   267
		GridLayout layout = new GridLayout(2, false);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   268
		comboComp.setLayout(layout);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   269
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   270
		gd.horizontalSpan = colspan;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   271
		comboComp.setLayoutData(gd);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   272
		Label dlabel = new Label(comboComp, SWT.NONE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   273
		dlabel.setText(LaunchMessages.getString("CMainTab.Build_Config")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   274
		fBuildConfigCombo = new Combo(comboComp, SWT.READ_ONLY | SWT.DROP_DOWN);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   275
		fBuildConfigCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   276
		fBuildConfigCombo.addSelectionListener(new SelectionListener() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   277
		    public void widgetSelected(SelectionEvent e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   278
		    	updateLaunchConfigurationDialog();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   279
		    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   280
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   281
		    public void widgetDefaultSelected(SelectionEvent e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   282
		    	updateLaunchConfigurationDialog();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   283
		    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   284
		});
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   285
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   286
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   287
	protected void createExeFileGroup(Composite parent, int colSpan) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   288
		Composite mainComp = new Composite(parent, SWT.NONE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   289
		GridLayout mainLayout = new GridLayout();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   290
		mainLayout.numColumns = 3;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   291
		mainLayout.marginHeight = 0;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   292
		mainLayout.marginWidth = 0;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   293
		mainComp.setLayout(mainLayout);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   294
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   295
		gd.horizontalSpan = colSpan;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   296
		mainComp.setLayoutData(gd);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   297
		fProgLabel = new Label(mainComp, SWT.NONE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   298
		fProgLabel.setText(LaunchMessages.getString("CMainTab.C/C++_Application")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   299
		gd = new GridData();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   300
		gd.horizontalSpan = 3;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   301
		fProgLabel.setLayoutData(gd);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   302
		fProgText = new Text(mainComp, SWT.SINGLE | SWT.BORDER);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   303
		gd = new GridData(GridData.FILL_HORIZONTAL);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   304
		fProgText.setLayoutData(gd);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   305
		fProgText.addModifyListener(new ModifyListener() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   306
			public void modifyText(ModifyEvent evt) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   307
				updateLaunchConfigurationDialog();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   308
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   309
		});
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   310
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   311
		fSearchButton = createPushButton(mainComp, LaunchMessages.getString("CMainTab.Search..."), null); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   312
		fSearchButton.addSelectionListener(new SelectionAdapter() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   313
			@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   314
			public void widgetSelected(SelectionEvent evt) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   315
				handleSearchButtonSelected();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   316
				updateLaunchConfigurationDialog();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   317
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   318
		});
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   319
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   320
		Button fBrowseForBinaryButton;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   321
		fBrowseForBinaryButton = createPushButton(mainComp, LaunchMessages.getString("Launch.common.Browse_2"), null); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   322
		fBrowseForBinaryButton.addSelectionListener(new SelectionAdapter() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   323
			@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   324
			public void widgetSelected(SelectionEvent evt) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   325
				handleBinaryBrowseButtonSelected();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   326
				updateLaunchConfigurationDialog();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   327
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   328
		});
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   329
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   330
47
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   331
	protected void createBuildOptionGroup(final Composite parent, int colSpan) {
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   332
		Group buildGroup = new Group(parent, SWT.NONE);
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   333
		GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   334
		gridData.horizontalSpan = colSpan;
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   335
		GridLayout gridLayout = new GridLayout();
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   336
		gridLayout.numColumns = 2;
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   337
		gridLayout.marginHeight = 5;
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   338
		gridLayout.marginWidth = 5;
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   339
		gridLayout.makeColumnsEqualWidth= true;
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   340
		buildGroup.setLayoutData(gridData);
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   341
		buildGroup.setLayout(gridLayout);
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   342
		buildGroup.setText("Build (if required) before launching"); //$NON-NLS-1$
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   343
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   344
		fDisableBuildButton = new Button(buildGroup, SWT.RADIO);
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   345
		fDisableBuildButton.setText(LaunchMessages.getString("CMainTab.Disable_build_button_label")); //$NON-NLS-1$
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   346
		fDisableBuildButton.setToolTipText(LaunchMessages.getString("CMainTab.Disable_build_button_tooltip")); //$NON-NLS-1$
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   347
		fDisableBuildButton.addSelectionListener(new SelectionAdapter() {
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   348
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   349
			public void widgetSelected(SelectionEvent evt) {
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   350
				updateLaunchConfigurationDialog();
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   351
			}
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   352
		});
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   353
		
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   354
		new Label(buildGroup, SWT.NONE);
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   355
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   356
		fEnableBuildButton = new Button(buildGroup, SWT.RADIO);
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   357
		fEnableBuildButton.setText(LaunchMessages.getString("CMainTab.Enable_build_button_label")); //$NON-NLS-1$
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   358
		fEnableBuildButton.setToolTipText(LaunchMessages.getString("CMainTab.Enable_build_button_tooltip")); //$NON-NLS-1$
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   359
		fEnableBuildButton.addSelectionListener(new SelectionAdapter() {
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   360
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   361
			public void widgetSelected(SelectionEvent evt) {
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   362
				updateLaunchConfigurationDialog();
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   363
			}
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   364
		});
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   365
		
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   366
		new Label(buildGroup, SWT.NONE);
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   367
		
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   368
		fWorkspaceSettingsButton = new Button(buildGroup, SWT.RADIO);
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   369
		fWorkspaceSettingsButton.setText(LaunchMessages.getString("CMainTab.Workspace_settings_button_label")); //$NON-NLS-1$
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   370
		fWorkspaceSettingsButton.setToolTipText(LaunchMessages.getString("CMainTab.Workspace_settings_button_tooltip")); //$NON-NLS-1$
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   371
		fWorkspaceSettingsButton.addSelectionListener(new SelectionAdapter() {
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   372
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   373
			public void widgetSelected(SelectionEvent evt) {
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   374
				updateLaunchConfigurationDialog();
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   375
			}
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   376
		});
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   377
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   378
		fWorkpsaceSettingsLink = new Link(buildGroup, SWT.NONE); //$NON-NLS-1$
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   379
		fWorkpsaceSettingsLink.setText(LaunchMessages.getString("CMainTab.Workspace_settings_link_label")); //$NON-NLS-1$
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   380
		fWorkpsaceSettingsLink.addSelectionListener(new SelectionAdapter() {
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   381
			public void widgetSelected(SelectionEvent e) {
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   382
				PreferencesUtil.createPreferenceDialogOn(
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   383
						parent.getShell(), 
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   384
						LaunchMessages.getString("CMainTab.Workspace_settings_page_id"), //$NON-NLS-1$
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   385
						null, 
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   386
						null).open();
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   387
			}
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   388
		});
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   389
	}
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   390
	/** @since 6.0 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   391
	protected void createCoreFileGroup(Composite parent, int colSpan) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   392
		Composite coreComp = new Composite(parent, SWT.NONE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   393
		GridLayout coreLayout = new GridLayout();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   394
		coreLayout.numColumns = 3;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   395
		coreLayout.marginHeight = 0;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   396
		coreLayout.marginWidth = 0;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   397
		coreComp.setLayout(coreLayout);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   398
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   399
		gd.horizontalSpan = colSpan;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   400
		coreComp.setLayoutData(gd);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   401
		fCoreLabel = new Label(coreComp, SWT.NONE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   402
		fCoreLabel.setText(LaunchMessages.getString("CMainTab.CoreFile_path")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   403
		gd = new GridData();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   404
		gd.horizontalSpan = 3;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   405
		fCoreLabel.setLayoutData(gd);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   406
		fCoreText = new Text(coreComp, SWT.SINGLE | SWT.BORDER);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   407
		gd = new GridData(GridData.FILL_HORIZONTAL);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   408
		fCoreText.setLayoutData(gd);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   409
		fCoreText.addModifyListener(new ModifyListener() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   410
			public void modifyText(ModifyEvent evt) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   411
				updateLaunchConfigurationDialog();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   412
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   413
		});
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   414
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   415
		Button browseForCoreButton;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   416
		browseForCoreButton = createPushButton(coreComp, LaunchMessages.getString("Launch.common.Browse_2"), null); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   417
		browseForCoreButton.addSelectionListener(new SelectionAdapter() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   418
			@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   419
			public void widgetSelected(SelectionEvent evt) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   420
				String text = handleBrowseButtonSelected();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   421
				if (text != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   422
					fCoreText.setText(text);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   423
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   424
				updateLaunchConfigurationDialog();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   425
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   426
		});
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   427
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   428
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   429
	protected boolean wantsTerminalOption() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   430
		return fWantsTerminalOption;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   431
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   432
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   433
	protected void createTerminalOption(Composite parent, int colSpan) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   434
		Composite mainComp = new Composite(parent, SWT.NONE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   435
		GridLayout mainLayout = new GridLayout();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   436
		mainLayout.numColumns = 1;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   437
		mainLayout.marginHeight = 0;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   438
		mainLayout.marginWidth = 0;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   439
		mainComp.setLayout(mainLayout);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   440
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   441
		gd.horizontalSpan = colSpan;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   442
		mainComp.setLayoutData(gd);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   443
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   444
		fTerminalButton = createCheckButton(mainComp, LaunchMessages.getString("CMainTab.UseTerminal")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   445
		fTerminalButton.addSelectionListener(new SelectionAdapter() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   446
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   447
			@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   448
			public void widgetSelected(SelectionEvent evt) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   449
				updateLaunchConfigurationDialog();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   450
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   451
		});
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   452
		fTerminalButton.setEnabled(PTY.isSupported());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   453
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   454
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   455
	/*
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   456
	 * (non-Javadoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   457
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   458
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   459
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   460
	public void initializeFrom(ILaunchConfiguration config) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   461
		filterPlatform = getPlatform(config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   462
		updateProjectFromConfig(config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   463
		updateProgramFromConfig(config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   464
		updateCoreFromConfig(config);
47
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   465
		updateBuildOptionFromConfig(config);
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   466
		updateTerminalFromConfig(config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   467
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   468
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   469
	protected void updateTerminalFromConfig(ILaunchConfiguration config) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   470
		if (fTerminalButton != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   471
			boolean useTerminal = true;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   472
			try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   473
				useTerminal = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, ICDTLaunchConfigurationConstants.USE_TERMINAL_DEFAULT);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   474
			} catch (CoreException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   475
				LaunchUIPlugin.log(e);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   476
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   477
			fTerminalButton.setSelection(useTerminal);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   478
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   479
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   480
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   481
	protected void updateProjectFromConfig(ILaunchConfiguration config) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   482
		String projectName = EMPTY_STRING;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   483
		String configName = EMPTY_STRING;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   484
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   485
			projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, EMPTY_STRING);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   486
			configName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, EMPTY_STRING);			
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   487
		} catch (CoreException ce) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   488
			LaunchUIPlugin.log(ce);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   489
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   490
		fProjText.setText(projectName);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   491
		updateBuildConfigCombo(configName);		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   492
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   493
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   494
	protected void updateProgramFromConfig(ILaunchConfiguration config) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   495
		String programName = EMPTY_STRING;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   496
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   497
			programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, EMPTY_STRING);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   498
		} catch (CoreException ce) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   499
			LaunchUIPlugin.log(ce);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   500
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   501
		fProgText.setText(programName);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   502
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   503
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   504
	/** @since 6.0 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   505
	protected void updateCoreFromConfig(ILaunchConfiguration config) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   506
		if (fCoreText != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   507
			String coreName = EMPTY_STRING;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   508
			try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   509
				coreName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, EMPTY_STRING);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   510
			} catch (CoreException ce) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   511
				LaunchUIPlugin.log(ce);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   512
			}
47
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   513
			fProgText.setText(coreName);
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   514
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   515
	}
47
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   516
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   517
	protected void updateBuildOptionFromConfig(ILaunchConfiguration config) {
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   518
		int buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING;
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   519
		try {
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   520
			buildBeforeLaunchValue = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, buildBeforeLaunchValue);
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   521
		} catch (CoreException e) {
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   522
			LaunchUIPlugin.log(e);
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   523
		}
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   524
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   525
		fDisableBuildButton.setSelection(buildBeforeLaunchValue == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED);
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   526
		fEnableBuildButton.setSelection(buildBeforeLaunchValue == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_ENABLED);
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   527
		fWorkspaceSettingsButton.setSelection(buildBeforeLaunchValue == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING);
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   528
	}
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   529
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   530
	/*
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   531
	 * (non-Javadoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   532
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   533
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   534
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   535
	public void performApply(ILaunchConfigurationWorkingCopy config) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   536
		ICProject cProject = this.getCProject();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   537
		if (cProject != null && cProject.exists())
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   538
		{
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   539
			config.setMappedResources(new IResource[] { cProject.getProject() });
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   540
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   541
		else
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   542
		{
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   543
			// the user typed in a non-existent project name.  Ensure that
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   544
			// won't be suppressed from the dialog.  This matches JDT behaviour
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   545
			config.setMappedResources(null);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   546
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   547
		config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, fProjText.getText());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   548
		config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, (String)fBuildConfigCombo.getData(Integer.toString(fBuildConfigCombo.getSelectionIndex())));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   549
		config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, fProgText.getText());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   550
		if (fCoreText != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   551
			config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, fCoreText.getText());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   552
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   553
		if (fTerminalButton != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   554
			config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, fTerminalButton.getSelection());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   555
		}
47
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   556
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   557
		if (fDisableBuildButton != null) {
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   558
			int buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING;
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   559
			if (fDisableBuildButton.getSelection()) {
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   560
				buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED;
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   561
			} else if (fEnableBuildButton.getSelection()) {
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   562
				buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_ENABLED;
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   563
			}
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   564
			config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, buildBeforeLaunchValue);
4c12a1ced0aa Build for Eclipse 3.5 and CDT 6.0.
ryall
parents: 37
diff changeset
   565
		}
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   566
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   567
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   568
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   569
	 * Show a dialog that lists all main types
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   570
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   571
	protected void handleSearchButtonSelected() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   572
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   573
		if (getCProject() == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   574
			MessageDialog.openInformation(getShell(), LaunchMessages.getString("CMainTab.Project_required"), //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   575
					LaunchMessages.getString("CMainTab.Enter_project_before_searching_for_program")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   576
			return;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   577
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   578
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   579
		ILabelProvider programLabelProvider = new CElementLabelProvider() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   580
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   581
			@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   582
			public String getText(Object element) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   583
				if (element instanceof IBinary) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   584
					IBinary bin = (IBinary)element;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   585
					StringBuffer name = new StringBuffer();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   586
					name.append(bin.getPath().lastSegment());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   587
					return name.toString();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   588
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   589
				return super.getText(element);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   590
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   591
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   592
			@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   593
			public Image getImage(Object element) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   594
				if (! (element instanceof ICElement)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   595
					return super.getImage(element);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   596
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   597
				ICElement celement = (ICElement)element;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   598
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   599
				if (celement.getElementType() == ICElement.C_BINARY) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   600
					IBinary belement = (IBinary)celement;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   601
					if (belement.isExecutable()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   602
						return DebugUITools.getImage(IDebugUIConstants.IMG_ACT_RUN);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   603
					}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   604
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   605
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   606
				return super.getImage(element);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   607
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   608
		};
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   609
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   610
		ILabelProvider qualifierLabelProvider = new CElementLabelProvider() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   611
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   612
			@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   613
			public String getText(Object element) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   614
				if (element instanceof IBinary) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   615
					IBinary bin = (IBinary)element;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   616
					StringBuffer name = new StringBuffer();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   617
					name.append(bin.getCPU() + (bin.isLittleEndian() ? "le" : "be")); //$NON-NLS-1$ //$NON-NLS-2$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   618
					name.append(" - "); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   619
					name.append(bin.getPath().toString());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   620
					return name.toString();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   621
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   622
				return super.getText(element);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   623
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   624
		};
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   625
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   626
		TwoPaneElementSelector dialog = new TwoPaneElementSelector(getShell(), programLabelProvider, qualifierLabelProvider);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   627
		dialog.setElements(getBinaryFiles(getCProject()));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   628
		dialog.setMessage(LaunchMessages.getString("CMainTab.Choose_program_to_run")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   629
		dialog.setTitle(LaunchMessages.getString("CMainTab.Program_Selection")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   630
		dialog.setUpperListLabel(LaunchMessages.getString("Launch.common.BinariesColon")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   631
		dialog.setLowerListLabel(LaunchMessages.getString("Launch.common.QualifierColon")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   632
		dialog.setMultipleSelection(false);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   633
		// dialog.set
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   634
		if (dialog.open() == Window.OK) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   635
			IBinary binary = (IBinary)dialog.getFirstResult();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   636
			fProgText.setText(binary.getResource().getProjectRelativePath().toString());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   637
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   638
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   639
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   640
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   641
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   642
	 * Show a dialog that lets the user select a project. This in turn provides context for the main
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   643
	 * type, allowing the user to key a main type name, or constraining the search for main types to
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   644
	 * the specified project.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   645
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   646
	protected void handleBinaryBrowseButtonSelected() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   647
		final ICProject cproject = getCProject();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   648
		if (cproject == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   649
			MessageDialog.openInformation(getShell(), LaunchMessages.getString("CMainTab.Project_required"), //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   650
					LaunchMessages.getString("CMainTab.Enter_project_before_browsing_for_program")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   651
			return;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   652
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   653
		FileDialog fileDialog = new FileDialog(getShell(), SWT.NONE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   654
		fileDialog.setFileName(fProgText.getText());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   655
		String text= fileDialog.open();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   656
		if (text != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   657
			fProgText.setText(text);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   658
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   659
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   660
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   661
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   662
	 * Show a dialog that lets the user select a file.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   663
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   664
	 * @since 6.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   665
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   666
	protected String handleBrowseButtonSelected() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   667
		FileDialog fileDialog = new FileDialog(getShell(), SWT.NONE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   668
		fileDialog.setFileName(fProgText.getText());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   669
		return fileDialog.open();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   670
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   671
	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   672
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   673
	 * Iterate through and suck up all of the executable files that we can find.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   674
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   675
	protected IBinary[] getBinaryFiles(final ICProject cproject) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   676
		final Display display;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   677
		if (cproject == null || !cproject.exists()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   678
			return null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   679
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   680
		if (getShell() == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   681
			display = LaunchUIPlugin.getShell().getDisplay();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   682
		} else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   683
			display = getShell().getDisplay();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   684
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   685
		final Object[] ret = new Object[1];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   686
		BusyIndicator.showWhile(display, new Runnable() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   687
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   688
			public void run() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   689
				try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   690
					ret[0] = cproject.getBinaryContainer().getBinaries();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   691
				} catch (CModelException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   692
					LaunchUIPlugin.errorDialog("Launch UI internal error", e); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   693
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   694
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   695
		});
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   696
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   697
		return (IBinary[])ret[0];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   698
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   699
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   700
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   701
	 * Show a dialog that lets the user select a project. This in turn provides context for the main
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   702
	 * type, allowing the user to key a main type name, or constraining the search for main types to
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   703
	 * the specified project.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   704
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   705
	protected void handleProjectButtonSelected() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   706
		ICProject project = chooseCProject();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   707
		if (project == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   708
			return;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   709
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   710
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   711
		String projectName = project.getElementName();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   712
		fProjText.setText(projectName);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   713
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   714
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   715
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   716
	 * Realize a C Project selection dialog and return the first selected project, or null if there
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   717
	 * was none.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   718
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   719
	protected ICProject chooseCProject() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   720
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   721
			ICProject[] projects = getCProjects();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   722
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   723
			ILabelProvider labelProvider = new CElementLabelProvider();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   724
			ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   725
			dialog.setTitle(LaunchMessages.getString("CMainTab.Project_Selection")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   726
			dialog.setMessage(LaunchMessages.getString("CMainTab.Choose_project_to_constrain_search_for_program")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   727
			dialog.setElements(projects);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   728
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   729
			ICProject cProject = getCProject();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   730
			if (cProject != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   731
				dialog.setInitialSelections(new Object[]{cProject});
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   732
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   733
			if (dialog.open() == Window.OK) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   734
				return (ICProject)dialog.getFirstResult();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   735
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   736
		} catch (CModelException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   737
			LaunchUIPlugin.errorDialog("Launch UI internal error", e); //$NON-NLS-1$			
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   738
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   739
		return null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   740
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   741
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   742
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   743
	 * Return an array a ICProject whose platform match that of the runtime env.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   744
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   745
	protected ICProject[] getCProjects() throws CModelException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   746
		ICProject cproject[] = CoreModel.getDefault().getCModel().getCProjects();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   747
		List<ICProject> list = new ArrayList<ICProject>(cproject.length);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   748
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   749
		for (int i = 0; i < cproject.length; i++) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   750
			ICDescriptor cdesciptor = null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   751
			try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   752
				cdesciptor = CCorePlugin.getDefault().getCProjectDescription((IProject)cproject[i].getResource(), false);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   753
				if (cdesciptor != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   754
					String projectPlatform = cdesciptor.getPlatform();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   755
					if (filterPlatform.equals("*") //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   756
							|| projectPlatform.equals("*") //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   757
							|| filterPlatform.equalsIgnoreCase(projectPlatform) == true) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   758
						list.add(cproject[i]);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   759
					}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   760
				} else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   761
					list.add(cproject[i]);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   762
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   763
			} catch (CoreException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   764
				list.add(cproject[i]);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   765
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   766
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   767
		return list.toArray(new ICProject[list.size()]);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   768
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   769
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   770
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   771
	 * Return the ICProject corresponding to the project name in the project name text field, or
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   772
	 * null if the text does not match a project name.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   773
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   774
	protected ICProject getCProject() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   775
		String projectName = fProjText.getText().trim();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   776
		if (projectName.length() < 1) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   777
			return null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   778
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   779
		return CoreModel.getDefault().getCModel().getCProject(projectName);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   780
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   781
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   782
	/*
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   783
	 * (non-Javadoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   784
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   785
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   786
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   787
	@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   788
	public boolean isValid(ILaunchConfiguration config) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   789
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   790
		setErrorMessage(null);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   791
		setMessage(null);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   792
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   793
		if (!dontCheckProgram) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   794
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   795
		String name = fProjText.getText().trim();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   796
		if (name.length() == 0) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   797
			setErrorMessage(LaunchMessages.getString("CMainTab.Project_not_specified")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   798
			return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   799
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   800
		if (!ResourcesPlugin.getWorkspace().getRoot().getProject(name).exists()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   801
			setErrorMessage(LaunchMessages.getString("Launch.common.Project_does_not_exist")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   802
			return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   803
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   804
		IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   805
		if (!project.isOpen()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   806
			setErrorMessage(LaunchMessages.getString("CMainTab.Project_must_be_opened")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   807
			return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   808
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   809
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   810
		name = fProgText.getText().trim();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   811
		if (name.length() == 0) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   812
			setErrorMessage(LaunchMessages.getString("CMainTab.Program_not_specified")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   813
			return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   814
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   815
		if (name.equals(".") || name.equals("..")) { //$NON-NLS-1$ //$NON-NLS-2$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   816
			setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   817
			return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   818
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   819
		IPath exePath = new Path(name);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   820
		if (!exePath.isAbsolute()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   821
			IPath location = project.getLocation();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   822
			if (location == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   823
				setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   824
				return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   825
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   826
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   827
			exePath = location.append(name);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   828
			if (!exePath.toFile().exists()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   829
				// Try the old way, which is required to support linked resources.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   830
				IFile projFile = null;					
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   831
				try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   832
					projFile = project.getFile(name);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   833
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   834
				catch (IllegalArgumentException exc) {}	// thrown if relative path that resolves to a root file ("..\somefile")
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   835
				if (projFile == null || !projFile.exists()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   836
					setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   837
					return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   838
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   839
				else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   840
					exePath = projFile.getLocation();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   841
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   842
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   843
		} 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   844
		if (!exePath.toFile().exists()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   845
			setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   846
			return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   847
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   848
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   849
			if (!isBinary(project, exePath)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   850
				setErrorMessage(LaunchMessages.getString("CMainTab.Program_is_not_a_recongnized_executable")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   851
				return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   852
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   853
		} catch (CoreException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   854
			LaunchUIPlugin.log(e);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   855
			setErrorMessage(e.getLocalizedMessage());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   856
			return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   857
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   858
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   859
		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   860
		if (fCoreText != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   861
			String coreName = fCoreText.getText().trim();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   862
			// We accept an empty string.  This should trigger a prompt to the user
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   863
			// This allows to re-use the launch, with a different core file.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   864
			if (!coreName.equals(EMPTY_STRING)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   865
				if (coreName.equals(".") || coreName.equals("..")) { //$NON-NLS-1$ //$NON-NLS-2$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   866
					setErrorMessage(LaunchMessages.getString("CMainTab.Core_does_not_exist")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   867
					return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   868
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   869
				IPath corePath = new Path(coreName);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   870
				if (!corePath.toFile().exists()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   871
					setErrorMessage(LaunchMessages.getString("CMainTab.Core_does_not_exist")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   872
					return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   873
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   874
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   875
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   876
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   877
		return true;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   878
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   879
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   880
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   881
	 * @param project
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   882
	 * @param exePath
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   883
	 * @return
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   884
	 * @throws CoreException
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   885
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   886
	protected boolean isBinary(IProject project, IPath exePath) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   887
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   888
			Boolean binValue = fBinaryExeCache.get(exePath);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   889
			if (binValue == null)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   890
			{
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   891
				IBinaryObject exe = LaunchUtils.getBinary(project, exePath);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   892
				binValue = exe != null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   893
				fBinaryExeCache.put(exePath, binValue);				
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   894
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   895
			return binValue;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   896
		} catch (ClassCastException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   897
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   898
		return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   899
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   900
	/*
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   901
	 * (non-Javadoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   902
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   903
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   904
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   905
	public void setDefaults(ILaunchConfigurationWorkingCopy config) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   906
	    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   907
	    // Workaround for bug 262840: select the standard CDT launcher by default.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   908
	    HashSet<String> set = new HashSet<String>();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   909
	    set.add(getLaunchConfigurationDialog().getMode());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   910
	    try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   911
    	    ILaunchDelegate preferredDelegate = config.getPreferredDelegate(set);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   912
    	    if (preferredDelegate == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   913
    	        if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_APP)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   914
    	            config.setPreferredLaunchDelegate(set, "org.eclipse.cdt.cdi.launch.localCLaunch");
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   915
    	        } else if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_ATTACH)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   916
                    config.setPreferredLaunchDelegate(set, "org.eclipse.cdt.cdi.launch.localCAttachLaunch");
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   917
    	        } else if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_POST_MORTEM)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   918
                    config.setPreferredLaunchDelegate(set, "org.eclipse.cdt.cdi.launch.coreFileCLaunch");
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   919
                } 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   920
    	    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   921
	    } catch (CoreException e) {}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   922
	        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   923
		// We set empty attributes for project & program so that when one config
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   924
		// is
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   925
		// compared to another, the existence of empty attributes doesn't cause
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   926
		// an
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   927
		// incorrect result (the performApply() method can result in empty
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   928
		// values
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   929
		// for these attributes being set on a config if there is nothing in the
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   930
		// corresponding text boxes)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   931
		// plus getContext will use this to base context from if set.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   932
		config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, EMPTY_STRING);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   933
		config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, EMPTY_STRING);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   934
		config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, EMPTY_STRING);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   935
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   936
		ICElement cElement = null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   937
		cElement = getContext(config, getPlatform(config));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   938
		if (cElement != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   939
			initializeCProject(cElement, config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   940
			initializeProgramName(cElement, config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   941
		} else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   942
			// don't want to remember the interim value from before
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   943
			config.setMappedResources(null);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   944
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   945
		if (wantsTerminalOption()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   946
			config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, ICDTLaunchConfigurationConstants.USE_TERMINAL_DEFAULT);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   947
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   948
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   949
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   950
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   951
	 * Set the program name attributes on the working copy based on the ICElement
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   952
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   953
	protected void initializeProgramName(ICElement cElement, ILaunchConfigurationWorkingCopy config) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   954
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   955
		boolean renamed = false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   956
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   957
		if (!(cElement instanceof IBinary))
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   958
		{
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   959
			cElement = cElement.getCProject();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   960
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   961
		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   962
		if (cElement instanceof ICProject) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   963
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   964
			IProject project = cElement.getCProject().getProject();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   965
			String name = project.getName();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   966
			ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(project);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   967
			if (projDes != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   968
				String buildConfigName = projDes.getActiveConfiguration().getName();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   969
				//bug 234951
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   970
				name = LaunchMessages.getFormattedString("CMainTab.Configuration_name", new String[]{name, buildConfigName}); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   971
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   972
			name = getLaunchConfigurationDialog().generateName(name);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   973
			config.rename(name);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   974
			renamed = true;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   975
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   976
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   977
		IBinary binary = null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   978
		if (cElement instanceof ICProject) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   979
			IBinary[] bins = getBinaryFiles((ICProject)cElement);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   980
			if (bins != null && bins.length == 1) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   981
				binary = bins[0];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   982
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   983
		} else if (cElement instanceof IBinary) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   984
			binary = (IBinary)cElement;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   985
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   986
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   987
		if (binary != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   988
			String path;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   989
			path = binary.getResource().getProjectRelativePath().toOSString();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   990
			config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, path);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   991
			if (!renamed)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   992
			{
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   993
				String name = binary.getElementName();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   994
				int index = name.lastIndexOf('.');
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   995
				if (index > 0) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   996
					name = name.substring(0, index);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   997
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   998
				name = getLaunchConfigurationDialog().generateName(name);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   999
				config.rename(name);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1000
				renamed = true;				
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1001
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1002
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1003
		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1004
		if (!renamed)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1005
		{
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1006
			String name = getLaunchConfigurationDialog().generateName(cElement.getCProject().getElementName());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1007
			config.rename(name);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1008
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1009
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1010
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1011
	@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1012
    public String getId() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1013
        return TAB_ID;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1014
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1015
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1016
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1017
	/*
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1018
	 * (non-Javadoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1019
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1020
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1021
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1022
	public String getName() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1023
		return LaunchMessages.getString("CMainTab.Main"); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1024
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1025
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1026
	/*
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1027
	 * (non-Javadoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1028
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1029
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1030
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1031
	@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1032
	public Image getImage() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1033
		return LaunchImages.get(LaunchImages.IMG_VIEW_MAIN_TAB);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1034
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1035
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1036
	/*
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1037
	 * (non-Javadoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1038
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1039
	 * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#updateLaunchConfigurationDialog()
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1040
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1041
	@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1042
	protected void updateLaunchConfigurationDialog() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1043
		super.updateLaunchConfigurationDialog();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1044
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1045
}