You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2010/06/08 14:02:47 UTC
svn commit: r952625 - in /myfaces/tobago/trunk:
tobago-core/src/main/java/org/apache/myfaces/tobago/component/
tobago-core/src/main/java/org/apache/myfaces/tobago/util/
tobago-core/src/test/java/org/apache/myfaces/tobago/util/
tobago-example/tobago-exa...
Author: lofwyr
Date: Tue Jun 8 12:02:47 2010
New Revision: 952625
URL: http://svn.apache.org/viewvc?rev=952625&view=rev
Log:
TOBAGO-892: Context menu on some components
- context menu for panels
- optimize facet handling
Added:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/FacetUtils.java
myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/FacetUtilsUniTest.java
myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/facet/
myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/facet/contextMenu/
myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/facet/contextMenu/panel.xhtml
Modified:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Facets.java
myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/navigation.xhtml
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js
myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css
myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Facets.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Facets.java?rev=952625&r1=952624&r2=952625&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Facets.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Facets.java Tue Jun 8 12:02:47 2010
@@ -27,6 +27,7 @@ public final class Facets {
public static final String COMPLETE = "complete";
public static final String CONFIRMATION = "confirmation";
public static final String CONSTRAINTS = "constraints";
+ public static final String CONTEXT_MENU = "contextMenu";
public static final String DROP_DOWN_MENU = "dropDownMenu";
public static final String LABEL = "label";
public static final String LAYOUT = "layout";
Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/FacetUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/FacetUtils.java?rev=952625&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/FacetUtils.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/FacetUtils.java Tue Jun 8 12:02:47 2010
@@ -0,0 +1,65 @@
+package org.apache.myfaces.tobago.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.myfaces.tobago.component.Facets;
+import org.apache.myfaces.tobago.internal.component.AbstractUIMenu;
+import org.apache.myfaces.tobago.internal.util.Deprecation;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * Utility class to provide a type save way to get a specific facet from a components.
+ */
+public class FacetUtils {
+
+ private FacetUtils() {
+ }
+
+ /**
+ * A type save utility to get the facet <code>contextMenu</code> from a component.
+ */
+ public static AbstractUIMenu getContextMenu(UIComponent component) {
+ return (AbstractUIMenu) component.getFacet(Facets.CONTEXT_MENU);
+ }
+
+ public static void setContextMenu(UIComponent component, AbstractUIMenu menu) {
+ component.getFacets().put(Facets.CONTEXT_MENU, menu);
+ }
+
+ /**
+ * A type save utility to get the facet <code>dropDownMenu</code> from a component.
+ * It also returns the deprecated facet <code>menupopup</code>
+ */
+ public static AbstractUIMenu getDropDownMenu(UIComponent component) {
+ UIComponent result = component.getFacet(Facets.DROP_DOWN_MENU);
+ if (result == null) {
+ result = component.getFacet(Facets.MENUPOPUP);
+ if (result != null) {
+ if (Deprecation.LOG.isWarnEnabled()) {
+ Deprecation.LOG.warn("Facet 'menupopup' was deprecated, please rename it to 'dropDownMenu'");
+ }
+ }
+ }
+ return (AbstractUIMenu) result;
+ }
+
+ public static void setDropDownMenu(UIComponent component, AbstractUIMenu menu) {
+ component.getFacets().put(Facets.DROP_DOWN_MENU, menu);
+ }
+}
Added: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/FacetUtilsUniTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/FacetUtilsUniTest.java?rev=952625&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/FacetUtilsUniTest.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/util/FacetUtilsUniTest.java Tue Jun 8 12:02:47 2010
@@ -0,0 +1,58 @@
+package org.apache.myfaces.tobago.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.myfaces.tobago.component.Facets;
+import org.apache.myfaces.tobago.component.UIMenu;
+import org.apache.myfaces.tobago.component.UIPanel;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class FacetUtilsUniTest {
+
+ @Test
+ public void testContextMenu() {
+ UIPanel panel = new UIPanel();
+ Assert.assertNull(FacetUtils.getContextMenu(panel));
+ UIMenu menu = new UIMenu();
+ FacetUtils.setContextMenu(panel, menu);
+ Assert.assertEquals(menu, FacetUtils.getContextMenu(panel));
+ }
+
+ @Test
+ public void testDropDownMenu() {
+ UIPanel panel = new UIPanel();
+ Assert.assertNull(FacetUtils.getContextMenu(panel));
+ UIMenu menu = new UIMenu();
+ FacetUtils.setDropDownMenu(panel, menu);
+ Assert.assertEquals(menu, FacetUtils.getDropDownMenu(panel));
+ }
+
+ /**
+ * @deprecated since 1.5.0
+ */
+ @Test
+ @Deprecated
+ public void testMenupopup() {
+ UIPanel panel = new UIPanel();
+ Assert.assertNull(FacetUtils.getContextMenu(panel));
+ UIMenu menu = new UIMenu();
+ panel.getFacets().put(Facets.MENUPOPUP, menu);
+ Assert.assertEquals(menu, FacetUtils.getDropDownMenu(panel));
+ }
+}
Added: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/facet/contextMenu/panel.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/facet/contextMenu/panel.xhtml?rev=952625&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/facet/contextMenu/panel.xhtml (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/facet/contextMenu/panel.xhtml Tue Jun 8 12:02:47 2010
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<f:view
+ xmlns:jsp="http://java.sun.com/JSP/Page"
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:tx="http://myfaces.apache.org/tobago/extension"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core">
+ <tc:page id="page">
+ <tc:gridLayoutConstraint width="500px" height="200px"/>
+ <f:facet name="layout">
+ <tc:gridLayout/>
+ </f:facet>
+
+ <tc:panel id="panel">
+ <f:facet name="layout">
+ <tc:gridLayout columns="*;*" rows="*;*"/>
+ </f:facet>
+ <f:facet name="contextMenu">
+ <tc:menu>
+ <tc:menuCommand onclick="alert('Main Menu 1')" label="Main Menu 1"/>
+ <tc:menuCommand onclick="alert('Main Menu 2')" label="Main Menu 2"/>
+ <tc:menu label="Main Submenu">
+ <tc:menuCommand onclick="alert('Main Menu 3')" label="Main Menu 3"/>
+ <tc:menuCommand onclick="alert('Main Menu 4')" label="Main Menu 4"/>
+ </tc:menu>
+ </tc:menu>
+ </f:facet>
+
+ <tc:textarea readonly="true" value="Main Menu">
+ <tc:gridLayoutConstraint columnSpan="2"/>
+ </tc:textarea>
+
+ <tc:textarea readonly="true" value="Also Main Menu"/>
+
+ <tc:panel>
+ <f:facet name="contextMenu">
+ <tc:menu>
+ <tc:menuCommand onclick="alert('Other Menu 1')" label="Other Menu 1"/>
+ <tc:menuCommand onclick="alert('Other Menu 2')" label="Other Menu 2"/>
+ <tc:menu label="Other Submenu">
+ <tc:menuCommand onclick="alert('Other Menu 3')" label="Other Menu 3"/>
+ <tc:menuCommand onclick="alert('Other Menu 4')" label="Other Menu 4"/>
+ </tc:menu>
+ </tc:menu>
+ </f:facet>
+
+ <tc:textarea readonly="true" value="Other Menu"/>
+ </tc:panel>
+
+ </tc:panel>
+ </tc:page>
+</f:view>
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/navigation.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/navigation.xhtml?rev=952625&r1=952624&r2=952625&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/navigation.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/navigation.xhtml Tue Jun 8 12:02:47 2010
@@ -46,7 +46,7 @@
<tc:button action="#{clientConfig.submit}" label="OK"/>
</tc:panel>
- <tc:tree>
+ <tc:tree showJunctions="true">
<tc:treeData value="#{browser.tree}" var="node">
<tc:treeNode link="#{node.resource}" label="#{node.label}" target="page:content"/>
</tc:treeData>
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java?rev=952625&r1=952624&r2=952625&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PanelRenderer.java Tue Jun 8 12:02:47 2010
@@ -17,8 +17,6 @@ package org.apache.myfaces.tobago.render
* limitations under the License.
*/
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.apache.myfaces.tobago.component.Facets;
import org.apache.myfaces.tobago.component.UIPanel;
import org.apache.myfaces.tobago.component.UIReload;
@@ -32,6 +30,8 @@ import org.apache.myfaces.tobago.renderk
import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -83,6 +83,9 @@ public class PanelRenderer extends Layou
if (panel instanceof UIPanel && ((UIPanel) panel).getTip() != null) {
writer.writeAttribute(HtmlAttributes.TITLE, ((UIPanel) panel).getTip(), true);
}
+
+ HtmlRendererUtils.encodeContextMenu(facesContext, writer, panel);
+
// TODO check ajax id
if (facesContext instanceof TobagoFacesContext && !((TobagoFacesContext) facesContext).isAjax()) {
Integer frequency = null;
@@ -99,7 +102,7 @@ public class PanelRenderer extends Layou
};
HtmlRendererUtils.writeScriptLoader(facesContext, null, cmds);
}
- HtmlRendererUtils.checkForCommandFacet(component, facesContext, writer);
+ HtmlRendererUtils.checkForCommandFacet(panel, facesContext, writer);
}
@Override
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java?rev=952625&r1=952624&r2=952625&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java Tue Jun 8 12:02:47 2010
@@ -33,7 +33,6 @@ import org.apache.myfaces.tobago.context
import org.apache.myfaces.tobago.context.ResourceManagerUtils;
import org.apache.myfaces.tobago.context.TobagoFacesContext;
import org.apache.myfaces.tobago.event.PageAction;
-import org.apache.myfaces.tobago.internal.util.Deprecation;
import org.apache.myfaces.tobago.internal.util.StringUtils;
import org.apache.myfaces.tobago.layout.LayoutBase;
import org.apache.myfaces.tobago.layout.Measure;
@@ -48,6 +47,7 @@ import org.apache.myfaces.tobago.renderk
import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
import org.apache.myfaces.tobago.util.ComponentUtils;
+import org.apache.myfaces.tobago.util.FacetUtils;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -703,7 +703,7 @@ public class SheetRenderer extends Layou
tip = "";
}
- final UIComponent dropDownMenu = getDropDownMenuFacet(column);
+ final UIComponent dropDownMenu = FacetUtils.getDropDownMenu(column);
if (dropDownMenu != null) {
LOG.error("Drop down menu is not implemented in sheets yet!");
// Todo: implement it!
@@ -809,7 +809,7 @@ public class SheetRenderer extends Layou
UIMenu menu = (UIMenu) CreateComponentUtils.createComponent(
facesContext, UIMenu.COMPONENT_TYPE, RendererTypes.MENU, "selectorMenu");
menu.setTransient(true);
- column.getFacets().put(Facets.DROP_DOWN_MENU, menu);
+ FacetUtils.setDropDownMenu(column, menu);
menu.setImage("image/sheetSelectorMenu.gif");
menu.setLabel("vv"); //todo remove this after fixing the image above
@@ -959,19 +959,6 @@ public class SheetRenderer extends Layou
writer.endElement(type);
}
- private UIComponent getDropDownMenuFacet(UIColumn command) {
- UIComponent result = command.getFacet(Facets.DROP_DOWN_MENU);
- if (result == null) {
- result = command.getFacet(Facets.MENUPOPUP);
- if (result != null) {
- if (Deprecation.LOG.isWarnEnabled()) {
- Deprecation.LOG.warn("Facet 'menupopup' was deprecated, please rename to 'dropDownMenu'");
- }
- }
- }
- return result;
- }
-
private Measure getContentBorder(FacesContext facesContext, UISheet data) {
return getOffsetLeft(facesContext, data).add(getOffsetRight(facesContext, data));
}
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java?rev=952625&r1=952624&r2=952625&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java Tue Jun 8 12:02:47 2010
@@ -48,6 +48,7 @@ import org.apache.myfaces.tobago.renderk
import org.apache.myfaces.tobago.renderkit.util.JQueryUtils;
import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
import org.apache.myfaces.tobago.util.ComponentUtils;
+import org.apache.myfaces.tobago.util.FacetUtils;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -466,7 +467,7 @@ public class TabGroupRenderer extends La
facesContext, UICommand.COMPONENT_TYPE, null, "all");
UIMenu menu = (UIMenu) CreateComponentUtils.createComponent(
facesContext, UIMenu.COMPONENT_TYPE, RendererTypes.MENU, "menu");
- all.getFacets().put(Facets.DROP_DOWN_MENU, menu);
+ FacetUtils.setDropDownMenu(all, menu);
int index = 0;
for (UIComponent child : (List<UIComponent>) tabGroup.getChildren()) {
if (child instanceof UITab) {
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java?rev=952625&r1=952624&r2=952625&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java Tue Jun 8 12:02:47 2010
@@ -30,8 +30,8 @@ import org.apache.myfaces.tobago.config.
import org.apache.myfaces.tobago.context.ResourceManager;
import org.apache.myfaces.tobago.context.ResourceManagerFactory;
import org.apache.myfaces.tobago.context.ResourceManagerUtils;
+import org.apache.myfaces.tobago.internal.component.AbstractUIMenu;
import org.apache.myfaces.tobago.internal.component.UICommandBase;
-import org.apache.myfaces.tobago.internal.util.Deprecation;
import org.apache.myfaces.tobago.layout.Measure;
import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
import org.apache.myfaces.tobago.renderkit.LayoutComponentRendererBase;
@@ -42,6 +42,7 @@ import org.apache.myfaces.tobago.renderk
import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
import org.apache.myfaces.tobago.util.ComponentUtils;
+import org.apache.myfaces.tobago.util.FacetUtils;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -217,7 +218,7 @@ public abstract class ToolBarRendererBas
final String clientId = command.getClientId(facesContext);
final boolean disabled = ComponentUtils.getBooleanAttribute(command, Attributes.DISABLED);
final LabelWithAccessKey label = new LabelWithAccessKey(command);
- final UIComponent dropDownMenu = getDropDownMenuFacet(command);
+ final AbstractUIMenu dropDownMenu = FacetUtils.getDropDownMenu(command);
final ResourceManager resources = getResourceManager();
final String labelPosition = getLabelPosition(command.getParent());
@@ -406,7 +407,7 @@ public abstract class ToolBarRendererBas
writer.writeAttribute(HtmlAttributes.SRC, menuImage, false);
writer.writeStyleAttribute(openerStyle);
writer.endElement(HtmlConstants.IMG);
- renderPopup(facesContext, writer, dropDownMenu);
+ renderDropDownMenu(facesContext, writer, dropDownMenu);
}
writer.endElement(HtmlConstants.SPAN);
writer.endElement(HtmlConstants.SPAN);
@@ -415,19 +416,6 @@ public abstract class ToolBarRendererBas
// computation of the width of the toolBar will not be used in the moment.
}
- private UIComponent getDropDownMenuFacet(UICommandBase command) {
- UIComponent result = command.getFacet(Facets.DROP_DOWN_MENU);
- if (result == null) {
- result = command.getFacet(Facets.MENUPOPUP);
- if (result != null) {
- if (Deprecation.LOG.isWarnEnabled()) {
- Deprecation.LOG.warn("Facet 'menupopup' was deprecated, please rename to 'dropDownMenu'");
- }
- }
- }
- return result;
- }
-
private Measure renderSeparator(
FacesContext facesContext, UIToolBar toolBar, UIToolBarSeparator separator, TobagoResponseWriter writer,
Measure width)
@@ -494,7 +482,7 @@ public abstract class ToolBarRendererBas
}
private String createCommandOnClick(FacesContext facesContext, UICommandBase command) {
- if (hasNoCommand(command) && getDropDownMenuFacet(command) != null) {
+ if (hasNoCommand(command) && FacetUtils.getDropDownMenu(command) != null) {
return null;
} else {
CommandRendererHelper helper = new CommandRendererHelper(facesContext, command);
@@ -515,7 +503,7 @@ public abstract class ToolBarRendererBas
}
private String createMenuOnClick(UICommandBase command) {
- if (getDropDownMenuFacet(command) != null) {
+ if (FacetUtils.getDropDownMenu(command) != null) {
return "jQuery(this).find('a').click();event.stopPropagation();";
} else {
return null;
@@ -567,13 +555,11 @@ public abstract class ToolBarRendererBas
return facesContext.getExternalContext().getRequestContextPath() + image;
}
- private void renderPopup(FacesContext facesContext, TobagoResponseWriter writer, UIComponent popupMenu)
+ private void renderDropDownMenu(FacesContext facesContext, TobagoResponseWriter writer, AbstractUIMenu dropDownMenu)
throws IOException {
- writer.startElement(HtmlConstants.OL, popupMenu);
- writer.writeClassAttribute("tobago-menuBar");
- // TODO: use a different style class
- writer.writeStyleAttribute("display:inline;width:0;height:0;position:absolute;visibility:hidden;");
- RenderUtils.encode(facesContext, popupMenu);
+ writer.startElement(HtmlConstants.OL, dropDownMenu);
+ writer.writeClassAttribute("tobago-menuBar tobago-menu-dropDownMenu");
+ RenderUtils.encode(facesContext, dropDownMenu);
writer.endElement(HtmlConstants.OL);
}
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js?rev=952625&r1=952624&r2=952625&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/tobago-menu.js Tue Jun 8 12:02:47 2010
@@ -239,6 +239,13 @@ function xxx_tobagoMenuInit() {
event.stopPropagation();
});
+ // init context menus
+ jQuery(".tobago-menu-contextMenu").parent().bind("contextmenu", function(event) {
+ jQuery(this).children(".tobago-menu-contextMenu").find('a').click();
+ event.stopPropagation();
+ return false;
+ });
+
// IE6 select-tag fix
// put a iframe inside the div, so that a <select> tag doesn't shine through.
// the iframe must be resized (see above)
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css?rev=952625&r1=952624&r2=952625&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/style/style.css Tue Jun 8 12:02:47 2010
@@ -391,6 +391,14 @@ li.tobago-menu-selected {
border-style: solid;
}
+.tobago-menu-contextMenu, .tobago-menu-dropDownMenu {
+ display: inline;
+ width: 0;
+ height: 0;
+ position: absolute;
+ visibility: hidden;
+}
+
/* workaround for IE6 */
iframe.tobago-menu-ie6bugfix {
position: absolute;
Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java?rev=952625&r1=952624&r2=952625&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java Tue Jun 8 12:02:47 2010
@@ -35,6 +35,7 @@ import org.apache.myfaces.tobago.renderk
import org.apache.myfaces.tobago.renderkit.html.StyleClasses;
import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
import org.apache.myfaces.tobago.util.ComponentUtils;
+import org.apache.myfaces.tobago.util.FacetUtils;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -686,4 +687,16 @@ public final class HtmlRendererUtils {
}
}
}
+
+ public static void encodeContextMenu(FacesContext facesContext, TobagoResponseWriter writer, UIComponent parent)
+ throws IOException {
+ final UIComponent contextMenu = FacetUtils.getContextMenu(parent);
+ if (contextMenu != null) {
+ writer.startElement(HtmlConstants.OL, contextMenu);
+ writer.writeClassAttribute("tobago-menuBar tobago-menu-contextMenu");
+ RenderUtils.encode(facesContext, contextMenu);
+ writer.endElement(HtmlConstants.OL);
+ }
+ }
+
}