debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/DebugRunProcessDialog.java
author Ed Swartz <ed.swartz@nokia.com>
Thu, 08 Apr 2010 14:41:29 -0500
changeset 1185 02373fb1e121
parent 1090 02cf64aef519
child 1284 7ef1318ac801
permissions -rw-r--r--
Fix use of PathUtils: do not use new Path() on a Windows format path; this breaks in Linux.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
     1
/*
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
     3
* All rights reserved.
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
     4
* This component and the accompanying materials are made available
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
     6
* which accompanies this distribution, and is available
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
     8
*
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
     9
* Initial Contributors:
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    11
*
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    12
* Contributors:
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    13
*
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    14
* Description: 
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    15
*
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    16
*/
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    17
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    18
package com.nokia.cdt.internal.debug.launch.newwizard;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    19
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    20
import java.io.File;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    21
import java.text.MessageFormat;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    22
import java.util.List;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    23
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    24
import org.eclipse.cdt.core.model.CoreModel;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    25
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    26
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    27
import org.eclipse.core.resources.IProject;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    28
import org.eclipse.core.runtime.IPath;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    29
import org.eclipse.core.runtime.IStatus;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    30
import org.eclipse.core.runtime.Path;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    31
import org.eclipse.core.runtime.Status;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    32
import org.eclipse.jface.layout.GridDataFactory;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    33
import org.eclipse.jface.layout.GridLayoutFactory;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    34
import org.eclipse.jface.resource.JFaceResources;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    35
import org.eclipse.jface.viewers.ArrayContentProvider;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    36
import org.eclipse.jface.viewers.ComboViewer;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    37
import org.eclipse.jface.viewers.ISelectionChangedListener;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    38
import org.eclipse.jface.viewers.IStructuredSelection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    39
import org.eclipse.jface.viewers.LabelProvider;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    40
import org.eclipse.jface.viewers.SelectionChangedEvent;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    41
import org.eclipse.jface.viewers.StructuredSelection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    42
import org.eclipse.swt.SWT;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    43
import org.eclipse.swt.events.ControlAdapter;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    44
import org.eclipse.swt.events.ControlEvent;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    45
import org.eclipse.swt.events.DisposeEvent;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    46
import org.eclipse.swt.events.DisposeListener;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    47
import org.eclipse.swt.events.ModifyEvent;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    48
import org.eclipse.swt.events.ModifyListener;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    49
import org.eclipse.swt.events.SelectionAdapter;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    50
import org.eclipse.swt.events.SelectionEvent;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    51
import org.eclipse.swt.layout.GridData;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    52
import org.eclipse.swt.widgets.Button;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    53
import org.eclipse.swt.widgets.Combo;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    54
import org.eclipse.swt.widgets.Composite;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    55
import org.eclipse.swt.widgets.Control;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    56
import org.eclipse.swt.widgets.FileDialog;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    57
import org.eclipse.swt.widgets.Label;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    58
import org.eclipse.swt.widgets.Link;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    59
import org.eclipse.swt.widgets.Shell;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    60
import org.eclipse.swt.widgets.Text;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    61
import org.eclipse.ui.dialogs.PreferencesUtil;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    62
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    63
import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    64
import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    65
import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    66
import com.nokia.carbide.cdt.builder.project.ISISBuilderInfo;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    67
import com.nokia.cdt.internal.debug.launch.newwizard.LaunchWizardData.EExeSelection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    68
import com.nokia.cpp.internal.api.utils.core.PathUtils;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    69
import com.nokia.cpp.internal.api.utils.ui.BrowseDialogUtils;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    70
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    71
/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    72
 *	This dialog allows in-depth configuration of the debug/run process options.
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    73
 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    74
public class DebugRunProcessDialog extends AbstractLaunchSettingsDialog implements ICProjectDescriptionListener {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    75
	private ComboViewer projectExecutableViewer;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    76
	private Text remoteProgramEntry;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    77
	private Button projectExecutableRadioButton;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    78
	private Button remoteExecutableRadioButton;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    79
	private Button attachToProcessRadioButton;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    80
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    81
	private Label packageInfoLabel;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    82
	private Button installPackageCheckbox;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    83
	private Combo sisFile;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    84
	private Text sisEdit;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    85
	private Button sisBrowse;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    86
	private Composite installPackageUI;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    87
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    88
	protected DebugRunProcessDialog(Shell shell, LaunchWizardData data) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    89
		super(shell, data);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    90
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    91
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    92
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    93
	/* (non-Javadoc)
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    94
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    95
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    96
	@Override
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    97
	protected Control createDialogArea(Composite parent) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    98
		Composite composite = initDialogArea(parent, 
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
    99
				MessageFormat.format(Messages.getString("DebugRunProcessDialog.ChangeProcessMsg"), data.getModeLabel()), //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   100
				data.isDebug() ? LaunchWizardHelpIds.WIZARD_DIALOG_CHANGE_DEBUG_PROCESS : 
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   101
					LaunchWizardHelpIds.WIZARD_DIALOG_CHANGE_RUN_PROCESS);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   102
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   103
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   104
		createProcessSelector(composite);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   105
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   106
		Label sep = new Label(composite, SWT.NONE);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   107
		GridDataFactory.fillDefaults().applyTo(sep);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   108
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   109
		createPackageConfiguration(composite);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   110
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   111
		initUI();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   112
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   113
		validate();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   114
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   115
		return composite;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   116
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   117
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   118
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   119
	private void createProcessSelector(Composite composite) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   120
		Label label;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   121
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   122
		label = new Label(composite, SWT.WRAP);
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   123
		label.setText(MessageFormat.format(Messages.getString("DebugRunProcessDialog.ModeLabel"), data.getModeLabel())); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   124
		label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   125
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   126
		GridDataFactory.fillDefaults().grab(true, false).applyTo(composite);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   127
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   128
		Composite radioGroup = new Composite(composite, SWT.NONE);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   129
		GridDataFactory.fillDefaults().grab(true, false).applyTo(radioGroup);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   130
		GridLayoutFactory.fillDefaults().extendedMargins(INDENT, 0, 0, 0).numColumns(2).applyTo(radioGroup);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   131
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   132
		createProjectExecutableRadioButton(radioGroup);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   133
		createRemoteExecutableRadioButton(radioGroup);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   134
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   135
		label = new Label(radioGroup, SWT.SEPARATOR | SWT.HORIZONTAL);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   136
		GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(label);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   137
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   138
		createAttachToProcessRadioButton(radioGroup);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   139
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   140
		String msg;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   141
		if (data.isDebug())
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   142
			msg = Messages.getString("DebugRunProcessDialog.DebugConfigureMsg"); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   143
		else
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   144
			msg = Messages.getString("DebugRunProcessDialog.RunConfigureMsg"); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   145
		setMessage(msg);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   146
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   147
		switch (data.getExeSelection()) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   148
		case USE_PROJECT_EXECUTABLE:
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   149
			projectExecutableRadioButton.setSelection(true);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   150
			break;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   151
		case USE_REMOTE_EXECUTABLE:
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   152
			remoteExecutableRadioButton.setSelection(true);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   153
			break;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   154
		case ATTACH_TO_PROCESS:
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   155
			attachToProcessRadioButton.setSelection(true);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   156
			break;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   157
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   158
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   159
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   160
	private void createPackageConfiguration(Composite composite) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   161
		Label label;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   162
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   163
		label = new Label(composite, SWT.WRAP);
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   164
		label.setText(MessageFormat.format(Messages.getString("DebugRunProcessDialog.DeployLabel"), data.getModeLabel())); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   165
		label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   166
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   167
		GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   168
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   169
		packageInfoLabel = new Label(composite, SWT.WRAP);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   170
		GridDataFactory.fillDefaults().grab(true, false).applyTo(packageInfoLabel);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   171
		composite.addControlListener(new ControlAdapter() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   172
			@Override
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   173
			public void controlResized(ControlEvent e) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   174
				packageInfoLabel.pack();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   175
			}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   176
		});
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   177
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   178
		installPackageCheckbox = new Button(composite, SWT.CHECK);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   179
		GridDataFactory.fillDefaults().applyTo(installPackageCheckbox);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   180
		
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   181
		installPackageCheckbox.setText(Messages.getString("DebugRunProcessDialog.InstallBeforeLaunchLabel")); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   182
		installPackageUI = new Composite(composite, SWT.NONE);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   183
		GridDataFactory.fillDefaults().indent(INDENT, 0).applyTo(installPackageUI);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   184
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   185
		createSISContents(installPackageUI);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   186
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   187
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   188
		installPackageCheckbox.addSelectionListener(new SelectionAdapter() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   189
			@Override
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   190
			public void widgetSelected(SelectionEvent e) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   191
				data.setInstallPackage(installPackageCheckbox.getSelection());
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   192
				updatePackageUI();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   193
			}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   194
		});
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   195
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   196
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   197
		if (data.isInstallPackage()) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   198
			installPackageCheckbox.setSelection(true);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   199
			updatePackageUI();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   200
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   201
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   202
		updateSisFile();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   203
		updatePackageUI();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   204
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   205
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   206
    protected void createSISContents(Composite composite) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   207
        GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(2).applyTo(composite);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   208
            
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   209
		final IProject project = data.getProject();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   210
		ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(project);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   211
		if (cpi != null) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   212
			final Label sisLabel = new Label(composite, SWT.NONE);
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   213
			sisLabel.setText(Messages.getString("DebugRunProcessDialog.SISFileLabel")); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   214
			GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(1, 1).applyTo(sisLabel);
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   215
			sisLabel.setToolTipText(Messages.getString("DebugRunProcessDialog.SISQueryTip")); //$NON-NLS-1$
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   216
			sisLabel.setData(UID, "DebugRunProcessDialog.sisLabel"); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   217
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   218
			sisFile = new Combo(composite, SWT.READ_ONLY);
1045
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   219
			GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true, false).applyTo(sisFile);
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   220
			sisFile.setToolTipText(Messages.getString("DebugRunProcessDialog.SISQueryTip"));  //$NON-NLS-1$
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   221
			sisFile.setData(UID, "DebugRunProcessDialog.sisFile"); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   222
			
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   223
			sisFile.addSelectionListener(new SelectionAdapter() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   224
				@Override
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   225
				public void widgetSelected(SelectionEvent e) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   226
					updateSisFile();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   227
				}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   228
			});
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   229
			
1045
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   230
			updateSisFileCombo(cpi);
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   231
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   232
			// listen for events so we can detect if they click on the link below and add new sis info.
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   233
			CoreModel.getDefault().getProjectDescriptionManager().addCProjectDescriptionListener(this, CProjectDescriptionEvent.APPLIED);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   234
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   235
			composite.addDisposeListener(new DisposeListener() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   236
				
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   237
				public void widgetDisposed(DisposeEvent e) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   238
					CoreModel.getDefault().getProjectDescriptionManager().removeCProjectDescriptionListener(DebugRunProcessDialog.this);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   239
				}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   240
			});
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   241
			
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   242
			Link link = new Link(composite, SWT.NONE);
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   243
			link.setText("<a>" + Messages.getString("DebugRunProcessDialog.SISConfigLinkText") + "...</a>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   244
			GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).span(2, 1).grab(true, false).applyTo(link);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   245
			link.addSelectionListener(new SelectionAdapter() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   246
				public void widgetSelected(SelectionEvent e) {
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   247
					PreferencesUtil.createPropertyDialogOn(getShell(), project, "com.nokia.carbide.cdt.internal.builder.ui.CarbideBuildConfigurationsPage", null, null).open(); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   248
				}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   249
			});
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   250
			link.setData(UID, "DebugRunProcessDialog.link"); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   251
		} else {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   252
			// not a Carbide project, just an executable.  show a browse/edit combo
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   253
			// to let them select a sis file if they want to.
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   254
			final Label sisLabel = new Label(composite, SWT.NONE);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   255
			sisLabel.setText("SIS File to Install:"); //$NON-NLS-1$
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   256
			GridDataFactory.swtDefaults().span(2, 1).applyTo(sisLabel);
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   257
			sisLabel.setToolTipText(Messages.getString("DebugRunProcessDialog.SISQueryTip")); //$NON-NLS-1$
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   258
			sisLabel.setData(UID, "DebugRunProcessDialog.sisLabel"); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   259
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   260
			sisEdit = new Text(composite, SWT.BORDER);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   261
			GridDataFactory.fillDefaults().span(1, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(sisEdit);
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   262
			sisEdit.setToolTipText(Messages.getString("DebugRunProcessDialog.SISQueryTip")); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   263
			sisEdit.addModifyListener(new ModifyListener() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   264
				public void modifyText(ModifyEvent e) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   265
					updateSisFile();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   266
					validate();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   267
				}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   268
			});
1045
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   269
			String sisPath = data.getSisPath();
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   270
			if (sisPath != null)
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   271
				sisEdit.setText(sisPath);
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   272
			sisEdit.setData(UID, "DebugRunProcessDialog.sisEdit"); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   273
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   274
			sisBrowse = new Button(composite, SWT.NONE);
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   275
			sisBrowse.setText(Messages.getString("DebugRunProcessDialog.BrowseLabel")); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   276
			sisBrowse.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   277
			sisBrowse.addSelectionListener(new SelectionAdapter() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   278
				public void widgetSelected(SelectionEvent evt) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   279
					FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   280
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   281
					dialog.setText(Messages.getString("DebugRunProcessDialog.Title")); //$NON-NLS-1$
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   282
					dialog.setFilterExtensions(new String[] {"*.sis*", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   283
					dialog.setFilterNames(new String[] {Messages.getString("DebugRunProcessDialog.InstallFilterName"), Messages.getString("DebugRunProcessDialog.AllFilterName")}); //$NON-NLS-1$ //$NON-NLS-2$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   284
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   285
					BrowseDialogUtils.initializeFrom(dialog, sisEdit);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   286
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   287
					String result = dialog.open();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   288
					if (result != null && new File(result).exists()) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   289
						sisEdit.setText(result);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   290
						updateSisFile();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   291
						validate();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   292
					}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   293
				}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   294
			});
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   295
			sisBrowse.setData(UID, "DebugRunProcessDialog.sisBrowse"); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   296
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   297
    }
1045
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   298
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   299
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   300
	private void updateSisFileCombo(ICarbideProjectInfo cpi) {
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   301
		sisFile.add(Messages.getString("DebugRunProcessDialog.NoneItem")); //$NON-NLS-1$
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   302
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   303
		ICarbideBuildConfiguration config = cpi.getDefaultConfiguration();
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   304
		for (ISISBuilderInfo info : config.getSISBuilderInfoList()) {
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   305
			IPath sisPath = info.getSigningType() == ISISBuilderInfo.DONT_SIGN ? info.getUnsignedSISFullPath() : info.getSignedSISFullPath();
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   306
			sisFile.add(sisPath.toOSString());
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   307
		}
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   308
		
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   309
		// select the first sis file if any, otherwise select none
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   310
		if (sisFile.getItemCount() > 1) {
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   311
			sisFile.select(1);
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   312
		} else {
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   313
			sisFile.select(0);
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   314
		}
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   315
		updateSisFile();
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   316
	}
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   317
    
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   318
    
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   319
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   320
	 * 
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   321
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   322
	protected void updateSisFile() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   323
		String sisPath;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   324
    	if (sisFile != null) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   325
        	sisPath = sisFile.getSelectionIndex() == 0 ? null : sisFile.getText(); //$NON-NLS-1$
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   326
        	data.setSisPath(sisPath);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   327
    	} else if (sisEdit != null) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   328
    		sisPath = sisEdit.getText();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   329
    		data.setSisPath(sisPath);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   330
    	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   331
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   332
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   333
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   334
	private void updatePackageUI() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   335
		installPackageUI.setEnabled(data.isInstallPackage());
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   336
		for (Control kid : installPackageUI.getChildren())
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   337
			kid.setEnabled(data.isInstallPackage());
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   338
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   339
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   340
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   341
	public void handleEvent(CProjectDescriptionEvent event) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   342
		Shell shell = getShell();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   343
		if (shell == null || shell.isDisposed()) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   344
			return;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   345
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   346
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   347
		IProject project = event.getProject() ;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   348
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   349
		if (project != data.getProject()) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   350
			return;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   351
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   352
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   353
		if (sisFile != null) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   354
			ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(project);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   355
			if (cpi != null) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   356
				sisFile.removeAll();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   357
1045
7bd4eb5648d7 bug 10808 tweak UI + validation + fix issues with non-carbide project case
dadubrow
parents: 969
diff changeset
   358
				updateSisFileCombo(cpi);
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   359
			}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   360
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   361
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   362
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   363
	protected void initUI() {
1090
02cf64aef519 Fix 10861
dadubrow
parents: 1045
diff changeset
   364
		List<IPath> exes = data.getLaunchableExes();
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   365
		projectExecutableViewer.setInput(exes);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   366
		IPath exeSelectionPath = data.getExeSelectionPath();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   367
		if (exeSelectionPath.equals(Path.EMPTY) && !exes.isEmpty())
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   368
			exeSelectionPath = exes.get(0);
1090
02cf64aef519 Fix 10861
dadubrow
parents: 1045
diff changeset
   369
		if (!Path.EMPTY.equals(exeSelectionPath)) {
02cf64aef519 Fix 10861
dadubrow
parents: 1045
diff changeset
   370
			projectExecutableViewer.setSelection(new StructuredSelection(exeSelectionPath));
02cf64aef519 Fix 10861
dadubrow
parents: 1045
diff changeset
   371
			IPath remotePath = createSuggestedRemotePath(exeSelectionPath);
02cf64aef519 Fix 10861
dadubrow
parents: 1045
diff changeset
   372
			remoteProgramEntry.setText(PathUtils.convertPathToWindows(remotePath));
02cf64aef519 Fix 10861
dadubrow
parents: 1045
diff changeset
   373
		}
02cf64aef519 Fix 10861
dadubrow
parents: 1045
diff changeset
   374
		
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   375
		if (data.getExeSelection() == EExeSelection.USE_PROJECT_EXECUTABLE && exeSelectionPath != null) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   376
			projectExecutableRadioButton.forceFocus();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   377
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   378
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   379
		if (data.getExeSelection() == EExeSelection.USE_REMOTE_EXECUTABLE && exeSelectionPath != null) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   380
			remoteExecutableRadioButton.forceFocus();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   381
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   382
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   383
		if (data.getExeSelection() == EExeSelection.ATTACH_TO_PROCESS) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   384
			attachToProcessRadioButton.forceFocus();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   385
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   386
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   387
		handleProjectExecutableRadioSelected();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   388
		handleRemoteExecutableRadioSelected();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   389
		handleAttachToProcessRadioSelected();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   390
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   391
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   392
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   393
	private IPath createSuggestedRemotePath(IPath exeSelectionPath) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   394
		String filename = exeSelectionPath.lastSegment();
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   395
		return PathUtils.createPath("C:/sys/bin").append(filename); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   396
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   397
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   398
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   399
	 * Allow selecting an executable detected to be built by the program.
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   400
	 * @param radioGroup
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   401
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   402
	private void createProjectExecutableRadioButton(Composite radioGroup) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   403
		projectExecutableRadioButton = new Button(radioGroup, SWT.RADIO);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   404
		GridDataFactory.fillDefaults().grab(false, false).applyTo(projectExecutableRadioButton);
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   405
		projectExecutableRadioButton.setText(Messages.getString("DebugRunProcessDialog.LaunchProjectExeLabel")); //$NON-NLS-1$
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   406
		projectExecutableRadioButton.setData(UID, "radio_project_executable"); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   407
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   408
		projectExecutableViewer = new ComboViewer(radioGroup, SWT.READ_ONLY);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   409
		GridDataFactory.fillDefaults().grab(true, false).applyTo(projectExecutableViewer.getControl());
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   410
		projectExecutableViewer.getControl().setData(UID, "combo_project_executable"); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   411
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   412
		projectExecutableViewer.setContentProvider(new ArrayContentProvider());
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   413
		projectExecutableViewer.setLabelProvider(new LabelProvider() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   414
			@Override
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   415
			public String getText(Object element) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   416
				if (element instanceof IPath)
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   417
					return ((IPath) element).lastSegment();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   418
				return super.getText(element);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   419
			}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   420
		});
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   421
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   422
		projectExecutableRadioButton.addSelectionListener(new SelectionAdapter() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   423
			@Override
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   424
			public void widgetSelected(SelectionEvent e) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   425
				handleProjectExecutableRadioSelected();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   426
			}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   427
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   428
		});
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   429
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   430
		projectExecutableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   431
			
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   432
			public void selectionChanged(SelectionChangedEvent event) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   433
				Object sel = ((IStructuredSelection) event.getSelection()).getFirstElement();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   434
				if (sel instanceof IPath) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   435
					data.setExeSelectionPath((IPath) sel); 
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   436
					
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   437
					// track the default remote program from the executable, for easy editing
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   438
					if (remoteProgramEntry != null) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   439
						IPath exeSelectionPath = createSuggestedRemotePath(data.getExeSelectionPath());
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   440
						remoteProgramEntry.setText(PathUtils.convertPathToWindows(exeSelectionPath)); 
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   441
					}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   442
					
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   443
					validate();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   444
				}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   445
			}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   446
		});
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   447
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   448
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   449
	private void handleProjectExecutableRadioSelected() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   450
		if (projectExecutableRadioButton.getSelection()) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   451
			projectExecutableViewer.getControl().setEnabled(true);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   452
			data.setExeSelection(EExeSelection.USE_PROJECT_EXECUTABLE);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   453
			IPath selectedPath = (IPath) ((IStructuredSelection) projectExecutableViewer.getSelection()).getFirstElement();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   454
			if (selectedPath != null) {
1185
02373fb1e121 Fix use of PathUtils: do not use new Path() on a Windows format path; this breaks in Linux.
Ed Swartz <ed.swartz@nokia.com>
parents: 1090
diff changeset
   455
				data.setExeSelectionPath(selectedPath);
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   456
			}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   457
			validate();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   458
		} else {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   459
			projectExecutableViewer.getControl().setEnabled(false);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   460
			// another button becomes active and sets the new launch process
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   461
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   462
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   463
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   464
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   465
	 * Allow user to enter an executable path.
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   466
	 * @param radioGroup
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   467
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   468
	private void createRemoteExecutableRadioButton(Composite radioGroup) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   469
		remoteExecutableRadioButton = new Button(radioGroup, SWT.RADIO);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   470
		GridDataFactory.fillDefaults().grab(false, false).applyTo(remoteExecutableRadioButton);
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   471
		remoteExecutableRadioButton.setText(Messages.getString("DebugRunProcessDialog.LaunchRemoteProgLabel")); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   472
		
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   473
		remoteExecutableRadioButton.setData(UID, "radio_remote_program"); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   474
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   475
		remoteProgramEntry = new Text(radioGroup, SWT.BORDER);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   476
		GridDataFactory.fillDefaults().grab(true, false).applyTo(remoteProgramEntry);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   477
		
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   478
		remoteProgramEntry.setData(UID, "text_remote_program"); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   479
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   480
		remoteExecutableRadioButton.addSelectionListener(new SelectionAdapter() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   481
			@Override
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   482
			public void widgetSelected(SelectionEvent e) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   483
				handleRemoteExecutableRadioSelected();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   484
			}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   485
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   486
		});
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   487
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   488
		remoteProgramEntry.addModifyListener(new ModifyListener() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   489
			public void modifyText(ModifyEvent e) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   490
				data.setExeSelectionPath(new Path(remoteProgramEntry.getText().trim()));
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   491
				validate();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   492
			}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   493
		});
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   494
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   495
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   496
	private void handleRemoteExecutableRadioSelected() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   497
		if (remoteExecutableRadioButton.getSelection()) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   498
			remoteProgramEntry.setEnabled(true);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   499
			data.setExeSelection(EExeSelection.USE_REMOTE_EXECUTABLE);
1185
02373fb1e121 Fix use of PathUtils: do not use new Path() on a Windows format path; this breaks in Linux.
Ed Swartz <ed.swartz@nokia.com>
parents: 1090
diff changeset
   500
			IPath path = PathUtils.createPath(remoteProgramEntry.getText());
02373fb1e121 Fix use of PathUtils: do not use new Path() on a Windows format path; this breaks in Linux.
Ed Swartz <ed.swartz@nokia.com>
parents: 1090
diff changeset
   501
			data.setExeSelectionPath(path);
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   502
			validate();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   503
		} else {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   504
			remoteProgramEntry.setEnabled(false);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   505
			// another button becomes active and sets the new launch process
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   506
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   507
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   508
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   509
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   510
	 * Allow user to attach to a process.
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   511
	 * @param radioGroup
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   512
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   513
	private void createAttachToProcessRadioButton(Composite radioGroup) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   514
		attachToProcessRadioButton = new Button(radioGroup, SWT.RADIO);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   515
		GridDataFactory.fillDefaults().grab(false, false).applyTo(attachToProcessRadioButton);
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   516
		attachToProcessRadioButton.setText(Messages.getString("DebugRunProcessDialog.AttachLabel")); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   517
		
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   518
		attachToProcessRadioButton.setData(UID, "radio_attach_to_process"); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   519
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   520
		Label label = new Label(radioGroup, SWT.WRAP);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   521
		GridDataFactory.fillDefaults().grab(false, false).align(SWT.LEFT, SWT.CENTER).applyTo(label);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   522
		
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   523
		label.setText(Messages.getString("DebugRunProcessDialog.AttachAddlMsg")); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   524
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   525
		attachToProcessRadioButton.addSelectionListener(new SelectionAdapter() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   526
			@Override
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   527
			public void widgetSelected(SelectionEvent e) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   528
				handleAttachToProcessRadioSelected();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   529
			}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   530
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   531
		});
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   532
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   533
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   534
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   535
	private void handleAttachToProcessRadioSelected() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   536
		if (attachToProcessRadioButton.getSelection()) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   537
			data.setExeSelection(EExeSelection.ATTACH_TO_PROCESS);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   538
			data.setExeSelectionPath(null);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   539
			validate();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   540
		} else {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   541
			// another button becomes active and sets the new launch process
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   542
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   543
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   544
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   545
	@Override
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   546
	protected void validate() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   547
		IStatus status = Status.OK_STATUS;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   548
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   549
		// check launch method
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   550
		IPath exePath = data.getExeSelectionPath(); 
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   551
		switch (data.getExeSelection()) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   552
		case USE_PROJECT_EXECUTABLE:
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   553
			if (exePath.isEmpty()) {
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   554
				status = error(Messages.getString("DebugRunProcessDialog.NoExesError")); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   555
			}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   556
			break;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   557
		case USE_REMOTE_EXECUTABLE:
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   558
			if (exePath.isEmpty()) {
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   559
				status = error(Messages.getString("DebugRunProcessDialog.EnterPathError")); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   560
			} else {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   561
				String exePathString = exePath.toString();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   562
				char drive = exePathString.charAt(0);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   563
				char colon = exePathString.length() < 2 ? 0x0 : exePathString.charAt(1);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   564
				char root = exePathString.length() < 3 ? 0x0 : exePathString.charAt(2);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   565
				char lastChar = exePathString.charAt(exePathString.length() - 1);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   566
				if (!Character.isLetter(drive) || colon != ':' || (root != '\\' && root != '/') || 
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   567
						lastChar == '\\' || lastChar == '/' || lastChar == ':') { 
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   568
					status = error(Messages.getString("DebugRunProcessDialog.AbsolutePathError")); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   569
				} else if (exePath.getFileExtension() == null) {
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   570
					status = warning(Messages.getString("DebugRunProcessDialog.FilePathError")); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   571
				}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   572
			}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   573
			break;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   574
		case ATTACH_TO_PROCESS:
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   575
			break;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   576
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   577
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   578
		// check SIS selection
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   579
		if (data.isInstallPackage()) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   580
	    	if (sisEdit != null) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   581
	    		String text = sisEdit.getText().trim();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   582
	    		if (text.length() > 0) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   583
	    			// empty is allowed, but if they specify something, make sure
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   584
	    			// it exists
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   585
	    			File file = new File(text);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   586
	    			if (!file.exists()) {
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   587
	    				status = error(Messages.getString("DebugRunProcessDialog.SISFileExistError"), text); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   588
	    			}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   589
	    		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   590
	    	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   591
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   592
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   593
		updateStatus(status);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   594
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   595
}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   596