All usages of SingleSelect/OptionGroup and PrintListener fixed by adding a clearOptions() in the PrintListener. Issue #2171.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2837 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2014-09-04 11:52:51 +00:00
parent 31d94afaad
commit cf9ed68bfb
65 changed files with 3600 additions and 3582 deletions

View File

@ -81,6 +81,7 @@ public class CategoryProviderContentTypeBlockForm extends Form {
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
OptionGroup optionGroup = (OptionGroup) e.getTarget(); OptionGroup optionGroup = (OptionGroup) e.getTarget();
optionGroup.clearOptions();
ContentTypeCollection ctc = ContentType ContentTypeCollection ctc = ContentType
.getRegisteredContentTypes(); .getRegisteredContentTypes();
ctc.addOrder(ContentType.LABEL); ctc.addOrder(ContentType.LABEL);

View File

@ -15,7 +15,6 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.atoz.ui.admin; package com.arsdigita.atoz.ui.admin;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
@ -75,8 +74,8 @@ public class ItemProviderAliasForm extends Form {
m_letter = new SingleSelect("letter"); m_letter = new SingleSelect("letter");
m_letter.addValidationListener(new NotNullValidationListener()); m_letter.addValidationListener(new NotNullValidationListener());
m_letter.addOption(new Option(null, "--Select one--")); m_letter.addOption(new Option(null, "--Select one--"));
for (int i = 0 ; i < 26 ; i++) { for (int i = 0; i < 26; i++) {
String letter = new String(new char[]{(char)((int)'a' + i)}); String letter = new String(new char[]{(char) ((int) 'a' + i)});
m_letter.addOption(new Option(letter, letter.toUpperCase())); m_letter.addOption(new Option(letter, letter.toUpperCase()));
} }
@ -85,23 +84,25 @@ public class ItemProviderAliasForm extends Form {
m_item.addPrintListener(new PrintListener() { m_item.addPrintListener(new PrintListener() {
public void prepare(PrintEvent event) { public void prepare(PrintEvent event) {
OptionGroup group = (SingleSelect) event.getTarget(); OptionGroup group = (SingleSelect) event.getTarget();
group.clearOptions();
PageState state = event.getPageState(); PageState state = event.getPageState();
boolean valueSet = false; boolean valueSet = false;
Category category = ((ItemProvider) m_provider.getSelectedObject(state)) Category category = ((ItemProvider) m_provider.getSelectedObject(state))
.getCategory(); .getCategory();
CategorizedCollection children = category.getObjects(ContentItem.BASE_DATA_OBJECT_TYPE); CategorizedCollection children = category.getObjects(
ContentItem.BASE_DATA_OBJECT_TYPE);
children.addOrder("name"); children.addOrder("name");
while (children.next()) { while (children.next()) {
ACSObject item = (ACSObject) children.getDomainObject(); ACSObject item = (ACSObject) children.getDomainObject();
if ((item instanceof ContentItem) && if ((item instanceof ContentItem) && ((ContentItem) item).getVersion().
((ContentItem) item).getVersion().equals(ContentItem.DRAFT)) { equals(ContentItem.DRAFT)) {
group.addOption(new Option(item.getID().toString(), group.addOption(new Option(item.getID().toString(),
((ContentItem)item).getName())); ((ContentItem) item).getName()));
} }
} }
} }
@ -123,6 +124,7 @@ public class ItemProviderAliasForm extends Form {
} }
private class ProviderSubmissionListener implements FormSubmissionListener { private class ProviderSubmissionListener implements FormSubmissionListener {
public void submitted(FormSectionEvent e) public void submitted(FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
PageState state = e.getPageState(); PageState state = e.getPageState();
@ -135,6 +137,7 @@ public class ItemProviderAliasForm extends Form {
} }
private class ProviderProcessListener implements FormProcessListener { private class ProviderProcessListener implements FormProcessListener {
public void process(FormSectionEvent e) public void process(FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
PageState state = e.getPageState(); PageState state = e.getPageState();
@ -145,11 +148,10 @@ public class ItemProviderAliasForm extends Form {
BigDecimal itemId = new BigDecimal(m_item.getValue(state).toString()); BigDecimal itemId = new BigDecimal(m_item.getValue(state).toString());
ContentItem item = new ContentItem(itemId); ContentItem item = new ContentItem(itemId);
String letter = (String)m_letter.getValue(state); String letter = (String) m_letter.getValue(state);
String title = (String)m_title.getValue(state); String title = (String) m_title.getValue(state);
//provider.addAlias(item, letter, title); //provider.addAlias(item, letter, title);
ItemAlias alias = (ItemAlias) Classes.newInstance(ItemAlias.class); ItemAlias alias = (ItemAlias) Classes.newInstance(ItemAlias.class);
alias.setTitle(title); alias.setTitle(title);
alias.setLetter(letter); alias.setLetter(letter);

View File

@ -78,6 +78,7 @@ public class GenericOrgaUnitTextAssetEdit extends BasicItemForm implements FormS
@Override @Override
public void prepare(final PrintEvent event) { public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget(); final SingleSelect target = (SingleSelect) event.getTarget();
target.clearOptions();
final RelationAttributeCollection names = new RelationAttributeCollection( final RelationAttributeCollection names = new RelationAttributeCollection(
"GenericOrgaUnitTextAssetName"); "GenericOrgaUnitTextAssetName");

View File

@ -102,6 +102,7 @@ public class PublicPersonalProfileCreate extends PageCreate {
ownerSelect.addPrintListener(new PrintListener() { ownerSelect.addPrintListener(new PrintListener() {
public void prepare(final PrintEvent event) { public void prepare(final PrintEvent event) {
final SingleSelect ownerSelect = (SingleSelect) event.getTarget(); final SingleSelect ownerSelect = (SingleSelect) event.getTarget();
ownerSelect.clearOptions();
String personType = config.getPersonType(); String personType = config.getPersonType();
if ((personType == null) || (personType.isEmpty())) { if ((personType == null) || (personType.isEmpty())) {

View File

@ -105,6 +105,7 @@ public class PublicPersonalProfileNavigationAddForm
public void prepare(final PrintEvent event) { public void prepare(final PrintEvent event) {
SingleSelect select = (SingleSelect) event.getTarget(); SingleSelect select = (SingleSelect) event.getTarget();
select.clearOptions();
select.addOption(new Option("", "")); select.addOption(new Option("", ""));
PublicPersonalProfileNavItemCollection navItems = PublicPersonalProfileNavItemCollection navItems =

View File

@ -91,6 +91,7 @@ public class PublicPersonalProfilePropertyForm extends BasicPageForm implements
ownerSelect.addPrintListener(new PrintListener() { ownerSelect.addPrintListener(new PrintListener() {
public void prepare(final PrintEvent event) { public void prepare(final PrintEvent event) {
final SingleSelect ownerSelect = (SingleSelect) event.getTarget(); final SingleSelect ownerSelect = (SingleSelect) event.getTarget();
ownerSelect.clearOptions();
final PublicPersonalProfile profile = (PublicPersonalProfile) itemModel.getSelectedItem(event. final PublicPersonalProfile profile = (PublicPersonalProfile) itemModel.getSelectedItem(event.
getPageState()); getPageState());

View File

@ -105,7 +105,7 @@ public class DecisionTreeOptionEditForm extends Form
setMethod(Form.POST); setMethod(Form.POST);
setEncType("multipart/form-data"); setEncType("multipart/form-data");
ColumnPanel panel = (ColumnPanel)getPanel(); ColumnPanel panel = (ColumnPanel) getPanel();
panel.setBorder(false); panel.setBorder(false);
panel.setPadColor("#FFFFFF"); panel.setPadColor("#FFFFFF");
panel.setColumnWidth(1, "20%"); panel.setColumnWidth(1, "20%");
@ -133,6 +133,7 @@ public class DecisionTreeOptionEditForm extends Form
/** /**
* Returns the save/cancel section from this form. * Returns the save/cancel section from this form.
*
* @return * @return
*/ */
public SaveCancelSection getSaveCancelSection() { public SaveCancelSection getSaveCancelSection() {
@ -145,7 +146,9 @@ public class DecisionTreeOptionEditForm extends Form
private void initSectionOptions(PrintEvent e) { private void initSectionOptions(PrintEvent e) {
PageState state = e.getPageState(); PageState state = e.getPageState();
SingleSelect target = (SingleSelect) e.getTarget(); SingleSelect target = (SingleSelect) e.getTarget();
DecisionTree tree = (DecisionTree)m_selTree.getSelectedObject(state); target.clearOptions();
DecisionTree tree = (DecisionTree) m_selTree.getSelectedObject(state);
if (tree != null) { if (tree != null) {
DecisionTreeSectionCollection sections = tree.getSections(); DecisionTreeSectionCollection sections = tree.getSections();
@ -162,6 +165,7 @@ public class DecisionTreeOptionEditForm extends Form
/** /**
* Form initialisation hook. * Form initialisation hook.
*
* @param fse * @param fse
*/ */
@Override @Override
@ -229,20 +233,18 @@ public class DecisionTreeOptionEditForm extends Form
/** /**
* @param event * @param event
* @throws com.arsdigita.bebop.FormProcessException * @throws com.arsdigita.bebop.FormProcessException Called on form submission. Check to see if
* Called on form submission. Check to see if the user clicked the * the user clicked the cancel button. If they did, don't continue with the form.
* cancel button. If they did, don't continue with the form.
*/ */
@Override @Override
public void submitted(FormSectionEvent event) public void submitted(FormSectionEvent event)
throws FormProcessException { throws FormProcessException {
PageState state = event.getPageState(); PageState state = event.getPageState();
if ( m_saveCancelSection.getCancelButton() if (m_saveCancelSection.getCancelButton()
.isSelected(state) && m_container != null) { .isSelected(state) && m_container != null) {
m_container.onlyShowComponent( m_container.onlyShowComponent(
state, DecisionTreeOptionStep.OPTION_TABLE + state, DecisionTreeOptionStep.OPTION_TABLE + m_container.getTypeIDStr());
m_container.getTypeIDStr());
throw new FormProcessException( throw new FormProcessException(
DecisionTreeGlobalizationUtil.globalize( DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.options.form.submission_cancelled") "cms.contenttypes.ui.decisiontree.options.form.submission_cancelled")
@ -251,8 +253,8 @@ public class DecisionTreeOptionEditForm extends Form
} }
/** /**
* Called after form has been validated. Create the new SectionOption and * Called after form has been validated. Create the new SectionOption and assign it to the
* assign it to the current DecisionTree. * current DecisionTree.
* *
* @param event * @param event
* @throws com.arsdigita.bebop.FormProcessException * @throws com.arsdigita.bebop.FormProcessException
@ -262,7 +264,8 @@ public class DecisionTreeOptionEditForm extends Form
PageState state = event.getPageState(); PageState state = event.getPageState();
FormData data = event.getFormData(); FormData data = event.getFormData();
DecisionTreeSection section = new DecisionTreeSection(new BigDecimal((String)data.get(SECTION))); DecisionTreeSection section = new DecisionTreeSection(new BigDecimal((String) data.get(
SECTION)));
DecisionTreeSectionOption option; DecisionTreeSectionOption option;
if (m_selOption.getSelectedKey(state) != null) { if (m_selOption.getSelectedKey(state) != null) {
@ -277,8 +280,8 @@ public class DecisionTreeOptionEditForm extends Form
option.setRank(Integer.valueOf(rank)); option.setRank(Integer.valueOf(rank));
} }
String label = (String)data.get(LABEL); String label = (String) data.get(LABEL);
String value = (String)data.get(VALUE); String value = (String) data.get(VALUE);
option.setSection(section); option.setSection(section);
option.setLabel(label); option.setLabel(label);
@ -287,8 +290,7 @@ public class DecisionTreeOptionEditForm extends Form
if (m_container != null) { if (m_container != null) {
m_container.onlyShowComponent( m_container.onlyShowComponent(
state, state,
DecisionTreeOptionStep.OPTION_TABLE + DecisionTreeOptionStep.OPTION_TABLE + m_container.getTypeIDStr());
m_container.getTypeIDStr());
} }
} }

View File

@ -111,7 +111,7 @@ public class DecisionTreeTargetEditForm extends Form
setMethod(Form.POST); setMethod(Form.POST);
setEncType("multipart/form-data"); setEncType("multipart/form-data");
ColumnPanel panel = (ColumnPanel)getPanel(); ColumnPanel panel = (ColumnPanel) getPanel();
panel.setBorder(false); panel.setBorder(false);
panel.setPadColor("#FFFFFF"); panel.setPadColor("#FFFFFF");
panel.setColumnWidth(1, "20%"); panel.setColumnWidth(1, "20%");
@ -139,6 +139,7 @@ public class DecisionTreeTargetEditForm extends Form
/** /**
* Returns the save/cancel section from this form. * Returns the save/cancel section from this form.
*
* @return * @return
*/ */
public SaveCancelSection getSaveCancelSection() { public SaveCancelSection getSaveCancelSection() {
@ -151,7 +152,9 @@ public class DecisionTreeTargetEditForm extends Form
private void initSectionOptions(PrintEvent e) { private void initSectionOptions(PrintEvent e) {
PageState state = e.getPageState(); PageState state = e.getPageState();
SingleSelect target = (SingleSelect) e.getTarget(); SingleSelect target = (SingleSelect) e.getTarget();
DecisionTree tree = (DecisionTree)m_selTree.getSelectedObject(state); target.clearOptions();
DecisionTree tree = (DecisionTree) m_selTree.getSelectedObject(state);
if (tree != null) { if (tree != null) {
DecisionTreeSectionCollection sections = tree.getSections(); DecisionTreeSectionCollection sections = tree.getSections();
@ -173,7 +176,8 @@ public class DecisionTreeTargetEditForm extends Form
private void initTargetOptions(PrintEvent e) { private void initTargetOptions(PrintEvent e) {
PageState state = e.getPageState(); PageState state = e.getPageState();
SingleSelect target = (SingleSelect) e.getTarget(); SingleSelect target = (SingleSelect) e.getTarget();
DecisionTree tree = (DecisionTree)m_selTree.getSelectedObject(state); target.clearOptions();
DecisionTree tree = (DecisionTree) m_selTree.getSelectedObject(state);
if (tree != null) { if (tree != null) {
DecisionTreeSectionCollection sections = tree.getSections(); DecisionTreeSectionCollection sections = tree.getSections();
@ -195,7 +199,8 @@ public class DecisionTreeTargetEditForm extends Form
private void initMatchOptions(PrintEvent e) { private void initMatchOptions(PrintEvent e) {
PageState state = e.getPageState(); PageState state = e.getPageState();
SingleSelect target = (SingleSelect) e.getTarget(); SingleSelect target = (SingleSelect) e.getTarget();
DecisionTree tree = (DecisionTree)m_selTree.getSelectedObject(state); target.clearOptions();
DecisionTree tree = (DecisionTree) m_selTree.getSelectedObject(state);
if (tree != null) { if (tree != null) {
DecisionTreeSectionOptionCollection sectionOptions = tree.getOptions(); DecisionTreeSectionOptionCollection sectionOptions = tree.getOptions();
@ -203,8 +208,8 @@ public class DecisionTreeTargetEditForm extends Form
while (sectionOptions.next()) { while (sectionOptions.next()) {
DecisionTreeSectionOption sectionOption = sectionOptions DecisionTreeSectionOption sectionOption = sectionOptions
.getOption(); .getOption();
String label = sectionOption.getSection().getTitle() + String label = sectionOption.getSection().getTitle() + " : " + sectionOption.
" : " + sectionOption.getLabel(); getLabel();
Option option = new Option(sectionOption.getID().toString(), Option option = new Option(sectionOption.getID().toString(),
label); label);
target.addOption(option, state); target.addOption(option, state);
@ -214,7 +219,9 @@ public class DecisionTreeTargetEditForm extends Form
} }
} }
/** Form initialisation hook. Sets the options for select widgets. /**
* Form initialisation hook. Sets the options for select widgets.
*
* @param fse * @param fse
*/ */
@Override @Override
@ -231,10 +238,11 @@ public class DecisionTreeTargetEditForm extends Form
data.put(TARGET_URL, target.getTargetURL()); data.put(TARGET_URL, target.getTargetURL());
DecisionTreeSection targetSection = target.getTargetSection(); DecisionTreeSection targetSection = target.getTargetSection();
if (targetSection != null) if (targetSection != null) {
data.put(TARGET_SECTION, targetSection.getID()); data.put(TARGET_SECTION, targetSection.getID());
} }
} }
}
/** /**
* Add form widgets for a Section. * Add form widgets for a Section.
@ -243,10 +251,10 @@ public class DecisionTreeTargetEditForm extends Form
Option pleaseSelect = new Option( Option pleaseSelect = new Option(
"", "",
new Label(DecisionTreeGlobalizationUtil.globalize( new Label(DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.targets.form.please_select") )); "cms.contenttypes.ui.decisiontree.targets.form.please_select")));
Option none = new Option( Option none = new Option(
"", "",
new Label( DecisionTreeGlobalizationUtil.globalize( new Label(DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.targets.form.none"))); "cms.contenttypes.ui.decisiontree.targets.form.none")));
// add(new Label(DecisionTreeGlobalizationUtil.globalize( // add(new Label(DecisionTreeGlobalizationUtil.globalize(
@ -317,8 +325,9 @@ public class DecisionTreeTargetEditForm extends Form
} }
/** /**
* Called on form submission. Check to see if the user clicked the * Called on form submission. Check to see if the user clicked the cancel button. If they did,
* cancel button. If they did, don't continue with the form. * don't continue with the form.
*
* @param event * @param event
* @throws com.arsdigita.bebop.FormProcessException * @throws com.arsdigita.bebop.FormProcessException
*/ */
@ -327,11 +336,11 @@ public class DecisionTreeTargetEditForm extends Form
throws FormProcessException { throws FormProcessException {
PageState state = event.getPageState(); PageState state = event.getPageState();
if ( m_saveCancelSection.getCancelButton().isSelected(state) if (m_saveCancelSection.getCancelButton().isSelected(state)
&& m_container != null) { && m_container != null) {
m_container.onlyShowComponent(state, m_container.onlyShowComponent(state,
DecisionTreeTargetStep.TARGET_TABLE + DecisionTreeTargetStep.TARGET_TABLE + m_container.
m_container.getTypeIDStr()); getTypeIDStr());
throw new FormProcessException( throw new FormProcessException(
DecisionTreeGlobalizationUtil.globalize( DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.targets.form.submission_cancelled") "cms.contenttypes.ui.decisiontree.targets.form.submission_cancelled")
@ -340,8 +349,8 @@ public class DecisionTreeTargetEditForm extends Form
} }
/** /**
* Called after form has been validated. Create the new * Called after form has been validated. Create the new DecisionTreeOptionTarget and assign it
* DecisionTreeOptionTarget and assign it to the current DecisionTree. * to the current DecisionTree.
* *
* @param event * @param event
* @throws com.arsdigita.bebop.FormProcessException * @throws com.arsdigita.bebop.FormProcessException
@ -351,12 +360,11 @@ public class DecisionTreeTargetEditForm extends Form
PageState state = event.getPageState(); PageState state = event.getPageState();
FormData data = event.getFormData(); FormData data = event.getFormData();
DecisionTreeSectionOption matchOption = new DecisionTreeSectionOption matchOption = new DecisionTreeSectionOption(new BigDecimal(
DecisionTreeSectionOption(new (String) data.get(MATCH_OPTION)));
BigDecimal((String)data.get(MATCH_OPTION)));
DecisionTreeSection targetSection = null; DecisionTreeSection targetSection = null;
String sectionID = (String)data.get(TARGET_SECTION); String sectionID = (String) data.get(TARGET_SECTION);
if (!"".equals(sectionID)) { if (!"".equals(sectionID)) {
targetSection = new DecisionTreeSection(new BigDecimal(sectionID)); targetSection = new DecisionTreeSection(new BigDecimal(sectionID));
} }
@ -372,14 +380,13 @@ public class DecisionTreeTargetEditForm extends Form
} }
target.setMatchOption(matchOption); target.setMatchOption(matchOption);
target.setTargetURL((String)data.get(TARGET_URL)); target.setTargetURL((String) data.get(TARGET_URL));
target.setTargetSection(targetSection); target.setTargetSection(targetSection);
if (m_container != null) { if (m_container != null) {
m_container.onlyShowComponent( m_container.onlyShowComponent(
state, state,
DecisionTreeTargetStep.TARGET_TABLE + DecisionTreeTargetStep.TARGET_TABLE + m_container.getTypeIDStr());
m_container.getTypeIDStr());
} }
} }

View File

@ -76,6 +76,7 @@ public class ContentSectionCreateForm extends Form {
@Override @Override
public void prepare(final PrintEvent event) { public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget(); final SingleSelect target = (SingleSelect) event.getTarget();
target.clearOptions();
final DataCollection categories = SessionManager.getSession().retrieve( final DataCollection categories = SessionManager.getSession().retrieve(
Category.BASE_DATA_OBJECT_TYPE); Category.BASE_DATA_OBJECT_TYPE);

View File

@ -124,9 +124,6 @@ public class GenericAddressPropertyForm extends BasicPageForm
SingleSelect country = new SingleSelect(countryParam); SingleSelect country = new SingleSelect(countryParam);
country.setLabel(ContenttypesGlobalizationUtil country.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.iso_country_code")); .globalize("cms.contenttypes.ui.address.iso_country_code"));
country.addOption(new Option("",
new Label(GlobalizationUtil
.globalize("cms.ui.select_one"))));
try { try {
country.addPrintListener(new PrintListener() { country.addPrintListener(new PrintListener() {
@ -134,9 +131,14 @@ public class GenericAddressPropertyForm extends BasicPageForm
@Override @Override
public void prepare(final PrintEvent event) { public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget(); final SingleSelect target = (SingleSelect) event.getTarget();
target.clearOptions();
final Iterator countries = GenericAddress.getSortedListOfCountries(null) final Iterator countries = GenericAddress.getSortedListOfCountries(null)
.entrySet().iterator(); .entrySet().iterator();
target.addOption(new Option("",
new Label(GlobalizationUtil
.globalize("cms.ui.select_one"))));
while (countries.hasNext()) { while (countries.hasNext()) {
Map.Entry<String, String> elem = (Map.Entry<String, String>) countries Map.Entry<String, String> elem = (Map.Entry<String, String>) countries
.next(); .next();

View File

@ -118,15 +118,18 @@ public class GenericContactAttachPersonPropertyForm extends BasicPageForm
contactType.setLabel(ContenttypesGlobalizationUtil.globalize( contactType.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericperson.contact.type")); "cms.contenttypes.ui.genericperson.contact.type"));
contactType.addValidationListener(new NotNullValidationListener()); contactType.addValidationListener(new NotNullValidationListener());
contactType.addOption(new Option("",
new Label(GlobalizationUtil
.globalize("cms.ui.select_one"))));
try { try {
contactType.addPrintListener(new PrintListener() { contactType.addPrintListener(new PrintListener() {
@Override @Override
public void prepare(final PrintEvent event) { public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget(); final SingleSelect target = (SingleSelect) event.getTarget();
target.clearOptions();
target.addOption(new Option("",
new Label(GlobalizationUtil
.globalize("cms.ui.select_one"))));
final GenericContactTypeCollection contacttypes final GenericContactTypeCollection contacttypes
= new GenericContactTypeCollection(); = new GenericContactTypeCollection();

View File

@ -142,16 +142,17 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm
country.setLabel(ContenttypesGlobalizationUtil.globalize( country.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.address.iso_country_code")); "cms.contenttypes.ui.address.iso_country_code"));
country.addOption(new Option("",
new Label(ContenttypesGlobalizationUtil
.globalize("cms.ui.select_one"))));
try { try {
country.addPrintListener(new PrintListener() { country.addPrintListener(new PrintListener() {
@Override @Override
public void prepare(final PrintEvent event) { public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget(); final SingleSelect target = (SingleSelect) event.getTarget();
target.clearOptions();
target.addOption(new Option("",
new Label(ContenttypesGlobalizationUtil
.globalize("cms.ui.select_one"))));
final Iterator countries = GenericAddress.getSortedListOfCountries(null) final Iterator countries = GenericAddress.getSortedListOfCountries(null)
.entrySet().iterator(); .entrySet().iterator();

View File

@ -137,15 +137,17 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm
contactType.setLabel(ContenttypesGlobalizationUtil contactType.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.contact.type")); .globalize("cms.contenttypes.ui.person.contact.type"));
contactType.addValidationListener(new NotNullValidationListener()); contactType.addValidationListener(new NotNullValidationListener());
contactType.addOption(new Option("",
new Label(GlobalizationUtil
.globalize("cms.ui.select_one"))));
try { try {
contactType.addPrintListener(new PrintListener() { contactType.addPrintListener(new PrintListener() {
@Override @Override
public void prepare(final PrintEvent event) { public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget(); final SingleSelect target = (SingleSelect) event.getTarget();
target.clearOptions();
target.addOption(new Option("",
new Label(GlobalizationUtil
.globalize("cms.ui.select_one"))));
final GenericContactTypeCollection contacttypes final GenericContactTypeCollection contacttypes
= new GenericContactTypeCollection(); = new GenericContactTypeCollection();

View File

@ -74,14 +74,16 @@ public class GenericContactEntryAddForm extends BasicItemForm {
contactEntryKey.setLabel(ContenttypesGlobalizationUtil.globalize( contactEntryKey.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericcontact.contactEntry.key")); "cms.contenttypes.ui.genericcontact.contactEntry.key"));
contactEntryKey.addValidationListener(new NotNullValidationListener()); contactEntryKey.addValidationListener(new NotNullValidationListener());
contactEntryKey.addOption(new Option("", new Label(GlobalizationUtil.globalize(
"cms.ui.select_one"))));
try { try {
contactEntryKey.addPrintListener(new PrintListener() { contactEntryKey.addPrintListener(new PrintListener() {
@Override @Override
public void prepare(final PrintEvent event) { public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget(); final SingleSelect target = (SingleSelect) event.getTarget();
target.clearOptions();
target.addOption(new Option("", new Label(GlobalizationUtil.globalize(
"cms.ui.select_one"))));
final GenericContactEntryKeys keyList = new GenericContactEntryKeys(); final GenericContactEntryKeys keyList = new GenericContactEntryKeys();
// keyList.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale() // keyList.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale()

View File

@ -45,8 +45,8 @@ import org.apache.log4j.Logger;
/** /**
* Generates a form for creating new localisations for the given category. * Generates a form for creating new localisations for the given category.
* *
* This class is part of the admin GUI of CCM and extends the standard form * This class is part of the admin GUI of CCM and extends the standard form in order to present
* in order to present forms for managing the multi-language categories. * forms for managing the multi-language categories.
* *
* @author Sören Bernstein <quasi@quasiweb.de> * @author Sören Bernstein <quasi@quasiweb.de>
*/ */
@ -63,7 +63,9 @@ public class GenericContactTypeAddForm extends BasicItemForm {
private ItemSelectionModel m_itemModel; private ItemSelectionModel m_itemModel;
private SingleSelect language; private SingleSelect language;
/** Creates a new instance of CategoryLocalizationAddForm */ /**
* Creates a new instance of CategoryLocalizationAddForm
*/
public GenericContactTypeAddForm(ItemSelectionModel itemModel) { public GenericContactTypeAddForm(ItemSelectionModel itemModel) {
super("ContactEntryAddForm", itemModel); super("ContactEntryAddForm", itemModel);
@ -88,7 +90,8 @@ public class GenericContactTypeAddForm extends BasicItemForm {
language.setLabel(ContenttypesGlobalizationUtil language.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.contacttypes.language")); .globalize("cms.contenttypes.ui.contacttypes.language"));
language.addValidationListener(new NotNullValidationListener()); language.addValidationListener(new NotNullValidationListener());
language.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil.globalize("cms.ui.select_one").localize()))); language.addOption(new Option("", new Label((String) ContenttypesGlobalizationUtil.
globalize("cms.ui.select_one").localize())));
// Name // Name
ParameterModel nameParam = new StringParameter(NAME); ParameterModel nameParam = new StringParameter(NAME);
@ -99,17 +102,15 @@ public class GenericContactTypeAddForm extends BasicItemForm {
.globalize("cms.contenttypes.ui.contacttypes.name")); .globalize("cms.contenttypes.ui.contacttypes.name"));
add(name); add(name);
} }
public void init(FormSectionEvent fse) { public void init(FormSectionEvent fse) {
FormData data = fse.getFormData(); FormData data = fse.getFormData();
PageState state = fse.getPageState(); PageState state = fse.getPageState();
RelationAttribute contacttype = (RelationAttribute) RelationAttribute contacttype = (RelationAttribute) getItemSelectionModel()
getItemSelectionModel()
.getSelectedObject(state); .getSelectedObject(state);
GenericContactTypeCollection contacttypeCollection = new GenericContactTypeCollection contacttypeCollection = new GenericContactTypeCollection(
GenericContactTypeCollection(contacttype.getKey()); contacttype.getKey());
// all supported languages (by registry entry) // all supported languages (by registry entry)
KernelConfig kernelConfig = Kernel.getConfig(); KernelConfig kernelConfig = Kernel.getConfig();
@ -121,8 +122,7 @@ public class GenericContactTypeAddForm extends BasicItemForm {
// If lanuage exists, remove it from the selection list // If lanuage exists, remove it from the selection list
if (!contacttypeCollection.hasLanguage(code)) { if (!contacttypeCollection.hasLanguage(code)) {
language.addOption(new language.addOption(new Option(code,
Option(code,
new Locale(code).getDisplayLanguage()), new Locale(code).getDisplayLanguage()),
state); state);
} }
@ -138,8 +138,7 @@ public class GenericContactTypeAddForm extends BasicItemForm {
public void process(FormSectionEvent fse) { public void process(FormSectionEvent fse) {
FormData data = fse.getFormData(); FormData data = fse.getFormData();
PageState state = fse.getPageState(); PageState state = fse.getPageState();
RelationAttribute contacttype = (RelationAttribute) RelationAttribute contacttype = (RelationAttribute) getItemSelectionModel()
getItemSelectionModel()
.getSelectedObject(state); .getSelectedObject(state);
// //

View File

@ -98,15 +98,18 @@ public class GenericOrganizationalUnitContactAddForm
contactType.setLabel(ContenttypesGlobalizationUtil.globalize( contactType.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.contact.type")); "cms.contenttypes.ui.genericorgaunit.contact.type"));
contactType.addValidationListener(new NotNullValidationListener()); contactType.addValidationListener(new NotNullValidationListener());
contactType.addOption(new Option("",
new Label(ContenttypesGlobalizationUtil.
globalize("cms.ui.select_one"))));
try { try {
contactType.addPrintListener(new PrintListener() { contactType.addPrintListener(new PrintListener() {
@Override @Override
public void prepare(final PrintEvent event) { public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget(); final SingleSelect target = (SingleSelect) event.getTarget();
target.clearOptions();
target.addOption(new Option("",
new Label(ContenttypesGlobalizationUtil.
globalize("cms.ui.select_one"))));
final GenericOrganizationContactTypeCollection contacttypes final GenericOrganizationContactTypeCollection contacttypes
= new GenericOrganizationContactTypeCollection(); = new GenericOrganizationContactTypeCollection();

View File

@ -100,16 +100,19 @@ public class GenericOrganizationalUnitPersonAddForm
roleSelect.setLabel(ContenttypesGlobalizationUtil.globalize( roleSelect.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.person.role")); "cms.contenttypes.ui.genericorgaunit.person.role"));
roleSelect.addValidationListener(new NotNullValidationListener()); roleSelect.addValidationListener(new NotNullValidationListener());
roleSelect.addOption(
new Option("",
new Label(ContenttypesGlobalizationUtil
.globalize("cms.ui.select_one"))));
try { try {
roleSelect.addPrintListener(new PrintListener() { roleSelect.addPrintListener(new PrintListener() {
@Override @Override
public void prepare(final PrintEvent event) { public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget(); final SingleSelect target = (SingleSelect) event.getTarget();
target.clearOptions();
target.addOption(
new Option("",
new Label(ContenttypesGlobalizationUtil
.globalize("cms.ui.select_one"))));
final RelationAttributeCollection roles = new RelationAttributeCollection( final RelationAttributeCollection roles = new RelationAttributeCollection(
getRoleAttributeName()); getRoleAttributeName());
@ -139,15 +142,18 @@ public class GenericOrganizationalUnitPersonAddForm
statusSelect.setLabel(ContenttypesGlobalizationUtil.globalize( statusSelect.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.person.status")); "cms.contenttypes.ui.genericorgaunit.person.status"));
statusSelect.addValidationListener(new NotNullValidationListener()); statusSelect.addValidationListener(new NotNullValidationListener());
statusSelect.addOption(new Option("",
new Label(ContenttypesGlobalizationUtil.
globalize("cms.ui.select_one"))));
try { try {
statusSelect.addPrintListener(new PrintListener() { statusSelect.addPrintListener(new PrintListener() {
@Override @Override
public void prepare(final PrintEvent event) { public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget(); final SingleSelect target = (SingleSelect) event.getTarget();
target.clearOptions();
statusSelect.addOption(new Option("",
new Label(ContenttypesGlobalizationUtil.
globalize("cms.ui.select_one"))));
RelationAttributeCollection statusColl = new RelationAttributeCollection( RelationAttributeCollection statusColl = new RelationAttributeCollection(
getStatusAttributeName()); getStatusAttributeName());
statusColl.addLanguageFilter(Kernel.getConfig().getDefaultLanguage()); statusColl.addLanguageFilter(Kernel.getConfig().getDefaultLanguage());

View File

@ -100,15 +100,18 @@ public class GenericPersonContactAddForm extends BasicItemForm {
contactType.setLabel(ContenttypesGlobalizationUtil.globalize( contactType.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericperson.contact.type")); "cms.contenttypes.ui.genericperson.contact.type"));
contactType.addValidationListener(new NotNullValidationListener()); contactType.addValidationListener(new NotNullValidationListener());
contactType.addOption(new Option("",
new Label(GlobalizationUtil.
globalize("cms.ui.select_one"))));
try { try {
contactType.addPrintListener(new PrintListener() { contactType.addPrintListener(new PrintListener() {
@Override @Override
public void prepare(final PrintEvent event) { public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget(); final SingleSelect target = (SingleSelect) event.getTarget();
target.clearOptions();
target.addOption(new Option("",
new Label(GlobalizationUtil.
globalize("cms.ui.select_one"))));
// Add the Options to the SingleSelect widget // Add the Options to the SingleSelect widget
final GenericContactTypeCollection contacttypes final GenericContactTypeCollection contacttypes
= new GenericContactTypeCollection(); = new GenericContactTypeCollection();

View File

@ -231,6 +231,7 @@ public abstract class CategoryForm extends Form
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
OptionGroup target = (OptionGroup) e.getTarget(); OptionGroup target = (OptionGroup) e.getTarget();
target.clearOptions();
PageState state = e.getPageState(); PageState state = e.getPageState();
Category root = getRootCategory(state); Category root = getRootCategory(state);
if (root == null) { if (root == null) {
@ -361,6 +362,7 @@ public abstract class CategoryForm extends Form
@Override @Override
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
OptionGroup o = (OptionGroup) e.getTarget(); OptionGroup o = (OptionGroup) e.getTarget();
o.clearOptions();
PageState state = e.getPageState(); PageState state = e.getPageState();
CategoryMap m = getAssignedCategories(state); CategoryMap m = getAssignedCategories(state);

View File

@ -345,6 +345,7 @@ public class SectionConfigurationPage extends CMSPage implements Resettable {
public void prepare(PrintEvent event) { public void prepare(PrintEvent event) {
PageState state = event.getPageState(); PageState state = event.getPageState();
SingleSelect target = (SingleSelect) event.getTarget(); SingleSelect target = (SingleSelect) event.getTarget();
target.clearOptions();
addLocales(state, target); addLocales(state, target);
} }
}); });

View File

@ -686,6 +686,7 @@ public class PageCreateDynamic extends FormSection
public void prepare(PrintEvent event) { public void prepare(PrintEvent event) {
SingleSelect t = (SingleSelect) event.getTarget(); SingleSelect t = (SingleSelect) event.getTarget();
t.clearOptions();
PageState s = event.getPageState(); PageState s = event.getPageState();
//get the current content section //get the current content section

View File

@ -28,6 +28,7 @@ public abstract class AbstractFolderPicker extends SingleSelect {
@Override @Override
public void prepare(PrintEvent ev) { public void prepare(PrintEvent ev) {
((SingleSelect) ev.getTarget()).clearOptions();
addOptions(ev.getPageState(), addOptions(ev.getPageState(),
(SingleSelect) ev.getTarget()); (SingleSelect) ev.getTarget());
} }

View File

@ -256,6 +256,7 @@ class ItemLifecycleSelectForm extends BaseForm {
ldc.addOrder("label"); ldc.addOrder("label");
final SingleSelect target = (SingleSelect) e.getTarget(); final SingleSelect target = (SingleSelect) e.getTarget();
target.clearOptions();
while (ldc.next()) { while (ldc.next()) {
final LifecycleDefinition ld = ldc.getLifecycleDefinition(); final LifecycleDefinition ld = ldc.getLifecycleDefinition();

View File

@ -105,6 +105,7 @@ public class TemplateCreate extends BasicItemForm {
PageState state = e.getPageState(); PageState state = e.getPageState();
SingleSelect target = (SingleSelect)e.getTarget(); SingleSelect target = (SingleSelect)e.getTarget();
target.clearOptions();
TemplateContextCollection contexts = TemplateContext.retrieveAll(); TemplateContextCollection contexts = TemplateContext.retrieveAll();
contexts.addOrder(TemplateContext.LABEL); contexts.addOrder(TemplateContext.LABEL);

View File

@ -126,6 +126,7 @@ public class AddContentItemElement extends ElementAddForm {
public void prepare(PrintEvent event) { public void prepare(PrintEvent event) {
SingleSelect t = (SingleSelect) event.getTarget(); SingleSelect t = (SingleSelect) event.getTarget();
t.clearOptions();
// Get the current content section // Get the current content section
ContentSection section = CMS.getContext().getContentSection(); ContentSection section = CMS.getContext().getContentSection();

View File

@ -154,6 +154,7 @@ public class AddType extends CMSForm
public void prepare(PrintEvent event) { public void prepare(PrintEvent event) {
SingleSelect t = (SingleSelect) event.getTarget(); SingleSelect t = (SingleSelect) event.getTarget();
t.clearOptions();
//get the current content section //get the current content section
ContentSection section = CMS.getContext().getContentSection(); ContentSection section = CMS.getContext().getContentSection();

View File

@ -447,6 +447,7 @@ public class CreateType extends CMSForm
public void prepare(PrintEvent event) { public void prepare(PrintEvent event) {
SingleSelect t = (SingleSelect) event.getTarget(); SingleSelect t = (SingleSelect) event.getTarget();
t.clearOptions();
// Get the current content section // Get the current content section
ContentSection section = CMS.getContext().getContentSection(); ContentSection section = CMS.getContext().getContentSection();
@ -474,6 +475,7 @@ public class CreateType extends CMSForm
public void prepare(PrintEvent event) { public void prepare(PrintEvent event) {
SingleSelect t = (SingleSelect) event.getTarget(); SingleSelect t = (SingleSelect) event.getTarget();
t.clearOptions();
// Get the current content section // Get the current content section
ContentSection section = CMS.getContext().getContentSection(); ContentSection section = CMS.getContext().getContentSection();
@ -496,6 +498,7 @@ public class CreateType extends CMSForm
public void prepare(PrintEvent event) { public void prepare(PrintEvent event) {
SingleSelect t = (SingleSelect) event.getTarget(); SingleSelect t = (SingleSelect) event.getTarget();
t.clearOptions();
// Get the current content section // Get the current content section
ContentSection section = CMS.getContext().getContentSection(); ContentSection section = CMS.getContext().getContentSection();

View File

@ -301,6 +301,7 @@ public class EditType extends CMSForm
public void prepare(PrintEvent event) { public void prepare(PrintEvent event) {
SingleSelect t = (SingleSelect) event.getTarget(); SingleSelect t = (SingleSelect) event.getTarget();
t.clearOptions();
// Get the current content section // Get the current content section
ContentSection section = CMS.getContext().getContentSection(); ContentSection section = CMS.getContext().getContentSection();
@ -325,6 +326,7 @@ public class EditType extends CMSForm
public void prepare(PrintEvent event) { public void prepare(PrintEvent event) {
SingleSelect t = (SingleSelect) event.getTarget(); SingleSelect t = (SingleSelect) event.getTarget();
t.clearOptions();
// Get the current content section // Get the current content section
ContentSection section = CMS.getContext().getContentSection(); ContentSection section = CMS.getContext().getContentSection();

View File

@ -154,6 +154,7 @@ public class SearchAndSelect extends FormSection
&& (m_results.resultsCount() > 0))) { && (m_results.resultsCount() > 0))) {
OptionGroup outputWidget = (OptionGroup) e.getTarget(); OptionGroup outputWidget = (OptionGroup) e.getTarget();
outputWidget.clearOptions();
if (m_isOptional && !m_isMultiple) { if (m_isOptional && !m_isMultiple) {
outputWidget.addOption(new Option("", "None")); outputWidget.addOption(new Option("", "None"));

View File

@ -40,6 +40,7 @@ public abstract class AbstractCategoryPicker extends SingleSelect
try { try {
addPrintListener(new PrintListener() { addPrintListener(new PrintListener() {
public void prepare(PrintEvent ev) { public void prepare(PrintEvent ev) {
((SingleSelect) ev.getTarget()).clearOptions();
addOptions(ev.getPageState(), addOptions(ev.getPageState(),
(SingleSelect)ev.getTarget()); (SingleSelect)ev.getTarget());
} }

View File

@ -79,6 +79,7 @@ public class DataDrivenSelectForm extends WidgetLabelForm {
try { try {
m_query.addPrintListener(new PrintListener() { m_query.addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
((Select) e.getTarget()).clearOptions();
loadComponents((Select)e.getTarget(), e.getPageState()); loadComponents((Select)e.getTarget(), e.getPageState());
} }
}); });

View File

@ -120,6 +120,7 @@ public class TemplateEmailForm extends ProcessListenerForm {
new OID( PersistentFormSection.BASE_DATA_OBJECT_TYPE, new OID( PersistentFormSection.BASE_DATA_OBJECT_TYPE,
formID ); formID );
m_controls.clearOptions();
m_controls.addOption(new Option("::user.email::", "Email address"), ps); m_controls.addOption(new Option("::user.email::", "Email address"), ps);
PersistentFormSection form = (PersistentFormSection) PersistentFormSection form = (PersistentFormSection)

View File

@ -317,6 +317,8 @@ public class PartySearchSelect
} }
protected void initPartyChoices(PageState ps) { protected void initPartyChoices(PageState ps) {
m_select.clearOptions();
PartyCollection parties = (PartyCollection) m_partyQuery.get(ps); PartyCollection parties = (PartyCollection) m_partyQuery.get(ps);
boolean isEmpty = true; boolean isEmpty = true;

View File

@ -113,6 +113,8 @@ public class ApplicationCreateForm<T extends Application> extends Form implement
@Override @Override
public void prepare(final PrintEvent event) { public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget(); final SingleSelect target = (SingleSelect) event.getTarget();
target.clearOptions();
target.addOption(new Option("", "")); target.addOption(new Option("", ""));
final ApplicationCollection applications = Application.retrieveAllApplications(); final ApplicationCollection applications = Application.retrieveAllApplications();

View File

@ -140,8 +140,7 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
public BigDecimalParameter getFileIDParam() { public BigDecimalParameter getFileIDParam() {
try { try {
return ((DocmgrBasePage) m_page).getFileIDParam(); return ((DocmgrBasePage) m_page).getFileIDParam();
} } catch (Throwable e) {
catch (Throwable e) {
} }
return null; return null;
} }
@ -152,7 +151,7 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
} }
private Component makePropertiesPane() { private Component makePropertiesPane() {
SimpleContainer container= new SimpleContainer(); SimpleContainer container = new SimpleContainer();
m_propertiesPane = new FilePropertiesPanel(this); m_propertiesPane = new FilePropertiesPanel(this);
container.add(m_propertiesPane); container.add(m_propertiesPane);
@ -228,7 +227,8 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
Element nameElement = element.newChildElement("docs:name", DOCS_XML_NS); Element nameElement = element.newChildElement("docs:name", DOCS_XML_NS);
nameElement.setText(URLDecoder.decode(doc.getName())); nameElement.setText(URLDecoder.decode(doc.getName()));
Element descriptionElement = element.newChildElement("docs:description", DOCS_XML_NS); Element descriptionElement = element.newChildElement("docs:description",
DOCS_XML_NS);
String description = doc.getDescription(); String description = doc.getDescription();
if (description != null) { if (description != null) {
descriptionElement.setText(description); descriptionElement.setText(description);
@ -241,8 +241,11 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
// Retrieve pretty name for a mime type. // Retrieve pretty name for a mime type.
typeElement.setText(doc.getPrettyMimeType()); typeElement.setText(doc.getPrettyMimeType());
Element lastModifiedElement = element.newChildElement("docs:last-modified", DOCS_XML_NS); Element lastModifiedElement = element.newChildElement("docs:last-modified",
lastModifiedElement.setText(null != doc.getLastModifiedDate() ? DMUtils.DateFormat.format(doc.getLastModifiedDate()) : ""); DOCS_XML_NS);
lastModifiedElement.setText(
null != doc.getLastModifiedDate() ? DMUtils.DateFormat.format(doc.
getLastModifiedDate()) : "");
Element revisionElement = element.newChildElement("docs:revision", DOCS_XML_NS); Element revisionElement = element.newChildElement("docs:revision", DOCS_XML_NS);
@ -251,7 +254,6 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
revisionElement.setText(numRevs + ""); revisionElement.setText(numRevs + "");
// Must allow for the possibility that not author is available. // Must allow for the possibility that not author is available.
Element authorElement = element.newChildElement("docs:author", DOCS_XML_NS); Element authorElement = element.newChildElement("docs:author", DOCS_XML_NS);
authorElement.setText(doc.getImpliedAuthor()); authorElement.setText(doc.getImpliedAuthor());
@ -270,12 +272,10 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
catElement.addAttribute("name", cat.getName()); catElement.addAttribute("name", cat.getName());
} }
} } catch (DataObjectNotFoundException exc) {
catch (DataObjectNotFoundException exc) {
Element notfoundElement = element.newChildElement("docs:notfound", DOCS_XML_NS); Element notfoundElement = element.newChildElement("docs:notfound", DOCS_XML_NS);
} }
} } else {
else {
Element notfoundElement = element.newChildElement("docs:notfound", DOCS_XML_NS); Element notfoundElement = element.newChildElement("docs:notfound", DOCS_XML_NS);
} }
} }
@ -290,7 +290,8 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
} }
} }
class FileEditForm extends Form implements FormValidationListener, FormProcessListener, FormInitListener { class FileEditForm extends Form implements FormValidationListener, FormProcessListener,
FormInitListener {
private final static String FILE_EDIT = "file-edit"; private final static String FILE_EDIT = "file-edit";
private final static String FILE_EDIT_CATS = "file-edit-cats"; private final static String FILE_EDIT_CATS = "file-edit-cats";
@ -337,8 +338,7 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
SingleSelect audienceEntry = new SingleSelect(m_FileAudience); SingleSelect audienceEntry = new SingleSelect(m_FileAudience);
try { try {
audienceEntry.addPrintListener(new IntendedAudienceSelectPrinter()); audienceEntry.addPrintListener(new IntendedAudienceSelectPrinter());
} } catch (TooManyListenersException tmlex) {
catch (TooManyListenersException tmlex) {
s_log.error(tmlex.getMessage()); s_log.error(tmlex.getMessage());
tmlex.printStackTrace(); tmlex.printStackTrace();
} }
@ -355,9 +355,9 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
try { try {
BigDecimalParameter fileIDParam = null; BigDecimalParameter fileIDParam = null;
fileIDParam = getFileIDParam(); fileIDParam = getFileIDParam();
catSelect.addPrintListener(new CategoriesPrintListener(getContentSection(), fileIDParam)); catSelect.addPrintListener(new CategoriesPrintListener(getContentSection(),
} fileIDParam));
catch (java.util.TooManyListenersException tmex) { } catch (java.util.TooManyListenersException tmex) {
throw new UncheckedWrapperException(tmex.getMessage()); throw new UncheckedWrapperException(tmex.getMessage());
} }
add(catSelect); add(catSelect);
@ -402,7 +402,7 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
cat = cats.getCategory(); cat = cats.getCategory();
String catID = cat.getID().toString(); String catID = cat.getID().toString();
assignedCats.add(catID); assignedCats.add(catID);
s_log.debug("init: "+catID); s_log.debug("init: " + catID);
} }
data.put(FILE_EDIT_FNAME, URLDecoder.decode(doc.getName())); data.put(FILE_EDIT_FNAME, URLDecoder.decode(doc.getName()));
@ -465,7 +465,6 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
/** /**
* Test if the new name already exists in the current folder * Test if the new name already exists in the current folder
*/ */
public void validate(FormSectionEvent event) throws FormProcessException { public void validate(FormSectionEvent event) throws FormProcessException {
PageState state = event.getPageState(); PageState state = event.getPageState();
if (m_submit.isSelected(state)) { if (m_submit.isSelected(state)) {
@ -485,9 +484,9 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
String title = (String) data.get(FILE_EDIT_TITLE); String title = (String) data.get(FILE_EDIT_TITLE);
if (title == null || title.length() == 0) { if (title == null || title.length() == 0) {
data.addError(FILE_EDIT_TITLE, "This parameter is required."); data.addError(FILE_EDIT_TITLE, "This parameter is required.");
} } else if (title.length() > 200) {
else if (title.length() > 200) { data.addError(FILE_EDIT_TITLE,
data.addError(FILE_EDIT_TITLE, "This title is too long. It must be fewer than 200 characters."); "This title is too long. It must be fewer than 200 characters.");
} }
} }
@ -495,7 +494,8 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
* Initialize form data for document's intended audience. * Initialize form data for document's intended audience.
*/ */
private void initAudienceFormData(FormData data, Document doc) { private void initAudienceFormData(FormData data, Document doc) {
ObjectPermissionCollection opc = PermissionService.getDirectGrantedPermissions(doc.getOID()); ObjectPermissionCollection opc = PermissionService.getDirectGrantedPermissions(doc.
getOID());
long numPermissions = opc.size(); long numPermissions = opc.size();
if (numPermissions > 1) { if (numPermissions > 1) {
s_log.error("there should only be 1 direct permission for " + "a document"); s_log.error("there should only be 1 direct permission for " + "a document");
@ -514,8 +514,7 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
opc.close(); opc.close();
if (isPublic) { if (isPublic) {
data.put(FILE_EDIT_AUDIENCE, "public"); data.put(FILE_EDIT_AUDIENCE, "public");
} } else {
else {
data.put(FILE_EDIT_AUDIENCE, "internal"); data.put(FILE_EDIT_AUDIENCE, "internal");
} }
} }
@ -529,9 +528,11 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
if (intendedAudience == null) { if (intendedAudience == null) {
throw new FormProcessException("Intended Audience cannot be null"); throw new FormProcessException("Intended Audience cannot be null");
} }
final PermissionDescriptor publicDescriptor = new PermissionDescriptor(PrivilegeDescriptor.READ, doc.getOID(), new OID( final PermissionDescriptor publicDescriptor = new PermissionDescriptor(
PrivilegeDescriptor.READ, doc.getOID(), new OID(
User.BASE_DATA_OBJECT_TYPE, PermissionManager.VIRTUAL_PUBLIC_ID)); User.BASE_DATA_OBJECT_TYPE, PermissionManager.VIRTUAL_PUBLIC_ID));
final PermissionDescriptor internalDescriptor = new PermissionDescriptor(PrivilegeDescriptor.READ, doc.getOID(), new OID( final PermissionDescriptor internalDescriptor = new PermissionDescriptor(
PrivilegeDescriptor.READ, doc.getOID(), new OID(
Group.BASE_DATA_OBJECT_TYPE, DocMgr.getConfig().getInternalGroupID())); Group.BASE_DATA_OBJECT_TYPE, DocMgr.getConfig().getInternalGroupID()));
new KernelExcursion() { new KernelExcursion() {
protected void excurse() { protected void excurse() {
@ -541,12 +542,10 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
if ("public".equals(intendedAudience)) { if ("public".equals(intendedAudience)) {
PermissionService.grantPermission(publicDescriptor); PermissionService.grantPermission(publicDescriptor);
PermissionService.revokePermission(internalDescriptor); PermissionService.revokePermission(internalDescriptor);
} } else if ("internal".equals(intendedAudience)) {
else if ("internal".equals(intendedAudience)) {
PermissionService.revokePermission(publicDescriptor); PermissionService.revokePermission(publicDescriptor);
PermissionService.grantPermission(internalDescriptor); PermissionService.grantPermission(internalDescriptor);
} } else {
else {
// workspace only // workspace only
PermissionService.revokePermission(publicDescriptor); PermissionService.revokePermission(publicDescriptor);
PermissionService.revokePermission(internalDescriptor); PermissionService.revokePermission(internalDescriptor);
@ -556,6 +555,7 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
} }
protected class AuthorLabelPrinter implements PrintListener { protected class AuthorLabelPrinter implements PrintListener {
public AuthorLabelPrinter() { public AuthorLabelPrinter() {
// Empty // Empty
} }
@ -571,13 +571,19 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
} }
protected class IntendedAudienceSelectPrinter implements PrintListener { protected class IntendedAudienceSelectPrinter implements PrintListener {
public IntendedAudienceSelectPrinter() { public IntendedAudienceSelectPrinter() {
} }
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
SingleSelect select = (SingleSelect) e.getTarget(); SingleSelect select = (SingleSelect) e.getTarget();
select.clearOptions();
select.addOption(new Option("workspace", Web.getWebContext().getApplication().getParentApplication()== null? Web.getWebContext().getApplication().getDisplayName():Web.getWebContext().getApplication().getParentApplication().getDisplayName() + " members")); select.addOption(new Option("workspace", Web.getWebContext().getApplication().
getParentApplication() == null ? Web.getWebContext().
getApplication().getDisplayName() : Web.getWebContext().
getApplication().getParentApplication().getDisplayName()
+ " members"));
select.addOption(new Option("internal", new Label(FILE_INTENDED_AUDIENCE_INTERNAL))); select.addOption(new Option("internal", new Label(FILE_INTENDED_AUDIENCE_INTERNAL)));
select.addOption(new Option("public", new Label(FILE_INTENDED_AUDIENCE_PUBLIC))); select.addOption(new Option("public", new Label(FILE_INTENDED_AUDIENCE_PUBLIC)));
} }
@ -596,7 +602,8 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
} }
} }
class VersionUploadForm extends Form implements FormInitListener, FormProcessListener, FormValidationListener { class VersionUploadForm extends Form implements FormInitListener, FormProcessListener,
FormValidationListener {
private static final String VERSION_UPLOAD_FORM = "file-version"; private static final String VERSION_UPLOAD_FORM = "file-version";
private static final String VERSION_TRANSACTION_DESCRIPTION = "file-transaction-description"; private static final String VERSION_TRANSACTION_DESCRIPTION = "file-transaction-description";
@ -683,8 +690,8 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
} }
/** /**
* Receive uploaded file and reset file content, mime type, and * Receive uploaded file and reset file content, mime type, and description. Return to File
* description. Return to File properties screen. * properties screen.
*/ */
public void process(FormSectionEvent e) throws FormProcessException { public void process(FormSectionEvent e) throws FormProcessException {
@ -706,12 +713,10 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
} }
// Try to update the file in the database // Try to update the file in the database
FileAsset fa = doc.getFile(); FileAsset fa = doc.getFile();
fa.loadFromFile(fname, src, "txt"); fa.loadFromFile(fname, src, "txt");
} } catch (java.io.IOException ex) {
catch (java.io.IOException ex) {
ex.printStackTrace(); ex.printStackTrace();
throw new FormProcessException(ex.getMessage()); throw new FormProcessException(ex.getMessage());
} }
@ -719,8 +724,9 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
// Annotate transaction description // Annotate transaction description
String vdesc = (String) data.get(VERSION_TRANSACTION_DESCRIPTION); String vdesc = (String) data.get(VERSION_TRANSACTION_DESCRIPTION);
//If version description string is over 4K in size, truncate... //If version description string is over 4K in size, truncate...
if (vdesc.length() > FOUR_K_CHAR_LIMIT) if (vdesc.length() > FOUR_K_CHAR_LIMIT) {
vdesc = vdesc.substring(0, FOUR_K_CHAR_LIMIT); vdesc = vdesc.substring(0, FOUR_K_CHAR_LIMIT);
}
Versions.tag(doc.getOID(), vdesc); Versions.tag(doc.getOID(), vdesc);
doc.setLastModifiedLocal(doc.getLastModifiedDate()); doc.setLastModifiedLocal(doc.getLastModifiedDate());
doc.save(); doc.save();
@ -730,9 +736,8 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
} }
/** /**
* Validate the length of name of the new file being uploaded. Validate * Validate the length of name of the new file being uploaded. Validate if user tries to
* if user tries to upload a file with a different Mime type than the * upload a file with a different Mime type than the original. This is not supported.
* original. This is not supported.
* *
*/ */
public void validate(FormSectionEvent e) throws FormProcessException { public void validate(FormSectionEvent e) throws FormProcessException {
@ -751,13 +756,13 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
int nameLength = 500; int nameLength = 500;
try { try {
nameLength = fname.getBytes("UTF-8").length; nameLength = fname.getBytes("UTF-8").length;
} } catch (UnsupportedEncodingException uee) {
catch (UnsupportedEncodingException uee) {
throw new RuntimeException("No UTF-8 support: " + uee); throw new RuntimeException("No UTF-8 support: " + uee);
} }
// XXX Not localized as the other errors are. // XXX Not localized as the other errors are.
if (nameLength > 200) { if (nameLength > 200) {
data.addError(VERSION_FILE_UPLOAD, "This filename is too long. It must be fewer than 200 characters."); data.addError(VERSION_FILE_UPLOAD,
"This filename is too long. It must be fewer than 200 characters.");
} }
String desc = (String) data.get(VERSION_TRANSACTION_DESCRIPTION); String desc = (String) data.get(VERSION_TRANSACTION_DESCRIPTION);
@ -811,7 +816,8 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
BoxPanel panel = new BoxPanel(); BoxPanel panel = new BoxPanel();
panel.add(FILE_SEND_COLLEAGUE_THANKS); panel.add(FILE_SEND_COLLEAGUE_THANKS);
ActionLink backLink = new ActionLink(FILE_SEND_COLLEAGUE_THANKS_RETURN_LINK.localize().toString()); ActionLink backLink = new ActionLink(FILE_SEND_COLLEAGUE_THANKS_RETURN_LINK.localize().
toString());
backLink.addActionListener(new ActionListener() { backLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PageState state = e.getPageState(); PageState state = e.getPageState();
@ -833,11 +839,12 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
private static final String EMAIL_PARAM_NAME = "scEmail"; private static final String EMAIL_PARAM_NAME = "scEmail";
private final TrimmedStringParameter m_emailParam = new TrimmedStringParameter(EMAIL_PARAM_NAME); private final TrimmedStringParameter m_emailParam = new TrimmedStringParameter(
EMAIL_PARAM_NAME);
private FileSendColleaguePane m_parent; private FileSendColleaguePane m_parent;
public SendForm(FileSendColleaguePane parent) { public SendForm(FileSendColleaguePane parent) {
super("sendEmail",new BoxPanel()); super("sendEmail", new BoxPanel());
m_parent = parent; m_parent = parent;
@ -866,8 +873,11 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
s_log.debug(FILE_SEND_COLLEAGUE_RETURN_ADDRESS.localize().toString()); s_log.debug(FILE_SEND_COLLEAGUE_RETURN_ADDRESS.localize().toString());
Mail mail = new Mail((String) data.get(EMAIL_PARAM_NAME), FILE_SEND_COLLEAGUE_RETURN_ADDRESS.localize().toString(), Mail mail = new Mail((String) data.get(EMAIL_PARAM_NAME),
FILE_SEND_COLLEAGUE_SUBJECT.localize().toString(), FILE_SEND_COLLEAGUE_MESSAGE.localize().toString() + " " + u.getName()); FILE_SEND_COLLEAGUE_RETURN_ADDRESS.localize().toString(),
FILE_SEND_COLLEAGUE_SUBJECT.localize().toString(),
FILE_SEND_COLLEAGUE_MESSAGE.localize().toString() + " " + u.
getName());
Document doc = new Document((BigDecimal) state.getValue(docIDParam)); Document doc = new Document((BigDecimal) state.getValue(docIDParam));
try { try {
FileAsset fa = doc.getFile(); FileAsset fa = doc.getFile();
@ -889,13 +899,11 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
s_log.debug("mimeTypeString: " + mimeTypeString); s_log.debug("mimeTypeString: " + mimeTypeString);
mail.attach(assetStream.toByteArray(), mimeTypeString, doc.getTitle()); mail.attach(assetStream.toByteArray(), mimeTypeString, doc.getTitle());
mail.send(); mail.send();
} } catch (java.io.IOException iox) {
catch (java.io.IOException iox) {
s_log.error("SendForm.process", iox); s_log.error("SendForm.process", iox);
// iox.printStackTrace(); // iox.printStackTrace();
throw new FormProcessException("An error occurred while trying to send document"); throw new FormProcessException("An error occurred while trying to send document");
} } catch (javax.mail.MessagingException mex) {
catch (javax.mail.MessagingException mex) {
s_log.error("SendForm.process", mex); s_log.error("SendForm.process", mex);
//mex.printStackTrace(); //mex.printStackTrace();
throw new FormProcessException("An error occurred while trying to send document"); throw new FormProcessException("An error occurred while trying to send document");
@ -996,11 +1004,13 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
User user = Web.getWebContext().getUser(); User user = Web.getWebContext().getUser();
Application app = Web.getWebContext().getApplication(); Application app = Web.getWebContext().getApplication();
// Document doc = new Document((BigDecimal) state.getValue(docIDParam)); // Document doc = new Document((BigDecimal) state.getValue(docIDParam));
if (PermissionService.checkPermission(new PermissionDescriptor(PrivilegeDescriptor.ADMIN, app, user))) { if (PermissionService.checkPermission(
new PermissionDescriptor(PrivilegeDescriptor.ADMIN, app, user))) {
return; return;
} }
if (!PermissionService.checkPermission(new PermissionDescriptor(PrivilegeDescriptor.EDIT, app, user))) { if (!PermissionService.checkPermission(
new PermissionDescriptor(PrivilegeDescriptor.EDIT, app, user))) {
m_editLink.setVisible(state, false); m_editLink.setVisible(state, false);
m_delete.setVisible(state, false); m_delete.setVisible(state, false);
m_newVersion.setVisible(state, false); m_newVersion.setVisible(state, false);
@ -1023,10 +1033,11 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
try { try {
String appURI = getRedirectURI(state); String appURI = getRedirectURI(state);
DispatcherHelper.sendRedirect(state.getRequest(), state.getResponse(), appURI + "?" + SEL_FOLDER_ID_PARAM.getName() + "=" DispatcherHelper.sendRedirect(state.getRequest(), state.getResponse(), appURI + "?"
+ SEL_FOLDER_ID_PARAM.
getName() + "="
+ parentFolderID); + parentFolderID);
} } catch (IOException iox) {
catch (IOException iox) {
throw new UncheckedWrapperException(iox); throw new UncheckedWrapperException(iox);
} }
} }

View File

@ -12,7 +12,6 @@
* rights and limitations under the License. * rights and limitations under the License.
* *
*/ */
package com.arsdigita.cms.docmgr.ui; package com.arsdigita.cms.docmgr.ui;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -65,10 +64,11 @@ public class CategoriesPrintListener implements PrintListener {
} }
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
OptionGroup o = (OptionGroup)e.getTarget(); OptionGroup o = (OptionGroup) e.getTarget();
o.clearOptions();
PageState state = e.getPageState(); PageState state = e.getPageState();
Category root = Category root
m_docsContentSection.getRootCategory(); = m_docsContentSection.getRootCategory();
// Breadth-first traversal of the teee // Breadth-first traversal of the teee
CategoryTreeModelLite model = new CategoryTreeModelLite(root); CategoryTreeModelLite model = new CategoryTreeModelLite(root);
@ -100,12 +100,12 @@ public class CategoriesPrintListener implements PrintListener {
} }
boolean firstLoop = true; boolean firstLoop = true;
while(!queue.isEmpty()) { while (!queue.isEmpty()) {
DataQueryTreeNode node = (DataQueryTreeNode)queue.removeFirst(); DataQueryTreeNode node = (DataQueryTreeNode) queue.removeFirst();
String name = (String)nameQueue.removeFirst(); String name = (String) nameQueue.removeFirst();
// Process the node // Process the node
String id = (String)node.getKey(); String id = (String) node.getKey();
if (firstLoop && m_showRoot) { if (firstLoop && m_showRoot) {
// can't assign to root category // can't assign to root category
@ -116,11 +116,11 @@ public class CategoriesPrintListener implements PrintListener {
if (model.hasChildren(node, state)) { if (model.hasChildren(node, state)) {
// Append children // Append children
for(Iterator i = model.getChildren(node, state); i.hasNext(); ) { for (Iterator i = model.getChildren(node, state); i.hasNext();) {
TreeNode n = (TreeNode)i.next(); TreeNode n = (TreeNode) i.next();
queue.addLast(n); queue.addLast(n);
StringBuffer nameBuf = new StringBuffer(name); StringBuffer nameBuf = new StringBuffer(name);
if(name.length() > 0) { if (name.length() > 0) {
nameBuf.append(SEPARATOR); nameBuf.append(SEPARATOR);
} }
nameBuf.append(n.getElement()); nameBuf.append(n.getElement());

View File

@ -12,7 +12,6 @@
* rights and limitations under the License. * rights and limitations under the License.
* *
*/ */
package com.arsdigita.cms.docmgr.ui; package com.arsdigita.cms.docmgr.ui;
import com.arsdigita.bebop.ColumnPanel; import com.arsdigita.bebop.ColumnPanel;
@ -80,9 +79,8 @@ import java.util.Iterator;
import java.util.TooManyListenersException; import java.util.TooManyListenersException;
/** /**
* This component allows to change the file name and the * This component allows to change the file name and the description of a file. It also serves to
* description of a file. It also serves to associate * associate keywords to a file (knowledge object).
* keywords to a file (knowledge object).
* *
* @author Stefan Deusch * @author Stefan Deusch
* @author Crag Wolfe * @author Crag Wolfe
@ -91,10 +89,11 @@ class FileEditForm extends Form
implements FormValidationListener, implements FormValidationListener,
FormProcessListener, FormProcessListener,
FormInitListener, FormInitListener,
DMConstants DMConstants {
{
private final static org.apache.log4j.Logger s_log = private final static org.apache.log4j.Logger s_log
org.apache.log4j.Logger.getLogger(FileEditForm.class); = org.apache.log4j.Logger.getLogger(
FileEditForm.class);
private final static String FILE_EDIT = "file-edit"; private final static String FILE_EDIT = "file-edit";
private final static String FILE_EDIT_CATS = "file-edit-cats"; private final static String FILE_EDIT_CATS = "file-edit-cats";
@ -127,8 +126,9 @@ class FileEditForm extends Form
private Submit m_submit; private Submit m_submit;
public FileEditForm(Component parent) { public FileEditForm(Component parent) {
this(parent,false, null); this(parent, false, null);
} }
/** /**
* Constructor * Constructor
*/ */
@ -153,8 +153,7 @@ class FileEditForm extends Form
add(new Label(FILE_UPLOAD_ADD_FILE)); add(new Label(FILE_UPLOAD_ADD_FILE));
m_fileUpload = new FileUpload(FILE_UPLOAD); m_fileUpload = new FileUpload(FILE_UPLOAD);
add(m_fileUpload); add(m_fileUpload);
} } else {
else {
add(new Label(FILE_NAME_REQUIRED)); add(new Label(FILE_NAME_REQUIRED));
m_FileName = new StringParameter(FILE_EDIT_FNAME); m_FileName = new StringParameter(FILE_EDIT_FNAME);
TextField fnameEntry = new TextField(m_FileName); TextField fnameEntry = new TextField(m_FileName);
@ -166,7 +165,6 @@ class FileEditForm extends Form
TextField fTitleEntry = new TextField(m_FileTitle); TextField fTitleEntry = new TextField(m_FileTitle);
add(fTitleEntry); add(fTitleEntry);
add(new Label(FILE_INTENDED_AUDIENCE)); add(new Label(FILE_INTENDED_AUDIENCE));
SingleSelect audienceEntry = new SingleSelect(m_FileAudience); SingleSelect audienceEntry = new SingleSelect(m_FileAudience);
try { try {
@ -190,9 +188,7 @@ class FileEditForm extends Form
if (!m_creation) { if (!m_creation) {
fileIDParam = getFileIDParam(); fileIDParam = getFileIDParam();
} }
catSelect.addPrintListener catSelect.addPrintListener(new CategoriesPrintListener(getContentSection(),
(new CategoriesPrintListener
(getContentSection(),
fileIDParam)); fileIDParam));
} catch (java.util.TooManyListenersException tmex) { } catch (java.util.TooManyListenersException tmex) {
throw new UncheckedWrapperException(tmex.getMessage()); throw new UncheckedWrapperException(tmex.getMessage());
@ -228,11 +224,11 @@ class FileEditForm extends Form
if (m_creation) { if (m_creation) {
initCreate(e); initCreate(e);
} } else {
else {
initEdit(e); initEdit(e);
} }
} }
public void initEdit(FormSectionEvent e) public void initEdit(FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
@ -251,7 +247,7 @@ class FileEditForm extends Form
cat = cats.getCategory(); cat = cats.getCategory();
String catID = cat.getID().toString(); String catID = cat.getID().toString();
assignedCats.add(catID); assignedCats.add(catID);
s_log.debug("init: "+catID); s_log.debug("init: " + catID);
} }
data.put(FILE_EDIT_FNAME, URLDecoder.decode(doc.getName())); data.put(FILE_EDIT_FNAME, URLDecoder.decode(doc.getName()));
@ -301,12 +297,12 @@ class FileEditForm extends Form
Document doc = DMUtils.getFile(getSelectedDocID(state)); Document doc = DMUtils.getFile(getSelectedDocID(state));
setDocumentAttributes(data,doc); setDocumentAttributes(data, doc);
doc.setCategories((String[]) data.get(FILE_EDIT_CATS)); doc.setCategories((String[]) data.get(FILE_EDIT_CATS));
doc.setLastModifiedLocal(new java.util.Date()); doc.setLastModifiedLocal(new java.util.Date());
doc.save(); // creates a new revision doc.save(); // creates a new revision
setDocumentPermission(data,doc); setDocumentPermission(data, doc);
return doc; return doc;
} }
@ -326,8 +322,7 @@ class FileEditForm extends Form
int index; int index;
if (mime != null && (index = fname.lastIndexOf('.')) > -1) { if (mime != null && (index = fname.lastIndexOf('.')) > -1) {
titleTmp = fname.substring(0, index); titleTmp = fname.substring(0, index);
} } else {
else {
titleTmp = fname; titleTmp = fname;
} }
} }
@ -340,8 +335,8 @@ class FileEditForm extends Form
HttpServletRequest mreq = e.getPageState().getRequest(); HttpServletRequest mreq = e.getPageState().getRequest();
Assert.isTrue(mreq instanceof MultipartHttpServletRequest, Assert.isTrue(mreq instanceof MultipartHttpServletRequest,
"I got a " + mreq + " when I was " + "I got a " + mreq + " when I was "
"expecting a MultipartHttpServletRequest"); + "expecting a MultipartHttpServletRequest");
src = ((MultipartHttpServletRequest) mreq).getFile(FILE_UPLOAD); src = ((MultipartHttpServletRequest) mreq).getFile(FILE_UPLOAD);
} }
@ -359,15 +354,13 @@ class FileEditForm extends Form
BigDecimal folderID = new BigDecimal(selKey); BigDecimal folderID = new BigDecimal(selKey);
try { try {
p = new DocFolder(folderID); p = new DocFolder(folderID);
} catch(DataObjectNotFoundException nf) { } catch (DataObjectNotFoundException nf) {
throw new ObjectNotFoundException throw new ObjectNotFoundException((String) FOLDER_PARENTNOTFOUND_ERROR.localize(req));
((String) FOLDER_PARENTNOTFOUND_ERROR.localize(req));
} }
} }
final DocFolder parent = p; final DocFolder parent = p;
// insert the file in the data base below parent // insert the file in the data base below parent
final Document f1 = new Document(); final Document f1 = new Document();
// FR: define the bundle here // FR: define the bundle here
@ -394,25 +387,26 @@ class FileEditForm extends Form
bundle.setName(fname); bundle.setName(fname);
bundle.setParent(parent); bundle.setParent(parent);
bundle.setContentSection(parent.getContentSection()); bundle.setContentSection(parent.getContentSection());
PermissionService.setContext(bundle,parent); PermissionService.setContext(bundle, parent);
PermissionService.setContext(f1,bundle); PermissionService.setContext(f1, bundle);
PermissionService.setContext(fa,f1); PermissionService.setContext(fa, f1);
bundle.save(); bundle.save();
f1.save(); f1.save();
}}.run(); }
}.run();
try { try {
fa.loadFromFile(fname,src,"txt"); fa.loadFromFile(fname, src, "txt");
} catch (java.io.IOException ex) { } catch (java.io.IOException ex) {
ex.printStackTrace(); ex.printStackTrace();
throw new FormProcessException(ex.getMessage()); throw new FormProcessException(ex.getMessage());
} }
Versions.tag(f1.getOID(),(FILE_UPLOAD_INITIAL_TRANSACTION_DESCRIPTION Versions.tag(f1.getOID(), (FILE_UPLOAD_INITIAL_TRANSACTION_DESCRIPTION
.localize(req) .localize(req)
.toString())); .toString()));
setDocumentAttributes(data,f1); setDocumentAttributes(data, f1);
// title must be set before name // title must be set before name
f1.setTitle(title); f1.setTitle(title);
f1.setName(URLEncoder.encode(fname)); f1.setName(URLEncoder.encode(fname));
@ -422,7 +416,7 @@ class FileEditForm extends Form
//f1.save(); //f1.save();
// context has been set, now add additional permissions // context has been set, now add additional permissions
setDocumentPermission(data,f1); setDocumentPermission(data, f1);
f1.setCategories((String[]) data.get(FILE_EDIT_CATS)); f1.setCategories((String[]) data.get(FILE_EDIT_CATS));
bundle.save(); bundle.save();
@ -433,7 +427,6 @@ class FileEditForm extends Form
private void setDocumentAttributes(FormData data, private void setDocumentAttributes(FormData data,
Document doc) { Document doc) {
if (!m_creation) { if (!m_creation) {
String ftitle = (String) data.get(FILE_EDIT_TITLE); String ftitle = (String) data.get(FILE_EDIT_TITLE);
String fname = (String) data.get(FILE_EDIT_FNAME); String fname = (String) data.get(FILE_EDIT_FNAME);
@ -460,7 +453,6 @@ class FileEditForm extends Form
/** /**
* Test if the new name already exists in the current folder * Test if the new name already exists in the current folder
*/ */
public void validate(FormSectionEvent event) public void validate(FormSectionEvent event)
throws FormProcessException { throws FormProcessException {
@ -469,12 +461,14 @@ class FileEditForm extends Form
//validate length of author //validate length of author
String author = (String) data.get(FILE_EDIT_AUTHOR); String author = (String) data.get(FILE_EDIT_AUTHOR);
if (author != null && author.length() > 200) { if (author != null && author.length() > 200) {
data.addError(FILE_EDIT_AUTHOR, "This parameter is too long. It must be fewer than 200 characters."); data.addError(FILE_EDIT_AUTHOR,
"This parameter is too long. It must be fewer than 200 characters.");
} }
//validate length of description //validate length of description
String desc = (String) data.get(FILE_EDIT_DESCRIPTION); String desc = (String) data.get(FILE_EDIT_DESCRIPTION);
if (desc != null && desc.length() > 4000) { if (desc != null && desc.length() > 4000) {
data.addError(FILE_EDIT_DESCRIPTION, "This parameter is too long. It must be fewer than 4000 characters."); data.addError(FILE_EDIT_DESCRIPTION,
"This parameter is too long. It must be fewer than 4000 characters.");
} }
if (m_creation) { if (m_creation) {
@ -500,8 +494,7 @@ class FileEditForm extends Form
// XXX Not localized as the other errors are. // XXX Not localized as the other errors are.
if (fname.length() > 200) { if (fname.length() > 200) {
data.addError data.addError(FILE_UPLOAD,
(FILE_UPLOAD,
"This filename is too long. It must be fewer than 200 characters."); "This filename is too long. It must be fewer than 200 characters.");
} }
@ -520,7 +513,7 @@ class FileEditForm extends Form
BigDecimal folderID = new BigDecimal(selKey); BigDecimal folderID = new BigDecimal(selKey);
try { try {
parent = new DocFolder(folderID); parent = new DocFolder(folderID);
} catch(DataObjectNotFoundException nf) { } catch (DataObjectNotFoundException nf) {
throw new ObjectNotFoundException(FOLDER_PARENTNOTFOUND_ERROR throw new ObjectNotFoundException(FOLDER_PARENTNOTFOUND_ERROR
.localize(req).toString()); .localize(req).toString());
} }
@ -534,7 +527,7 @@ class FileEditForm extends Form
data.addError(FILE_UPLOAD, data.addError(FILE_UPLOAD,
RESOURCE_EXISTS_ERROR RESOURCE_EXISTS_ERROR
.localize(req).toString()); .localize(req).toString());
} catch(DataObjectNotFoundException nf) { } catch (DataObjectNotFoundException nf) {
// ok here // ok here
}// catch(InvalidNameException ex) { }// catch(InvalidNameException ex) {
} }
@ -552,28 +545,21 @@ class FileEditForm extends Form
String title = (String) data.get(FILE_EDIT_TITLE); String title = (String) data.get(FILE_EDIT_TITLE);
if (title == null || title.length() == 0) { if (title == null || title.length() == 0) {
data.addError(FILE_EDIT_TITLE, "This parameter is required."); data.addError(FILE_EDIT_TITLE, "This parameter is required.");
} } else if (title.length() > 200) {
else if (title.length() > 200) {
data.addError(FILE_EDIT_TITLE, data.addError(FILE_EDIT_TITLE,
"This title is too long. It must be fewer than 200 characters."); "This title is too long. It must be fewer than 200 characters.");
} }
// HttpServletRequest req = state.getRequest(); // HttpServletRequest req = state.getRequest();
// Document doc = DMUtils.getFile(getSelectedDocID(state)); // Document doc = DMUtils.getFile(getSelectedDocID(state));
// // Construct a name with the optional extension // // Construct a name with the optional extension
// String name = doc.getName(); // String name = doc.getName();
// if (!doc.isValidNewName(name)) { // if (!doc.isValidNewName(name)) {
// data.addError(FILE_EDIT_FNAME, // data.addError(FILE_EDIT_FNAME,
// "Not a valid new name for this file"); // "Not a valid new name for this file");
// } // }
// Verify that the new name does not correspond to an existing // Verify that the new name does not correspond to an existing
// resource (file or folder) // resource (file or folder)
// XXX we need this, but leaving it broken for now... --hbrock // XXX we need this, but leaving it broken for now... --hbrock
/* /*
@ -598,22 +584,20 @@ class FileEditForm extends Form
*/ */
private void initAudienceFormData(FormData data, private void initAudienceFormData(FormData data,
Document doc) { Document doc) {
ObjectPermissionCollection opc = ObjectPermissionCollection opc
PermissionService.getDirectGrantedPermissions(doc.getOID()); = PermissionService.getDirectGrantedPermissions(doc.getOID());
long numPermissions = opc.size(); long numPermissions = opc.size();
if (numPermissions > 1) { if (numPermissions > 1) {
s_log.error("there should only be 1 direct permission for "+ s_log.error("there should only be 1 direct permission for " + "a document");
"a document");
} }
if (numPermissions == 0) { if (numPermissions == 0) {
data.put(FILE_EDIT_AUDIENCE,"workspace"); data.put(FILE_EDIT_AUDIENCE, "workspace");
opc.close(); opc.close();
return; return;
} }
boolean isPublic = false; boolean isPublic = false;
while (opc.next()) { while (opc.next()) {
if (opc.getGranteeID().intValue() == if (opc.getGranteeID().intValue() == PermissionManager.VIRTUAL_PUBLIC_ID) {
PermissionManager.VIRTUAL_PUBLIC_ID) {
isPublic = true; isPublic = true;
} }
} }
@ -633,31 +617,28 @@ class FileEditForm extends Form
throws FormProcessException { throws FormProcessException {
final String intendedAudience = (String) data.get(FILE_EDIT_AUDIENCE); final String intendedAudience = (String) data.get(FILE_EDIT_AUDIENCE);
if (intendedAudience == null) { if (intendedAudience == null) {
throw new FormProcessException throw new FormProcessException("Intended Audience cannot be null");
("Intended Audience cannot be null");
} }
final PermissionDescriptor publicDescriptor = final PermissionDescriptor publicDescriptor
new PermissionDescriptor = new PermissionDescriptor(PrivilegeDescriptor.READ,
(PrivilegeDescriptor.READ,
doc.getOID(), doc.getOID(),
new OID(User.BASE_DATA_OBJECT_TYPE, new OID(User.BASE_DATA_OBJECT_TYPE,
PermissionManager.VIRTUAL_PUBLIC_ID)); PermissionManager.VIRTUAL_PUBLIC_ID));
final PermissionDescriptor internalDescriptor = final PermissionDescriptor internalDescriptor
new PermissionDescriptor = new PermissionDescriptor(PrivilegeDescriptor.READ,
(PrivilegeDescriptor.READ,
doc.getOID(), doc.getOID(),
new OID(Group.BASE_DATA_OBJECT_TYPE, new OID(Group.BASE_DATA_OBJECT_TYPE,
DocMgr.getConfig().getInternalGroupID())); DocMgr.getConfig().
getInternalGroupID()));
new KernelExcursion() { new KernelExcursion() {
protected void excurse() { protected void excurse() {
//Party currentParty = Kernel.getWebContext().getParty(); //Party currentParty = Kernel.getWebContext().getParty();
setParty(Kernel.getSystemParty()); setParty(Kernel.getSystemParty());
if("public".equals(intendedAudience)) { if ("public".equals(intendedAudience)) {
PermissionService.grantPermission(publicDescriptor); PermissionService.grantPermission(publicDescriptor);
PermissionService.revokePermission(internalDescriptor); PermissionService.revokePermission(internalDescriptor);
} else if("internal".equals(intendedAudience)) { } else if ("internal".equals(intendedAudience)) {
PermissionService.revokePermission(publicDescriptor); PermissionService.revokePermission(publicDescriptor);
PermissionService.grantPermission(internalDescriptor); PermissionService.grantPermission(internalDescriptor);
} else { } else {
@ -670,6 +651,7 @@ class FileEditForm extends Form
} }
protected class AuthorLabelPrinter implements PrintListener { protected class AuthorLabelPrinter implements PrintListener {
public AuthorLabelPrinter() { public AuthorLabelPrinter() {
// Empty // Empty
} }
@ -680,38 +662,39 @@ class FileEditForm extends Form
String name = Web.getWebContext().getUser().getName(); String name = Web.getWebContext().getUser().getName();
label.setLabel("Author: (if not "+name+")"); label.setLabel("Author: (if not " + name + ")");
} }
} }
protected class IntendedAudienceSelectPrinter implements PrintListener { protected class IntendedAudienceSelectPrinter implements PrintListener {
public IntendedAudienceSelectPrinter() { public IntendedAudienceSelectPrinter() {
} }
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
SingleSelect select = (SingleSelect) e.getTarget(); SingleSelect select = (SingleSelect) e.getTarget();
select.clearOptions();
select.addOption select.addOption(new Option("workspace",
(new Option("workspace",
Web.getWebContext().getApplication() Web.getWebContext().getApplication()
.getParentApplication() == null ? Web.getWebContext().getApplication().getDisplayName() .getParentApplication() == null ? Web.getWebContext().
: Web.getWebContext().getApplication().getParentApplication().getDisplayName()+ getApplication().getDisplayName()
" members")); : Web.getWebContext().getApplication().
getParentApplication().getDisplayName() + " members"));
select.addOption select.addOption(new Option("internal",
(new Option("internal",
new Label(FILE_INTENDED_AUDIENCE_INTERNAL))); new Label(FILE_INTENDED_AUDIENCE_INTERNAL)));
select.addOption select.addOption(new Option("public",
(new Option("public",
new Label(FILE_INTENDED_AUDIENCE_PUBLIC))); new Label(FILE_INTENDED_AUDIENCE_PUBLIC)));
} }
} }
private ContentSection getContentSection() { private ContentSection getContentSection() {
ContentSectionCollection csl = ContentSection.getAllSections(); ContentSectionCollection csl = ContentSection.getAllSections();
csl.addEqualsFilter("label",DocMgr.getConfig().getContentSection()); csl.addEqualsFilter("label", DocMgr.getConfig().getContentSection());
if (!csl.next()) { if (!csl.next()) {
csl.close(); return null; csl.close();
return null;
} }
ContentSection docsContentSection = csl.getContentSection(); ContentSection docsContentSection = csl.getContentSection();
csl.close(); csl.close();
@ -729,8 +712,7 @@ class FileEditForm extends Form
private BigDecimalParameter getFileIDParam() { private BigDecimalParameter getFileIDParam() {
if (m_parent instanceof FileInfoPropertiesPane) { if (m_parent instanceof FileInfoPropertiesPane) {
return ((FileInfoPropertiesPane) m_parent).getFileIDParam(); return ((FileInfoPropertiesPane) m_parent).getFileIDParam();
} } else {
else {
if (m_parent instanceof BrowseFileInfoPropertiesPane) { if (m_parent instanceof BrowseFileInfoPropertiesPane) {
((BrowseFileInfoPropertiesPane) m_parent).getFileIDParam(); ((BrowseFileInfoPropertiesPane) m_parent).getFileIDParam();
} }
@ -742,16 +724,13 @@ class FileEditForm extends Form
if (m_parent instanceof BrowsePane) { if (m_parent instanceof BrowsePane) {
if (docID != null) { if (docID != null) {
((BrowsePane) m_parent).displayFilePropPanel(state, docID); ((BrowsePane) m_parent).displayFilePropPanel(state, docID);
} } else {
else {
((BrowsePane) m_parent).displayFolderContentPanel(state); ((BrowsePane) m_parent).displayFolderContentPanel(state);
} }
} } else {
else {
if (m_parent instanceof FileInfoPropertiesPane) { if (m_parent instanceof FileInfoPropertiesPane) {
((FileInfoPropertiesPane) m_parent).displayPropertiesAndActions(state); ((FileInfoPropertiesPane) m_parent).displayPropertiesAndActions(state);
} } else {
else {
if (m_parent instanceof BrowseFileInfoPropertiesPane) { if (m_parent instanceof BrowseFileInfoPropertiesPane) {
((BrowseFileInfoPropertiesPane) m_parent).displayPropertiesPane(state); ((BrowseFileInfoPropertiesPane) m_parent).displayPropertiesPane(state);
} }
@ -759,4 +738,3 @@ class FileEditForm extends Form
} }
} }
} }

View File

@ -12,7 +12,6 @@
* rights and limitations under the License. * rights and limitations under the License.
* *
*/ */
package com.arsdigita.cms.docmgr.ui; package com.arsdigita.cms.docmgr.ui;
import com.arsdigita.bebop.*; import com.arsdigita.bebop.*;
@ -47,10 +46,11 @@ import java.util.TooManyListenersException;
* *
* @author Crag Wolfe * @author Crag Wolfe
*/ */
class SearchPane extends SimpleContainer implements DMConstants class SearchPane extends SimpleContainer implements DMConstants {
{
private static final org.apache.log4j.Logger s_log = private static final org.apache.log4j.Logger s_log
org.apache.log4j.Logger.getLogger(SearchPane.class); = org.apache.log4j.Logger.getLogger(
SearchPane.class);
public static final String SEARCH_AUTHOR = "searchAuthor"; public static final String SEARCH_AUTHOR = "searchAuthor";
public static final String SEARCH_TERMS = "searchTerms"; public static final String SEARCH_TERMS = "searchTerms";
@ -58,8 +58,8 @@ class SearchPane extends SimpleContainer implements DMConstants
public static final String CATEGORY_SELECT = "searchCategorySelect"; public static final String CATEGORY_SELECT = "searchCategorySelect";
public static final String WORKSPACE_SELECT = "workspaceSelect"; public static final String WORKSPACE_SELECT = "workspaceSelect";
private final BigDecimalParameter m_categoriesParam = new BigDecimalParameter(CATEGORY_SELECT) ; private final BigDecimalParameter m_categoriesParam = new BigDecimalParameter(CATEGORY_SELECT);
private final BigDecimalParameter m_workspaceParam = new BigDecimalParameter(WORKSPACE_SELECT) ; private final BigDecimalParameter m_workspaceParam = new BigDecimalParameter(WORKSPACE_SELECT);
private final TrimmedStringParameter m_termsParam = new TrimmedStringParameter(SEARCH_TERMS); private final TrimmedStringParameter m_termsParam = new TrimmedStringParameter(SEARCH_TERMS);
private final TrimmedStringParameter m_authorParam = new TrimmedStringParameter(SEARCH_AUTHOR); private final TrimmedStringParameter m_authorParam = new TrimmedStringParameter(SEARCH_AUTHOR);
private final StringParameter m_mimeTypeParam = new StringParameter(SEARCH_MIME_TYPE); private final StringParameter m_mimeTypeParam = new StringParameter(SEARCH_MIME_TYPE);
@ -86,26 +86,25 @@ class SearchPane extends SimpleContainer implements DMConstants
// set component's content section // set component's content section
ContentSectionCollection csl = ContentSection.getAllSections(); ContentSectionCollection csl = ContentSection.getAllSections();
csl.addEqualsFilter("label",DocMgr.getConfig().getContentSection()); csl.addEqualsFilter("label", DocMgr.getConfig().getContentSection());
if (!csl.next()) { if (!csl.next()) {
csl.close(); return; csl.close();
return;
} }
m_docsContentSection = csl.getContentSection(); m_docsContentSection = csl.getContentSection();
csl.close(); csl.close();
// bebop components // bebop components
//m_mainTabPane = new SimpleContainer(); //m_mainTabPane = new SimpleContainer();
m_mainBrowseContainer = new BoxPanel(BoxPanel.HORIZONTAL, true); m_mainBrowseContainer = new BoxPanel(BoxPanel.HORIZONTAL, true);
//m_mainTabPane.addTab(WS_SEARCH_TITLE, //m_mainTabPane.addTab(WS_SEARCH_TITLE,
// m_mainBrowseContainer); // m_mainBrowseContainer);
//m_mainTabPane.add(new Label("yo")); //m_mainTabPane.add(new Label("yo"));
//m_mainBrowseContainer.setClassAttr("sidebarNavPanel"); //m_mainBrowseContainer.setClassAttr("sidebarNavPanel");
DocsSearchForm leftSide = new DocsSearchForm(new GridPanel(2)); DocsSearchForm leftSide = new DocsSearchForm(new GridPanel(2));
m_mainBrowseContainer.add(leftSide); m_mainBrowseContainer.add(leftSide);
m_mainBrowseContainer.add(new Label(" &nbsp; &nbsp; ",false)); m_mainBrowseContainer.add(new Label(" &nbsp; &nbsp; ", false));
m_model = new SearchListModelBuilder(leftSide); m_model = new SearchListModelBuilder(leftSide);
@ -154,8 +153,9 @@ class SearchPane extends SimpleContainer implements DMConstants
private class DocsSearchForm extends Form private class DocsSearchForm extends Form
implements SearchForm, FormValidationListener, implements SearchForm, FormValidationListener,
FormProcessListener, FormInitListener { FormProcessListener, FormInitListener {
public DocsSearchForm(Container panel) { public DocsSearchForm(Container panel) {
super("docSearch",panel); super("docSearch", panel);
add(new Label("Search text:")); add(new Label("Search text:"));
TextField searchText = new TextField(SEARCH_TERMS); TextField searchText = new TextField(SEARCH_TERMS);
@ -172,29 +172,24 @@ class SearchPane extends SimpleContainer implements DMConstants
add(new com.arsdigita.bebop.form.Date(m_endDateParam)); add(new com.arsdigita.bebop.form.Date(m_endDateParam));
add(new Label("Category")); add(new Label("Category"));
SingleSelect categoriesWidget = SingleSelect categoriesWidget
new SingleSelect(m_categoriesParam); = new SingleSelect(m_categoriesParam);
try { try {
categoriesWidget.addOption(new Option("","")); categoriesWidget.addOption(new Option("", ""));
categoriesWidget.addPrintListener categoriesWidget.addPrintListener(new CategoriesPrintListener(m_docsContentSection));
(new CategoriesPrintListener
(m_docsContentSection));
} catch (TooManyListenersException e) { } catch (TooManyListenersException e) {
UncheckedWrapperException.throwLoggedException UncheckedWrapperException.throwLoggedException(getClass(), "Too many listeners", e);
(getClass(), "Too many listeners", e);
} }
add(categoriesWidget); add(categoriesWidget);
//categoriesWidget.setSize(SELECT_HEIGHT); //categoriesWidget.setSize(SELECT_HEIGHT);
add(new Label("Workspace")); add(new Label("Workspace"));
SingleSelect workspaceWidget = SingleSelect workspaceWidget
new SingleSelect(m_workspaceParam); = new SingleSelect(m_workspaceParam);
try { try {
workspaceWidget.addPrintListener workspaceWidget.addPrintListener(new WorkspacesPrintListener());
(new WorkspacesPrintListener());
} catch (TooManyListenersException e) { } catch (TooManyListenersException e) {
UncheckedWrapperException.throwLoggedException UncheckedWrapperException.throwLoggedException(getClass(), "Too many listeners", e);
(getClass(), "Too many listeners", e);
} }
add(workspaceWidget); add(workspaceWidget);
@ -209,23 +204,20 @@ class SearchPane extends SimpleContainer implements DMConstants
throws FormProcessException { throws FormProcessException {
PageState state = e.getPageState(); PageState state = e.getPageState();
String terms = (String)state.getValue(m_termsParam); String terms = (String) state.getValue(m_termsParam);
String author = (String)state.getValue(m_authorParam); String author = (String) state.getValue(m_authorParam);
String mimeType = (String)state.getValue(m_mimeTypeParam); String mimeType = (String) state.getValue(m_mimeTypeParam);
Date endDate = (Date)state.getValue(m_endDateParam); Date endDate = (Date) state.getValue(m_endDateParam);
Date startDate = (Date)state.getValue(m_startDateParam); Date startDate = (Date) state.getValue(m_startDateParam);
BigDecimal workspaceID = (BigDecimal)state.getValue(m_workspaceParam); BigDecimal workspaceID = (BigDecimal) state.getValue(m_workspaceParam);
BigDecimal categoryID = BigDecimal categoryID
(BigDecimal) state.getValue(m_categoriesParam); = (BigDecimal) state.getValue(m_categoriesParam);
if (StringUtils.emptyString(terms) && if (StringUtils.emptyString(terms) && StringUtils.emptyString(author) && StringUtils.
StringUtils.emptyString(author) && emptyString(mimeType) && endDate == null && startDate == null && categoryID
StringUtils.emptyString(mimeType) && == null
endDate == null && && workspaceID == null) {
startDate == null && m_emptyLabel.setVisible(state, true);
categoryID == null &&
workspaceID == null) {
m_emptyLabel.setVisible(state,true);
m_validated.set(state, new Boolean(false)); m_validated.set(state, new Boolean(false));
throw new FormProcessException("At least one search parameter must be specified"); throw new FormProcessException("At least one search parameter must be specified");
} }
@ -233,57 +225,50 @@ class SearchPane extends SimpleContainer implements DMConstants
} }
public void init(FormSectionEvent e) { public void init(FormSectionEvent e) {
m_segmentHeader.setVisibleComponent m_segmentHeader.setVisibleComponent(e.getPageState(), m_emptyLabel);
(e.getPageState(),m_emptyLabel);
} }
public void process(FormSectionEvent e) { public void process(FormSectionEvent e) {
PageState state = e.getPageState(); PageState state = e.getPageState();
SearchResults results = getSearchHits(state); SearchResults results = getSearchHits(state);
if(results != null && if (results != null && results.getTotalSize() > 0) {
results.getTotalSize() > 0) { m_segmentHeader.setVisibleComponent(state, m_hasResultsLabel);
m_segmentHeader.setVisibleComponent
(state,m_hasResultsLabel);
s_log.debug("results"); s_log.debug("results");
} else { } else {
m_segmentHeader.setVisibleComponent m_segmentHeader.setVisibleComponent(state, m_noResultsLabel);
(state,m_noResultsLabel);
s_log.debug("no results"); s_log.debug("no results");
} }
} }
public SearchResults getSearchHits( PageState state ) { public SearchResults getSearchHits(PageState state) {
SearchResults coln = (SearchResults) m_coln.get(state); SearchResults coln = (SearchResults) m_coln.get(state);
if (coln == null && if (coln == null && m_submit.isSelected(state) && ((Boolean) m_validated.get(state)).
m_submit.isSelected(state) && booleanValue()) {
((Boolean) m_validated.get(state)).booleanValue()) { String terms = (String) state.getValue(m_termsParam);
String terms = (String)state.getValue(m_termsParam); String author = (String) state.getValue(m_authorParam);
String author = (String)state.getValue(m_authorParam); String mimeType = (String) state.getValue(m_mimeTypeParam);
String mimeType = (String)state.getValue(m_mimeTypeParam); Date endDate = (Date) state.getValue(m_endDateParam);
Date endDate = (Date)state.getValue(m_endDateParam); Date startDate = (Date) state.getValue(m_startDateParam);
Date startDate = (Date)state.getValue(m_startDateParam); BigDecimal workspaceID = (BigDecimal) state.getValue(m_workspaceParam);
BigDecimal workspaceID = (BigDecimal)state.getValue(m_workspaceParam);
String[] sections = null; String[] sections = null;
if (!LuceneSearcher.class.equals(SearchUtils.getSearcher().getClass())) { if (!LuceneSearcher.class.equals(SearchUtils.getSearcher().getClass())) {
sections = (String[]) new String[] sections = (String[]) new String[]{m_docsContentSection.getID().toString()};
{m_docsContentSection.getID().toString()};
} }
// don't need this since all types in this section are documents // don't need this since all types in this section are documents
//String[] types = (String[])state.getValue(m_typesParam); //String[] types = (String[])state.getValue(m_typesParam);
String[] types = null; String[] types = null;
BigDecimal rootCategoryID = BigDecimal rootCategoryID
m_docsContentSection.getRootCategory().getID(); = m_docsContentSection.getRootCategory().getID();
ArrayList categoryIDs = new ArrayList(); ArrayList categoryIDs = new ArrayList();
if (!LuceneSearcher.class.equals(SearchUtils.getSearcher().getClass())) { if (!LuceneSearcher.class.equals(SearchUtils.getSearcher().getClass())) {
BigDecimal categoryID = BigDecimal categoryID
(BigDecimal) state.getValue(m_categoriesParam); = (BigDecimal) state.getValue(m_categoriesParam);
if (categoryID != null && if (categoryID != null && !categoryID.equals(rootCategoryID)) {
!categoryID.equals(rootCategoryID)) {
categoryIDs.add(categoryID.toString()); categoryIDs.add(categoryID.toString());
} }
@ -302,7 +287,7 @@ class SearchPane extends SimpleContainer implements DMConstants
//if (terms != null && !"".equals(terms)) { //if (terms != null && !"".equals(terms)) {
// if form has been submitted, m_emptyLabel will not be visible // if form has been submitted, m_emptyLabel will not be visible
User user = (User)Kernel.getContext().getParty(); User user = (User) Kernel.getContext().getParty();
coln = SearchUtils.getAdvancedSearch(terms, coln = SearchUtils.getAdvancedSearch(terms,
author, author,
mimeType, mimeType,
@ -322,49 +307,50 @@ class SearchPane extends SimpleContainer implements DMConstants
public boolean isVisible(PageState state) { public boolean isVisible(PageState state) {
return true; return true;
} }
public long getSearchResultCount(PageState state) { public long getSearchResultCount(PageState state) {
return m_coln.get(state) == null ? 0 : return m_coln.get(state) == null ? 0
((SearchResults)m_coln.get(state)).getTotalSize(); : ((SearchResults) m_coln.get(state)).getTotalSize();
} }
} }
private class MimeTypesWidget extends SingleSelect { private class MimeTypesWidget extends SingleSelect {
public MimeTypesWidget (ParameterModel pm) { public MimeTypesWidget(ParameterModel pm) {
super(pm); super(pm);
addOption(new Option("","")); addOption(new Option("", ""));
addOption(new Option("excel","Excel document")); addOption(new Option("excel", "Excel document"));
addOption(new Option("html","HTML")); addOption(new Option("html", "HTML"));
addOption(new Option("acrobat","PDF")); addOption(new Option("acrobat", "PDF"));
addOption(new Option("plain text","Plain text")); addOption(new Option("plain text", "Plain text"));
addOption(new Option("powerpoint","Powerpoint file")); addOption(new Option("powerpoint", "Powerpoint file"));
addOption(new Option("rich text","Rich Text Format (rtf)")); addOption(new Option("rich text", "Rich Text Format (rtf)"));
addOption(new Option("word","Word document")); addOption(new Option("word", "Word document"));
} }
} }
private class WorkspacesPrintListener implements PrintListener { private class WorkspacesPrintListener implements PrintListener {
public WorkspacesPrintListener() { }
public WorkspacesPrintListener() {
}
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
OptionGroup o = (OptionGroup)e.getTarget(); OptionGroup o = (OptionGroup) e.getTarget();
o.clearOptions();
PageState state = e.getPageState(); PageState state = e.getPageState();
User user = Web.getWebContext().getUser(); User user = Web.getWebContext().getUser();
o.addOption(new Option("","")); o.addOption(new Option("", ""));
DataQuery dq = SessionManager.getSession().retrieveQuery DataQuery dq = SessionManager.getSession().retrieveQuery(
("com.arsdigita.cms.docmgr.workspacesWithRepositories"); "com.arsdigita.cms.docmgr.workspacesWithRepositories");
while(dq.next()) { while (dq.next()) {
if (PermissionService.checkPermission if (PermissionService.checkPermission(new PermissionDescriptor(
(new PermissionDescriptor PrivilegeDescriptor.READ,
(PrivilegeDescriptor.READ,
new OID(Document.BASE_DATA_OBJECT_TYPE, new OID(Document.BASE_DATA_OBJECT_TYPE,
dq.get("workspaceID")), dq.get("workspaceID")),
user.getOID()))) { user.getOID()))) {
o.addOption(new Option o.addOption(new Option(((BigDecimal) dq.get("workspaceID")).toString(),
(((BigDecimal) dq.get("workspaceID")).toString(),
(String) dq.get("title"))); (String) dq.get("title")));
} }

View File

@ -54,6 +54,7 @@ public class CategoryWidget extends SingleSelect implements Constants {
PageState s = e.getPageState(); PageState s = e.getPageState();
final Forum forum = getForum(s); final Forum forum = getForum(s);
SingleSelect target = (SingleSelect) e.getTarget(); SingleSelect target = (SingleSelect) e.getTarget();
target.clearOptions();
// Get categories for this forum // Get categories for this forum
if (forum.noCategoryPostsAllowed()) { if (forum.noCategoryPostsAllowed()) {
@ -83,8 +84,7 @@ public class CategoryWidget extends SingleSelect implements Constants {
try { try {
while (children.next()) { while (children.next()) {
Category c = children.getCategory(); Category c = children.getCategory();
target.addOption(new Option target.addOption(new Option(c.getID().toString(),
(c.getID().toString(),
c.getName())); c.getName()));
} }
@ -101,16 +101,15 @@ public class CategoryWidget extends SingleSelect implements Constants {
*/ */
private Forum getForum(final PageState s) { private Forum getForum(final PageState s) {
Forum forum; Forum forum;
if (ForumContext.getContext(s).getThreadID() != null ) { if (ForumContext.getContext(s).getThreadID() != null) {
Post rootPost = (Post)ForumContext.getContext(s). Post rootPost = (Post) ForumContext.getContext(s).
getMessageThread().getRootMessage(); getMessageThread().getRootMessage();
forum = rootPost.getForum(); forum = rootPost.getForum();
} else if (ForumContext.getContext(s).getForum() != null) { } else if (ForumContext.getContext(s).getForum() != null) {
forum = ForumContext.getContext(s).getForum(); forum = ForumContext.getContext(s).getForum();
} else { } else {
// sanity check // sanity check
throw new UncheckedWrapperException throw new UncheckedWrapperException("Must be either a forum, or a thread page.");
("Must be either a forum, or a thread page.");
} }
return forum; return forum;
} }

View File

@ -75,6 +75,7 @@ public class DomainProviderForm extends AbstractProviderForm {
m_domain.addPrintListener(new PrintListener() { m_domain.addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
SingleSelect s = (SingleSelect)e.getTarget(); SingleSelect s = (SingleSelect)e.getTarget();
s.clearOptions();
DataCollection domains = SessionManager.getSession() DataCollection domains = SessionManager.getSession()
.retrieve(Domain.BASE_DATA_OBJECT_TYPE); .retrieve(Domain.BASE_DATA_OBJECT_TYPE);

View File

@ -49,6 +49,7 @@ public class ControlledList extends SingleSelect {
addPrintListener(new PrintListener() { addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
ControlledList target = (ControlledList)e.getTarget(); ControlledList target = (ControlledList)e.getTarget();
target.clearOptions();
target.populate(); target.populate();
} }
}); });

View File

@ -15,7 +15,6 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.london.terms.ui.admin; package com.arsdigita.london.terms.ui.admin;
import com.arsdigita.bebop.Form; import com.arsdigita.bebop.Form;
@ -43,7 +42,6 @@ import com.arsdigita.web.ApplicationCollection;
import java.util.TooManyListenersException; import java.util.TooManyListenersException;
/** /**
* *
* *
@ -82,7 +80,8 @@ public class DomainContextForm extends Form {
try { try {
m_app.addPrintListener(new PrintListener() { m_app.addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
SingleSelect t = (SingleSelect)e.getTarget(); SingleSelect t = (SingleSelect) e.getTarget();
t.clearOptions();
ApplicationCollection apps = Application ApplicationCollection apps = Application
.retrieveAllApplications(); .retrieveAllApplications();
apps.addOrder(Application.PRIMARY_URL); apps.addOrder(Application.PRIMARY_URL);
@ -111,6 +110,7 @@ public class DomainContextForm extends Form {
} }
private class DomainInitListener implements FormInitListener { private class DomainInitListener implements FormInitListener {
public void init(FormSectionEvent ev) public void init(FormSectionEvent ev)
throws FormProcessException { throws FormProcessException {
PageState state = ev.getPageState(); PageState state = ev.getPageState();
@ -121,6 +121,7 @@ public class DomainContextForm extends Form {
} }
private class DomainSubmissionListener implements FormSubmissionListener { private class DomainSubmissionListener implements FormSubmissionListener {
public void submitted(FormSectionEvent ev) public void submitted(FormSectionEvent ev)
throws FormProcessException { throws FormProcessException {
PageState state = ev.getPageState(); PageState state = ev.getPageState();
@ -133,19 +134,19 @@ public class DomainContextForm extends Form {
} }
private class DomainProcessListener implements FormProcessListener { private class DomainProcessListener implements FormProcessListener {
public void process(FormSectionEvent ev) public void process(FormSectionEvent ev)
throws FormProcessException { throws FormProcessException {
PageState state = ev.getPageState(); PageState state = ev.getPageState();
Domain domain = (Domain)state.getValue(m_domain); Domain domain = (Domain) state.getValue(m_domain);
Application app = (Application)m_app.getValue(state); Application app = (Application) m_app.getValue(state);
domain.setAsRootForObject(app, domain.setAsRootForObject(app,
(String)m_context.getValue(state)); (String) m_context.getValue(state));
fireCompletionEvent(state); fireCompletionEvent(state);
} }
} }
} }

View File

@ -69,6 +69,7 @@ public class DomainMappingAddForm extends Form {
@Override @Override
public void prepare(final PrintEvent event) { public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget(); final SingleSelect target = (SingleSelect) event.getTarget();
target.clearOptions();
if (event.getPageState().getValue(selected) == null) { if (event.getPageState().getValue(selected) == null) {
target.setReadOnly(); target.setReadOnly();

View File

@ -98,6 +98,7 @@ public class CategoryForm extends Form {
private static class TemplatePrintListener implements PrintListener { private static class TemplatePrintListener implements PrintListener {
public void prepare(PrintEvent ev) { public void prepare(PrintEvent ev) {
SingleSelect target = (SingleSelect)ev.getTarget(); SingleSelect target = (SingleSelect)ev.getTarget();
target.clearOptions();
target.addOption(new Option(null, "Inherit from parent")); target.addOption(new Option(null, "Inherit from parent"));
TemplateCollection templates = Template.retrieveAll(); TemplateCollection templates = Template.retrieveAll();

View File

@ -124,6 +124,7 @@ public class CategoryFormAddContext extends Form {
private class ContextPrintListener implements PrintListener { private class ContextPrintListener implements PrintListener {
public void prepare(PrintEvent ev) { public void prepare(PrintEvent ev) {
SingleSelect target = (SingleSelect)ev.getTarget(); SingleSelect target = (SingleSelect)ev.getTarget();
target.clearOptions();
TemplateContextCollection contexts = TemplateContext.retrieveAll(); TemplateContextCollection contexts = TemplateContext.retrieveAll();
while (contexts.next()) { while (contexts.next()) {
TemplateContext context = contexts.getTemplateContext(); TemplateContext context = contexts.getTemplateContext();

View File

@ -76,6 +76,7 @@ public class NavigationCreateForm extends Form {
termDomainSelect.addPrintListener(new PrintListener() { termDomainSelect.addPrintListener(new PrintListener() {
public void prepare(final PrintEvent event) { public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget(); final SingleSelect target = (SingleSelect) event.getTarget();
target.clearOptions();
final DataCollection termDomains = SessionManager.getSession(). final DataCollection termDomains = SessionManager.getSession().
retrieve(Domain.BASE_DATA_OBJECT_TYPE); retrieve(Domain.BASE_DATA_OBJECT_TYPE);

View File

@ -142,6 +142,7 @@ public class NavigationTreePortletEditor extends PortletConfigFormSection
public void prepare(PrintEvent e) public void prepare(PrintEvent e)
{ {
SingleSelect target = (SingleSelect) e.getTarget(); SingleSelect target = (SingleSelect) e.getTarget();
target.clearOptions();
DomainCollection navigations = new DomainCollection(SessionManager.getSession().retrieve( DomainCollection navigations = new DomainCollection(SessionManager.getSession().retrieve(
Navigation.BASE_DATA_OBJECT_TYPE)); Navigation.BASE_DATA_OBJECT_TYPE));

View File

@ -189,6 +189,7 @@ public class ObjectListPortletEditor extends PortletConfigFormSection {
public void prepare(PrintEvent ev) { public void prepare(PrintEvent ev) {
OptionGroup target = (OptionGroup)ev.getTarget(); OptionGroup target = (OptionGroup)ev.getTarget();
target.clearOptions();
MetadataRoot root = MetadataRoot.getMetadataRoot(); MetadataRoot root = MetadataRoot.getMetadataRoot();
Iterator types = root.getObjectTypes().iterator(); Iterator types = root.getObjectTypes().iterator();

View File

@ -18,10 +18,8 @@
*/ */
package com.arsdigita.portalserver.permissions; package com.arsdigita.portalserver.permissions;
import com.arsdigita.portalserver.permissions.util.GlobalizationUtil; import com.arsdigita.portalserver.permissions.util.GlobalizationUtil;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
@ -54,15 +52,13 @@ import com.arsdigita.portalserver.*;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import org.apache.log4j.Category; import org.apache.log4j.Category;
/** /**
* *
* @version $Id: ObjectPermissionEdit.java#3 $ * @version $Id: ObjectPermissionEdit.java#3 $
*/ */
public class ObjectPermissionEdit extends CompoundComponent { public class ObjectPermissionEdit extends CompoundComponent {
private static Category s_log = Category.getInstance private static Category s_log = Category.getInstance(ObjectPermissionEdit.class.getName());
(ObjectPermissionEdit.class.getName());
// Heavily-reused per-request label for renderer getComponent calls // Heavily-reused per-request label for renderer getComponent calls
private final static RequestLocal s_dynamicLabel = new RequestLocal() { private final static RequestLocal s_dynamicLabel = new RequestLocal() {
@ -72,27 +68,26 @@ public class ObjectPermissionEdit extends CompoundComponent {
} }
}; };
private static class ObjectGrantsTable extends GrantsTable { private static class ObjectGrantsTable extends GrantsTable {
static void getGrantsHelper(ACSObject object, static void getGrantsHelper(ACSObject object,
Collection types, Collection types,
LinkedList ordering) { LinkedList ordering) {
HashMap canonicalMap = new HashMap(); HashMap canonicalMap = new HashMap();
ObjectPermissionCollection opc = ObjectPermissionCollection opc
PermissionService.getDirectGrantedPermissions(object.getOID()); = PermissionService.getDirectGrantedPermissions(object.
getOID());
try { try {
while (opc.next()) { while (opc.next()) {
s_log.debug s_log.debug("Current grant in loop is " + opc.getPrivilege());
("Current grant in loop is " + opc.getPrivilege());
if (opc.isInherited() if (opc.isInherited()
// Skip create privileges. They are created // Skip create privileges. They are created
// and destroyed implicitly when the other // and destroyed implicitly when the other
// privileges are used. // privileges are used.
|| opc.getPrivilege().equals || opc.getPrivilege().equals(PrivilegeDescriptor.CREATE)) {
(PrivilegeDescriptor.CREATE)) {
continue; continue;
} }
@ -134,7 +129,6 @@ public class ObjectPermissionEdit extends CompoundComponent {
} }
} }
public ObjectGrantsTable(RequestLocal grantsRL, public ObjectGrantsTable(RequestLocal grantsRL,
RequestLocal typesRL, RequestLocal typesRL,
boolean isEditable) { boolean isEditable) {
@ -155,10 +149,11 @@ public class ObjectPermissionEdit extends CompoundComponent {
public Object initialValue(PageState ps) { public Object initialValue(PageState ps) {
SimpleContainer result = new SimpleContainer(); SimpleContainer result = new SimpleContainer();
result.add(Icons.GROUP_16); result.add(Icons.GROUP_16);
result.add((Component)s_dynamicLabel.get(ps)); result.add((Component) s_dynamicLabel.get(ps));
return result; return result;
} }
}; };
public Component getComponent(Table table, public Component getComponent(Table table,
PageState ps, PageState ps,
Object value, Object value,
@ -166,9 +161,10 @@ public class ObjectPermissionEdit extends CompoundComponent {
Object key, Object key,
int row, int row,
int column) { int column) {
Grant grant = (Grant)value; Grant grant = (Grant) value;
Label nameLabel = (Label)s_dynamicLabel.get(ps); Label nameLabel = (Label) s_dynamicLabel.get(ps);
nameLabel.setLabel( (String) GlobalizationUtil.globalize("cw.cw.permissions.").localize() + grant.granteeName); nameLabel.setLabel((String) GlobalizationUtil.globalize("cw.cw.permissions.").
localize() + grant.granteeName);
if (grant.granteeIsUser) { if (grant.granteeIsUser) {
return (Component) m_userNameDisplay.get(ps); return (Component) m_userNameDisplay.get(ps);
} else { } else {
@ -181,9 +177,8 @@ public class ObjectPermissionEdit extends CompoundComponent {
} }
} }
private static class ObjectDirectGrantsTable extends ObjectGrantsTable { private static class ObjectDirectGrantsTable extends ObjectGrantsTable {
public ObjectDirectGrantsTable(final RequestLocal objectRL, public ObjectDirectGrantsTable(final RequestLocal objectRL,
final RequestLocal typesRL) { final RequestLocal typesRL) {
super(new RequestLocal() { super(new RequestLocal() {
@ -199,9 +194,8 @@ public class ObjectPermissionEdit extends CompoundComponent {
} }
private static class ObjectIndirectGrantsTable extends ObjectGrantsTable { private static class ObjectIndirectGrantsTable extends ObjectGrantsTable {
public ObjectIndirectGrantsTable(final RequestLocal objectRL, public ObjectIndirectGrantsTable(final RequestLocal objectRL,
final RequestLocal typesRL) { final RequestLocal typesRL) {
super(new RequestLocal() { super(new RequestLocal() {
@ -218,8 +212,7 @@ public class ObjectPermissionEdit extends CompoundComponent {
if (ctx == null) { if (ctx == null) {
break; break;
} }
object = (ACSObject) DomainObjectFactory.newInstance object = (ACSObject) DomainObjectFactory.newInstance(ctx);
(ctx);
getGrantsHelper(object, types, ordering); getGrantsHelper(object, types, ordering);
} }
@ -248,35 +241,36 @@ public class ObjectPermissionEdit extends CompoundComponent {
} }
private class MainDisplay extends CompoundComponent { private class MainDisplay extends CompoundComponent {
MainDisplay(final RequestLocal objectRL, MainDisplay(final RequestLocal objectRL,
final RequestLocal directTypesRL, final RequestLocal directTypesRL,
final RequestLocal indirectTypesRL, final RequestLocal indirectTypesRL,
final ActionListener onAddClick) { final ActionListener onAddClick) {
super(new BoxPanel(BoxPanel.VERTICAL)); super(new BoxPanel(BoxPanel.VERTICAL));
// Header for direct permission list // Header for direct permission list
final GridPanel directHeader = new GridPanel(2); final GridPanel directHeader = new GridPanel(2);
Label directLabel = Label directLabel
new Label(GlobalizationUtil.globalize("cw.cw.permissions.view_and_manage_specific_permissions")); = new Label(GlobalizationUtil.globalize(
"cw.cw.permissions.view_and_manage_specific_permissions"));
directLabel.setFontWeight(Label.BOLD); directLabel.setFontWeight(Label.BOLD);
directHeader.add(directLabel, GridPanel.LEFT); directHeader.add(directLabel, GridPanel.LEFT);
ActionLink newGrantLink = new ActionLink( (String) GlobalizationUtil.globalize("cw.cw.permissions.add_user_or_role").localize()); ActionLink newGrantLink = new ActionLink((String) GlobalizationUtil.globalize(
"cw.cw.permissions.add_user_or_role").localize());
newGrantLink.setClassAttr("actionLink"); newGrantLink.setClassAttr("actionLink");
newGrantLink.addActionListener(onAddClick); newGrantLink.addActionListener(onAddClick);
directHeader.add(newGrantLink, GridPanel.RIGHT); directHeader.add(newGrantLink, GridPanel.RIGHT);
add(directHeader); add(directHeader);
add(new Label("The following users and roles have specific " + add(new Label("The following users and roles have specific "
"privileges on this knowledge item:")); + "privileges on this knowledge item:"));
// Direct permission list // Direct permission list
Table directTable = new ObjectDirectGrantsTable Table directTable = new ObjectDirectGrantsTable(objectRL, directTypesRL);
(objectRL, directTypesRL);
directTable.setCellPadding("5"); directTable.setCellPadding("5");
Label directEmptyView = new Label("No specific privileges are " + Label directEmptyView = new Label("No specific privileges are "
"defined on this item."); + "defined on this item.");
directEmptyView.setFontWeight(Label.ITALIC); directEmptyView.setFontWeight(Label.ITALIC);
directTable.setEmptyView(directEmptyView); directTable.setEmptyView(directEmptyView);
add(directTable); add(directTable);
@ -284,24 +278,22 @@ public class ObjectPermissionEdit extends CompoundComponent {
add(new Label(" ")); add(new Label(" "));
// Header for indirect permission list // Header for indirect permission list
Label indirectLabel = new Label(GlobalizationUtil.globalize("cw.cw.permissions.view_general_permissions")); Label indirectLabel = new Label(GlobalizationUtil.globalize(
"cw.cw.permissions.view_general_permissions"));
indirectLabel.setFontWeight(Label.BOLD); indirectLabel.setFontWeight(Label.BOLD);
add(indirectLabel); add(indirectLabel);
add(new Label("The following users and roles have broader " + add(new Label("The following users and roles have broader "
"privileges applying to this and other knowledge " + + "privileges applying to this and other knowledge "
"items. Note that these are inherited privileges " + + "items. Note that these are inherited privileges "
"and can only be changed from the location given " + + "and can only be changed from the location given "
"in the \"On\" column.")); + "in the \"On\" column."));
// Indirect permission list // Indirect permission list
Table indirectTable = new ObjectIndirectGrantsTable Table indirectTable = new ObjectIndirectGrantsTable(objectRL, indirectTypesRL);
(objectRL, indirectTypesRL);
indirectTable.setCellPadding("5"); indirectTable.setCellPadding("5");
Label indirectEmpty = new Label("No general permissions apply " + Label indirectEmpty = new Label("No general permissions apply " + "to this item.");
"to this item.");
indirectEmpty.setFontWeight(Label.ITALIC); indirectEmpty.setFontWeight(Label.ITALIC);
indirectTable.setEmptyView(indirectEmpty); indirectTable.setEmptyView(indirectEmpty);
add(indirectTable); add(indirectTable);
@ -314,25 +306,27 @@ public class ObjectPermissionEdit extends CompoundComponent {
private static final long MAX_RESULTS = 20; private static final long MAX_RESULTS = 20;
private class NewGrantDisplay extends CompoundComponent { private class NewGrantDisplay extends CompoundComponent {
// RequestLocal storing the object // RequestLocal storing the object
private final RequestLocal m_objectRL; private final RequestLocal m_objectRL;
// Collection of 'relevant types' // Collection of 'relevant types'
private final RequestLocal m_typesRL; private final RequestLocal m_typesRL;
// Parameter containing user's search string // Parameter containing user's search string
private final StringParameter m_queryParam = private final StringParameter m_queryParam
new StringParameter("queryParam"); = new StringParameter("queryParam");
// Flag indicating whether or not to limit search to current // Flag indicating whether or not to limit search to current
// workspace's participants // workspace's participants
private final BooleanParameter m_limitParam = private final BooleanParameter m_limitParam
new BooleanParameter("limitParam"); = new BooleanParameter("limitParam");
private final RequestLocal m_partiesRL = new RequestLocal() { private final RequestLocal m_partiesRL = new RequestLocal() {
public Object initialValue(PageState ps) { public Object initialValue(PageState ps) {
PortalSite psite = PortalSite psite
PortalSite.getCurrentPortalSite(ps.getRequest()); = PortalSite.getCurrentPortalSite(ps.getRequest());
String queryString = (String) ps.getValue(m_queryParam); String queryString = (String) ps.getValue(m_queryParam);
@ -351,7 +345,6 @@ public class ObjectPermissionEdit extends CompoundComponent {
} }
}; };
private void clearQuery(PageState ps) { private void clearQuery(PageState ps) {
ps.setValue(m_queryParam, null); ps.setValue(m_queryParam, null);
ps.setValue(m_limitParam, null); ps.setValue(m_limitParam, null);
@ -374,6 +367,7 @@ public class ObjectPermissionEdit extends CompoundComponent {
} }
private class BoldLabel extends Label { private class BoldLabel extends Label {
public BoldLabel(String text) { public BoldLabel(String text) {
super(text); super(text);
setFontWeight(Label.BOLD); setFontWeight(Label.BOLD);
@ -381,6 +375,7 @@ public class ObjectPermissionEdit extends CompoundComponent {
} }
private class MyAddGrantForm extends AddGrantForm { private class MyAddGrantForm extends AddGrantForm {
public MyAddGrantForm(String name, public MyAddGrantForm(String name,
Widget partyWidget, Widget partyWidget,
final RequestLocal errorMessageRL) { final RequestLocal errorMessageRL) {
@ -392,7 +387,7 @@ public class ObjectPermissionEdit extends CompoundComponent {
add(new BoldLabel("On:") { add(new BoldLabel("On:") {
public void generateXML(PageState ps, Element parent) { public void generateXML(PageState ps, Element parent) {
Collection types = (Collection)m_typesRL.get(ps); Collection types = (Collection) m_typesRL.get(ps);
if ((types == null) || (types.size() <= 1)) { if ((types == null) || (types.size() <= 1)) {
parent.newChildElement("bebop:label", BEBOP_XML_NS); parent.newChildElement("bebop:label", BEBOP_XML_NS);
@ -408,7 +403,6 @@ public class ObjectPermissionEdit extends CompoundComponent {
add(new Label("")); add(new Label(""));
// Row 2: Widgets // Row 2: Widgets
// Create a hidden widget for the objectID // Create a hidden widget for the objectID
add(new Hidden(getObjectParameter())); add(new Hidden(getObjectParameter()));
@ -431,7 +425,7 @@ public class ObjectPermissionEdit extends CompoundComponent {
PageState ps = ev.getPageState(); PageState ps = ev.getPageState();
FormData fd = ev.getFormData(); FormData fd = ev.getFormData();
fd.put(getObjectParameter().getName(), fd.put(getObjectParameter().getName(),
((ACSObject)m_objectRL.get(ps)).getID()); ((ACSObject) m_objectRL.get(ps)).getID());
} }
}); });
@ -451,30 +445,28 @@ public class ObjectPermissionEdit extends CompoundComponent {
// This RL makes available a PartyCollection containing // This RL makes available a PartyCollection containing
// the result of the specified query // the result of the specified query
final BoxPanel screen1 = new BoxPanel(BoxPanel.VERTICAL) { final BoxPanel screen1 = new BoxPanel(BoxPanel.VERTICAL) {
public boolean isVisible(PageState ps) { public boolean isVisible(PageState ps) {
if (!haveQuery(ps)) { if (!haveQuery(ps)) {
return true; return true;
} }
PartyCollection pc = PartyCollection pc
NewGrantDisplay.this.getQueryResults(ps); = NewGrantDisplay.this.getQueryResults(ps);
long n = pc.size(); long n = pc.size();
return (n == 0 || n > MAX_RESULTS); return (n == 0 || n > MAX_RESULTS);
} }
}; };
add(screen1); add(screen1);
Label roleFormTitle = new BoldLabel(""); Label roleFormTitle = new BoldLabel("");
roleFormTitle.addPrintListener(new PrintListener() { roleFormTitle.addPrintListener(new PrintListener() {
public void prepare(PrintEvent ev) { public void prepare(PrintEvent ev) {
PageState ps = ev.getPageState(); PageState ps = ev.getPageState();
Label tgt = (Label)ev.getTarget(); Label tgt = (Label) ev.getTarget();
PortalSite psite = PortalSite psite
PortalSite.getCurrentPortalSite(ps.getRequest()); = PortalSite.getCurrentPortalSite(ps.getRequest());
tgt.setLabel("Grant privilege to a role from the \"" + tgt.setLabel("Grant privilege to a role from the \"" + psite.getTitle()
psite.getTitle() + "\" portal:"); + "\" portal:");
} }
}); });
screen1.add(roleFormTitle); screen1.add(roleFormTitle);
@ -485,14 +477,14 @@ public class ObjectPermissionEdit extends CompoundComponent {
SingleSelect roleField = new SingleSelect("roleField"); SingleSelect roleField = new SingleSelect("roleField");
roleField.setPrintListener(new PrintListener() { roleField.setPrintListener(new PrintListener() {
public void prepare(PrintEvent ev) { public void prepare(PrintEvent ev) {
SingleSelect tgt = (SingleSelect)ev.getTarget(); SingleSelect tgt = (SingleSelect) ev.getTarget();
tgt.clearOptions();
PageState ps = ev.getPageState(); PageState ps = ev.getPageState();
PortalSite psite = PortalSite psite
PortalSite.getCurrentPortalSite(ps.getRequest()); = PortalSite.getCurrentPortalSite(ps.getRequest());
RoleCollection rc = psite.getRoles(); RoleCollection rc = psite.getRoles();
while (rc.next()) { while (rc.next()) {
Option o = new Option Option o = new Option(rc.getID().toString(), rc.getRoleName());
(rc.getID().toString(), rc.getRoleName());
tgt.addOption(o); tgt.addOption(o);
} }
} }
@ -505,11 +497,8 @@ public class ObjectPermissionEdit extends CompoundComponent {
// Error message display // Error message display
screen1.add(new ErrorMessageDisplay(rfErrorMessageRL)); screen1.add(new ErrorMessageDisplay(rfErrorMessageRL));
// Toplevel search label // Toplevel search label
screen1.add(new BoldLabel("Search for a user or role to recieve " + screen1.add(new BoldLabel("Search for a user or role to recieve " + "a privilege:"));
"a privilege:"));
Form otherSearch = new Form("otherSearch", new GridPanel(2)); Form otherSearch = new Form("otherSearch", new GridPanel(2));
otherSearch.setRedirecting(true); otherSearch.setRedirecting(true);
@ -522,18 +511,17 @@ public class ObjectPermissionEdit extends CompoundComponent {
Label limitLabel = new Label(""); Label limitLabel = new Label("");
limitLabel.addPrintListener(new PrintListener() { limitLabel.addPrintListener(new PrintListener() {
public void prepare(PrintEvent ev) { public void prepare(PrintEvent ev) {
Label tgt = (Label)ev.getTarget(); Label tgt = (Label) ev.getTarget();
PageState ps = ev.getPageState(); PageState ps = ev.getPageState();
PortalSite psite = PortalSite psite
PortalSite.getCurrentPortalSite(ps.getRequest()); = PortalSite.getCurrentPortalSite(ps.getRequest());
tgt.setLabel("Limit search to \"" + psite.getTitle() + tgt.setLabel("Limit search to \"" + psite.getTitle() + "\" participants");
"\" participants");
} }
}); });
final CheckboxGroup limitToParticipants = final CheckboxGroup limitToParticipants
new CheckboxGroup("limitToParticipants"); = new CheckboxGroup("limitToParticipants");
String[] limitDefault = { "yes" }; String[] limitDefault = {"yes"};
limitToParticipants.setDefaultValue(limitDefault); limitToParticipants.setDefaultValue(limitDefault);
limitToParticipants.addOption(new Option("yes", limitLabel)); limitToParticipants.addOption(new Option("yes", limitLabel));
otherSearch.add(limitToParticipants); otherSearch.add(limitToParticipants);
@ -541,7 +529,8 @@ public class ObjectPermissionEdit extends CompoundComponent {
otherSearch.add(new Label("")); otherSearch.add(new Label(""));
// Label to display when no matches are found // Label to display when no matches are found
Label noMatchLabel = new Label(GlobalizationUtil.globalize("cw.cw.permissions.no_matches_found")) { Label noMatchLabel = new Label(GlobalizationUtil.globalize(
"cw.cw.permissions.no_matches_found")) {
public boolean isVisible(PageState ps) { public boolean isVisible(PageState ps) {
if (!haveQuery(ps)) { if (!haveQuery(ps)) {
return false; return false;
@ -563,8 +552,9 @@ public class ObjectPermissionEdit extends CompoundComponent {
otherSearch.add(noMatchLabel); otherSearch.add(noMatchLabel);
// Label to display when too many matches are found. // Label to display when too many matches are found.
Label tooManyLabel = Label tooManyLabel
new Label(GlobalizationUtil.globalize("cw.cw.permissions.too_many_matches_refine_your_search")) { = new Label(GlobalizationUtil.globalize(
"cw.cw.permissions.too_many_matches_refine_your_search")) {
public boolean isVisible(PageState ps) { public boolean isVisible(PageState ps) {
if (!haveQuery(ps)) { if (!haveQuery(ps)) {
return false; return false;
@ -586,8 +576,6 @@ public class ObjectPermissionEdit extends CompoundComponent {
// tooManyLabel.setColor(Color.red); // tooManyLabel.setColor(Color.red);
otherSearch.add(tooManyLabel); otherSearch.add(tooManyLabel);
// SECOND Add screen: Search results // SECOND Add screen: Search results
final BoxPanel screen2 = new BoxPanel(BoxPanel.VERTICAL) { final BoxPanel screen2 = new BoxPanel(BoxPanel.VERTICAL) {
public boolean isVisible(PageState ps) { public boolean isVisible(PageState ps) {
@ -604,8 +592,8 @@ public class ObjectPermissionEdit extends CompoundComponent {
otherSearch.addProcessListener(new FormProcessListener() { otherSearch.addProcessListener(new FormProcessListener() {
public void process(FormSectionEvent ev) { public void process(FormSectionEvent ev) {
PageState ps = ev.getPageState(); PageState ps = ev.getPageState();
String queryString = (String)queryField.getValue(ps); String queryString = (String) queryField.getValue(ps);
String[] limit = (String[])limitToParticipants.getValue(ps); String[] limit = (String[]) limitToParticipants.getValue(ps);
if (limit != null && limit.length > 0) { if (limit != null && limit.length > 0) {
setQuery(ps, queryString, Boolean.TRUE); setQuery(ps, queryString, Boolean.TRUE);
} else { } else {
@ -618,8 +606,10 @@ public class ObjectPermissionEdit extends CompoundComponent {
screen1.add(new Label("")); screen1.add(new Label(""));
ActionLink returnLink = ActionLink returnLink
new ActionLink( (String) GlobalizationUtil.globalize("cw.cw.permissions.return_to_current_permissions_view").localize()); = new ActionLink((String) GlobalizationUtil.globalize(
"cw.cw.permissions.return_to_current_permissions_view").
localize());
returnLink.setClassAttr("actionLink"); returnLink.setClassAttr("actionLink");
returnLink.addActionListener(new ActionListener() { returnLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) { public void actionPerformed(ActionEvent ev) {
@ -628,9 +618,7 @@ public class ObjectPermissionEdit extends CompoundComponent {
}); });
screen1.add(returnLink); screen1.add(returnLink);
// Build Search results form // Build Search results form
RequestLocal pfErrorMessageRL = new RequestLocal(); RequestLocal pfErrorMessageRL = new RequestLocal();
RadioGroup partyField = new RadioGroup("partyField"); RadioGroup partyField = new RadioGroup("partyField");
@ -638,7 +626,7 @@ public class ObjectPermissionEdit extends CompoundComponent {
partyField.setPrintListener(new PrintListener() { partyField.setPrintListener(new PrintListener() {
public void prepare(PrintEvent ev) { public void prepare(PrintEvent ev) {
PageState ps = ev.getPageState(); PageState ps = ev.getPageState();
RadioGroup target = (RadioGroup)ev.getTarget(); RadioGroup target = (RadioGroup) ev.getTarget();
PartyCollection parties = getQueryResults(ps); PartyCollection parties = getQueryResults(ps);
while (parties.next()) { while (parties.next()) {
target.addOption(new Option(parties.getID().toString(), target.addOption(new Option(parties.getID().toString(),
@ -647,7 +635,6 @@ public class ObjectPermissionEdit extends CompoundComponent {
} }
}); });
Form partyForm = new MyAddGrantForm("partyGrant", Form partyForm = new MyAddGrantForm("partyGrant",
partyField, partyField,
pfErrorMessageRL); pfErrorMessageRL);
@ -656,7 +643,8 @@ public class ObjectPermissionEdit extends CompoundComponent {
screen2.add(new ErrorMessageDisplay(pfErrorMessageRL)); screen2.add(new ErrorMessageDisplay(pfErrorMessageRL));
ActionLink newSearchLink = new ActionLink( (String) GlobalizationUtil.globalize("cw.cw.permissions.try_a_new_search").localize()); ActionLink newSearchLink = new ActionLink((String) GlobalizationUtil.
globalize("cw.cw.permissions.try_a_new_search").localize());
newSearchLink.setClassAttr("actionLink"); newSearchLink.setClassAttr("actionLink");
newSearchLink.addActionListener(new ActionListener() { newSearchLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) { public void actionPerformed(ActionEvent ev) {
@ -665,8 +653,10 @@ public class ObjectPermissionEdit extends CompoundComponent {
}); });
screen2.add(newSearchLink); screen2.add(newSearchLink);
ActionLink returnToMainLink = ActionLink returnToMainLink
new ActionLink( (String) GlobalizationUtil.globalize("cw.cw.permissions.return_to_current_permissions_view").localize()); = new ActionLink((String) GlobalizationUtil.globalize(
"cw.cw.permissions.return_to_current_permissions_view").
localize());
returnToMainLink.setClassAttr("actionLink"); returnToMainLink.setClassAttr("actionLink");
returnToMainLink.addActionListener(new ActionListener() { returnToMainLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) { public void actionPerformed(ActionEvent ev) {
@ -676,7 +666,6 @@ public class ObjectPermissionEdit extends CompoundComponent {
screen2.add(returnToMainLink); screen2.add(returnToMainLink);
} }
public void fireCompletionEvent(PageState ps) { public void fireCompletionEvent(PageState ps) {
clearQuery(ps); clearQuery(ps);
super.fireCompletionEvent(ps); super.fireCompletionEvent(ps);
@ -690,24 +679,21 @@ public class ObjectPermissionEdit extends CompoundComponent {
} }
public void register(Page p) { public void register(Page p) {
// Assert.assertTrue((p instanceof CWPage), // Assert.assertTrue((p instanceof CWPage),
Assert.isTrue((p instanceof CWPage), Assert.isTrue((p instanceof CWPage),
"ObjectPermissionEdit may only be used on " + "ObjectPermissionEdit may only be used on " + "instances of CWPage.");
"instances of CWPage.");
super.register(p); super.register(p);
} }
private void initialize(RequestLocal objectRL, private void initialize(RequestLocal objectRL,
RequestLocal directTypesRL, RequestLocal directTypesRL,
RequestLocal indirectTypesRL) { RequestLocal indirectTypesRL) {
final SimpleContainer c = (SimpleContainer)getContainer(); final SimpleContainer c = (SimpleContainer) getContainer();
final Completable newGrantDisplay = final Completable newGrantDisplay
new NewGrantDisplay(objectRL, directTypesRL) { = new NewGrantDisplay(objectRL, directTypesRL) {
public void register(Page p) { public void register(Page p) {
super.register(p); super.register(p);
p.setVisibleDefault(this, false); p.setVisibleDefault(this, false);
@ -717,13 +703,13 @@ public class ObjectPermissionEdit extends CompoundComponent {
ActionListener onAddClick = new ActionListener() { ActionListener onAddClick = new ActionListener() {
public void actionPerformed(ActionEvent ev) { public void actionPerformed(ActionEvent ev) {
PageState ps = ev.getPageState(); PageState ps = ev.getPageState();
CWPage page = (CWPage)ps.getPage(); CWPage page = (CWPage) ps.getPage();
page.goModal(ps, newGrantDisplay); page.goModal(ps, newGrantDisplay);
} }
}; };
final Component mainDisplay = final Component mainDisplay
new MainDisplay(objectRL, = new MainDisplay(objectRL,
directTypesRL, directTypesRL,
indirectTypesRL, indirectTypesRL,
onAddClick); onAddClick);
@ -731,7 +717,7 @@ public class ObjectPermissionEdit extends CompoundComponent {
newGrantDisplay.addCompletionListener(new ActionListener() { newGrantDisplay.addCompletionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) { public void actionPerformed(ActionEvent ev) {
PageState ps = ev.getPageState(); PageState ps = ev.getPageState();
CWPage page = (CWPage)ps.getPage(); CWPage page = (CWPage) ps.getPage();
page.goUnmodal(ps); page.goUnmodal(ps);
} }
}); });
@ -740,8 +726,6 @@ public class ObjectPermissionEdit extends CompoundComponent {
add(newGrantDisplay); add(newGrantDisplay);
} }
public ObjectPermissionEdit(final RequestLocal objectRL) { public ObjectPermissionEdit(final RequestLocal objectRL) {
super(new SimpleContainer()); super(new SimpleContainer());
initialize(objectRL, new RequestLocal(), new RequestLocal()); initialize(objectRL, new RequestLocal(), new RequestLocal());

View File

@ -251,6 +251,7 @@ public class PartyPermissionEdit extends CompoundComponent {
objectSelect.setPrintListener(new PrintListener() { objectSelect.setPrintListener(new PrintListener() {
public void prepare(PrintEvent ev) { public void prepare(PrintEvent ev) {
SingleSelect target = (SingleSelect)ev.getTarget(); SingleSelect target = (SingleSelect)ev.getTarget();
target.clearOptions();
PageState ps = ev.getPageState(); PageState ps = ev.getPageState();
List options = (List) m_targetsRL.get(ps); List options = (List) m_targetsRL.get(ps);
for (Iterator it = options.iterator(); it.hasNext(); ) { for (Iterator it = options.iterator(); it.hasNext(); ) {

View File

@ -26,8 +26,8 @@ import com.arsdigita.bebop.event.*;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import com.arsdigita.persistence.metadata.ObjectType; import com.arsdigita.persistence.metadata.ObjectType;
class TypeSingleSelect extends SingleSelect { class TypeSingleSelect extends SingleSelect {
private RequestLocal m_typesRL; private RequestLocal m_typesRL;
public TypeSingleSelect(ParameterModel param, public TypeSingleSelect(ParameterModel param,
@ -40,12 +40,13 @@ class TypeSingleSelect extends SingleSelect {
"All Contained Items")); "All Contained Items"));
setPrintListener(new PrintListener() { setPrintListener(new PrintListener() {
public void prepare(PrintEvent ev) { public void prepare(PrintEvent ev) {
SingleSelect tgt = (SingleSelect)ev.getTarget(); SingleSelect tgt = (SingleSelect) ev.getTarget();
tgt.clearOptions();
PageState ps = ev.getPageState(); PageState ps = ev.getPageState();
Iterator types = Iterator types
((Collection)m_typesRL.get(ps)).iterator(); = ((Collection) m_typesRL.get(ps)).iterator();
while (types.hasNext()) { while (types.hasNext()) {
ObjectType type = (ObjectType)types.next(); ObjectType type = (ObjectType) types.next();
tgt.addOption(new Option(type.getQualifiedName(), tgt.addOption(new Option(type.getQualifiedName(),
type.getName())); type.getName()));
} }
@ -54,7 +55,7 @@ class TypeSingleSelect extends SingleSelect {
} }
public void generateXML(PageState ps, Element parent) { public void generateXML(PageState ps, Element parent) {
Collection types = (Collection)m_typesRL.get(ps); Collection types = (Collection) m_typesRL.get(ps);
if (types == null) { if (types == null) {
parent.newChildElement("bebop:label", BEBOP_XML_NS); parent.newChildElement("bebop:label", BEBOP_XML_NS);
return; return;

View File

@ -18,7 +18,6 @@
*/ */
package com.arsdigita.portalserver.ui.admin; package com.arsdigita.portalserver.ui.admin;
import com.arsdigita.portalserver.util.GlobalizationUtil; import com.arsdigita.portalserver.util.GlobalizationUtil;
import com.arsdigita.web.ApplicationType; import com.arsdigita.web.ApplicationType;
@ -77,10 +76,11 @@ import java.math.BigDecimal;
* @version $Id: //portalserver/dev/src/com/arsdigita/portalserver/ui/admin/DisplayPane.java#9 $ * @version $Id: //portalserver/dev/src/com/arsdigita/portalserver/ui/admin/DisplayPane.java#9 $
*/ */
public class DisplayPane extends DynamicListWizard { public class DisplayPane extends DynamicListWizard {
public static final String versionId = "$Id: //portalserver/dev/src/com/arsdigita/portalserver/ui/admin/DisplayPane.java#9 $ by $Author: dennis $, $DateTime: 2004/08/17 23:19:25 $"; public static final String versionId = "$Id: //portalserver/dev/src/com/arsdigita/portalserver/ui/admin/DisplayPane.java#9 $ by $Author: dennis $, $DateTime: 2004/08/17 23:19:25 $";
private static final Logger s_cat = private static final Logger s_cat
Logger.getLogger(ApplicationsPane.class.getName()); = Logger.getLogger(ApplicationsPane.class.getName());
final ModalContainer m_editContainer = new ModalContainer(); final ModalContainer m_editContainer = new ModalContainer();
@ -91,18 +91,21 @@ public class DisplayPane extends DynamicListWizard {
DeleteTabForm m_deleteTabForm; DeleteTabForm m_deleteTabForm;
List m_layouts; List m_layouts;
RequestLocal selectedTabIDRL; RequestLocal selectedTabIDRL;
static final String m_layoutNames[] = {"W","NW","WN","NWN","NNN"}; static final String m_layoutNames[] = {"W", "NW", "WN", "NWN", "NNN"};
BigDecimalParameter m_selectedPortletParam; BigDecimalParameter m_selectedPortletParam;
static final String FOUR_SPACE_INDENT_STRING = "&nbsp;&nbsp;&nbsp;&nbsp;"; static final String FOUR_SPACE_INDENT_STRING = "&nbsp;&nbsp;&nbsp;&nbsp;";
static class TabListModel implements ListModel { static class TabListModel implements ListModel {
PortalTabCollection m_tabs; PortalTabCollection m_tabs;
PortalTab m_currTab; PortalTab m_currTab;
public TabListModel(PortalSite psite) { public TabListModel(PortalSite psite) {
m_tabs = psite.getTabsForPortalSite(); m_tabs = psite.getTabsForPortalSite();
} }
public boolean next() { public boolean next() {
if (!m_tabs.next()) { if (!m_tabs.next()) {
return false; return false;
@ -110,52 +113,54 @@ public class DisplayPane extends DynamicListWizard {
m_currTab = m_tabs.getPortalTab(); m_currTab = m_tabs.getPortalTab();
return true; return true;
} }
public Object getElement() { public Object getElement() {
return m_currTab.getTitle(); return m_currTab.getTitle();
} }
public String getKey() { public String getKey() {
return m_currTab.getID().toString(); return m_currTab.getID().toString();
} }
} }
public DisplayPane(final RequestLocal portalsiteRL) {
public DisplayPane(final RequestLocal portalsiteRL)
{
super("Current Tabs. Use the arrows to shift tab position.", super("Current Tabs. Use the arrows to shift tab position.",
new ListModelBuilder() { new ListModelBuilder() {
public ListModel makeModel(List l, PageState ps) { public ListModel makeModel(List l, PageState ps) {
PortalSite psite = (PortalSite)portalsiteRL.get(ps); PortalSite psite = (PortalSite) portalsiteRL.get(ps);
return new TabListModel(psite); return new TabListModel(psite);
} }
public void lock() {}
public boolean isLocked() { return true; } public void lock() {
}
public boolean isLocked() {
return true;
}
}, },
"Add a tab", "Add a tab",
new Label(GlobalizationUtil.globalize("cw.workspace.ui.admin.there_currently_is_no_tab_selected_please_select_a_tab"))); new Label(GlobalizationUtil.globalize(
"cw.workspace.ui.admin.there_currently_is_no_tab_selected_please_select_a_tab")));
final DynamicListWizard dlw = this; final DynamicListWizard dlw = this;
// FORM FOR ADDING NEW TABS // FORM FOR ADDING NEW TABS
Form addForm = new Form("addTab"); Form addForm = new Form("addTab");
addForm.add(new Label(GlobalizationUtil.globalize("cw.workspace.ui.admin.new_tab_name"))); addForm.add(new Label(GlobalizationUtil.globalize("cw.workspace.ui.admin.new_tab_name")));
final TextField newTabName = new TextField("name"); final TextField newTabName = new TextField("name");
newTabName.getParameterModel().addParameterListener newTabName.getParameterModel().addParameterListener(new NotEmptyValidationListener());
(new NotEmptyValidationListener());
newTabName.setSize(40); newTabName.setSize(40);
addForm.add(newTabName); addForm.add(newTabName);
addForm.add(new Label()); addForm.add(new Label());
addForm.add(new Submit("Add tab")); addForm.add(new Submit("Add tab"));
addForm.addProcessListener(new FormProcessListener() { addForm.addProcessListener(new FormProcessListener() {
public void process(FormSectionEvent ev) { public void process(FormSectionEvent ev) {
PageState ps = ev.getPageState(); PageState ps = ev.getPageState();
PortalSite psite = (PortalSite)portalsiteRL.get(ps); PortalSite psite = (PortalSite) portalsiteRL.get(ps);
PortalTab newTab = PortalTab newTab
PortalTab.createTab((String)newTabName.getValue(ps),psite); = PortalTab.createTab((String) newTabName.getValue(ps), psite);
psite.addPortalTab(newTab); psite.addPortalTab(newTab);
newTab.save(); newTab.save();
psite.save(); psite.save();
@ -172,7 +177,7 @@ public class DisplayPane extends DynamicListWizard {
// CONSTRUCT EDIT COMPONENT // CONSTRUCT EDIT COMPONENT
selectedTabIDRL = new RequestLocal() { selectedTabIDRL = new RequestLocal() {
protected Object initialValue(PageState ps) { protected Object initialValue(PageState ps) {
String tabIDstr = (String)dlw.getSelectionModel() String tabIDstr = (String) dlw.getSelectionModel()
.getSelectedKey(ps); .getSelectedKey(ps);
return new BigDecimal(tabIDstr); return new BigDecimal(tabIDstr);
} }
@ -181,28 +186,30 @@ public class DisplayPane extends DynamicListWizard {
m_selectedPortletParam = new BigDecimalParameter("selectedPortlet"); m_selectedPortletParam = new BigDecimalParameter("selectedPortlet");
m_mainDisplay = new BoxPanel(BoxPanel.VERTICAL); m_mainDisplay = new BoxPanel(BoxPanel.VERTICAL);
PortletLayoutComponent plc = PortletLayoutComponent plc
new PortletLayoutComponent(portalsiteRL, selectedTabIDRL) { = new PortletLayoutComponent(portalsiteRL, selectedTabIDRL) {
protected void handleConfigure(PageState ps, BigDecimal id) { protected void handleConfigure(PageState ps, BigDecimal id) {
ps.setValue(m_selectedPortletParam, id); ps.setValue(m_selectedPortletParam, id);
m_editContainer.setVisibleComponent(ps, m_portletModify); m_editContainer.setVisibleComponent(ps, m_portletModify);
} }
}; };
LockableLinks locklinks = LockableLinks locklinks
new LockableLinks(portalsiteRL, selectedTabIDRL); = new LockableLinks(portalsiteRL, selectedTabIDRL);
m_mainDisplay.add(locklinks); m_mainDisplay.add(locklinks);
m_mainDisplay.add(plc); m_mainDisplay.add(plc);
BoxPanel links = new BoxPanel(BoxPanel.HORIZONTAL, true); BoxPanel links = new BoxPanel(BoxPanel.HORIZONTAL, true);
ActionLink renameLink = new ActionLink( (String) GlobalizationUtil.globalize("cw.workspace.ui.admin.rename_tab").localize()); ActionLink renameLink = new ActionLink((String) GlobalizationUtil.globalize(
"cw.workspace.ui.admin.rename_tab").localize());
renameLink.setClassAttr("actionLink"); renameLink.setClassAttr("actionLink");
renameLink.addActionListener(new RenameLinkListener()); renameLink.addActionListener(new RenameLinkListener());
links.add(renameLink); links.add(renameLink);
ActionLink deleteLink = new ActionLink( (String) GlobalizationUtil.globalize("cw.workspace.ui.admin.delete_tab").localize()) { ActionLink deleteLink = new ActionLink((String) GlobalizationUtil.globalize(
"cw.workspace.ui.admin.delete_tab").localize()) {
public boolean isVisible(PageState ps) { public boolean isVisible(PageState ps) {
PortalSite psite = (PortalSite)portalsiteRL.get(ps); PortalSite psite = (PortalSite) portalsiteRL.get(ps);
PortalTabCollection pstc = psite.getTabsForPortalSite(); PortalTabCollection pstc = psite.getTabsForPortalSite();
return (pstc.size() > 1); return (pstc.size() > 1);
} }
@ -213,8 +220,8 @@ public class DisplayPane extends DynamicListWizard {
m_mainDisplay.add(links); m_mainDisplay.add(links);
final BigDecimalParameter portletTypeParam = final BigDecimalParameter portletTypeParam
new BigDecimalParameter("typeID"); = new BigDecimalParameter("typeID");
Form addPortlet = new Form("ap1", new GridPanel(1)) { Form addPortlet = new Form("ap1", new GridPanel(1)) {
public void register(Page p) { public void register(Page p) {
super.register(p); super.register(p);
@ -226,8 +233,7 @@ public class DisplayPane extends DynamicListWizard {
SimpleContainer imageLabelSC = new SimpleContainer(); SimpleContainer imageLabelSC = new SimpleContainer();
imageLabelSC.add(image); imageLabelSC.add(image);
imageLabelSC.add(new Label imageLabelSC.add(new Label("To add a portlet to this page, first choose a type: "));
("To add a portlet to this page, first choose a type: "));
addPortlet.add(imageLabelSC); addPortlet.add(imageLabelSC);
@ -239,9 +245,10 @@ public class DisplayPane extends DynamicListWizard {
ptc.addOrder("title"); ptc.addOrder("title");
while (ptc.next()) { while (ptc.next()) {
ApplicationType providerAppType = ptc.getPortletType().getProviderApplicationType(); ApplicationType providerAppType = ptc.getPortletType().getProviderApplicationType();
if ( providerAppType != null ) { if (providerAppType != null) {
portletTypeSelect.addOption(new Option(ptc.getID().toString(), ptc.getTitle() + portletTypeSelect.addOption(new Option(ptc.getID().toString(), ptc.getTitle() + " ("
" (" + providerAppType.getTitle() + ") ")); + providerAppType.
getTitle() + ") "));
} else { } else {
portletTypeSelect.addOption(new Option(ptc.getID().toString(), ptc.getTitle())); portletTypeSelect.addOption(new Option(ptc.getID().toString(), ptc.getTitle()));
} }
@ -265,22 +272,18 @@ public class DisplayPane extends DynamicListWizard {
BoxPanel tabLayouts = new BoxPanel(BoxPanel.HORIZONTAL, true); BoxPanel tabLayouts = new BoxPanel(BoxPanel.HORIZONTAL, true);
ListModelBuilder lmb = new ListModelBuilder() ListModelBuilder lmb = new ListModelBuilder() {
{
boolean m_isLocked; boolean m_isLocked;
public ListModel makeModel(List l, PageState pageState) public ListModel makeModel(List l, PageState pageState) {
{ return new LayoutListModel(pageState);
return new LayoutListModel (pageState);
} }
public void lock() public void lock() {
{
m_isLocked = true; m_isLocked = true;
} }
public boolean isLocked() public boolean isLocked() {
{
return m_isLocked; return m_isLocked;
} }
}; };
@ -291,15 +294,14 @@ public class DisplayPane extends DynamicListWizard {
m_layouts.setCellRenderer(new LayoutListCellRenderer()); m_layouts.setCellRenderer(new LayoutListCellRenderer());
m_layouts.addChangeListener(new ChangeListener () { m_layouts.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) public void stateChanged(ChangeEvent e) {
{
PageState ps = e.getPageState(); PageState ps = e.getPageState();
String key = (String) ((List) dlw.getListingComponent()) String key = (String) ((List) dlw.getListingComponent())
.getSelectedKey(ps); .getSelectedKey(ps);
BigDecimal bd = new BigDecimal(key); BigDecimal bd = new BigDecimal(key);
PortalTab ptab = PortalTab.retrieveTab(bd); PortalTab ptab = PortalTab.retrieveTab(bd);
String laykey = (String)m_layouts.getSelectedKey(ps); String laykey = (String) m_layouts.getSelectedKey(ps);
Integer lk = new Integer(laykey); Integer lk = new Integer(laykey);
ptab.setLayout(m_layoutNames[lk.intValue()]); ptab.setLayout(m_layoutNames[lk.intValue()]);
ptab.save(); ptab.save();
@ -310,9 +312,8 @@ public class DisplayPane extends DynamicListWizard {
m_mainDisplay.add(tabLayouts); m_mainDisplay.add(tabLayouts);
m_portletAddForm
m_portletAddForm = = new PortletAddForm(portalsiteRL, selectedTabIDRL, new RequestLocal() {
new PortletAddForm(portalsiteRL, selectedTabIDRL, new RequestLocal() {
protected Object initialValue(PageState ps) { protected Object initialValue(PageState ps) {
BigDecimal id = (BigDecimal) ps.getValue(portletTypeParam); BigDecimal id = (BigDecimal) ps.getValue(portletTypeParam);
if (id == null) { if (id == null) {
@ -330,8 +331,8 @@ public class DisplayPane extends DynamicListWizard {
RequestLocal selectedPortletRL = new RequestLocal() { RequestLocal selectedPortletRL = new RequestLocal() {
public Object initialValue(PageState ps) { public Object initialValue(PageState ps) {
BigDecimal portletID = BigDecimal portletID
(BigDecimal)ps.getValue(m_selectedPortletParam); = (BigDecimal) ps.getValue(m_selectedPortletParam);
if (portletID == null) { if (portletID == null) {
return null; return null;
} }
@ -345,8 +346,7 @@ public class DisplayPane extends DynamicListWizard {
ps.setValue(m_selectedPortletParam, null); ps.setValue(m_selectedPortletParam, null);
} }
}; };
m_portletModify = new ApplicationModifyComponent m_portletModify = new ApplicationModifyComponent(selectedPortletRL, true, reset, reset);
(selectedPortletRL, true, reset, reset);
m_renameTabForm = new RenameTabForm(selectedTabIDRL); m_renameTabForm = new RenameTabForm(selectedTabIDRL);
m_deleteTabForm = new DeleteTabForm(selectedTabIDRL); m_deleteTabForm = new DeleteTabForm(selectedTabIDRL);
@ -377,10 +377,9 @@ public class DisplayPane extends DynamicListWizard {
//One other thing, if there is only one tab in the list, //One other thing, if there is only one tab in the list,
//this code preselects it, unless the add tab link has been //this code preselects it, unless the add tab link has been
//clicked. //clicked.
((List) getListingComponent()).setCellRenderer(new ListCellRenderer() { ((List) getListingComponent()).setCellRenderer(new ListCellRenderer() {
public Component getComponent(List list,PageState state, public Component getComponent(List list, PageState state,
Object value,String key, int index,boolean isSelected) { Object value, String key, int index, boolean isSelected) {
Label tabName; Label tabName;
int indent_ctr = 0; int indent_ctr = 0;
@ -399,30 +398,28 @@ public class DisplayPane extends DynamicListWizard {
//If only one tab, select it ONLY if addtablink not selected //If only one tab, select it ONLY if addtablink not selected
// and then get outa here... // and then get outa here...
if(size == 1) if (size == 1) {
{ if ((dlw.getAddLink().isSelected(state)) == false) {
if((dlw.getAddLink().isSelected(state)) == false) list.setSelectedKey(state, key);
{
list.setSelectedKey(state,key);
tabName = new Label(value.toString()); tabName = new Label(value.toString());
container.add(tabName); container.add(tabName);
//Update tab request local //Update tab request local
selectedTabIDRL.set(state,bd); selectedTabIDRL.set(state, bd);
return container; return container;
} }
} } else //more than one tab...
else //more than one tab...
{ {
indent_ctr = 0; indent_ctr = 0;
while(ptcoll.next()) while (ptcoll.next()) {
{
indent_ctr++; indent_ctr++;
if(bd.compareTo(ptcoll.getID()) == 0) //we found tab... if (bd.compareTo(ptcoll.getID()) == 0) //we found tab...
{ {
if(indent_ctr == 1) if (indent_ctr == 1) {
isFirst = true; isFirst = true;
if(indent_ctr == size) }
if (indent_ctr == size) {
isLast = true; isLast = true;
}
break; break;
} }
} }
@ -431,8 +428,7 @@ public class DisplayPane extends DynamicListWizard {
//Code below constructs proper indent for tab //Code below constructs proper indent for tab
StringBuffer buf = new StringBuffer(200); StringBuffer buf = new StringBuffer(200);
for(int i = 0; i < (indent_ctr - 1); i++) for (int i = 0; i < (indent_ctr - 1); i++) {
{
buf.append(FOUR_SPACE_INDENT_STRING); buf.append(FOUR_SPACE_INDENT_STRING);
} }
@ -440,48 +436,45 @@ public class DisplayPane extends DynamicListWizard {
//This could be done below in the particular cases for //This could be done below in the particular cases for
//a slight performance benefit, but putting them //a slight performance benefit, but putting them
//here, together, is easier to understand... //here, together, is easier to understand...
if(isSelected) //This tab name is currently selected... if (isSelected) //This tab name is currently selected...
{ {
tabName = new Label(value.toString()); tabName = new Label(value.toString());
tabName.setFontWeight(Label.BOLD); tabName.setFontWeight(Label.BOLD);
Label labelLeft = new Label(GlobalizationUtil.globalize("cw.workspace.ui.admin.shift_left")); Label labelLeft = new Label(GlobalizationUtil.globalize(
Label labelRight = new Label(GlobalizationUtil.globalize("cw.workspace.ui.admin.shift_right")); "cw.workspace.ui.admin.shift_left"));
Label labelRight = new Label(GlobalizationUtil.globalize(
"cw.workspace.ui.admin.shift_right"));
ControlLink linkLeft = new ControlLink(labelLeft) { ControlLink linkLeft = new ControlLink(labelLeft) {
public void setControlEvent(PageState s) { public void setControlEvent(PageState s) {
s.setControlEvent(dlw,"left","1"); s.setControlEvent(dlw, "left", "1");
} }
}; };
ControlLink linkRight = new ControlLink(labelRight) { ControlLink linkRight = new ControlLink(labelRight) {
public void setControlEvent(PageState s) { public void setControlEvent(PageState s) {
s.setControlEvent(dlw,"right","1"); s.setControlEvent(dlw, "right", "1");
} }
}; };
linkLeft.setClassAttr("shiftleft"); linkLeft.setClassAttr("shiftleft");
linkRight.setClassAttr("shiftright"); linkRight.setClassAttr("shiftright");
if(isFirst) if (isFirst) {
{
container.add(tabName); container.add(tabName);
container.add(linkRight); container.add(linkRight);
} } else if (isLast) {
else if(isLast)
{
container.add(linkLeft); container.add(linkLeft);
container.add(tabName); container.add(tabName);
} } else //This tab is somewhere in the middle...
else //This tab is somewhere in the middle...
{ {
container.add(linkLeft); container.add(linkLeft);
container.add(tabName); container.add(tabName);
container.add(linkRight); container.add(linkRight);
} }
} } else //this tab is NOT selected...return a link
else //this tab is NOT selected...return a link
{ {
String ttab = buf.toString() + value.toString(); String ttab = buf.toString() + value.toString();
tabName = new Label(ttab,false); tabName = new Label(ttab, false);
ControlLink l = new ControlLink(tabName); ControlLink l = new ControlLink(tabName);
container.add(l); container.add(l);
} }
@ -489,7 +482,6 @@ public class DisplayPane extends DynamicListWizard {
} }
}); });
} //end of constructor } //end of constructor
public void register(Page p) { public void register(Page p) {
@ -497,53 +489,55 @@ public class DisplayPane extends DynamicListWizard {
p.addComponentStateParam(this, m_selectedPortletParam); p.addComponentStateParam(this, m_selectedPortletParam);
} }
public void respond(PageState state) throws javax.servlet.ServletException{ public void respond(PageState state) throws javax.servlet.ServletException {
String tabIDstr = String tabIDstr
(String)this.getSelectionModel() = (String) this.getSelectionModel()
.getSelectedKey(state); .getSelectedKey(state);
BigDecimal tabID = new BigDecimal(tabIDstr); BigDecimal tabID = new BigDecimal(tabIDstr);
String name = state.getControlEventName(); String name = state.getControlEventName();
if(name.compareTo("left") == 0) { if (name.compareTo("left") == 0) {
PortalTab ptab = PortalTab.retrieveTab(tabID); PortalTab ptab = PortalTab.retrieveTab(tabID);
PortalSite psite = ptab.getPortalSite(); PortalSite psite = ptab.getPortalSite();
psite.swapTabWithPrevious(ptab); psite.swapTabWithPrevious(ptab);
} else if(name.compareTo("right") == 0) { } else if (name.compareTo("right") == 0) {
PortalTab ptab = PortalTab.retrieveTab(tabID); PortalTab ptab = PortalTab.retrieveTab(tabID);
PortalSite psite = ptab.getPortalSite(); PortalSite psite = ptab.getPortalSite();
psite.swapTabWithNext(ptab); psite.swapTabWithNext(ptab);
} }
} }
public class RenameTabForm extends Form implements FormProcessListener { public class RenameTabForm extends Form implements FormProcessListener {
private TextField currenttabName; private TextField currenttabName;
private Label instruction; private Label instruction;
private Submit button,cancelbutton; private Submit button, cancelbutton;
private RequestLocal m_tabIDRL; private RequestLocal m_tabIDRL;
public RenameTabForm(RequestLocal SelectedTabIDRL) { public RenameTabForm(RequestLocal SelectedTabIDRL) {
super("renametabform"); super("renametabform");
m_tabIDRL = SelectedTabIDRL; m_tabIDRL = SelectedTabIDRL;
instruction = new Label(GlobalizationUtil.globalize("cw.workspace.ui.admin.enter_new_name_for_this_tab_in_text_field")); instruction = new Label(GlobalizationUtil.globalize(
"cw.workspace.ui.admin.enter_new_name_for_this_tab_in_text_field"));
currenttabName = new TextField("CurrentTabName"); currenttabName = new TextField("CurrentTabName");
currenttabName.setDefaultValue(""); currenttabName.setDefaultValue("");
currenttabName.setSize(40); currenttabName.setSize(40);
currenttabName.addValidationListener currenttabName.addValidationListener(new NotNullValidationListener(
(new NotNullValidationListener("Every Tab must have a name!")); "Every Tab must have a name!"));
try { try {
currenttabName.addPrintListener(new PrintListener() { currenttabName.addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
PageState s = e.getPageState(); PageState s = e.getPageState();
BigDecimal tabID = (BigDecimal)m_tabIDRL.get(s); BigDecimal tabID = (BigDecimal) m_tabIDRL.get(s);
PortalTab ptab = PortalTab.retrieveTab(tabID); PortalTab ptab = PortalTab.retrieveTab(tabID);
TextField tf = (TextField)e.getTarget(); TextField tf = (TextField) e.getTarget();
tf.setValue(s,ptab.getTitle()); tf.setValue(s, ptab.getTitle());
} }
}); });
} catch(java.util.TooManyListenersException e) { } } catch (java.util.TooManyListenersException e) {
}
button = new Submit("Rename tab"); button = new Submit("Rename tab");
button.setButtonLabel("Rename tab"); button.setButtonLabel("Rename tab");
cancelbutton = new Submit("Cancel"); cancelbutton = new Submit("Cancel");
@ -558,8 +552,8 @@ public class DisplayPane extends DynamicListWizard {
public void process(FormSectionEvent e) { public void process(FormSectionEvent e) {
PageState s = e.getPageState(); PageState s = e.getPageState();
if(button.isSelected(s)) { if (button.isSelected(s)) {
BigDecimal tabID = (BigDecimal)m_tabIDRL.get(s); BigDecimal tabID = (BigDecimal) m_tabIDRL.get(s);
PortalTab ptab = PortalTab.retrieveTab(tabID); PortalTab ptab = PortalTab.retrieveTab(tabID);
ptab.setTitle(currenttabName.getValue(s).toString()); ptab.setTitle(currenttabName.getValue(s).toString());
ptab.save(); ptab.save();
@ -570,25 +564,26 @@ public class DisplayPane extends DynamicListWizard {
} //end rename form } //end rename form
public class DeleteTabForm extends Form implements FormProcessListener { public class DeleteTabForm extends Form implements FormProcessListener {
private TextField currenttabName; private TextField currenttabName;
private Label instruction; private Label instruction;
private Submit button; private Submit button;
private Submit cancelbutton; private Submit cancelbutton;
private RequestLocal m_tabIDRL; private RequestLocal m_tabIDRL;
public DeleteTabForm(RequestLocal SelectedTabIDRL) { public DeleteTabForm(RequestLocal SelectedTabIDRL) {
super("deletetabform"); super("deletetabform");
m_tabIDRL = SelectedTabIDRL; m_tabIDRL = SelectedTabIDRL;
instruction = new Label(GlobalizationUtil.globalize("cw.workspace.ui.admin.are_you_sure_you_want_to_delete_this_tab")); instruction = new Label(GlobalizationUtil.globalize(
"cw.workspace.ui.admin.are_you_sure_you_want_to_delete_this_tab"));
instruction.addPrintListener(new PrintListener() { instruction.addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
PageState s = e.getPageState(); PageState s = e.getPageState();
String prefixstr = "Are you sure you want to delete the "; String prefixstr = "Are you sure you want to delete the ";
BigDecimal tabID = (BigDecimal)m_tabIDRL.get(s); BigDecimal tabID = (BigDecimal) m_tabIDRL.get(s);
PortalTab ptab = PortalTab.retrieveTab(tabID); PortalTab ptab = PortalTab.retrieveTab(tabID);
Label t = (Label)e.getTarget(); Label t = (Label) e.getTarget();
t.setLabel(prefixstr + ptab.getTitle() + " tab?"); t.setLabel(prefixstr + ptab.getTitle() + " tab?");
} }
}); });
@ -606,8 +601,8 @@ public class DisplayPane extends DynamicListWizard {
public void process(FormSectionEvent e) { public void process(FormSectionEvent e) {
PageState s = e.getPageState(); PageState s = e.getPageState();
if(button.isSelected(s)) { if (button.isSelected(s)) {
BigDecimal tabID = (BigDecimal)m_tabIDRL.get(s); BigDecimal tabID = (BigDecimal) m_tabIDRL.get(s);
PortalTab ptab = PortalTab.retrieveTab(tabID); PortalTab ptab = PortalTab.retrieveTab(tabID);
ptab.delete(); ptab.delete();
getSelectionModel().clearSelection(s); getSelectionModel().clearSelection(s);
@ -618,6 +613,7 @@ public class DisplayPane extends DynamicListWizard {
} //end delete form } //end delete form
private class RenameLinkListener implements ActionListener { private class RenameLinkListener implements ActionListener {
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
PageState ps = event.getPageState(); PageState ps = event.getPageState();
m_editContainer.setVisibleComponent(ps, m_renameTabForm); m_editContainer.setVisibleComponent(ps, m_renameTabForm);
@ -625,19 +621,19 @@ public class DisplayPane extends DynamicListWizard {
} }
private class DeleteLinkListener implements ActionListener { private class DeleteLinkListener implements ActionListener {
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
PageState ps = event.getPageState(); PageState ps = event.getPageState();
m_editContainer.setVisibleComponent(ps, m_deleteTabForm); m_editContainer.setVisibleComponent(ps, m_deleteTabForm);
} }
} }
private class LayoutListModel implements ListModel private class LayoutListModel implements ListModel {
{
Vector vec; Vector vec;
ListIterator vl; ListIterator vl;
LayoutListModel (PageState pageState) LayoutListModel(PageState pageState) {
{
vec = new Vector(); vec = new Vector();
vec.add("W"); vec.add("W");
vec.add("NW"); vec.add("NW");
@ -648,18 +644,15 @@ public class DisplayPane extends DynamicListWizard {
vl = vec.listIterator(); vl = vec.listIterator();
} }
public boolean next() public boolean next() {
{
return vl.hasNext(); return vl.hasNext();
} }
public Object getElement() public Object getElement() {
{
return vl.next(); return vl.next();
} }
public String getKey() public String getKey() {
{
int dex = vl.previousIndex(); int dex = vl.previousIndex();
dex = dex + 1; dex = dex + 1;
//Integer it = new Integer(vl.previousIndex()); //Integer it = new Integer(vl.previousIndex());
@ -668,26 +661,21 @@ public class DisplayPane extends DynamicListWizard {
} }
} }
class LayoutListCellRenderer implements ListCellRenderer class LayoutListCellRenderer implements ListCellRenderer {
{
public Component getComponent public Component getComponent(List list, PageState pageState, Object value, String key,
(List list, PageState pageState, Object value, String key, int index, boolean isSelected) {
int index, boolean isSelected) String val = (String) value;
{
String val = (String)value;
//check if selected...if not selected //check if selected...if not selected
//find out what index we are... //find out what index we are...
//then set an attribute on the link so that it is replaced //then set an attribute on the link so that it is replaced
//with an image link in the stylesheet. //with an image link in the stylesheet.
//if selected, return a label with a selected attr and value... //if selected, return a label with a selected attr and value...
if(isSelected) if (isSelected) {
{
Label label = new Label(val); Label label = new Label(val);
label.setClassAttr(val); label.setClassAttr(val);
return label; return label;
} } else {
else
{
ControlLink link = new ControlLink(val); ControlLink link = new ControlLink(val);
link.setClassAttr(val); link.setClassAttr(val);
link.setStyleAttr("HooHaH"); link.setStyleAttr("HooHaH");
@ -697,5 +685,4 @@ public class DisplayPane extends DynamicListWizard {
} }
} }
} }

View File

@ -15,7 +15,6 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.portalworkspace.ui; package com.arsdigita.portalworkspace.ui;
import com.arsdigita.bebop.Form; import com.arsdigita.bebop.Form;
@ -63,15 +62,17 @@ public class ApplicationSelector extends Form {
/** /**
* Convenient Constructor * Convenient Constructor
*
* @param type * @param type
* @param app * @param app
*/ */
public ApplicationSelector(ApplicationType type,DomainObjectParameter app) { public ApplicationSelector(ApplicationType type, DomainObjectParameter app) {
this(type, app, null); this(type, app, null);
} }
/** /**
* Constructor * Constructor
*
* @param type * @param type
* @param app * @param app
* @param privilege * @param privilege
@ -85,8 +86,7 @@ public class ApplicationSelector extends Form {
m_app = app; m_app = app;
m_privilege = privilege; m_privilege = privilege;
s_log.debug("displayed applications will be filtered by privilege " + s_log.debug("displayed applications will be filtered by privilege " + m_privilege);
m_privilege);
m_apps = new SingleSelect(new DomainObjectParameter("apps")); m_apps = new SingleSelect(new DomainObjectParameter("apps"));
m_apps.addValidationListener(new NotNullValidationListener()); m_apps.addValidationListener(new NotNullValidationListener());
@ -108,6 +108,7 @@ public class ApplicationSelector extends Form {
* *
*/ */
private class AppSubmissionListener implements FormSubmissionListener { private class AppSubmissionListener implements FormSubmissionListener {
public void submitted(FormSectionEvent e) public void submitted(FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
if (m_buttons.getCancelButton().isSelected(e.getPageState())) { if (m_buttons.getCancelButton().isSelected(e.getPageState())) {
@ -152,11 +153,12 @@ public class ApplicationSelector extends Form {
if (user == null) { if (user == null) {
user = Kernel.getPublicUser(); user = Kernel.getPublicUser();
} }
PermissionService.filterObjects(apps,m_privilege, user.getOID()); PermissionService.filterObjects(apps, m_privilege, user.getOID());
} }
apps.addOrder("primaryURL"); apps.addOrder("primaryURL");
SingleSelect t = (SingleSelect) e.getTarget(); SingleSelect t = (SingleSelect) e.getTarget();
t.clearOptions();
t.addOption(new Option(null, "--select one--")); t.addOption(new Option(null, "--select one--"));
while (apps.next()) { while (apps.next()) {
Application app = apps.getApplication(); Application app = apps.getApplication();

View File

@ -15,7 +15,6 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.portalworkspace.ui; package com.arsdigita.portalworkspace.ui;
import java.util.TooManyListenersException; import java.util.TooManyListenersException;
@ -81,6 +80,7 @@ public class LayoutForm extends Form implements FormProcessListener,
m_layout.addPrintListener(new PrintListener() { m_layout.addPrintListener(new PrintListener() {
public void prepare(PrintEvent ev) { public void prepare(PrintEvent ev) {
SingleSelect target = (SingleSelect) ev.getTarget(); SingleSelect target = (SingleSelect) ev.getTarget();
target.clearOptions();
DomainCollection layouts = PageLayout.retrieveAll(); DomainCollection layouts = PageLayout.retrieveAll();
layouts.addOrder(PageLayout.TITLE); layouts.addOrder(PageLayout.TITLE);
while (layouts.next()) { while (layouts.next()) {

View File

@ -12,7 +12,6 @@
* rights and limitations under the License. * rights and limitations under the License.
* *
*/ */
package com.arsdigita.portalworkspace.ui; package com.arsdigita.portalworkspace.ui;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -59,6 +58,7 @@ public class PortletTypeForm extends Form {
PageState pageState = e.getPageState(); PageState pageState = e.getPageState();
OptionGroup optionGroup = (OptionGroup) e.getTarget(); OptionGroup optionGroup = (OptionGroup) e.getTarget();
optionGroup.clearOptions();
PortletTypeCollection portletTypes = PortletType PortletTypeCollection portletTypes = PortletType
.retrieveAllPortletTypes(); .retrieveAllPortletTypes();

View File

@ -15,7 +15,6 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.portalworkspace.ui.admin; package com.arsdigita.portalworkspace.ui.admin;
import java.math.BigDecimal; import java.math.BigDecimal;

View File

@ -15,7 +15,6 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.portalworkspace.ui.admin; package com.arsdigita.portalworkspace.ui.admin;
import java.util.TooManyListenersException; import java.util.TooManyListenersException;
@ -41,13 +40,10 @@ import com.arsdigita.util.UncheckedWrapperException;
import com.arsdigita.web.Application; import com.arsdigita.web.Application;
import com.arsdigita.web.ui.ApplicationConfigFormSection; import com.arsdigita.web.ui.ApplicationConfigFormSection;
// Referenced in Initializer. // Referenced in Initializer.
// No other referebce found. // No other referebce found.
// TODO: What happens if omitted? // TODO: What happens if omitted?
// (2013-02-10pb) // (2013-02-10pb)
/** /**
* *
* *
@ -74,6 +70,7 @@ public class WorkspaceConfigFormSection extends ApplicationConfigFormSection {
m_layout.addPrintListener(new PrintListener() { m_layout.addPrintListener(new PrintListener() {
public void prepare(PrintEvent ev) { public void prepare(PrintEvent ev) {
SingleSelect target = (SingleSelect) ev.getTarget(); SingleSelect target = (SingleSelect) ev.getTarget();
target.clearOptions();
DomainCollection layouts = PageLayout.retrieveAll(); DomainCollection layouts = PageLayout.retrieveAll();
layouts.addOrder(PageLayout.TITLE); layouts.addOrder(PageLayout.TITLE);
while (layouts.next()) { while (layouts.next()) {

View File

@ -62,6 +62,7 @@ public class WorkspaceCreateForm extends ApplicationCreateForm<Workspace> {
layout.addPrintListener(new PrintListener() { layout.addPrintListener(new PrintListener() {
public void prepare(final PrintEvent event) { public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget(); final SingleSelect target = (SingleSelect) event.getTarget();
target.clearOptions();
final DomainCollection layouts = PageLayout.retrieveAll(); final DomainCollection layouts = PageLayout.retrieveAll();
layouts.addOrder(PageLayout.TITLE); layouts.addOrder(PageLayout.TITLE);
while (layouts.next()) { while (layouts.next()) {

View File

@ -12,7 +12,6 @@
* rights and limitations under the License. * rights and limitations under the License.
* *
*/ */
package com.arsdigita.portalworkspace.ui.portlet; package com.arsdigita.portalworkspace.ui.portlet;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -66,6 +65,7 @@ public class ContentDirectoryPortletEditor extends PortletConfigFormSection {
/** /**
* Constructor * Constructor
*
* @param resType * @param resType
* @param parentAppRL * @param parentAppRL
*/ */
@ -169,8 +169,10 @@ public class ContentDirectoryPortletEditor extends PortletConfigFormSection {
* *
*/ */
private class CategoryPrintListener implements PrintListener { private class CategoryPrintListener implements PrintListener {
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
SingleSelect target = (SingleSelect) e.getTarget(); SingleSelect target = (SingleSelect) e.getTarget();
target.clearOptions();
Application app = Web.getWebContext().getApplication(); Application app = Web.getWebContext().getApplication();
Category root = Category.getRootForObject(app, getUseContext()); Category root = Category.getRootForObject(app, getUseContext());

View File

@ -15,7 +15,6 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.portalworkspace.ui.portlet; package com.arsdigita.portalworkspace.ui.portlet;
import com.arsdigita.bebop.ColumnPanel; import com.arsdigita.bebop.ColumnPanel;
@ -39,8 +38,8 @@ import com.arsdigita.portal.Portlet;
/** /**
* @author <a href="https://sourceforge.net/users/terry_permeance/">terry_permeance</a> * @author <a href="https://sourceforge.net/users/terry_permeance/">terry_permeance</a>
*/ */
public class FlashPortletEditor extends PortletConfigFormSection public class FlashPortletEditor extends PortletConfigFormSection {
{
private TextField m_backgroundColour; private TextField m_backgroundColour;
private TextField m_detectKey; private TextField m_detectKey;
@ -63,25 +62,23 @@ public class FlashPortletEditor extends PortletConfigFormSection
private TextField m_xiRedirectUrl; private TextField m_xiRedirectUrl;
public FlashPortletEditor(ResourceType resType, RequestLocal parentAppRL) public FlashPortletEditor(ResourceType resType, RequestLocal parentAppRL) {
{
super(resType, parentAppRL); super(resType, parentAppRL);
} }
public FlashPortletEditor(RequestLocal application) public FlashPortletEditor(RequestLocal application) {
{
super(application); super(application);
} }
protected void addWidgets() protected void addWidgets() {
{
super.addWidgets(); super.addWidgets();
m_file = this.addTextField(FlashPortlet.SWF_FILE, "SWF file", 64, 2048, true); m_file = this.addTextField(FlashPortlet.SWF_FILE, "SWF file", 64, 2048, true);
m_width = this.addTextField(FlashPortlet.WIDTH, "Width", 8, 8, true); m_width = this.addTextField(FlashPortlet.WIDTH, "Width", 8, 8, true);
m_height = this.addTextField(FlashPortlet.HEIGHT, "Height", 8, 8, true); m_height = this.addTextField(FlashPortlet.HEIGHT, "Height", 8, 8, true);
m_version = this.addTextField(FlashPortlet.VERSION, "Minimum Flash version", 8, 8, true); m_version = this.addTextField(FlashPortlet.VERSION, "Minimum Flash version", 8, 8, true);
m_backgroundColour = this.addTextField(FlashPortlet.BACKGROUND_COLOUR, "Background colour", 7, 7, true); m_backgroundColour = this.addTextField(FlashPortlet.BACKGROUND_COLOUR, "Background colour",
7, 7, true);
m_backgroundColour.addValidationListener(new HTMLColourCodeValidationListener()); m_backgroundColour.addValidationListener(new HTMLColourCodeValidationListener());
m_quality = this.addSingleSelect(FlashPortlet.QUALITY, "Quality", false); m_quality = this.addSingleSelect(FlashPortlet.QUALITY, "Quality", false);
@ -96,18 +93,19 @@ public class FlashPortletEditor extends PortletConfigFormSection
m_variables = this.addTextArea(FlashPortlet.VARIABLES, "Variables", 4, 64, false); m_variables = this.addTextArea(FlashPortlet.VARIABLES, "Variables", 4, 64, false);
m_detectKey = this.addTextField(FlashPortlet.DETECT_KEY, "Detect key", 32, 32, false); m_detectKey = this.addTextField(FlashPortlet.DETECT_KEY, "Detect key", 32, 32, false);
m_redirectUrl = this.addTextField(FlashPortlet.REDIRECT_URL, "Redirect URL", 64, 2048, false); m_redirectUrl = this.
m_xiRedirectUrl = this.addTextField(FlashPortlet.XI_REDIRECT_URL, "XI Redirect URL", 64, 2048, false); addTextField(FlashPortlet.REDIRECT_URL, "Redirect URL", 64, 2048, false);
m_xiRedirectUrl = this.addTextField(FlashPortlet.XI_REDIRECT_URL, "XI Redirect URL", 64,
2048, false);
add(new Link("What do these fields mean?", "http://blog.deconcept.com/swfobject/"), ColumnPanel.FULL_WIDTH|ColumnPanel.CENTER); add(new Link("What do these fields mean?", "http://blog.deconcept.com/swfobject/"),
ColumnPanel.FULL_WIDTH | ColumnPanel.CENTER);
} }
protected void initWidgets(PageState state, Portlet portlet) throws FormProcessException protected void initWidgets(PageState state, Portlet portlet) throws FormProcessException {
{
super.initWidgets(state, portlet); super.initWidgets(state, portlet);
if (portlet != null) if (portlet != null) {
{
FlashPortlet flashPortlet = (FlashPortlet) portlet; FlashPortlet flashPortlet = (FlashPortlet) portlet;
// Load the form from the portlet // Load the form from the portlet
@ -123,12 +121,11 @@ public class FlashPortletEditor extends PortletConfigFormSection
m_width.setValue(state, flashPortlet.getWidth()); m_width.setValue(state, flashPortlet.getWidth());
m_xiRedirectUrl.setValue(state, flashPortlet.getXiRedirectUrl()); m_xiRedirectUrl.setValue(state, flashPortlet.getXiRedirectUrl());
m_quality.setValue(state, flashPortlet.getQuality()); m_quality.setValue(state, flashPortlet.getQuality());
} } else {
else
{
// Set defaults // Set defaults
m_backgroundColour.setValue(state, "#ffffff"); m_backgroundColour.setValue(state, "#ffffff");
m_file.setValue(state, "http://www.adobe.com/support/flashplayer/ts/documents/tn_15507/flashplayerversion.swf"); m_file.setValue(state,
"http://www.adobe.com/support/flashplayer/ts/documents/tn_15507/flashplayerversion.swf");
m_width.setValue(state, "100%"); m_width.setValue(state, "100%");
m_height.setValue(state, "100%"); m_height.setValue(state, "100%");
m_version.setValue(state, "8.0"); m_version.setValue(state, "8.0");
@ -137,8 +134,7 @@ public class FlashPortletEditor extends PortletConfigFormSection
} }
} }
protected void processWidgets(PageState state, Portlet portlet) throws FormProcessException protected void processWidgets(PageState state, Portlet portlet) throws FormProcessException {
{
super.processWidgets(state, portlet); super.processWidgets(state, portlet);
FlashPortlet flashPortlet = (FlashPortlet) portlet; FlashPortlet flashPortlet = (FlashPortlet) portlet;
@ -159,32 +155,27 @@ public class FlashPortletEditor extends PortletConfigFormSection
/** /**
* Add a new text field. * Add a new text field.
* *
* @param name * @param name the name of the parameter
* the name of the parameter * @param label the label to be displayed
* @param label * @param size the visible size of the text field
* the label to be displayed * @param maxLength the maximum length of text that can be entered
* @param size * @param mandatory denotes whether this text field requires a value
* the visible size of the text field
* @param maxLength
* the maximum length of text that can be entered
* @param mandatory
* denotes whether this text field requires a value
* @return the text field * @return the text field
*/ */
private TextField addTextField(String name, String label, int size, int maxLength, boolean mandatory) private TextField addTextField(String name, String label, int size, int maxLength,
{ boolean mandatory) {
TextField field = new TextField(new StringParameter(name)); TextField field = new TextField(new StringParameter(name));
field.setSize(size); field.setSize(size);
field.setMaxLength(maxLength); field.setMaxLength(maxLength);
// Add validation // Add validation
if (mandatory) if (mandatory) {
{
field.addValidationListener(new NotEmptyValidationListener()); field.addValidationListener(new NotEmptyValidationListener());
} }
// Add to the form // Add to the form
add(mandatory ? new Label(label + ":", Label.BOLD) : new Label(label + ":"), ColumnPanel.RIGHT); add(mandatory ? new Label(label + ":", Label.BOLD) : new Label(label + ":"),
ColumnPanel.RIGHT);
add(field); add(field);
return field; return field;
} }
@ -192,30 +183,24 @@ public class FlashPortletEditor extends PortletConfigFormSection
/** /**
* Add a new text area. * Add a new text area.
* *
* @param name * @param name the name of the parameter
* the name of the parameter * @param label the label to be displayed
* @param label * @param rows the visible rows
* the label to be displayed * @param cols the visible cols
* @param rows * @param mandatory denotes whether this text field requires a value
* the visible rows
* @param cols
* the visible cols
* @param mandatory
* denotes whether this text field requires a value
* @return the text area * @return the text area
*/ */
private TextArea addTextArea(String name, String label, int rows, int cols, boolean mandatory) private TextArea addTextArea(String name, String label, int rows, int cols, boolean mandatory) {
{
TextArea field = new TextArea(new StringParameter(name), rows, cols, TextArea.SOFT); TextArea field = new TextArea(new StringParameter(name), rows, cols, TextArea.SOFT);
// Add validation // Add validation
if (mandatory) if (mandatory) {
{
field.addValidationListener(new NotEmptyValidationListener()); field.addValidationListener(new NotEmptyValidationListener());
} }
// Add to the form // Add to the form
add(mandatory ? new Label(label + ":", Label.BOLD) : new Label(label + ":"), ColumnPanel.RIGHT); add(mandatory ? new Label(label + ":", Label.BOLD) : new Label(label + ":"),
ColumnPanel.RIGHT);
add(field); add(field);
return field; return field;
} }
@ -223,26 +208,22 @@ public class FlashPortletEditor extends PortletConfigFormSection
/** /**
* Add a new single select. * Add a new single select.
* *
* @param name * @param name the name of the parameter
* the name of the parameter * @param label the label to be displayed
* @param label * @param mandatory denotes whether this text field requires a value
* the label to be displayed
* @param mandatory
* denotes whether this text field requires a value
* @return the text area * @return the text area
*/ */
private SingleSelect addSingleSelect(String name, String label, boolean mandatory) private SingleSelect addSingleSelect(String name, String label, boolean mandatory) {
{
SingleSelect field = new SingleSelect(new StringParameter(name)); SingleSelect field = new SingleSelect(new StringParameter(name));
// Add validation // Add validation
if (mandatory) if (mandatory) {
{
field.addValidationListener(new NotEmptyValidationListener()); field.addValidationListener(new NotEmptyValidationListener());
} }
// Add to the form // Add to the form
add(mandatory ? new Label(label + ":", Label.BOLD) : new Label(label + ":"), ColumnPanel.RIGHT); add(mandatory ? new Label(label + ":", Label.BOLD) : new Label(label + ":"),
ColumnPanel.RIGHT);
add(field); add(field);
return field; return field;
} }

View File

@ -12,7 +12,6 @@
* rights and limitations under the License. * rights and limitations under the License.
* *
*/ */
package com.arsdigita.portalworkspace.ui.portlet; package com.arsdigita.portalworkspace.ui.portlet;
import java.util.Iterator; import java.util.Iterator;
@ -112,6 +111,7 @@ public class RSSFeedPortletBrowserForm extends Form {
m_hosts.addPrintListener(new PrintListener() { m_hosts.addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
SingleSelect group = (SingleSelect) e.getTarget(); SingleSelect group = (SingleSelect) e.getTarget();
group.clearOptions();
Iterator hosts = RSSFeedPortletHelper.getACSJHosts(); Iterator hosts = RSSFeedPortletHelper.getACSJHosts();
while (hosts.hasNext()) { while (hosts.hasNext()) {
@ -129,6 +129,7 @@ public class RSSFeedPortletBrowserForm extends Form {
m_feeds.addPrintListener(new PrintListener() { m_feeds.addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
SingleSelect group = (SingleSelect) e.getTarget(); SingleSelect group = (SingleSelect) e.getTarget();
group.clearOptions();
Iterator feeds = (Iterator) m_feed.get(e.getPageState()); Iterator feeds = (Iterator) m_feed.get(e.getPageState());
while (feeds != null && feeds.hasNext()) { while (feeds != null && feeds.hasNext()) {

View File

@ -17,7 +17,8 @@
* *
*/ */
package com.arsdigita.simplesurvey.ui.admin; package com.arsdigita.simplesurvey.ui.admin;
import com.arsdigita.simplesurvey.util.GlobalizationUtil ;
import com.arsdigita.simplesurvey.util.GlobalizationUtil;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormProcessListener;
@ -66,7 +67,6 @@ public class AnswerValuesPanel extends SimpleContainer {
// Displays a list of the multiple choice answers grouped by question // Displays a list of the multiple choice answers grouped by question
// Each of the answers contains a link that leads to a drop-down value selection widget // Each of the answers contains a link that leads to a drop-down value selection widget
private SurveySelectionModel m_survey; private SurveySelectionModel m_survey;
private static final String QUESTION_TEXT = "questionText"; private static final String QUESTION_TEXT = "questionText";
private static final String ANSWER_TEXT = "answerText"; private static final String ANSWER_TEXT = "answerText";
@ -85,8 +85,9 @@ public class AnswerValuesPanel extends SimpleContainer {
private ActionLink m_complete; private ActionLink m_complete;
private Link m_back; private Link m_back;
private static org.apache.log4j.Logger s_log = private static org.apache.log4j.Logger s_log
org.apache.log4j.Logger.getLogger(AnswerValuesPanel.class.getName()); = org.apache.log4j.Logger.getLogger(
AnswerValuesPanel.class.getName());
private DataTable m_answerTable; private DataTable m_answerTable;
@ -98,38 +99,41 @@ public class AnswerValuesPanel extends SimpleContainer {
m_questionText = new RequestLocal(); m_questionText = new RequestLocal();
m_answerValue = new RequestLocal(); m_answerValue = new RequestLocal();
m_complete = new ActionLink( (String) GlobalizationUtil.globalize("simplesurvey.ui.admin.back_to_question_list").localize()); m_complete = new ActionLink((String) GlobalizationUtil.globalize(
"simplesurvey.ui.admin.back_to_question_list").localize());
m_complete.addActionListener(new ActionListener() { m_complete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState(); PageState ps = e.getPageState();
m_answerTable.setVisible(ps, true); m_answerTable.setVisible(ps, true);
m_answerValuesForm.setVisible(ps, false); m_answerValuesForm.setVisible(ps, false);
m_complete.setVisible(ps,false); m_complete.setVisible(ps, false);
m_back.setVisible(ps, true); m_back.setVisible(ps, true);
} }
}); });
m_back = new Link(new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.back_to_survey_list")), "../admin"); m_back = new Link(new Label(GlobalizationUtil.globalize(
"simplesurvey.ui.admin.back_to_survey_list")), "../admin");
add(m_complete); add(m_complete);
add(m_back); add(m_back);
setupAnswerTable(); setupAnswerTable();
setupAnswerValuesForm(); setupAnswerValuesForm();
} }
public void register (Page p) {
p.setVisibleDefault(m_answerValuesForm,false); public void register(Page p) {
p.setVisibleDefault(m_answerValuesForm, false);
m_optionID = new BigDecimalParameter("option_id"); m_optionID = new BigDecimalParameter("option_id");
m_surveyID = new BigDecimalParameter("survey_id"); m_surveyID = new BigDecimalParameter("survey_id");
p.addGlobalStateParam(m_optionID); p.addGlobalStateParam(m_optionID);
p.addGlobalStateParam(m_surveyID); p.addGlobalStateParam(m_surveyID);
p.addRequestListener( new RequestListener() { p.addRequestListener(new RequestListener() {
public void pageRequested(RequestEvent e) { public void pageRequested(RequestEvent e) {
PageState ps = e.getPageState(); PageState ps = e.getPageState();
if ( ps.getValue(m_optionID) == null || if (ps.getValue(m_optionID) == null || m_answerValuesForm.getFormData(ps).
m_answerValuesForm.getFormData(ps).isSubmission()) { isSubmission()) {
m_answerTable.setVisible(ps, true); m_answerTable.setVisible(ps, true);
m_answerValuesForm.setVisible(ps, false); m_answerValuesForm.setVisible(ps, false);
m_complete.setVisible(ps,false); m_complete.setVisible(ps, false);
m_back.setVisible(ps, true); m_back.setVisible(ps, true);
} /*else { } /*else {
m_answerTable.setVisible(ps, false); m_answerTable.setVisible(ps, false);
@ -148,6 +152,7 @@ public class AnswerValuesPanel extends SimpleContainer {
} }
dq.close(); dq.close();
}*/ }*/
} }
}); });
} }
@ -156,16 +161,17 @@ public class AnswerValuesPanel extends SimpleContainer {
String s = (String) m_questionText.get(ps); String s = (String) m_questionText.get(ps);
return s.substring(6, s.length()); return s.substring(6, s.length());
} }
private String getAnswerText(PageState ps) { private String getAnswerText(PageState ps) {
String s = (String) m_answerText.get(ps); String s = (String) m_answerText.get(ps);
return s; return s;
} }
private BigDecimal getAnswerValue(PageState ps) { private BigDecimal getAnswerValue(PageState ps) {
BigDecimal bi = (BigDecimal) m_answerValue.get(ps); BigDecimal bi = (BigDecimal) m_answerValue.get(ps);
return bi; return bi;
} }
private void setupAnswerTable() { private void setupAnswerTable() {
// This is the table that holds the list of all answer options in the survey // This is the table that holds the list of all answer options in the survey
@ -174,12 +180,12 @@ public class AnswerValuesPanel extends SimpleContainer {
TableColumn c1 = m_answerTable.addColumn("simplesurvey.ui.admin.question", QUESTION_TEXT, TableColumn c1 = m_answerTable.addColumn("simplesurvey.ui.admin.question", QUESTION_TEXT,
false, new QuestionTextRenderer()); false, new QuestionTextRenderer());
TableColumn c2 = m_answerTable.addColumn("simplesurvey.ui.admin.answer", ANSWER_TEXT); TableColumn c2 = m_answerTable.addColumn("simplesurvey.ui.admin.answer", ANSWER_TEXT);
TableColumn c3 = m_answerTable.addColumn("simplesurvey.ui.admin.current_value", ANSWER_VALUE); TableColumn c3 = m_answerTable.
addColumn("simplesurvey.ui.admin.current_value", ANSWER_VALUE);
c1.setHeaderRenderer(new GlobalizedHeaderRenderer()); c1.setHeaderRenderer(new GlobalizedHeaderRenderer());
c2.setHeaderRenderer(new GlobalizedHeaderRenderer()); c2.setHeaderRenderer(new GlobalizedHeaderRenderer());
c3.setHeaderRenderer(new GlobalizedHeaderRenderer()); c3.setHeaderRenderer(new GlobalizedHeaderRenderer());
// Add a single select box widget to each possible answer // Add a single select box widget to each possible answer
// The admin can select a point value for each answer // The admin can select a point value for each answer
TableColumn editValueColumn = new TableColumn(); TableColumn editValueColumn = new TableColumn();
@ -189,9 +195,10 @@ public class AnswerValuesPanel extends SimpleContainer {
add(m_answerTable); add(m_answerTable);
} }
private BigDecimal getSurveyID(PageState ps) { private BigDecimal getSurveyID(PageState ps) {
BigDecimal surveyID = null; BigDecimal surveyID = null;
if ( ps.getValue(m_surveyID) == null ) { if (ps.getValue(m_surveyID) == null) {
Survey s = m_survey.getSelectedSurvey(ps); Survey s = m_survey.getSelectedSurvey(ps);
surveyID = s.getID(); surveyID = s.getID();
} else { } else {
@ -204,7 +211,8 @@ public class AnswerValuesPanel extends SimpleContainer {
m_answerValuesForm = new AnswerValuesForm(); m_answerValuesForm = new AnswerValuesForm();
add(m_answerValuesForm); add(m_answerValuesForm);
} }
private class AnswerValueActionListener extends TableActionAdapter{
private class AnswerValueActionListener extends TableActionAdapter {
public void cellSelected(TableActionEvent e) { public void cellSelected(TableActionEvent e) {
PageState ps = e.getPageState(); PageState ps = e.getPageState();
@ -219,17 +227,18 @@ public class AnswerValuesPanel extends SimpleContainer {
DataQuery dq = SessionManager.getSession().retrieveQuery(query); DataQuery dq = SessionManager.getSession().retrieveQuery(query);
dq.setParameter("optionID", optionID); dq.setParameter("optionID", optionID);
if ( dq.next()) { if (dq.next()) {
m_questionText.set(ps, (String) dq.get(QUESTION_TEXT)); m_questionText.set(ps, (String) dq.get(QUESTION_TEXT));
m_answerText.set(ps, (String) dq.get(ANSWER_TEXT)); m_answerText.set(ps, (String) dq.get(ANSWER_TEXT));
m_answerValue.set(ps, (BigDecimal) dq.get(ANSWER_VALUE)); m_answerValue.set(ps, (BigDecimal) dq.get(ANSWER_VALUE));
m_select.setValue(ps,getAnswerValue(ps)); m_select.setValue(ps, getAnswerValue(ps));
} }
dq.close(); dq.close();
} }
} }
private class AnswerValuesForm extends Form { private class AnswerValuesForm extends Form {
private AnswerValuesForm() { private AnswerValuesForm() {
@ -271,28 +280,35 @@ public class AnswerValuesPanel extends SimpleContainer {
addInitListener(new AnswerValuesInitListener()); addInitListener(new AnswerValuesInitListener());
} }
} }
private class AnswerValuesProcessListener implements FormProcessListener { private class AnswerValuesProcessListener implements FormProcessListener {
public void process(FormSectionEvent e) throws FormProcessException { public void process(FormSectionEvent e) throws FormProcessException {
PageState ps = e.getPageState(); PageState ps = e.getPageState();
FormData fd = e.getFormData(); FormData fd = e.getFormData();
BigDecimal optionID = (BigDecimal) ps.getValue(m_optionID); BigDecimal optionID = (BigDecimal) ps.getValue(m_optionID);
BigDecimal answerValue = new BigDecimal((String) fd.get(ANSWER_VALUE)); BigDecimal answerValue = new BigDecimal((String) fd.get(ANSWER_VALUE));
DataOperation dao = SessionManager.getSession().retrieveDataOperation("com.arsdigita.simplesurvey.updateAnswerValue"); DataOperation dao = SessionManager.getSession().retrieveDataOperation(
"com.arsdigita.simplesurvey.updateAnswerValue");
dao.setParameter("optionID", optionID); dao.setParameter("optionID", optionID);
dao.setParameter("answerValue", answerValue); dao.setParameter("answerValue", answerValue);
dao.execute(); dao.execute();
ps.setValue(m_optionID, null); ps.setValue(m_optionID, null);
} }
} }
private class AnswerValuesInitListener implements FormInitListener { private class AnswerValuesInitListener implements FormInitListener {
public void init(FormSectionEvent e) throws FormProcessException { public void init(FormSectionEvent e) throws FormProcessException {
PageState ps = e.getPageState(); PageState ps = e.getPageState();
s_log.warn("Setting value of select to " + getAnswerValue(ps)); s_log.warn("Setting value of select to " + getAnswerValue(ps));
m_select.setValue(ps, getAnswerValue(ps)); m_select.setValue(ps, getAnswerValue(ps));
} }
} }
private class GlobalizedHeaderRenderer implements TableCellRenderer { private class GlobalizedHeaderRenderer implements TableCellRenderer {
public Component getComponent(Table table, PageState state, Object value, public Component getComponent(Table table, PageState state, Object value,
boolean isSelected, Object key, int row, boolean isSelected, Object key, int row,
int column) { int column) {
@ -304,23 +320,26 @@ public class AnswerValuesPanel extends SimpleContainer {
return label; return label;
} }
} }
private class QuestionTextRenderer implements TableCellRenderer { private class QuestionTextRenderer implements TableCellRenderer {
@Override @Override
public Component getComponent(Table table, PageState state, Object value, public Component getComponent(Table table, PageState state, Object value,
boolean isSelected, Object key, int row, boolean isSelected, Object key, int row,
int column) { int column) {
if ( ! isLocked() && table != null && table.isLocked() ) { if (!isLocked() && table != null && table.isLocked()) {
lock(); lock();
} }
if ( value == null ) { if (value == null) {
return new Label(""); return new Label("");
} }
String question = (String) value; String question = (String) value;
// Cut off the 6 chars "label=" stored in the db // Cut off the 6 chars "label=" stored in the db
return new Label(question.substring(6,question.length())); return new Label(question.substring(6, question.length()));
} }
} }
private class EditLinkRenderer implements TableCellRenderer { private class EditLinkRenderer implements TableCellRenderer {
@Override @Override
@ -328,10 +347,10 @@ public class AnswerValuesPanel extends SimpleContainer {
boolean isSelected, Object key, int row, boolean isSelected, Object key, int row,
int column) { int column) {
if ( ! isLocked() && table != null && table.isLocked() ) { if (!isLocked() && table != null && table.isLocked()) {
lock(); lock();
} }
if ( value == null ) { if (value == null) {
return new Label(""); return new Label("");
} }
/*Link l = new Link(new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.edit_value")),"../admin"); /*Link l = new Link(new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.edit_value")),"../admin");
@ -342,17 +361,21 @@ public class AnswerValuesPanel extends SimpleContainer {
l.setVar("option_id", ((BigDecimal) key).toString()); l.setVar("option_id", ((BigDecimal) key).toString());
return l; */ return l; */
ControlLink cl = new ControlLink(new Label (GlobalizationUtil.globalize("simplesurvey.ui.admin.edit_value"))); ControlLink cl = new ControlLink(new Label(GlobalizationUtil.globalize(
"simplesurvey.ui.admin.edit_value")));
return cl; return cl;
} }
} }
private class AnswerListingBuilder implements DataQueryBuilder { private class AnswerListingBuilder implements DataQueryBuilder {
private final static String KEY_COLUMN = "optionID"; private final static String KEY_COLUMN = "optionID";
public boolean m_locked; public boolean m_locked;
public AnswerListingBuilder() { public AnswerListingBuilder() {
super(); super();
} }
public DataQuery makeDataQuery(DataTable t, PageState ps) { public DataQuery makeDataQuery(DataTable t, PageState ps) {
final String query = "com.arsdigita.simplesurvey.getAnswerOptions"; final String query = "com.arsdigita.simplesurvey.getAnswerOptions";
DataQuery dq = SessionManager.getSession().retrieveQuery(query); DataQuery dq = SessionManager.getSession().retrieveQuery(query);
@ -364,9 +387,11 @@ public class AnswerValuesPanel extends SimpleContainer {
public String getKeyColumn() { public String getKeyColumn() {
return KEY_COLUMN; return KEY_COLUMN;
} }
public void lock() { public void lock() {
m_locked = true; m_locked = true;
} }
public boolean isLocked() { public boolean isLocked() {
return m_locked; return m_locked;
} }

View File

@ -489,6 +489,8 @@ public class SiteForm extends Form {
@Override @Override
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
final SingleSelect target = (SingleSelect) e.getTarget(); final SingleSelect target = (SingleSelect) e.getTarget();
target.clearOptions();
ApplicationCollection customApps; ApplicationCollection customApps;
target.addOption(new Option(DEFAULT_APP, target.addOption(new Option(DEFAULT_APP,
@ -525,6 +527,7 @@ public class SiteForm extends Form {
@Override @Override
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
SingleSelect target = (SingleSelect) e.getTarget(); SingleSelect target = (SingleSelect) e.getTarget();
target.clearOptions();
PageState state = e.getPageState(); PageState state = e.getPageState();
Map themes = Subsite.getConfig().getThemes(); Map themes = Subsite.getConfig().getThemes();
Set entrySet = themes.entrySet(); Set entrySet = themes.entrySet();

View File

@ -142,6 +142,8 @@ public class ThemeControlPanel extends SelectionPanel
@Override @Override
public void prepare(final PrintEvent event) { public void prepare(final PrintEvent event) {
final SingleSelect target = (SingleSelect) event.getTarget(); final SingleSelect target = (SingleSelect) event.getTarget();
target.clearOptions();
final DataCollection options = SessionManager final DataCollection options = SessionManager
.getSession() .getSession()
.retrieve(Theme.BASE_DATA_OBJECT_TYPE); .retrieve(Theme.BASE_DATA_OBJECT_TYPE);

View File

@ -103,15 +103,16 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
try { try {
HttpServletRequest request = state.getRequest(); HttpServletRequest request = state.getRequest();
id = new BigDecimal(request.getParameter(Webpage.ID)); id = new BigDecimal(request.getParameter(Webpage.ID));
} } catch (Exception ex) {
catch (Exception ex) {
} }
m_createForm.setVisible(state, id == null); m_createForm.setVisible(state, id == null);
m_editForm.setVisible(state, id != null); m_editForm.setVisible(state, id != null);
super.generateXML(state, parent); super.generateXML(state, parent);
} }
public class WebpageCMSEditorForm extends Form implements FormInitListener, FormValidationListener, FormProcessListener { public class WebpageCMSEditorForm extends Form implements FormInitListener,
FormValidationListener,
FormProcessListener {
Hidden m_itemID; Hidden m_itemID;
TextField m_author, m_title; TextField m_author, m_title;
@ -246,8 +247,7 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
s_log.error("content section doesn't match! create new webpage entity."); s_log.error("content section doesn't match! create new webpage entity.");
webpage = null; webpage = null;
} }
} } catch (Exception ex) {
catch (Exception ex) {
} }
m_categories.setPrintListener(new CategoriesPrintListener(section)); m_categories.setPrintListener(new CategoriesPrintListener(section));
@ -266,8 +266,7 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
assignedCats.add(catID); assignedCats.add(catID);
} }
m_categories.setValue(state, assignedCats.toArray()); m_categories.setValue(state, assignedCats.toArray());
} } else {
else {
m_categories.setValue(state, new String[]{request.getParameter("categoryID")}); m_categories.setValue(state, new String[]{request.getParameter("categoryID")});
if (m_displayDates) { if (m_displayDates) {
final java.util.Date start = new java.util.Date(System.currentTimeMillis()); final java.util.Date start = new java.util.Date(System.currentTimeMillis());
@ -280,15 +279,13 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
// return 12. // return 12.
if (calendar.get(Calendar.HOUR) == 0) { if (calendar.get(Calendar.HOUR) == 0) {
m_startHour.setValue(state, new Integer(12)); m_startHour.setValue(state, new Integer(12));
} } else {
else {
m_startHour.setValue(state, new Integer(calendar.get(Calendar.HOUR))); m_startHour.setValue(state, new Integer(calendar.get(Calendar.HOUR)));
} }
final Integer min = new Integer(calendar.get(Calendar.MINUTE)); final Integer min = new Integer(calendar.get(Calendar.MINUTE));
if (min.intValue() < 10) { if (min.intValue() < 10) {
m_startMinute.setValue(state, "0" + min.toString()); m_startMinute.setValue(state, "0" + min.toString());
} } else {
else {
m_startMinute.setValue(state, min.toString()); m_startMinute.setValue(state, min.toString());
} }
m_startAmpm.setValue(state, new Integer(calendar.get(Calendar.AM_PM))); m_startAmpm.setValue(state, new Integer(calendar.get(Calendar.AM_PM)));
@ -338,7 +335,7 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
} }
} }
} }
if (! valid) { if (!valid) {
throw new FormProcessException("There is an error on the form"); throw new FormProcessException("There is an error on the form");
} }
} }
@ -369,8 +366,7 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
BigDecimal id = new BigDecimal(idTxt); BigDecimal id = new BigDecimal(idTxt);
webpage = new Webpage(id); webpage = new Webpage(id);
} }
} } catch (Exception ex) {
catch (Exception ex) {
throw new FormProcessException(ex); throw new FormProcessException(ex);
} }
@ -381,7 +377,7 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
User user = Web.getWebContext().getUser(); User user = Web.getWebContext().getUser();
if (webpage != null) { if (webpage != null) {
if ( !sm.canAccess(user, SecurityConstants.EDIT_ITEM, webpage ) ) { if (!sm.canAccess(user, SecurityConstants.EDIT_ITEM, webpage)) {
throw new FormProcessException("Insufficient permissions"); throw new FormProcessException("Insufficient permissions");
} }
if (!webpage.getContentSection().equals(section)) { if (!webpage.getContentSection().equals(section)) {
@ -394,9 +390,8 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
webpage.setCategories((String[]) m_categories.getValue(state)); webpage.setCategories((String[]) m_categories.getValue(state));
webpage.setDescription((String) m_desc.getValue(state)); webpage.setDescription((String) m_desc.getValue(state));
webpage.save(); webpage.save();
} } else {
else { if (!sm.canAccess(user, SecurityConstants.NEW_ITEM)) {
if ( !sm.canAccess(user, SecurityConstants.NEW_ITEM ) ) {
throw new FormProcessException("Insufficient permissions"); throw new FormProcessException("Insufficient permissions");
} }
webpage = new Webpage(); webpage = new Webpage();
@ -421,8 +416,7 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
if (lfColl.next()) { if (lfColl.next()) {
lifecycleDefinition = lfColl.getLifecycleDefinition(); lifecycleDefinition = lfColl.getLifecycleDefinition();
} }
} } finally {
finally {
if (lfColl != null) { if (lfColl != null) {
lfColl.close(); lfColl.close();
} }
@ -440,8 +434,7 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
flow.start(Web.getWebContext().getUser()); flow.start(Web.getWebContext().getUser());
flow.save(); flow.save();
} }
} } finally {
finally {
if (taskColl != null) { if (taskColl != null) {
taskColl.close(); taskColl.close();
} }
@ -452,22 +445,22 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
Engine engine = Engine.getInstance(); Engine engine = Engine.getInstance();
Assert.exists(engine, Engine.class); Assert.exists(engine, Engine.class);
Iterator i = engine.getEnabledTasks(Web.getWebContext().getUser(), workflow.getID()).iterator(); Iterator i = engine.getEnabledTasks(Web.getWebContext().getUser(), workflow.
getID()).iterator();
CMSTask task; CMSTask task;
do { do {
while (i.hasNext()) { while (i.hasNext()) {
task = (CMSTask) i.next(); task = (CMSTask) i.next();
try { try {
task.finish(); task.finish();
} } catch (Exception ex) {
catch (Exception ex) {
throw new FormProcessException(ex); throw new FormProcessException(ex);
} }
} }
i = engine.getEnabledTasks(Web.getWebContext().getUser(), workflow.getID()).iterator(); i = engine.getEnabledTasks(Web.getWebContext().getUser(), workflow.
} getID()).iterator();
while (i.hasNext()); } while (i.hasNext());
// publish // publish
if (lifecycleDefinition != null) { if (lifecycleDefinition != null) {
@ -485,22 +478,22 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
} }
final Integer endAmpm = (Integer) m_endAmpm.getValue(state); final Integer endAmpm = (Integer) m_endAmpm.getValue(state);
java.util.Date startDate = (java.util.Date) m_startDate.getValue(state); java.util.Date startDate = (java.util.Date) m_startDate.getValue(
state);
final Calendar start = Calendar.getInstance(); final Calendar start = Calendar.getInstance();
start.setTime(startDate); start.setTime(startDate);
start.set(Calendar.AM_PM, startAmpm.intValue()); start.set(Calendar.AM_PM, startAmpm.intValue());
start.set(Calendar.MINUTE, startMinute.intValue()); start.set(Calendar.MINUTE, startMinute.intValue());
start.set(Calendar.AM_PM, startAmpm.intValue()); start.set(Calendar.AM_PM, startAmpm.intValue());
if (startHour.intValue() != 12) { if (startHour.intValue() != 12) {
start.set(Calendar.HOUR_OF_DAY, 12 * startAmpm.intValue() + startHour.intValue()); start.set(Calendar.HOUR_OF_DAY, 12 * startAmpm.intValue()
+ startHour.intValue());
start.set(Calendar.HOUR, startHour.intValue()); start.set(Calendar.HOUR, startHour.intValue());
} } else {
else {
if (startAmpm.intValue() == 0) { if (startAmpm.intValue() == 0) {
start.set(Calendar.HOUR_OF_DAY, 0); start.set(Calendar.HOUR_OF_DAY, 0);
start.set(Calendar.HOUR, 0); start.set(Calendar.HOUR, 0);
} } else {
else {
start.set(Calendar.HOUR_OF_DAY, 12); start.set(Calendar.HOUR_OF_DAY, 12);
start.set(Calendar.HOUR, 0); start.set(Calendar.HOUR, 0);
} }
@ -515,15 +508,14 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
end.set(Calendar.MINUTE, endMinute.intValue()); end.set(Calendar.MINUTE, endMinute.intValue());
end.set(Calendar.AM_PM, endAmpm.intValue()); end.set(Calendar.AM_PM, endAmpm.intValue());
if (endHour.intValue() != 12) { if (endHour.intValue() != 12) {
end.set(Calendar.HOUR_OF_DAY, 12 * endAmpm.intValue() + endHour.intValue()); end.set(Calendar.HOUR_OF_DAY, 12 * endAmpm.intValue()
+ endHour.intValue());
end.set(Calendar.HOUR, endHour.intValue()); end.set(Calendar.HOUR, endHour.intValue());
} } else {
else {
if (endAmpm.intValue() == 0) { if (endAmpm.intValue() == 0) {
end.set(Calendar.HOUR_OF_DAY, 0); end.set(Calendar.HOUR_OF_DAY, 0);
end.set(Calendar.HOUR, 0); end.set(Calendar.HOUR, 0);
} } else {
else {
end.set(Calendar.HOUR_OF_DAY, 12); end.set(Calendar.HOUR_OF_DAY, 12);
end.set(Calendar.HOUR, 0); end.set(Calendar.HOUR, 0);
} }
@ -548,8 +540,7 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
} }
} }
} }
} } else {
else {
webpage.publish(lifecycleDefinition, new java.util.Date()); webpage.publish(lifecycleDefinition, new java.util.Date());
} }
@ -562,13 +553,11 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
} }
} }
commitTransaction = true; commitTransaction = true;
} } finally {
finally {
if (txn != null && isMyTransaction) { if (txn != null && isMyTransaction) {
if (commitTransaction) { if (commitTransaction) {
txn.commitTxn(); txn.commitTxn();
} } else {
else {
txn.abortTxn(); txn.abortTxn();
} }
} }
@ -577,13 +566,13 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
try { try {
DispatcherHelper.sendRedirect(request, state.getResponse(), section.getPath()); DispatcherHelper.sendRedirect(request, state.getResponse(), section.getPath());
} } catch (IOException ex) {
catch (IOException ex) {
throw new FormProcessException(ex); throw new FormProcessException(ex);
} }
} }
public class TimeZonePrinter implements PrintListener { public class TimeZonePrinter implements PrintListener {
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
final Label target = (Label) e.getTarget(); final Label target = (Label) e.getTarget();
final PageState state = e.getPageState(); final PageState state = e.getPageState();