Author: nbelaevski
Date: 2010-07-12 13:56:20 -0400 (Mon, 12 Jul 2010)
New Revision: 17973
Added:
root/ui/output/trunk/panels/ui/src/main/java/org/richfaces/component/UIPanel.java
root/ui/output/trunk/panels/ui/src/main/java/org/richfaces/component/UIPopupPanel.java
root/ui/output/trunk/panels/ui/src/main/java/org/richfaces/renderkit/html/PanelBaseRenderer.java
root/ui/output/trunk/panels/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/MANIFEST.MF
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/css/
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/css/panel.ecss
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/css/popupPanel.ecss
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/faces-config.xml
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/images/
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/images/bg_header.png
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/images/close_act.gif
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/images/edit.gif
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/panels.taglib.xml
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/script/
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/script/popupPanel.js
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/script/popupPanelBorders.js
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/script/popupPanelSizer.js
root/ui/output/trunk/panels/ui/src/main/templates/
root/ui/output/trunk/panels/ui/src/main/templates/panel.template.xml
root/ui/output/trunk/panels/ui/src/main/templates/popupPanel.template.xml
root/ui/output/trunk/panels/ui/src/test/java/org/richfaces/renderkit/html/PanelRendererTest.java
root/ui/output/trunk/panels/ui/src/test/java/org/richfaces/renderkit/html/PopupRendererTest.java
root/ui/output/trunk/panels/ui/src/test/resources/
root/ui/output/trunk/panels/ui/src/test/resources/panelTest.xhtml
root/ui/output/trunk/panels/ui/src/test/resources/popupPanelText.xhtml
Modified:
root/ui/output/trunk/bom/pom.xml
Log:
Moved ui-sandbox/panels2/ui module
Modified: root/ui/output/trunk/bom/pom.xml
===================================================================
--- root/ui/output/trunk/bom/pom.xml 2010-07-12 17:52:44 UTC (rev 17972)
+++ root/ui/output/trunk/bom/pom.xml 2010-07-12 17:56:20 UTC (rev 17973)
@@ -36,6 +36,7 @@
<properties>
<org.richfaces.core.version>4.0.0-SNAPSHOT</org.richfaces.core.version>
+
<org.richfaces.ui.core.version>4.0.0-SNAPSHOT</org.richfaces.ui.core.version>
</properties>
<dependencyManagement>
@@ -49,6 +50,14 @@
</dependency>
<dependency>
+ <groupId>org.richfaces.ui.core</groupId>
+ <artifactId>richfaces-ui-core-bom</artifactId>
+ <version>${org.richfaces.ui.core.version}</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
<groupId>org.richfaces.ui.output</groupId>
<artifactId>richfaces-ui-output-ui</artifactId>
<version>${project.version}</version>
Copied: root/ui/output/trunk/panels/ui/src/main/java/org/richfaces/component/UIPanel.java
(from rev 17965,
root/ui-sandbox/panels2/trunk/ui/src/main/java/org/richfaces/component/UIPanel.java)
===================================================================
--- root/ui/output/trunk/panels/ui/src/main/java/org/richfaces/component/UIPanel.java
(rev 0)
+++
root/ui/output/trunk/panels/ui/src/main/java/org/richfaces/component/UIPanel.java 2010-07-12
17:56:20 UTC (rev 17973)
@@ -0,0 +1,41 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import javax.faces.component.UIComponentBase;
+
+/**
+ * JSF component class
+ *
+ */
+public class UIPanel extends UIComponentBase {
+ private static final String COMPONENT_FAMILY = "org.richfaces.Panel";
+
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+}
Copied:
root/ui/output/trunk/panels/ui/src/main/java/org/richfaces/component/UIPopupPanel.java
(from rev 17965,
root/ui-sandbox/panels2/trunk/ui/src/main/java/org/richfaces/component/UIPopupPanel.java)
===================================================================
---
root/ui/output/trunk/panels/ui/src/main/java/org/richfaces/component/UIPopupPanel.java
(rev 0)
+++
root/ui/output/trunk/panels/ui/src/main/java/org/richfaces/component/UIPopupPanel.java 2010-07-12
17:56:20 UTC (rev 17973)
@@ -0,0 +1,280 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponentBase;
+
+import org.richfaces.json.JSONException;
+import org.richfaces.json.JSONMap;
+
+/**
+ * JSF component class
+ *
+ */
+public class UIPopupPanel extends UIComponentBase {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.PopupPanel";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.PopupPanel";
+
+ protected enum PropertyKeys {
+ width, height, zIndex, minHeight, minWidth, maxHeight, maxWidth, top, left,
moveable, autosized, modal, domElementAttachment, controlsClass, show, headerClass,
keepVisualState, overlapEmbedObjects, resizeable, shadowDepth, shadowOpacity, style,
styleClass, visualOptions
+ }
+
+ public Map<String, Object> getHandledVisualOptions() {
+ String options = (String) getStateHelper().eval(PropertyKeys.visualOptions);
+ Map<String, Object> result;
+ result = prepareVisualOptions(options);
+
+ if (null == result) {
+ result = new HashMap<String, Object>();
+ }
+ return result;
+ }
+
+ public String getVisualOptions() {
+ return (String) getStateHelper().eval(PropertyKeys.visualOptions);
+ }
+
+ public void setVisualOptions(String visualOptions) {
+ getStateHelper().put(PropertyKeys.visualOptions, visualOptions);
+ }
+
+ public int getZIndex() {
+ return (Integer) getStateHelper().eval(PropertyKeys.zIndex, 100);
+ }
+
+ public void setZIndex(int zIndex) {
+ getStateHelper().put(PropertyKeys.zIndex, zIndex);
+ }
+
+ public int getHeight() {
+ return (Integer) getStateHelper().eval(PropertyKeys.height, -1);
+ }
+
+ public void setHeight(int height) {
+ getStateHelper().put(PropertyKeys.height, height);
+ }
+
+ public int getWidth() {
+ return (Integer) getStateHelper().eval(PropertyKeys.width, -1);
+ }
+
+ public void setWidth(int width) {
+ getStateHelper().put(PropertyKeys.width, width);
+ }
+
+ public int getMinHeight() {
+ return (Integer) getStateHelper().eval(PropertyKeys.minHeight, -1);
+ }
+
+ public void setMinHeight(int minheight) {
+ getStateHelper().put(PropertyKeys.minHeight, minheight);
+ }
+
+ public int getMinWidth() {
+ return (Integer) getStateHelper().eval(PropertyKeys.minWidth, -1);
+ }
+
+ public void setMinWidth(int minWidth) {
+ getStateHelper().put(PropertyKeys.minWidth, minWidth);
+ }
+
+ public int getMaxHeight() {
+ return (Integer) getStateHelper().eval(PropertyKeys.maxHeight,
Integer.MAX_VALUE);
+ }
+
+ public void setMaxHeight(int maxheight) {
+ getStateHelper().put(PropertyKeys.maxHeight, maxheight);
+ }
+
+ public int getMaxWidth() {
+ return (Integer) getStateHelper().eval(PropertyKeys.maxWidth,
Integer.MAX_VALUE);
+ }
+
+ public void setMaxWidth(int maxWidth) {
+ getStateHelper().put(PropertyKeys.maxWidth, maxWidth);
+ }
+
+ public String getTop() {
+ return (String) getStateHelper().eval(PropertyKeys.top, "auto");
+ }
+
+ public void setTop(String top) {
+ getStateHelper().put(PropertyKeys.top, top);
+ }
+
+ public String getLeft() {
+ return (String) getStateHelper().eval(PropertyKeys.left, "auto");
+ }
+
+ public void setLeft(String left) {
+ getStateHelper().put(PropertyKeys.left, left);
+ }
+
+ public boolean isShow() {
+ return (Boolean) getStateHelper().eval(PropertyKeys.show, false);
+ }
+
+ public void setShow(boolean show) {
+ getStateHelper().put(PropertyKeys.show, show);
+ }
+
+ public boolean isMoveable() {
+ return (Boolean) getStateHelper().eval(PropertyKeys.moveable, true);
+ }
+
+ public void setMoveable(boolean moveable) {
+ getStateHelper().put(PropertyKeys.moveable, moveable);
+ }
+
+ public boolean isAutosized() {
+ return (Boolean) getStateHelper().eval(PropertyKeys.autosized, false);
+ }
+
+ public void setAutosized(boolean autosized) {
+ getStateHelper().put(PropertyKeys.autosized, autosized);
+ }
+
+ public boolean isModal() {
+ return (Boolean) getStateHelper().eval(PropertyKeys.modal, true);
+ }
+
+ public void setModal(boolean modal) {
+ getStateHelper().put(PropertyKeys.modal, modal);
+ }
+
+ public boolean isKeepVisualState() {
+ return (Boolean) getStateHelper().eval(PropertyKeys.keepVisualState, false);
+ }
+
+ public void setKeepVisualState(boolean keepVisualState) {
+ getStateHelper().put(PropertyKeys.keepVisualState, keepVisualState);
+ }
+
+ public boolean isOverlapEmbedObjects() {
+ return (Boolean) getStateHelper().eval(PropertyKeys.overlapEmbedObjects, false);
+ }
+
+ public void setOverlapEmbedObjects(boolean overlapEmbedObjects) {
+ getStateHelper().put(PropertyKeys.overlapEmbedObjects, overlapEmbedObjects);
+ }
+
+ public boolean isResizeable() {
+ return (Boolean) getStateHelper().eval(PropertyKeys.resizeable, true);
+ }
+
+ public void setResizeable(boolean resizeable) {
+ getStateHelper().put(PropertyKeys.resizeable, resizeable);
+ }
+
+ /*
+ * public boolean isTrimOverlayedElements() { return (Boolean)
+ * getStateHelper().eval(PropertyKeys.trimOverlayedElements, false); }
+ *
+ * public void setTrimOverlayedElements(boolean trimOverlayedElements) {
+ * getStateHelper().put(PropertyKeys.trimOverlayedElements, trimOverlayedElements);
}
+ */
+
+ public String getDomElementAttachment() {
+ return (String) getStateHelper().eval(PropertyKeys.domElementAttachment);
+ }
+
+ public void setDomElementAttachment(String domElementAttachment) {
+ getStateHelper().put(PropertyKeys.domElementAttachment, domElementAttachment);
+ }
+
+ public String getControlsClass() {
+ return (String) getStateHelper().eval(PropertyKeys.controlsClass);
+ }
+
+ public void setControlsClass(String controlsClass) {
+ getStateHelper().put(PropertyKeys.controlsClass, controlsClass);
+ }
+
+ /*
+ * public String getLabel() { return (String)
getStateHelper().eval(PropertyKeys.label); }
+ *
+ * public void setLabel(String label) { getStateHelper().put(PropertyKeys.label,
label); }
+ */
+
+ public String getHeaderClass() {
+ return (String) getStateHelper().eval(PropertyKeys.headerClass);
+ }
+
+ public void setHeaderClass(String headerClass) {
+ getStateHelper().put(PropertyKeys.headerClass, headerClass);
+ }
+
+ /*
+ * public String getScrollerClass() { return (String)
getStateHelper().eval(PropertyKeys.scrollerClass); }
+ *
+ * public void setScrollerClass(String scrollerClass) {
getStateHelper().put(PropertyKeys.scrollerClass,
+ * scrollerClass); }
+ */
+
+ public String getShadowDepth() {
+ return (String) getStateHelper().eval(PropertyKeys.shadowDepth);
+ }
+
+ public void setShadowDepth(String shadowDepth) {
+ getStateHelper().put(PropertyKeys.shadowDepth, shadowDepth);
+ }
+
+ public String getShadowOpacity() {
+ return (String) getStateHelper().eval(PropertyKeys.shadowOpacity);
+ }
+
+ public void setShadowOpacity(String shadowOpacity) {
+ getStateHelper().put(PropertyKeys.shadowOpacity, shadowOpacity);
+ }
+
+ private Map<String, Object> prepareVisualOptions(Object value) {
+ if (null == value) {
+ return new HashMap<String, Object>();
+ } else if (value instanceof Map) {
+ return (Map<String, Object>) value;
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (!s.startsWith("{")) {
+ s = "{" + s + "}";
+ }
+ try {
+ return new HashMap<String, Object>(new JSONMap(s));
+ } catch (JSONException e) {
+ throw new FacesException(e);
+ }
+ } else {
+ throw new FacesException("Attribute visualOptions of component [" +
this.getClientId(getFacesContext())
+ + "] must be instance of Map or String, but its type is " +
value.getClass().getSimpleName());
+ }
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+}
Copied:
root/ui/output/trunk/panels/ui/src/main/java/org/richfaces/renderkit/html/PanelBaseRenderer.java
(from rev 17965,
root/ui-sandbox/panels2/trunk/ui/src/main/java/org/richfaces/renderkit/html/PanelBaseRenderer.java)
===================================================================
---
root/ui/output/trunk/panels/ui/src/main/java/org/richfaces/renderkit/html/PanelBaseRenderer.java
(rev 0)
+++
root/ui/output/trunk/panels/ui/src/main/java/org/richfaces/renderkit/html/PanelBaseRenderer.java 2010-07-12
17:56:20 UTC (rev 17973)
@@ -0,0 +1,52 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.renderkit.RendererBase;
+import org.richfaces.component.UIPanel;
+
+/**
+ * @author amarkhel
+ * @since Jun 14, 2010
+ */
+@ResourceDependency(name = "css/panel.ecss")
+public class PanelBaseRenderer extends RendererBase {
+
+ public PanelBaseRenderer() {
+ }
+
+ public void renderHeaderFacet(FacesContext context, UIComponent component) throws
IOException {
+ UIComponent headerFacet = component.getFacet("header");
+ headerFacet.encodeAll(context);
+ }
+
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return UIPanel.class;
+ }
+}
Copied:
root/ui/output/trunk/panels/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java
(from rev 17965,
root/ui-sandbox/panels2/trunk/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java)
===================================================================
---
root/ui/output/trunk/panels/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java
(rev 0)
+++
root/ui/output/trunk/panels/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java 2010-07-12
17:56:20 UTC (rev 17973)
@@ -0,0 +1,241 @@
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.richfaces.component.UIPopupPanel;
+
+@ResourceDependencies( { @ResourceDependency(name = "jquery.js"),
@ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(name = "richfaces-base-component.js"),
@ResourceDependency(name = "script/popupPanel.js"),
+ @ResourceDependency(name = "script/popupPanelBorders.js"),
@ResourceDependency(name = "script/popupPanelSizer.js"),
+ @ResourceDependency(name = "css/popupPanel.ecss")
+
+})
+public class PopupPanelBaseRenderer extends RendererBase {
+
+ private static final String CONTROLS_FACET = "controls";
+ private static final String HEADER_FACET = "header";
+ private static final int SIZE = 10;
+ private static final String STATE_OPTION_SUFFIX = "StateOption_";
+ private static final Set<String> ALLOWED_ATTACHMENT_OPTIONS = new
HashSet<String>();
+ static {
+ ALLOWED_ATTACHMENT_OPTIONS.add("body");
+ ALLOWED_ATTACHMENT_OPTIONS.add("parent");
+ ALLOWED_ATTACHMENT_OPTIONS.add("form");
+ }
+
+ public void renderHeaderFacet(FacesContext context, UIComponent component) throws
IOException {
+ renderFacet(context, component, HEADER_FACET);
+ }
+
+ public void renderControlsFacet(FacesContext context, UIComponent component) throws
IOException {
+ renderFacet(context, component, CONTROLS_FACET);
+ }
+
+ private void renderFacet(FacesContext context, UIComponent component, String facet)
throws IOException {
+ UIComponent headerFacet = component.getFacet(facet);
+ headerFacet.encodeAll(context);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void doDecode(FacesContext context, UIComponent component) {
+ super.doDecode(context, component);
+
+ UIPopupPanel panel = (UIPopupPanel) component;
+ ExternalContext exCtx = context.getExternalContext();
+ Map<String, String> rqMap = exCtx.getRequestParameterMap();
+ Object panelOpenState = rqMap.get(panel.getClientId(context) +
"OpenedState");
+
+ if (panel.isKeepVisualState()) {
+ if (null != panelOpenState) {
+ // Bug
https://jira.jboss.org/jira/browse/RF-2466
+ // Incorrect old:
+ // panel.setShowWhenRendered(Boolean.parseBoolean((String) clnId));
+ // ShowWhenRendered can be settled separately with modal panel
"showWhenRendered" attribute
+ // so we should combine ShowWhenRendered || KeepVisualState &&
(OpenedState==TRUE) against rewriting
+ boolean show = panel.isShow() || Boolean.parseBoolean((String)
panelOpenState);
+ panel.setShow(show);
+
+ Map<String, Object> visualOptions = (Map<String, Object>)
panel.getHandledVisualOptions();
+ Iterator<Entry<String, String>> it =
rqMap.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry<String, String> entry = it.next();
+ int suffixPos =
entry.getKey().toString().indexOf(STATE_OPTION_SUFFIX);
+ if (-1 != suffixPos) {
+ String key = entry.getKey().toString().substring(suffixPos +
STATE_OPTION_SUFFIX.length());
+ visualOptions.put(key, entry.getValue());
+ }
+ }
+ }
+ }
+ }
+
+ protected Class getComponentClass() {
+ return UIPopupPanel.class;
+ }
+
+ public void checkOptions(FacesContext context, UIComponent component) {
+ UIPopupPanel panel = (UIPopupPanel) component;
+ if (panel.isAutosized() && panel.isResizeable()) {
+ throw new IllegalArgumentException("Autosized modal panel can't be
resizeable.");
+ }
+
+ String domElementAttachment = panel.getDomElementAttachment();
+ if (domElementAttachment != null && domElementAttachment.trim().length()
!= 0) {
+ if (!ALLOWED_ATTACHMENT_OPTIONS.contains(domElementAttachment)) {
+ throw new IllegalArgumentException("Value '" +
domElementAttachment
+ + "' of domElementAttachment attribute is illegal. " +
"Allowed values are: "
+ + ALLOWED_ATTACHMENT_OPTIONS);
+ }
+ }
+
+ if (panel.getMinHeight() != -1) {
+ if (panel.getMinHeight() < SIZE) {
+ throw new IllegalArgumentException();
+ }
+
+ }
+
+ if (panel.getMinWidth() != -1) {
+ if (panel.getMinWidth() < SIZE) {
+ throw new IllegalArgumentException();
+ }
+
+ }
+ }
+
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ public String buildShowScript(FacesContext context, UIComponent component) {
+ UIPopupPanel panel = (UIPopupPanel) component;
+ StringBuilder result = new StringBuilder();
+
+ // Bug
https://jira.jboss.org/jira/browse/RF-2466
+ // We are already processed KeepVisualState and current open state in
+ // doDecode, so no need to check panel.isKeepVisualState() here.
+ if (panel.isShow()) {
+ result.append("RichFaces.ui.PopupPanel.showPopupPanel('" +
panel.getClientId(context) + "', {");
+
+ Iterator<Map.Entry<String, Object>> it = ((Map<String,
Object>) panel.getHandledVisualOptions()).entrySet()
+ .iterator();
+ while (it.hasNext()) {
+ Map.Entry<String, Object> entry = it.next();
+
+ result.append(entry.getKey() + ": '" + entry.getValue() +
"'");
+ if (it.hasNext()) {
+ result.append(", ");
+ }
+ }
+
+ result.append("});");
+ }
+ return result.toString();
+ }
+
+ private void writeOption(StringBuilder builder, String attribbute, Object value,
UIComponent component,
+ boolean isString) {
+ if (component.getAttributes().get(attribbute) != null) {
+ builder.append(attribbute + ":");
+ if (isString) {
+ builder.append("'");
+ }
+ builder.append(value);
+ if (isString) {
+ builder.append("'");
+ }
+ builder.append(",");
+ }
+ }
+
+ public String buildScript(FacesContext context, UIComponent component) throws
IOException {
+ UIPopupPanel panel = (UIPopupPanel) component;
+ StringBuilder result = new StringBuilder();
+ result.append("new RichFaces.ui.PopupPanel('");
+ result.append(panel.getClientId());
+ result.append("',{");
+ writeOption(result, "width", panel.getWidth(), component, false);
+ writeOption(result, "height", panel.getHeight(), component, false);
+ writeOption(result, "minWidth", panel.getMinWidth(), component,
false);
+ writeOption(result, "minHeight", panel.getMinHeight(), component,
false);
+ writeOption(result, "maxWidth", panel.getMaxWidth(), component,
false);
+ writeOption(result, "maxHeight", panel.getMaxHeight(), component,
false);
+ writeOption(result, "resizeable", panel.isResizeable(), component,
false);
+ writeOption(result, "moveable", panel.isMoveable(), component, false);
+ writeOption(result, "left", panel.getLeft(), component, true);
+ writeOption(result, "top", panel.getTop(), component, true);
+ writeOption(result, "zIndex", panel.getZIndex(), component, false);
+ writeOption(result, "onresize", writeEventHandlerFunction(context,
panel, "onresize"), component, false);
+ writeOption(result, "onmove", writeEventHandlerFunction(context, panel,
"onmove"), component, false);
+ writeOption(result, "onshow", writeEventHandlerFunction(context, panel,
"onshow"), component, false);
+ writeOption(result, "onhide", writeEventHandlerFunction(context, panel,
"onhide"), component, false);
+ writeOption(result, "onbeforeshow", writeEventHandlerFunction(context,
panel, "onbeforeshow"), component, false);
+ writeOption(result, "onbeforehide", writeEventHandlerFunction(context,
panel, "onbeforehide"), component, false);
+ writeOption(result, "shadowDepth", panel.getShadowDepth(), component,
true);
+ writeOption(result, "shadowOpacity", panel.getShadowOpacity(),
component, true);
+ writeOption(result, "domElementAttachment",
panel.getDomElementAttachment(), component, true);
+ writeOption(result, "keepVisualState", panel.isKeepVisualState(),
component, false);
+ writeOption(result, "show", panel.isShow(), component, false);
+ writeOption(result, "autosized", panel.isAutosized(), component,
false);
+ writeOption(result, "overlapEmbedObjects",
panel.isOverlapEmbedObjects(), component, false);
+ result.delete(result.length() - 1, result.length());
+ if (component.getAttributes().get("visualOptions") != null) {
+ result.append(writeVisualOptions(context, panel));
+ }
+ result.append("});");
+ return result.toString();
+ }
+
+ public String writeEventHandlerFunction(FacesContext context, UIComponent component,
String eventName)
+ throws IOException {
+ String event = (String) component.getAttributes().get(eventName);
+
+ if (event != null) {
+ event = event.trim();
+
+ if (event.length() != 0) {
+ JSFunctionDefinition function = new JSFunctionDefinition();
+
+ function.addParameter("event");
+ function.addToBody(event);
+
+ return function.toScript();
+ }
+ }
+
+ return "";
+ }
+
+ private String writeVisualOptions(FacesContext context, UIPopupPanel panel) throws
IOException {
+ StringBuffer result = new StringBuffer();
+
+ Iterator<Map.Entry<String, Object>> it = ((Map<String, Object>)
panel.getHandledVisualOptions()).entrySet()
+ .iterator();
+ if (it.hasNext()) {
+ result.append(",\n");
+ }
+ while (it.hasNext()) {
+ Map.Entry<String, Object> entry = it.next();
+
+ result.append(entry.getKey() + ": '" + entry.getValue() +
"'");
+ if (it.hasNext()) {
+ result.append(",");
+ }
+ }
+ return result.toString();
+ }
+}
Copied: root/ui/output/trunk/panels/ui/src/main/resources/META-INF/MANIFEST.MF (from rev
17965, root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/MANIFEST.MF)
===================================================================
--- root/ui/output/trunk/panels/ui/src/main/resources/META-INF/MANIFEST.MF
(rev 0)
+++ root/ui/output/trunk/panels/ui/src/main/resources/META-INF/MANIFEST.MF 2010-07-12
17:56:20 UTC (rev 17973)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Copied: root/ui/output/trunk/panels/ui/src/main/resources/META-INF/css/panel.ecss (from
rev 17965, root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/css/panel.ecss)
===================================================================
--- root/ui/output/trunk/panels/ui/src/main/resources/META-INF/css/panel.ecss
(rev 0)
+++ root/ui/output/trunk/panels/ui/src/main/resources/META-INF/css/panel.ecss 2010-07-12
17:56:20 UTC (rev 17973)
@@ -0,0 +1,29 @@
+.rf-panel{
+ background-color:'#{richSkin.generalBackgroundColor}';
+ color:'#{richSkin.panelBorderColor}';
+ border-width:1px;
+ border-style:solid;
+ padding:1px;
+}
+
+.rf-panel-header{
+ background-color:'#{richSkin.headerBackgroundColor}';
+ border-color:'#{richSkin.headerBackgroundColor}';
+ font-size:'#{richSkin.headerSizeFont}';
+ color:'#{richSkin.headerTextColor}';
+ font-weight:'#{richSkin.headerWeightFont}';
+ font-family:'#{richSkin.headerFamilyFont}';
+ padding:2px;
+ border-width:1px;
+ border-style:solid;
+ background-position:top left;
+ background-repeat:repeat-x;
+ background-image:"url(#{resource['org.richfaces.renderkit.html.GradientA']})";
+}
+
+.rf-panel-body{
+ font-size:'#{richSkin.generalSizeFont}';
+ color:'#{richSkin.generalTextColor}';
+ font-family:'#{richSkin.generalFamilyFont}';
+ padding:10px;
+}
\ No newline at end of file
Copied: root/ui/output/trunk/panels/ui/src/main/resources/META-INF/css/popupPanel.ecss
(from rev 17965,
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/css/popupPanel.ecss)
===================================================================
--- root/ui/output/trunk/panels/ui/src/main/resources/META-INF/css/popupPanel.ecss
(rev 0)
+++
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/css/popupPanel.ecss 2010-07-12
17:56:20 UTC (rev 17973)
@@ -0,0 +1,170 @@
+.mp-button {
+ outline-style: none;
+ position: absolute;
+ clip: rect(0px 0px 1px 1px);
+ height: 0px;
+ width: 0px;
+ left: 0px;
+ top: 0px;
+ z-index: -300;
+ opacity:0.1;
+ filter : 'alpha(opacity=10)';
+}
+
+.mp_shade {
+ position : fixed;
+ width : 100%;
+ height : 100%;
+ top:0px;
+ left : 0px;
+ background : #D0D0D0;
+ opacity:0.5;
+ filter : 'alpha(opacity=50)';
+}
+.mp_iframe {
+ position : absolute;
+ width : 100%;
+ height : 100%;
+ top:0px;
+ left : 0px;
+ opacity:0.3;
+ filter : 'alpha(opacity=30)';
+}
+.mp_shadow {
+ position : fixed;
+ background-color : #000000;
+ opacity:0.1;
+ filter : 'alpha(opacity=10)';
+}
+.mp_container {
+ position : fixed;
+ border : '1px solid #{richSkin.panelBorderColor}';
+ background : '#{richSkin.generalBackgroundColor}';
+ z-index:100;
+}
+.mp_header {
+ background :
"url(#{resource['org.richfaces.renderkit.html.GradientA']})";
+ repeat-x : 'top left #{richSkin.headerBackgroundColor}';
+ position : relative;
+ padding-left : 10px;
+ cursor : move;
+ padding : 2px;
+}
+.mp_header_content {
+ overflow : hidden;
+ white-space : nowrap;
+ text-overflow: ellipsis;
+ font-weight : '#{richSkin.headerWeightFont}';
+ color : '#{richSkin.headerTextColor}';
+ font-family : '#{richSkin.headerFamilyFont}';
+ font-size : '#{richSkin.headerSizeFont}';
+ padding : 2px;
+ padding-left : 10px;
+}
+.mp_header_controls {
+ background : "url(#{resource['images/close_act.gif']}) no-repeat
center";
+ width : 16px;
+ height : 16px;
+ position : absolute;
+ top : 8px;
+ right : 8px;
+ white-space : nowrap;
+ cursor : default;
+}
+.mp_header_icon {
+ background : "url(#{resource['images/edit.gif']}) no-repeat center";
+ width : 16px;
+ height : 16px;
+ margin-right : 5px;
+ vertical-align : middle;
+ display : inline-block;
+ text-align : middle;
+}
+.mp_content_scroller {
+ position : relative;
+ top : 0px;
+ left : 0px;
+ overflow : auto;
+}
+.mp_content {
+ position : relative;
+ padding : 10px;
+ color : '#{richSkin.generalTextColor}';
+ font-family : '#{richSkin.generalFamilyFont}';
+ font-size : '#{richSkin.generalSizeFont}';
+}
+.mp_handler {
+ background : red;
+ filter : 'alpha(opacity=0)';
+ opacity:0;
+ position : absolute;
+ margin : -4px;
+}
+.mp_handler_left {
+ width : 7px;
+ height : 100%;
+ top : 0px;
+ left : 0px;
+ cursor : w-resize;
+}
+
+.mp_handler_right {
+ width : 7px;
+ height : 100%;
+ top : 0px;
+ right : 0px;
+ cursor : w-resize;
+}
+
+.mp-iframe {
+ position: absolute;
+ left: 0px;
+ top: 0px;
+ background-color: white;
+ overflow-y: hidden;
+ z-index: -1;
+}
+
+.mp_handler_top {
+ width : 100%;
+ height : 7px;
+ top : 0px;
+ left : 0px;
+ cursor : n-resize;
+}
+.mp_handler_bottom {
+ width : 100%;
+ height : 7px;
+ bottom : 0px;
+ left : 0px;
+ cursor : n-resize;
+}
+
+.mp_handler_top_left {
+ width : 10px;
+ height : 10px;
+ top : 0px;
+ left : 0px;
+ cursor : nw-resize;
+}
+.mp_handler_top_right {
+ width : 10px;
+ height : 10px;
+ top : 0px;
+ right : 0px;
+ cursor : ne-resize;
+}
+.mp_handler_bottom_left {
+ width : 10px;
+ height : 10px;
+ bottom : 0px;
+ left : 0px;
+ cursor : ne-resize;
+}
+.mp_handler_bottom_right {
+ width : 10px;
+ height : 10px;
+ bottom : 0px;
+ right : 0px;
+ cursor : nw-resize;
+}
\ No newline at end of file
Copied: root/ui/output/trunk/panels/ui/src/main/resources/META-INF/faces-config.xml (from
rev 17965, root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/faces-config.xml)
===================================================================
--- root/ui/output/trunk/panels/ui/src/main/resources/META-INF/faces-config.xml
(rev 0)
+++ root/ui/output/trunk/panels/ui/src/main/resources/META-INF/faces-config.xml 2010-07-12
17:56:20 UTC (rev 17973)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<faces-config version="2.0" metadata-complete="false"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:cdk="http://richfaces.org/cdk/extensions"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<component>
+ <component-type>org.richfaces.Panel</component-type>
+ <component-class>org.richfaces.component.UIPanel</component-class>
+ </component>
+ <component>
+ <component-type>org.richfaces.PopupPanel</component-type>
+ <component-class>org.richfaces.component.UIPopupPanel</component-class>
+ </component>
+ <render-kit>
+ <render-kit-id>HTML_BASIC</render-kit-id>
+ <renderer>
+ <component-family>org.richfaces.Panel</component-family>
+ <renderer-type>org.richfaces.PanelRenderer</renderer-type>
+
<renderer-class>org.richfaces.renderkit.html.PanelRenderer</renderer-class>
+ </renderer>
+ <renderer>
+ <component-family>org.richfaces.PopupPanel</component-family>
+ <renderer-type>org.richfaces.PopupPanelRenderer</renderer-type>
+
<renderer-class>org.richfaces.renderkit.html.PopupPanelRenderer</renderer-class>
+ </renderer>
+ </render-kit>
+ <faces-config-extension>
+ <cdk:taglib>
+ <cdk:shortName>panels</cdk:shortName>
+ <
cdk:uri>http://richfaces.org/panels</cdk:uri>
+ </cdk:taglib>
+ </faces-config-extension>
+</faces-config>
Copied: root/ui/output/trunk/panels/ui/src/main/resources/META-INF/images/bg_header.png
(from rev 17965,
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/images/bg_header.png)
===================================================================
(Binary files differ)
Copied: root/ui/output/trunk/panels/ui/src/main/resources/META-INF/images/close_act.gif
(from rev 17965,
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/images/close_act.gif)
===================================================================
(Binary files differ)
Copied: root/ui/output/trunk/panels/ui/src/main/resources/META-INF/images/edit.gif (from
rev 17965, root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/images/edit.gif)
===================================================================
(Binary files differ)
Copied: root/ui/output/trunk/panels/ui/src/main/resources/META-INF/panels.taglib.xml (from
rev 17965,
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/panels.taglib.xml)
===================================================================
--- root/ui/output/trunk/panels/ui/src/main/resources/META-INF/panels.taglib.xml
(rev 0)
+++
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/panels.taglib.xml 2010-07-12
17:56:20 UTC (rev 17973)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<facelet-taglib
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+
http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
version="2.0" id="a4j">
+ <
namespace>http://richfaces.org/panels</namespace>
+ <tag>
+ <tag-name>panel</tag-name>
+ <component>
+ <component-type>org.richfaces.Panel</component-type>
+ <renderer-type>org.richfaces.PanelRenderer</renderer-type>
+ </component>
+ </tag>
+
+ <tag>
+ <tag-name>popupPanel</tag-name>
+ <component>
+ <component-type>org.richfaces.PopupPanel</component-type>
+ <renderer-type>org.richfaces.PopupPanelRenderer</renderer-type>
+ </component>
+ </tag>
+</facelet-taglib>
Copied: root/ui/output/trunk/panels/ui/src/main/resources/META-INF/script/popupPanel.js
(from rev 17965,
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/script/popupPanel.js)
===================================================================
--- root/ui/output/trunk/panels/ui/src/main/resources/META-INF/script/popupPanel.js
(rev 0)
+++
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/script/popupPanel.js 2010-07-12
17:56:20 UTC (rev 17973)
@@ -0,0 +1,686 @@
+(function ($, richfaces) {
+
+ richfaces.ui = richfaces.ui || {};
+ var selectionEventHandler = function(event){
+ event.stopPropagation();
+ event.preventDefault();
+ };
+
+ var disableSelection = function (element)
+ {
+ if (typeof element.onselectstart!="undefined") //IE
+ {
+ jQuery(element).bind( 'selectstart', selectionEventHandler);
+ }
+ else //All other (ie: Opera)
+ {
+ jQuery(element).bind( 'mousedown', selectionEventHandler);
+ }
+ }
+
+ var enableSelection = function (element)
+ {
+ if (typeof element.onselectstart!="undefined") //IE
+ {
+ jQuery(element).unbind( 'selectstart', selectionEventHandler);
+ }
+ else if (typeof element.style.MozUserSelect!="undefined") //Firefox
+ {
+ jQuery(element).css('MozUserSelect','');
+ }
+ else //All other (ie: Opera)
+ {
+ jQuery(element).unbind( 'mousedown', selectionEventHandler);
+ }
+ }
+
+ richfaces.ui.PopupPanel = function(id, options) {
+
+ $super.constructor.call(this,id);
+ this.markerId = id;
+ $p.attachToDom.call(this, id);
+ id = "#" + id;
+ this.options = options;
+
+ this.id = $(id);
+ this.minWidth = this.getMinimumSize(this.options.minWidth);
+ this.minHeight = this.getMinimumSize(this.options.minHeight);
+ this.maxWidth = this.options.maxWidth;
+ this.maxHeight = this.options.maxHeight;
+ this.options = options;
+
+ this.baseZIndex = this.options.zindex ? this.options.zindex : 100;
+
+ this.div = id;
+ this.cdiv = id + "_container";
+ this.contentDiv = id + "_content";
+ this.shadowDiv = id + "_shadow";
+ this.scrollerDiv = id + "_content_scroller"
+
+ this.borders = new Array();
+
+ if (this.options.resizeable) {
+ this.borders.push(new richfaces.ui.PopupPanel.Border(id + "ResizerN", this,
"N-resize", richfaces.ui.PopupPanel.Sizer.N));
+ this.borders.push(new richfaces.ui.PopupPanel.Border(id + "ResizerE", this,
"E-resize", richfaces.ui.PopupPanel.Sizer.E));
+ this.borders.push(new richfaces.ui.PopupPanel.Border(id + "ResizerS", this,
"S-resize", richfaces.ui.PopupPanel.Sizer.S));
+ this.borders.push(new richfaces.ui.PopupPanel.Border(id + "ResizerW", this,
"W-resize", richfaces.ui.PopupPanel.Sizer.W));
+
+ this.borders.push(new richfaces.ui.PopupPanel.Border(id + "ResizerNW", this,
"NW-resize", richfaces.ui.PopupPanel.Sizer.NW));
+ this.borders.push(new richfaces.ui.PopupPanel.Border(id + "ResizerNE", this,
"NE-resize", richfaces.ui.PopupPanel.Sizer.NE));
+ this.borders.push(new richfaces.ui.PopupPanel.Border(id + "ResizerSE", this,
"SE-resize", richfaces.ui.PopupPanel.Sizer.SE));
+ this.borders.push(new richfaces.ui.PopupPanel.Border(id + "ResizerSW", this,
"SW-resize", richfaces.ui.PopupPanel.Sizer.SW));
+ }
+
+ if (this.options.moveable && $(id + "_header")) {
+ this.header = new richfaces.ui.PopupPanel.Border(id + "_header", this,
"move", richfaces.ui.PopupPanel.Sizer.Header);
+ } else{
+ $(id + "_header").css('cursor', 'default');
+ }
+
+ };
+
+ var $super = richfaces.BaseComponent.extend(richfaces.BaseComponent,
richfaces.ui.PopupPanel);
+ var $p =
richfaces.BaseComponent.extend(richfaces.BaseComponent,richfaces.ui.PopupPanel, {});
+ var $super = richfaces.ui.PopupPanel.$super;
+ $.extend(richfaces.ui.PopupPanel.prototype, (function (options) {
+
+ return {
+
+ name: "RichFaces.ui.PopupPanel",
+ saveInputValues: function(element) {
+ /* Fix for RF-3856 - Checkboxes in modal panel does not hold their states after modal
was closed and opened again */
+ if ($.browser.msie /* reproducible for checkbox/radio in IE6, radio in IE 7/8 beta 2
*/) {
+ $('input[type=checkbox], input[type=radio]', element).each(function(index)
{
+ $(this).defaultChecked = $(this).checked;
+ });
+ }
+ },
+
+ width: function() {
+ return this.getContentElement()[0].clientWidth;//TODO
+ },
+
+ height: function() {
+ return this.getContentElement()[0].clientHeight;//TODO
+ },
+
+ getLeft : function (){
+ return $(this.cdiv).css('left');
+ },
+
+ getTop : function (){
+ return $(this.cdiv).css('top');
+ },
+
+ getInitialSize : function(){
+ if(this.options.autosized){
+ return $(this.div+"_headerSpan").height();
+ } else{
+ return $(this.div + "_header_content").height();
+ }
+ },
+
+ getContentElement: function() {
+ if (!this._contentElement) {
+ this._contentElement = $(this.cdiv);
+ }
+
+ return this._contentElement;
+ },
+ getSizeElement : function() {
+ return document.body;
+ },
+
+ getMinimumSize : function(size) {
+ return Math.max(size, 2*this.getInitialSize() + 2);
+ },
+ destroy: function() {
+
+ this._contentElement = null;
+
+ this.parent = null;
+ if (this.header) {
+ this.header.destroy();
+ this.header=null;
+ }
+
+ for (var k = 0; k < this.borders.length; k++ ) {
+ this.borders[k].destroy();
+ }
+ this.borders = null;
+
+ if (this.domReattached) {
+ var element = this.id;
+ var parent = $(element).parent();
+ if (parent) {
+ parent.remove(element);
+ }
+ }
+ },
+
+ initIframe : function() {
+ if (this.contentWindow) {
+ $(this.contentWindow.document.body).css("margin", "0px 0px 0px
0px");
+ } else {
+ //TODO opera etc.
+
+ }
+
+ if("transparent" == $(document.body).css("background-color")) {
+ $(this).css('filter', "alpha(opacity=0)");
+ $(this).css('opacity', "0");
+ }
+ },
+
+ setLeft: function(pos) {
+ if(!isNaN(pos)){
+ $(this.cdiv).css('left', pos + "px");
+ var depth = this.options.shadowDepth ? this.options.shadowDepth : 2;
+ $(this.shadowDiv).css('left', pos + depth + "px");
+ }
+ },
+
+ setTop: function(pos) {
+ if(!isNaN(pos)){
+ $(this.cdiv).css('top', pos + "px");
+ var depth = this.options.shadowDepth ? this.options.shadowDepth : 2;
+ $(this.shadowDiv).css('top', pos + depth +"px");
+ }
+ },
+
+ show: function(event, opts) {
+ if(!this.shown &&
this.invokeEvent("beforeshow",event,null,element)) {
+
+ var element = this.id;
+
+ if (!this.domReattached) {
+ this.parent = $(element).parent();
+
+ var domElementAttachment;
+ if (opts) {
+ domElementAttachment = opts.domElementAttachment;
+ }
+
+ if (!domElementAttachment) {
+ domElementAttachment = this.options.domElementAttachment;
+ }
+
+ var newParent;
+ if ('parent' == domElementAttachment) {
+ newParent = this.parent;
+ } else if ('form' == domElementAttachment) {
+ newParent = this.findForm(element) || document.body;
+ } else {
+ //default - body
+ newParent = document.body;
+ }
+
+ if (newParent != this.parent) {
+ this.saveInputValues(element);
+ element.insertBefore(newParent.firstChild);
+ this.domReattached = true;
+ } else {
+ $(this.parent).show();
+ }
+ }
+
+ var forms = $("form", element);
+
+ if (this.options.keepVisualState && forms) {
+ for (var i = 0; i < forms.length; i++) {
+ var popup = this;
+ $(forms[i]).bind( "submit", {popup:popup}, this.setStateInput);
+ }
+ }
+
+
+
+ var options = {};
+ this.userOptions = {};
+ if (!element.mpSet) {
+ $.extend(options, this.options);
+ }
+
+ if (opts) {
+ $.extend(options, opts);
+ $.extend(this.userOptions, opts);
+ }
+
+ this.currentMinHeight = this.getMinimumSize((options.minHeight || options.minHeight
== 0) ? options.minHeight : this.minHeight);
+ this.currentMinWidth = this.getMinimumSize((options.minWidth || options.minWidth ==
0) ? options.minWidth : this.minWidth);
+
+ var eContentElt = this.getContentElement();
+
+ if (!this.options.autosized) {
+ if (options.width && options.width == -1)
+ options.width = 600;
+ if (options.height && options.height == -1)
+ options.height = 400;
+ } else{
+ options.width = $(this.div+"_headerSpan").width() +20;
+ }
+
+ if (options.width && options.width != -1) {
+ if (this.currentMinWidth > options.width) {
+ options.width = this.currentMinWidth;
+ }
+ if (options.width > this.maxWidth) {
+ options.width = this.maxWidth;
+ }
+ $(eContentElt).css('width', options.width + (/px/.test(options.width) ?
'' : 'px'));
+ $(this.shadowDiv).css('width', options.width + 4 +
(/px/.test(options.width) ? '' : 'px'));
+ $(this.scrollerDiv).css('width', options.width + (/px/.test(options.width)
? '' : 'px'));
+
+
+ }
+
+ if (options.height && options.height != -1) {
+ if (this.currentMinHeight > options.height) {
+ options.height = this.currentMinHeight;
+ }
+ if (options.height > this.maxHeight) {
+ options.height = this.maxHeight;
+ }
+ $(eContentElt).css('height', options.height + (/px/.test(options.height) ?
'' : 'px'));
+ $(this.shadowDiv).css('height', options.height + 4 +
(/px/.test(options.height) ? '' : 'px'));
+ var headerHeight = $(this.div +"_header")[0].clientHeight;
+ $(this.scrollerDiv).css('height', options.height - headerHeight +
(/px/.test(options.height) ? '' : 'px'));
+
+
+ }
+ var eIframe;
+ if (this.options.overlapEmbedObjects && !this.iframe) {
+ this.iframe = this.markerId + "IFrame";
+ $("<iframe src=\"javascript:''\"
frameborder=\"0\" scrolling=\"no\" id=\"" + this.iframe +
"\" " +
+ "class=\"mp-iframe\" style=\"width:" +this.options.width +
"px; height:" + this.options.height + "px;\">" +
+ "</iframe>").insertBefore($(':first-child',
$(this.cdiv))[0]);
+
+ eIframe = jQuery("#"+this.iframe);
+
+ $(eIframe).bind('load', this.initIframe);
+ this.eIframe = eIframe;
+ }
+ element.mpSet = true;
+
+ var eDiv = $(this.div);
+
+ if (options.left) {
+ var _left;
+ if (options.left != "auto") {
+ _left = parseInt(options.left, 10);
+ } else {
+ var cw = this.getSizeElement().clientWidth;
+ var _width = this.width();
+ if (cw >= _width) {
+ _left = (cw - _width) / 2;
+ } else {
+ _left = 0;
+ }
+ }
+
+ this.setLeft(Math.round(_left));
+ }
+
+ if (options.top) {
+ var _top;
+ if (options.top != "auto") {
+ _top = parseInt(options.top, 10);
+ } else {
+ var cw = this.getSizeElement().clientHeight;
+ var _height = this.height();
+ if (cw >= _height) {
+ _top = (cw - _height) / 2;
+ } else {
+ _top = 0;
+ }
+ }
+
+ this.setTop(Math.round(_top));
+ }
+
+ var opacity = options.shadowOpacity ? options.shadowOpacity : 0.1;
+ $(this.shadowDiv).css('opacity', opacity);
+ $(this.shadowDiv).css('filter ', 'alpha(opacity='+opacity*100
+');');
+ $(element).css('visibility', '');
+ $(element).css('display', 'block');
+ var event = {};
+ event.parameters = opts || {};
+ this.shown = true;
+ this.invokeEvent("show",event,null,element);
+ }
+ },
+
+ startDrag: function(border) {
+ for (var k = 0; k < this.borders.length; k++ ) {
+ this.borders[k].hide();
+ }
+ disableSelection(document.body);
+ },
+
+ endDrag: function(border) {
+ for (var k = 0; k < this.borders.length; k++ ) {
+ this.borders[k].show();
+ this.borders[k].doPosition();
+ }
+ enableSelection(document.body);
+ },
+
+ hide: function(event, opts) {
+ var element = this.id;
+ if (this.shown &&
this.invokeEvent("beforehide",event,null,element)) {
+
+ this.currentMinHeight = undefined;
+ this.currentMinWidth = undefined;
+
+ $(this.id).hide();
+
+ if (this.parent) {
+ if (this.domReattached) {
+ this.saveInputValues(element);
+
+ this.parent.append(element);
+
+ this.domReattached = false;
+ } else {
+ $(this.parent).hide();
+ }
+ }
+
+ var event = {};
+ event.parameters = opts || {};
+ if (this.options && this.options.onhide) {
+ this.options.onhide(event);
+ }
+
+ var forms = $("form", element);
+ if (this.options.keepVisualState && forms) {
+ for (var i = 0; i < forms.length; i++) {
+ $(forms[i]).unbind( "submit", this.setStateInput);
+ }
+ }
+
+ this.shown = false;
+
+ }
+ },
+
+ getStyle: function(elt, name) {
+ return parseInt($(elt).css(name).replace("px", ""), 10);
+ },
+
+ doResizeOrMove: function(diff) {
+ var vetoes = {};
+ var shadowHash = {};
+ var cssHash = {};
+ var cssHashWH = {};
+ var shadowHashWH = {};
+ var contentHashWH = {};
+ var scrollerHashWH = {};
+
+ var vetoeChange = false;
+ var newSize;
+ var shadowDepth = this.options.shadowDepth? this.options.shadowDepth: 4;
+ var scrollerHeight = 22;
+ var scrollerWidth = 0;
+ var eContentElt = this.getContentElement();
+
+ newSize = this.getStyle(eContentElt, "width");
+
+ var oldSize = newSize;
+ newSize += diff.deltaWidth || 0;
+
+
+
+ if (newSize >= this.currentMinWidth || this.options.autosized) {
+ if (diff.deltaWidth) {
+ cssHashWH.width = newSize + 'px';
+ shadowHashWH.width = newSize + shadowDepth + 'px';
+ contentHashWH.width = newSize - scrollerWidth + 'px';
+ scrollerHashWH.width = newSize - scrollerWidth + 'px';
+ }
+ } else {
+ if (diff.deltaWidth) {
+ cssHashWH.width = this.currentMinWidth + 'px';
+ shadowHashWH.width = this.currentMinWidth + shadowDepth + 'px';
+ contentHashWH.width = this.currentMinWidth - scrollerWidth + 'px';
+ scrollerHashWH.width = this.currentMinWidth - scrollerWidth + 'px';
+ vetoes.vx = oldSize - this.currentMinWidth;
+ }
+
+ vetoes.x = true;
+ }
+
+ if (newSize >= this.options.maxWidth) {
+ if (diff.deltaWidth) {
+ cssHashWH.width = this.currentMaxWidth + 'px';
+ shadowHashWH.width = this.currentMaxWidth + shadowDepth + 'px';
+ contentHashWH.width = this.currentMaxWidth - scrollerWidth + 'px';
+ scrollerHashWH.width = this.currentMaxWidth - scrollerWidth + 'px';
+ vetoes.vx = oldSize - this.currentMaxWidth;
+ }
+
+ vetoes.x = true;
+ }
+
+ if (vetoes.vx && diff.deltaX) {
+ diff.deltaX = -vetoes.vx;
+ }
+
+ var eCdiv = $(this.cdiv);
+
+ if (diff.deltaX && (vetoes.vx || !vetoes.x)) {
+ if (vetoes.vx) {
+ diff.deltaX = vetoes.vx;
+ }
+ var newPos;
+
+ newPos = this.getStyle(eCdiv, "left");
+ newPos += diff.deltaX;
+ cssHash.left = newPos + 'px';
+
+ shadowHash.left = newPos + shadowDepth + "px";
+ }
+
+ newSize = this.getStyle(eContentElt, "height")
+
+ var oldSize = newSize;
+ newSize += diff.deltaHeight || 0;
+
+ if (newSize >= this.currentMinHeight || this.options.autosized) {
+ if (diff.deltaHeight) {
+ cssHashWH.height = newSize + 'px';
+ shadowHashWH.height = newSize + shadowDepth + 'px';
+ scrollerHashWH.height = newSize - scrollerHeight + 'px';
+ }
+ } else {
+ if (diff.deltaHeight) {
+ cssHashWH.height = this.currentMinHeight + 'px';
+ shadowHashWH.height = this.currentMinHeight + shadowDepth + 'px';
+ scrollerHashWH.height = this.currentMinHeight - scrollerHeight + 'px';
+ vetoes.vy = oldSize - this.currentMinHeight;
+ }
+
+ vetoes.y = true;
+ }
+
+ if (newSize >= this.options.maxHeight) {
+ if (diff.deltaHeight) {
+ cssHashWH.height = this.currentMaxHeight + 'px';
+ shadowHashWH.height = this.currentMaxHeight + shadowDepth + 'px';
+ scrollerHashWH.height = this.currentMaxHeight - scrollerHeight + 'px';
+ vetoes.vy = oldSize - this.currentMaxHeight;
+ }
+
+ vetoes.y = true;
+ }
+
+ if (vetoes.vy && diff.deltaY) {
+ diff.deltaY = -vetoes.vy;
+ }
+
+ if (diff.deltaY && (vetoes.vy || !vetoes.y)) {
+ if (vetoes.vy) {
+ diff.deltaY = vetoes.vy;
+ }
+
+ }
+ if (diff.deltaY && (vetoes.vy || !vetoes.y)) {
+ if (vetoes.vy) {
+ diff.deltaY = vetoes.vy;
+ }
+ var newPos;
+
+ newPos = this.getStyle(eCdiv, "top");
+ newPos += diff.deltaY;
+ cssHash.top = newPos + 'px';
+ shadowHash.top = newPos + shadowDepth + "px";
+ }
+ $(eContentElt).css(cssHashWH);
+ $(this.scrollerDiv).css(scrollerHashWH);
+ if(this.eIframe)$(this.eIframe).css(scrollerHashWH);
+ $(this.shadowDiv).css(shadowHashWH);
+
+ $(eCdiv).css(cssHash);
+ $(this.shadowDiv).css(shadowHash);
+ //if(this.eIframe)$(this.eIframe).css(cssHash);
+ $.extend(this.userOptions, cssHash);
+ $.extend(this.userOptions, cssHashWH);
+ var w = this.width();
+ var h = this.height();
+
+ this.reductionData = null;
+
+ if (w <= 2*this.getInitialSize()) {
+ this.reductionData = {};
+ this.reductionData.w = w;
+ }
+
+ if (h <= 2*this.getInitialSize()) {
+ if (!this.reductionData) {
+ this.reductionData = {};
+ }
+
+ this.reductionData.h = h;
+ }
+
+ if (this.header) {
+ this.header.doPosition();
+ }
+
+ return vetoes;
+ },
+
+ setSize : function (width, height){
+ var w = width - this.width() ;
+ var h = height -this.height();
+ var diff = new richfaces.ui.PopupPanel.Sizer.Diff(0,0, w, h);
+ this.doResizeOrMove(diff);
+ },
+
+ moveTo : function (top, left){
+ var shadowDepth = this.options.shadowDepth? this.options.shadowDepth: 4;
+ $(this.cdiv).css('top', top);
+ $(this.cdiv).css('left', left);
+ $(this.shadowDiv).css('top', top + shadowDepth);
+ $(this.shadowDiv).css('left', left + shadowDepth);
+ },
+
+ move : function (dx, dy){
+ var diff = new richfaces.ui.PopupPanel.Sizer.Diff(dx,dy, 0, 0);
+ this.doResizeOrMove(diff);
+ },
+
+ resize : function (dx, dy){
+ var diff = new richfaces.ui.PopupPanel.Sizer.Diff(0,0, dx, dy);
+ this.doResizeOrMove(diff);
+ },
+
+ findForm: function(elt) {
+ var target = elt;
+ while (target) {
+ if (!target.tagName /* document node doesn't have tagName */
+ || target.tagName.toLowerCase() != "form") {
+
+ target = $(target).parent();
+ } else {
+ break;
+ }
+ }
+
+ return target;
+ },
+
+ setStateInput: function(event) {
+ // Concret input but not entire form is a target element for onsubmit in FF
+ var popup = event.data.popup;
+ target = $(popup.findForm(event.currentTarget));
+
+ var input = document.createElement("input");
+ input.type = "hidden";
+ input.id = popup.markerId + "OpenedState";
+ input.name = popup.markerId + "OpenedState";
+ input.value = popup.shown ? "true" : "false";
+ target.append(input);
+
+ $.each(popup.userOptions, function(key, value) {
+ input = document.createElement("input");
+ input.type = "hidden";
+ input.id = popup.markerId + "StateOption_" + key;
+ input.name = popup.markerId + "StateOption_" + key;
+ input.value = value;
+ target.append(input);
+ });
+
+ return true;
+ },
+
+ invokeEvent: function(eventName, event, value, element) {
+
+ var eventFunction = this.options['on'+eventName];
+ var result;
+
+ if (eventFunction) {
+ var eventObj;
+ if (event) {
+ eventObj = event;
+ }
+ else if(document.createEventObject) {
+ eventObj = document.createEventObject();
+ }
+ else if( document.createEvent ) {
+ eventObj = document.createEvent('Events');
+ eventObj.initEvent( eventName, true, false );
+ }
+
+ eventObj.rich = {component:this};
+ eventObj.rich.value = value;
+
+ try {
+ result = eventFunction.call(element, eventObj);
+ }
+ catch (e) { LOG.warn("Exception: "+e.Message + "\n[on"+eventName
+ "]"); }
+ }
+
+ if (result!=false) {
+ result = true;
+ }
+ return result;
+ }
+
+
+ }
+
+ })());
+ $.extend(richfaces.ui.PopupPanel, {
+
+ showPopupPanel : function (id, opts, event) {
+
+ $(document).ready(richfaces.$(id).show());
+ },
+
+ hidePopupPanel : function (id, opts, event) {
+ $(document).ready(richfaces.$(id).hide());
+ }
+ });
+
+})(jQuery, window.RichFaces);
Copied:
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/script/popupPanelBorders.js
(from rev 17965,
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/script/popupPanelBorders.js)
===================================================================
---
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/script/popupPanelBorders.js
(rev 0)
+++
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/script/popupPanelBorders.js 2010-07-12
17:56:20 UTC (rev 17973)
@@ -0,0 +1,174 @@
+(function ($, richfaces) {
+
+ richfaces.ui = richfaces.ui || {};
+
+ richfaces.ui.PopupPanel.Border = function(id, modalPanel, cursor, sizer) {
+
+ $super.constructor.call(this,id);
+
+ var element = jQuery(id);
+ jQuery(element).css('cursor',cursor);
+ var border = this;
+ jQuery(this.id).bind( 'mousedown', {border:border},this.startDrag);
+
+ this.modalPanel = modalPanel;
+ this.sizer = sizer;
+ };
+
+ var $super = richfaces.BaseComponent.extend(richfaces.BaseComponent,
richfaces.ui.PopupPanel.Border);
+ var $super = richfaces.ui.PopupPanel.Border.$super;
+
+ $.extend(richfaces.ui.PopupPanel.Border.prototype, (function (options) {
+
+ return {
+
+ name: "RichFaces.ui.PopupPanel.Border",
+
+ destroy: function()
+ {
+ if (this.doingDrag)
+ {
+ jQuery(document).unbind( 'mousemove', this.doDrag);
+ jQuery(document).unbind( 'mouseup', this.endDrag);
+ }
+
+ jQuery(this.id).unbind( 'mousedown', this.startDrag);
+ this.modalPanel=null;
+ },
+
+ show: function() {
+ jQuery(this.id).show();
+ },
+
+ hide: function() {
+ jQuery(this.id).hide();
+ },
+
+ startDrag: function(event) {
+ var border = event.data.border;
+ border.doingDrag = true;
+
+ border.dragX = event.clientX;
+ border.dragY = event.clientY;
+ jQuery(document).bind( 'mousemove',{border:border}, border.doDrag);
+ jQuery(document).bind( 'mouseup',{border:border}, border.endDrag);
+
+ //var eCursorDiv = jQuery(border.modalPanel.cDiv);
+ //jQuery(eCursorDiv).css('cursor', jQuery(border.id).css('cursor'));
+ //jQuery(eCursorDiv).css('zIndex', 10);
+
+ border.modalPanel.startDrag(border);
+
+ border.onselectStartHandler = document.onselectstart;
+ document.onselectstart = function() { return false; }
+ },
+
+ getWindowSize : function() {
+ var myWidth = 0, myHeight = 0;
+ if( typeof( window.innerWidth ) == 'number' ) {
+ myWidth = window.innerWidth;
+ myHeight = window.innerHeight;
+ } else if( document.documentElement && (
document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
+ myWidth = document.documentElement.clientWidth;
+ myHeight = document.documentElement.clientHeight;
+ } else if( document.body && ( document.body.clientWidth ||
document.body.clientHeight ) ) {
+ myWidth = document.body.clientWidth;
+ myHeight = document.body.clientHeight;
+ }
+ return {"width":myWidth,"height":myHeight};
+ },
+
+ doDrag: function(event) {
+ var border = event.data.border;
+ if (!border.doingDrag) {
+ return ;
+ }
+
+ var evtX = event.clientX;
+ var evtY = event.clientY;
+
+ var winSize = border.getWindowSize();
+
+ if (evtX < 0) {
+ evtX = 0;
+ } else if (evtX >= winSize.width) {
+ evtX = winSize.width - 1;
+ }
+
+ if (evtY < 0) {
+ evtY = 0;
+ } else if (evtY >= winSize.height) {
+ evtY = winSize.height - 1;
+ }
+
+ var dx = evtX - border.dragX;
+ var dy = evtY - border.dragY;
+
+ if (dx != 0 || dy != 0) {
+
+ var id = border.id;
+
+ var diff = border.sizer.prototype.doDiff(dx, dy);//TODO
+ var doResize;
+
+ var element = jQuery(border.modalPanel.cdiv);
+
+ if (diff.deltaWidth || diff.deltaHeight) {
+ doResize = border.modalPanel.invokeEvent("resize",event,null,element);
+ } else if (diff.deltaX || diff.deltaY) {
+ doResize = border.modalPanel.invokeEvent("move",event,null,element);
+ }
+
+ var vetoes;
+
+ if (doResize) {
+ vetoes = border.modalPanel.doResizeOrMove(diff);
+ }
+
+ if(vetoes){
+ if (!vetoes.x) {
+ border.dragX = evtX;
+ } else {
+ if (!diff.deltaX) {
+ border.dragX -= vetoes.vx || 0;
+ } else {
+ border.dragX += vetoes.vx || 0;
+ }
+ }
+
+ if (!vetoes.y) {
+ border.dragY = evtY;
+ } else {
+ if (!diff.deltaY) {
+ border.dragY -= vetoes.vy || 0;
+ } else {
+ border.dragY += vetoes.vy || 0;
+ }
+ }
+ }
+ }
+ },
+
+ endDrag: function(event) {
+ var border = event.data.border;
+ border.doingDrag = undefined;
+
+ jQuery(document).unbind( 'mousemove', border.doDrag);
+ jQuery(document).unbind( 'mouseup', border.endDrag);
+
+ border.modalPanel.endDrag(border);
+
+ border.modalPanel.doResizeOrMove(richfaces.ui.PopupPanel.Sizer.Diff.EMPTY);
+
+ document.onselectstart = border.onselectStartHandler;
+ border.onselectStartHandler = null;
+ },
+
+ doPosition: function() {
+ this.sizer.prototype.doPosition(this.modalPanel, jQuery(this.id)); //TODO remove
prototype
+ }
+ }
+
+ })());
+
+})(jQuery, window.RichFaces);
\ No newline at end of file
Copied:
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/script/popupPanelSizer.js (from
rev 17965,
root/ui-sandbox/panels2/trunk/ui/src/main/resources/META-INF/script/popupPanelSizer.js)
===================================================================
--- root/ui/output/trunk/panels/ui/src/main/resources/META-INF/script/popupPanelSizer.js
(rev 0)
+++
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/script/popupPanelSizer.js 2010-07-12
17:56:20 UTC (rev 17973)
@@ -0,0 +1,279 @@
+(function ($, richfaces) {
+
+ richfaces.ui = richfaces.ui || {};
+
+ richfaces.ui.PopupPanel.Sizer = function(id, modalPanel, cursor, sizer) {
+
+ $super.constructor.call(this,id);
+
+ };
+
+ var $super = richfaces.BaseComponent.extend(richfaces.BaseComponent,
richfaces.ui.PopupPanel.Sizer);
+ var $super = richfaces.ui.PopupPanel.Sizer.$super;
+ $.extend(richfaces.ui.PopupPanel.Sizer.prototype, (function (options) {
+ return {
+
+ name: "richfaces.ui.PopupPanel.Sizer",
+
+ doSetupSize: function (modalPanel, elt) {
+ var width = 0;
+ var height = 0;
+
+ var reductionData = modalPanel.reductionData;
+
+ if (reductionData) {
+ if (reductionData.w) {
+ width = reductionData.w / 2;
+ }
+
+ if (reductionData.h) {
+ height = reductionData.h / 2;
+ }
+ }
+
+ if (width > 0) {
+ if (elt.clientWidth > width) {
+ if (!elt.reducedWidth) {
+ elt.reducedWidth = jQuery(elt).css('width');
+ }
+ jQuery(elt).css('width', width + 'px');
+ } else if (width < 4 && elt.reducedWidth == 4 + 'px') {
+ jQuery(elt).css('width', width + 'px');
+ }
+ } else {
+ if (elt.reducedWidth) {
+ jQuery(elt).css('width', elt.reducedWidth);
+ elt.reducedWidth = undefined;
+ }
+ }
+
+ if (height > 0) {
+ if (elt.clientHeight > height) {
+ if (!elt.reducedHeight) {
+ elt.reducedHeight = jQuery(elt).css('height');
+ }
+ elt.style.height = height + 'px';
+ } else if (height < 4 && elt.reducedHeight == 4 + 'px') {
+ jQuery(elt).css('height', height + 'px');
+ }
+ } else {
+ if (elt.reducedHeight) {
+ jQuery(elt).css('height', elt.reducedHeight);
+ elt.reducedHeight = undefined;
+ }
+ }
+ },
+
+ doSetupPosition: function (modalPanel, elt, left, top) {
+ if(!isNaN(left) && !isNaN(top)){
+ jQuery(elt).css('left', left + 'px');
+ jQuery(elt).css('top', top + 'px');
+ }
+ },
+
+ doPosition: function (modalPanel, elt) {
+
+ },
+
+ doDiff: function (dx, dy) {
+
+ }
+ }
+
+ })());
+ richfaces.ui.PopupPanel.Sizer.Diff = function(dX, dY, dWidth, dHeight) {
+
+ this.deltaX = dX;
+ this.deltaY = dY;
+
+ this.deltaWidth = dWidth;
+ this.deltaHeight = dHeight;
+
+ };
+
+ richfaces.ui.PopupPanel.Sizer.Diff.EMPTY = function(){
+ return new richfaces.ui.PopupPanel.Sizer.Diff(0, 0, 0, 0);
+ },
+
+ richfaces.ui.PopupPanel.Sizer.N = function(){
+
+ }
+
+ $.extend(richfaces.ui.PopupPanel.Sizer.N.prototype,
richfaces.ui.PopupPanel.Sizer.prototype);
+ $.extend(richfaces.ui.PopupPanel.Sizer.N.prototype, {
+
+
+ name: "richfaces.ui.PopupPanel.Sizer.N",
+
+ doPosition : function (popupPanel, elt) {
+ jQuery(elt).css('width',popupPanel.width() + 'px');
+ this.doSetupPosition(popupPanel, elt, 0, 0);
+ },
+
+ doDiff : function(dx, dy) {
+ return new richfaces.ui.PopupPanel.Sizer.Diff(0, dy, 0, -dy);
+ },
+
+ });
+
+ richfaces.ui.PopupPanel.Sizer.NW = function(){
+
+ }
+ $.extend(richfaces.ui.PopupPanel.Sizer.NW.prototype,
richfaces.ui.PopupPanel.Sizer.prototype);
+ $.extend(richfaces.ui.PopupPanel.Sizer.NW.prototype, {
+
+ name: "richfaces.ui.PopupPanel.Sizer.NW",
+
+ doPosition : function (popupPanel, elt) {
+ this.doSetupSize(popupPanel, elt);
+ this.doSetupPosition(popupPanel, elt, 0, 0);
+ },
+
+ doDiff : function(dx, dy) {
+ return new richfaces.ui.PopupPanel.Sizer.Diff(dx, dy, -dx, -dy);
+ }
+
+ });
+
+ richfaces.ui.PopupPanel.Sizer.NE = function(){
+
+ }
+ $.extend(richfaces.ui.PopupPanel.Sizer.NE.prototype,
richfaces.ui.PopupPanel.Sizer.prototype);
+ $.extend(richfaces.ui.PopupPanel.Sizer.NE.prototype, {
+
+ name: "richfaces.ui.PopupPanel.Sizer.NE",
+
+ doPosition : function (popupPanel, elt) {
+ this.doSetupSize(popupPanel, elt);
+ this.doSetupPosition(popupPanel, elt, popupPanel.width() - elt.clientWidth, 0);
+ },
+
+ doDiff : function(dx, dy) {
+ return new richfaces.ui.PopupPanel.Sizer.Diff(0, dy, dx, -dy);
+ }
+
+ });
+
+ richfaces.ui.PopupPanel.Sizer.E = function(){
+
+ }
+ $.extend(richfaces.ui.PopupPanel.Sizer.E.prototype,
richfaces.ui.PopupPanel.Sizer.prototype);
+ $.extend(richfaces.ui.PopupPanel.Sizer.E.prototype, {
+
+ name: "richfaces.ui.PopupPanel.Sizer.E",
+
+ doPosition : function (popupPanel, elt) {
+ jQuery(elt).css('height', popupPanel.height() + 'px');
+ this.doSetupPosition(popupPanel, elt, popupPanel.width() - elt.clientWidth, 0);
+ },
+
+ doDiff : function(dx, dy) {
+ return new richfaces.ui.PopupPanel.Sizer.Diff(0, 0, dx, 0);
+ }
+
+ });
+
+ richfaces.ui.PopupPanel.Sizer.SE = function(){
+
+ }
+ $.extend(richfaces.ui.PopupPanel.Sizer.SE.prototype,
richfaces.ui.PopupPanel.Sizer.prototype);
+ $.extend(richfaces.ui.PopupPanel.Sizer.prototype.SE, {
+
+ name: "richfaces.ui.PopupPanel.Sizer.SE",
+
+ doPosition : function (popupPanel, elt) {
+ this.doSetupSize(popupPanel, elt);
+ this.doSetupPosition(popupPanel, elt, popupPanel.width() - elt.clientWidth,
+ popupPanel.height() - elt.clientHeight);
+ },
+
+ doDiff : function(dx, dy) {
+ return new richfaces.ui.PopupPanel.Sizer.Diff(0, 0, dx, dy);
+ }
+
+ });
+
+ richfaces.ui.PopupPanel.Sizer.S = function(){
+
+ }
+ $.extend(richfaces.ui.PopupPanel.Sizer.S.prototype,
richfaces.ui.PopupPanel.Sizer.prototype);
+ $.extend(richfaces.ui.PopupPanel.Sizer.S.prototype,{
+
+ name: "richfaces.ui.PopupPanel.Sizer.S",
+
+ doPosition : function (popupPanel, elt) {
+ jQuery(elt).css('width', popupPanel.width() + 'px');
+ this.doSetupPosition(popupPanel, elt, 0, popupPanel.height() - elt.clientHeight);
+ },
+
+ doDiff : function(dx, dy) {
+ return new richfaces.ui.PopupPanel.Sizer.Diff(0, 0, 0, dy);
+ }
+
+ });
+
+
+ richfaces.ui.PopupPanel.Sizer.SW = function(){
+
+ }
+ $.extend(richfaces.ui.PopupPanel.Sizer.SW.prototype,
richfaces.ui.PopupPanel.Sizer.prototype);
+ $.extend(richfaces.ui.PopupPanel.Sizer.SW.prototype,{
+
+
+ name: "richfaces.ui.PopupPanel.Sizer.SW",
+
+ doPosition : function (popupPanel, elt) {
+ this.doSetupSize(popupPanel, elt);
+ this.doSetupPosition(popupPanel, elt, 0, popupPanel.height() - elt.clientHeight);
+ },
+
+ doDiff : function(dx, dy) {
+ return new richfaces.ui.PopupPanel.Sizer.Diff(dx, 0, -dx, dy);
+ }
+
+ });
+
+ richfaces.ui.PopupPanel.Sizer.W = function(){
+
+ }
+ $.extend(richfaces.ui.PopupPanel.Sizer.W.prototype,
richfaces.ui.PopupPanel.Sizer.prototype);
+ $.extend(richfaces.ui.PopupPanel.Sizer.W.prototype,{
+
+
+ name: "richfaces.ui.PopupPanel.Sizer.W",
+
+ doPosition : function (popupPanel, elt) {
+ jQuery(elt).css('height', popupPanel.height() + 'px');
+ this.doSetupPosition(popupPanel, elt, 0, 0);
+ },
+
+ doDiff : function(dx, dy) {
+ return new richfaces.ui.PopupPanel.Sizer.Diff(dx, 0, -dx, 0);
+ }
+
+
+ });
+
+
+ richfaces.ui.PopupPanel.Sizer.Header = function(){
+
+ }
+ $.extend(richfaces.ui.PopupPanel.Sizer.Header.prototype,
richfaces.ui.PopupPanel.Sizer.prototype);
+ $.extend(richfaces.ui.PopupPanel.Sizer.Header.prototype, {
+
+
+ name: "richfaces.ui.PopupPanel.Sizer.Header",
+
+ doPosition : function (popupPanel, elt) {
+
+ },
+
+ doDiff : function(dx, dy) {
+ return new richfaces.ui.PopupPanel.Sizer.Diff(dx, dy, 0, 0);
+ }
+
+
+ });
+
+
+})(jQuery, window.RichFaces);
\ No newline at end of file
Copied: root/ui/output/trunk/panels/ui/src/main/templates/panel.template.xml (from rev
17965, root/ui-sandbox/panels2/trunk/ui/src/main/templates/panel.template.xml)
===================================================================
--- root/ui/output/trunk/panels/ui/src/main/templates/panel.template.xml
(rev 0)
+++ root/ui/output/trunk/panels/ui/src/main/templates/panel.template.xml 2010-07-12
17:56:20 UTC (rev 17973)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<cdk:root
xmlns="http://richfaces.org/cdk/xhtml-el"
+
xmlns:cdk="http://richfaces.org/cdk/core"
+
xmlns:c="http://richfaces.org/cdk/jstl/core"
+
xmlns:cc="http://richfaces.org/cdk/jsf/composite"
+
xmlns:javaee="http://java.sun.com/xml/ns/javaee">
+
+ <cc:interface>
+ <cdk:class>org.richfaces.renderkit.html.PanelRenderer</cdk:class>
+ <cdk:superclass>org.richfaces.renderkit.html.PanelBaseRenderer</cdk:superclass>
+ <cdk:component-family>org.richfaces.Panel</cdk:component-family>
+ <cdk:renderer-type>org.richfaces.PanelRenderer</cdk:renderer-type>
+ </cc:interface>
+
+ <cc:implementation>
+ <div cdk:passThroughWithExclusions="id,value,styleClass,class"
id="#{clientId}" class="rf-panel
#{component.attributes['styleClass']}">
+ <c:choose>
+ <c:when test="#{component.getFacet('header') != null and
component.getFacet('header').rendered}">
+ <div id="#{clientId}_header" class="rf-panel-header
#{component.attributes['headerClass']}">
+ <!-- <cc:renderFacet name="header" />-->
+ <cdk:call expression="renderHeaderFacet(facesContext, component)"
/>
+ </div>
+ </c:when>
+ <c:when test="#{component.attributes['header']!= null and not
component.attributes['header'].equals('')}">
+ <div id="#{clientId}_header" class="rf-panel-header
#{component.attributes['headerClass']}">
+ #{component.attributes['header']}
+ </div>
+ </c:when>
+ <c:otherwise>
+ </c:otherwise>
+ </c:choose>
+ <div id="#{clientId}_body" class="rf-panel-body
#{component.attributes['bodyClass']}">
+ <cdk:call expression="renderChildren(facesContext, component)" />
+ </div>
+ </div>
+
+ </cc:implementation>
+</cdk:root>
\ No newline at end of file
Copied: root/ui/output/trunk/panels/ui/src/main/templates/popupPanel.template.xml (from
rev 17965, root/ui-sandbox/panels2/trunk/ui/src/main/templates/popupPanel.template.xml)
===================================================================
--- root/ui/output/trunk/panels/ui/src/main/templates/popupPanel.template.xml
(rev 0)
+++ root/ui/output/trunk/panels/ui/src/main/templates/popupPanel.template.xml 2010-07-12
17:56:20 UTC (rev 17973)
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<cdk:root
xmlns="http://richfaces.org/cdk/xhtml-el"
+
xmlns:cdk="http://richfaces.org/cdk/core"
+
xmlns:c="http://richfaces.org/cdk/jstl/core"
+
xmlns:cc="http://richfaces.org/cdk/jsf/composite"
+
xmlns:javaee="http://java.sun.com/xml/ns/javaee">
+
+ <cc:interface>
+ <cdk:class>org.richfaces.renderkit.html.PopupPanelRenderer</cdk:class>
+ <cdk:superclass>org.richfaces.renderkit.html.PopupPanelBaseRenderer</cdk:superclass>
+ <cdk:component-family>org.richfaces.PopupPanel</cdk:component-family>
+ <cdk:renderer-type>org.richfaces.PopupPanelRenderer</cdk:renderer-type>
+ </cc:interface>
+
+ <cc:implementation>
+ <cdk:call expression="checkOptions(facesContext, component)" />
+ <div id="#{clientId}" style="visibility: hidden;">
+ <button class="mp-button"
id="#{clientId}FirstHref"></button>
+ <c:if test="#{component.attributes['modal']}">
+ <div id="#{clientId}_shade"
onclick="#{component.attributes['onmaskclick']}"
+ ondblclick="#{component.attributes['onmaskdblclick']}"
+ oncontextmenu="#{component.attributes['onmaskcontextmenu']}"
+ onmouseup="#{component.attributes['onmaskmouseup']}"
+ onmousedown="#{component.attributes['onmaskmousedown']}"
+ onmousemove="#{component.attributes['onmaskmousemove']}"
+ onmouseover="#{component.attributes['onmaskmouseover']}"
+ onmouseout="#{component.attributes['onmaskmouseout']}"
class="mp_shade"/>
+
+</c:if>
+ <div id="#{clientId}_shadow" class="mp_shadow"/>
+ <div id="#{clientId}_container"
cdk:passThroughWithExclusions="id,style,class,styleClass"
class="mp_container #{component.attributes['styleClass']}">
+ <div id="#{clientId}_header" class="mp_header
#{component.attributes['headerClass']}" >
+ <c:if test="#{component.getFacet('header')!=null and
component.getFacet('header').rendered}">
+ <div id="#{clientId}_header_content"
class="mp_header_content">
+ <c:if test="#{component.attributes['autosized']}">
+ <span id="#{clientId}_headerSpan">
+ <cdk:call expression="renderHeaderFacet(facesContext, component)"/>
+ </span>
+ </c:if>
+ <c:if test="#{!component.attributes['autosized']}">
+ <cdk:call expression="renderHeaderFacet(facesContext, component)"/>
+ </c:if>
+ </div>
+ </c:if>
+ <c:if test="#{component.getFacet('controls')!=null and
component.getFacet('controls').rendered}">
+ <div id="#{clientId}_header_controls" class="mp_header_controls
#{component.attributes['controlsClass']}">
+ <cdk:call expression="renderControlsFacet(facesContext,
component)"/>
+ </div>
+ </c:if>
+ </div>
+ <div id="#{clientId}_content_scroller" class="mp_content_scroller
#{component.attributes['scrollerClass']}">
+ <div id="#{clientId}_content" class="mp_content"
style="#{component.attributes['style']}">
+ <cdk:call expression="renderChildren(facesContext, component)"/>
+ </div>
+ </div>
+ <c:if test="#{component.attributes['resizeable']}">
+ <div id="#{clientId}ResizerW" class="mp_handler
mp_handler_left"></div>
+ <div id="#{clientId}ResizerE" class="mp_handler
mp_handler_right"></div>
+ <div id="#{clientId}ResizerN" class="mp_handler
mp_handler_top"></div>
+
+ <div id="#{clientId}ResizerS" class="mp_handler
mp_handler_bottom"></div>
+ <div id="#{clientId}ResizerNW" class="mp_handler
mp_handler_top_left"></div>
+ <div id="#{clientId}ResizerNE" class="mp_handler
mp_handler_top_right"></div>
+ <div id="#{clientId}ResizerSW" class="mp_handler
mp_handler_bottom_left"></div>
+ <div id="#{clientId}ResizerSE" class="mp_handler
mp_handler_bottom_right"></div>
+ </c:if>
+
+ </div>
+
+
+
+<button class="mp-button"
id="#{clientId}LastHref"></button>
+</div>
+<cdk:object type="java.lang.String" name="script"
value="#{buildScript(facesContext, component)}" />
+ <cdk:object type="java.lang.String" name="showScript"
value="#{buildShowScript(facesContext, component)}" />
+ <script type="text/javascript">
+ #{script}
+ </script>
+ <c:if test="#{showScript != null}">
+ <script type="text/javascript">
+ #{showScript}
+ </script>
+ </c:if>
+
+
+ </cc:implementation>
+</cdk:root>
\ No newline at end of file
Copied:
root/ui/output/trunk/panels/ui/src/test/java/org/richfaces/renderkit/html/PanelRendererTest.java
(from rev 17965,
root/ui-sandbox/panels2/trunk/ui/src/test/java/org/richfaces/renderkit/html/PanelRendererTest.java)
===================================================================
---
root/ui/output/trunk/panels/ui/src/test/java/org/richfaces/renderkit/html/PanelRendererTest.java
(rev 0)
+++
root/ui/output/trunk/panels/ui/src/test/java/org/richfaces/renderkit/html/PanelRendererTest.java 2010-07-12
17:56:20 UTC (rev 17973)
@@ -0,0 +1,157 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.renderkit.html;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.faces.application.ViewHandler;
+import javax.faces.context.FacesContext;
+import javax.faces.view.ViewDeclarationLanguage;
+
+import org.jboss.test.faces.FacesEnvironment.FacesRequest;
+import org.jboss.test.faces.htmlunit.HtmlUnitEnvironment;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.richfaces.component.UIPanel;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * @author Andrey Markhel
+ *
+ */
+public class PanelRendererTest {
+
+ private HtmlUnitEnvironment environment;
+
+ @Before
+ public void setUp() {
+ environment = new HtmlUnitEnvironment();
+ environment.withWebRoot(new File("src/test/resources"));
+ environment.start();
+ }
+
+ @After
+ public void tearDown() {
+ environment.release();
+ environment = null;
+ }
+
+ private FacesRequest startFacesRequest() throws IOException {
+ FacesRequest facesRequest =
environment.createFacesRequest("http://localhost/panelTest.jsf");
+ facesRequest.withViewId("/panelTest.jsf");
+ facesRequest.start();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ViewHandler vh = facesContext.getApplication().getViewHandler();
+ ViewDeclarationLanguage vdl = vh.getViewDeclarationLanguage(facesContext,
facesContext.getViewRoot()
+ .getViewId());
+ vdl.buildView(facesContext, facesContext.getViewRoot());
+ return facesRequest;
+ }
+ /**
+ * Test method for {@link
org.richfaces.renderkit.ExtendedDataTableRenderer#getComponentClass()}.
+ *
+ * @throws IOException
+ */
+ @Test
+ public final void testGetComponentClass() throws IOException {
+ FacesRequest facesRequest = startFacesRequest();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ UIPanel component = (UIPanel)
facesContext.getViewRoot().findComponent("panelWithFacet");
+ PanelRenderer renderer = (PanelRenderer) FacesContext.getCurrentInstance()
+ .getRenderKit().getRenderer(component.getFamily(),
component.getRendererType());
+ assertEquals(UIPanel.class, renderer.getComponentClass());
+ facesRequest.release();
+ }
+
+ /**
+ * Test method for
+ * {@link
org.richfaces.renderkit.ExtendedDataTableRenderer#doEncodeBegin(javax.faces.context.ResponseWriter,
+ * javax.faces.context.FacesContext, javax.faces.component.UIComponent)}.
+ *
+ * @throws IOException
+ */
+ /*@Test
+ public final void testDoEncode() throws IOException {
+ HtmlPage page = environment.getPage("/panelTest.jsf");
+ HtmlElement panelWithFacet = page.getElementById("panelWithFacet");
+ assertEquals("rf-panel panel",
panelWithFacet.getAttribute("class"));
+ assertEquals("Write your own custom rich components with built-in AJAX
support",
panelWithFacet.getElementById("panelWithFacet_header").getTextContent().trim());
+ assertEquals("The CDK includes",
panelWithFacet.getElementById("panelWithFacet_body")
+ .getTextContent().trim().substring(0, 16));
+ HtmlElement simplePanel = page.getElementById("simplePanel");
+ assertEquals("rf-panel ",
simplePanel.getAttribute("class"));
+ try{
+ simplePanel.getElementById("simplePanel_header");
+ }catch(Exception e){
+ assertTrue(true);
+ }
+ assertEquals("RichFaces is a l", simplePanel
+ .getElementById("simplePanel_body")
+ .getTextContent().trim().substring(0, 16));
+ HtmlElement simplePanelBody = page.getElementById("simplePanel_body");
+ assertEquals("rf-panel-body rich-laguna-panel-no-header",
simplePanelBody.getAttribute("class"));
+ HtmlElement simplePanel2 =
page.getElementById("simplePanelWithTextHeader");
+ assertEquals("rf-panel ",
simplePanel2.getAttribute("class"));
+
assertNotNull(simplePanel2.getElementById("simplePanelWithTextHeader_header"));
+ assertEquals("rich-laguna-panel-no-header",
simplePanel2.getElementById("simplePanelWithTextHeader_header").getTextContent().trim());
+ assertEquals("RichFaces is a l", simplePanel2
+ .getElementById("simplePanelWithTextHeader_body")
+ .getTextContent().trim().substring(0, 16));
+
+ HtmlElement nestedPanelContainer =
page.getElementById("nestedPanelContainer");
+ assertEquals("rf-panel ",
nestedPanelContainer.getAttribute("class"));
+
assertNotNull(nestedPanelContainer.getElementById("nestedPanelContainer_header"));
+ assertEquals("||||",
nestedPanelContainer.getElementById("nestedPanelContainer_header").getTextContent().trim());
+ HtmlElement nestedPanelContainerHeader =
page.getElementById("nestedPanelContainer_header");
+ assertEquals("rf-panel-header outpanelHeader",
nestedPanelContainerHeader.getAttribute("class"));
+ assertEquals("Benefits of Usin", nestedPanelContainer
+ .getElementById("nestedPanelContainer_body")
+ .getTextContent().trim().substring(0, 16));
+ HtmlElement nestedPanel1 =
nestedPanelContainer.getElementById("nestedPanel1");
+ assertEquals("rf-panel ",
nestedPanel1.getAttribute("class"));
+ HtmlElement nestedPanel1Body =
page.getElementById("nestedPanel1_body");
+ assertEquals("rf-panel-body inpanelBody",
nestedPanel1Body.getAttribute("class"));
+ assertNotNull(nestedPanel1.getElementById("nestedPanel1_header"));
+ assertEquals("For Application Developers",
nestedPanel1.getElementById("nestedPanel1_header").getTextContent().trim());
+ assertEquals("Production quali", nestedPanel1
+ .getElementById("nestedPanel1_body")
+ .getTextContent().trim().substring(0, 16));
+ HtmlElement nestedPanel2 =
nestedPanelContainer.getElementById("nestedPanel2");
+ assertEquals("rf-panel ",
nestedPanel2.getAttribute("class"));
+ HtmlElement nestedPanel2Body =
page.getElementById("nestedPanel2_body");
+ assertEquals("rf-panel-body inpanelBody",
nestedPanel2Body.getAttribute("class"));
+ assertNotNull(nestedPanel2.getElementById("nestedPanel2_header"));
+ assertEquals("For Component Developers",
nestedPanel2.getElementById("nestedPanel2_header").getTextContent().trim());
+ assertEquals("Ajax4jsf is Open", nestedPanel2
+ .getElementById("nestedPanel2_body")
+ .getTextContent().trim().substring(0, 16));
+ }*/
+
+}
Copied:
root/ui/output/trunk/panels/ui/src/test/java/org/richfaces/renderkit/html/PopupRendererTest.java
(from rev 17965,
root/ui-sandbox/panels2/trunk/ui/src/test/java/org/richfaces/renderkit/html/PopupRendererTest.java)
===================================================================
---
root/ui/output/trunk/panels/ui/src/test/java/org/richfaces/renderkit/html/PopupRendererTest.java
(rev 0)
+++
root/ui/output/trunk/panels/ui/src/test/java/org/richfaces/renderkit/html/PopupRendererTest.java 2010-07-12
17:56:20 UTC (rev 17973)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.renderkit.html;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.faces.application.ViewHandler;
+import javax.faces.context.FacesContext;
+import javax.faces.view.ViewDeclarationLanguage;
+
+import org.jboss.test.faces.FacesEnvironment.FacesRequest;
+import org.jboss.test.faces.htmlunit.HtmlUnitEnvironment;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.richfaces.component.UIPanel;
+import org.richfaces.component.UIPopupPanel;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * @author Andrey Markhel
+ *
+ */
+public class PopupRendererTest {
+
+ private HtmlUnitEnvironment environment;
+
+ @Before
+ public void setUp() {
+ environment = new HtmlUnitEnvironment();
+ environment.withWebRoot(new File("src/test/resources"));
+ environment.start();
+ }
+
+ @After
+ public void tearDown() {
+ environment.release();
+ environment = null;
+ }
+
+ private FacesRequest startFacesRequest() throws IOException {
+ FacesRequest facesRequest =
environment.createFacesRequest("http://localhost/popupPanelTest.jsf");
+ facesRequest.withViewId("/popupPanelTest.jsf");
+ facesRequest.start();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ViewHandler vh = facesContext.getApplication().getViewHandler();
+ ViewDeclarationLanguage vdl = vh.getViewDeclarationLanguage(facesContext,
facesContext.getViewRoot()
+ .getViewId());
+ vdl.buildView(facesContext, facesContext.getViewRoot());
+ return facesRequest;
+ }
+ /**
+ * Test method for {@link
org.richfaces.renderkit.ExtendedDataTableRenderer#getComponentClass()}.
+ *
+ * @throws IOException
+ */
+ @Test
+ public final void testGetComponentClass() throws IOException {
+ /*FacesRequest facesRequest = startFacesRequest();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ UIPopupPanel component = (UIPopupPanel)
facesContext.getViewRoot().findComponent("panel");
+ PopupPanelRenderer renderer = (PopupPanelRenderer)
FacesContext.getCurrentInstance()
+ .getRenderKit().getRenderer(component.getFamily(),
component.getRendererType());
+ assertEquals(UIPopupPanel.class, renderer.getComponentClass());
+ facesRequest.release();*/
+ return ;
+ }
+
+ /**
+ * Test method for
+ * {@link
org.richfaces.renderkit.ExtendedDataTableRenderer#doEncodeBegin(javax.faces.context.ResponseWriter,
+ * javax.faces.context.FacesContext, javax.faces.component.UIComponent)}.
+ *
+ * @throws IOException
+ */
+ /*@Test
+ public final void testDoEncode() throws IOException {
+ HtmlPage page = environment.getPage("/panelTest.jsf");
+ HtmlElement panelWithFacet = page.getElementById("panelWithFacet");
+ assertEquals("rf-panel panel",
panelWithFacet.getAttribute("class"));
+ assertEquals("Write your own custom rich components with built-in AJAX
support",
panelWithFacet.getElementById("panelWithFacet_header").getTextContent().trim());
+ assertEquals("The CDK includes",
panelWithFacet.getElementById("panelWithFacet_body")
+ .getTextContent().trim().substring(0, 16));
+ HtmlElement simplePanel = page.getElementById("simplePanel");
+ assertEquals("rf-panel ",
simplePanel.getAttribute("class"));
+ try{
+ simplePanel.getElementById("simplePanel_header");
+ }catch(Exception e){
+ assertTrue(true);
+ }
+ assertEquals("RichFaces is a l", simplePanel
+ .getElementById("simplePanel_body")
+ .getTextContent().trim().substring(0, 16));
+ HtmlElement simplePanelBody = page.getElementById("simplePanel_body");
+ assertEquals("rf-panel-body rich-laguna-panel-no-header",
simplePanelBody.getAttribute("class"));
+ HtmlElement simplePanel2 =
page.getElementById("simplePanelWithTextHeader");
+ assertEquals("rf-panel ",
simplePanel2.getAttribute("class"));
+
assertNotNull(simplePanel2.getElementById("simplePanelWithTextHeader_header"));
+ assertEquals("rich-laguna-panel-no-header",
simplePanel2.getElementById("simplePanelWithTextHeader_header").getTextContent().trim());
+ assertEquals("RichFaces is a l", simplePanel2
+ .getElementById("simplePanelWithTextHeader_body")
+ .getTextContent().trim().substring(0, 16));
+
+ HtmlElement nestedPanelContainer =
page.getElementById("nestedPanelContainer");
+ assertEquals("rf-panel ",
nestedPanelContainer.getAttribute("class"));
+
assertNotNull(nestedPanelContainer.getElementById("nestedPanelContainer_header"));
+ assertEquals("||||",
nestedPanelContainer.getElementById("nestedPanelContainer_header").getTextContent().trim());
+ HtmlElement nestedPanelContainerHeader =
page.getElementById("nestedPanelContainer_header");
+ assertEquals("rf-panel-header outpanelHeader",
nestedPanelContainerHeader.getAttribute("class"));
+ assertEquals("Benefits of Usin", nestedPanelContainer
+ .getElementById("nestedPanelContainer_body")
+ .getTextContent().trim().substring(0, 16));
+ HtmlElement nestedPanel1 =
nestedPanelContainer.getElementById("nestedPanel1");
+ assertEquals("rf-panel ",
nestedPanel1.getAttribute("class"));
+ HtmlElement nestedPanel1Body =
page.getElementById("nestedPanel1_body");
+ assertEquals("rf-panel-body inpanelBody",
nestedPanel1Body.getAttribute("class"));
+ assertNotNull(nestedPanel1.getElementById("nestedPanel1_header"));
+ assertEquals("For Application Developers",
nestedPanel1.getElementById("nestedPanel1_header").getTextContent().trim());
+ assertEquals("Production quali", nestedPanel1
+ .getElementById("nestedPanel1_body")
+ .getTextContent().trim().substring(0, 16));
+ HtmlElement nestedPanel2 =
nestedPanelContainer.getElementById("nestedPanel2");
+ assertEquals("rf-panel ",
nestedPanel2.getAttribute("class"));
+ HtmlElement nestedPanel2Body =
page.getElementById("nestedPanel2_body");
+ assertEquals("rf-panel-body inpanelBody",
nestedPanel2Body.getAttribute("class"));
+ assertNotNull(nestedPanel2.getElementById("nestedPanel2_header"));
+ assertEquals("For Component Developers",
nestedPanel2.getElementById("nestedPanel2_header").getTextContent().trim());
+ assertEquals("Ajax4jsf is Open", nestedPanel2
+ .getElementById("nestedPanel2_body")
+ .getTextContent().trim().substring(0, 16));
+ }*/
+
+}
\ No newline at end of file
Copied: root/ui/output/trunk/panels/ui/src/test/resources/panelTest.xhtml (from rev 17965,
root/ui-sandbox/panels2/trunk/ui/src/test/resources/panelTest.xhtml)
===================================================================
--- root/ui/output/trunk/panels/ui/src/test/resources/panelTest.xhtml
(rev 0)
+++ root/ui/output/trunk/panels/ui/src/test/resources/panelTest.xhtml 2010-07-12 17:56:20
UTC (rev 17973)
@@ -0,0 +1,98 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:panel="http://richfaces.org/panels"
+
xmlns:rich="http://richfaces.org/rich">
+<!--
+JBoss, Home of Professional Open Source
+Copyright ${year}, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+-->
+ <h:head>
+ <title>Richfaces ExtendedDataTable Test</title>
+ </h:head>
+
+ <h:body>
+ <panel:panel styleClass="panel" id="panelWithFacet">
+ <f:facet name="header">
+ Write your own custom rich components with built-in AJAX support
+ </f:facet>
+ The CDK includes a code-generation facility and a
+ templating facility using a JSP-like syntax. These capabilities help
+ to avoid a routine process of a component creation. The component factory
+ works like a well-oiled machine allowing the creation of first-class
+ rich components with built-in Ajax functionality even more easily than
+ the creation of simpler components by means of the traditional coding
+ approach.
+ </panel:panel>
+ <panel:panel id="simplePanel"
bodyClass="rich-laguna-panel-no-header">
+ RichFaces is a library for adding rich user interface features to JSF
+ applications. It extends the Ajax4jsf framework to include a large
+ (and growing) set of powerful rich AJAX-enabled components that come
+ with extensive skins support.
+ </panel:panel>
+ <panel:panel id="simplePanelWithTextHeader"
header="rich-laguna-panel-no-header">
+ RichFaces is a library for adding rich user interface features to JSF
+ applications. It extends the Ajax4jsf framework to include a large
+ (and growing) set of powerful rich AJAX-enabled components that come
+ with extensive skins support.
+ </panel:panel>
+ <panel:panel id="nestedPanelContainer" style="padding:0"
headerClass="outpanelHeader">
+ <f:facet name="header">
+ ||||
+ </f:facet>
+ <h2 align="center"><h:outputText value="Benefits of Using
Ajax4jsf" /></h2>
+ <h:panelGrid columns="2" columnClasses="gridContent">
+ <panel:panel id="nestedPanel1"
bodyClass="inpanelBody">
+ <f:facet name="header">
+ For Application Developers
+ </f:facet>
+ <ul>
+ <li>Production quality Open Source</li>
+ <li>Does Open Source and has an Open Architecture</li>
+ <li>Compatible with any JSF Implementation - MyFaces, JSF1.1,
JSF1.2</li>
+ <li>Allows to Ajaxify JSF application without writing
Javascript</li>
+ <li>Works with standard and third party components</li>
+ <li>Adds the Ajax capability to existing non-Ajax
components</li>
+ </ul>
+ </panel:panel>
+ <panel:panel id="nestedPanel2"
bodyClass="inpanelBody">
+ <f:facet name="header" >
+ For Component Developers
+ </f:facet>
+ <ul>
+ <li>Ajax4jsf is Open Source and has an Open
Architecture</li>
+ <li>Gives an API to create components with built-in Ajax
support</li>
+ <li>Has a Component Development Kit for rapid
development</li>
+ <li>Allows to skin the look-n-feel using both CSS and set of
skin-parameters</li>
+ <li>Automatically generates the unit test-cases for developing
components</li>
+ <li>Allows to pack javascript code, images, css inside the
final jar</li>
+ </ul>
+ </panel:panel>
+ </h:panelGrid>
+ </panel:panel>
+ </h:body>
+</html>
Copied: root/ui/output/trunk/panels/ui/src/test/resources/popupPanelText.xhtml (from rev
17965, root/ui-sandbox/panels2/trunk/ui/src/test/resources/popupPanelText.xhtml)
===================================================================
--- root/ui/output/trunk/panels/ui/src/test/resources/popupPanelText.xhtml
(rev 0)
+++ root/ui/output/trunk/panels/ui/src/test/resources/popupPanelText.xhtml 2010-07-12
17:56:20 UTC (rev 17973)
@@ -0,0 +1,82 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:panel="http://richfaces.org/panels"
+
xmlns:rich="http://richfaces.org/rich">
+<!--
+JBoss, Home of Professional Open Source
+Copyright ${year}, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+-->
+ <h:head>
+ <title>Richfaces ExtendedDataTable Test</title>
+ </h:head>
+
+ <h:body>
+
+ <panel:popupPanel domElementAttachment="body"
visualOptions="{left:400px;}" moveable="true"
overlapEmbedObjects="true" keepVisualState="true"
onmaskclick="alert('1')" width="600" height="400"
id="panel" left="500px" top="300px">
+ <f:facet name="header">
+ Write your own custom rich components with built-in AJAX
+ </f:facet>
+ <h:form>
+ <h:panelGroup layout="block"
style="width:500px,height:400px;">
+ The CDK includes a code-generation facility and a
+ templating facility using a JSP-like syntax. These capabilities help
+ to avoid a routine process of a component creation. The component factory
+ works like a well-oiled machine allowing the creation of first-class
+ rich components with built-in Ajax functionality even more easily than
+ the creation of simpler components by means of the traditional coding
+ approach.
+
+ <a4j:commandLink value="Hide">
+
+ <rich:componentControl target="panel" operation="hide"
event="click">
+ </rich:componentControl>
+ </a4j:commandLink>
+
+<h:inputText value="aaa"/>
+<a href="#" onclick="RichFaces.$('panel').setSize(500,
300)" tabindex="0">setSize
+ </a>
+ <a href="#" onclick="RichFaces.$('panel').resize(20,
50)" tabindex="0">resize
+ </a>
+ <a href="#" onclick="RichFaces.$('panel').move(20,
50)" tabindex="0">move
+ </a>
+
+ <a href="#" onclick="RichFaces.$('panel').moveTo(20,
50)" tabindex="0">moveTo
+ </a>
+ </h:panelGroup>
+ </h:form>
+ </panel:popupPanel>
+
+ <a4j:commandLink value="Show">
+
+ <rich:componentControl target="panel" operation="show"
event="click">
+ </rich:componentControl>
+ </a4j:commandLink>
+
+ </h:body>
+</html>
\ No newline at end of file