KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > event > impl > FullScreenCopletEvent


1 /*
2  * Copyright 1999-2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.portal.event.impl;
17
18 import org.apache.cocoon.portal.coplet.CopletInstanceData;
19 import org.apache.cocoon.portal.event.RequestEvent;
20 import org.apache.cocoon.portal.event.ConvertableEvent;
21 import org.apache.cocoon.portal.layout.Layout;
22 import org.apache.cocoon.portal.PortalService;
23
24 /**
25  * EventSource: copletID
26  *
27  * @author <a HREF="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
28  * @author <a HREF="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
29  *
30  * @version CVS $Id: FullScreenCopletEvent.java 219049 2005-07-14 15:11:52Z cziegeler $
31  */

32 public class FullScreenCopletEvent
33     extends CopletStatusEvent
34     implements RequestEvent, ConvertableEvent {
35
36     public static final String JavaDoc REQUEST_PARAMETER_NAME = "cocoon-portal-fs";
37
38     protected Layout layout;
39
40     public FullScreenCopletEvent(CopletInstanceData data, Layout layout) {
41         this.coplet = data;
42         this.layout = layout;
43     }
44
45     FullScreenCopletEvent(PortalService service, String JavaDoc eventData) {
46         int index = eventData.indexOf('_');
47         String JavaDoc copletId;
48         if (index > 0) {
49             copletId = eventData.substring(0, index);
50             this.coplet =
51                 service.getComponentManager().getProfileManager().getCopletInstanceData(copletId);
52             if (eventData.length() > index + 1) {
53                 String JavaDoc layoutId = eventData.substring(index + 1);
54                 this.layout =
55                     service.getComponentManager().getProfileManager().getPortalLayout(null, layoutId);
56             }
57         } else {
58             this.layout = null;
59             this.coplet =
60                 service.getComponentManager().getProfileManager().getCopletInstanceData(eventData);
61         }
62     }
63
64     /* (non-Javadoc)
65      * @see org.apache.cocoon.portal.event.RequestEvent#getRequestParameterName()
66      */

67     public String JavaDoc getRequestParameterName() {
68         return REQUEST_PARAMETER_NAME;
69     }
70
71     public Layout getLayout() {
72         return this.layout;
73     }
74
75     public String JavaDoc asString() {
76         if (this.layout == null) {
77             return this.coplet.getId();
78         }
79         String JavaDoc layoutId = this.layout.getId();
80         if (layoutId == null) {
81             // Without a layout id this can't be marshalled.
82
return null;
83         }
84         return this.coplet.getId() + "_" + layoutId;
85     }
86 }
Popular Tags