1 11 12 package org.eclipse.ui.statushandlers; 13 14 import java.util.HashMap ; 15 16 import org.eclipse.core.runtime.IAdaptable; 17 import org.eclipse.core.runtime.IStatus; 18 import org.eclipse.core.runtime.QualifiedName; 19 import org.eclipse.ui.PlatformUI; 20 21 30 public class StatusAdapter implements IAdaptable { 31 32 35 static final String PROPERTY_PREFIX = PlatformUI.PLUGIN_ID 36 + ".workbench.statusHandlers.adapters"; 38 42 public static final QualifiedName TITLE_PROPERTY = new QualifiedName( 43 PROPERTY_PREFIX, "title"); 45 50 public static final QualifiedName TIMESTAMP_PROPERTY = new QualifiedName( 51 PROPERTY_PREFIX, "timestamp"); 53 private IStatus status; 54 55 private HashMap properties; 56 57 private HashMap adapters; 58 59 65 public StatusAdapter(IStatus status) { 66 this.status = status; 67 } 68 69 79 public void addAdapter(Class adapter, Object object) { 80 if (adapters == null) { 81 adapters = new HashMap (); 82 } 83 adapters.put(adapter, object); 84 } 85 86 91 public Object getAdapter(Class adapter) { 92 if (adapters == null) { 93 return null; 94 } 95 return adapters.get(adapter); 96 } 97 98 104 public IStatus getStatus() { 105 return status; 106 } 107 108 114 public void setStatus(IStatus status) { 115 this.status = status; 116 } 117 118 127 public Object getProperty(QualifiedName key) { 128 if (properties == null) { 129 return null; 130 } 131 return properties.get(key); 132 } 133 134 142 public void setProperty(QualifiedName key, Object value) { 143 if (properties == null) { 144 properties = new HashMap (); 145 } 146 properties.put(key, value); 147 } 148 } 149 | Popular Tags |