Skip to content

Commit c192a55

Browse files
committed
trying to sync my local changes with github
1 parent 5f45dfd commit c192a55

File tree

2 files changed

+110
-155
lines changed

2 files changed

+110
-155
lines changed

it.baeyens.arduino.core/src/it/baeyens/arduino/ui/ArduinoPreferencePage.java

Lines changed: 40 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,21 @@
2929
import org.eclipse.swt.events.SelectionListener;
3030
import org.eclipse.swt.widgets.Button;
3131
import org.eclipse.swt.widgets.Composite;
32+
import org.eclipse.swt.widgets.MessageBox;
3233
import org.eclipse.ui.IWorkbench;
3334
import org.eclipse.ui.IWorkbenchPreferencePage;
3435
import org.eclipse.ui.preferences.ScopedPreferenceStore;
3536

3637
/**
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/>
4241
*
4342
*
4443
* @author Jan Baeyens
4544
*
4645
*/
47-
public class ArduinoPreferencePage extends FieldEditorPreferencePage implements
48-
IWorkbenchPreferencePage {
46+
public class ArduinoPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
4947

5048
private StringFieldEditor mArduinoIdeVersion;
5149
private DirectoryFieldEditor mArduinoIdePath;
@@ -55,10 +53,8 @@ public class ArduinoPreferencePage extends FieldEditorPreferencePage implements
5553

5654
/**
5755
* 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.
6258
*
6359
* @author Jan Baeyens
6460
*/
@@ -71,8 +67,7 @@ public void propertyChange(PropertyChangeEvent event) {
7167
public ArduinoPreferencePage() {
7268
super(org.eclipse.jface.preference.FieldEditorPreferencePage.GRID);
7369
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));
7671
}
7772

7873
@Override
@@ -86,10 +81,8 @@ public boolean okToLeave() {
8681
}
8782

8883
/**
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/>
9386
*
9487
* @see propertyChange
9588
*
@@ -104,6 +97,17 @@ public boolean performOk() {
10497
return false;
10598
if (!mIsDirty)
10699
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+
}
107111
super.performOk();
108112
setWorkSpacePathVariables();
109113
// reset the previous selected values
@@ -115,12 +119,10 @@ public boolean performOk() {
115119
}
116120

117121
/**
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)
120123
*
121124
*
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
124126
* libraries) The Arduino IDE root folder
125127
*
126128
*
@@ -132,23 +134,13 @@ private void setWorkSpacePathVariables() {
132134

133135
try {
134136

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()));
146141
} 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));
152144
e.printStackTrace();
153145
}
154146
}
@@ -167,25 +159,17 @@ public void init(IWorkbench workbench) {
167159
protected void createFieldEditors() {
168160
final Composite parent = getFieldEditorParent();
169161

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());
173163

174164
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);
178166
addField(mArduinoPrivateLibPath);
179167

180168
Dialog.applyDialogFont(parent);
181169

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)",
185171
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);
189173
addField(mArduinoIdeVersion);
190174
mArduinoIdeVersion.setEnabled(false, parent);
191175
Button TestButton = new Button(parent, SWT.BUTTON1);
@@ -206,12 +190,10 @@ public void widgetDefaultSelected(SelectionEvent e) {
206190
}
207191

208192
/**
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
211194
* provide path.
212195
*
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
215197
*
216198
* @author Jan Baeyens
217199
*
@@ -222,29 +204,24 @@ private boolean testStatus() {
222204

223205
// Validate the arduino path
224206
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();
227208
boolean isArduinoFolderValid = arduinoBoardFile.canRead();
228209
if (isArduinoFolderValid) {
229210
Path BoardFile = new Path(mArduinoIdePath.getStringValue());
230211
if (!BoardFile.equals(mPrefBoardFile)) {
231212
mPrefBoardFile = BoardFile;
232-
mArduinoIdeVersion.setStringValue(ArduinoHelpers
233-
.GetIDEVersion(BoardFile));
213+
mArduinoIdeVersion.setStringValue(ArduinoHelpers.GetIDEVersion(BoardFile));
234214
}
235215
} else {
236216
ErrorMessage += Seperator + "Arduino folder is not correct!";
237217
Seperator = "/n";
238218
}
239219

240220
// 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();
245223
if (!isArduinoPrivateLibFolderValid) {
246-
ErrorMessage += Seperator
247-
+ "Private library folder is not correct!";
224+
ErrorMessage += Seperator + "Private library folder is not correct!";
248225
Seperator = "/n";
249226
}
250227

0 commit comments

Comments
 (0)