cdt/cdt_6_0_x/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java
author ryall
Mon, 10 Aug 2009 13:37:15 -0500
changeset 62 c400a1d2216a
parent 54 89a4ce4b37f5
child 71 51dbf4bbe3f7
permissions -rw-r--r--
Sync with changes in public CDT.
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
		
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   351
		fWorkspaceSettingsButton = new Button(buildGroup, SWT.RADIO);
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   352
		fWorkspaceSettingsButton.setText(LaunchMessages.getString("CMainTab.Workspace_settings_button_label")); //$NON-NLS-1$
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   353
		fWorkspaceSettingsButton.setToolTipText(LaunchMessages.getString("CMainTab.Workspace_settings_button_tooltip")); //$NON-NLS-1$
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   354
		fWorkspaceSettingsButton.addSelectionListener(new SelectionAdapter() {
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   355
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   356
			public void widgetSelected(SelectionEvent evt) {
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   357
				updateLaunchConfigurationDialog();
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   358
			}
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   359
		});
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   360
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   361
		fWorkpsaceSettingsLink = new Link(buildGroup, SWT.NONE); //$NON-NLS-1$
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   362
		fWorkpsaceSettingsLink.setText(LaunchMessages.getString("CMainTab.Workspace_settings_link_label")); //$NON-NLS-1$
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   363
		fWorkpsaceSettingsLink.addSelectionListener(new SelectionAdapter() {
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   364
			public void widgetSelected(SelectionEvent e) {
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   365
				PreferencesUtil.createPreferenceDialogOn(
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   366
						parent.getShell(), 
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   367
						LaunchMessages.getString("CMainTab.Workspace_settings_page_id"), //$NON-NLS-1$
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   368
						null, 
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   369
						null).open();
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   370
			}
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   371
		});
54
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   372
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   373
		fDisableBuildButton = new Button(buildGroup, SWT.RADIO);
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   374
		fDisableBuildButton.setText(LaunchMessages.getString("CMainTab.Disable_build_button_label")); //$NON-NLS-1$
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   375
		fDisableBuildButton.setToolTipText(LaunchMessages.getString("CMainTab.Disable_build_button_tooltip")); //$NON-NLS-1$
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   376
		fDisableBuildButton.addSelectionListener(new SelectionAdapter() {
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   377
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   378
			public void widgetSelected(SelectionEvent evt) {
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   379
				updateLaunchConfigurationDialog();
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   380
			}
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   381
		});
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   382
		
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   383
		new Label(buildGroup, SWT.NONE);
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   384
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   385
		fEnableBuildButton = new Button(buildGroup, SWT.RADIO);
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   386
		fEnableBuildButton.setText(LaunchMessages.getString("CMainTab.Enable_build_button_label")); //$NON-NLS-1$
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   387
		fEnableBuildButton.setToolTipText(LaunchMessages.getString("CMainTab.Enable_build_button_tooltip")); //$NON-NLS-1$
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   388
		fEnableBuildButton.addSelectionListener(new SelectionAdapter() {
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   389
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   390
			public void widgetSelected(SelectionEvent evt) {
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   391
				updateLaunchConfigurationDialog();
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
		});
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   394
		
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   395
		new Label(buildGroup, SWT.NONE);
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   396
	}
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   397
	/** @since 6.0 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   398
	protected void createCoreFileGroup(Composite parent, int colSpan) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   399
		Composite coreComp = new Composite(parent, SWT.NONE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   400
		GridLayout coreLayout = new GridLayout();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   401
		coreLayout.numColumns = 3;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   402
		coreLayout.marginHeight = 0;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   403
		coreLayout.marginWidth = 0;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   404
		coreComp.setLayout(coreLayout);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   405
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   406
		gd.horizontalSpan = colSpan;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   407
		coreComp.setLayoutData(gd);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   408
		fCoreLabel = new Label(coreComp, SWT.NONE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   409
		fCoreLabel.setText(LaunchMessages.getString("CMainTab.CoreFile_path")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   410
		gd = new GridData();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   411
		gd.horizontalSpan = 3;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   412
		fCoreLabel.setLayoutData(gd);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   413
		fCoreText = new Text(coreComp, SWT.SINGLE | SWT.BORDER);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   414
		gd = new GridData(GridData.FILL_HORIZONTAL);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   415
		fCoreText.setLayoutData(gd);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   416
		fCoreText.addModifyListener(new ModifyListener() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   417
			public void modifyText(ModifyEvent evt) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   418
				updateLaunchConfigurationDialog();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   419
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   420
		});
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   421
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   422
		Button browseForCoreButton;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   423
		browseForCoreButton = createPushButton(coreComp, LaunchMessages.getString("Launch.common.Browse_2"), null); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   424
		browseForCoreButton.addSelectionListener(new SelectionAdapter() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   425
			@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   426
			public void widgetSelected(SelectionEvent evt) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   427
				String text = handleBrowseButtonSelected();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   428
				if (text != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   429
					fCoreText.setText(text);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   430
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   431
				updateLaunchConfigurationDialog();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   432
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   433
		});
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   434
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   435
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   436
	protected boolean wantsTerminalOption() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   437
		return fWantsTerminalOption;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   438
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   439
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   440
	protected void createTerminalOption(Composite parent, int colSpan) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   441
		Composite mainComp = new Composite(parent, SWT.NONE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   442
		GridLayout mainLayout = new GridLayout();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   443
		mainLayout.numColumns = 1;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   444
		mainLayout.marginHeight = 0;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   445
		mainLayout.marginWidth = 0;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   446
		mainComp.setLayout(mainLayout);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   447
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   448
		gd.horizontalSpan = colSpan;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   449
		mainComp.setLayoutData(gd);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   450
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   451
		fTerminalButton = createCheckButton(mainComp, LaunchMessages.getString("CMainTab.UseTerminal")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   452
		fTerminalButton.addSelectionListener(new SelectionAdapter() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   453
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   454
			@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   455
			public void widgetSelected(SelectionEvent evt) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   456
				updateLaunchConfigurationDialog();
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
		fTerminalButton.setEnabled(PTY.isSupported());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   460
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   461
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   462
	/*
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   463
	 * (non-Javadoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   464
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   465
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   466
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   467
	public void initializeFrom(ILaunchConfiguration config) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   468
		filterPlatform = getPlatform(config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   469
		updateProjectFromConfig(config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   470
		updateProgramFromConfig(config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   471
		updateCoreFromConfig(config);
54
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   472
		updateBuildOptionFromConfig(config);
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   473
		updateTerminalFromConfig(config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   474
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   475
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   476
	protected void updateTerminalFromConfig(ILaunchConfiguration config) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   477
		if (fTerminalButton != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   478
			boolean useTerminal = true;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   479
			try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   480
				useTerminal = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, ICDTLaunchConfigurationConstants.USE_TERMINAL_DEFAULT);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   481
			} catch (CoreException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   482
				LaunchUIPlugin.log(e);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   483
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   484
			fTerminalButton.setSelection(useTerminal);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   485
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   486
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   487
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   488
	protected void updateProjectFromConfig(ILaunchConfiguration config) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   489
		String projectName = EMPTY_STRING;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   490
		String configName = EMPTY_STRING;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   491
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   492
			projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, EMPTY_STRING);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   493
			configName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, EMPTY_STRING);			
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   494
		} catch (CoreException ce) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   495
			LaunchUIPlugin.log(ce);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   496
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   497
		fProjText.setText(projectName);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   498
		updateBuildConfigCombo(configName);		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   499
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   500
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   501
	protected void updateProgramFromConfig(ILaunchConfiguration config) {
54
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   502
		if (fProgText != null)
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   503
		{
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   504
			String programName = EMPTY_STRING;
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   505
			try {
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   506
				programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, EMPTY_STRING);
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   507
			} catch (CoreException ce) {
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   508
				LaunchUIPlugin.log(ce);
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   509
			}
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   510
			fProgText.setText(programName);
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   511
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   512
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   513
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   514
	/** @since 6.0 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   515
	protected void updateCoreFromConfig(ILaunchConfiguration config) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   516
		if (fCoreText != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   517
			String coreName = EMPTY_STRING;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   518
			try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   519
				coreName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, EMPTY_STRING);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   520
			} catch (CoreException ce) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   521
				LaunchUIPlugin.log(ce);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   522
			}
62
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   523
			fCoreText.setText(coreName);
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   524
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   525
	}
54
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   526
62
c400a1d2216a Sync with changes in public CDT.
ryall
parents: 54
diff changeset
   527
	/** @since 6.1 */
54
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   528
	protected void updateBuildOptionFromConfig(ILaunchConfiguration config) {
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   529
		int buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING;
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   530
		try {
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   531
			buildBeforeLaunchValue = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, buildBeforeLaunchValue);
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   532
		} catch (CoreException e) {
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   533
			LaunchUIPlugin.log(e);
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   534
		}
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   535
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   536
		fDisableBuildButton.setSelection(buildBeforeLaunchValue == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED);
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   537
		fEnableBuildButton.setSelection(buildBeforeLaunchValue == ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_ENABLED);
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   538
		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
   539
	}
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   540
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   541
	/*
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   542
	 * (non-Javadoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   543
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   544
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   545
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   546
	public void performApply(ILaunchConfigurationWorkingCopy config) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   547
		ICProject cProject = this.getCProject();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   548
		if (cProject != null && cProject.exists())
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   549
		{
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   550
			config.setMappedResources(new IResource[] { cProject.getProject() });
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   551
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   552
		else
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   553
		{
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   554
			// the user typed in a non-existent project name.  Ensure that
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   555
			// won't be suppressed from the dialog.  This matches JDT behaviour
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   556
			config.setMappedResources(null);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   557
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   558
		config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, fProjText.getText());
54
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   559
		if (fBuildConfigCombo != null) {
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   560
			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
   561
		}
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   562
		if (fProgText != null) {
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   563
			config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, fProgText.getText());
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   564
		}
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   565
		if (fCoreText != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   566
			config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, fCoreText.getText());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   567
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   568
		if (fTerminalButton != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   569
			config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, fTerminalButton.getSelection());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   570
		}
54
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   571
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   572
		if (fDisableBuildButton != null) {
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   573
			int buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING;
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   574
			if (fDisableBuildButton.getSelection()) {
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   575
				buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED;
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   576
			} else if (fEnableBuildButton.getSelection()) {
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   577
				buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_ENABLED;
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   578
			}
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   579
			config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, buildBeforeLaunchValue);
89a4ce4b37f5 merge in Ken's previous merges and bug 8513.
timkelly
parents: 51
diff changeset
   580
		}
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   581
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   582
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   583
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   584
	 * Show a dialog that lists all main types
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   585
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   586
	protected void handleSearchButtonSelected() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   587
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   588
		if (getCProject() == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   589
			MessageDialog.openInformation(getShell(), LaunchMessages.getString("CMainTab.Project_required"), //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   590
					LaunchMessages.getString("CMainTab.Enter_project_before_searching_for_program")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   591
			return;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   592
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   593
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   594
		ILabelProvider programLabelProvider = new CElementLabelProvider() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   595
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   596
			@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   597
			public String getText(Object element) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   598
				if (element instanceof IBinary) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   599
					IBinary bin = (IBinary)element;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   600
					StringBuffer name = new StringBuffer();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   601
					name.append(bin.getPath().lastSegment());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   602
					return name.toString();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   603
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   604
				return super.getText(element);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   605
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   606
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   607
			@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   608
			public Image getImage(Object element) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   609
				if (! (element instanceof ICElement)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   610
					return super.getImage(element);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   611
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   612
				ICElement celement = (ICElement)element;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   613
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   614
				if (celement.getElementType() == ICElement.C_BINARY) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   615
					IBinary belement = (IBinary)celement;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   616
					if (belement.isExecutable()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   617
						return DebugUITools.getImage(IDebugUIConstants.IMG_ACT_RUN);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   618
					}
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
				return super.getImage(element);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   622
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   623
		};
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   624
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   625
		ILabelProvider qualifierLabelProvider = new CElementLabelProvider() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   626
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   627
			@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   628
			public String getText(Object element) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   629
				if (element instanceof IBinary) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   630
					IBinary bin = (IBinary)element;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   631
					StringBuffer name = new StringBuffer();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   632
					name.append(bin.getCPU() + (bin.isLittleEndian() ? "le" : "be")); //$NON-NLS-1$ //$NON-NLS-2$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   633
					name.append(" - "); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   634
					name.append(bin.getPath().toString());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   635
					return name.toString();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   636
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   637
				return super.getText(element);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   638
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   639
		};
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   640
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   641
		TwoPaneElementSelector dialog = new TwoPaneElementSelector(getShell(), programLabelProvider, qualifierLabelProvider);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   642
		dialog.setElements(getBinaryFiles(getCProject()));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   643
		dialog.setMessage(LaunchMessages.getString("CMainTab.Choose_program_to_run")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   644
		dialog.setTitle(LaunchMessages.getString("CMainTab.Program_Selection")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   645
		dialog.setUpperListLabel(LaunchMessages.getString("Launch.common.BinariesColon")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   646
		dialog.setLowerListLabel(LaunchMessages.getString("Launch.common.QualifierColon")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   647
		dialog.setMultipleSelection(false);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   648
		// dialog.set
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   649
		if (dialog.open() == Window.OK) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   650
			IBinary binary = (IBinary)dialog.getFirstResult();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   651
			fProgText.setText(binary.getResource().getProjectRelativePath().toString());
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
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   655
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   656
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   657
	 * 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
   658
	 * 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
   659
	 * the specified project.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   660
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   661
	protected void handleBinaryBrowseButtonSelected() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   662
		final ICProject cproject = getCProject();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   663
		if (cproject == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   664
			MessageDialog.openInformation(getShell(), LaunchMessages.getString("CMainTab.Project_required"), //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   665
					LaunchMessages.getString("CMainTab.Enter_project_before_browsing_for_program")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   666
			return;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   667
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   668
		FileDialog fileDialog = new FileDialog(getShell(), SWT.NONE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   669
		fileDialog.setFileName(fProgText.getText());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   670
		String text= fileDialog.open();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   671
		if (text != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   672
			fProgText.setText(text);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   673
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   674
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   675
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   676
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   677
	 * Show a dialog that lets the user select a file.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   678
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   679
	 * @since 6.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   680
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   681
	protected String handleBrowseButtonSelected() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   682
		FileDialog fileDialog = new FileDialog(getShell(), SWT.NONE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   683
		fileDialog.setFileName(fProgText.getText());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   684
		return fileDialog.open();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   685
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   686
	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   687
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   688
	 * Iterate through and suck up all of the executable files that we can find.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   689
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   690
	protected IBinary[] getBinaryFiles(final ICProject cproject) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   691
		final Display display;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   692
		if (cproject == null || !cproject.exists()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   693
			return null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   694
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   695
		if (getShell() == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   696
			display = LaunchUIPlugin.getShell().getDisplay();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   697
		} else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   698
			display = getShell().getDisplay();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   699
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   700
		final Object[] ret = new Object[1];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   701
		BusyIndicator.showWhile(display, new Runnable() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   702
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   703
			public void run() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   704
				try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   705
					ret[0] = cproject.getBinaryContainer().getBinaries();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   706
				} catch (CModelException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   707
					LaunchUIPlugin.errorDialog("Launch UI internal error", e); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   708
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   709
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   710
		});
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   711
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   712
		return (IBinary[])ret[0];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   713
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   714
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   715
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   716
	 * 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
   717
	 * 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
   718
	 * the specified project.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   719
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   720
	protected void handleProjectButtonSelected() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   721
		ICProject project = chooseCProject();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   722
		if (project == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   723
			return;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   724
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   725
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   726
		String projectName = project.getElementName();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   727
		fProjText.setText(projectName);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   728
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   729
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   730
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   731
	 * 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
   732
	 * was none.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   733
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   734
	protected ICProject chooseCProject() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   735
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   736
			ICProject[] projects = getCProjects();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   737
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   738
			ILabelProvider labelProvider = new CElementLabelProvider();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   739
			ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   740
			dialog.setTitle(LaunchMessages.getString("CMainTab.Project_Selection")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   741
			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
   742
			dialog.setElements(projects);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   743
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   744
			ICProject cProject = getCProject();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   745
			if (cProject != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   746
				dialog.setInitialSelections(new Object[]{cProject});
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   747
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   748
			if (dialog.open() == Window.OK) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   749
				return (ICProject)dialog.getFirstResult();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   750
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   751
		} catch (CModelException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   752
			LaunchUIPlugin.errorDialog("Launch UI internal error", e); //$NON-NLS-1$			
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   753
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   754
		return null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   755
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   756
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   757
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   758
	 * Return an array a ICProject whose platform match that of the runtime env.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   759
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   760
	protected ICProject[] getCProjects() throws CModelException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   761
		ICProject cproject[] = CoreModel.getDefault().getCModel().getCProjects();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   762
		List<ICProject> list = new ArrayList<ICProject>(cproject.length);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   763
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   764
		for (int i = 0; i < cproject.length; i++) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   765
			ICDescriptor cdesciptor = null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   766
			try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   767
				cdesciptor = CCorePlugin.getDefault().getCProjectDescription((IProject)cproject[i].getResource(), false);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   768
				if (cdesciptor != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   769
					String projectPlatform = cdesciptor.getPlatform();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   770
					if (filterPlatform.equals("*") //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   771
							|| projectPlatform.equals("*") //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   772
							|| filterPlatform.equalsIgnoreCase(projectPlatform) == true) {
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
				} else {
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
			} catch (CoreException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   779
				list.add(cproject[i]);
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
		return list.toArray(new ICProject[list.size()]);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   783
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   784
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   785
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   786
	 * 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
   787
	 * null if the text does not match a project name.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   788
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   789
	protected ICProject getCProject() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   790
		String projectName = fProjText.getText().trim();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   791
		if (projectName.length() < 1) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   792
			return null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   793
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   794
		return CoreModel.getDefault().getCModel().getCProject(projectName);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   795
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   796
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   797
	/*
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   798
	 * (non-Javadoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   799
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   800
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   801
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   802
	@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   803
	public boolean isValid(ILaunchConfiguration config) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   804
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   805
		setErrorMessage(null);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   806
		setMessage(null);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   807
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   808
		if (!dontCheckProgram) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   809
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   810
		String name = fProjText.getText().trim();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   811
		if (name.length() == 0) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   812
			setErrorMessage(LaunchMessages.getString("CMainTab.Project_not_specified")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   813
			return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   814
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   815
		if (!ResourcesPlugin.getWorkspace().getRoot().getProject(name).exists()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   816
			setErrorMessage(LaunchMessages.getString("Launch.common.Project_does_not_exist")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   817
			return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   818
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   819
		IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   820
		if (!project.isOpen()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   821
			setErrorMessage(LaunchMessages.getString("CMainTab.Project_must_be_opened")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   822
			return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   823
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   824
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   825
		name = fProgText.getText().trim();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   826
		if (name.length() == 0) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   827
			setErrorMessage(LaunchMessages.getString("CMainTab.Program_not_specified")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   828
			return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   829
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   830
		if (name.equals(".") || name.equals("..")) { //$NON-NLS-1$ //$NON-NLS-2$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   831
			setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   832
			return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   833
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   834
		IPath exePath = new Path(name);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   835
		if (!exePath.isAbsolute()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   836
			IPath location = project.getLocation();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   837
			if (location == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   838
				setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   839
				return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   840
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   841
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   842
			exePath = location.append(name);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   843
			if (!exePath.toFile().exists()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   844
				// Try the old way, which is required to support linked resources.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   845
				IFile projFile = null;					
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   846
				try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   847
					projFile = project.getFile(name);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   848
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   849
				catch (IllegalArgumentException exc) {}	// thrown if relative path that resolves to a root file ("..\somefile")
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   850
				if (projFile == null || !projFile.exists()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   851
					setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   852
					return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   853
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   854
				else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   855
					exePath = projFile.getLocation();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   856
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   857
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   858
		} 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   859
		if (!exePath.toFile().exists()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   860
			setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   861
			return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   862
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   863
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   864
			if (!isBinary(project, exePath)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   865
				setErrorMessage(LaunchMessages.getString("CMainTab.Program_is_not_a_recongnized_executable")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   866
				return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   867
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   868
		} catch (CoreException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   869
			LaunchUIPlugin.log(e);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   870
			setErrorMessage(e.getLocalizedMessage());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   871
			return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   872
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   873
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   874
		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   875
		if (fCoreText != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   876
			String coreName = fCoreText.getText().trim();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   877
			// We accept an empty string.  This should trigger a prompt to the user
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   878
			// This allows to re-use the launch, with a different core file.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   879
			if (!coreName.equals(EMPTY_STRING)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   880
				if (coreName.equals(".") || coreName.equals("..")) { //$NON-NLS-1$ //$NON-NLS-2$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   881
					setErrorMessage(LaunchMessages.getString("CMainTab.Core_does_not_exist")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   882
					return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   883
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   884
				IPath corePath = new Path(coreName);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   885
				if (!corePath.toFile().exists()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   886
					setErrorMessage(LaunchMessages.getString("CMainTab.Core_does_not_exist")); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   887
					return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   888
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   889
			}
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
		return true;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   893
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   894
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   895
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   896
	 * @param project
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   897
	 * @param exePath
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   898
	 * @return
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   899
	 * @throws CoreException
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   900
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   901
	protected boolean isBinary(IProject project, IPath exePath) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   902
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   903
			Boolean binValue = fBinaryExeCache.get(exePath);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   904
			if (binValue == null)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   905
			{
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   906
				IBinaryObject exe = LaunchUtils.getBinary(project, exePath);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   907
				binValue = exe != null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   908
				fBinaryExeCache.put(exePath, binValue);				
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   909
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   910
			return binValue;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   911
		} catch (ClassCastException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   912
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   913
		return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   914
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   915
	/*
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   916
	 * (non-Javadoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   917
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   918
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   919
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   920
	public void setDefaults(ILaunchConfigurationWorkingCopy config) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   921
	    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   922
	    // Workaround for bug 262840: select the standard CDT launcher by default.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   923
	    HashSet<String> set = new HashSet<String>();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   924
	    set.add(getLaunchConfigurationDialog().getMode());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   925
	    try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   926
    	    ILaunchDelegate preferredDelegate = config.getPreferredDelegate(set);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   927
    	    if (preferredDelegate == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   928
    	        if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_APP)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   929
    	            config.setPreferredLaunchDelegate(set, "org.eclipse.cdt.cdi.launch.localCLaunch");
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   930
    	        } else if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_ATTACH)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   931
                    config.setPreferredLaunchDelegate(set, "org.eclipse.cdt.cdi.launch.localCAttachLaunch");
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   932
    	        } else if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_POST_MORTEM)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   933
                    config.setPreferredLaunchDelegate(set, "org.eclipse.cdt.cdi.launch.coreFileCLaunch");
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   934
                } 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   935
    	    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   936
	    } catch (CoreException e) {}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   937
	        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   938
		// We set empty attributes for project & program so that when one config
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   939
		// is
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   940
		// compared to another, the existence of empty attributes doesn't cause
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   941
		// an
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   942
		// incorrect result (the performApply() method can result in empty
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   943
		// values
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   944
		// for these attributes being set on a config if there is nothing in the
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   945
		// corresponding text boxes)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   946
		// plus getContext will use this to base context from if set.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   947
		config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, EMPTY_STRING);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   948
		config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, EMPTY_STRING);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   949
		config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, EMPTY_STRING);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   950
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   951
		ICElement cElement = null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   952
		cElement = getContext(config, getPlatform(config));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   953
		if (cElement != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   954
			initializeCProject(cElement, config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   955
			initializeProgramName(cElement, config);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   956
		} else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   957
			// don't want to remember the interim value from before
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   958
			config.setMappedResources(null);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   959
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   960
		if (wantsTerminalOption()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   961
			config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, ICDTLaunchConfigurationConstants.USE_TERMINAL_DEFAULT);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   962
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   963
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   964
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   965
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   966
	 * Set the program name attributes on the working copy based on the ICElement
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   967
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   968
	protected void initializeProgramName(ICElement cElement, ILaunchConfigurationWorkingCopy config) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   969
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   970
		boolean renamed = false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   971
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   972
		if (!(cElement instanceof IBinary))
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   973
		{
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   974
			cElement = cElement.getCProject();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   975
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   976
		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   977
		if (cElement instanceof ICProject) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   978
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   979
			IProject project = cElement.getCProject().getProject();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   980
			String name = project.getName();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   981
			ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(project);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   982
			if (projDes != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   983
				String buildConfigName = projDes.getActiveConfiguration().getName();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   984
				//bug 234951
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   985
				name = LaunchMessages.getFormattedString("CMainTab.Configuration_name", new String[]{name, buildConfigName}); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   986
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   987
			name = getLaunchConfigurationDialog().generateName(name);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   988
			config.rename(name);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   989
			renamed = true;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   990
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   991
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   992
		IBinary binary = null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   993
		if (cElement instanceof ICProject) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   994
			IBinary[] bins = getBinaryFiles((ICProject)cElement);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   995
			if (bins != null && bins.length == 1) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   996
				binary = bins[0];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   997
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   998
		} else if (cElement instanceof IBinary) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   999
			binary = (IBinary)cElement;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1000
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1001
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1002
		if (binary != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1003
			String path;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1004
			path = binary.getResource().getProjectRelativePath().toOSString();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1005
			config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, path);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1006
			if (!renamed)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1007
			{
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1008
				String name = binary.getElementName();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1009
				int index = name.lastIndexOf('.');
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1010
				if (index > 0) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1011
					name = name.substring(0, index);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1012
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1013
				name = getLaunchConfigurationDialog().generateName(name);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1014
				config.rename(name);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1015
				renamed = true;				
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1016
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1017
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1018
		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1019
		if (!renamed)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1020
		{
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1021
			String name = getLaunchConfigurationDialog().generateName(cElement.getCProject().getElementName());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1022
			config.rename(name);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1023
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1024
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1025
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1026
	@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1027
    public String getId() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1028
        return TAB_ID;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1029
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1030
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1031
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1032
	/*
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1033
	 * (non-Javadoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1034
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1035
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1036
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1037
	public String getName() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1038
		return LaunchMessages.getString("CMainTab.Main"); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1039
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1040
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1041
	/*
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1042
	 * (non-Javadoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1043
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1044
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1045
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1046
	@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1047
	public Image getImage() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1048
		return LaunchImages.get(LaunchImages.IMG_VIEW_MAIN_TAB);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1049
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1050
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1051
	/*
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1052
	 * (non-Javadoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1053
	 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1054
	 * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#updateLaunchConfigurationDialog()
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1055
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1056
	@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1057
	protected void updateLaunchConfigurationDialog() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1058
		super.updateLaunchConfigurationDialog();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1059
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1060
}