1 11 package org.eclipse.jdt.internal.ui.browsing; 12 13 import java.util.ArrayList ; 14 import java.util.List ; 15 16 import org.eclipse.swt.widgets.Composite; 17 import org.eclipse.swt.widgets.Item; 18 import org.eclipse.swt.widgets.Widget; 19 20 import org.eclipse.jdt.core.IPackageFragment; 21 22 import org.eclipse.jdt.internal.ui.viewsupport.ColoredViewersManager; 23 import org.eclipse.jdt.internal.ui.viewsupport.ProblemTableViewer; 24 25 28 class PackagesViewTableViewer extends ProblemTableViewer implements IPackagesViewViewer { 29 30 public PackagesViewTableViewer(Composite parent, int style) { 31 super(parent, style); 32 ColoredViewersManager.install(this); 33 } 34 35 public void mapElement(Object element, Widget item) { 36 if (element instanceof LogicalPackage && item instanceof Item) { 37 LogicalPackage cp= (LogicalPackage) element; 38 IPackageFragment[] fragments= cp.getFragments(); 39 for (int i= 0; i < fragments.length; i++) { 40 IPackageFragment fragment= fragments[i]; 41 fResourceToItemsMapper.addToMap(fragment, (Item)item); 42 } 43 } 44 super.mapElement(element, item); 45 } 46 47 public void unmapElement(Object element, Widget item) { 48 if (element instanceof LogicalPackage && item instanceof Item) { 49 LogicalPackage cp= (LogicalPackage) element; 50 IPackageFragment[] fragments= cp.getFragments(); 51 for (int i= 0; i < fragments.length; i++) { 52 IPackageFragment fragment= fragments[i]; 53 fResourceToItemsMapper.removeFromMap(fragment, (Item)item); 54 } 55 } 56 super.unmapElement(element, item); 57 } 58 59 63 protected Object [] getFilteredChildren(Object parent) { 64 65 Object [] result= getRawChildren(parent); 66 List list= new ArrayList (); 67 if (result != null) { 68 Object [] toBeFiltered= new Object [1]; 69 for (int i= 0; i < result.length; i++) { 70 Object object= result[i]; 71 if(object instanceof LogicalPackage) { 72 if(selectLogicalPackage((LogicalPackage)object)) 73 list.add(object); 74 } else { 75 toBeFiltered[0]= object; 76 if (filter(toBeFiltered).length == 1) 77 list.add(object); 78 } 79 } 80 } 81 return list.toArray(); 82 } 83 84 private boolean selectLogicalPackage(LogicalPackage logicalPackage) { 85 return filter(logicalPackage.getFragments()).length > 0; 86 } 87 88 90 public Widget doFindItem(Object element){ 91 return super.doFindItem(element); 92 } 93 94 public Widget doFindInputItem(Object element){ 95 return super.doFindInputItem(element); 96 } 97 98 public List getSelectionFromWidget(){ 99 return super.getSelectionFromWidget(); 100 } 101 102 public void doUpdateItem(Widget item, Object element, boolean fullMap){ 103 super.doUpdateItem(item, element, fullMap); 104 } 105 106 public void internalRefresh(Object element){ 107 super.internalRefresh(element); 108 } 109 110 public void setSelectionToWidget(List l, boolean reveal){ 111 super.setSelectionToWidget(l, reveal); 112 } 113 } 114 | Popular Tags |