1 26 package org.objectweb.util.explorer.resolver.lib; 27 28 import org.objectweb.util.explorer.api.Entry; 29 import org.objectweb.util.explorer.core.common.api.BadParamException; 30 import org.objectweb.util.explorer.core.common.api.Description; 31 import org.objectweb.util.explorer.core.common.api.ExplorerConstants; 32 import org.objectweb.util.explorer.core.common.lib.ClassesInheritance; 33 import org.objectweb.util.explorer.core.panel.api.CompositePanelDescription; 34 import org.objectweb.util.explorer.core.panel.api.PanelDescription; 35 import org.objectweb.util.explorer.core.panel.lib.BasicCompositePanelDescription; 36 37 45 public class PanelResolver 46 extends AbstractPropertyResolver 47 { 48 49 55 61 67 70 protected String getPropertyType() { 71 return ExplorerConstants.PANEL_PROPERTY; 72 } 73 74 79 protected PanelDescription getPanelDesc(Object key){ 80 return (PanelDescription)getPropertyProvider().getPropertyDescription(getPropertyType(), key); 81 } 82 83 88 protected Description getPanelDescription(Entry currentEntry){ 89 CompositePanelDescription desc = null; 90 if(currentEntry!=null && currentEntry.getValue()!=null){ 91 Class [] javaTypes = ClassesInheritance.getInheritedClasses(currentEntry.getValue().getClass()); 92 String [] roleIds = getRoleProvider().getInheritedRoleIds(getRoleManager().getCurrentRoleIds()); 93 for (int i = 0; i < javaTypes.length; i++) { 94 for (int j = 0; j < roleIds.length; j++) { 95 Object key = null; 96 try { 97 key = getKeyProvider().computeKey(new String []{getTypeSystemId(),javaTypes[i].getName(),roleIds[j]}); 98 } catch (BadParamException e) { 99 getTrace().warn("Bad key param: " + e.getMessage()); 100 } 101 if(key!=null){ 102 PanelDescription newPanelDesc = getPanelDesc(key); 103 if(newPanelDesc!=null){ 104 if(desc==null){ 105 desc = new BasicCompositePanelDescription(); 106 } 107 desc.addPanelDescription(newPanelDesc); 108 } 109 if(newPanelDesc!=null) break; 110 } 111 } 112 if(desc!=null && !desc.inheritTypePanel()) break; 113 } 114 } 115 return desc; 116 } 117 118 124 127 public Description resolve(String propertyType, Entry currentEntry, Entry parentEntry) { 128 return getPanelDescription(currentEntry); 129 } 130 131 } 132 133 134 | Popular Tags |