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.layout.GridData;
|
|
30 |
import org.eclipse.swt.widgets.Button;
|
|
31 |
import org.eclipse.swt.widgets.Composite;
|
|
32 |
import org.eclipse.swt.widgets.Control;
|
|
33 |
import org.eclipse.swt.widgets.Label;
|
|
34 |
import org.eclipse.swt.widgets.Link;
|
|
35 |
import org.eclipse.swt.widgets.Shell;
|
|
36 |
import org.eclipse.ui.dialogs.PreferencesUtil;
|
|
37 |
|
|
38 |
import com.nokia.cdt.internal.debug.launch.newwizard.LaunchWizardData.EBuildBeforeLaunchOption;
|
|
39 |
|
|
40 |
/**
|
|
41 |
* This dialog allows in-depth configuration of the other settings in the launch.
|
|
42 |
* Currently this only covers the build-before-launch options.
|
|
43 |
*/
|
|
44 |
public class OtherSettingsDialog extends AbstractLaunchSettingsDialog {
|
|
45 |
|
|
46 |
private Button fDisableBuildButton;
|
|
47 |
private Button fEnableBuildButton;
|
|
48 |
private Button fWorkspaceSettingsButton;
|
|
49 |
private Link fWorkspaceSettingsLink;
|
|
50 |
|
|
51 |
protected OtherSettingsDialog(Shell shell, LaunchWizardData data) {
|
|
52 |
super(shell, data);
|
|
53 |
}
|
|
54 |
|
|
55 |
|
|
56 |
/* (non-Javadoc)
|
|
57 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
|
58 |
*/
|
|
59 |
@Override
|
|
60 |
protected Control createDialogArea(Composite parent) {
|
|
61 |
Composite composite = initDialogArea(parent,
|
969
|
62 |
Messages.getString("OtherSettingsDialog.Title"), //$NON-NLS-1$
|
956
|
63 |
LaunchWizardHelpIds.WIZARD_DIALOG_OTHER_SETTINGS);
|
|
64 |
|
969
|
65 |
String description = Messages.getString("OtherSettingsDialog.Desc1") + //$NON-NLS-1$
|
|
66 |
Messages.getString("OtherSettingsDialog.Desc2") + //$NON-NLS-1$
|
|
67 |
Messages.getString("OtherSettingsDialog.Desc3"); //$NON-NLS-1$
|
956
|
68 |
|
|
69 |
final Label label = new Label(composite, SWT.WRAP);
|
|
70 |
label.setText(description);
|
|
71 |
GridData labelData = GridDataFactory.fillDefaults().grab(true, false).create();
|
|
72 |
label.setLayoutData(labelData);
|
|
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) {
|
|
98 |
data.setBuildBeforeLaunchOption(EBuildBeforeLaunchOption.NEVER);
|
|
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) {
|
|
113 |
data.setBuildBeforeLaunchOption(EBuildBeforeLaunchOption.ALWAYS);
|
|
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) {
|
|
128 |
data.setBuildBeforeLaunchOption(EBuildBeforeLaunchOption.USE_WORKSPACE_SETTING);
|
|
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 |
|
|
150 |
switch (data.getBuildBeforeLaunch()) {
|
|
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$
|
956
|
176 |
if (data.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 |
|