1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.apache.jetspeed.decoration; |
18 |
|
|
19 |
|
import java.util.ArrayList; |
20 |
|
import java.util.Collections; |
21 |
|
import java.util.List; |
22 |
|
|
23 |
|
import javax.portlet.PortletMode; |
24 |
|
import javax.portlet.WindowState; |
25 |
|
|
26 |
|
import org.apache.jetspeed.JetspeedActions; |
27 |
|
import org.apache.jetspeed.om.common.portlet.PortletApplication; |
28 |
|
import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite; |
29 |
|
import org.apache.jetspeed.om.page.ContentFragment; |
30 |
|
import org.apache.jetspeed.request.RequestContext; |
31 |
|
import org.apache.jetspeed.security.SecurityAccessController; |
32 |
|
import org.apache.pluto.om.window.PortletWindow; |
33 |
|
|
34 |
|
public class PrintSoloDecoratorActionsFactory extends AbstractDecoratorActionsFactory |
35 |
|
{ |
36 |
0 |
private static final DecoratorActionTemplate PRINT_MODE_TEMPLATE = new DecoratorActionTemplate(JetspeedActions.PRINT_MODE); |
37 |
0 |
private static final DecoratorActionTemplate SOLO_ACTION_TEMPLATE = new DecoratorActionTemplate(JetspeedActions.SOLO_STATE); |
38 |
|
|
39 |
|
private final List supportedActions; |
40 |
|
private final List supportedSoloActions; |
41 |
|
|
42 |
|
public PrintSoloDecoratorActionsFactory() |
43 |
0 |
{ |
44 |
0 |
ArrayList list = new ArrayList(JetspeedActions.getStandardPortletModes()); |
45 |
0 |
list.add(JetspeedActions.PRINT_MODE); |
46 |
0 |
list.addAll(JetspeedActions.getStandardWindowStates()); |
47 |
0 |
list.add(JetspeedActions.SOLO_STATE); |
48 |
0 |
supportedActions = Collections.unmodifiableList(list); |
49 |
0 |
list = new ArrayList(JetspeedActions.getStandardPortletModes()); |
50 |
0 |
list.add(JetspeedActions.PRINT_MODE); |
51 |
0 |
supportedSoloActions = Collections.unmodifiableList(list); |
52 |
0 |
} |
53 |
|
|
54 |
|
public List getSupportedActions(RequestContext rc, PortletApplication pa, PortletWindow pw, PortletMode cm, |
55 |
|
WindowState ws, Decoration decoration) |
56 |
|
{ |
57 |
|
|
58 |
0 |
return JetspeedActions.SOLO_STATE.equals(ws) ? supportedSoloActions : supportedActions; |
59 |
|
} |
60 |
|
|
61 |
|
public List getDecoratorActions(RequestContext rc, PortletApplication pa, PortletWindow pw, PortletMode pm, |
62 |
|
WindowState ws, Decoration decoration, List actionTemplates, |
63 |
|
PortletDefinitionComposite portlet, ContentFragment fragment, SecurityAccessController accessController) |
64 |
|
{ |
65 |
0 |
int prclass="keyword">intModeIndex = actionTemplates.indexOf(PRINT_MODE_TEMPLATE); |
66 |
0 |
int soloStateIndex = actionTemplates.indexOf(SOLO_ACTION_TEMPLATE); |
67 |
|
|
68 |
0 |
if ( printModeIndex != -1 && soloStateIndex != -1 ) |
69 |
|
{ |
70 |
|
|
71 |
0 |
DecoratorActionTemplate soloStateTemplate = (DecoratorActionTemplate)actionTemplates.remove(soloStateIndex); |
72 |
0 |
DecoratorActionTemplate printActionTemplate = (DecoratorActionTemplate)actionTemplates.get(printModeIndex); |
73 |
0 |
printActionTemplate.setState(soloStateTemplate.getState()); |
74 |
0 |
printActionTemplate.setCustomState((soloStateTemplate.getCustomState())); |
75 |
0 |
} |
76 |
0 |
else if ( soloStateIndex != -1 ) |
77 |
|
{ |
78 |
|
|
79 |
0 |
actionTemplates.remove(soloStateIndex); |
80 |
|
} |
81 |
|
|
82 |
|
|
83 |
0 |
return super.getDecoratorActions(rc,pa,pw,pm,ws,decoration,actionTemplates, portlet, fragment, accessController); |
84 |
|
} |
85 |
|
|
86 |
|
protected DecoratorAction createAction(RequestContext rc, PortletWindow pw, Decoration decoration, |
87 |
|
DecoratorActionTemplate template) |
88 |
|
{ |
89 |
0 |
DecoratorAction action = super.createAction(rc,pw,decoration,template); |
90 |
0 |
if ( template.getState() != null && JetspeedActions.SOLO_STATE.equals(template.getState())) |
91 |
|
{ |
92 |
|
|
93 |
0 |
action.setTarget("_blank"); |
94 |
|
} |
95 |
0 |
return action; |
96 |
|
} |
97 |
|
} |