1 5 package net.sf.panoptes.controller.actions; 6 7 import java.awt.event.ActionEvent ; 8 9 import javax.swing.AbstractAction ; 10 import javax.swing.Action ; 11 import javax.swing.ImageIcon ; 12 13 import org.apache.commons.logging.Log; 14 import org.apache.commons.logging.LogFactory; 15 16 import net.sf.panoptes.controller.MainController; 17 18 import foxtrot.Task; 19 import foxtrot.Worker; 20 21 27 public abstract class TaskAction extends BaseAction { 28 29 protected Log log = LogFactory.getLog(getClass()); 30 31 public TaskAction(String name) { 32 super(name); 33 } 34 public TaskAction(String name, String iconName) { 35 super(name); 36 37 } 38 39 public void actionPerformed(final ActionEvent e) { 40 try { 41 Worker.post(new Task() { 42 public Object run() throws Exception { 43 doTask(e); 44 return null; 45 } 46 }); 47 } catch (Exception ex) { 48 log.error("Unable to execute task", ex); 49 MainController.getInstance().displayError("Error", "An error occured whlie performing action", ex); 50 } 51 } 52 53 public abstract void doTask(ActionEvent e) throws Exception ; 54 55 } 56 | Popular Tags |