author | dadubrow |
Wed, 20 Oct 2010 09:35:54 -0500 | |
changeset 2163 | f0a9f2d04d4a |
parent 1013 | 83255eb26cdb |
permissions | -rw-r--r-- |
956 | 1 |
/* |
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
package com.nokia.cdt.internal.debug.launch.newwizard; |
|
19 |
||
20 |
import org.eclipse.core.runtime.IStatus; |
|
21 |
import org.eclipse.core.runtime.Status; |
|
22 |
import org.eclipse.jface.layout.GridDataFactory; |
|
23 |
import org.eclipse.jface.layout.GridLayoutFactory; |
|
24 |
import org.eclipse.swt.SWT; |
|
25 |
import org.eclipse.swt.events.ControlAdapter; |
|
26 |
import org.eclipse.swt.events.ControlEvent; |
|
27 |
import org.eclipse.swt.events.SelectionAdapter; |
|
28 |
import org.eclipse.swt.events.SelectionEvent; |
|
29 |
import org.eclipse.swt.widgets.Button; |
|
30 |
import org.eclipse.swt.widgets.Composite; |
|
31 |
import org.eclipse.swt.widgets.Control; |
|
32 |
import org.eclipse.swt.widgets.Label; |
|
33 |
import org.eclipse.swt.widgets.Link; |
|
34 |
import org.eclipse.swt.widgets.Shell; |
|
35 |
import org.eclipse.ui.dialogs.PreferencesUtil; |
|
36 |
||
2163 | 37 |
import com.nokia.cdt.internal.debug.launch.newwizard.IOtherSettingsWizardData.EBuildBeforeLaunchOption; |
956 | 38 |
|
39 |
/** |
|
40 |
* This dialog allows in-depth configuration of the other settings in the launch. |
|
41 |
* Currently this only covers the build-before-launch options. |
|
42 |
*/ |
|
43 |
public class OtherSettingsDialog extends AbstractLaunchSettingsDialog { |
|
44 |
||
45 |
private Button fDisableBuildButton; |
|
46 |
private Button fEnableBuildButton; |
|
47 |
private Button fWorkspaceSettingsButton; |
|
48 |
private Link fWorkspaceSettingsLink; |
|
2163 | 49 |
private IOtherSettingsWizardData otherSettingsWizardData; |
956 | 50 |
|
2163 | 51 |
protected OtherSettingsDialog(Shell shell, IWizardData data) { |
956 | 52 |
super(shell, data); |
2163 | 53 |
otherSettingsWizardData = (IOtherSettingsWizardData) data; |
956 | 54 |
} |
55 |
||
56 |
||
57 |
/* (non-Javadoc) |
|
58 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
|
59 |
*/ |
|
60 |
@Override |
|
61 |
protected Control createDialogArea(Composite parent) { |
|
62 |
Composite composite = initDialogArea(parent, |
|
969 | 63 |
Messages.getString("OtherSettingsDialog.Title"), //$NON-NLS-1$ |
956 | 64 |
LaunchWizardHelpIds.WIZARD_DIALOG_OTHER_SETTINGS); |
65 |
||
969 | 66 |
String description = Messages.getString("OtherSettingsDialog.Desc1") + //$NON-NLS-1$ |
67 |
Messages.getString("OtherSettingsDialog.Desc2") + //$NON-NLS-1$ |
|
68 |
Messages.getString("OtherSettingsDialog.Desc3"); //$NON-NLS-1$ |
|
956 | 69 |
|
70 |
final Label label = new Label(composite, SWT.WRAP); |
|
71 |
label.setText(description); |
|
1011
ac82c32cc589
bug 10773 - fix initial text of finish button + tweak width of other settings dialog to wrap text
dadubrow
parents:
993
diff
changeset
|
72 |
GridDataFactory.fillDefaults().grab(true, false).hint(400, SWT.DEFAULT).applyTo(label); |
956 | 73 |
|
74 |
// spacer |
|
75 |
new Label(composite, SWT.NONE); |
|
76 |
||
77 |
final Composite radio = new Composite(composite, SWT.NONE); |
|
78 |
GridLayoutFactory.fillDefaults().numColumns(2).applyTo(radio); |
|
79 |
GridDataFactory.fillDefaults().grab(true, true).applyTo(radio); |
|
80 |
||
81 |
composite.addControlListener(new ControlAdapter() { |
|
82 |
@Override |
|
83 |
public void controlResized(ControlEvent e) { |
|
84 |
label.pack(); |
|
85 |
} |
|
86 |
}); |
|
87 |
||
88 |
fDisableBuildButton = new Button(radio, SWT.RADIO); |
|
89 |
fDisableBuildButton.setText(Messages.getString("OtherSettingsDialog.DisableButtonLabel")); //$NON-NLS-1$ |
|
90 |
fDisableBuildButton.setToolTipText(Messages.getString("OtherSettingsDialog.DisableButtonToolTip")); //$NON-NLS-1$ |
|
969 | 91 |
fDisableBuildButton.setData(UID, "OtherSettingsDialog.disableBuildButton"); //$NON-NLS-1$ |
956 | 92 |
|
93 |
GridDataFactory.fillDefaults().span(2, 1).applyTo(fDisableBuildButton); |
|
94 |
||
95 |
fDisableBuildButton.addSelectionListener(new SelectionAdapter() { |
|
96 |
@Override |
|
97 |
public void widgetSelected(SelectionEvent e) { |
|
2163 | 98 |
otherSettingsWizardData.setBuildBeforeLaunchOption(EBuildBeforeLaunchOption.NEVER); |
956 | 99 |
} |
100 |
}); |
|
101 |
||
102 |
||
103 |
fEnableBuildButton = new Button(radio, SWT.RADIO); |
|
104 |
fEnableBuildButton.setText(Messages.getString("OtherSettingsDialog.EnableButtonLabel")); //$NON-NLS-1$ |
|
105 |
fEnableBuildButton.setToolTipText(Messages.getString("OtherSettingsDialog.EnableButtonToolTip")); //$NON-NLS-1$ |
|
969 | 106 |
fEnableBuildButton.setData(UID, "OtherSettingsDialog.enableBuildButon"); //$NON-NLS-1$ |
956 | 107 |
|
108 |
GridDataFactory.fillDefaults().span(2, 1).applyTo(fEnableBuildButton); |
|
109 |
||
110 |
fEnableBuildButton.addSelectionListener(new SelectionAdapter() { |
|
111 |
@Override |
|
112 |
public void widgetSelected(SelectionEvent e) { |
|
2163 | 113 |
otherSettingsWizardData.setBuildBeforeLaunchOption(EBuildBeforeLaunchOption.ALWAYS); |
956 | 114 |
} |
115 |
}); |
|
116 |
||
117 |
||
118 |
fWorkspaceSettingsButton = new Button(radio, SWT.RADIO); |
|
119 |
fWorkspaceSettingsButton.setText(Messages.getString("OtherSettingsDialog.WorkspaceSettingsButtonLabel")); //$NON-NLS-1$ |
|
120 |
fWorkspaceSettingsButton.setToolTipText(Messages.getString("OtherSettingsDialog.WorkspaceSettingsButtonToolTip")); //$NON-NLS-1$ |
|
969 | 121 |
fWorkspaceSettingsButton.setData(UID, "OtherSettingsDialog.workspaceSettingsButton"); //$NON-NLS-1$ |
956 | 122 |
|
123 |
GridDataFactory.swtDefaults().span(1, 1).applyTo(fWorkspaceSettingsButton); |
|
124 |
||
125 |
fWorkspaceSettingsButton.addSelectionListener(new SelectionAdapter() { |
|
126 |
@Override |
|
127 |
public void widgetSelected(SelectionEvent e) { |
|
2163 | 128 |
otherSettingsWizardData.setBuildBeforeLaunchOption(EBuildBeforeLaunchOption.USE_WORKSPACE_SETTING); |
956 | 129 |
} |
130 |
}); |
|
131 |
||
132 |
||
133 |
fWorkspaceSettingsLink = new Link(radio, SWT.NONE); |
|
134 |
fWorkspaceSettingsLink.setText(Messages.getString("OtherSettingsDialog.WorkspaceSettingsLinkLabel")); //$NON-NLS-1$ |
|
969 | 135 |
fWorkspaceSettingsLink.setData(UID, "OtherSettingsDialog.workspaceSettingsLink"); //$NON-NLS-1$ |
956 | 136 |
|
137 |
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(true, false).span(1, 1).applyTo(fWorkspaceSettingsLink); |
|
138 |
||
139 |
fWorkspaceSettingsLink.addSelectionListener(new SelectionAdapter() { |
|
140 |
public void widgetSelected(SelectionEvent e) { |
|
141 |
PreferencesUtil.createPreferenceDialogOn( |
|
142 |
radio.getShell(), |
|
143 |
Messages.getString("OtherSettingsDialog.WorkspaceSettingsPageID"), //$NON-NLS-1$ |
|
144 |
null, |
|
145 |
null).open(); |
|
146 |
validate(); |
|
147 |
} |
|
148 |
}); |
|
149 |
||
2163 | 150 |
switch (otherSettingsWizardData.getBuildBeforeLaunch()) { |
956 | 151 |
case ALWAYS: |
152 |
fEnableBuildButton.setSelection(true); |
|
153 |
fEnableBuildButton.setFocus(); |
|
154 |
break; |
|
155 |
case NEVER: |
|
156 |
fDisableBuildButton.setSelection(true); |
|
157 |
fDisableBuildButton.setFocus(); |
|
158 |
break; |
|
159 |
case USE_WORKSPACE_SETTING: |
|
160 |
fWorkspaceSettingsButton.setSelection(true); |
|
161 |
fWorkspaceSettingsButton.setFocus(); |
|
162 |
break; |
|
163 |
} |
|
164 |
||
165 |
validate(); |
|
166 |
||
167 |
return radio; |
|
168 |
} |
|
169 |
||
170 |
@Override |
|
171 |
protected void validate() { |
|
172 |
IStatus status = Status.OK_STATUS; |
|
173 |
updateStatus(status); |
|
174 |
||
969 | 175 |
String wsState = ""; //$NON-NLS-1$ |
2163 | 176 |
if (otherSettingsWizardData.isWorkspaceBuildBeforeLaunch()) |
969 | 177 |
wsState = Messages.getString("OtherSettingsDialog.EnabledLabel"); //$NON-NLS-1$ |
956 | 178 |
else |
969 | 179 |
wsState = Messages.getString("OtherSettingsDialog.DisabledLabel"); //$NON-NLS-1$ |
956 | 180 |
|
181 |
fWorkspaceSettingsButton.setText( |
|
182 |
Messages.getString("OtherSettingsDialog.WorkspaceSettingsButtonLabel") + //$NON-NLS-1$ |
|
183 |
wsState); |
|
184 |
fWorkspaceSettingsButton.pack(); |
|
185 |
||
186 |
} |
|
187 |
} |
|
188 |