1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-26 20:54:22 +01:00

Remove SketchCodeDocument

This class served no purpose anymore, so it can be removed. The
`SketchCode.getMetadata()` and `setMetaData()` methods only served to
keep track of a SketchCodeDocument instance (and were no longer used),
so these are removed too, just like some SketchCode constructors dealing
with this metadata object.
This commit is contained in:
Matthijs Kooijman 2015-12-08 15:24:47 +01:00 committed by Martino Facchin
parent d2bac8659e
commit 6c2a94ecc5
3 changed files with 2 additions and 61 deletions

View File

@ -90,11 +90,6 @@ public class Sketch {
protected void load(boolean forceUpdate) throws IOException {
data.load();
for (SketchCode code : data.getCodes()) {
if (code.getMetadata() == null)
code.setMetadata(new SketchCodeDocument(this, code));
}
// set the main file to be the current tab
if (editor != null) {
int current = editor.getCurrentTabIndex();
@ -401,7 +396,7 @@ public class Sketch {
return;
}
ensureExistence();
SketchCode code = (new SketchCodeDocument(this, newFile)).getCode();
SketchCode code = new SketchCode(newFile);
try {
editor.addTab(code, "");
} catch (IOException e) {
@ -861,7 +856,7 @@ public class Sketch {
}
if (codeExtension != null) {
SketchCode newCode = (new SketchCodeDocument(this, destFile)).getCode();
SketchCode newCode = new SketchCode(destFile);
if (replacement) {
data.replaceCode(newCode);

View File

@ -1,33 +0,0 @@
package processing.app;
import java.io.File;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
public class SketchCodeDocument {
private SketchCode code;
private Sketch sketch;
public SketchCodeDocument(Sketch sketch, SketchCode code) {
this.code = code;
this.sketch = sketch;
this.code.setMetadata(this);
}
public SketchCodeDocument(Sketch sketch, File file) {
this(sketch, new SketchCode(file));
}
public SketchCode getCode() {
return code;
}
public void setCode(SketchCode code) {
this.code = code;
}
}

View File

@ -45,8 +45,6 @@ public class SketchCode {
*/
private File file;
private Object metadata;
/**
* Interface for an in-memory storage of text file contents. This is
* intended to allow a GUI to keep modified text in memory, and allow
@ -74,16 +72,7 @@ public class SketchCode {
private TextStorage storage;
public SketchCode(File file) {
init(file, null);
}
public SketchCode(File file, Object metadata) {
init(file, metadata);
}
private void init(File file, Object metadata) {
this.file = file;
this.metadata = metadata;
}
/**
@ -244,14 +233,4 @@ public class SketchCode {
BaseNoGui.saveFile(storage.getText(), newFile);
}
public Object getMetadata() {
return metadata;
}
public void setMetadata(Object metadata) {
this.metadata = metadata;
}
}