blob: 5e63c1c2bae8d539f7e715d0417c171d209a4abb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/*******************************************************************************
* Copyright (c) 2004, 2007 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.framework.ui.skynet.relation.explorer;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
public class ArtifactModelList {
private ArrayList<ArtifactModel> artifacts = new ArrayList<ArtifactModel>();
private Set<IArtifactListViewer> changeListeners = new HashSet<IArtifactListViewer>();
/**
* Constructor
*/
public ArtifactModelList() {
super();
artifacts = new ArrayList<ArtifactModel>();
changeListeners = new HashSet<IArtifactListViewer>();
}
/**
* Return the collection of ItemTask
*/
public ArrayList<ArtifactModel> getArtifacts() {
return artifacts;
}
/**
* Add a new task to the collection of tasks
*/
public void addArtifact(ArtifactModel artifact, boolean top) {
if (top) {
artifacts.add(0, artifact);
} else {
artifacts.add(artifacts.size(), artifact);
}
Iterator<IArtifactListViewer> iterator = changeListeners.iterator();
while (iterator.hasNext()) {
iterator.next().addArtifact(artifact);
}
}
/**
* @param artifact -
*/
public void removeArtifact(ArtifactModel artifact) {
artifacts.remove(artifact);
Iterator<IArtifactListViewer> iterator = changeListeners.iterator();
while (iterator.hasNext()) {
iterator.next().removeArtifact(artifact);
}
}
@Override
public String toString() {
String str = "";
for (int i = 0; i < artifacts.size(); i++) {
String name = artifacts.get(i).getName();
str += "\nTask " + name;
}
return str + "\n\n";
}
/**
* @param artifact -
*/
public void artifactChanged(ArtifactModel artifact) {
Iterator<IArtifactListViewer> iterator = changeListeners.iterator();
while (iterator.hasNext()) {
iterator.next().updateArtifact(artifact);
}
}
/**
* @param viewer
*/
public void removeChangeListener(IArtifactListViewer viewer) {
changeListeners.remove(viewer);
}
/**
* @param viewer
*/
public void addChangeListener(IArtifactListViewer viewer) {
changeListeners.add(viewer);
}
public ArrayList<ArtifactModel> getArtifactModel() {
return artifacts;
}
}
|