*
* @param evt The current event.
*/
public void actionPerformed(ActionEvent evt)
{
final IApplication app = getApplication();
final Frame parentFrame = getParentFrame(evt);
final FileExtensionFilter[] filters = new FileExtensionFilter[1];
filters[0] = new FileExtensionFilter(s_stringMgr.getString("DumpApplicationAction.textfiles"), new String[] { ".txt" });
final JLabel lbl = new JLabel(s_stringMgr.getString("DumpApplicationAction.warning"));
lbl.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
final File outFile = Dialogs.selectFileForWriting(parentFrame, filters, lbl);
if (outFile != null)
{
ListMessageHandler msgHandler = new ListMessageHandler();
ICommand cmd = new DumpApplicationCommand(app, outFile, msgHandler);
try
{
cmd.execute();
String[] msgs = msgHandler.getMessages();
String[] warnings = msgHandler.getWarningMessages();
Throwable[] errors = msgHandler.getExceptions();
if (msgs.length > 0 || errors.length > 0 || warnings.length > 0)
{
for (int i = 0; i < msgs.length; ++i)
{
app.showErrorDialog(msgs[i]);
}
for (int i = 0; i < warnings.length; ++i)
{
app.showErrorDialog(warnings[i]);
}
for (int i = 0; i < errors.length; ++i)
{
app.showErrorDialog(errors[i]);
}
}
else
{
final String msg = s_stringMgr.getString("DumpApplicationAction.success", outFile.getAbsolutePath());
ErrorDialog dlg = new ErrorDialog(getApplication().getMainFrame(), msg);
// i18n[DumpApplicationAction.titleSuccess=Dump successful]
dlg.setTitle(s_stringMgr.getString("DumpApplicationAction.titleSuccess"));
dlg.setVisible(true);
}
}
catch (Throwable ex)
{
final String msg = s_stringMgr.getString("DumpApplicationAction.failure");
app.showErrorDialog(msg, ex);
s_log.error(msg, ex);
}
}
}