* @param object The object to configure.
* @param parent The parent window, or null if there is none.
*/
public void createEditor(NamedObj object, Frame parent) {
try {
FileParameter docAttribute = null;
if (!(parent instanceof TableauFrame)) {
throw new InternalErrorException("Frame \"" + parent
+ "\" is not a TableauFrame");
}
Configuration configuration = ((TableauFrame) parent)
.getConfiguration();
NamedObj documentedObject = object;
while (documentedObject != null) {
docAttribute = (FileParameter) documentedObject
.getAttribute("_documentation", FileParameter.class);
if (docAttribute != null) {
break;
}
documentedObject = documentedObject.getContainer();
}
if (docAttribute != null) {
URL doc = MoMLApplication.specToURL(docAttribute
.getExpression());
configuration.openModel(doc, doc, doc.toExternalForm());
} else {
NamedObj container = object.getContainer();
if (container == null) {
container = object;
}
JFileChooser fileDialog = new JFileChooser();
fileDialog.setDialogTitle("Select a documentation file.");
//File _directory = null;
String cwd = StringUtilities.getProperty("user.dir");
if (cwd != null) {
fileDialog.setCurrentDirectory(new File(cwd));
}
if (fileDialog.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION) {
// FIXME: why is this ignored?
//_directory = fileDialog.getCurrentDirectory();
String fileName = fileDialog.getSelectedFile()
.getAbsolutePath();
docAttribute = new FileParameter(container,
"_documentation");
docAttribute.setExpression(fileName);
}
}
} catch (Throwable throwable) {
throw new InternalErrorException(object, throwable,
"Cannot access Documentation");