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 2009/11/04 11:14:30 UTC
svn commit: r832696 - in
/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag:
MenuBarRenderer.java ToolBarRendererBase.java
Author: lofwyr
Date: Wed Nov 4 10:14:28 2009
New Revision: 832696
URL: http://svn.apache.org/viewvc?rev=832696&view=rev
Log:
TOBAGO-412: Commands in Menu/ToolBar have an other base class
Modified:
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java?rev=832696&r1=832695&r2=832696&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuBarRenderer.java Wed Nov 4 10:14:28 2009
@@ -29,7 +29,7 @@
import org.apache.myfaces.tobago.component.Attributes;
import org.apache.myfaces.tobago.component.CreateComponentUtils;
import org.apache.myfaces.tobago.component.Facets;
-import org.apache.myfaces.tobago.component.UICommand;
+import org.apache.myfaces.tobago.component.UICommandBase;
import org.apache.myfaces.tobago.component.UIMenu;
import org.apache.myfaces.tobago.component.UIMenuCommand;
import org.apache.myfaces.tobago.component.UIMenuSeparator;
@@ -72,8 +72,7 @@
public static final String SEARCH_ID_POSTFIX = SUBCOMPONENT_SEP + "popup";
private static final String MENU_ACCELERATOR_KEYS = "menuAcceleratorKeys";
- public void encodeEnd(FacesContext facesContext,
- UIComponent component) throws IOException {
+ public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
String clientId;
Map attributes = component.getAttributes();
@@ -90,10 +89,12 @@
if (ComponentUtils.getBooleanAttribute(component, Attributes.PAGE_MENU)) {
styleClasses.addClass("menuBar", "page-facet"); // XXX not a standard compliant name
} else {
- writer.writeStyleAttribute();
+ // todo
+// HtmlStyleMap style = new HtmlStyleMap(facesContext, component);
+// writer.writeStyleAttribute(style);
}
writer.writeClassAttribute(styleClasses);
-
+
/*
writer.startElement(HtmlConstants.SPAN);
@@ -119,7 +120,7 @@
}
private void renderTopLevelItems(FacesContext facesContext,
- TobagoResponseWriter writer, UIComponent component) throws IOException {
+ TobagoResponseWriter writer, UIComponent component) throws IOException {
String bac = "green;";
for (Object o : component.getChildren()) {
if (o instanceof UIMenu) {
@@ -164,19 +165,19 @@
String function = setupFunction + "('" + clientId + "', '" + page.getClientId(facesContext) + "');";
String scriptBlock = createJavascriptFunction(facesContext, component, setupFunction);
StringTokenizer st = new StringTokenizer(scriptBlock, "\n");
- ArrayList<String> lines = new ArrayList<String>();
+ ArrayList<String> lines = new ArrayList<String>();
while (st.hasMoreTokens()) {
lines.add(st.nextToken());
}
lines.add(function);
HtmlRendererUtils.writeScriptLoader(facesContext,
- new String[] {"script/tobago-menu.js"},
+ new String[]{"script/tobago-menu.js"},
lines.toArray(new String[lines.size()]));
}
}
protected String createJavascriptFunction(FacesContext facesContext,
- UIComponent component, String setupFunction)
+ UIComponent component, String setupFunction)
throws IOException {
StringBuilder sb = new StringBuilder(256);
@@ -333,17 +334,19 @@
writer.writeAttribute(HtmlAttributes.SRC, image, false);
writer.endElement(HtmlConstants.IMG);
}
+
private int addMenuEntrys(StringBuilder sb, String var,
FacesContext facesContext, UIComponent component, boolean warn) throws IOException {
return addMenuEntrys(sb, var, facesContext, component, warn, 0);
}
- private int addMenuEntrys(StringBuilder sb, String var,
- FacesContext facesContext, UIComponent component, boolean warn, int index)
+
+ private int addMenuEntrys(
+ StringBuilder sb, String var, FacesContext facesContext, UIComponent component, boolean warn, int index)
throws IOException {
for (Object o : component.getChildren()) {
UIComponent entry = (UIComponent) o;
- if (entry instanceof UICommand) {
- addMenuEntry(sb, var, facesContext, (UICommand) entry);
+ if (entry instanceof UICommandBase) {
+ addMenuEntry(sb, var, facesContext, (UICommandBase) entry);
} else if (entry instanceof UIMenuSeparator) {
addMenuSeparator(sb, var);
} else if (entry instanceof UIMenu) {
@@ -351,14 +354,13 @@
} else if (entry instanceof UIForm) {
index = addMenuEntrys(sb, var, facesContext, entry, warn, index);
} else if (warn) {
- LOG.error("Illegal UIComponent class in menuBar: "
- + entry.getClass().getName());
+ LOG.error("Illegal UIComponent class in menuBar (not UICommandBase): " + entry.getClass().getName());
}
}
return index;
}
- private void addMenuEntry(StringBuilder sb, String var, FacesContext facesContext, UICommand command)
+ private void addMenuEntry(StringBuilder sb, String var, FacesContext facesContext, UICommandBase command)
throws IOException {
CommandRendererHelper helper = new CommandRendererHelper(facesContext, command);
String onclick = helper.getOnclick();
@@ -380,14 +382,15 @@
}
}
- private void addCommand(StringBuilder sb, String var, FacesContext facesContext,
- UICommand command, String onClick) throws IOException {
+ private void addCommand(
+ StringBuilder sb, String var, FacesContext facesContext, UICommandBase command, String onClick)
+ throws IOException {
String image = (String) command.getAttributes().get(Attributes.IMAGE);
addMenuItem(sb, var, facesContext, command, image, onClick);
}
- private void addSelectBoolean(StringBuilder sb, String var,
- FacesContext facesContext, UICommand command, String onClick)
+ private void addSelectBoolean(
+ StringBuilder sb, String var, FacesContext facesContext, UICommandBase command, String onClick)
throws IOException {
UIComponent checkbox = command.getFacet(Facets.ITEMS);
@@ -408,14 +411,14 @@
}
private void addMenuItem(
- StringBuilder sb, String var, FacesContext facesContext, UICommand command, String image, String onclick)
+ StringBuilder sb, String var, FacesContext facesContext, UICommandBase command, String image, String onclick)
throws IOException {
LabelWithAccessKey label = new LabelWithAccessKey(command);
addMenuItem(sb, var, facesContext, command, label, image, onclick);
}
private void addSelectOne(
- StringBuilder sb, String var, FacesContext facesContext, UICommand command, String onclick)
+ StringBuilder sb, String var, FacesContext facesContext, UICommandBase command, String onclick)
throws IOException {
List<SelectItem> items;
LabelWithAccessKey label = new LabelWithAccessKey(command);
@@ -463,10 +466,10 @@
}
}
- private void addMenuItem(StringBuilder sb, String var,
- FacesContext facesContext,
- UICommand command, LabelWithAccessKey label, String image,
- String onClick) throws IOException {
+ private void addMenuItem(
+ StringBuilder sb, String var, FacesContext facesContext, UICommandBase command,
+ LabelWithAccessKey label, String image, String onClick)
+ throws IOException {
if (!command.isRendered()) {
return;
}
@@ -543,7 +546,7 @@
sb.append("));\n");
}
- private String prepareForScript(String s) {
+ private String prepareForScript(String s) {
return s.replaceAll("\n", " ").replaceAll("'", "\\\\'");
}
Modified: myfaces/tobago/trunk/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/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java?rev=832696&r1=832695&r2=832696&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java Wed Nov 4 10:14:28 2009
@@ -24,7 +24,7 @@
import org.apache.myfaces.tobago.component.CreateComponentUtils;
import org.apache.myfaces.tobago.component.Facets;
import org.apache.myfaces.tobago.component.RendererTypes;
-import org.apache.myfaces.tobago.component.UICommand;
+import org.apache.myfaces.tobago.component.UICommandBase;
import org.apache.myfaces.tobago.component.UIMenu;
import org.apache.myfaces.tobago.component.UIMenuSelectOne;
import org.apache.myfaces.tobago.component.UISelectBooleanCommand;
@@ -81,18 +81,18 @@
boolean first = true;
for (Iterator iter = children.iterator(); iter.hasNext();) {
UIComponent component = (UIComponent) iter.next();
- if (component instanceof UICommand) {
+ if (component instanceof UICommandBase) {
boolean last = !iter.hasNext();
- renderToolbarCommand(context, (UICommand) component, writer, first, last);
+ renderToolbarCommand(context, (UICommandBase) component, writer, first, last);
first = false;
} else {
- LOG.error("Illegal UIComponent class in toolbar :" + component.getClass().getName());
+ LOG.error("Illegal UIComponent class in toolbar (not UICommandBase):" + component.getClass().getName());
}
}
}
private void renderToolbarCommand(FacesContext facesContext,
- final UICommand command, TobagoResponseWriter writer, boolean first, boolean last)
+ final UICommandBase command, TobagoResponseWriter writer, boolean first, boolean last)
throws IOException {
if (command instanceof UISelectBooleanCommand) {
renderSelectBoolean(facesContext, command, writer, first, last);
@@ -113,7 +113,7 @@
}
}
- private void renderSelectOne(FacesContext facesContext, UICommand command,
+ private void renderSelectOne(FacesContext facesContext, UICommandBase command,
TobagoResponseWriter writer, boolean first, boolean last)
throws IOException {
@@ -182,7 +182,7 @@
}
- private void renderSelectBoolean(FacesContext facesContext, UICommand command,
+ private void renderSelectBoolean(FacesContext facesContext, UICommandBase command,
TobagoResponseWriter writer, boolean first, boolean last)
throws IOException {
@@ -206,7 +206,7 @@
}
private void renderToolbarButton(
- FacesContext facesContext, final UICommand command, TobagoResponseWriter writer,
+ FacesContext facesContext, UICommandBase command, TobagoResponseWriter writer,
boolean first, boolean last, boolean selected, String onClick)
throws IOException {
if (!command.isRendered()) {
@@ -340,7 +340,7 @@
protected abstract String getDivClasses(boolean selected, boolean disabled);
- private String createOnClick(FacesContext facesContext, UICommand command) {
+ private String createOnClick(FacesContext facesContext, UICommandBase command) {
if (command.getFacet(Facets.MENUPOPUP) != null
&& command.getAction() == null
&& command.getActionListener() == null
@@ -411,7 +411,7 @@
}
private void renderAnchorBegin(
- FacesContext facesContext, TobagoResponseWriter writer, final UICommand command,
+ FacesContext facesContext, TobagoResponseWriter writer, UICommandBase command,
final LabelWithAccessKey label, final boolean disabled)
throws IOException {
writer.startElement(HtmlConstants.A, command);