Skip to content

Commit 9ab0ea6

Browse files
author
Federico Fissore
committed
Sketch: some code cleanup
1 parent 22e9d25 commit 9ab0ea6

File tree

1 file changed

+11
-45
lines changed

1 file changed

+11
-45
lines changed

app/src/processing/app/Sketch.java

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,16 @@
4949
public class Sketch {
5050
static private File tempBuildFolder;
5151

52-
private Editor editor;
52+
private final Editor editor;
5353

5454
/** true if any of the files have been modified. */
5555
private boolean modified;
5656

5757
private SketchCodeDocument current;
5858
private int currentIndex;
5959

60-
private SketchData data;
60+
private final SketchData data;
6161

62-
/** Class name for the PApplet, as determined by the preprocessor. */
63-
private String appletClassName;
64-
6562
/**
6663
* path is location of the main .pde file, because this is also
6764
* simplest to use when opening the file from the finder/explorer.
@@ -126,7 +123,7 @@ protected void load(boolean forceUpdate) throws IOException {
126123
}
127124

128125

129-
boolean renamingCode;
126+
private boolean renamingCode;
130127

131128
/**
132129
* Handler for the New Code menu option.
@@ -523,7 +520,7 @@ public void setModified(boolean state) {
523520
}
524521

525522

526-
protected void calcModified() {
523+
private void calcModified() {
527524
modified = false;
528525
for (SketchCode code : data.getCodes()) {
529526
if (code.isModified()) {
@@ -615,7 +612,7 @@ public boolean accept(File dir, String name) {
615612
}
616613

617614

618-
protected boolean renameCodeToInoExtension(File pdeFile) {
615+
private boolean renameCodeToInoExtension(File pdeFile) {
619616
for (SketchCode c : data.getCodes()) {
620617
if (!c.getFile().equals(pdeFile))
621618
continue;
@@ -640,9 +637,6 @@ protected boolean renameCodeToInoExtension(File pdeFile) {
640637
* because they can cause trouble.
641638
*/
642639
protected boolean saveAs() throws IOException {
643-
String newParentDir = null;
644-
String newName = null;
645-
646640
// get new name for folder
647641
FileDialog fd = new FileDialog(editor, _("Save sketch folder as..."), FileDialog.SAVE);
648642
if (isReadOnly() || isUntitled()) {
@@ -658,8 +652,8 @@ protected boolean saveAs() throws IOException {
658652
fd.setFile(oldName);
659653

660654
fd.setVisible(true);
661-
newParentDir = fd.getDirectory();
662-
newName = fd.getFile();
655+
String newParentDir = fd.getDirectory();
656+
String newName = fd.getFile();
663657

664658
// user canceled selection
665659
if (newName == null) return false;
@@ -960,10 +954,10 @@ public void importLibrary(File jarPath) throws IOException {
960954
// could also scan the text in the file to see if each import
961955
// statement is already in there, but if the user has the import
962956
// commented out, then this will be a problem.
963-
StringBuffer buffer = new StringBuffer();
964-
for (int i = 0; i < list.length; i++) {
957+
StringBuilder buffer = new StringBuilder();
958+
for (String aList : list) {
965959
buffer.append("#include <");
966-
buffer.append(list[i]);
960+
buffer.append(aList);
967961
buffer.append(">\n");
968962
}
969963
buffer.append('\n');
@@ -1240,29 +1234,6 @@ protected boolean upload(String buildPath, String suggestedClassName, boolean us
12401234
return success;
12411235
}
12421236

1243-
1244-
public boolean exportApplicationPrompt() throws IOException, RunnerException {
1245-
return false;
1246-
}
1247-
1248-
1249-
/**
1250-
* Export to application via GUI.
1251-
*/
1252-
protected boolean exportApplication() throws IOException, RunnerException {
1253-
return false;
1254-
}
1255-
1256-
1257-
/**
1258-
* Export to application without GUI.
1259-
*/
1260-
public boolean exportApplication(String destPath,
1261-
int exportPlatform) throws IOException, RunnerException {
1262-
return false;
1263-
}
1264-
1265-
12661237
/**
12671238
* Make sure the sketch hasn't been moved or deleted by some
12681239
* nefarious user. If they did, try to re-create it and save.
@@ -1361,7 +1332,7 @@ public String getDefaultExtension() {
13611332
return data.getDefaultExtension();
13621333
}
13631334

1364-
static private List<String> hiddenExtensions = Arrays.asList("ino", "pde");
1335+
static private final List<String> hiddenExtensions = Arrays.asList("ino", "pde");
13651336

13661337
public List<String> getHiddenExtensions() {
13671338
return hiddenExtensions;
@@ -1457,11 +1428,6 @@ public boolean isUntitled() {
14571428
}
14581429

14591430

1460-
public String getAppletClassName2() {
1461-
return appletClassName;
1462-
}
1463-
1464-
14651431
// .................................................................
14661432

14671433

0 commit comments

Comments
 (0)