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