14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 package com.nokia.carbide.cpp.internal.project.ui.sharedui; |
17 package com.nokia.carbide.cpp.internal.project.ui.sharedui; |
18 |
18 |
|
19 import org.eclipse.core.runtime.IStatus; |
|
20 import org.eclipse.core.runtime.Status; |
19 import org.eclipse.jface.dialogs.IDialogSettings; |
21 import org.eclipse.jface.dialogs.IDialogSettings; |
20 import org.eclipse.swt.SWT; |
22 import org.eclipse.swt.SWT; |
21 import org.eclipse.swt.events.SelectionEvent; |
23 import org.eclipse.swt.events.SelectionEvent; |
22 import org.eclipse.swt.events.SelectionListener; |
24 import org.eclipse.swt.events.SelectionListener; |
23 import org.eclipse.swt.layout.GridData; |
25 import org.eclipse.swt.layout.GridData; |
24 import org.eclipse.swt.layout.GridLayout; |
26 import org.eclipse.swt.layout.GridLayout; |
25 import org.eclipse.swt.widgets.Combo; |
27 import org.eclipse.swt.widgets.Combo; |
26 import org.eclipse.swt.widgets.Composite; |
28 import org.eclipse.swt.widgets.Composite; |
27 import org.eclipse.swt.widgets.Label; |
29 import org.eclipse.swt.widgets.Label; |
28 |
30 |
|
31 import com.nokia.carbide.cpp.internal.api.sdk.SBSv2Utils; |
29 import com.nokia.carbide.cpp.internal.project.ui.Messages; |
32 import com.nokia.carbide.cpp.internal.project.ui.Messages; |
|
33 import com.nokia.carbide.cpp.internal.project.ui.ProjectUIPlugin; |
30 import com.nokia.carbide.cpp.sdk.ui.shared.BuildTargetsPage; |
34 import com.nokia.carbide.cpp.sdk.ui.shared.BuildTargetsPage; |
31 |
35 |
32 public class BuilderSelectionComposite extends Composite { |
36 public class BuilderSelectionComposite extends Composite { |
33 |
37 |
34 private static final String LAST_BUILDER_STORE = "NewProjectPage.LAST_BUILDER_STORE"; //$NON-NLS-1$ |
38 private static final String LAST_BUILDER_STORE = "NewProjectPage.LAST_BUILDER_STORE"; //$NON-NLS-1$ |
58 builderCombo.setData(".uid", "builderCombo"); //$NON-NLS-1$ //$NON-NLS-2$ |
62 builderCombo.setData(".uid", "builderCombo"); //$NON-NLS-1$ //$NON-NLS-2$ |
59 builderCombo.add(Messages.getString("NewProjectPage.sbsv1")); //$NON-NLS-1$ |
63 builderCombo.add(Messages.getString("NewProjectPage.sbsv1")); //$NON-NLS-1$ |
60 builderCombo.add(Messages.getString("NewProjectPage.sbsv2")); //$NON-NLS-1$ |
64 builderCombo.add(Messages.getString("NewProjectPage.sbsv2")); //$NON-NLS-1$ |
61 builderCombo.setData(".uid", "builderCombo"); //$NON-NLS-1$ //$NON-NLS-2$ |
65 builderCombo.setData(".uid", "builderCombo"); //$NON-NLS-1$ //$NON-NLS-2$ |
62 builderCombo.select(0); |
66 builderCombo.select(0); |
63 builderCombo.addSelectionListener(new SelectionListener() { |
67 // builderCombo.addSelectionListener(new SelectionListener() { |
|
68 // |
|
69 // public void widgetDefaultSelected(SelectionEvent e) { |
|
70 // widgetSelected(e); |
|
71 // } |
|
72 // |
|
73 // public void widgetSelected(SelectionEvent e) { |
|
74 // validatePage(); |
|
75 // } |
|
76 // |
|
77 // }); |
|
78 } |
64 |
79 |
65 public void widgetDefaultSelected(SelectionEvent e) { |
80 /** |
66 widgetSelected(e); |
81 * Validate the builder selection. Implementers of this client should |
|
82 * listen for changes on the builder combo via {@link #getBuilderCombo()} |
|
83 * @return null for no error, otherwise a string for the error message |
|
84 */ |
|
85 public String validatePage() { |
|
86 useSBSv2Builder = false; |
|
87 if (builderCombo != null && builderCombo.getSelectionIndex() == 1) { |
|
88 |
|
89 // if SBSv2 is selected, make sure SBS_HOME is defined |
|
90 if (SBSv2Utils.getSBSBinDirectory() == null){ |
|
91 return "SBS_HOME environment variable is not defined. Carbide needs this variable to find the base SBS install."; |
67 } |
92 } |
68 |
93 |
69 public void widgetSelected(SelectionEvent e) { |
|
70 validatePage(); |
|
71 } |
|
72 |
|
73 }); |
|
74 } |
|
75 |
|
76 public boolean validatePage() { |
|
77 useSBSv2Builder = false; |
|
78 if (builderCombo != null && builderCombo.getSelectionIndex() == 1) { |
|
79 useSBSv2Builder = true; |
94 useSBSv2Builder = true; |
80 } |
95 } |
81 |
96 |
82 getShell().setData(BuildTargetsPage.SBSV2BUILDER, new Boolean(useSBSv2Builder)); |
97 getShell().setData(BuildTargetsPage.SBSV2BUILDER, new Boolean(useSBSv2Builder)); |
83 |
98 |
84 return true; |
99 return null; |
85 } |
100 } |
86 |
101 |
87 public void saveDialogSettings(IDialogSettings settings) { |
102 public void saveDialogSettings(IDialogSettings settings) { |
88 if (settings != null) { |
103 if (settings != null) { |
89 // remember their builder selection |
104 // remember their builder selection |
90 if (builderCombo != null) { |
105 if (builderCombo != null) { |
91 settings.put(LAST_BUILDER_STORE, builderCombo.getSelectionIndex()); |
106 settings.put(LAST_BUILDER_STORE, builderCombo.getSelectionIndex()); |