29
29
import org .eclipse .swt .events .SelectionListener ;
30
30
import org .eclipse .swt .widgets .Button ;
31
31
import org .eclipse .swt .widgets .Composite ;
32
+ import org .eclipse .swt .widgets .MessageBox ;
32
33
import org .eclipse .ui .IWorkbench ;
33
34
import org .eclipse .ui .IWorkbenchPreferencePage ;
34
35
import org .eclipse .ui .preferences .ScopedPreferenceStore ;
35
36
36
37
/**
37
- * ArduinoPreferencePage is the class that is behind the preference page of
38
- * arduino that allows you to select the arduino path and the library path and a
39
- * option to use disable RXTX <br/>
40
- * Note that this class uses 2 technologies to change values (the flag and the
41
- * path). <br/>
38
+ * ArduinoPreferencePage is the class that is behind the preference page of arduino that allows you to select the arduino path and the library path
39
+ * and a option to use disable RXTX <br/>
40
+ * Note that this class uses 2 technologies to change values (the flag and the path). <br/>
42
41
*
43
42
*
44
43
* @author Jan Baeyens
45
44
*
46
45
*/
47
- public class ArduinoPreferencePage extends FieldEditorPreferencePage implements
48
- IWorkbenchPreferencePage {
46
+ public class ArduinoPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
49
47
50
48
private StringFieldEditor mArduinoIdeVersion ;
51
49
private DirectoryFieldEditor mArduinoIdePath ;
@@ -55,10 +53,8 @@ public class ArduinoPreferencePage extends FieldEditorPreferencePage implements
55
53
56
54
/**
57
55
* PropertyChange set the flag mIsDirty to false. <br/>
58
- * This is needed because the default PerformOK saves all fields in the
59
- * object store. Therefore I set the mIsDirty flag to true as soon as a
60
- * field gets change. Then I use this flag in the PerformOK to decide to
61
- * call the super performOK or not.
56
+ * This is needed because the default PerformOK saves all fields in the object store. Therefore I set the mIsDirty flag to true as soon as a field
57
+ * gets change. Then I use this flag in the PerformOK to decide to call the super performOK or not.
62
58
*
63
59
* @author Jan Baeyens
64
60
*/
@@ -71,8 +67,7 @@ public void propertyChange(PropertyChangeEvent event) {
71
67
public ArduinoPreferencePage () {
72
68
super (org .eclipse .jface .preference .FieldEditorPreferencePage .GRID );
73
69
setDescription ("Arduino Settings for this workspace" );
74
- setPreferenceStore (new ScopedPreferenceStore (InstanceScope .INSTANCE ,
75
- ArduinoConst .NODE_ARDUINO ));
70
+ setPreferenceStore (new ScopedPreferenceStore (InstanceScope .INSTANCE , ArduinoConst .NODE_ARDUINO ));
76
71
}
77
72
78
73
@ Override
@@ -86,10 +81,8 @@ public boolean okToLeave() {
86
81
}
87
82
88
83
/**
89
- * PerformOK is done when the end users presses OK on a preference page. The
90
- * order of the execution of the performOK is undefined. This method saves
91
- * the path variables based on the settings and removes the last used
92
- * setting.<br/>
84
+ * PerformOK is done when the end users presses OK on a preference page. The order of the execution of the performOK is undefined. This method
85
+ * saves the path variables based on the settings and removes the last used setting.<br/>
93
86
*
94
87
* @see propertyChange
95
88
*
@@ -104,6 +97,17 @@ public boolean performOk() {
104
97
return false ;
105
98
if (!mIsDirty )
106
99
return true ;
100
+ if (mArduinoIdeVersion .getStringValue ().compareTo ("1.5.2" ) > 0 ) {
101
+ String message = "The Arduino core team decided for a library specification which is hard to support. You need to make changes to you arduino libraries to make this work. See eclipse.baeyens.it/librarymadness.html for more info." ;
102
+ // MessageDialog warningDialog = new MessageDialog(null, , null, message, MessageDialog.WARNING, "OK", 0);
103
+ // warningDialog.open();
104
+
105
+ MessageBox dialog = new MessageBox (getShell (), SWT .ICON_QUESTION | SWT .OK | SWT .CANCEL );
106
+ dialog .setText ("Unsupportable Arduino IDE" );
107
+ dialog .setMessage (message );
108
+ if (dialog .open () == SWT .CANCEL )
109
+ return false ;
110
+ }
107
111
super .performOk ();
108
112
setWorkSpacePathVariables ();
109
113
// reset the previous selected values
@@ -115,12 +119,10 @@ public boolean performOk() {
115
119
}
116
120
117
121
/**
118
- * This method sets the eclipse path variables to contain the important
119
- * Arduino folders (code wise that is)
122
+ * This method sets the eclipse path variables to contain the important Arduino folders (code wise that is)
120
123
*
121
124
*
122
- * The arduino library location in the root folder (used when importing
123
- * arduino libraries) The Private library path (used when importing private
125
+ * The arduino library location in the root folder (used when importing arduino libraries) The Private library path (used when importing private
124
126
* libraries) The Arduino IDE root folder
125
127
*
126
128
*
@@ -132,23 +134,13 @@ private void setWorkSpacePathVariables() {
132
134
133
135
try {
134
136
135
- pathMan .setURIValue (
136
- ArduinoConst .WORKSPACE_PATH_VARIABLE_NAME_ARDUINO_LIB ,
137
- URIUtil .toURI (new Path (mArduinoIdePath .getStringValue ())
138
- .append (ArduinoConst .LIBRARY_PATH_SUFFIX )
139
- .toString ()));
140
- pathMan .setURIValue (
141
- ArduinoConst .WORKSPACE_PATH_VARIABLE_NAME_PRIVATE_LIB ,
142
- URIUtil .toURI (mArduinoPrivateLibPath .getStringValue ()));
143
- pathMan .setURIValue (
144
- ArduinoConst .WORKSPACE_PATH_VARIABLE_NAME_ARDUINO ,
145
- URIUtil .toURI (mArduinoIdePath .getStringValue ()));
137
+ pathMan .setURIValue (ArduinoConst .WORKSPACE_PATH_VARIABLE_NAME_ARDUINO_LIB ,
138
+ URIUtil .toURI (new Path (mArduinoIdePath .getStringValue ()).append (ArduinoConst .LIBRARY_PATH_SUFFIX ).toString ()));
139
+ pathMan .setURIValue (ArduinoConst .WORKSPACE_PATH_VARIABLE_NAME_PRIVATE_LIB , URIUtil .toURI (mArduinoPrivateLibPath .getStringValue ()));
140
+ pathMan .setURIValue (ArduinoConst .WORKSPACE_PATH_VARIABLE_NAME_ARDUINO , URIUtil .toURI (mArduinoIdePath .getStringValue ()));
146
141
} catch (CoreException e ) {
147
- Common .log (new Status (
148
- IStatus .ERROR ,
149
- ArduinoConst .CORE_PLUGIN_ID ,
150
- "Failed to create the workspace path variables. The setup will not work properly" ,
151
- e ));
142
+ Common .log (new Status (IStatus .ERROR , ArduinoConst .CORE_PLUGIN_ID ,
143
+ "Failed to create the workspace path variables. The setup will not work properly" , e ));
152
144
e .printStackTrace ();
153
145
}
154
146
}
@@ -167,25 +159,17 @@ public void init(IWorkbench workbench) {
167
159
protected void createFieldEditors () {
168
160
final Composite parent = getFieldEditorParent ();
169
161
170
- mArduinoIdePath = new MyDirectoryFieldEditor (
171
- ArduinoConst .KEY_ARDUINOPATH , "Arduino IDE path" , parent ,
172
- Common .getArduinoIdeSuffix ());
162
+ mArduinoIdePath = new MyDirectoryFieldEditor (ArduinoConst .KEY_ARDUINOPATH , "Arduino IDE path" , parent , Common .getArduinoIdeSuffix ());
173
163
174
164
addField (mArduinoIdePath );
175
- mArduinoPrivateLibPath = new DirectoryFieldEditor (
176
- ArduinoConst .KEY_PRIVATE_LIBRARY_PATH , "Private Library path" ,
177
- parent );
165
+ mArduinoPrivateLibPath = new DirectoryFieldEditor (ArduinoConst .KEY_PRIVATE_LIBRARY_PATH , "Private Library path" , parent );
178
166
addField (mArduinoPrivateLibPath );
179
167
180
168
Dialog .applyDialogFont (parent );
181
169
182
- addField (new BooleanFieldEditor (
183
- ArduinoConst .KEY_RXTXDISABLED ,
184
- "Disable RXTX (disables Arduino reset during upload and the serial monitor)" ,
170
+ addField (new BooleanFieldEditor (ArduinoConst .KEY_RXTXDISABLED , "Disable RXTX (disables Arduino reset during upload and the serial monitor)" ,
185
171
parent ));
186
- mArduinoIdeVersion = new StringFieldEditor (
187
- ArduinoConst .KEY_ARDUINO_IDE_VERSION , "Arduino IDE Version" ,
188
- parent );
172
+ mArduinoIdeVersion = new StringFieldEditor (ArduinoConst .KEY_ARDUINO_IDE_VERSION , "Arduino IDE Version" , parent );
189
173
addField (mArduinoIdeVersion );
190
174
mArduinoIdeVersion .setEnabled (false , parent );
191
175
Button TestButton = new Button (parent , SWT .BUTTON1 );
@@ -206,12 +190,10 @@ public void widgetDefaultSelected(SelectionEvent e) {
206
190
}
207
191
208
192
/**
209
- * testStatus test whether the provided information is OK. Here the code
210
- * checks whether there is a hardware\arduino\board.txt file under the
193
+ * testStatus test whether the provided information is OK. Here the code checks whether there is a hardware\arduino\board.txt file under the
211
194
* provide path.
212
195
*
213
- * @return true if the provided info is OK; False if the provided info is
214
- * not OK
196
+ * @return true if the provided info is OK; False if the provided info is not OK
215
197
*
216
198
* @author Jan Baeyens
217
199
*
@@ -222,29 +204,24 @@ private boolean testStatus() {
222
204
223
205
// Validate the arduino path
224
206
Path arduinoFolder = new Path (mArduinoIdePath .getStringValue ());
225
- File arduinoBoardFile = arduinoFolder .append (
226
- ArduinoConst .LIB_VERSION_FILE ).toFile ();
207
+ File arduinoBoardFile = arduinoFolder .append (ArduinoConst .LIB_VERSION_FILE ).toFile ();
227
208
boolean isArduinoFolderValid = arduinoBoardFile .canRead ();
228
209
if (isArduinoFolderValid ) {
229
210
Path BoardFile = new Path (mArduinoIdePath .getStringValue ());
230
211
if (!BoardFile .equals (mPrefBoardFile )) {
231
212
mPrefBoardFile = BoardFile ;
232
- mArduinoIdeVersion .setStringValue (ArduinoHelpers
233
- .GetIDEVersion (BoardFile ));
213
+ mArduinoIdeVersion .setStringValue (ArduinoHelpers .GetIDEVersion (BoardFile ));
234
214
}
235
215
} else {
236
216
ErrorMessage += Seperator + "Arduino folder is not correct!" ;
237
217
Seperator = "/n" ;
238
218
}
239
219
240
220
// Validate the private lib path
241
- Path PrivateLibFolder = new Path (
242
- mArduinoPrivateLibPath .getStringValue ());
243
- boolean isArduinoPrivateLibFolderValid = PrivateLibFolder .toFile ()
244
- .canRead ();
221
+ Path PrivateLibFolder = new Path (mArduinoPrivateLibPath .getStringValue ());
222
+ boolean isArduinoPrivateLibFolderValid = PrivateLibFolder .toFile ().canRead ();
245
223
if (!isArduinoPrivateLibFolderValid ) {
246
- ErrorMessage += Seperator
247
- + "Private library folder is not correct!" ;
224
+ ErrorMessage += Seperator + "Private library folder is not correct!" ;
248
225
Seperator = "/n" ;
249
226
}
250
227
0 commit comments