mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-31 20:52:13 +01:00
Use SketchCode.isPrimary()
in more places
This should be more reliable than comparing filenames or assuming the primary file is always at index 0.
This commit is contained in:
parent
dd5c1787fd
commit
3d573a7e86
@ -2016,7 +2016,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SketchCode current = getCurrentTab().getSketchCode();
|
SketchCode current = getCurrentTab().getSketchCode();
|
||||||
if (sketch.getName().equals(current.getPrettyName())) {
|
if (current.isPrimary()) {
|
||||||
setTitle(I18n.format(tr("{0} | Arduino {1}"), sketch.getName(),
|
setTitle(I18n.format(tr("{0} | Arduino {1}"), sketch.getName(),
|
||||||
BaseNoGui.VERSION_NAME_LONG));
|
BaseNoGui.VERSION_NAME_LONG));
|
||||||
} else {
|
} else {
|
||||||
|
@ -181,7 +181,7 @@ public class SketchController {
|
|||||||
// Don't let the user create the main tab as a .java file instead of .pde
|
// Don't let the user create the main tab as a .java file instead of .pde
|
||||||
if (!isDefaultExtension(newExtension)) {
|
if (!isDefaultExtension(newExtension)) {
|
||||||
if (renamingCode) { // If creating a new tab, don't show this error
|
if (renamingCode) { // If creating a new tab, don't show this error
|
||||||
if (current == sketch.getCode(0)) { // If this is the main tab, disallow
|
if (current.isPrimary()) { // If this is the main tab, disallow
|
||||||
Base.showWarning(tr("Problem with rename"),
|
Base.showWarning(tr("Problem with rename"),
|
||||||
tr("The main file can't use an extension.\n" +
|
tr("The main file can't use an extension.\n" +
|
||||||
"(It may be time for your to graduate to a\n" +
|
"(It may be time for your to graduate to a\n" +
|
||||||
@ -572,9 +572,8 @@ public class SketchController {
|
|||||||
// make sure there doesn't exist a .cpp file with that name already
|
// make sure there doesn't exist a .cpp file with that name already
|
||||||
// but ignore this situation for the first tab, since it's probably being
|
// but ignore this situation for the first tab, since it's probably being
|
||||||
// resaved (with the same name) to another location/folder.
|
// resaved (with the same name) to another location/folder.
|
||||||
for (int i = 1; i < sketch.getCodeCount(); i++) {
|
for (SketchCode code : sketch.getCodes()) {
|
||||||
SketchCode code = sketch.getCode(i);
|
if (!code.isPrimary() && newName.equalsIgnoreCase(code.getPrettyName())) {
|
||||||
if (newName.equalsIgnoreCase(code.getPrettyName())) {
|
|
||||||
Base.showMessage(tr("Error"),
|
Base.showMessage(tr("Error"),
|
||||||
I18n.format(tr("You can't save the sketch as \"{0}\"\n" +
|
I18n.format(tr("You can't save the sketch as \"{0}\"\n" +
|
||||||
"because the sketch already has a file with that name."), newName
|
"because the sketch already has a file with that name."), newName
|
||||||
@ -619,7 +618,7 @@ public class SketchController {
|
|||||||
|
|
||||||
// save the other tabs to their new location
|
// save the other tabs to their new location
|
||||||
for (SketchCode code : sketch.getCodes()) {
|
for (SketchCode code : sketch.getCodes()) {
|
||||||
if (sketch.indexOfCode(code) == 0) continue;
|
if (code.isPrimary()) continue;
|
||||||
File newFile = new File(newFolder, code.getFileName());
|
File newFile = new File(newFolder, code.getFileName());
|
||||||
code.saveAs(newFile);
|
code.saveAs(newFile);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user