1 | package org.apache.maven.continuum.web.util; |
2 | |
3 | /* |
4 | * Licensed to the Apache Software Foundation (ASF) under one |
5 | * or more contributor license agreements. See the NOTICE file |
6 | * distributed with this work for additional information |
7 | * regarding copyright ownership. The ASF licenses this file |
8 | * to you under the Apache License, Version 2.0 (the |
9 | * "License"); you may not use this file except in compliance |
10 | * with the License. You may obtain a copy of the License at |
11 | * |
12 | * http://www.apache.org/licenses/LICENSE-2.0 |
13 | * |
14 | * Unless required by applicable law or agreed to in writing, |
15 | * software distributed under the License is distributed on an |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
17 | * KIND, either express or implied. See the License for the |
18 | * specific language governing permissions and limitations |
19 | * under the License. |
20 | */ |
21 | |
22 | import org.apache.maven.continuum.project.ContinuumProjectState; |
23 | |
24 | /** |
25 | * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a> |
26 | * @version $Id: StateGenerator.java 729461 2008-12-26 08:38:10Z olamy $ |
27 | */ |
28 | public class StateGenerator |
29 | { |
30 | public static final String NEW = "NEW"; |
31 | |
32 | public static final String SUCCESS = "Success"; |
33 | |
34 | public static final String FAILED = "Failed"; |
35 | |
36 | public static final String ERROR = "Error"; |
37 | |
38 | public static final String BUILDING = "Building"; |
39 | |
40 | public static final String UPDATING = "Updating"; |
41 | |
42 | public static final String CHECKING_OUT = "Checking Out"; |
43 | |
44 | public static final String UNKNOWN = "Unknown"; |
45 | |
46 | public static String generate( int state, String contextPath ) |
47 | { |
48 | if ( state == ContinuumProjectState.NEW ) |
49 | { |
50 | return NEW; |
51 | } |
52 | else if ( state == ContinuumProjectState.OK || state == ContinuumProjectState.UPDATED ) |
53 | { |
54 | return "<img src=\"" + contextPath + "/images/icon_success_sml.gif\" alt=\"" + SUCCESS + "\" title=\"" + |
55 | SUCCESS + "\" border=\"0\" />"; |
56 | } |
57 | else if ( state == ContinuumProjectState.FAILED ) |
58 | { |
59 | return "<img src=\"" + contextPath + "/images/icon_warning_sml.gif\" alt=\"" + FAILED + "\" title=\"" + |
60 | FAILED + "\" border=\"0\" />"; |
61 | } |
62 | else if ( state == ContinuumProjectState.ERROR ) |
63 | { |
64 | return "<img src=\"" + contextPath + "/images/icon_error_sml.gif\" alt=\"" + ERROR + "\" title=\"" + ERROR + |
65 | "\" border=\"0\" />"; |
66 | } |
67 | else if ( state == ContinuumProjectState.BUILDING ) |
68 | { |
69 | return "<img src=\"" + contextPath + "/images/building.gif\" alt=\"" + BUILDING + "\" title=\"" + BUILDING + |
70 | "\" border=\"0\" />"; |
71 | } |
72 | else if ( state == ContinuumProjectState.UPDATING ) |
73 | { |
74 | return "<img src=\"" + contextPath + "/images/checkingout.gif\" alt=\"" + UPDATING + "\" title=\"" + |
75 | UPDATING + "\" border=\"0\" />"; |
76 | } |
77 | else if ( state == ContinuumProjectState.CHECKING_OUT ) |
78 | { |
79 | return "<img src=\"" + contextPath + "/images/checkingout.gif\" alt=\"" + CHECKING_OUT + "\" title=\"" + |
80 | CHECKING_OUT + "\" border=\"0\" />"; |
81 | } |
82 | else |
83 | { |
84 | return UNKNOWN; |
85 | } |
86 | } |
87 | } |