Implement toString to return useful GUI things
Under SWT, it's easy to simply tell GUI elements with text labels that they should keep track of an arbitrary object, but also use this separate arbitrary label for what to display in the GUI controls for things like lists. Well, that's not how JavaFX works, nor really Swing or other things. They assume you implemented the Java toString method to provide something useful. And of course since there's been no need to, these methods were unimplemented! I've made FormattedDisks and DirectoryEntrys and FileEntrys all return the most logical thing for them to return: Their names. Something I should consider here is whether ProDOS subdirectories' toStrings should explicitly append a trailing slash. They don't at the moment, but they could do. ProDOS disk names include leading and trailing slash. SWT doesn't, and it looks odd to have /VOLUME/ at the top of the tree and no other slashes in sight.
This commit is contained in:
parent
327c5dc3e7
commit
31a949f0db
|
@ -395,4 +395,12 @@ public abstract class FormattedDisk extends Disk implements DirectoryEntry {
|
|||
* Typically, the FileEntry.setFileData method should be used.
|
||||
*/
|
||||
public abstract void setFileData(FileEntry fileEntry, byte[] fileData) throws DiskFullException;
|
||||
|
||||
/**
|
||||
* Implement toString() to return disk name.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getDiskName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -503,4 +503,12 @@ public class CpmFileEntry implements FileEntry {
|
|||
}
|
||||
return allocations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement toString() to return file name.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getFilename();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -501,4 +501,12 @@ public class DosFileEntry implements FileEntry {
|
|||
public boolean canCompile() {
|
||||
return isApplesoftBasicFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement toString() to return file name.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getFilename();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -340,4 +340,12 @@ public class GutenbergFileEntry implements FileEntry {
|
|||
public boolean canCompile() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement toString() to return file name.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getFilename();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -256,4 +256,12 @@ public class NakedosFileEntry implements FileEntry {
|
|||
public boolean equals (Object o) {
|
||||
return this.getFilename().equals(((NakedosFileEntry)o).getFilename());
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement toString() to return file name.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getFilename();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -536,4 +536,12 @@ public class PascalFileEntry implements FileEntry {
|
|||
public void setFileCount(int count) {
|
||||
AppleUtil.setWordValue(fileEntry, 16, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement toString() to return file name.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getFilename();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,4 +98,12 @@ public class ProdosDirectoryEntry extends ProdosFileEntry implements DirectoryEn
|
|||
public DirectoryEntry createDirectory(String name) throws DiskFullException {
|
||||
return getDisk().createDirectory(getSubdirectoryHeader(), name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement toString() to return directory name.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getFilename();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -616,4 +616,12 @@ public class ProdosFileEntry extends ProdosCommonEntry implements FileEntry {
|
|||
public boolean canCompile() {
|
||||
return getDisk().canCompile(getFiletype());
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement toString() to return file name.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getFilename();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -328,4 +328,12 @@ public class RdosFileEntry implements FileEntry {
|
|||
public boolean canCompile() {
|
||||
return isApplesoftBasicFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement toString() to return file name.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getFilename();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue