left.add(buttonPanel);
// Next, put in a panel to configure the code generator.
// If the model contains an attribute with tableau
// configuration information, use that. Otherwise, make one.
GeneratorAttribute attribute = (GeneratorAttribute) model
.getAttribute(Copernicus.GENERATOR_NAME,
GeneratorAttribute.class);
if (attribute == null) {
attribute = new GeneratorAttribute(model,
Copernicus.GENERATOR_NAME);
// Read the default parameters for this model.
attribute.initialize();
}
Configurer configurer = new Configurer(attribute);
final GeneratorAttribute options = attribute;
JPanel controlPanel = new JPanel();
controlPanel.add(configurer);
JScrollPane scrollPane = new JScrollPane(controlPanel);
left.add(scrollPane, BorderLayout.CENTER);
// Create a JTextAreaExec without Start and Cancel buttons.
final JTextAreaExec exec = new JTextAreaExec(
"Code Generator Commands", false);
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
left, exec);
splitPane.setOneTouchExpandable(true);
// Adjust the divider so that the control panel does not
// have a horizontal scrollbar.
Dimension preferred = left.getPreferredSize();
splitPane.setDividerLocation(preferred.width + 20);
getContentPane().add(splitPane, BorderLayout.CENTER);
// ActionListeners for the buttons
parametersButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
try {
options.sanityCheckAndUpdateParameters(null);
} catch (Exception ex) {
exec.appendJTextArea(ex.toString());
}
exec.appendJTextArea(options.toString());
}
});
stopButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
exec.cancel();
}
});
clearButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
exec.clear();
}
});
goButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
try {
// The code generator to run. The value of this
// parameter should name a subdirectory of
// ptolemy/copernicus such as "java" or "shallow".
String codeGenerator = options
.getParameter("codeGenerator");
String targetPath = options.getParameter("targetPath");
String ptIIUserDirectory = options
.getParameter("ptIIUserDirectory");
// Check that we will be able to write
File directory = new File(ptIIUserDirectory, targetPath);