001/* 002 * Sonar, open source software quality management tool. 003 * Copyright (C) 2008-2012 SonarSource 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 */ 020package org.sonar.gwt.ui; 021 022import com.google.gwt.core.client.GWT; 023import com.google.gwt.user.client.ui.AbstractImagePrototype; 024import com.google.gwt.user.client.ui.ImageBundle; 025 026/** 027 * All icons are 16x16 pixels 028 */ 029public 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 * @deprecated since 2.5 use {@link Icons#forSeverity(String)} 083 */ 084 @Deprecated 085 public static AbstractImagePrototype forPriority(final String priority) { 086 return forSeverity(priority); 087 } 088 089 /** 090 * @since 2.5 091 */ 092 public static AbstractImagePrototype forSeverity(final String severity) { 093 AbstractImagePrototype image; 094 if ("BLOCKER".equals(severity)) { 095 image = get().priorityBlocker(); 096 097 } else if ("CRITICAL".equals(severity)) { 098 image = get().priorityCritical(); 099 100 } else if ("MAJOR".equals(severity)) { 101 image = get().priorityMajor(); 102 103 } else if ("MINOR".equals(severity)) { 104 image = get().priorityMinor(); 105 106 } else if ("INFO".equals(severity)) { 107 image = get().priorityInfo(); 108 109 } else { 110 image = get().empty(); 111 } 112 return image; 113 } 114 115 public static interface IconBundle extends ImageBundle { 116 AbstractImagePrototype empty(); 117 118 AbstractImagePrototype zoom(); 119 120 AbstractImagePrototype information(); 121 122 AbstractImagePrototype help(); 123 124 AbstractImagePrototype qualifierField(); 125 126 AbstractImagePrototype qualifierMethod(); 127 128 AbstractImagePrototype qualifierClass(); 129 130 AbstractImagePrototype qualifierFile(); 131 132 AbstractImagePrototype qualifierUnitTest(); 133 134 AbstractImagePrototype qualifierDirectory(); 135 136 AbstractImagePrototype qualifierPackage(); 137 138 AbstractImagePrototype qualifierProject(); 139 140 AbstractImagePrototype qualifierModule(); 141 142 AbstractImagePrototype qualifierLibrary(); 143 144 AbstractImagePrototype statusOk(); 145 146 AbstractImagePrototype statusError(); 147 148 AbstractImagePrototype statusWarning(); 149 150 AbstractImagePrototype priorityBlocker(); 151 152 AbstractImagePrototype priorityCritical(); 153 154 AbstractImagePrototype priorityMajor(); 155 156 AbstractImagePrototype priorityMinor(); 157 158 AbstractImagePrototype priorityInfo(); 159 } 160}