KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > dataset > provider > SaveTask


1 /*
2  * $Id: SaveTask.java,v 1.1 2005/02/27 00:24:56 rbair Exp $
3  *
4  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
5  * Santa Clara, California 95054, U.S.A. All rights reserved.
6  */

7
8 package org.jdesktop.dataset.provider;
9
10 import javax.swing.Icon JavaDoc;
11 import org.jdesktop.dataset.DataSet;
12 import org.jdesktop.dataset.DataTable;
13
14 /**
15  *
16  * @author rbair
17  */

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 JavaDoc e) {
31             final Throwable JavaDoc error = e;
32             e.printStackTrace();
33             setProgress(getMaximum());
34         }
35     }
36
37     protected abstract void saveData(DataTable[] tables) throws Exception JavaDoc;
38
39     /**
40      * @inheritDoc
41      */

42     public String JavaDoc getDescription() {
43         return "<html><h3>Saving data</h3></html>";
44     }
45
46     /**
47      * @inheritDoc
48      */

49     public Icon JavaDoc getIcon() {
50         return null;
51     }
52
53     /**
54      * @inheritDoc
55      */

56     public String JavaDoc getMessage() {
57         return "Saving item " + (getProgress() + 1) + " of " + getMaximum();
58     }
59
60     /**
61      * @inheritDoc
62      */

63     public boolean cancel() throws Exception JavaDoc {
64         return false;
65     }
66 }
Popular Tags