source: trunk/gsdl3/src/java/org/greenstone/gsdl3/build/CollectionConstructor.java@ 5148

Last change on this file since 5148 was 5148, checked in by kjdon, 21 years ago

code style consistency check - class variables no longer end in _

  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1package org.greenstone.gsdl3.build;
2
3import org.greenstone.gsdl3.util.*;
4//import java.util.Thread
5import javax.swing.event.EventListenerList;
6import org.w3c.dom.Element;
7
8/** base class for collection construction */
9public abstract class CollectionConstructor
10 extends Thread {
11
12 /** the site in which building is to take place */
13 protected String site_home = null;
14 /** the name of the collection */
15 protected String collection_name = null;
16 /** the stage of construction */
17 protected int process_type = -1;
18 /** other arguments/parameters for the construction process - in a paramList */
19 protected Element process_params = null;
20 /** the list of listeners for the process */
21 protected EventListenerList listeners = null;
22 /** A flag used to determine if this process has been asked to cancel. */
23 protected boolean cancel = false;
24
25 public CollectionConstructor(String name) {
26 super(name);
27 this.listeners = new EventListenerList();
28 }
29
30 /** carry out any set up stuff - returns false if couldn't set up properly
31 */
32 public boolean configure() {
33 return true;
34 }
35 public void stopAction() {
36 this.cancel = true;
37 }
38
39 public void setActionType(int type) {
40 this.process_type = type;
41 }
42 public void setSiteHome(String site_home) {
43 this.site_home = site_home;
44 }
45 public void setCollectionName(String coll_name) {
46 this.collection_name = coll_name;
47 }
48 public void setProcessParams(Element params) {
49 this.process_params = params;
50 }
51 public boolean addListener(ConstructionListener listener) {
52 this.listeners.add(ConstructionListener.class, listener);
53 return true;
54 }
55 public boolean removeListener(ConstructionListener listener) {
56 this.listeners.remove(ConstructionListener.class, listener);
57 return true;
58 }
59
60 protected void sendProcessBegun(ConstructionEvent evt) {
61 Object[] concerned = this.listeners.getListenerList();
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) {
69 Object[] concerned = this.listeners.getListenerList();
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
79 Object[] concerned = this.listeners.getListenerList();
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
88 Object[] concerned = this.listeners.getListenerList();
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
96 abstract public void run();
97}
Note: See TracBrowser for help on using the repository browser.