|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
InspectorButton.java | 0% | 0% | 0% | 0% |
|
1 |
// Copyright 2004, 2005 The Apache Software Foundation
|
|
2 |
//
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
5 |
// You may obtain a copy of the License at
|
|
6 |
//
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8 |
//
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12 |
// See the License for the specific language governing permissions and
|
|
13 |
// limitations under the License.
|
|
14 |
|
|
15 |
package org.apache.tapestry.contrib.inspector;
|
|
16 |
|
|
17 |
import java.util.HashMap;
|
|
18 |
import java.util.Map;
|
|
19 |
|
|
20 |
import org.apache.hivemind.Resource;
|
|
21 |
import org.apache.tapestry.BaseComponent;
|
|
22 |
import org.apache.tapestry.IDirect;
|
|
23 |
import org.apache.tapestry.IEngine;
|
|
24 |
import org.apache.tapestry.IMarkupWriter;
|
|
25 |
import org.apache.tapestry.IRequestCycle;
|
|
26 |
import org.apache.tapestry.IScript;
|
|
27 |
import org.apache.tapestry.PageRenderSupport;
|
|
28 |
import org.apache.tapestry.Tapestry;
|
|
29 |
import org.apache.tapestry.TapestryUtils;
|
|
30 |
import org.apache.tapestry.engine.DirectServiceParameter;
|
|
31 |
import org.apache.tapestry.engine.IEngineService;
|
|
32 |
import org.apache.tapestry.engine.ILink;
|
|
33 |
import org.apache.tapestry.engine.IScriptSource;
|
|
34 |
import org.apache.tapestry.html.Body;
|
|
35 |
|
|
36 |
/**
|
|
37 |
* Component that can be placed into application pages that will launch the inspector in a new
|
|
38 |
* window. [ <a href="../../../../../../ComponentReference/InspectorButton.html">Component Reference
|
|
39 |
* </a>]
|
|
40 |
* <p>
|
|
41 |
* Because the InspectorButton component is implemented using a
|
|
42 |
* {@link org.apache.tapestry.html.Rollover}, the containing page must use a {@link Body}component
|
|
43 |
* instead of a <body> tag.
|
|
44 |
*
|
|
45 |
* @author Howard Lewis Ship
|
|
46 |
*/
|
|
47 |
|
|
48 |
public abstract class InspectorButton extends BaseComponent implements IDirect |
|
49 |
{ |
|
50 |
private boolean _disabled = false; |
|
51 |
|
|
52 |
/**
|
|
53 |
* Gets the listener for the link component.
|
|
54 |
*
|
|
55 |
* @since 1.0.5
|
|
56 |
*/
|
|
57 |
|
|
58 | 0 |
public void trigger(IRequestCycle cycle) |
59 |
{ |
|
60 | 0 |
String name = getNamespace().constructQualifiedName("Inspector");
|
61 |
|
|
62 | 0 |
Inspector inspector = (Inspector) cycle.getPage(name); |
63 |
|
|
64 | 0 |
inspector.inspect(getPage().getPageName(), cycle); |
65 |
} |
|
66 |
|
|
67 |
/**
|
|
68 |
* Renders the script, then invokes the normal implementation.
|
|
69 |
*
|
|
70 |
* @since 1.0.5
|
|
71 |
*/
|
|
72 |
|
|
73 | 0 |
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) |
74 |
{ |
|
75 | 0 |
if (_disabled || cycle.isRewinding())
|
76 | 0 |
return;
|
77 |
|
|
78 | 0 |
IEngine engine = getPage().getEngine(); |
79 | 0 |
IScriptSource source = engine.getScriptSource(); |
80 |
|
|
81 | 0 |
Resource scriptLocation = getSpecification().getSpecificationLocation() |
82 |
.getRelativeResource("InspectorButton.script");
|
|
83 |
|
|
84 | 0 |
IScript script = source.getScript(scriptLocation); |
85 |
|
|
86 | 0 |
Map symbols = new HashMap();
|
87 |
|
|
88 | 0 |
IEngineService service = engine.getService(Tapestry.DIRECT_SERVICE); |
89 | 0 |
ILink link = service.getLink(cycle, new DirectServiceParameter(this)); |
90 |
|
|
91 | 0 |
symbols.put("URL", link.getURL());
|
92 |
|
|
93 | 0 |
PageRenderSupport pageRenderSupport = TapestryUtils.getPageRenderSupport(cycle, this);
|
94 |
|
|
95 | 0 |
script.execute(cycle, pageRenderSupport, symbols); |
96 |
|
|
97 |
// Now, go render the rest from the template.
|
|
98 |
|
|
99 | 0 |
super.renderComponent(writer, cycle);
|
100 |
} |
|
101 |
|
|
102 | 0 |
public boolean isDisabled() |
103 |
{ |
|
104 | 0 |
return _disabled;
|
105 |
} |
|
106 |
|
|
107 | 0 |
public void setDisabled(boolean disabled) |
108 |
{ |
|
109 | 0 |
_disabled = disabled; |
110 |
} |
|
111 |
|
|
112 |
/**
|
|
113 |
* Always returns false.
|
|
114 |
*
|
|
115 |
* @since 2.3
|
|
116 |
*/
|
|
117 |
|
|
118 | 0 |
public boolean isStateful() |
119 |
{ |
|
120 | 0 |
return false; |
121 |
} |
|
122 |
|
|
123 |
} |
|