18 package org.turro.zul.portal;
20 import java.util.logging.Level;
21 import java.util.logging.Logger;
22 import org.jdom.Element;
23 import org.turro.elephant.context.ElephantContext;
24 import org.zkoss.zk.ui.Component;
25 import org.zkoss.zk.ui.ext.AfterCompose;
26 import org.zkoss.zul.Panel;
27 import org.zkoss.zul.Panelchildren;
33 public class PortalContent extends Panel implements Comparable, AfterCompose {
35 private Integer order;
38 public void load(Element root) {
39 order = Integer.valueOf(root.getAttributeValue(
"order",
"0"));
40 setTitle(root.getAttributeValue(
"title"));
41 setBorder(root.getAttributeValue(
"border",
"normal"));
42 setHeight(root.getAttributeValue(
"height",
"300px"));
43 setStyle(root.getAttributeValue(
"style",
""));
44 setCollapsible(Boolean.valueOf(root.getAttributeValue(
"collapsible",
"true")));
45 setMaximizable(Boolean.valueOf(root.getAttributeValue(
"maximizable",
"true")));
46 setMovable(Boolean.valueOf(root.getAttributeValue(
"movable",
"true")));
47 setClosable(Boolean.valueOf(root.getAttributeValue(
"closable",
"true")));
48 createInstance(root.getChild(
"content"));
49 if(content instanceof Component) {
50 Panelchildren children =
new Panelchildren();
51 appendChild(children);
52 children.appendChild((Component) content);
56 public void save(Element root) {
57 root.setAttribute(
"order", getPosition(order) +
"");
58 root.setAttribute(
"title", getTitle());
59 root.setAttribute(
"border", getBorder());
60 root.setAttribute(
"height", getHeight());
61 if(getStyle() !=
null) {
62 root.setAttribute(
"style", getStyle());
64 root.setAttribute(
"collapsible", Boolean.toString(isCollapsible()));
65 root.setAttribute(
"maximizable", Boolean.toString(isMaximizable()));
66 root.setAttribute(
"movable", Boolean.toString(isMovable()));
67 root.setAttribute(
"closable", Boolean.toString(isClosable()));
69 Element el =
new Element(
"content");
70 el.setAttribute(
"java-class", content.getClass().getName());
84 private void createInstance(Element root) {
85 if(root ==
null)
return;
88 String jClass = root.getAttributeValue(
"java-class");
89 Class cls = Class.forName(jClass);
91 java.lang.reflect.Constructor cons = cls.getConstructor(
new Class[] {});
93 impl = cons.newInstance(
new Object[] {});
96 if(impl instanceof IPortalContent) {
97 content = (IPortalContent) impl;
100 }
catch(Exception ex) {
101 Logger.getLogger(PortalContent.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(
null), ex);
105 private int getPosition(
int order) {
106 if(getParent() ==
null) {
109 int pos = getParent().getChildren().indexOf(
this);
118 if(content instanceof AfterCompose) {
119 ((AfterCompose) content).afterCompose();
void getConfiguration(Element root)
void setConfiguration(Element root)