String[] argumentNames = new String[argumentsList.size()];
Iterator arguments = argumentsList.iterator();
int index = 0;
while (arguments.hasNext()) {
Argument argument = (Argument) arguments.next();
argumentNames[index++] = argument.getName();
}
Query query = new Query();
query.addChoice("delete", "Argument to delete", argumentNames,
null, false);
ComponentDialog dialog = new ComponentDialog(_owner,
"Delete a argument for " + _target.getFullName(), query,
null);
// If the OK button was pressed, then queue a mutation
// to delete the argument.
if (dialog.buttonPressed().equals("OK")) {
String argumentName = query.getStringValue("delete");
if (argumentName != null) {
Argument argument = _target.getArgument(argumentName);
if (argument != null) {
try {
_target.removeArgument(argument);
} catch (Exception e) {
MessageHandler.error("Unable to remove argument '"
+ argument + "'.", e);
}
// The context for the MoML should be the first
// container above this port in the hierarchy
// that defers its MoML definition, or the
// immediate parent if there is none.
NamedObj container = argument.getContainer();
String moml = "<deleteProperty name=\""
+ argument.getName() + "\"/>\n";
ChangeRequest request = new MoMLChangeRequest(this,
container, moml);
container.addChangeListener(this);
container.requestChange(request);