bchilds | 68f36fc | 2007-03-01 22:47:33 +0000 | [diff] [blame] | 1 | package org.eclipse.wst.jsdt.web.core.internal.java; |
2 | |||||
3 | /** | ||||
4 | * @author pavery | ||||
5 | */ | ||||
bchilds | 68f36fc | 2007-03-01 22:47:33 +0000 | [diff] [blame] | 6 | import java.util.ArrayList; |
7 | import java.util.List; | ||||
8 | |||||
bchilds | d01b1ea | 2007-03-02 16:52:19 +0000 | [diff] [blame] | 9 | import org.eclipse.wst.jsdt.core.IProblemRequestor; |
10 | import org.eclipse.wst.jsdt.core.compiler.IProblem; | ||||
bchilds | 68f36fc | 2007-03-01 22:47:33 +0000 | [diff] [blame] | 11 | |
bchilds | a118170 | 2007-06-14 21:47:04 +0000 | [diff] [blame] | 12 | class JsProblemRequestor implements IProblemRequestor { |
bchilds | 104d959 | 2007-04-30 23:38:39 +0000 | [diff] [blame] | 13 | private List fCollectedProblems; |
bchilds | 104d959 | 2007-04-30 23:38:39 +0000 | [diff] [blame] | 14 | private boolean fIsActive = false; |
bchilds | 68f36fc | 2007-03-01 22:47:33 +0000 | [diff] [blame] | 15 | private boolean fIsRunning = false; |
bchilds | a118170 | 2007-06-14 21:47:04 +0000 | [diff] [blame] | 16 | |
bchilds | 68f36fc | 2007-03-01 22:47:33 +0000 | [diff] [blame] | 17 | public void acceptProblem(IProblem problem) { |
bchilds | 68f36fc | 2007-03-01 22:47:33 +0000 | [diff] [blame] | 18 | if (isActive()) { |
19 | fCollectedProblems.add(problem); | ||||
20 | } | ||||
21 | } | ||||
bchilds | a118170 | 2007-06-14 21:47:04 +0000 | [diff] [blame] | 22 | |
bchilds | 133806a | 2007-03-27 15:52:39 +0000 | [diff] [blame] | 23 | public void beginReporting() { |
bchilds | 133806a | 2007-03-27 15:52:39 +0000 | [diff] [blame] | 24 | fIsRunning = true; |
25 | fCollectedProblems = new ArrayList(); | ||||
26 | } | ||||
bchilds | a118170 | 2007-06-14 21:47:04 +0000 | [diff] [blame] | 27 | |
bchilds | 68f36fc | 2007-03-01 22:47:33 +0000 | [diff] [blame] | 28 | public void endReporting() { |
bchilds | 68f36fc | 2007-03-01 22:47:33 +0000 | [diff] [blame] | 29 | fIsRunning = false; |
30 | } | ||||
bchilds | a118170 | 2007-06-14 21:47:04 +0000 | [diff] [blame] | 31 | |
bchilds | 133806a | 2007-03-27 15:52:39 +0000 | [diff] [blame] | 32 | /** |
33 | * @return the list of collected problems | ||||
34 | */ | ||||
35 | public List getCollectedProblems() { | ||||
bchilds | 133806a | 2007-03-27 15:52:39 +0000 | [diff] [blame] | 36 | return fCollectedProblems; |
37 | } | ||||
bchilds | a118170 | 2007-06-14 21:47:04 +0000 | [diff] [blame] | 38 | |
bchilds | 68f36fc | 2007-03-01 22:47:33 +0000 | [diff] [blame] | 39 | public boolean isActive() { |
bchilds | 68f36fc | 2007-03-01 22:47:33 +0000 | [diff] [blame] | 40 | return fIsActive && fCollectedProblems != null; |
41 | } | ||||
bchilds | a118170 | 2007-06-14 21:47:04 +0000 | [diff] [blame] | 42 | |
bchilds | 133806a | 2007-03-27 15:52:39 +0000 | [diff] [blame] | 43 | public boolean isRunning() { |
bchilds | 133806a | 2007-03-27 15:52:39 +0000 | [diff] [blame] | 44 | return fIsRunning; |
45 | } | ||||
bchilds | a118170 | 2007-06-14 21:47:04 +0000 | [diff] [blame] | 46 | |
bchilds | 68f36fc | 2007-03-01 22:47:33 +0000 | [diff] [blame] | 47 | /** |
48 | * Sets the active state of this problem requestor. | ||||
49 | * | ||||
50 | * @param isActive | ||||
51 | * the state of this problem requestor | ||||
52 | */ | ||||
53 | public void setIsActive(boolean isActive) { | ||||
bchilds | 68f36fc | 2007-03-01 22:47:33 +0000 | [diff] [blame] | 54 | if (fIsActive != isActive) { |
55 | fIsActive = isActive; | ||||
56 | if (fIsActive) { | ||||
57 | startCollectingProblems(); | ||||
58 | } else { | ||||
59 | stopCollectingProblems(); | ||||
60 | } | ||||
61 | } | ||||
62 | } | ||||
bchilds | a118170 | 2007-06-14 21:47:04 +0000 | [diff] [blame] | 63 | |
bchilds | 68f36fc | 2007-03-01 22:47:33 +0000 | [diff] [blame] | 64 | /** |
65 | * Tells this annotation model to collect temporary problems from now on. | ||||
66 | */ | ||||
67 | private void startCollectingProblems() { | ||||
bchilds | 68f36fc | 2007-03-01 22:47:33 +0000 | [diff] [blame] | 68 | fCollectedProblems = new ArrayList(); |
69 | } | ||||
bchilds | a118170 | 2007-06-14 21:47:04 +0000 | [diff] [blame] | 70 | |
bchilds | 68f36fc | 2007-03-01 22:47:33 +0000 | [diff] [blame] | 71 | /** |
72 | * Tells this annotation model to no longer collect temporary problems. | ||||
73 | */ | ||||
74 | private void stopCollectingProblems() { | ||||
bchilds | a118170 | 2007-06-14 21:47:04 +0000 | [diff] [blame] | 75 | // do nothing |
bchilds | 68f36fc | 2007-03-01 22:47:33 +0000 | [diff] [blame] | 76 | } |
bchilds | 68f36fc | 2007-03-01 22:47:33 +0000 | [diff] [blame] | 77 | } |