Go to file
Matthijs Kooijman 72f815bcf9 Refactor file adding and renaming, and save as handling
This commits replaces a significant part of the code handling these
features. A lot of responsibilities are moved from SketchController to
Sketch, though the code involved is rewritten mostly.

Most of the handling now happens inside Sketch, including various checks
against the new filename. Basically SketchController processes the user
input to decide what needs to be done, and Sketch checks if it can be
done and does it.

If problems occur, an IOException is thrown, using a translated error
message that is shown by SketchController as-is. This might not be the
best way to transfer error messages (regular IOExceptions might contain
less-friendly messages), so this might need further improvement later.

In addition to moving around code and responsibilities, this code also
changes behaviour in some places:
 - Because Sketch and SketchFile are now in control of renames and
   saves, they can update their internal state after a rename. This
   removes the need for reloading the entire sketch after a rename or
   save as and allows `Editor.handleOpenUnchecked()` to be removed.
 - When renaming the entire sketch, all files used to be saved before
   renaming, since the sketch would be re-opened after renaming. Since
   the re-opening no longer happens, there is no longer a need to save
   the sketch, so any unsaved changes remain unsaved in the editor after
   renaming the sketch.
 - When renaming or adding new files, duplicate filenames are detected.
   Initially, this happened case sensitively, but it was later changed to
   use case insensitive matching to prevent problems on Windows (where
   filenames cannot differ in just case). To prevent complexity, this
   did not distinguish between systems. In commit 5fbf9621f6 (Sketch
   rename: allowig a case change rename if NOT on windows), the
   intention was to only do case insensitive checking on Windows, but it
   effectively disabled all checking on other systems, making the check
   not catch duplicate filenames at all.

   With this commit, all these checks are done using `File.equals()`
   instead of comparing strings, which is already aware of the case
   sensitivity of the platform and should act accordingly.
 - Some error messages were changed.
 - When adding a file, an empty file is not created directly, but only a
   SketchFile and EditorTab is added. When the sketch is saved, the file
   is created.
 - When importing a file that already exists (thus overwriting it),
   instead of replacing the SketchFile instance, this just lets the
   EditorTab reload its contents. This was broken since the introduction
   of EditorTab. The file would be replaced, but not this was not
   reflected in the editor, which is now fixed. This change allows
   `Sketch.replaceFile()` to be removed.
 - When importing a file that does not exist yet (thus adding it), a tab
   is now also added for it (in addition to a SketchFile). This was
   broken since the introduction of EditorTab, and would result in the
   file being added, but not shown in the editor.

This commit adds a `Sketch.renameFileTo()` method, to rename a single
file within the sketch. It would be better to integrate its contents
into `Sketch.renameTo()`, but that does not have access to the `Sketch`
instance it is contained in. This will be changed in a future commit.
2016-08-26 16:42:44 +02:00
.settings Update eclipse java-formatter settings 2015-03-27 14:51:11 +01:00
app Refactor file adding and renaming, and save as handling 2016-08-26 16:42:44 +02:00
arduino-core Refactor file adding and renaming, and save as handling 2016-08-26 16:42:44 +02:00
build Merge branch 'patch-1' of https://github.com/dagwieers/Arduino-1 2016-08-22 14:46:10 +02:00
hardware Update SoftwareSerialExample.ino 2016-08-14 19:14:53 -04:00
libraries Stepper: update version to 1.1.3 2016-03-08 15:37:18 +01:00
.classpath Installing tools from packager (eg: arduino) in packager folder, thus avoiding 2015-11-20 17:15:53 +01:00
.gitignore Update avr-gcc to 4.9.2 and avrdude to 6.3 2016-07-25 12:34:57 +02:00
.project Fix eclipse project files 2012-01-11 14:18:48 +01:00
README.md Fix typo in readme 2016-03-02 17:54:54 +01:00
examples_formatter.conf Serial plotter: added comment to AnalogReadSerial. Fixes #3451 2015-07-06 15:27:07 +02:00
format.every.sketch.sh Examples: mass code format. See example_formatter.conf 2015-07-06 15:19:05 +02:00
lib_sync Added lib_sync, utility script 2015-04-23 17:46:20 +02:00
license.txt adding LGPL (a bit late, whoops). 2007-10-12 01:58:48 +00:00

README.md

Arduino

Installation

Detailed instructions are in reference/Guide_Windows.html and reference/Guide_MacOSX.html. For Linux, see the Arduino playground: http://www.arduino.cc/playground/Learning/Linux

Credits

Arduino is an open source project, supported by many.

The Arduino team is composed of Massimo Banzi, David Cuartielles, Tom Igoe and David A. Mellis.

Arduino uses GNU avr-gcc toolchain, GCC ARM Embedded toolchain, avr-libc, avrdude, bossac, openOCD and code from Processing and Wiring.

Icon and about image designed by ToDo