1 7 8 package org.jdesktop.dataset.provider; 9 10 import javax.swing.Icon ; 11 import org.jdesktop.dataset.DataSet; 12 import org.jdesktop.dataset.DataTable; 13 14 18 public abstract class SaveTask extends AbstractTask { 19 private DataTable[] tables; 20 21 public SaveTask(DataTable[] tables) { 22 this.tables = tables == null ? new DataTable[0] : tables; 23 } 24 25 public void run() { 26 setIndeterminate(true); 27 try { 28 saveData(tables); 29 setProgress(getMaximum()); 30 } catch (Exception e) { 31 final Throwable error = e; 32 e.printStackTrace(); 33 setProgress(getMaximum()); 34 } 35 } 36 37 protected abstract void saveData(DataTable[] tables) throws Exception ; 38 39 42 public String getDescription() { 43 return "<html><h3>Saving data</h3></html>"; 44 } 45 46 49 public Icon getIcon() { 50 return null; 51 } 52 53 56 public String getMessage() { 57 return "Saving item " + (getProgress() + 1) + " of " + getMaximum(); 58 } 59 60 63 public boolean cancel() throws Exception { 64 return false; 65 } 66 } | Popular Tags |