*
* @return TRUE if successful
* @see #getInstances()
*/
public boolean execute() {
DataGenerator generator;
boolean result;
String relName;
String cname;
String cmd;
result = true;
generator = (DataGenerator) m_GeneratorEditor.getValue();
relName = generator.getRelationName();
cname = generator.getClass().getName().replaceAll(".*\\.", "");
cmd = generator.getClass().getName();
if (generator instanceof OptionHandler)
cmd += " " + Utils.joinOptions(((OptionHandler) generator).getOptions());
try {
m_Log.logMessage(Messages.getInstance().getString("DataGeneratorPanel_Execute_Log_LogMessage_Text_First") + cname);
m_Log.logMessage(Messages.getInstance().getString("DataGeneratorPanel_Execute_Log_LogMessage_Text_Second") + cmd);
m_Output = new StringWriter();
generator.setOutput(new PrintWriter(m_Output));
DataGenerator.makeData(generator, generator.getOptions());
m_Instances = new Instances(new StringReader(getOutput()));
m_Log.logMessage(Messages.getInstance().getString("DataGeneratorPanel_Execute_Log_LogMessage_Text_Third") + cname);
}
catch (Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(
this, Messages.getInstance().getString("DataGeneratorPanel_Execute_JOptionPaneShowMessageDialog_Text_First") + e.getMessage(),
Messages.getInstance().getString("DataGeneratorPanel_Execute_JOptionPaneShowMessageDialog_Text_Second"), JOptionPane.ERROR_MESSAGE);
m_Instances = null;
m_Output = new StringWriter();
result = false;
}
generator.setRelationName(relName);
return result;
}