1 11 12 package org.eclipse.debug.internal.ui.views.memory; 13 14 import java.util.ArrayList ; 15 16 import org.eclipse.jface.viewers.ISelection; 17 import org.eclipse.jface.viewers.ISelectionChangedListener; 18 import org.eclipse.jface.viewers.ISelectionProvider; 19 import org.eclipse.jface.viewers.SelectionChangedEvent; 20 21 22 27 public class ViewPaneSelectionProvider implements ISelectionProvider 28 { 29 ArrayList fListeners = new ArrayList (); 30 ISelection fSelection; 31 32 35 public void addSelectionChangedListener(ISelectionChangedListener listener) 36 { 37 if (!fListeners.contains(listener)) 38 fListeners.add(listener); 39 40 } 41 42 45 public ISelection getSelection() 46 { 47 return fSelection; 48 } 49 50 53 public void removeSelectionChangedListener(ISelectionChangedListener listener) 54 { 55 if (fListeners.contains(listener)) 56 fListeners.remove(listener); 57 58 } 59 60 63 public void setSelection(ISelection selection) 64 { 65 fSelection = selection; 66 fireChanged(); 67 } 68 69 public void fireChanged() 70 { 71 SelectionChangedEvent evt = new SelectionChangedEvent(this, getSelection()); 72 for (int i=0; i<fListeners.size(); i++) 73 { 74 ((ISelectionChangedListener)fListeners.get(i)).selectionChanged(evt); 75 } 76 } 77 } 78 | Popular Tags |