You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by id...@apache.org on 2007/04/13 22:14:35 UTC
svn commit: r528641 - in /myfaces/tobago/trunk/example/addressbook/src/main:
java/org/apache/myfaces/tobago/example/addressbook/web/ webapp/application/
webapp/application/admin/
webapp/tobago-resource/html/standard/standard/image/org/ webapp/tobago-re...
Author: idus
Date: Fri Apr 13 13:14:34 2007
New Revision: 528641
URL: http://svn.apache.org/viewvc?view=rev&rev=528641
Log:
cosmetics: improved menu and toolbar and added a way to generate example data
Added:
myfaces/tobago/trunk/example/addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/RandomAddressGenerator.java (with props)
myfaces/tobago/trunk/example/addressbook/src/main/webapp/tobago-resource/html/standard/standard/image/org/
myfaces/tobago/trunk/example/addressbook/src/main/webapp/tobago-resource/html/standard/standard/image/org/tango-project/
myfaces/tobago/trunk/example/addressbook/src/main/webapp/tobago-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/
myfaces/tobago/trunk/example/addressbook/src/main/webapp/tobago-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/32x32/
myfaces/tobago/trunk/example/addressbook/src/main/webapp/tobago-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/32x32/categories/
myfaces/tobago/trunk/example/addressbook/src/main/webapp/tobago-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/32x32/categories/preferences-systemDisabled.png (with props)
myfaces/tobago/trunk/example/addressbook/src/main/webapp/tobago-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/32x32/mimetypes/
myfaces/tobago/trunk/example/addressbook/src/main/webapp/tobago-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/32x32/mimetypes/x-office-address-bookDisabled.png (with props)
Modified:
myfaces/tobago/trunk/example/addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/Controller.java
myfaces/tobago/trunk/example/addressbook/src/main/webapp/application/admin/logging.jsp
myfaces/tobago/trunk/example/addressbook/src/main/webapp/application/list.jsp
Modified: myfaces/tobago/trunk/example/addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/Controller.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/Controller.java?view=diff&rev=528641&r1=528640&r2=528641
==============================================================================
--- myfaces/tobago/trunk/example/addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/Controller.java (original)
+++ myfaces/tobago/trunk/example/addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/Controller.java Fri Apr 13 13:14:34 2007
@@ -23,32 +23,34 @@
*/
import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.WordUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.commons.lang.WordUtils;
-import org.apache.myfaces.tobago.model.SheetState;
-import org.apache.myfaces.tobago.context.Theme;
-import org.apache.myfaces.tobago.context.ClientProperties;
+import org.apache.myfaces.tobago.component.UIColumn;
import org.apache.myfaces.tobago.config.TobagoConfig;
+import org.apache.myfaces.tobago.context.ClientProperties;
+import org.apache.myfaces.tobago.context.Theme;
+import org.apache.myfaces.tobago.event.SortActionEvent;
import org.apache.myfaces.tobago.example.addressbook.Address;
import org.apache.myfaces.tobago.example.addressbook.AddressDao;
import org.apache.myfaces.tobago.example.addressbook.AddressDaoException;
import org.apache.myfaces.tobago.example.addressbook.Picture;
-import org.apache.myfaces.tobago.event.SortActionEvent;
-import org.apache.myfaces.tobago.component.UIColumn;
+import org.apache.myfaces.tobago.model.SheetState;
-import javax.faces.application.FacesMessage;
import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
-import javax.faces.component.UIComponent;
import javax.faces.validator.ValidatorException;
-import javax.faces.event.ActionEvent;
+import java.io.IOException;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import java.util.Locale;
-import java.util.ArrayList;
-import java.util.Iterator;
public class Controller {
@@ -97,7 +99,7 @@
themes.add(0, tobagoConfig.getDefaultTheme());
themeItems = new ArrayList<SelectItem>();
for (Theme theme : themes) {
- themeItems.add(new SelectItem(theme, theme.getDisplayName()));
+ themeItems.add(new SelectItem(theme, StringUtils.capitalize(theme.getDisplayName())));
}
ClientProperties client = ClientProperties.getInstance(facesContext);
@@ -129,6 +131,13 @@
return OUTCOME_EDITOR;
}
+ public String addDummyAddresses() throws IOException, AddressDaoException {
+ for (int i=0; i<100; ++i) {
+ currentAddress = RandomAddressGenerator.generateAddress();
+ store();
+ }
+ return OUTCOME_LIST;
+ }
public String editAddress() {
LOG.debug("action: editAddress");
@@ -173,6 +182,7 @@
}
public String languageChangedList() {
+ initLanguages();
return OUTCOME_LIST;
}
@@ -344,6 +354,23 @@
public String popupFileUpload() {
setRenderFileUploadPopup(true);
+ return null;
+ }
+
+ public String languageChanged() {
+ countries.init(language);
+ initLanguages();
+/*
+ // reinit date converter
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ UIViewRoot viewRoot = facesContext.getViewRoot();
+ EditableValueHolder component = (EditableValueHolder)
+ viewRoot.findComponent(":page:dayOfBirth");
+ if (component != null) {
+ DateTimeConverter converter = (DateTimeConverter) component.getConverter();
+ converter.setPattern(MessageUtils.getLocalizedString(facesContext, "editor_date_pattern"));
+ }
+*/
return null;
}
Added: myfaces/tobago/trunk/example/addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/RandomAddressGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/RandomAddressGenerator.java?view=auto&rev=528641
==============================================================================
--- myfaces/tobago/trunk/example/addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/RandomAddressGenerator.java (added)
+++ myfaces/tobago/trunk/example/addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/RandomAddressGenerator.java Fri Apr 13 13:14:34 2007
@@ -0,0 +1,73 @@
+package org.apache.myfaces.tobago.example.addressbook.web;
+
+/*
+ * 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.example.addressbook.Address;
+import org.apache.commons.lang.math.RandomUtils;
+
+import java.util.Locale;
+import java.util.Calendar;
+
+/**
+ * Tries to generate random, uncontroversial addresses.
+ *
+ * @see <a href="http://en.wikipedia.org/wiki/John_Doe">Wikipedia: John Doe</a>
+ * @see <a href="http://en.wikipedia.org/wiki/Alice_and_Bob">Wikipedia: Alice and Bob</a>
+ * @see <a href="http://en.wikipedia.org/wiki/Placeholder_name">Wikipedia: Placeholder name</a>
+ */
+public class RandomAddressGenerator {
+
+ private static final String[] MALE_FIRST_NAMES = {
+ "Alan", "Arvid", "Bernd", "Detlef", "Frank", "Hans",
+ "John", "Max", "Michael", "Otto", "Tom", "Udo"};
+ private static final String[] FEMALE_FIRST_NAMES = {
+ "Anna", "Erika", "Jane", "Kate", "Kerstin", "Maria",
+ "Polly", "Sabine", "Shirley", "Tanya", "Tracy", "Yvonne"};
+
+ private static final String[] GERMAN_LAST_NAMES = {
+ "Müller", "Meier", "Mustermann", "Schmidt", "Schulze"};
+ private static final String[] ENGLISH_LAST_NAMES = {
+ "Doe", "Jones", "Miller", "Public", "Raymond", "Smithee"
+ };
+
+ public static Address generateAddress() {
+ return generateAddress(RandomUtils.nextBoolean(), RandomUtils.nextBoolean());
+ }
+
+ public static Address generateAddress(boolean female, boolean german) {
+ Address address = new Address();
+ address.setFirstName(female ? randomString(FEMALE_FIRST_NAMES) : randomString(MALE_FIRST_NAMES));
+ if (german) {
+ address.setLastName(randomString(GERMAN_LAST_NAMES));
+ address.setCountry(Locale.GERMANY);
+ } else {
+ address.setLastName(randomString(ENGLISH_LAST_NAMES));
+ address.setCountry(RandomUtils.nextBoolean() ? Locale.US : Locale.UK);
+ }
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(1920, 0, 1);
+ calendar.add(Calendar.DAY_OF_YEAR, RandomUtils.nextInt(70 * 365));
+ address.setDayOfBirth(calendar.getTime());
+ return address;
+ }
+
+ static String randomString(String[] array) {
+ return array[RandomUtils.nextInt(array.length)];
+ }
+
+}
Propchange: myfaces/tobago/trunk/example/addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/RandomAddressGenerator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tobago/trunk/example/addressbook/src/main/webapp/application/admin/logging.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/addressbook/src/main/webapp/application/admin/logging.jsp?view=diff&rev=528641&r1=528640&r2=528641
==============================================================================
--- myfaces/tobago/trunk/example/addressbook/src/main/webapp/application/admin/logging.jsp (original)
+++ myfaces/tobago/trunk/example/addressbook/src/main/webapp/application/admin/logging.jsp Fri Apr 13 13:14:34 2007
@@ -33,7 +33,7 @@
<tc:out value="#{appender.name}"/>
</tc:column>
<tc:column label="File">
- <tc:link inline="true" action="#{logging.downloadLogFile}"
+ <tc:link inline="true" action="#{logging.downloadLogFile}" tip="Download Log File"
target="_blank" rendered="#{! empty appender.file}">
<f:param value="#{appender}" binding="#{logging.currentAppender}"/>
<tc:out value="#{appender.file}"/>
Modified: myfaces/tobago/trunk/example/addressbook/src/main/webapp/application/list.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/addressbook/src/main/webapp/application/list.jsp?view=diff&rev=528641&r1=528640&r2=528641
==============================================================================
--- myfaces/tobago/trunk/example/addressbook/src/main/webapp/application/list.jsp (original)
+++ myfaces/tobago/trunk/example/addressbook/src/main/webapp/application/list.jsp Fri Apr 13 13:14:34 2007
@@ -23,11 +23,36 @@
<tc:page label="#{bundle.listPageTitle}" state="#{layout}" width="#{layout.width}" height="#{layout.height}">
<f:facet name="menuBar">
<tc:menuBar id="menuBar">
- <tc:menu label="File">
- <tc:menuItem label="Logout" image="image/export.gif"/>
+ <tc:menu label="#{bundle.menuFile}">
+ <tc:menuItem label="#{bundle.menuFileNew}" action="#{controller.createAddress}" immediate="true"
+ image="image/org/tango-project/tango-icon-theme/16x16/actions/contact-new.png"/>
+ <tc:menuItem label="Add Dummy Addresses" action="#{controller.addDummyAddresses}" immediate="true"/>
+ <tc:menuSeparator/>
+ <tc:menuItem label="Logout" image="image/org/tango-project/tango-icon-theme/16x16/actions/system-log-out.png"/>
</tc:menu>
- <tc:menu label="Help">
- <tc:menuItem label="#{bundle.toolbarAbout}"
+
+ <tc:menu label="#{bundle.menuSettings}">
+ <tc:menu label="#{bundle.menuSettingsLanguage}" >
+ <tx:menuRadio action="#{controller.languageChanged}"
+ value="#{controller.language}">
+ <f:selectItems value="#{controller.languages}" />
+ </tx:menuRadio>
+ </tc:menu>
+ <tc:menu label="#{bundle.menuSettingsTheme}" >
+ <tx:menuRadio action="#{controller.themeChanged}"
+ value="#{controller.theme}">
+ <f:selectItems value="#{controller.themeItems}" />
+ </tx:menuRadio>
+ </tc:menu>
+ <tc:menuItem label="#{bundle.menuSettingsMode}" >
+ <f:facet name="items">
+ <tc:selectBooleanCheckbox value="#{controller.simple}" />
+ </f:facet>
+ </tc:menuItem>
+ </tc:menu>
+
+ <tc:menu label="#{bundle.menuHelp}">
+ <tc:menuItem label="#{bundle.menuHelpAbout}"
action="alert('#{bundle.aboutMessage}')"
type="script" image="image/org/tango-project/tango-icon-theme/16x16/apps/help-browser.png"/>
</tc:menu>
@@ -40,13 +65,14 @@
</f:facet>
<tc:toolBar iconSize="big">
<tc:button label="#{bundle.toolbarAddressList}" action="#{controller.search}" immediate="true"
- image="image/org/tango-project/tango-icon-theme/32x32/mimetypes/x-office-address-book.png"/>
+ image="image/org/tango-project/tango-icon-theme/32x32/mimetypes/x-office-address-book.png"
+ disabled="#{facesContext.viewRoot.viewId == '/application/list.jsp'}"/>
<tc:button label="#{bundle.listNew}" action="#{controller.createAddress}"
image="image/org/tango-project/tango-icon-theme/32x32/actions/contact-new.png" />
<tc:button onclick="alert('#{bundle.aboutMessage}')" label="#{bundle.toolbarAbout}"
image="image/org/tango-project/tango-icon-theme/32x32/apps/help-browser.png"/>
<tc:button label="#{bundle.admin}" action="#{admin.admin}"
- image="image/org/tango-project/tango-icon-theme/32x32/categories/applications-system.png" />
+ image="image/org/tango-project/tango-icon-theme/32x32/categories/preferences-system.png" />
</tc:toolBar>
<tc:box label="#{bundle.listBoxTitle}">
<f:facet name="layout">
@@ -55,7 +81,7 @@
<f:facet name="toolBar">
<tc:toolBar>
<tc:button label="#{bundle.listNew}" action="#{controller.createAddress}"
- image="image/org/tango-project/tango-icon-theme/16x16/actions/contact-new.png" />
+ image="image/org/tango-project/tango-icon-theme/16x16/actions/contact-new.png"/>
<tc:button label="#{bundle.listEdit}" action="#{controller.editAddress}"
image="image/org/tango-project/tango-icon-theme/16x16/apps/accessories-text-editor.png" />
<tc:button label="#{bundle.listDelete}" action="#{controller.deleteAddresses}"
@@ -64,7 +90,8 @@
<tc:out value="#{bundle.listDeleteConfirmation}" />
</f:facet>
</tc:button>
- <tc:button label="Select Columns" action="#{controller.selectColumns}">
+ <tc:button label="Select Columns" action="#{controller.selectColumns}"
+ image="image/org/tango-project/tango-icon-theme/16x16/categories/applications-system.png">
<f:facet name="popup">
<tc:popup width="300px" height="200px" left="200px" top="200px"
rendered="#{controller.renderPopup}" id="popup">
Added: myfaces/tobago/trunk/example/addressbook/src/main/webapp/tobago-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/32x32/categories/preferences-systemDisabled.png
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/addressbook/src/main/webapp/tobago-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/32x32/categories/preferences-systemDisabled.png?view=auto&rev=528641
==============================================================================
Binary file - no diff available.
Propchange: myfaces/tobago/trunk/example/addressbook/src/main/webapp/tobago-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/32x32/categories/preferences-systemDisabled.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: myfaces/tobago/trunk/example/addressbook/src/main/webapp/tobago-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/32x32/mimetypes/x-office-address-bookDisabled.png
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/addressbook/src/main/webapp/tobago-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/32x32/mimetypes/x-office-address-bookDisabled.png?view=auto&rev=528641
==============================================================================
Binary file - no diff available.
Propchange: myfaces/tobago/trunk/example/addressbook/src/main/webapp/tobago-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/32x32/mimetypes/x-office-address-bookDisabled.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream