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