1 package org.catacomb.graph.gui;
2
3 import org.catacomb.interlish.content.KeyedList;
4 import org.catacomb.interlish.structure.IDable;
5 import org.catacomb.interlish.structure.IDd;
6 import org.catacomb.report.E;
7
8
9 import java.util.ArrayList;
10
11
12 public class ViewSet implements IDable {
13
14 String id;
15
16 KeyedList<DataView> views;
17
18 String latestNew = null;
19
20 public ViewSet() {
21 views = new KeyedList<DataView>();
22 }
23
24 public ViewSet(String s) {
25 this();
26 id = s;
27 }
28
29 public KeyedList<? extends IDd> getDataViews() {
30 return views;
31 }
32
33 public void setID(String s) {
34 id = s;
35 }
36
37 public String getID() {
38 return id;
39 }
40
41
42 public void addView(DataView dv) {
43 if (views.hasItem(dv.getID())) {
44 views.remove(dv.getID());
45 }
46 views.add(dv);
47 }
48
49
50
51 public String newViewName() {
52 return views.newName("view");
53 }
54
55 public DataView getDataView(String s) {
56 return views.get(s);
57 }
58
59 public boolean hasView(String s) {
60 return views.hasItem(s);
61 }
62
63
64 public void addIfNew(ArrayList<DataView> newViews) {
65 boolean added = false;
66 latestNew = null;
67 for (DataView dv : newViews) {
68 String sid = dv.getID();
69 if (sid == null) {
70 E.error("view with no id " + dv);
71 } else if (hasView(dv.getID())) {
72
73 } else {
74
75 views.silentAddItem(dv);
76 added = true;
77 latestNew = dv.getID();
78 }
79 }
80 if (added) {
81 views.reportChange();
82 }
83 }
84
85
86 public String latestAddition() {
87 return latestNew;
88 }
89
90
91 public void printViews() {
92 E.info("all views: " + views.printIDs());
93 }
94
95 }