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:
parent
d2bac8659e
commit
6c2a94ecc5
@ -90,11 +90,6 @@ public class Sketch {
|
|||||||
protected void load(boolean forceUpdate) throws IOException {
|
protected void load(boolean forceUpdate) throws IOException {
|
||||||
data.load();
|
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
|
// set the main file to be the current tab
|
||||||
if (editor != null) {
|
if (editor != null) {
|
||||||
int current = editor.getCurrentTabIndex();
|
int current = editor.getCurrentTabIndex();
|
||||||
@ -401,7 +396,7 @@ public class Sketch {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ensureExistence();
|
ensureExistence();
|
||||||
SketchCode code = (new SketchCodeDocument(this, newFile)).getCode();
|
SketchCode code = new SketchCode(newFile);
|
||||||
try {
|
try {
|
||||||
editor.addTab(code, "");
|
editor.addTab(code, "");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -861,7 +856,7 @@ public class Sketch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (codeExtension != null) {
|
if (codeExtension != null) {
|
||||||
SketchCode newCode = (new SketchCodeDocument(this, destFile)).getCode();
|
SketchCode newCode = new SketchCode(destFile);
|
||||||
|
|
||||||
if (replacement) {
|
if (replacement) {
|
||||||
data.replaceCode(newCode);
|
data.replaceCode(newCode);
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -45,8 +45,6 @@ public class SketchCode {
|
|||||||
*/
|
*/
|
||||||
private File file;
|
private File file;
|
||||||
|
|
||||||
private Object metadata;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for an in-memory storage of text file contents. This is
|
* 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
|
* intended to allow a GUI to keep modified text in memory, and allow
|
||||||
@ -74,16 +72,7 @@ public class SketchCode {
|
|||||||
private TextStorage storage;
|
private TextStorage storage;
|
||||||
|
|
||||||
public SketchCode(File file) {
|
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.file = file;
|
||||||
this.metadata = metadata;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -244,14 +233,4 @@ public class SketchCode {
|
|||||||
|
|
||||||
BaseNoGui.saveFile(storage.getText(), newFile);
|
BaseNoGui.saveFile(storage.getText(), newFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Object getMetadata() {
|
|
||||||
return metadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setMetadata(Object metadata) {
|
|
||||||
this.metadata = metadata;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user