Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/de/intevation/artifactdatabase/state/FacetActivity.java @ 403:bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
artifacts/trunk@5150 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 29 Jul 2012 09:37:55 +0000 |
parents | |
children | 4c78c5d2b367 |
rev | line source |
---|---|
403
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.artifactdatabase.state; |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import de.intevation.artifacts.Artifact; |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import java.util.HashMap; |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 import java.util.Map; |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 public interface FacetActivity |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 { |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 public static final FacetActivity ACTIVE = new FacetActivity() { |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 @Override |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 public boolean isInitialActive( |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 Artifact artifact, |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 Facet facet, |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 String output |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 ) { |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 return true; |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 } |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 }; |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 public static final FacetActivity INACTIVE = new FacetActivity() { |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 @Override |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 public boolean isInitialActive( |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 Artifact artifact, |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 Facet facet, |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 String output |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 ) { |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 return false; |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 } |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 }; |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 boolean isInitialActive(Artifact artifact, Facet facet, String output); |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 public static final class Registry { |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 private static final Registry INSTANCE = new Registry(); |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 private Map<String, FacetActivity> activities; |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 private Registry() { |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 activities = new HashMap<String, FacetActivity>(); |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 } |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 public Registry getInstance() { |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 return INSTANCE; |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 } |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 public synchronized FacetActivity getActivity(String key) { |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 FacetActivity activity = activities.get(key); |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 return activity != null ? activity : ACTIVE; |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 } |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 public synchronized void register(String key, FacetActivity activity) { |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 activities.put(key, activity); |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 } |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 } |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 } |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |