Line | Hits | Source |
---|---|---|
1 | /******************************************************************************* | |
2 | * Demetrix process modelling system | |
3 | * | |
4 | * Copyright (c) 2003, 2004 Dimitri A. Pissarenko | |
5 | * | |
6 | * This file is part of Demetrix. | |
7 | * | |
8 | * Demetrix is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 2.1 of the License, or | |
11 | * (at your option) any later version. | |
12 | * | |
13 | * Demetrix is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with Demetrix; if not, write to the Free Software | |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | * | |
22 | * For further information you may | |
23 | * | |
24 | * - send an e-mail in Russian, German or English to dimitri.pissarenko@gmx.net | |
25 | * - look at http://sourceforge.net/projects/demetrix/ | |
26 | * - look at http://demetrix.sourceforge.net/ | |
27 | * - look at http://members.inode.at/d.pissarenko/ | |
28 | * | |
29 | *****************************************************************************/ | |
30 | ||
31 | package net.sourceforge.demetrix.ui; | |
32 | ||
33 | import java.util.Iterator; | |
34 | ||
35 | import java.util.Vector; | |
36 | ||
37 | import org.jgraph.graph.DefaultGraphCell; | |
38 | ||
39 | /** | |
40 | * @author Dimitri Pissarenko | |
41 | * | |
42 | */ | |
43 | ||
44 | public class CurrentlySelectedNodeSingleton { | |
45 | ||
46 | private static CurrentlySelectedNodeSingleton instance; | |
47 | ||
48 | private DefaultGraphCell currentlySelectedNode; | |
49 | private Object[] currentlySelectedCells; | |
50 | ||
51 | private Vector observers; | |
52 | ||
53 | 6 | public CurrentlySelectedNodeSingleton() { |
54 | ||
55 | 6 | this.observers = new Vector(); |
56 | ||
57 | 6 | } |
58 | ||
59 | public static CurrentlySelectedNodeSingleton getInstance() { | |
60 | ||
61 | 569 | if (instance == null) { |
62 | ||
63 | 6 | instance = new CurrentlySelectedNodeSingleton(); |
64 | ||
65 | } | |
66 | ||
67 | 569 | return instance; |
68 | ||
69 | } | |
70 | ||
71 | public void attach(CurrentlySelectedNodeObserver observer) { | |
72 | ||
73 | 25 | this.observers.add(observer); |
74 | ||
75 | 25 | } |
76 | ||
77 | public DefaultGraphCell getCurrentlySelectedNode() { | |
78 | ||
79 | 281 | return currentlySelectedNode; |
80 | ||
81 | } | |
82 | ||
83 | public void setCurrentlySelectedNode(DefaultGraphCell cell) { | |
84 | ||
85 | ||
86 | 25 | this.currentlySelectedNode = cell; |
87 | ||
88 | ||
89 | 25 | } |
90 | public void informCurrentlySelectedNodeChanged() | |
91 | { | |
92 | 26 | Iterator iterator = null; |
93 | ||
94 | 26 | CurrentlySelectedNodeObserver observer = null; |
95 | ||
96 | 26 | iterator = this.observers.iterator(); |
97 | ||
98 | 169 | while (iterator.hasNext()) { |
99 | ||
100 | 143 | observer = (CurrentlySelectedNodeObserver) iterator.next(); |
101 | ||
102 | 143 | observer.currentlySelectedNodeChanged(); |
103 | ||
104 | } | |
105 | ||
106 | 26 | } |
107 | /** | |
108 | * @return | |
109 | */ | |
110 | public Object[] getCurrentlySelectedCells() { | |
111 | 193 | return currentlySelectedCells; |
112 | } | |
113 | ||
114 | /** | |
115 | * @param objects | |
116 | */ | |
117 | public void setCurrentlySelectedCells(Object[] objects) { | |
118 | 18 | currentlySelectedCells = objects; |
119 | 18 | } |
120 | ||
121 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |