1 9 package org.jboss.portal.server; 10 11 import java.util.Collection ; 12 import java.util.HashSet ; 13 import java.util.Set ; 14 15 import org.jboss.portal.server.kernel.Service; 16 import org.jboss.portal.server.kernel.ServiceImplementation; 17 import org.jboss.portal.server.metadata.ServerObjectMetaData; 18 import org.jboss.portal.server.metadata.WindowMetaData; 19 import org.jboss.portal.server.plugins.mode.ContentTypes; 20 import org.jboss.portal.server.plugins.mode.Mode; 21 import org.jboss.portal.server.plugins.mode.ModeProvider; 22 import org.jboss.portal.server.plugins.windowstate.WindowState; 23 import org.jboss.portal.server.plugins.windowstate.WindowStateProvider; 24 import org.jboss.portal.server.user.ServerObjectContext; 25 26 32 public class Window extends ServerObject 33 { 34 35 protected Portal portal; 36 protected Instance instance; 37 protected WindowMetaData metaData; 38 39 public Window(WindowMetaData metaData) 40 { 41 super(metaData.getName()); 42 this.metaData = metaData; 43 } 44 45 public ServerObjectContext createContext() 46 { 47 return new WindowContext(getID()); 48 } 49 50 public ServerObjectMetaData getMetaData() 51 { 52 return metaData; 53 } 54 55 public PortalServer getServer() 56 { 57 return instance.getServer(); 58 } 59 60 63 public Portal getPortal() 64 { 65 return portal; 66 } 67 68 71 public Instance getInstance() 72 { 73 return instance; 74 } 75 76 public void addIDependOn(ServiceImplementation implementation) 77 { 78 Service service = implementation.getService(); 79 if (service instanceof Instance) 80 { 81 instance = (Instance)service; 82 } 83 else if (service instanceof Portal) 84 { 85 portal = (Portal)service; 86 } 87 else 88 { 89 super.addIDependOn(implementation); 90 } 91 } 92 93 public void removeIDependOn(ServiceImplementation implementation) 94 { 95 Service service = implementation.getService(); 96 if (service instanceof Instance) 97 { 98 instance = null; 99 } 100 else if (service instanceof Portal) 101 { 102 portal = null; 103 } 104 else 105 { 106 super.removeIDependOn(implementation); 107 } 108 } 109 110 113 public Collection getSupportedModes(String contentType) 114 { 115 Component component = getInstance().getComponent(); 116 ContentTypes contentTypes = component.getContentTypes(); 117 Set componentModes = contentTypes.getSupportedModes(contentType); 118 Set tmp = new HashSet (componentModes); 119 120 ModeProvider modes = portal.getModeProvider(); 122 tmp.retainAll(modes.getModes()); 123 return tmp; 124 } 125 126 131 public boolean isSupportedMode(String contentType, Mode mode) 132 { 133 Component component = instance.getComponent(); 135 ContentTypes contentTypes = component.getContentTypes(); 136 137 if (!contentTypes.isSupported(mode, contentType)) 139 { 140 return false; 141 } 142 143 ModeProvider portalProvider = portal.getModeProvider(); 145 return portalProvider.containsMode(mode); 146 } 147 148 151 public boolean isSupportedWindowState(WindowState windowState) 152 { 153 WindowStateProvider windowStates = portal.getWindowStateProvider(); 155 156 return windowStates.containsWindowState(windowState); 158 } 159 160 163 public Set getSupportedWindowStates() 164 { 165 return portal.getWindowStateProvider().getWindowStates(); 166 } 167 168 public ServerURL createURL() 170 { 171 WindowURL windowURL = new WindowURL(getID()); 172 return windowURL; 173 } 174 } 175 | Popular Tags |