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 2012/09/17 15:58:15 UTC
svn commit: r1386617 - in /myfaces/tobago/branches/tobago-1.5.x:
tobago-core/src/main/java/org/apache/myfaces/tobago/context/
tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/
tobago-core/src/main/java/org/apache/myfaces/tobago/util/ ...
Author: lofwyr
Date: Mon Sep 17 13:58:14 2012
New Revision: 1386617
URL: http://svn.apache.org/viewvc?rev=1386617&view=rev
Log:
TOBAGO-1196: Bug in component columnSelector. selectsubmenu is missing in columSelector header.
Added:
myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-selector.xhtml
Modified:
myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java
myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java
myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml
myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java?rev=1386617&r1=1386616&r2=1386617&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java Mon Sep 17 13:58:14 2012
@@ -76,6 +76,9 @@ public final class Markup implements Ser
public static final Markup RIGHT = valueOf("right");
public static final Markup SECONDS = valueOf("seconds");
public static final Markup SELECTED = valueOf("selected");
+ public static final Markup SHEET_SELECT_ALL = valueOf("sheetSelectAll");
+ public static final Markup SHEET_DESELECT_ALL = valueOf("sheetDeselectAll");
+ public static final Markup SHEET_TOGGLE_ALL = valueOf("sheetToggleAll");
public static final Markup SORTABLE = valueOf("sortable");
public static final Markup STRONG = valueOf("strong");
public static final Markup TOP = valueOf("top");
Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java?rev=1386617&r1=1386616&r2=1386617&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java Mon Sep 17 13:58:14 2012
@@ -36,6 +36,18 @@ public final class DataAttributes {
*/
public static final String RELOAD = "data-tobago-reload";
+ public static final String SELECTIONMODE = "data-tobago-selectionmode";
+
+ /**
+ * The selectable attribute e. g. for trees.
+ */
+ public static final String SELECTABLE = "data-tobago-selectable";
+
+ /**
+ * Reference to a sheet.
+ */
+ public static final String SHEETID = "data-tobago-sheetid";
+
/**
* Alternate to the src attribute, to implement a hover effect.
*/
Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java?rev=1386617&r1=1386616&r2=1386617&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java Mon Sep 17 13:58:14 2012
@@ -1018,6 +1018,18 @@ public class ComponentUtils {
/**
* Adding a data attribute to the component.
+ * The name must start with "data-", e. g. "data-tobago-foo" or "data-bar"
+ */
+ public static void putDataAttributeWithPrefix(UIComponent component, String name, Object value) {
+ if (name.startsWith("data-")) {
+ putDataAttribute(component, name.substring(5), value);
+ } else {
+ LOG.error("The name must start with 'data-' but it doesn't: '" + name + "'");
+ }
+ }
+
+ /**
+ * Adding a data attribute to the component.
* The name should not start with "data-", e. g. "tobago-foo" or "bar"
*/
public static void putDataAttribute(UIComponent component, Object name, Object value) {
Added: myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-selector.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-selector.xhtml?rev=1386617&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-selector.xhtml (added)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-example/tobago-example-test/src/main/webapp/tc/sheet/sheet-selector.xhtml Mon Sep 17 13:58:14 2012
@@ -0,0 +1,44 @@
+<?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: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">
+ <f:facet name="layout">
+ <tc:gridLayout rows="auto" columns="600px"/>
+ </f:facet>
+
+ <tc:sheet value="#{sheet.solarArray}" id="sheet" columns="auto;*;*" var="luminary" rows="20">
+
+ <tc:columnSelector/>
+
+ <tc:column label="Name" id="name" sortable="true">
+ <tc:out value="#{luminary.name}"/>
+ </tc:column>
+
+ <tc:column label="Orbit Of" id="orbit">
+ <tc:out value="#{luminary.orbit}"/>
+ </tc:column>
+ </tc:sheet>
+
+ </tc:page>
+</f:view>
Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java?rev=1386617&r1=1386616&r2=1386617&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java Mon Sep 17 13:58:14 2012
@@ -144,7 +144,9 @@ public class MenuCommandRenderer extends
}
writer.writeClassAttribute(Classes.createWorkaround("menu", markup)); // todo: solve workaround
writer.writeAttribute(HtmlAttributes.ONCLICK, onclick, true);
-
+ if (component != null) {
+ HtmlRendererUtils.writeDataAttributes(facesContext, writer, component);
+ }
if (image != null) {
if (firstLevel) {
Modified: myfaces/tobago/branches/tobago-1.5.x/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/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java?rev=1386617&r1=1386616&r2=1386617&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java Mon Sep 17 13:58:14 2012
@@ -32,6 +32,7 @@ import org.apache.myfaces.tobago.compone
import org.apache.myfaces.tobago.component.UIOut;
import org.apache.myfaces.tobago.component.UIReload;
import org.apache.myfaces.tobago.component.UISheet;
+import org.apache.myfaces.tobago.component.UIToolBar;
import org.apache.myfaces.tobago.config.Configurable;
import org.apache.myfaces.tobago.context.ClientProperties;
import org.apache.myfaces.tobago.context.Markup;
@@ -809,46 +810,53 @@ public class SheetRenderer extends Layou
}
}
-
protected void renderColumnSelectorHeader(
FacesContext facesContext, TobagoResponseWriter writer, UISheet sheet, UIColumnSelector column)
throws IOException {
+ final UIToolBar toolBar = createToolBar(facesContext, sheet);
writer.startElement(HtmlElements.DIV, null);
- writer.writeIdAttribute(column.getClientId(facesContext));
- writer.writeClassAttribute(Classes.create(sheet, "selectorMenu"));
- writer.endElement(HtmlElements.DIV);
+ writer.writeClassAttribute(Classes.create(sheet, "toolBar"));
if (UISheet.MULTI.equals(sheet.getSelectable())) {
- UIMenu menu = (UIMenu) CreateComponentUtils.createComponent(
- facesContext, UIMenu.COMPONENT_TYPE, RendererTypes.MENU, "selectorMenu");
- menu.setTransient(true);
- FacetUtils.setDropDownMenu(column, menu);
- menu.setImage("image/sheetSelectorMenu.gif");
- menu.setLabel("vv"); //todo remove this after fixing the image above
-
- String sheetId = column.getParent().getClientId(facesContext);
-
- createMenuItem(facesContext, menu, "sheetMenuSelect",
- "Tobago.Sheets.get('" + sheetId + "').selectAll()", "t_selectAll");
- createMenuItem(facesContext, menu, "sheetMenuUnselect",
- "Tobago.Sheets.get('" + sheetId + "').deselectAll()", "t_deselectAll");
- createMenuItem(facesContext, menu, "sheetMenuToggleselect",
- "Tobago.Sheets.get('" + sheetId + "').toggleAll()", "t_toggleAll");
-
- writer.startElement(HtmlElements.OL, menu);
- writer.writeClassAttribute(Classes.create(sheet, "menuBar"));
- writer.writeStyleAttribute("position:absolute;"); // FIXME: may use a different style class
- RenderUtils.encode(facesContext, menu);
- writer.endElement(HtmlElements.OL);
+ RenderUtils.prepareRendererAll(facesContext, toolBar);
+ RenderUtils.encode(facesContext, toolBar);
}
+
+ writer.endElement(HtmlElements.DIV);
}
- private void createMenuItem(final FacesContext facesContext, UIMenu menu, String label, String action, String id) {
- UIMenuCommand menuItem = (UIMenuCommand) CreateComponentUtils.createComponent(
+ private UIToolBar createToolBar(FacesContext facesContext, UISheet sheet) {
+ final Application application = facesContext.getApplication();
+ final UICommand dropDown = (UICommand) CreateComponentUtils.createComponent(
+ facesContext, UICommand.COMPONENT_TYPE, null, "dropDown");
+ final UIMenu menu = (UIMenu) CreateComponentUtils.createComponent(
+ facesContext, UIMenu.COMPONENT_TYPE, RendererTypes.MENU, "menu");
+ FacetUtils.setDropDownMenu(dropDown, menu);
+ final String sheetId = sheet.getClientId(facesContext);
+
+ createMenuItem(facesContext, menu, "sheetMenuSelect", Markup.SHEET_SELECT_ALL, sheetId);
+ createMenuItem(facesContext, menu, "sheetMenuUnselect", Markup.SHEET_DESELECT_ALL, sheetId);
+ createMenuItem(facesContext, menu, "sheetMenuToggleselect", Markup.SHEET_TOGGLE_ALL, sheetId);
+
+ final UIToolBar toolBar = (UIToolBar) application.createComponent(UIToolBar.COMPONENT_TYPE);
+ toolBar.setId(facesContext.getViewRoot().createUniqueId());
+ toolBar.setRendererType("TabGroupToolBar");
+ toolBar.setTransient(true);
+ toolBar.getChildren().add(dropDown);
+ sheet.getFacets().put(Facets.TOOL_BAR, toolBar);
+ return toolBar;
+ }
+
+ private void createMenuItem(
+ final FacesContext facesContext, UIMenu menu, String label, Markup markup, String sheetId) {
+ final String id = markup.toString();
+ final UIMenuCommand menuItem = (UIMenuCommand) CreateComponentUtils.createComponent(
facesContext, UIMenuCommand.COMPONENT_TYPE, RendererTypes.MENU_COMMAND, id);
- menuItem.setOnclick(action);
menuItem.setLabel(ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", label));
+ menuItem.setMarkup(markup);
+ menuItem.setOnclick("/**/"); // XXX avoid submit
+ ComponentUtils.putDataAttributeWithPrefix(menuItem, DataAttributes.SHEETID, sheetId);
menu.getChildren().add(menuItem);
}
Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml?rev=1386617&r1=1386616&r2=1386617&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml Mon Sep 17 13:58:14 2012
@@ -108,6 +108,12 @@
<!-- internal: to mark "cursor" position in the menu -->
<markup>selected</markup>
<markup>disabled</markup>
+ <!-- internal: sheet command -->
+ <markup>sheetSelectAll</markup>
+ <!-- internal: sheet command -->
+ <markup>sheetDeselectAll</markup>
+ <!-- internal: sheet command -->
+ <markup>sheetToggleAll</markup>
</supported-markup>
</renderer>
<renderer>
Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js?rev=1386617&r1=1386616&r2=1386617&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js Mon Sep 17 13:58:14 2012
@@ -86,6 +86,27 @@ Tobago.Sheet = function(sheetId, firstRo
LOG.debug("Sheet-total time = " + (this.endTime.getTime() - this.startTime.getTime())); // @DEV_ONLY
};
+Tobago.Sheet.init = function(elements) {
+
+ var commands;
+ commands = Tobago.Utils.selectWidthJQuery(elements, ".tobago-menu-markup-sheetSelectAll");
+ commands.click(function() {
+ Tobago.Sheets.get(jQuery(this).data("tobago-sheetid")).selectAll();
+ });
+ commands = Tobago.Utils.selectWidthJQuery(elements, ".tobago-menu-markup-sheetDeselectAll");
+ commands.click(function() {
+ Tobago.Sheets.get(jQuery(this).data("tobago-sheetid")).deselectAll();
+ });
+ commands = Tobago.Utils.selectWidthJQuery(elements, ".tobago-menu-markup-sheetToggleAll");
+ commands.click(function() {
+ Tobago.Sheets.get(jQuery(this).data("tobago-sheetid")).toggleAll();
+ });
+
+};
+
+Tobago.registerListener(Tobago.Sheet.init, Tobago.Phase.DOCUMENT_READY);
+Tobago.registerListener(Tobago.Sheet.init, Tobago.Phase.AFTER_UPDATE);
+
Tobago.Sheet.prototype.setupSortHeaders = function() {
var sheet = this;
jQuery(Tobago.Utils.escapeClientId(sheet.id)).find(".tobago-sheet-header[sorterId]").each(function() {