Admin-Seite für Subsites benutzbar gemacht:

- Labels für die Formularfelder hinzugefügt
- ColumnPanel eingefügt, damit die Sachen untereinander stehen


git-svn-id: https://svn.libreccm.org/ccm/trunk@1858 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2012-09-12 07:22:36 +00:00
parent 79d89bfe00
commit 3157d2ea88
4 changed files with 221 additions and 158 deletions

View File

@ -15,9 +15,9 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.arsdigita.subsite.ui;
import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.SaveCancelSection;
@ -37,6 +37,7 @@ import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.ParameterEvent;
import com.arsdigita.bebop.event.ParameterListener;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.bebop.parameters.ParameterData;
@ -65,7 +66,6 @@ import java.util.Iterator;
import org.apache.log4j.Logger;
/**
* Class creates the administration input form.
*
@ -76,10 +76,8 @@ public class SiteForm extends Form {
/** A logger instance. */
private static final Logger s_log = Logger.getLogger(SiteForm.class);
private SiteSelectionModel m_site;
private BigDecimal siteDefaultRootPageID;
/** Input field subsite title */
private TextField m_title;
private TextField m_hostname;
@ -89,16 +87,13 @@ public class SiteForm extends Form {
private CategoryPicker m_rootCategory;
private SingleSelect m_themes;
private SaveCancelSection m_buttons;
private final static String DEFAULT_APP = "DEFAULT_APP";
private final static String DEFAULT_APP_LABEL = "Site Wide Default ";
private final static String DEFAULT_STYLE = "DEFAULT_STYLE";
private final static String DEFAULT_STYLE_LABEL = "Site Wide Default ";
private final static String OTHER_STYLE = "OTHER_STYLE";
private final static String OTHER_STYLE_LABEL = "Other (type in box below)";
/**
* Constructor create input widgets and adds them to form.
*
@ -107,7 +102,8 @@ public class SiteForm extends Form {
*/
public SiteForm(String name, SiteSelectionModel site) {
super(name, new SimpleContainer());
//super(name, new SimpleContainer());
super(name, new ColumnPanel(2));
setClassAttr("simpleForm");
setRedirecting(true);
@ -122,8 +118,9 @@ public class SiteForm extends Form {
m_title = new TextField(new StringParameter("title"));
m_title.addValidationListener(new NotNullValidationListener());
m_title.setMetaDataAttribute("title", "Title");
m_title.setHint("Enter the title of the subsite, upto 80 characters");
m_title.setHint((String) SubsiteGlobalizationUtil.globalize("subsite.ui.title.hint").localize());
m_title.setSize(40);
add(new Label(SubsiteGlobalizationUtil.globalize("subsite.ui.title.label")));
add(m_title); // adds title input field to form
@ -133,9 +130,8 @@ public class SiteForm extends Form {
m_hostname.addValidationListener(new HostNameValidationListener());
m_hostname.setMetaDataAttribute("title", "Hostname");
m_hostname.setSize(40);
m_hostname.setHint(
"Enter the hostname for the subsite, eg business.example.com"
);
m_hostname.setHint((String) SubsiteGlobalizationUtil.globalize("subsite.ui.hostname.hint").localize());
add(new Label(SubsiteGlobalizationUtil.globalize("subsite.ui.hostname.label")));
add(m_hostname); // adds hostname input field to form
@ -145,9 +141,8 @@ public class SiteForm extends Form {
m_description.setMetaDataAttribute("title", "Description");
m_description.setCols(45);
m_description.setRows(4);
m_description.setHint(
"Enter a short description for the subsite, upto 4000 characters"
);
m_description.setHint((String) SubsiteGlobalizationUtil.globalize("subsite.ui.description.hint").localize());
add(new Label(SubsiteGlobalizationUtil.globalize("subsite.ui.description.label")));
add(m_description); // adds description input field to form
@ -155,30 +150,29 @@ public class SiteForm extends Form {
* by URL */
m_customFrontpageApp = new SingleSelect(
new StringParameter("customFrontpageApp"));
m_customFrontpageApp.setMetaDataAttribute("title",
"Front Page (url)");
m_customFrontpageApp.setMetaDataAttribute("title", "Front Page (url)");
// m_customFrontpageApp.setSize(40);
m_customFrontpageApp.setHint(
"Select the name (url) of the subsite custom homepage");
m_customFrontpageApp.setHint((String) SubsiteGlobalizationUtil.globalize("subsite.ui.customfrontpage.hint").
localize());
try {
m_customFrontpageApp.addPrintListener(new FrontpageAppListener());
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("This cannot happen", ex);
}
add(new Label(SubsiteGlobalizationUtil.globalize("subsite.ui.customfrontpage.label")));
add(m_customFrontpageApp); // adds selectfield start page to form
/* Setup selection box for themes */
m_themes = new SingleSelect(new StringParameter("selectStyleDir"));
m_themes.setMetaDataAttribute("title", "XSLT Directory");
m_themes.setHint("Select an existing theme from the list, select" +
" 'Other' to type something below or select" +
" 'Site Wide Default' to get the default themes." );
m_themes.setHint((String) SubsiteGlobalizationUtil.globalize("subsite.ui.theme.hint").localize());
try {
m_themes.addPrintListener(new ThemesListener());
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("This cannot happen", ex);
}
add(new Label(SubsiteGlobalizationUtil.globalize("subsite.ui.theme.label")));
add(m_themes); // adds themes selection box to form
@ -186,8 +180,8 @@ public class SiteForm extends Form {
m_styleDir = new TextField(new StringParameter("styleDir"));
m_styleDir.setMetaDataAttribute("title", "XSLT Directory (Other)");
m_styleDir.setSize(40);
m_styleDir.setHint( "Enter the directory for the custom XSLT styles, "
+"or leave blank for the default styling." );
m_styleDir.setHint("Enter the directory for the custom XSLT styles, or leave blank for the default styling.");
add(new Label(SubsiteGlobalizationUtil.globalize("subsite.ui.styledir.label")));
add(m_styleDir); // adds inputfield style dir to form
@ -197,16 +191,18 @@ public class SiteForm extends Form {
new Class[]{String.class},
new Object[]{"rootCategory"});
if (m_rootCategory instanceof Widget) {
((Widget)m_rootCategory)
.setMetaDataAttribute("title", "Root category");
((Widget)m_rootCategory)
.setHint("Select a root navigation category");
((Widget) m_rootCategory).setMetaDataAttribute("title", "Root category");
((Widget) m_rootCategory).setHint((String) SubsiteGlobalizationUtil.globalize(
"subsite.ui.root_category.hint").localize());
}
add(new Label(SubsiteGlobalizationUtil.globalize("subsite.ui.root_category.label")));
add(m_rootCategory); // adds domain category selection box to form
m_buttons = new SaveCancelSection();
m_buttons.getSaveButton().setButtonLabel(SubsiteGlobalizationUtil.globalize("subsite.ui.save"));
m_buttons.getSaveButton().setHint("Save the details in the form");
m_buttons.getCancelButton().setButtonLabel(SubsiteGlobalizationUtil.globalize("subsite.ui.cancel"));
m_buttons.getCancelButton().setHint("Abort changes & reset the form");
add(m_buttons);
@ -221,6 +217,7 @@ public class SiteForm extends Form {
*
*/
private class SiteSubmissionListener implements FormSubmissionListener {
public void submitted(FormSectionEvent e)
throws FormProcessException {
PageState state = e.getPageState();
@ -230,6 +227,7 @@ public class SiteForm extends Form {
throw new FormProcessException("cancel pressed");
}
}
}
/**
@ -254,17 +252,13 @@ public class SiteForm extends Form {
// need to make sure the styleDir is null
if (OTHER_STYLE.equals(themeDir)) {
if (StringUtils.emptyString(styleDir)) {
data.addError(
"If you choose '" + OTHER_STYLE_LABEL +
"' for the XSL Directory Select then " +
"you need to provide a style in the Text Field");
data.addError(SubsiteGlobalizationUtil.globalize("subsite.ui.other_style_missing",
new String[]{OTHER_STYLE_LABEL}));
}
} else {
if (!StringUtils.emptyString(styleDir)) {
data.addError(
"In order to set a in the text field, " +
"the XSL Directory select box must say '" +
OTHER_STYLE_LABEL + "'");
data.addError(SubsiteGlobalizationUtil.globalize("subsite.ui.other_style_invalid",
new String[]{OTHER_STYLE_LABEL}));
}
}
@ -274,10 +268,8 @@ public class SiteForm extends Form {
try {
Category testExist = m_rootCategory.getCategory(state);
String test = testExist.getDefaultDomainClass();
}
catch (Exception ex) {
data.addError(
"No valid category selected. Check category selection!");
} catch (Exception ex) {
data.addError(SubsiteGlobalizationUtil.globalize("subsite.ui.root_category_missing"));
}
} // End if (!m_buttons ...)
@ -289,6 +281,7 @@ public class SiteForm extends Form {
* Checks whether hostname is alreafy in use.
*/
private class HostNameValidationListener implements ParameterListener {
public void validate(ParameterEvent e) {
ParameterData data = e.getParameterData();
String hostname = (String) data.getValue();
@ -303,13 +296,12 @@ public class SiteForm extends Form {
sites.addNotEqualsFilter(Site.ID, site.getID());
}
if (sites.size() > 0) {
data.addError(
"The host name " + hostname +
" is already used by another site");
data.addError(SubsiteGlobalizationUtil.globalize("subsite.ui.hostname_already_in_use"));
}
}
}
}
/**
@ -345,8 +337,7 @@ public class SiteForm extends Form {
+ ", Current frontpage is: " + currentFrontpageID);
m_customFrontpageApp.setValue(
state,
currentFrontpageID == siteDefaultRootPageID ?
DEFAULT_APP : currentFrontpageID.toString() );
currentFrontpageID == siteDefaultRootPageID ? DEFAULT_APP : currentFrontpageID.toString());
String styleURL = site.getStyleDirectory();
// if the value is in the config map, then styleDir is
@ -374,6 +365,7 @@ public class SiteForm extends Form {
m_rootCategory.setCategory(state, root);
}
}
}
/**
@ -468,8 +460,8 @@ public class SiteForm extends Form {
site.getTemplateContext().getContext());
}
}
}
/**
*
@ -495,8 +487,7 @@ public class SiteForm extends Form {
* of the (BigDecimal) ID as value and the URL as
* label. */
String appID = customApps.get(ACSObject.ID).toString();
target.addOption( new
Option(appID ,
target.addOption(new Option(appID,
(customApps.getPrimaryURL()
+ "(" + appID + ")")));
}
@ -508,7 +499,6 @@ public class SiteForm extends Form {
}
/**
*
*/

View File

@ -0,0 +1,27 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.arsdigita.subsite.ui;
import com.arsdigita.globalization.GlobalizedMessage;
/**
*
* @author Jens Pelzetter <jens@jp-digital.de>
* @version $Id$
*/
public class SubsiteGlobalizationUtil {
public static final String BUNDLE_NAME = "com.arsdigita.subsite.ui.SubsiteResources";
public static GlobalizedMessage globalize(final String key) {
return new GlobalizedMessage(key, BUNDLE_NAME);
}
public static GlobalizedMessage globalize(final String key,
final Object[] args) {
return new GlobalizedMessage(key, BUNDLE_NAME, args);
}
}

View File

@ -0,0 +1,23 @@
# To change this template, choose Tools | Templates
# and open the template in the editor.
subsite.ui.title.hint=Enter the title of the subsite, upto 80 characters
subsite.ui.title.label=Title
subsite.ui.hostname.hint=Enter the hostname for the subsite, eg business.example.com
subsite.ui.hostname.label=Hostname
subsite.ui.description.hint=Enter a short description for the subsite, up to 4000 characters
subsite.ui.description.label=Description
subsite.ui.customfrontpage.hint=Select the name (url) of the subsite custom homepage
subsite.ui.customfrontpage.label=Front Page
subsite.ui.theme.hint=Select an existing theme from the list, select 'Other' to type something below or select 'Site Wide Default' to get the default themes.
subsite.ui.theme.label=Theme
subsite.ui.styledir.hint=Enter the directory for the custom XSLT styles, or leave blank for the default styling.
subsite.ui.styledir.label=Custom XSL directory
subsite.ui.root_category.hint=Select a root navigation category for the subsite
subsite.ui.root_category.label=Root category
subsite.ui.save=Save
subsite.ui.cancel=Cancel
subsite.ui.other_style_missing=If you choose {0} for the theme you need to provide a style in the text field
subsite.ui.other_style_invalid=To set custom XSL directory select {0} in for the theme
subsite.ui.root_category_missing=No root category selected
subsite.ui.hostname_already_in\ use=The hostname {0} is already used by another subsite

View File

@ -0,0 +1,23 @@
# To change this template, choose Tools | Templates
# and open the template in the editor.
subsite.ui.title.hint=Geben Sie den Titel der Subsite ein. Der Titel darf max. 80 Zeichen lang sein.
subsite.ui.title.label=Titel
subsite.ui.hostname.hint=Geben Sie den hostname, z.B. business.example.com, ein
subsite.ui.hostname.label=Hostname
subsite.ui.description.hint=Geben sie hier eine kurze Beschreibung der Seite ein (max. 4000 Zeichen)
subsite.ui.description.label=Beschreibung
subsite.ui.customfrontpage.hint=W\u00e4hlen Sie den Startseite f\u00fcr die Subsite
subsite.ui.customfrontpage.label=Startseite
subsite.ui.theme.hint=W\u00e4hlen Sie ein existierendes Theme aus. Um ein anderes Theme im Eingabefeld anzugeben w\u00e4hlen 'Other'. Um das Standard-Theme zu verwenden w\u00e4hlen Sie 'Site-Wide-Default'
subsite.ui.theme.label=Theme
subsite.ui.styledir.hint=Geben Sie den Pfad zu einem Verzeichnis mit eigenen XSL-Styles an. Um die Standard-Styles zu verwenden, lassen Sie das Feld leer.
subsite.ui.styledir.label=Zus\u00e4tzliches XSL Verzeichnis
subsite.ui.root_category.hint=W\u00e4hlen Sie das Kategoriensystem f\u00fcr die Subsite
subsite.ui.root_category.label=Kategoriensystem
subsite.ui.save=Speichern
subsite.ui.cancel=Abbrechen
subsite.ui.other_style_missing=Wenn Sie {0} f\u00fcr das Theme w\u00e4hlen, m\u00fcssen Sie im Textfeld ein Theme angeben
subsite.ui.other_style_invalid=Um ein eigenes Verzeichnis mit XSL-Styles anzugeben, w\u00e4hlen Sie {0} f\u00fcr das Theme
subsite.ui.root_category_missing=Kein Kategoriensystem ausgew\u00e4hlt
subsite.ui.hostname_already_in\ use=Der Hostname {0} wird bereits von einer anderen Subsite verwendet