1 11 package org.eclipse.jdt.internal.ui.viewsupport; 12 13 import org.eclipse.jdt.core.IPackageFragment; 14 15 import org.eclipse.jdt.ui.JavaElementImageDescriptor; 16 import org.eclipse.jdt.ui.ProblemsLabelDecorator; 17 18 import org.eclipse.jdt.internal.ui.browsing.LogicalPackage; 19 20 30 public class TreeHierarchyLayoutProblemsDecorator extends ProblemsLabelDecorator { 31 32 private boolean fIsFlatLayout; 33 34 public TreeHierarchyLayoutProblemsDecorator() { 35 this(false); 36 } 37 38 public TreeHierarchyLayoutProblemsDecorator(boolean isFlatLayout) { 39 super(null); 40 fIsFlatLayout= isFlatLayout; 41 } 42 43 protected int computePackageAdornmentFlags(IPackageFragment fragment) { 44 if (!fIsFlatLayout && !fragment.isDefaultPackage()) { 45 return super.computeAdornmentFlags(fragment.getResource()); 46 } 47 return super.computeAdornmentFlags(fragment); 48 } 49 50 53 protected int computeAdornmentFlags(Object element) { 54 if (element instanceof IPackageFragment) { 55 return computePackageAdornmentFlags((IPackageFragment) element); 56 } else if (element instanceof LogicalPackage) { 57 IPackageFragment[] fragments= ((LogicalPackage) element).getFragments(); 58 int res= 0; 59 for (int i= 0; i < fragments.length; i++) { 60 int flags= computePackageAdornmentFlags(fragments[i]); 61 if (flags == JavaElementImageDescriptor.ERROR) { 62 return flags; 63 } else if (flags != 0) { 64 res= flags; 65 } 66 } 67 return res; 68 } 69 return super.computeAdornmentFlags(element); 70 } 71 72 public void setIsFlatLayout(boolean state) { 73 fIsFlatLayout= state; 74 } 75 76 } 77 | Popular Tags |