// still in UMLNode class
public String getDisplayName () {
String s = super.getDisplayName ();
try {
s = fileObject().getFileSystem().getStatus()
.annotateName(s, Collections.singleton(fileObject));
} catch (FileStateInvalidException e) {
// no fs, do nothing
}
return s;
}
public String getHtmlDisplayName() {
try {
FileSystem.Status stat = fileObject.getFileSystem().getStatus();
if (stat instanceof FileSystem.HtmlStatus) {
FileSystem.HtmlStatus hstat = (FileSystem.HtmlStatus) stat;
String result = hstat.annotateNameHtml (
super.getDisplayName(), Collections.singleton(fileObject));
//Make sure the super string was really modified
if (!super.getDisplayName().equals(result)) {
return result;
}
// TODO attach status listener at the FileSystem
// and on change refire PROP_DISPLAY_NAME
}
} catch (FileStateInvalidException e) {
//do nothing and fall through
}
return super.getHtmlDisplayName();
}
public java.awt.Image getIcon (int type) {
java.awt.Image img = super.getIcon (type);
try {
img = model.getFileObject().getFileSystem().getStatus()
.annotateIcon(img, type, Collections.singleton(fileObject));
} catch (FileStateInvalidException e) {
// no fs, do nothing
}
return img;
}
public java.awt.Image getOpenedIcon (int type) {
java.awt.Image img = super.getIcon (type);
try {
img = model.getFileObject().getFileSystem().getStatus()
.annotateIcon(img, type, Collections.singleton(fileObject));
} catch (FileStateInvalidException e) {
// no fs, do nothing
}
return img;
}
private void attachStatusListener() {
FileSystem fs = fileObject.getFileSystem();
FileStatusListener l = FileUtil.weakFileStatusListener(new FSL, fs)
fs.addFileStatusListener(l);
}
private class FSL implements FileStatusListener {
public void annotationChanged (FileStatusEvent ev) {
if (ev.hasChanged(fileObject)) {
if (ev.isNameChange()) {
if (refreshNameNodes == null) {
refreshNameNodes = new HashSet();
}
post |= refreshNameNodes.add(DataNode.this);
}
if (ev.isIconChange()) {
if (refreshIconNodes == null) {
refreshIconNodes = new HashSet();
}
post |= refreshIconNodes.add(DataNode.this);
}
}
}
}
}
|