1 11 package org.eclipse.core.internal.registry; 12 13 import java.util.ResourceBundle ; 14 import org.eclipse.core.runtime.IStatus; 15 16 30 public class RegistrySupport { 31 32 static public String translate(String key, ResourceBundle resources) { 33 if (key == null) 34 return null; 35 if (resources == null) 36 return key; 37 String trimmedKey = key.trim(); 38 if (trimmedKey.length() == 0) 39 return key; 40 if (trimmedKey.charAt(0) != '%') 41 return key; 42 return resources.getString(trimmedKey.substring(1)); 43 } 44 45 static public void log(IStatus status, String prefix) { 46 String message = status.getMessage(); 47 int severity = status.getSeverity(); 48 49 String statusMsg; 50 switch (severity) { 51 case IStatus.ERROR : 52 statusMsg = RegistryMessages.log_error; 53 break; 54 case IStatus.WARNING : 55 statusMsg = RegistryMessages.log_warning; 56 break; 57 default : 58 statusMsg = RegistryMessages.log_log; 59 break; 60 } 61 statusMsg += message; 62 63 if (prefix != null) 64 statusMsg = prefix + statusMsg; 65 System.out.println(statusMsg); 66 67 IStatus[] children = status.getChildren(); 69 if (children.length != 0) { 70 String newPrefix; 71 if (prefix == null) 72 newPrefix = "\t"; else 74 newPrefix = prefix + "\t"; for (int i = 0; i < children.length; i++) { 76 log(children[i], newPrefix); 77 } 78 } 79 } 80 } 81 | Popular Tags |