001    /*
002     * Sonar, open source software quality management tool.
003     * Copyright (C) 2009 SonarSource SA
004     * mailto:contact AT sonarsource DOT com
005     *
006     * Sonar is free software; you can redistribute it and/or
007     * modify it under the terms of the GNU Lesser General Public
008     * License as published by the Free Software Foundation; either
009     * version 3 of the License, or (at your option) any later version.
010     *
011     * Sonar is distributed in the hope that it will be useful,
012     * but WITHOUT ANY WARRANTY; without even the implied warranty of
013     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014     * Lesser General Public License for more details.
015     *
016     * You should have received a copy of the GNU Lesser General Public
017     * License along with Sonar; if not, write to the Free Software
018     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
019     */
020    package org.sonar.gwt.ui;
021    
022    import com.google.gwt.core.client.GWT;
023    import com.google.gwt.user.client.ui.AbstractImagePrototype;
024    import com.google.gwt.user.client.ui.ImageBundle;
025    
026    /**
027     * All icons are 16x16 pixels
028     */
029    public final class Icons {
030      private static IconBundle INSTANCE;
031    
032      private Icons() {
033        // only static methods
034      }
035    
036      public static IconBundle get() {
037        if (INSTANCE == null) {
038          INSTANCE = GWT.create(IconBundle.class);
039        }
040        return INSTANCE;
041      }
042    
043      public static AbstractImagePrototype forQualifier(final String qualifier) {
044        AbstractImagePrototype image;
045        if ("FIL".equals(qualifier)) {
046          image = get().qualifierFile();
047        } else if ("CLA".equals(qualifier)) {
048          image = get().qualifierClass();
049    
050        } else if ("PAC".equals(qualifier)) {
051          image = get().qualifierPackage();
052    
053        } else if ("DIR".equals(qualifier)) {
054          image = get().qualifierDirectory();
055    
056        } else if ("BRC".equals(qualifier)) {
057          image = get().qualifierModule();
058    
059        } else if ("TRK".equals(qualifier)) {
060          image = get().qualifierProject();
061    
062        } else if ("UTS".equals(qualifier)) {
063          image = get().qualifierUnitTest();
064    
065        } else if ("FLD".equals(qualifier)) {
066          image = get().qualifierField();
067    
068        } else if ("MET".equals(qualifier)) {
069          image = get().qualifierMethod();
070    
071        } else if ("LIB".equals(qualifier)) {
072          image = get().qualifierLibrary();
073    
074        } else {
075          image = get().empty();
076        }
077        return image;
078      }
079    
080      /**
081       * @since 2.2
082       */
083      public static AbstractImagePrototype forPriority(final String priority) {
084        AbstractImagePrototype image;
085        if ("BLOCKER".equals(priority)) {
086          image = get().priorityBlocker();
087    
088        } else if ("CRITICAL".equals(priority)) {
089          image = get().priorityCritical();
090    
091        } else if ("MAJOR".equals(priority)) {
092          image = get().priorityMajor();
093    
094        } else if ("MINOR".equals(priority)) {
095          image = get().priorityMinor();
096    
097        } else if ("INFO".equals(priority)) {
098          image = get().priorityInfo();
099    
100        } else {
101          image = get().empty();
102        }
103        return image;
104      }
105    
106      public static interface IconBundle extends ImageBundle {
107        AbstractImagePrototype empty();
108    
109        AbstractImagePrototype zoom();
110    
111        AbstractImagePrototype information();
112    
113        AbstractImagePrototype help();
114    
115        AbstractImagePrototype qualifierField();
116    
117        AbstractImagePrototype qualifierMethod();
118    
119        AbstractImagePrototype qualifierClass();
120    
121        AbstractImagePrototype qualifierFile();
122    
123        AbstractImagePrototype qualifierUnitTest();
124    
125        AbstractImagePrototype qualifierDirectory();
126    
127        AbstractImagePrototype qualifierPackage();
128    
129        AbstractImagePrototype qualifierProject();
130    
131        AbstractImagePrototype qualifierModule();
132    
133        AbstractImagePrototype qualifierLibrary();
134    
135        AbstractImagePrototype statusOk();
136    
137        AbstractImagePrototype statusError();
138    
139        AbstractImagePrototype statusWarning();
140    
141        AbstractImagePrototype priorityBlocker();
142    
143        AbstractImagePrototype priorityCritical();
144    
145        AbstractImagePrototype priorityMajor();
146    
147        AbstractImagePrototype priorityMinor();
148    
149        AbstractImagePrototype priorityInfo();
150      }
151    }