* @param query The query into which to add the entry.
* @exception IllegalActionException If thrown when accessing parameters
* specifying whether files or directories should be listed.
*/
public void addEntry(PtolemyQuery query) throws IllegalActionException {
Settable container = (Settable) getContainer();
String name = container.getName();
String defaultValue = container.getExpression();
defaultValue = container.getExpression();
URI modelURI = URIAttribute.getModelURI(this);
File directory = null;
if (modelURI != null) {
if (modelURI.getScheme().equals("file")) {
File modelFile = new File(modelURI);
directory = modelFile.getParentFile();
}
}
// Check to see whether the attribute being configured
// specifies whether files or directories should be listed.
// By default, only files are selectable.
boolean allowFiles = true;
boolean allowDirectories = false;
if (container instanceof NamedObj) {
Parameter marker = (Parameter) ((NamedObj) container).getAttribute(
"allowFiles", Parameter.class);
if (marker != null) {
Token value = marker.getToken();
if (value instanceof BooleanToken) {
allowFiles = ((BooleanToken) value).booleanValue();
}
}
marker = (Parameter) ((NamedObj) container).getAttribute(
"allowDirectories", Parameter.class);
if (marker != null) {
Token value = marker.getToken();
if (value instanceof BooleanToken) {
allowDirectories = ((BooleanToken) value).booleanValue();
}
}
}
// FIXME: What to do when neither files nor directories are allowed?
if (!allowFiles && !allowDirectories) {
// The given attribute will not have a query in the dialog.
return;
}
query.addFileChooser(name, container.getDisplayName(), defaultValue,
modelURI, directory, allowFiles, allowDirectories, PtolemyQuery
.preferredBackgroundColor(container), PtolemyQuery
.preferredForegroundColor(container));
query.attachParameter(container, name);
}