1 11 package org.eclipse.debug.internal.ui.viewers; 12 13 import org.eclipse.core.runtime.ListenerList; 14 import org.eclipse.core.runtime.SafeRunner; 15 import org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext; 16 import org.eclipse.jface.util.IPropertyChangeListener; 17 import org.eclipse.jface.util.PropertyChangeEvent; 18 import org.eclipse.jface.util.SafeRunnable; 19 import org.eclipse.ui.IWorkbenchPart; 20 21 28 public class PresentationContext implements IPresentationContext { 29 30 private IWorkbenchPart fPart; 31 private String [] fColumns; 32 private ListenerList fListeners = new ListenerList(); 33 34 39 public PresentationContext(IWorkbenchPart part) { 40 fPart = part; 41 } 42 43 46 public IWorkbenchPart getPart() { 47 return fPart; 48 } 49 50 53 public String [] getColumns() { 54 return fColumns; 55 } 56 57 64 protected void firePropertyChange(String property, Object oldValue, Object newValue) { 65 if (!fListeners.isEmpty()) { 66 final PropertyChangeEvent event = new PropertyChangeEvent(this, property, oldValue, newValue); 67 Object [] listeners = fListeners.getListeners(); 68 for (int i = 0; i < listeners.length; i++) { 69 final IPropertyChangeListener listener = (IPropertyChangeListener) listeners[i]; 70 SafeRunner.run(new SafeRunnable() { 71 public void run() throws Exception { 72 listener.propertyChange(event); 73 } 74 }); 75 } 76 } 77 } 78 79 84 protected void setColumns(String [] ids) { 85 String [] oldValue = fColumns; 86 fColumns = ids; 87 firePropertyChange(IPresentationContext.PROPERTY_COLUMNS, oldValue, ids); 88 } 89 90 93 protected void dispose() { 94 fListeners.clear(); 95 fPart = null; 96 } 97 98 101 public void addPropertyChangeListener(IPropertyChangeListener listener) { 102 fListeners.add(listener); 103 } 104 105 108 public void removePropertyChangeListener(IPropertyChangeListener listener) { 109 fListeners.remove(listener); 110 } 111 112 } 113 | Popular Tags |