%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.commons.jelly.tags.jface.JFaceLayoutTag |
|
|
1 | /* |
|
2 | * Copyright 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.commons.jelly.tags.jface; |
|
17 | ||
18 | import org.apache.commons.jelly.JellyTagException; |
|
19 | import org.apache.commons.jelly.tags.jface.window.ApplicationWindowImpl; |
|
20 | import org.apache.commons.jelly.tags.jface.window.ApplicationWindowTag; |
|
21 | import org.apache.commons.jelly.tags.swt.LayoutTag; |
|
22 | import org.eclipse.jface.window.Window; |
|
23 | import org.eclipse.swt.widgets.Composite; |
|
24 | import org.eclipse.swt.widgets.Widget; |
|
25 | ||
26 | /** |
|
27 | * Implementation of SWT LayoutTag |
|
28 | * |
|
29 | * @author <a href="mailto:ckl@dacelo.nl">Christiaan ten Klooster</a> |
|
30 | */ |
|
31 | 0 | public class JFaceLayoutTag extends LayoutTag { |
32 | ||
33 | /** |
|
34 | * @param layoutClass |
|
35 | */ |
|
36 | public JFaceLayoutTag(Class layoutClass) { |
|
37 | 0 | super(layoutClass); |
38 | // TODO Auto-generated constructor stub |
|
39 | 0 | } |
40 | ||
41 | /* (non-Javadoc) |
|
42 | * @see org.apache.commons.jelly.tags.core.UseBeanTag#processBean(java.lang.String, java.lang.Object) |
|
43 | */ |
|
44 | protected void processBean(String var, Object bean) throws JellyTagException { |
|
45 | ||
46 | 0 | Widget parent = getParentWidget(); |
47 | 0 | if (parent == null) { // perhaps parent is a Window |
48 | 0 | Window window = getParentWindow(); |
49 | 0 | if (window != null && window instanceof ApplicationWindowImpl) { |
50 | 0 | parent = ((ApplicationWindowImpl) window).getContents(); |
51 | } |
|
52 | } |
|
53 | ||
54 | 0 | if (parent instanceof Composite) { |
55 | 0 | Composite composite = (Composite) parent; |
56 | 0 | composite.setLayout(getLayout()); |
57 | ||
58 | } else { |
|
59 | 0 | throw new JellyTagException("This tag must be nested within a composite widget tag"); |
60 | } |
|
61 | ||
62 | 0 | } |
63 | ||
64 | /** |
|
65 | * @return the parent window |
|
66 | */ |
|
67 | public Window getParentWindow() { |
|
68 | 0 | ApplicationWindowTag tag = |
69 | (ApplicationWindowTag) findAncestorWithClass(ApplicationWindowTag.class); |
|
70 | 0 | if (tag != null) { |
71 | 0 | return tag.getWindow(); |
72 | } |
|
73 | 0 | return null; |
74 | } |
|
75 | } |
|
76 | ||
77 |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |