[3661] | 1 | package org.greenstone.gsdl3.build;
|
---|
| 2 |
|
---|
| 3 | import org.greenstone.gsdl3.util.*;
|
---|
| 4 | //import java.util.Thread
|
---|
| 5 | import javax.swing.event.EventListenerList;
|
---|
| 6 | import org.w3c.dom.Element;
|
---|
| 7 |
|
---|
[3683] | 8 | /** base class for collection construction */
|
---|
[3661] | 9 | public abstract class CollectionConstructor
|
---|
| 10 | extends Thread {
|
---|
| 11 |
|
---|
[3683] | 12 | /** the site in which building is to take place */
|
---|
[5148] | 13 | protected String site_home = null;
|
---|
[3683] | 14 | /** the name of the collection */
|
---|
[5148] | 15 | protected String collection_name = null;
|
---|
[3683] | 16 | /** the stage of construction */
|
---|
[5148] | 17 | protected int process_type = -1;
|
---|
[3683] | 18 | /** other arguments/parameters for the construction process - in a paramList */
|
---|
[5148] | 19 | protected Element process_params = null;
|
---|
[3683] | 20 | /** the list of listeners for the process */
|
---|
[5148] | 21 | protected EventListenerList listeners = null;
|
---|
[3661] | 22 | /** A flag used to determine if this process has been asked to cancel. */
|
---|
[5148] | 23 | protected boolean cancel = false;
|
---|
[3661] | 24 |
|
---|
| 25 | public CollectionConstructor(String name) {
|
---|
| 26 | super(name);
|
---|
[5148] | 27 | this.listeners = new EventListenerList();
|
---|
[3661] | 28 | }
|
---|
| 29 |
|
---|
[3683] | 30 | /** carry out any set up stuff - returns false if couldn't set up properly
|
---|
| 31 | */
|
---|
| 32 | public boolean configure() {
|
---|
| 33 | return true;
|
---|
| 34 | }
|
---|
[3661] | 35 | public void stopAction() {
|
---|
[5148] | 36 | this.cancel = true;
|
---|
[3661] | 37 | }
|
---|
| 38 |
|
---|
| 39 | public void setActionType(int type) {
|
---|
[5148] | 40 | this.process_type = type;
|
---|
[3661] | 41 | }
|
---|
| 42 | public void setSiteHome(String site_home) {
|
---|
[5148] | 43 | this.site_home = site_home;
|
---|
[3661] | 44 | }
|
---|
| 45 | public void setCollectionName(String coll_name) {
|
---|
[5148] | 46 | this.collection_name = coll_name;
|
---|
[3661] | 47 | }
|
---|
| 48 | public void setProcessParams(Element params) {
|
---|
[5148] | 49 | this.process_params = params;
|
---|
[3661] | 50 | }
|
---|
| 51 | public boolean addListener(ConstructionListener listener) {
|
---|
[5148] | 52 | this.listeners.add(ConstructionListener.class, listener);
|
---|
[3661] | 53 | return true;
|
---|
| 54 | }
|
---|
| 55 | public boolean removeListener(ConstructionListener listener) {
|
---|
[5148] | 56 | this.listeners.remove(ConstructionListener.class, listener);
|
---|
[3661] | 57 | return true;
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | protected void sendProcessBegun(ConstructionEvent evt) {
|
---|
[5148] | 61 | Object[] concerned = this.listeners.getListenerList();
|
---|
[3661] | 62 | for(int i = 0; i < concerned.length ; i+=2) {
|
---|
| 63 | if(concerned[i] == ConstructionListener.class) {
|
---|
| 64 | ((ConstructionListener)concerned[i+1]).processBegun(evt);
|
---|
| 65 | }
|
---|
| 66 | }
|
---|
| 67 | }
|
---|
| 68 | protected void sendProcessComplete(ConstructionEvent evt) {
|
---|
[5148] | 69 | Object[] concerned = this.listeners.getListenerList();
|
---|
[3661] | 70 | for(int i = 0; i < concerned.length ; i+=2) {
|
---|
| 71 | if(concerned[i] == ConstructionListener.class) {
|
---|
| 72 | ((ConstructionListener)concerned[i+1]).processComplete(evt);
|
---|
| 73 | }
|
---|
| 74 | }
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | protected void sendProcessStatus(ConstructionEvent evt) {
|
---|
| 78 |
|
---|
[5148] | 79 | Object[] concerned = this.listeners.getListenerList();
|
---|
[3661] | 80 | for(int i = 0; i < concerned.length ; i+=2) {
|
---|
| 81 | if(concerned[i] == ConstructionListener.class) {
|
---|
| 82 | ((ConstructionListener)concerned[i+1]).processStatus(evt);
|
---|
| 83 | }
|
---|
| 84 | }
|
---|
| 85 | }
|
---|
| 86 | protected void sendMessage(ConstructionEvent evt) {
|
---|
| 87 |
|
---|
[5148] | 88 | Object[] concerned = this.listeners.getListenerList();
|
---|
[3661] | 89 | for(int i = 0; i < concerned.length ; i+=2) {
|
---|
| 90 | if(concerned[i] == ConstructionListener.class) {
|
---|
| 91 | ((ConstructionListener)concerned[i+1]).message(evt);
|
---|
| 92 | }
|
---|
| 93 | }
|
---|
| 94 | }
|
---|
| 95 |
|
---|
[4852] | 96 | abstract public void run();
|
---|
[3661] | 97 | }
|
---|