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