debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/BuildOptionsSelectionPage.java
author stechong
Thu, 18 Jun 2009 16:52:27 -0500
changeset 273 c2533fd23253
child 566 960058f9da89
child 569 369485fbe634
permissions -rw-r--r--
Fix for Bug 8513.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
273
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
     1
/* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
     2
* All rights reserved.
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
     3
* This component and the accompanying materials are made available
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
     4
* under the terms of the License "Eclipse Public License v1.0"
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
     5
* which accompanies this distribution, and is available
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
     6
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
     7
*
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
     8
* Initial Contributors:
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
     9
* Nokia Corporation - initial contribution.
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    10
*
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    11
* Contributors:
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    12
*
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    13
* Description: 
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    14
*
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    15
*/
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    16
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    17
package com.nokia.cdt.internal.debug.launch.wizard;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    18
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    19
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    20
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    21
import org.eclipse.jface.wizard.WizardPage;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    22
import org.eclipse.swt.SWT;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    23
import org.eclipse.swt.events.SelectionAdapter;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    24
import org.eclipse.swt.events.SelectionEvent;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    25
import org.eclipse.swt.layout.GridData;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    26
import org.eclipse.swt.layout.GridLayout;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    27
import org.eclipse.swt.widgets.Button;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    28
import org.eclipse.swt.widgets.Composite;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    29
import org.eclipse.swt.widgets.Group;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    30
import org.eclipse.swt.widgets.Label;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    31
import org.eclipse.swt.widgets.Link;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    32
import org.eclipse.ui.PlatformUI;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    33
import org.eclipse.ui.dialogs.PreferencesUtil;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    34
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    35
/**
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    36
 * A wizard page that handles build options.
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    37
 *
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    38
 */
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    39
public class BuildOptionsSelectionPage extends WizardPage {
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    40
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    41
	private Button fDisableBuildButton;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    42
	private Button fEnableBuildButton;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    43
	private Button fWorkspaceSettingsButton;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    44
	private Link fWorkpsaceSettingsLink;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    45
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    46
	/**
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    47
	 * Constructor.
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    48
	 */
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    49
	public BuildOptionsSelectionPage() {
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    50
		super("BuildOptionsSelectionPage"); //$NON-NLS-1$
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    51
		setTitle(Messages.getString("BuildOptionsSelectionPage.Title")); //$NON-NLS-1$
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    52
		setDescription(Messages.getString("BuildOptionsSelectionPage.Description")); //$NON-NLS-1$
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    53
	}
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    54
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    55
	/*
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    56
	 * (non-Javadoc)
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    57
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    58
	 */
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    59
	public void createControl(Composite parent) {
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    60
		final Composite composite = new Composite(parent, SWT.NULL);
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    61
        composite.setLayout(new GridLayout(1, false));
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    62
        composite.setLayoutData(new GridData());
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    63
		setControl(composite);
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    64
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    65
		Group optionsGroup = new Group(composite, SWT.NONE);
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    66
		GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    67
		GridLayout gridLayout = new GridLayout();
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    68
		gridLayout.numColumns = 2;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    69
		gridLayout.marginHeight = 5;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    70
		gridLayout.marginWidth = 5;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    71
		gridLayout.makeColumnsEqualWidth= true;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    72
		optionsGroup.setLayoutData(gridData);
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    73
		optionsGroup.setLayout(gridLayout);
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    74
		optionsGroup.setText(Messages.getString("BuildOptionsSelectionPage.OptionsGroupLabel"));
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    75
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    76
		fDisableBuildButton = new Button(optionsGroup, SWT.RADIO);
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    77
		fDisableBuildButton.setText(Messages.getString("BuildOptionsSelectionPage.DisableButtonLabel")); //$NON-NLS-1$
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    78
		fDisableBuildButton.setToolTipText(Messages.getString("BuildOptionsSelectionPage.DisableButtonToolTip")); //$NON-NLS-1$
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    79
		new Label(optionsGroup, SWT.NONE);
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    80
		fEnableBuildButton = new Button(optionsGroup, SWT.RADIO);
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    81
		fEnableBuildButton.setText(Messages.getString("BuildOptionsSelectionPage.EnableButtonLabel")); //$NON-NLS-1$
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    82
		fEnableBuildButton.setToolTipText(Messages.getString("BuildOptionsSelectionPage.EnableButtonToolTip")); //$NON-NLS-1$
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    83
		new Label(optionsGroup, SWT.NONE);
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    84
		fWorkspaceSettingsButton = new Button(optionsGroup, SWT.RADIO);
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    85
		fWorkspaceSettingsButton.setText(Messages.getString("BuildOptionsSelectionPage.WorkspaceSettingsButtonLabel")); //$NON-NLS-1$
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    86
		fWorkspaceSettingsButton.setToolTipText(Messages.getString("BuildOptionsSelectionPage.WorkspaceSettingsButtonToolTip")); //$NON-NLS-1$
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    87
		
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    88
		fWorkpsaceSettingsLink = new Link(optionsGroup, SWT.NONE);
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    89
		fWorkpsaceSettingsLink.setText(Messages.getString("BuildOptionsSelectionPage.WorkspaceSettingsLinkLabel")); //$NON-NLS-1$
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    90
		fWorkpsaceSettingsLink.addSelectionListener(new SelectionAdapter() {
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    91
			public void widgetSelected(SelectionEvent e) {
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    92
				PreferencesUtil.createPreferenceDialogOn(
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    93
						composite.getShell(), 
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    94
						Messages.getString("BuildOptionsSelectionPage.WorkspaceSettingsPageID"), //$NON-NLS-1$
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    95
						null, 
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    96
						null).open();
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    97
			}
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    98
		});
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
    99
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   100
		setDefaults();
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   101
	}
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   102
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   103
	/*
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   104
	 * (non-Javadoc)
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   105
	 * @see org.eclipse.jface.dialogs.DialogPage#performHelp()
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   106
	 */
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   107
	public void performHelp() {
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   108
		PlatformUI.getWorkbench().getHelpSystem().displayHelp(LaunchWizardHelpIds.BUILD_OPTIONS_SELECTION_PAGE);
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   109
	}
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   110
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   111
    /**
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   112
     * Initialize the default values for this page
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   113
     */
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   114
    public void setDefaults() {
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   115
    	fWorkspaceSettingsButton.setSelection(true);
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   116
    }
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   117
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   118
	/**
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   119
	 * Copy build option value to the given launch configuration
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   120
	 * @param config - launch configuration provided by caller
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   121
	 */
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   122
    public void updateConfiguration(ILaunchConfigurationWorkingCopy config) {
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   123
		int buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   124
		if (fDisableBuildButton.getSelection()) {
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   125
			buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   126
		} else if (fEnableBuildButton.getSelection()) {
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   127
			buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_ENABLED;
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   128
		}
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   129
		config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, buildBeforeLaunchValue);
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   130
    }
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   131
c2533fd23253 Fix for Bug 8513.
stechong
parents:
diff changeset
   132
}