Package: DeltaProcessingState

DeltaProcessingState

nameinstructionbranchcomplexitylinemethod
DeltaProcessingState()
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
addElementChangedListener(IElementChangedListener)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getListeners()
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
handleEvent(ElementChangedEvent)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
notify(IElementChangedListener[], ElementChangedEvent)
M: 20 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
removeElementChangedListener(IElementChangedListener)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * org.overture.ide.core
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.ide.internal.core;
23:
24: import java.util.ArrayList;
25: import java.util.List;
26:
27:
28: import org.eclipse.core.runtime.ISafeRunnable;
29: import org.eclipse.core.runtime.SafeRunner;
30: import org.overture.ide.core.ElementChangedEvent;
31: import org.overture.ide.core.IElementChangedListener;
32:
33:
34: public class DeltaProcessingState
35: {
36:         public List<IElementChangedListener> elementChangedListeners = new ArrayList<IElementChangedListener>();
37:         
38:         public synchronized void addElementChangedListener(IElementChangedListener listener)
39:         {
40:                 elementChangedListeners.add(listener);
41:
42:         }
43:
44:         public synchronized void removeElementChangedListener(IElementChangedListener listener)
45:         {
46:                 elementChangedListeners.remove(listener);
47:
48:         }
49:         
50:         
51:         
52:         protected synchronized IElementChangedListener[] getListeners() {
53:                 IElementChangedListener[] arr = new IElementChangedListener[elementChangedListeners.size()];
54:                 return elementChangedListeners.toArray(arr);
55:                 
56:         }
57:         
58:         public void handleEvent(final ElementChangedEvent event)
59:         {
60:                 notify(getListeners(),event);
61:         }
62:
63:         private void notify(IElementChangedListener[] resourceListeners,final ElementChangedEvent event)
64:         {
65:                 //int type = event.getType();
66:
67:                 try
68:                 {
69:•                        for (int i = 0; i < resourceListeners.length; i++)
70:                         {
71:
72:                                 final IElementChangedListener listener = resourceListeners[i];
73:
74:                                 SafeRunner.run(new ISafeRunnable() {
75:                                         public void handleException(Throwable e)
76:                                         {
77:                                                 // exception logged in SafeRunner#run
78:                                         }
79:
80:                                         public void run() throws Exception
81:                                         {
82:                                                 listener.elementChanged(event);
83:                                         }
84:                                 });
85:
86:                         }
87:
88:                 } finally
89:                 {
90:
91:                 }
92:         }
93: }