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.ContentPage; |
30 |
|
import org.apache.jetspeed.om.page.ContentFragment; |
31 |
|
import org.apache.jetspeed.request.RequestContext; |
32 |
|
import org.apache.jetspeed.security.SecurityAccessController; |
33 |
|
import org.apache.pluto.om.window.PortletWindow; |
34 |
|
|
35 |
|
public class CustomDecoratorActionsFactory extends AbstractDecoratorActionsFactory |
36 |
|
{ |
37 |
0 |
private static final DecoratorActionTemplate ABOUT_MODE_TEMPLATE = new DecoratorActionTemplate(JetspeedActions.ABOUT_MODE); |
38 |
0 |
private static final DecoratorActionTemplate CONFIG_MODE_TEMPLATE = new DecoratorActionTemplate(JetspeedActions.CONFIG_MODE); |
39 |
0 |
private static final DecoratorActionTemplate EDIT_DEFAULTS_MODE_TEMPLATE = new DecoratorActionTemplate(JetspeedActions.EDIT_DEFAULTS_MODE); |
40 |
|
|
41 |
0 |
private static final DecoratorActionTemplate PRINT_MODE_TEMPLATE = new DecoratorActionTemplate(JetspeedActions.PRINT_MODE); |
42 |
0 |
private static final DecoratorActionTemplate SOLO_ACTION_TEMPLATE = new DecoratorActionTemplate(JetspeedActions.SOLO_STATE); |
43 |
|
|
44 |
|
private final List supportedActions; |
45 |
|
private final List supportedSoloActions; |
46 |
|
|
47 |
|
public CustomDecoratorActionsFactory() |
48 |
0 |
{ |
49 |
0 |
ArrayList list = new ArrayList(JetspeedActions.getStandardPortletModes()); |
50 |
0 |
list.add(JetspeedActions.ABOUT_MODE); |
51 |
0 |
list.add(JetspeedActions.CONFIG_MODE); |
52 |
0 |
list.add(JetspeedActions.EDIT_DEFAULTS_MODE); |
53 |
|
|
54 |
0 |
list.add(JetspeedActions.PRINT_MODE); |
55 |
0 |
list.addAll(JetspeedActions.getStandardWindowStates()); |
56 |
0 |
list.add(JetspeedActions.SOLO_STATE); |
57 |
0 |
supportedActions = Collections.unmodifiableList(list); |
58 |
|
|
59 |
0 |
list = new ArrayList(JetspeedActions.getStandardPortletModes()); |
60 |
0 |
list.add(JetspeedActions.PRINT_MODE); |
61 |
0 |
supportedSoloActions = Collections.unmodifiableList(list); |
62 |
0 |
} |
63 |
|
|
64 |
|
public List getSupportedActions(RequestContext rc, PortletApplication pa, PortletWindow pw, PortletMode cm, |
65 |
|
WindowState ws, Decoration decoration) |
66 |
|
{ |
67 |
|
|
68 |
0 |
return JetspeedActions.SOLO_STATE.equals(ws) ? supportedSoloActions : supportedActions; |
69 |
|
} |
70 |
|
|
71 |
|
public List getDecoratorActions(RequestContext rc, PortletApplication pa, PortletWindow pw, PortletMode pm, |
72 |
|
WindowState ws, Decoration decoration, List actionTemplates, |
73 |
|
PortletDefinitionComposite portlet, ContentFragment fragment, SecurityAccessController accessController) |
74 |
|
{ |
75 |
0 |
int prclass="keyword">intModeIndex = actionTemplates.indexOf(PRINT_MODE_TEMPLATE); |
76 |
0 |
int soloStateIndex = actionTemplates.indexOf(SOLO_ACTION_TEMPLATE); |
77 |
|
|
78 |
0 |
if ( printModeIndex != -1 && soloStateIndex != -1 ) |
79 |
|
{ |
80 |
|
|
81 |
0 |
DecoratorActionTemplate soloStateTemplate = (DecoratorActionTemplate)actionTemplates.remove(soloStateIndex); |
82 |
0 |
DecoratorActionTemplate printActionTemplate = (DecoratorActionTemplate)actionTemplates.get(printModeIndex); |
83 |
0 |
printActionTemplate.setState(soloStateTemplate.getState()); |
84 |
0 |
printActionTemplate.setCustomState((soloStateTemplate.getCustomState())); |
85 |
0 |
} |
86 |
0 |
else if ( soloStateIndex != -1 ) |
87 |
|
{ |
88 |
|
|
89 |
0 |
actionTemplates.remove(soloStateIndex); |
90 |
|
} |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
0 |
int configModeIndex = actionTemplates.indexOf(CONFIG_MODE_TEMPLATE); |
95 |
0 |
if (configModeIndex != -1) |
96 |
|
{ |
97 |
|
try |
98 |
|
{ |
99 |
0 |
ContentPage page = rc.getPage(); |
100 |
0 |
page.checkAccess(JetspeedActions.CONFIG); |
101 |
|
} |
102 |
0 |
catch (SecurityException e) |
103 |
|
{ |
104 |
0 |
actionTemplates.remove(configModeIndex); |
105 |
0 |
} |
106 |
|
} |
107 |
|
|
108 |
0 |
int editDefaultsModeIndex = actionTemplates.indexOf(EDIT_DEFAULTS_MODE_TEMPLATE); |
109 |
0 |
if (editDefaultsModeIndex != -1) |
110 |
|
{ |
111 |
|
try |
112 |
|
{ |
113 |
0 |
ContentPage page = rc.getPage(); |
114 |
0 |
page.checkAccess(JetspeedActions.EDIT_DEFAULTS); |
115 |
|
} |
116 |
0 |
catch (SecurityException e) |
117 |
|
{ |
118 |
0 |
actionTemplates.remove(editDefaultsModeIndex); |
119 |
0 |
} |
120 |
|
} |
121 |
|
|
122 |
0 |
return super.getDecoratorActions(rc,pa,pw,pm,ws,decoration,actionTemplates, portlet, fragment, accessController); |
123 |
|
} |
124 |
|
|
125 |
|
protected DecoratorAction createAction(RequestContext rc, PortletWindow pw, Decoration decoration, |
126 |
|
DecoratorActionTemplate template) |
127 |
|
{ |
128 |
0 |
DecoratorAction action = super.createAction(rc,pw,decoration,template); |
129 |
0 |
if ( template.getState() != null && JetspeedActions.SOLO_STATE.equals(template.getState())) |
130 |
|
{ |
131 |
|
|
132 |
0 |
action.setTarget("_blank"); |
133 |
|
} |
134 |
0 |
return action; |
135 |
|
} |
136 |
|
} |