use of org.gephi.utils.longtask.api.LongTaskErrorHandler in project gephi by gephi.
the class DesktopGeneratorController method generate.
@Override
public void generate(final Generator generator) {
String title = generator.getName();
GeneratorUI ui = generator.getUI();
if (ui != null) {
ui.setup(generator);
JPanel panel = ui.getPanel();
final DialogDescriptor dd = new DialogDescriptor(panel, title);
if (panel instanceof ValidationPanel) {
ValidationPanel vp = (ValidationPanel) panel;
vp.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
dd.setValid(!((ValidationPanel) e.getSource()).isProblem());
}
});
}
Object result = DialogDisplayer.getDefault().notify(dd);
if (result != NotifyDescriptor.OK_OPTION) {
return;
}
ui.unsetup();
}
final Container container = Lookup.getDefault().lookup(Container.Factory.class).newContainer();
container.setSource("" + generator.getName());
container.setReport(new Report());
String taskname = NbBundle.getMessage(DesktopGeneratorController.class, "DesktopGeneratorController.taskname", generator.getName());
//Error handler
LongTaskErrorHandler errorHandler = new LongTaskErrorHandler() {
@Override
public void fatalError(Throwable t) {
Logger.getLogger("").log(Level.SEVERE, "", t.getCause() != null ? t.getCause() : t);
}
};
//Execute
executor.execute(generator, new Runnable() {
@Override
public void run() {
generator.generate(container.getLoader());
finishGenerate(container);
}
}, taskname, errorHandler);
}
Aggregations