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