1 | package org.honours.agents;
|
---|
2 |
|
---|
3 | import org.expeditee.agents.DefaultAgent;
|
---|
4 | import org.expeditee.gui.Frame;
|
---|
5 | import org.expeditee.gui.FrameIO;
|
---|
6 | import org.expeditee.gui.MessageBay;
|
---|
7 | import org.honours.Main;
|
---|
8 | import org.honours.collection.Collection;
|
---|
9 | import org.honours.CollectionSpace.CollectionSpace;
|
---|
10 |
|
---|
11 | public class CollectionSpaceAgent extends DefaultAgent {
|
---|
12 |
|
---|
13 |
|
---|
14 | private Collection _collection;
|
---|
15 | private CollectionSpace _collectionSpace;
|
---|
16 |
|
---|
17 | public Frame process(Frame frame) {
|
---|
18 |
|
---|
19 | _collection = Collection.findCollection(frame);
|
---|
20 | System.err.println(frame.getName());
|
---|
21 | System.err.println(_collection);
|
---|
22 |
|
---|
23 | if(_collection != null){
|
---|
24 | if(_collection.getCollectionSpace() == null){
|
---|
25 | //create a new collection space.
|
---|
26 | _collectionSpace = new CollectionSpace(_collection);
|
---|
27 | _collection.setCollectionSpace(_collectionSpace);
|
---|
28 | _collectionSpace.generate();
|
---|
29 |
|
---|
30 | int index = Collection.getCollectionPosition(_collection);
|
---|
31 | Main._collections.remove(index);
|
---|
32 | Main._collections.add(index, _collection);
|
---|
33 |
|
---|
34 | return FrameIO.LoadFrame(_collectionSpace.getName() + "1");
|
---|
35 | }
|
---|
36 | }else{
|
---|
37 | MessageBay.errorMessage("ERROR: Cannot generate a collection space as collection cannot be found.");
|
---|
38 | }
|
---|
39 |
|
---|
40 | return null;
|
---|
41 | }
|
---|
42 |
|
---|
43 |
|
---|
44 |
|
---|
45 | }
|
---|