3
3
import java .io .File ;
4
4
import java .io .IOException ;
5
5
6
- import org .eclipse .cdt .core .settings .model .ICConfigurationDescription ;
7
6
import org .eclipse .core .resources .IProject ;
8
7
import org .eclipse .core .runtime .CoreException ;
9
8
import org .eclipse .core .runtime .IPath ;
13
12
import org .eclipse .jface .resource .ImageDescriptor ;
14
13
import org .eclipse .jface .wizard .WizardPage ;
15
14
import org .eclipse .swt .SWT ;
16
- import org .eclipse .swt .layout .GridData ;
17
15
import org .eclipse .swt .layout .GridLayout ;
18
16
import org .eclipse .swt .widgets .Button ;
19
17
import org .eclipse .swt .widgets .Composite ;
29
27
public class NewSketchWizardCodeSelectionPage extends WizardPage {
30
28
31
29
final Shell shell = new Shell ();
32
- private final int ncol = 4 ;
33
- String [] codeOptions = { Messages .ui_new_sketch_default_ino , Messages .ui_new_sketch_default_cpp ,
34
- Messages .ui_new_sketch_custom_template , Messages .ui_new_sketch_sample_sketch };
30
+ String [] codeOptions = { Messages .ui_new_sketch_default_ino , Messages .ui_new_sketch_default_cpp , Messages .ui_new_sketch_custom_template ,
31
+ Messages .ui_new_sketch_sample_sketch };
35
32
private static final int defaultIno = 0 ;
36
33
private static final int defaultCPP = 1 ;
37
34
private static final int CustomTemplate = 2 ;
@@ -70,18 +67,11 @@ public void createControl(Composite parent) {
70
67
71
68
Composite composite = new Composite (parent , SWT .NULL );
72
69
this .mParentComposite = composite ;
73
- GridLayout theGridLayout ; // references the layout
74
- GridData theGriddata ; // references a grid
75
70
76
- //
77
- // create the grid layout and add it to the composite
78
- //
79
- theGridLayout = new GridLayout ();
80
- theGridLayout .numColumns = this .ncol ; // 4 columns
71
+ GridLayout theGridLayout = new GridLayout ();
72
+ theGridLayout .numColumns = 4 ;
81
73
composite .setLayout (theGridLayout );
82
- //
83
- // check box Use default
84
- //
74
+
85
75
Listener comboListener = new Listener () {
86
76
87
77
@ Override
@@ -91,19 +81,20 @@ public void handleEvent(Event event) {
91
81
92
82
}
93
83
};
94
- this .mCodeSourceOptionsCombo = new LabelCombo (composite , Messages .ui_new_sketch_selecy_code , this .ncol ,
95
- Const .EMPTY_STRING , true );
84
+ this .mCodeSourceOptionsCombo = new LabelCombo (composite , Messages .ui_new_sketch_selecy_code , 4 , Const .EMPTY_STRING , true );
96
85
this .mCodeSourceOptionsCombo .addListener (comboListener );
97
86
98
87
this .mCodeSourceOptionsCombo .setItems (this .codeOptions );
99
88
100
89
this .mTemplateFolderEditor = new DirectoryFieldEditor ("temp1" , Messages .ui_new_sketch_custom_template_location , //$NON-NLS-1$
101
90
composite );
102
- this .mExampleEditor = new SampleSelector (composite , SWT .NONE ,
103
- Messages .ui_new_sketch_select_example_code );
104
- // GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
105
- // gd.horizontalSpan = ncol;
106
- // mExampleEditor.setLayoutData(gd);
91
+
92
+ this .mExampleEditor = new SampleSelector (composite , SWT .FILL , Messages .ui_new_sketch_select_example_code , 4 );
93
+ // GridData theGriddata = new GridData();
94
+ // theGriddata.horizontalSpan = 4;// (ncol - 1);
95
+ // theGriddata.horizontalAlignment = SWT.FILL;
96
+ // this.mExampleEditor.setLayoutData(theGriddata);
97
+
107
98
this .mExampleEditor .addchangeListener (new Listener () {
108
99
109
100
@ Override
@@ -118,12 +109,6 @@ public void handleEvent(Event event) {
118
109
119
110
this .mCheckBoxUseCurrentLinkSample = new Button (composite , SWT .CHECK );
120
111
this .mCheckBoxUseCurrentLinkSample .setText (Messages .ui_new_sketch_link_to_sample_code );
121
- theGriddata = new GridData ();
122
- theGriddata .horizontalSpan = this .ncol ;
123
- theGriddata .horizontalAlignment = SWT .LEAD ;
124
- theGriddata .grabExcessHorizontalSpace = false ;
125
- this .mCheckBoxUseCurrentLinkSample .setLayoutData (theGriddata );
126
- //
127
112
128
113
//
129
114
// End of special controls
@@ -139,8 +124,7 @@ public void handleEvent(Event event) {
139
124
}
140
125
141
126
/**
142
- * @name SetControls() Enables or disables the controls based on the
143
- * Checkbox settings
127
+ * @name SetControls() Enables or disables the controls based on the Checkbox settings
144
128
*/
145
129
protected void SetControls () {
146
130
switch (this .mCodeSourceOptionsCombo .mCombo .getSelectionIndex ()) {
@@ -170,8 +154,7 @@ protected void SetControls() {
170
154
}
171
155
172
156
/**
173
- * @name validatePage() Check if the user has provided all the info to
174
- * create the project. If so enable the finish button.
157
+ * @name validatePage() Check if the user has provided all the info to create the project. If so enable the finish button.
175
158
*/
176
159
protected void validatePage () {
177
160
switch (this .mCodeSourceOptionsCombo .mCombo .getSelectionIndex ()) {
@@ -197,8 +180,7 @@ protected void validatePage() {
197
180
}
198
181
199
182
/**
200
- * @name restoreAllSelections() Restore all necessary variables into the
201
- * respective controls
183
+ * @name restoreAllSelections() Restore all necessary variables into the respective controls
202
184
*/
203
185
private void restoreAllSelections () {
204
186
//
@@ -209,14 +191,12 @@ private void restoreAllSelections() {
209
191
//
210
192
this .mTemplateFolderEditor .setStringValue (InstancePreferences .getLastTemplateFolderName ());
211
193
this .mCodeSourceOptionsCombo .mCombo .select (InstancePreferences .getLastUsedDefaultSketchSelection ());
212
- this .mExampleEditor .setLastUsedExamples ();
213
194
}
214
195
215
196
public void createFiles (IProject project , IProgressMonitor monitor ) throws CoreException {
216
197
217
198
InstancePreferences .setLastTemplateFolderName (this .mTemplateFolderEditor .getStringValue ());
218
- InstancePreferences
219
- .setLastUsedDefaultSketchSelection (this .mCodeSourceOptionsCombo .mCombo .getSelectionIndex ());
199
+ InstancePreferences .setLastUsedDefaultSketchSelection (this .mCodeSourceOptionsCombo .mCombo .getSelectionIndex ());
220
200
this .mExampleEditor .saveLastUsedExamples ();
221
201
222
202
String Include = "Arduino.h" ; //$NON-NLS-1$
@@ -245,8 +225,7 @@ public void createFiles(IProject project, IProgressMonitor monitor) throws CoreE
245
225
Stream .openContentStream (project .getName (), Include , inoFile .toString (), true ), monitor );
246
226
} else {
247
227
Helpers .addFileToProject (project , new Path (project .getName () + ".cpp" ), //$NON-NLS-1$
248
- Stream .openContentStream (project .getName (), Include , cppTemplateFile .toString (), true ),
249
- monitor );
228
+ Stream .openContentStream (project .getName (), Include , cppTemplateFile .toString (), true ), monitor );
250
229
Helpers .addFileToProject (project , new Path (project .getName () + ".h" ), //$NON-NLS-1$
251
230
Stream .openContentStream (project .getName (), Include , hTemplateFile .toString (), true ), monitor );
252
231
}
@@ -272,21 +251,4 @@ public void AddAllExamples() {
272
251
273
252
}
274
253
275
- public void importLibraries (IProject project , ICConfigurationDescription configurationDescription ) {
276
- switch (this .mCodeSourceOptionsCombo .mCombo .getSelectionIndex ()) {
277
- case defaultIno :
278
- case defaultCPP :
279
- case CustomTemplate :
280
- // no need to attach libraries here
281
- break ;
282
- case sample :
283
- this .mExampleEditor .importSelectedLibraries (project , configurationDescription );
284
- break ;
285
- default :
286
-
287
- break ;
288
- }
289
-
290
- }
291
-
292
254
}
0 commit comments