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 3606 additions and 3588 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -142,16 +142,17 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm
country.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.address.iso_country_code"));
country.addOption(new Option("",
new Label(ContenttypesGlobalizationUtil
.globalize("cms.ui.select_one"))));
try {
country.addPrintListener(new PrintListener() {
@Override
public void prepare(final PrintEvent event) {
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)
.entrySet().iterator();

View File

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

View File

@ -74,14 +74,16 @@ public class GenericContactEntryAddForm extends BasicItemForm {
contactEntryKey.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericcontact.contactEntry.key"));
contactEntryKey.addValidationListener(new NotNullValidationListener());
contactEntryKey.addOption(new Option("", new Label(GlobalizationUtil.globalize(
"cms.ui.select_one"))));
try {
contactEntryKey.addPrintListener(new PrintListener() {
@Override
public void prepare(final PrintEvent event) {
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();
// 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.
*
* This class is part of the admin GUI of CCM and extends the standard form
* in order to present forms for managing the multi-language categories.
* This class is part of the admin GUI of CCM and extends the standard form in order to present
* forms for managing the multi-language categories.
*
* @author Sören Bernstein <quasi@quasiweb.de>
*/
@ -63,7 +63,9 @@ public class GenericContactTypeAddForm extends BasicItemForm {
private ItemSelectionModel m_itemModel;
private SingleSelect language;
/** Creates a new instance of CategoryLocalizationAddForm */
/**
* Creates a new instance of CategoryLocalizationAddForm
*/
public GenericContactTypeAddForm(ItemSelectionModel itemModel) {
super("ContactEntryAddForm", itemModel);
@ -88,7 +90,8 @@ public class GenericContactTypeAddForm extends BasicItemForm {
language.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.contacttypes.language"));
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
ParameterModel nameParam = new StringParameter(NAME);
@ -99,17 +102,15 @@ public class GenericContactTypeAddForm extends BasicItemForm {
.globalize("cms.contenttypes.ui.contacttypes.name"));
add(name);
}
public void init(FormSectionEvent fse) {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
RelationAttribute contacttype = (RelationAttribute)
getItemSelectionModel()
RelationAttribute contacttype = (RelationAttribute) getItemSelectionModel()
.getSelectedObject(state);
GenericContactTypeCollection contacttypeCollection = new
GenericContactTypeCollection(contacttype.getKey());
GenericContactTypeCollection contacttypeCollection = new GenericContactTypeCollection(
contacttype.getKey());
// all supported languages (by registry entry)
KernelConfig kernelConfig = Kernel.getConfig();
@ -121,8 +122,7 @@ public class GenericContactTypeAddForm extends BasicItemForm {
// If lanuage exists, remove it from the selection list
if (!contacttypeCollection.hasLanguage(code)) {
language.addOption(new
Option(code,
language.addOption(new Option(code,
new Locale(code).getDisplayLanguage()),
state);
}
@ -138,8 +138,7 @@ public class GenericContactTypeAddForm extends BasicItemForm {
public void process(FormSectionEvent fse) {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
RelationAttribute contacttype = (RelationAttribute)
getItemSelectionModel()
RelationAttribute contacttype = (RelationAttribute) getItemSelectionModel()
.getSelectedObject(state);
//

View File

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

View File

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

View File

@ -100,15 +100,18 @@ public class GenericPersonContactAddForm extends BasicItemForm {
contactType.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericperson.contact.type"));
contactType.addValidationListener(new NotNullValidationListener());
contactType.addOption(new Option("",
new Label(GlobalizationUtil.
globalize("cms.ui.select_one"))));
try {
contactType.addPrintListener(new PrintListener() {
@Override
public void prepare(final PrintEvent event) {
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
final GenericContactTypeCollection contacttypes
= new GenericContactTypeCollection();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -140,8 +140,7 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
public BigDecimalParameter getFileIDParam() {
try {
return ((DocmgrBasePage) m_page).getFileIDParam();
}
catch (Throwable e) {
} catch (Throwable e) {
}
return null;
}
@ -152,7 +151,7 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
}
private Component makePropertiesPane() {
SimpleContainer container= new SimpleContainer();
SimpleContainer container = new SimpleContainer();
m_propertiesPane = new FilePropertiesPanel(this);
container.add(m_propertiesPane);
@ -228,7 +227,8 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
Element nameElement = element.newChildElement("docs:name", DOCS_XML_NS);
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();
if (description != null) {
descriptionElement.setText(description);
@ -241,8 +241,11 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
// Retrieve pretty name for a mime type.
typeElement.setText(doc.getPrettyMimeType());
Element lastModifiedElement = element.newChildElement("docs:last-modified", DOCS_XML_NS);
lastModifiedElement.setText(null != doc.getLastModifiedDate() ? DMUtils.DateFormat.format(doc.getLastModifiedDate()) : "");
Element lastModifiedElement = element.newChildElement("docs:last-modified",
DOCS_XML_NS);
lastModifiedElement.setText(
null != doc.getLastModifiedDate() ? DMUtils.DateFormat.format(doc.
getLastModifiedDate()) : "");
Element revisionElement = element.newChildElement("docs:revision", DOCS_XML_NS);
@ -251,7 +254,6 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
revisionElement.setText(numRevs + "");
// Must allow for the possibility that not author is available.
Element authorElement = element.newChildElement("docs:author", DOCS_XML_NS);
authorElement.setText(doc.getImpliedAuthor());
@ -270,12 +272,10 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
catElement.addAttribute("name", cat.getName());
}
}
catch (DataObjectNotFoundException exc) {
} catch (DataObjectNotFoundException exc) {
Element notfoundElement = element.newChildElement("docs:notfound", DOCS_XML_NS);
}
}
else {
} else {
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_CATS = "file-edit-cats";
@ -337,8 +338,7 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
SingleSelect audienceEntry = new SingleSelect(m_FileAudience);
try {
audienceEntry.addPrintListener(new IntendedAudienceSelectPrinter());
}
catch (TooManyListenersException tmlex) {
} catch (TooManyListenersException tmlex) {
s_log.error(tmlex.getMessage());
tmlex.printStackTrace();
}
@ -355,9 +355,9 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
try {
BigDecimalParameter fileIDParam = null;
fileIDParam = getFileIDParam();
catSelect.addPrintListener(new CategoriesPrintListener(getContentSection(), fileIDParam));
}
catch (java.util.TooManyListenersException tmex) {
catSelect.addPrintListener(new CategoriesPrintListener(getContentSection(),
fileIDParam));
} catch (java.util.TooManyListenersException tmex) {
throw new UncheckedWrapperException(tmex.getMessage());
}
add(catSelect);
@ -402,7 +402,7 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
cat = cats.getCategory();
String catID = cat.getID().toString();
assignedCats.add(catID);
s_log.debug("init: "+catID);
s_log.debug("init: " + catID);
}
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
*/
public void validate(FormSectionEvent event) throws FormProcessException {
PageState state = event.getPageState();
if (m_submit.isSelected(state)) {
@ -485,9 +484,9 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
String title = (String) data.get(FILE_EDIT_TITLE);
if (title == null || title.length() == 0) {
data.addError(FILE_EDIT_TITLE, "This parameter is required.");
}
else if (title.length() > 200) {
data.addError(FILE_EDIT_TITLE, "This title is too long. It must be fewer than 200 characters.");
} else if (title.length() > 200) {
data.addError(FILE_EDIT_TITLE,
"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.
*/
private void initAudienceFormData(FormData data, Document doc) {
ObjectPermissionCollection opc = PermissionService.getDirectGrantedPermissions(doc.getOID());
ObjectPermissionCollection opc = PermissionService.getDirectGrantedPermissions(doc.
getOID());
long numPermissions = opc.size();
if (numPermissions > 1) {
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();
if (isPublic) {
data.put(FILE_EDIT_AUDIENCE, "public");
}
else {
} else {
data.put(FILE_EDIT_AUDIENCE, "internal");
}
}
@ -529,9 +528,11 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
if (intendedAudience == 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));
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()));
new KernelExcursion() {
protected void excurse() {
@ -541,12 +542,10 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
if ("public".equals(intendedAudience)) {
PermissionService.grantPermission(publicDescriptor);
PermissionService.revokePermission(internalDescriptor);
}
else if ("internal".equals(intendedAudience)) {
} else if ("internal".equals(intendedAudience)) {
PermissionService.revokePermission(publicDescriptor);
PermissionService.grantPermission(internalDescriptor);
}
else {
} else {
// workspace only
PermissionService.revokePermission(publicDescriptor);
PermissionService.revokePermission(internalDescriptor);
@ -556,6 +555,7 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
}
protected class AuthorLabelPrinter implements PrintListener {
public AuthorLabelPrinter() {
// Empty
}
@ -571,13 +571,19 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
}
protected class IntendedAudienceSelectPrinter implements PrintListener {
public IntendedAudienceSelectPrinter() {
}
public void prepare(PrintEvent e) {
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("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_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
* description. Return to File properties screen.
* Receive uploaded file and reset file content, mime type, and description. Return to File
* properties screen.
*/
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
FileAsset fa = doc.getFile();
fa.loadFromFile(fname, src, "txt");
}
catch (java.io.IOException ex) {
} catch (java.io.IOException ex) {
ex.printStackTrace();
throw new FormProcessException(ex.getMessage());
}
@ -719,8 +724,9 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
// Annotate transaction description
String vdesc = (String) data.get(VERSION_TRANSACTION_DESCRIPTION);
//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);
}
Versions.tag(doc.getOID(), vdesc);
doc.setLastModifiedLocal(doc.getLastModifiedDate());
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
* if user tries to upload a file with a different Mime type than the
* original. This is not supported.
* Validate the length of name of the new file being uploaded. Validate if user tries to
* upload a file with a different Mime type than the original. This is not supported.
*
*/
public void validate(FormSectionEvent e) throws FormProcessException {
@ -751,13 +756,13 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
int nameLength = 500;
try {
nameLength = fname.getBytes("UTF-8").length;
}
catch (UnsupportedEncodingException uee) {
} catch (UnsupportedEncodingException uee) {
throw new RuntimeException("No UTF-8 support: " + uee);
}
// XXX Not localized as the other errors are.
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);
@ -811,7 +816,8 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
BoxPanel panel = new BoxPanel();
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() {
public void actionPerformed(ActionEvent e) {
PageState state = e.getPageState();
@ -833,11 +839,12 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
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;
public SendForm(FileSendColleaguePane parent) {
super("sendEmail",new BoxPanel());
super("sendEmail", new BoxPanel());
m_parent = parent;
@ -866,8 +873,11 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
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(),
FILE_SEND_COLLEAGUE_SUBJECT.localize().toString(), FILE_SEND_COLLEAGUE_MESSAGE.localize().toString() + " " + u.getName());
Mail mail = new Mail((String) data.get(EMAIL_PARAM_NAME),
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));
try {
FileAsset fa = doc.getFile();
@ -889,13 +899,11 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
s_log.debug("mimeTypeString: " + mimeTypeString);
mail.attach(assetStream.toByteArray(), mimeTypeString, doc.getTitle());
mail.send();
}
catch (java.io.IOException iox) {
} catch (java.io.IOException iox) {
s_log.error("SendForm.process", iox);
// iox.printStackTrace();
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);
//mex.printStackTrace();
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();
Application app = Web.getWebContext().getApplication();
// 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;
}
if (!PermissionService.checkPermission(new PermissionDescriptor(PrivilegeDescriptor.EDIT, app, user))) {
if (!PermissionService.checkPermission(
new PermissionDescriptor(PrivilegeDescriptor.EDIT, app, user))) {
m_editLink.setVisible(state, false);
m_delete.setVisible(state, false);
m_newVersion.setVisible(state, false);
@ -1023,10 +1033,11 @@ public class BrowseFileInfoPropertiesPane extends ModalContainer implements DMCo
try {
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);
}
catch (IOException iox) {
} catch (IOException iox) {
throw new UncheckedWrapperException(iox);
}
}

View File

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

View File

@ -12,7 +12,6 @@
* rights and limitations under the License.
*
*/
package com.arsdigita.cms.docmgr.ui;
import com.arsdigita.bebop.ColumnPanel;
@ -80,9 +79,8 @@ import java.util.Iterator;
import java.util.TooManyListenersException;
/**
* This component allows to change the file name and the
* description of a file. It also serves to associate
* keywords to a file (knowledge object).
* This component allows to change the file name and the description of a file. It also serves to
* associate keywords to a file (knowledge object).
*
* @author Stefan Deusch
* @author Crag Wolfe
@ -91,10 +89,11 @@ class FileEditForm extends Form
implements FormValidationListener,
FormProcessListener,
FormInitListener,
DMConstants
{
private final static org.apache.log4j.Logger s_log =
org.apache.log4j.Logger.getLogger(FileEditForm.class);
DMConstants {
private final static org.apache.log4j.Logger s_log
= org.apache.log4j.Logger.getLogger(
FileEditForm.class);
private final static String FILE_EDIT = "file-edit";
private final static String FILE_EDIT_CATS = "file-edit-cats";
@ -127,8 +126,9 @@ class FileEditForm extends Form
private Submit m_submit;
public FileEditForm(Component parent) {
this(parent,false, null);
this(parent, false, null);
}
/**
* Constructor
*/
@ -153,8 +153,7 @@ class FileEditForm extends Form
add(new Label(FILE_UPLOAD_ADD_FILE));
m_fileUpload = new FileUpload(FILE_UPLOAD);
add(m_fileUpload);
}
else {
} else {
add(new Label(FILE_NAME_REQUIRED));
m_FileName = new StringParameter(FILE_EDIT_FNAME);
TextField fnameEntry = new TextField(m_FileName);
@ -166,7 +165,6 @@ class FileEditForm extends Form
TextField fTitleEntry = new TextField(m_FileTitle);
add(fTitleEntry);
add(new Label(FILE_INTENDED_AUDIENCE));
SingleSelect audienceEntry = new SingleSelect(m_FileAudience);
try {
@ -190,9 +188,7 @@ class FileEditForm extends Form
if (!m_creation) {
fileIDParam = getFileIDParam();
}
catSelect.addPrintListener
(new CategoriesPrintListener
(getContentSection(),
catSelect.addPrintListener(new CategoriesPrintListener(getContentSection(),
fileIDParam));
} catch (java.util.TooManyListenersException tmex) {
throw new UncheckedWrapperException(tmex.getMessage());
@ -228,11 +224,11 @@ class FileEditForm extends Form
if (m_creation) {
initCreate(e);
}
else {
} else {
initEdit(e);
}
}
public void initEdit(FormSectionEvent e)
throws FormProcessException {
@ -251,7 +247,7 @@ class FileEditForm extends Form
cat = cats.getCategory();
String catID = cat.getID().toString();
assignedCats.add(catID);
s_log.debug("init: "+catID);
s_log.debug("init: " + catID);
}
data.put(FILE_EDIT_FNAME, URLDecoder.decode(doc.getName()));
@ -301,12 +297,12 @@ class FileEditForm extends Form
Document doc = DMUtils.getFile(getSelectedDocID(state));
setDocumentAttributes(data,doc);
setDocumentAttributes(data, doc);
doc.setCategories((String[]) data.get(FILE_EDIT_CATS));
doc.setLastModifiedLocal(new java.util.Date());
doc.save(); // creates a new revision
setDocumentPermission(data,doc);
setDocumentPermission(data, doc);
return doc;
}
@ -326,8 +322,7 @@ class FileEditForm extends Form
int index;
if (mime != null && (index = fname.lastIndexOf('.')) > -1) {
titleTmp = fname.substring(0, index);
}
else {
} else {
titleTmp = fname;
}
}
@ -340,8 +335,8 @@ class FileEditForm extends Form
HttpServletRequest mreq = e.getPageState().getRequest();
Assert.isTrue(mreq instanceof MultipartHttpServletRequest,
"I got a " + mreq + " when I was " +
"expecting a MultipartHttpServletRequest");
"I got a " + mreq + " when I was "
+ "expecting a MultipartHttpServletRequest");
src = ((MultipartHttpServletRequest) mreq).getFile(FILE_UPLOAD);
}
@ -359,15 +354,13 @@ class FileEditForm extends Form
BigDecimal folderID = new BigDecimal(selKey);
try {
p = new DocFolder(folderID);
} catch(DataObjectNotFoundException nf) {
throw new ObjectNotFoundException
((String) FOLDER_PARENTNOTFOUND_ERROR.localize(req));
} catch (DataObjectNotFoundException nf) {
throw new ObjectNotFoundException((String) FOLDER_PARENTNOTFOUND_ERROR.localize(req));
}
}
final DocFolder parent = p;
// insert the file in the data base below parent
final Document f1 = new Document();
// FR: define the bundle here
@ -394,25 +387,26 @@ class FileEditForm extends Form
bundle.setName(fname);
bundle.setParent(parent);
bundle.setContentSection(parent.getContentSection());
PermissionService.setContext(bundle,parent);
PermissionService.setContext(f1,bundle);
PermissionService.setContext(fa,f1);
PermissionService.setContext(bundle, parent);
PermissionService.setContext(f1, bundle);
PermissionService.setContext(fa, f1);
bundle.save();
f1.save();
}}.run();
}
}.run();
try {
fa.loadFromFile(fname,src,"txt");
fa.loadFromFile(fname, src, "txt");
} catch (java.io.IOException ex) {
ex.printStackTrace();
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)
.toString()));
setDocumentAttributes(data,f1);
setDocumentAttributes(data, f1);
// title must be set before name
f1.setTitle(title);
f1.setName(URLEncoder.encode(fname));
@ -422,7 +416,7 @@ class FileEditForm extends Form
//f1.save();
// context has been set, now add additional permissions
setDocumentPermission(data,f1);
setDocumentPermission(data, f1);
f1.setCategories((String[]) data.get(FILE_EDIT_CATS));
bundle.save();
@ -433,7 +427,6 @@ class FileEditForm extends Form
private void setDocumentAttributes(FormData data,
Document doc) {
if (!m_creation) {
String ftitle = (String) data.get(FILE_EDIT_TITLE);
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
*/
public void validate(FormSectionEvent event)
throws FormProcessException {
@ -469,12 +461,14 @@ class FileEditForm extends Form
//validate length of author
String author = (String) data.get(FILE_EDIT_AUTHOR);
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
String desc = (String) data.get(FILE_EDIT_DESCRIPTION);
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) {
@ -500,8 +494,7 @@ class FileEditForm extends Form
// XXX Not localized as the other errors are.
if (fname.length() > 200) {
data.addError
(FILE_UPLOAD,
data.addError(FILE_UPLOAD,
"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);
try {
parent = new DocFolder(folderID);
} catch(DataObjectNotFoundException nf) {
} catch (DataObjectNotFoundException nf) {
throw new ObjectNotFoundException(FOLDER_PARENTNOTFOUND_ERROR
.localize(req).toString());
}
@ -534,7 +527,7 @@ class FileEditForm extends Form
data.addError(FILE_UPLOAD,
RESOURCE_EXISTS_ERROR
.localize(req).toString());
} catch(DataObjectNotFoundException nf) {
} catch (DataObjectNotFoundException nf) {
// ok here
}// catch(InvalidNameException ex) {
}
@ -552,28 +545,21 @@ class FileEditForm extends Form
String title = (String) data.get(FILE_EDIT_TITLE);
if (title == null || title.length() == 0) {
data.addError(FILE_EDIT_TITLE, "This parameter is required.");
}
else if (title.length() > 200) {
} else if (title.length() > 200) {
data.addError(FILE_EDIT_TITLE,
"This title is too long. It must be fewer than 200 characters.");
}
// HttpServletRequest req = state.getRequest();
// Document doc = DMUtils.getFile(getSelectedDocID(state));
// // Construct a name with the optional extension
// String name = doc.getName();
// if (!doc.isValidNewName(name)) {
// data.addError(FILE_EDIT_FNAME,
// "Not a valid new name for this file");
// }
// Verify that the new name does not correspond to an existing
// resource (file or folder)
// XXX we need this, but leaving it broken for now... --hbrock
/*
@ -598,22 +584,20 @@ class FileEditForm extends Form
*/
private void initAudienceFormData(FormData data,
Document doc) {
ObjectPermissionCollection opc =
PermissionService.getDirectGrantedPermissions(doc.getOID());
ObjectPermissionCollection opc
= PermissionService.getDirectGrantedPermissions(doc.getOID());
long numPermissions = opc.size();
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");
}
if (numPermissions == 0) {
data.put(FILE_EDIT_AUDIENCE,"workspace");
data.put(FILE_EDIT_AUDIENCE, "workspace");
opc.close();
return;
}
boolean isPublic = false;
while (opc.next()) {
if (opc.getGranteeID().intValue() ==
PermissionManager.VIRTUAL_PUBLIC_ID) {
if (opc.getGranteeID().intValue() == PermissionManager.VIRTUAL_PUBLIC_ID) {
isPublic = true;
}
}
@ -633,31 +617,28 @@ class FileEditForm extends Form
throws FormProcessException {
final String intendedAudience = (String) data.get(FILE_EDIT_AUDIENCE);
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,
final PermissionDescriptor publicDescriptor
= new PermissionDescriptor(PrivilegeDescriptor.READ,
doc.getOID(),
new OID(User.BASE_DATA_OBJECT_TYPE,
PermissionManager.VIRTUAL_PUBLIC_ID));
final PermissionDescriptor internalDescriptor =
new PermissionDescriptor
(PrivilegeDescriptor.READ,
final PermissionDescriptor internalDescriptor
= new PermissionDescriptor(PrivilegeDescriptor.READ,
doc.getOID(),
new OID(Group.BASE_DATA_OBJECT_TYPE,
DocMgr.getConfig().getInternalGroupID()));
DocMgr.getConfig().
getInternalGroupID()));
new KernelExcursion() {
protected void excurse() {
//Party currentParty = Kernel.getWebContext().getParty();
setParty(Kernel.getSystemParty());
if("public".equals(intendedAudience)) {
if ("public".equals(intendedAudience)) {
PermissionService.grantPermission(publicDescriptor);
PermissionService.revokePermission(internalDescriptor);
} else if("internal".equals(intendedAudience)) {
} else if ("internal".equals(intendedAudience)) {
PermissionService.revokePermission(publicDescriptor);
PermissionService.grantPermission(internalDescriptor);
} else {
@ -670,6 +651,7 @@ class FileEditForm extends Form
}
protected class AuthorLabelPrinter implements PrintListener {
public AuthorLabelPrinter() {
// Empty
}
@ -680,38 +662,39 @@ class FileEditForm extends Form
String name = Web.getWebContext().getUser().getName();
label.setLabel("Author: (if not "+name+")");
label.setLabel("Author: (if not " + name + ")");
}
}
protected class IntendedAudienceSelectPrinter implements PrintListener {
public IntendedAudienceSelectPrinter() {
}
public void prepare(PrintEvent e) {
SingleSelect select = (SingleSelect) e.getTarget();
select.clearOptions();
select.addOption
(new Option("workspace",
select.addOption(new Option("workspace",
Web.getWebContext().getApplication()
.getParentApplication() == null ? Web.getWebContext().getApplication().getDisplayName()
: Web.getWebContext().getApplication().getParentApplication().getDisplayName()+
" members"));
.getParentApplication() == null ? Web.getWebContext().
getApplication().getDisplayName()
: Web.getWebContext().getApplication().
getParentApplication().getDisplayName() + " members"));
select.addOption
(new Option("internal",
select.addOption(new Option("internal",
new Label(FILE_INTENDED_AUDIENCE_INTERNAL)));
select.addOption
(new Option("public",
select.addOption(new Option("public",
new Label(FILE_INTENDED_AUDIENCE_PUBLIC)));
}
}
private ContentSection getContentSection() {
ContentSectionCollection csl = ContentSection.getAllSections();
csl.addEqualsFilter("label",DocMgr.getConfig().getContentSection());
csl.addEqualsFilter("label", DocMgr.getConfig().getContentSection());
if (!csl.next()) {
csl.close(); return null;
csl.close();
return null;
}
ContentSection docsContentSection = csl.getContentSection();
csl.close();
@ -729,8 +712,7 @@ class FileEditForm extends Form
private BigDecimalParameter getFileIDParam() {
if (m_parent instanceof FileInfoPropertiesPane) {
return ((FileInfoPropertiesPane) m_parent).getFileIDParam();
}
else {
} else {
if (m_parent instanceof BrowseFileInfoPropertiesPane) {
((BrowseFileInfoPropertiesPane) m_parent).getFileIDParam();
}
@ -742,16 +724,13 @@ class FileEditForm extends Form
if (m_parent instanceof BrowsePane) {
if (docID != null) {
((BrowsePane) m_parent).displayFilePropPanel(state, docID);
}
else {
} else {
((BrowsePane) m_parent).displayFolderContentPanel(state);
}
}
else {
} else {
if (m_parent instanceof FileInfoPropertiesPane) {
((FileInfoPropertiesPane) m_parent).displayPropertiesAndActions(state);
}
else {
} else {
if (m_parent instanceof BrowseFileInfoPropertiesPane) {
((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.
*
*/
package com.arsdigita.cms.docmgr.ui;
import com.arsdigita.bebop.*;
@ -47,10 +46,11 @@ import java.util.TooManyListenersException;
*
* @author Crag Wolfe
*/
class SearchPane extends SimpleContainer implements DMConstants
{
private static final org.apache.log4j.Logger s_log =
org.apache.log4j.Logger.getLogger(SearchPane.class);
class SearchPane extends SimpleContainer implements DMConstants {
private static final org.apache.log4j.Logger s_log
= org.apache.log4j.Logger.getLogger(
SearchPane.class);
public static final String SEARCH_AUTHOR = "searchAuthor";
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 WORKSPACE_SELECT = "workspaceSelect";
private final BigDecimalParameter m_categoriesParam = new BigDecimalParameter(CATEGORY_SELECT) ;
private final BigDecimalParameter m_workspaceParam = new BigDecimalParameter(WORKSPACE_SELECT) ;
private final BigDecimalParameter m_categoriesParam = new BigDecimalParameter(CATEGORY_SELECT);
private final BigDecimalParameter m_workspaceParam = new BigDecimalParameter(WORKSPACE_SELECT);
private final TrimmedStringParameter m_termsParam = new TrimmedStringParameter(SEARCH_TERMS);
private final TrimmedStringParameter m_authorParam = new TrimmedStringParameter(SEARCH_AUTHOR);
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
ContentSectionCollection csl = ContentSection.getAllSections();
csl.addEqualsFilter("label",DocMgr.getConfig().getContentSection());
csl.addEqualsFilter("label", DocMgr.getConfig().getContentSection());
if (!csl.next()) {
csl.close(); return;
csl.close();
return;
}
m_docsContentSection = csl.getContentSection();
csl.close();
// bebop components
//m_mainTabPane = new SimpleContainer();
m_mainBrowseContainer = new BoxPanel(BoxPanel.HORIZONTAL, true);
//m_mainTabPane.addTab(WS_SEARCH_TITLE,
// m_mainBrowseContainer);
//m_mainTabPane.add(new Label("yo"));
//m_mainBrowseContainer.setClassAttr("sidebarNavPanel");
DocsSearchForm leftSide = new DocsSearchForm(new GridPanel(2));
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);
@ -154,8 +153,9 @@ class SearchPane extends SimpleContainer implements DMConstants
private class DocsSearchForm extends Form
implements SearchForm, FormValidationListener,
FormProcessListener, FormInitListener {
public DocsSearchForm(Container panel) {
super("docSearch",panel);
super("docSearch", panel);
add(new Label("Search text:"));
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 Label("Category"));
SingleSelect categoriesWidget =
new SingleSelect(m_categoriesParam);
SingleSelect categoriesWidget
= new SingleSelect(m_categoriesParam);
try {
categoriesWidget.addOption(new Option("",""));
categoriesWidget.addPrintListener
(new CategoriesPrintListener
(m_docsContentSection));
categoriesWidget.addOption(new Option("", ""));
categoriesWidget.addPrintListener(new CategoriesPrintListener(m_docsContentSection));
} catch (TooManyListenersException e) {
UncheckedWrapperException.throwLoggedException
(getClass(), "Too many listeners", e);
UncheckedWrapperException.throwLoggedException(getClass(), "Too many listeners", e);
}
add(categoriesWidget);
//categoriesWidget.setSize(SELECT_HEIGHT);
add(new Label("Workspace"));
SingleSelect workspaceWidget =
new SingleSelect(m_workspaceParam);
SingleSelect workspaceWidget
= new SingleSelect(m_workspaceParam);
try {
workspaceWidget.addPrintListener
(new WorkspacesPrintListener());
workspaceWidget.addPrintListener(new WorkspacesPrintListener());
} catch (TooManyListenersException e) {
UncheckedWrapperException.throwLoggedException
(getClass(), "Too many listeners", e);
UncheckedWrapperException.throwLoggedException(getClass(), "Too many listeners", e);
}
add(workspaceWidget);
@ -209,23 +204,20 @@ class SearchPane extends SimpleContainer implements DMConstants
throws FormProcessException {
PageState state = e.getPageState();
String terms = (String)state.getValue(m_termsParam);
String author = (String)state.getValue(m_authorParam);
String mimeType = (String)state.getValue(m_mimeTypeParam);
Date endDate = (Date)state.getValue(m_endDateParam);
Date startDate = (Date)state.getValue(m_startDateParam);
BigDecimal workspaceID = (BigDecimal)state.getValue(m_workspaceParam);
BigDecimal categoryID =
(BigDecimal) state.getValue(m_categoriesParam);
String terms = (String) state.getValue(m_termsParam);
String author = (String) state.getValue(m_authorParam);
String mimeType = (String) state.getValue(m_mimeTypeParam);
Date endDate = (Date) state.getValue(m_endDateParam);
Date startDate = (Date) state.getValue(m_startDateParam);
BigDecimal workspaceID = (BigDecimal) state.getValue(m_workspaceParam);
BigDecimal categoryID
= (BigDecimal) state.getValue(m_categoriesParam);
if (StringUtils.emptyString(terms) &&
StringUtils.emptyString(author) &&
StringUtils.emptyString(mimeType) &&
endDate == null &&
startDate == null &&
categoryID == null &&
workspaceID == null) {
m_emptyLabel.setVisible(state,true);
if (StringUtils.emptyString(terms) && StringUtils.emptyString(author) && StringUtils.
emptyString(mimeType) && endDate == null && startDate == null && categoryID
== null
&& workspaceID == null) {
m_emptyLabel.setVisible(state, true);
m_validated.set(state, new Boolean(false));
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) {
m_segmentHeader.setVisibleComponent
(e.getPageState(),m_emptyLabel);
m_segmentHeader.setVisibleComponent(e.getPageState(), m_emptyLabel);
}
public void process(FormSectionEvent e) {
PageState state = e.getPageState();
SearchResults results = getSearchHits(state);
if(results != null &&
results.getTotalSize() > 0) {
m_segmentHeader.setVisibleComponent
(state,m_hasResultsLabel);
if (results != null && results.getTotalSize() > 0) {
m_segmentHeader.setVisibleComponent(state, m_hasResultsLabel);
s_log.debug("results");
} else {
m_segmentHeader.setVisibleComponent
(state,m_noResultsLabel);
m_segmentHeader.setVisibleComponent(state, m_noResultsLabel);
s_log.debug("no results");
}
}
public SearchResults getSearchHits( PageState state ) {
public SearchResults getSearchHits(PageState state) {
SearchResults coln = (SearchResults) m_coln.get(state);
if (coln == null &&
m_submit.isSelected(state) &&
((Boolean) m_validated.get(state)).booleanValue()) {
String terms = (String)state.getValue(m_termsParam);
String author = (String)state.getValue(m_authorParam);
String mimeType = (String)state.getValue(m_mimeTypeParam);
Date endDate = (Date)state.getValue(m_endDateParam);
Date startDate = (Date)state.getValue(m_startDateParam);
BigDecimal workspaceID = (BigDecimal)state.getValue(m_workspaceParam);
if (coln == null && m_submit.isSelected(state) && ((Boolean) m_validated.get(state)).
booleanValue()) {
String terms = (String) state.getValue(m_termsParam);
String author = (String) state.getValue(m_authorParam);
String mimeType = (String) state.getValue(m_mimeTypeParam);
Date endDate = (Date) state.getValue(m_endDateParam);
Date startDate = (Date) state.getValue(m_startDateParam);
BigDecimal workspaceID = (BigDecimal) state.getValue(m_workspaceParam);
String[] sections = null;
if (!LuceneSearcher.class.equals(SearchUtils.getSearcher().getClass())) {
sections = (String[]) new String[]
{m_docsContentSection.getID().toString()};
sections = (String[]) new String[]{m_docsContentSection.getID().toString()};
}
// don't need this since all types in this section are documents
//String[] types = (String[])state.getValue(m_typesParam);
String[] types = null;
BigDecimal rootCategoryID =
m_docsContentSection.getRootCategory().getID();
BigDecimal rootCategoryID
= m_docsContentSection.getRootCategory().getID();
ArrayList categoryIDs = new ArrayList();
if (!LuceneSearcher.class.equals(SearchUtils.getSearcher().getClass())) {
BigDecimal categoryID =
(BigDecimal) state.getValue(m_categoriesParam);
if (categoryID != null &&
!categoryID.equals(rootCategoryID)) {
BigDecimal categoryID
= (BigDecimal) state.getValue(m_categoriesParam);
if (categoryID != null && !categoryID.equals(rootCategoryID)) {
categoryIDs.add(categoryID.toString());
}
@ -302,7 +287,7 @@ class SearchPane extends SimpleContainer implements DMConstants
//if (terms != null && !"".equals(terms)) {
// 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,
author,
mimeType,
@ -322,49 +307,50 @@ class SearchPane extends SimpleContainer implements DMConstants
public boolean isVisible(PageState state) {
return true;
}
public long getSearchResultCount(PageState state) {
return m_coln.get(state) == null ? 0 :
((SearchResults)m_coln.get(state)).getTotalSize();
return m_coln.get(state) == null ? 0
: ((SearchResults) m_coln.get(state)).getTotalSize();
}
}
private class MimeTypesWidget extends SingleSelect {
public MimeTypesWidget (ParameterModel pm) {
public MimeTypesWidget(ParameterModel pm) {
super(pm);
addOption(new Option("",""));
addOption(new Option("excel","Excel document"));
addOption(new Option("html","HTML"));
addOption(new Option("acrobat","PDF"));
addOption(new Option("plain text","Plain text"));
addOption(new Option("powerpoint","Powerpoint file"));
addOption(new Option("rich text","Rich Text Format (rtf)"));
addOption(new Option("word","Word document"));
addOption(new Option("", ""));
addOption(new Option("excel", "Excel document"));
addOption(new Option("html", "HTML"));
addOption(new Option("acrobat", "PDF"));
addOption(new Option("plain text", "Plain text"));
addOption(new Option("powerpoint", "Powerpoint file"));
addOption(new Option("rich text", "Rich Text Format (rtf)"));
addOption(new Option("word", "Word document"));
}
}
private class WorkspacesPrintListener implements PrintListener {
public WorkspacesPrintListener() { }
public WorkspacesPrintListener() {
}
public void prepare(PrintEvent e) {
OptionGroup o = (OptionGroup)e.getTarget();
OptionGroup o = (OptionGroup) e.getTarget();
o.clearOptions();
PageState state = e.getPageState();
User user = Web.getWebContext().getUser();
o.addOption(new Option("",""));
DataQuery dq = SessionManager.getSession().retrieveQuery
("com.arsdigita.cms.docmgr.workspacesWithRepositories");
while(dq.next()) {
if (PermissionService.checkPermission
(new PermissionDescriptor
(PrivilegeDescriptor.READ,
o.addOption(new Option("", ""));
DataQuery dq = SessionManager.getSession().retrieveQuery(
"com.arsdigita.cms.docmgr.workspacesWithRepositories");
while (dq.next()) {
if (PermissionService.checkPermission(new PermissionDescriptor(
PrivilegeDescriptor.READ,
new OID(Document.BASE_DATA_OBJECT_TYPE,
dq.get("workspaceID")),
user.getOID()))) {
o.addOption(new Option
(((BigDecimal) dq.get("workspaceID")).toString(),
o.addOption(new Option(((BigDecimal) dq.get("workspaceID")).toString(),
(String) dq.get("title")));
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -251,6 +251,7 @@ public class PartyPermissionEdit extends CompoundComponent {
objectSelect.setPrintListener(new PrintListener() {
public void prepare(PrintEvent ev) {
SingleSelect target = (SingleSelect)ev.getTarget();
target.clearOptions();
PageState ps = ev.getPageState();
List options = (List) m_targetsRL.get(ps);
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.persistence.metadata.ObjectType;
class TypeSingleSelect extends SingleSelect {
private RequestLocal m_typesRL;
public TypeSingleSelect(ParameterModel param,
@ -40,12 +40,13 @@ class TypeSingleSelect extends SingleSelect {
"All Contained Items"));
setPrintListener(new PrintListener() {
public void prepare(PrintEvent ev) {
SingleSelect tgt = (SingleSelect)ev.getTarget();
SingleSelect tgt = (SingleSelect) ev.getTarget();
tgt.clearOptions();
PageState ps = ev.getPageState();
Iterator types =
((Collection)m_typesRL.get(ps)).iterator();
Iterator types
= ((Collection) m_typesRL.get(ps)).iterator();
while (types.hasNext()) {
ObjectType type = (ObjectType)types.next();
ObjectType type = (ObjectType) types.next();
tgt.addOption(new Option(type.getQualifiedName(),
type.getName()));
}
@ -54,7 +55,7 @@ class TypeSingleSelect extends SingleSelect {
}
public void generateXML(PageState ps, Element parent) {
Collection types = (Collection)m_typesRL.get(ps);
Collection types = (Collection) m_typesRL.get(ps);
if (types == null) {
parent.newChildElement("bebop:label", BEBOP_XML_NS);
return;

View File

@ -18,7 +18,6 @@
*/
package com.arsdigita.portalserver.ui.admin;
import com.arsdigita.portalserver.util.GlobalizationUtil;
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 $
*/
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 $";
private static final Logger s_cat =
Logger.getLogger(ApplicationsPane.class.getName());
private static final Logger s_cat
= Logger.getLogger(ApplicationsPane.class.getName());
final ModalContainer m_editContainer = new ModalContainer();
@ -91,18 +91,21 @@ public class DisplayPane extends DynamicListWizard {
DeleteTabForm m_deleteTabForm;
List m_layouts;
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;
static final String FOUR_SPACE_INDENT_STRING = "&nbsp;&nbsp;&nbsp;&nbsp;";
static class TabListModel implements ListModel {
PortalTabCollection m_tabs;
PortalTab m_currTab;
public TabListModel(PortalSite psite) {
m_tabs = psite.getTabsForPortalSite();
}
public boolean next() {
if (!m_tabs.next()) {
return false;
@ -110,52 +113,54 @@ public class DisplayPane extends DynamicListWizard {
m_currTab = m_tabs.getPortalTab();
return true;
}
public Object getElement() {
return m_currTab.getTitle();
}
public String getKey() {
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.",
new ListModelBuilder() {
public ListModel makeModel(List l, PageState ps) {
PortalSite psite = (PortalSite)portalsiteRL.get(ps);
PortalSite psite = (PortalSite) portalsiteRL.get(ps);
return new TabListModel(psite);
}
public void lock() {}
public boolean isLocked() { return true; }
public void lock() {
}
public boolean isLocked() {
return true;
}
},
"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;
// FORM FOR ADDING NEW TABS
Form addForm = new Form("addTab");
addForm.add(new Label(GlobalizationUtil.globalize("cw.workspace.ui.admin.new_tab_name")));
final TextField newTabName = new TextField("name");
newTabName.getParameterModel().addParameterListener
(new NotEmptyValidationListener());
newTabName.getParameterModel().addParameterListener(new NotEmptyValidationListener());
newTabName.setSize(40);
addForm.add(newTabName);
addForm.add(new Label());
addForm.add(new Submit("Add tab"));
addForm.addProcessListener(new FormProcessListener() {
public void process(FormSectionEvent ev) {
PageState ps = ev.getPageState();
PortalSite psite = (PortalSite)portalsiteRL.get(ps);
PortalTab newTab =
PortalTab.createTab((String)newTabName.getValue(ps),psite);
PortalSite psite = (PortalSite) portalsiteRL.get(ps);
PortalTab newTab
= PortalTab.createTab((String) newTabName.getValue(ps), psite);
psite.addPortalTab(newTab);
newTab.save();
psite.save();
@ -172,7 +177,7 @@ public class DisplayPane extends DynamicListWizard {
// CONSTRUCT EDIT COMPONENT
selectedTabIDRL = new RequestLocal() {
protected Object initialValue(PageState ps) {
String tabIDstr = (String)dlw.getSelectionModel()
String tabIDstr = (String) dlw.getSelectionModel()
.getSelectedKey(ps);
return new BigDecimal(tabIDstr);
}
@ -181,28 +186,30 @@ public class DisplayPane extends DynamicListWizard {
m_selectedPortletParam = new BigDecimalParameter("selectedPortlet");
m_mainDisplay = new BoxPanel(BoxPanel.VERTICAL);
PortletLayoutComponent plc =
new PortletLayoutComponent(portalsiteRL, selectedTabIDRL) {
PortletLayoutComponent plc
= new PortletLayoutComponent(portalsiteRL, selectedTabIDRL) {
protected void handleConfigure(PageState ps, BigDecimal id) {
ps.setValue(m_selectedPortletParam, id);
m_editContainer.setVisibleComponent(ps, m_portletModify);
}
};
LockableLinks locklinks =
new LockableLinks(portalsiteRL, selectedTabIDRL);
LockableLinks locklinks
= new LockableLinks(portalsiteRL, selectedTabIDRL);
m_mainDisplay.add(locklinks);
m_mainDisplay.add(plc);
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.addActionListener(new RenameLinkListener());
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) {
PortalSite psite = (PortalSite)portalsiteRL.get(ps);
PortalSite psite = (PortalSite) portalsiteRL.get(ps);
PortalTabCollection pstc = psite.getTabsForPortalSite();
return (pstc.size() > 1);
}
@ -213,8 +220,8 @@ public class DisplayPane extends DynamicListWizard {
m_mainDisplay.add(links);
final BigDecimalParameter portletTypeParam =
new BigDecimalParameter("typeID");
final BigDecimalParameter portletTypeParam
= new BigDecimalParameter("typeID");
Form addPortlet = new Form("ap1", new GridPanel(1)) {
public void register(Page p) {
super.register(p);
@ -226,8 +233,7 @@ public class DisplayPane extends DynamicListWizard {
SimpleContainer imageLabelSC = new SimpleContainer();
imageLabelSC.add(image);
imageLabelSC.add(new Label
("To add a portlet to this page, first choose a type: "));
imageLabelSC.add(new Label("To add a portlet to this page, first choose a type: "));
addPortlet.add(imageLabelSC);
@ -239,9 +245,10 @@ public class DisplayPane extends DynamicListWizard {
ptc.addOrder("title");
while (ptc.next()) {
ApplicationType providerAppType = ptc.getPortletType().getProviderApplicationType();
if ( providerAppType != null ) {
portletTypeSelect.addOption(new Option(ptc.getID().toString(), ptc.getTitle() +
" (" + providerAppType.getTitle() + ") "));
if (providerAppType != null) {
portletTypeSelect.addOption(new Option(ptc.getID().toString(), ptc.getTitle() + " ("
+ providerAppType.
getTitle() + ") "));
} else {
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);
ListModelBuilder lmb = new ListModelBuilder()
{
ListModelBuilder lmb = new ListModelBuilder() {
boolean m_isLocked;
public ListModel makeModel(List l, PageState pageState)
{
return new LayoutListModel (pageState);
public ListModel makeModel(List l, PageState pageState) {
return new LayoutListModel(pageState);
}
public void lock()
{
public void lock() {
m_isLocked = true;
}
public boolean isLocked()
{
public boolean isLocked() {
return m_isLocked;
}
};
@ -291,15 +294,14 @@ public class DisplayPane extends DynamicListWizard {
m_layouts.setCellRenderer(new LayoutListCellRenderer());
m_layouts.addChangeListener(new ChangeListener () {
public void stateChanged(ChangeEvent e)
{
m_layouts.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
PageState ps = e.getPageState();
String key = (String) ((List) dlw.getListingComponent())
.getSelectedKey(ps);
BigDecimal bd = new BigDecimal(key);
PortalTab ptab = PortalTab.retrieveTab(bd);
String laykey = (String)m_layouts.getSelectedKey(ps);
String laykey = (String) m_layouts.getSelectedKey(ps);
Integer lk = new Integer(laykey);
ptab.setLayout(m_layoutNames[lk.intValue()]);
ptab.save();
@ -310,9 +312,8 @@ public class DisplayPane extends DynamicListWizard {
m_mainDisplay.add(tabLayouts);
m_portletAddForm =
new PortletAddForm(portalsiteRL, selectedTabIDRL, new RequestLocal() {
m_portletAddForm
= new PortletAddForm(portalsiteRL, selectedTabIDRL, new RequestLocal() {
protected Object initialValue(PageState ps) {
BigDecimal id = (BigDecimal) ps.getValue(portletTypeParam);
if (id == null) {
@ -330,8 +331,8 @@ public class DisplayPane extends DynamicListWizard {
RequestLocal selectedPortletRL = new RequestLocal() {
public Object initialValue(PageState ps) {
BigDecimal portletID =
(BigDecimal)ps.getValue(m_selectedPortletParam);
BigDecimal portletID
= (BigDecimal) ps.getValue(m_selectedPortletParam);
if (portletID == null) {
return null;
}
@ -345,8 +346,7 @@ public class DisplayPane extends DynamicListWizard {
ps.setValue(m_selectedPortletParam, null);
}
};
m_portletModify = new ApplicationModifyComponent
(selectedPortletRL, true, reset, reset);
m_portletModify = new ApplicationModifyComponent(selectedPortletRL, true, reset, reset);
m_renameTabForm = new RenameTabForm(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,
//this code preselects it, unless the add tab link has been
//clicked.
((List) getListingComponent()).setCellRenderer(new ListCellRenderer() {
public Component getComponent(List list,PageState state,
Object value,String key, int index,boolean isSelected) {
public Component getComponent(List list, PageState state,
Object value, String key, int index, boolean isSelected) {
Label tabName;
int indent_ctr = 0;
@ -399,30 +398,28 @@ public class DisplayPane extends DynamicListWizard {
//If only one tab, select it ONLY if addtablink not selected
// and then get outa here...
if(size == 1)
{
if((dlw.getAddLink().isSelected(state)) == false)
{
list.setSelectedKey(state,key);
if (size == 1) {
if ((dlw.getAddLink().isSelected(state)) == false) {
list.setSelectedKey(state, key);
tabName = new Label(value.toString());
container.add(tabName);
//Update tab request local
selectedTabIDRL.set(state,bd);
selectedTabIDRL.set(state, bd);
return container;
}
}
else //more than one tab...
} else //more than one tab...
{
indent_ctr = 0;
while(ptcoll.next())
{
while (ptcoll.next()) {
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;
if(indent_ctr == size)
}
if (indent_ctr == size) {
isLast = true;
}
break;
}
}
@ -431,8 +428,7 @@ public class DisplayPane extends DynamicListWizard {
//Code below constructs proper indent for tab
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);
}
@ -440,48 +436,45 @@ public class DisplayPane extends DynamicListWizard {
//This could be done below in the particular cases for
//a slight performance benefit, but putting them
//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.setFontWeight(Label.BOLD);
Label labelLeft = new Label(GlobalizationUtil.globalize("cw.workspace.ui.admin.shift_left"));
Label labelRight = new Label(GlobalizationUtil.globalize("cw.workspace.ui.admin.shift_right"));
Label labelLeft = new Label(GlobalizationUtil.globalize(
"cw.workspace.ui.admin.shift_left"));
Label labelRight = new Label(GlobalizationUtil.globalize(
"cw.workspace.ui.admin.shift_right"));
ControlLink linkLeft = new ControlLink(labelLeft) {
public void setControlEvent(PageState s) {
s.setControlEvent(dlw,"left","1");
s.setControlEvent(dlw, "left", "1");
}
};
ControlLink linkRight = new ControlLink(labelRight) {
public void setControlEvent(PageState s) {
s.setControlEvent(dlw,"right","1");
s.setControlEvent(dlw, "right", "1");
}
};
linkLeft.setClassAttr("shiftleft");
linkRight.setClassAttr("shiftright");
if(isFirst)
{
if (isFirst) {
container.add(tabName);
container.add(linkRight);
}
else if(isLast)
{
} else if (isLast) {
container.add(linkLeft);
container.add(tabName);
}
else //This tab is somewhere in the middle...
} else //This tab is somewhere in the middle...
{
container.add(linkLeft);
container.add(tabName);
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();
tabName = new Label(ttab,false);
tabName = new Label(ttab, false);
ControlLink l = new ControlLink(tabName);
container.add(l);
}
@ -489,7 +482,6 @@ public class DisplayPane extends DynamicListWizard {
}
});
} //end of constructor
public void register(Page p) {
@ -497,53 +489,55 @@ public class DisplayPane extends DynamicListWizard {
p.addComponentStateParam(this, m_selectedPortletParam);
}
public void respond(PageState state) throws javax.servlet.ServletException{
String tabIDstr =
(String)this.getSelectionModel()
public void respond(PageState state) throws javax.servlet.ServletException {
String tabIDstr
= (String) this.getSelectionModel()
.getSelectedKey(state);
BigDecimal tabID = new BigDecimal(tabIDstr);
String name = state.getControlEventName();
if(name.compareTo("left") == 0) {
if (name.compareTo("left") == 0) {
PortalTab ptab = PortalTab.retrieveTab(tabID);
PortalSite psite = ptab.getPortalSite();
psite.swapTabWithPrevious(ptab);
} else if(name.compareTo("right") == 0) {
} else if (name.compareTo("right") == 0) {
PortalTab ptab = PortalTab.retrieveTab(tabID);
PortalSite psite = ptab.getPortalSite();
psite.swapTabWithNext(ptab);
}
}
public class RenameTabForm extends Form implements FormProcessListener {
private TextField currenttabName;
private Label instruction;
private Submit button,cancelbutton;
private Submit button, cancelbutton;
private RequestLocal m_tabIDRL;
public RenameTabForm(RequestLocal SelectedTabIDRL) {
super("renametabform");
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.setDefaultValue("");
currenttabName.setSize(40);
currenttabName.addValidationListener
(new NotNullValidationListener("Every Tab must have a name!"));
currenttabName.addValidationListener(new NotNullValidationListener(
"Every Tab must have a name!"));
try {
currenttabName.addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) {
PageState s = e.getPageState();
BigDecimal tabID = (BigDecimal)m_tabIDRL.get(s);
BigDecimal tabID = (BigDecimal) m_tabIDRL.get(s);
PortalTab ptab = PortalTab.retrieveTab(tabID);
TextField tf = (TextField)e.getTarget();
tf.setValue(s,ptab.getTitle());
TextField tf = (TextField) e.getTarget();
tf.setValue(s, ptab.getTitle());
}
});
} catch(java.util.TooManyListenersException e) { }
} catch (java.util.TooManyListenersException e) {
}
button = new Submit("Rename tab");
button.setButtonLabel("Rename tab");
cancelbutton = new Submit("Cancel");
@ -558,8 +552,8 @@ public class DisplayPane extends DynamicListWizard {
public void process(FormSectionEvent e) {
PageState s = e.getPageState();
if(button.isSelected(s)) {
BigDecimal tabID = (BigDecimal)m_tabIDRL.get(s);
if (button.isSelected(s)) {
BigDecimal tabID = (BigDecimal) m_tabIDRL.get(s);
PortalTab ptab = PortalTab.retrieveTab(tabID);
ptab.setTitle(currenttabName.getValue(s).toString());
ptab.save();
@ -570,25 +564,26 @@ public class DisplayPane extends DynamicListWizard {
} //end rename form
public class DeleteTabForm extends Form implements FormProcessListener {
private TextField currenttabName;
private Label instruction;
private Submit button;
private Submit cancelbutton;
private RequestLocal m_tabIDRL;
public DeleteTabForm(RequestLocal SelectedTabIDRL) {
super("deletetabform");
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() {
public void prepare(PrintEvent e) {
PageState s = e.getPageState();
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);
Label t = (Label)e.getTarget();
Label t = (Label) e.getTarget();
t.setLabel(prefixstr + ptab.getTitle() + " tab?");
}
});
@ -606,8 +601,8 @@ public class DisplayPane extends DynamicListWizard {
public void process(FormSectionEvent e) {
PageState s = e.getPageState();
if(button.isSelected(s)) {
BigDecimal tabID = (BigDecimal)m_tabIDRL.get(s);
if (button.isSelected(s)) {
BigDecimal tabID = (BigDecimal) m_tabIDRL.get(s);
PortalTab ptab = PortalTab.retrieveTab(tabID);
ptab.delete();
getSelectionModel().clearSelection(s);
@ -618,6 +613,7 @@ public class DisplayPane extends DynamicListWizard {
} //end delete form
private class RenameLinkListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
PageState ps = event.getPageState();
m_editContainer.setVisibleComponent(ps, m_renameTabForm);
@ -625,19 +621,19 @@ public class DisplayPane extends DynamicListWizard {
}
private class DeleteLinkListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
PageState ps = event.getPageState();
m_editContainer.setVisibleComponent(ps, m_deleteTabForm);
}
}
private class LayoutListModel implements ListModel
{
private class LayoutListModel implements ListModel {
Vector vec;
ListIterator vl;
LayoutListModel (PageState pageState)
{
LayoutListModel(PageState pageState) {
vec = new Vector();
vec.add("W");
vec.add("NW");
@ -648,18 +644,15 @@ public class DisplayPane extends DynamicListWizard {
vl = vec.listIterator();
}
public boolean next()
{
public boolean next() {
return vl.hasNext();
}
public Object getElement()
{
public Object getElement() {
return vl.next();
}
public String getKey()
{
public String getKey() {
int dex = vl.previousIndex();
dex = dex + 1;
//Integer it = new Integer(vl.previousIndex());
@ -668,26 +661,21 @@ public class DisplayPane extends DynamicListWizard {
}
}
class LayoutListCellRenderer implements ListCellRenderer
{
public Component getComponent
(List list, PageState pageState, Object value, String key,
int index, boolean isSelected)
{
String val = (String)value;
class LayoutListCellRenderer implements ListCellRenderer {
public Component getComponent(List list, PageState pageState, Object value, String key,
int index, boolean isSelected) {
String val = (String) value;
//check if selected...if not selected
//find out what index we are...
//then set an attribute on the link so that it is replaced
//with an image link in the stylesheet.
//if selected, return a label with a selected attr and value...
if(isSelected)
{
if (isSelected) {
Label label = new Label(val);
label.setClassAttr(val);
return label;
}
else
{
} else {
ControlLink link = new ControlLink(val);
link.setClassAttr(val);
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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.arsdigita.portalworkspace.ui;
import com.arsdigita.bebop.Form;
@ -63,15 +62,17 @@ public class ApplicationSelector extends Form {
/**
* Convenient Constructor
*
* @param type
* @param app
*/
public ApplicationSelector(ApplicationType type,DomainObjectParameter app) {
public ApplicationSelector(ApplicationType type, DomainObjectParameter app) {
this(type, app, null);
}
/**
* Constructor
*
* @param type
* @param app
* @param privilege
@ -85,8 +86,7 @@ public class ApplicationSelector extends Form {
m_app = app;
m_privilege = privilege;
s_log.debug("displayed applications will be filtered by privilege " +
m_privilege);
s_log.debug("displayed applications will be filtered by privilege " + m_privilege);
m_apps = new SingleSelect(new DomainObjectParameter("apps"));
m_apps.addValidationListener(new NotNullValidationListener());
@ -108,6 +108,7 @@ public class ApplicationSelector extends Form {
*
*/
private class AppSubmissionListener implements FormSubmissionListener {
public void submitted(FormSectionEvent e)
throws FormProcessException {
if (m_buttons.getCancelButton().isSelected(e.getPageState())) {
@ -152,11 +153,12 @@ public class ApplicationSelector extends Form {
if (user == null) {
user = Kernel.getPublicUser();
}
PermissionService.filterObjects(apps,m_privilege, user.getOID());
PermissionService.filterObjects(apps, m_privilege, user.getOID());
}
apps.addOrder("primaryURL");
SingleSelect t = (SingleSelect) e.getTarget();
t.clearOptions();
t.addOption(new Option(null, "--select one--"));
while (apps.next()) {
Application app = apps.getApplication();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -15,7 +15,6 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.arsdigita.portalworkspace.ui.portlet;
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>
*/
public class FlashPortletEditor extends PortletConfigFormSection
{
public class FlashPortletEditor extends PortletConfigFormSection {
private TextField m_backgroundColour;
private TextField m_detectKey;
@ -63,25 +62,23 @@ public class FlashPortletEditor extends PortletConfigFormSection
private TextField m_xiRedirectUrl;
public FlashPortletEditor(ResourceType resType, RequestLocal parentAppRL)
{
public FlashPortletEditor(ResourceType resType, RequestLocal parentAppRL) {
super(resType, parentAppRL);
}
public FlashPortletEditor(RequestLocal application)
{
public FlashPortletEditor(RequestLocal application) {
super(application);
}
protected void addWidgets()
{
protected void addWidgets() {
super.addWidgets();
m_file = this.addTextField(FlashPortlet.SWF_FILE, "SWF file", 64, 2048, true);
m_width = this.addTextField(FlashPortlet.WIDTH, "Width", 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_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_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_detectKey = this.addTextField(FlashPortlet.DETECT_KEY, "Detect key", 32, 32, false);
m_redirectUrl = this.addTextField(FlashPortlet.REDIRECT_URL, "Redirect URL", 64, 2048, false);
m_xiRedirectUrl = this.addTextField(FlashPortlet.XI_REDIRECT_URL, "XI Redirect URL", 64, 2048, false);
m_redirectUrl = this.
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);
if (portlet != null)
{
if (portlet != null) {
FlashPortlet flashPortlet = (FlashPortlet) portlet;
// Load the form from the portlet
@ -123,12 +121,11 @@ public class FlashPortletEditor extends PortletConfigFormSection
m_width.setValue(state, flashPortlet.getWidth());
m_xiRedirectUrl.setValue(state, flashPortlet.getXiRedirectUrl());
m_quality.setValue(state, flashPortlet.getQuality());
}
else
{
} else {
// Set defaults
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_height.setValue(state, "100%");
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);
FlashPortlet flashPortlet = (FlashPortlet) portlet;
@ -159,32 +155,27 @@ public class FlashPortletEditor extends PortletConfigFormSection
/**
* Add a new text field.
*
* @param name
* the name of the parameter
* @param label
* the label to be displayed
* @param size
* 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
* @param name the name of the parameter
* @param label the label to be displayed
* @param size 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
*/
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));
field.setSize(size);
field.setMaxLength(maxLength);
// Add validation
if (mandatory)
{
if (mandatory) {
field.addValidationListener(new NotEmptyValidationListener());
}
// 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);
return field;
}
@ -192,30 +183,24 @@ public class FlashPortletEditor extends PortletConfigFormSection
/**
* Add a new text area.
*
* @param name
* the name of the parameter
* @param label
* the label to be displayed
* @param rows
* the visible rows
* @param cols
* the visible cols
* @param mandatory
* denotes whether this text field requires a value
* @param name the name of the parameter
* @param label the label to be displayed
* @param rows the visible rows
* @param cols the visible cols
* @param mandatory denotes whether this text field requires a value
* @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);
// Add validation
if (mandatory)
{
if (mandatory) {
field.addValidationListener(new NotEmptyValidationListener());
}
// 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);
return field;
}
@ -223,26 +208,22 @@ public class FlashPortletEditor extends PortletConfigFormSection
/**
* Add a new single select.
*
* @param name
* the name of the parameter
* @param label
* the label to be displayed
* @param mandatory
* denotes whether this text field requires a value
* @param name the name of the parameter
* @param label the label to be displayed
* @param mandatory denotes whether this text field requires a value
* @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));
// Add validation
if (mandatory)
{
if (mandatory) {
field.addValidationListener(new NotEmptyValidationListener());
}
// 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);
return field;
}

View File

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

View File

@ -17,7 +17,8 @@
*
*/
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.FormProcessListener;
@ -66,7 +67,6 @@ public class AnswerValuesPanel extends SimpleContainer {
// 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
private SurveySelectionModel m_survey;
private static final String QUESTION_TEXT = "questionText";
private static final String ANSWER_TEXT = "answerText";
@ -85,8 +85,9 @@ public class AnswerValuesPanel extends SimpleContainer {
private ActionLink m_complete;
private Link m_back;
private static org.apache.log4j.Logger s_log =
org.apache.log4j.Logger.getLogger(AnswerValuesPanel.class.getName());
private static org.apache.log4j.Logger s_log
= org.apache.log4j.Logger.getLogger(
AnswerValuesPanel.class.getName());
private DataTable m_answerTable;
@ -98,38 +99,41 @@ public class AnswerValuesPanel extends SimpleContainer {
m_questionText = 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() {
public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState();
m_answerTable.setVisible(ps, true);
m_answerValuesForm.setVisible(ps, false);
m_complete.setVisible(ps,false);
m_complete.setVisible(ps, false);
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_back);
setupAnswerTable();
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_surveyID = new BigDecimalParameter("survey_id");
p.addGlobalStateParam(m_optionID);
p.addGlobalStateParam(m_surveyID);
p.addRequestListener( new RequestListener() {
p.addRequestListener(new RequestListener() {
public void pageRequested(RequestEvent e) {
PageState ps = e.getPageState();
if ( ps.getValue(m_optionID) == null ||
m_answerValuesForm.getFormData(ps).isSubmission()) {
if (ps.getValue(m_optionID) == null || m_answerValuesForm.getFormData(ps).
isSubmission()) {
m_answerTable.setVisible(ps, true);
m_answerValuesForm.setVisible(ps, false);
m_complete.setVisible(ps,false);
m_complete.setVisible(ps, false);
m_back.setVisible(ps, true);
} /*else {
m_answerTable.setVisible(ps, false);
@ -148,6 +152,7 @@ public class AnswerValuesPanel extends SimpleContainer {
}
dq.close();
}*/
}
});
}
@ -156,16 +161,17 @@ public class AnswerValuesPanel extends SimpleContainer {
String s = (String) m_questionText.get(ps);
return s.substring(6, s.length());
}
private String getAnswerText(PageState ps) {
String s = (String) m_answerText.get(ps);
return s;
}
private BigDecimal getAnswerValue(PageState ps) {
BigDecimal bi = (BigDecimal) m_answerValue.get(ps);
return bi;
}
private void setupAnswerTable() {
// 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,
false, new QuestionTextRenderer());
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());
c2.setHeaderRenderer(new GlobalizedHeaderRenderer());
c3.setHeaderRenderer(new GlobalizedHeaderRenderer());
// Add a single select box widget to each possible answer
// The admin can select a point value for each answer
TableColumn editValueColumn = new TableColumn();
@ -189,9 +195,10 @@ public class AnswerValuesPanel extends SimpleContainer {
add(m_answerTable);
}
private BigDecimal getSurveyID(PageState ps) {
BigDecimal surveyID = null;
if ( ps.getValue(m_surveyID) == null ) {
if (ps.getValue(m_surveyID) == null) {
Survey s = m_survey.getSelectedSurvey(ps);
surveyID = s.getID();
} else {
@ -204,7 +211,8 @@ public class AnswerValuesPanel extends SimpleContainer {
m_answerValuesForm = new AnswerValuesForm();
add(m_answerValuesForm);
}
private class AnswerValueActionListener extends TableActionAdapter{
private class AnswerValueActionListener extends TableActionAdapter {
public void cellSelected(TableActionEvent e) {
PageState ps = e.getPageState();
@ -219,17 +227,18 @@ public class AnswerValuesPanel extends SimpleContainer {
DataQuery dq = SessionManager.getSession().retrieveQuery(query);
dq.setParameter("optionID", optionID);
if ( dq.next()) {
if (dq.next()) {
m_questionText.set(ps, (String) dq.get(QUESTION_TEXT));
m_answerText.set(ps, (String) dq.get(ANSWER_TEXT));
m_answerValue.set(ps, (BigDecimal) dq.get(ANSWER_VALUE));
m_select.setValue(ps,getAnswerValue(ps));
m_select.setValue(ps, getAnswerValue(ps));
}
dq.close();
}
}
private class AnswerValuesForm extends Form {
private AnswerValuesForm() {
@ -271,28 +280,35 @@ public class AnswerValuesPanel extends SimpleContainer {
addInitListener(new AnswerValuesInitListener());
}
}
private class AnswerValuesProcessListener implements FormProcessListener {
public void process(FormSectionEvent e) throws FormProcessException {
PageState ps = e.getPageState();
FormData fd = e.getFormData();
BigDecimal optionID = (BigDecimal) ps.getValue(m_optionID);
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("answerValue", answerValue);
dao.execute();
ps.setValue(m_optionID, null);
}
}
private class AnswerValuesInitListener implements FormInitListener {
public void init(FormSectionEvent e) throws FormProcessException {
PageState ps = e.getPageState();
s_log.warn("Setting value of select to " + getAnswerValue(ps));
m_select.setValue(ps, getAnswerValue(ps));
}
}
private class GlobalizedHeaderRenderer implements TableCellRenderer {
public Component getComponent(Table table, PageState state, Object value,
boolean isSelected, Object key, int row,
int column) {
@ -304,23 +320,26 @@ public class AnswerValuesPanel extends SimpleContainer {
return label;
}
}
private class QuestionTextRenderer implements TableCellRenderer {
@Override
public Component getComponent(Table table, PageState state, Object value,
boolean isSelected, Object key, int row,
int column) {
if ( ! isLocked() && table != null && table.isLocked() ) {
if (!isLocked() && table != null && table.isLocked()) {
lock();
}
if ( value == null ) {
if (value == null) {
return new Label("");
}
String question = (String) value;
// 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 {
@Override
@ -328,10 +347,10 @@ public class AnswerValuesPanel extends SimpleContainer {
boolean isSelected, Object key, int row,
int column) {
if ( ! isLocked() && table != null && table.isLocked() ) {
if (!isLocked() && table != null && table.isLocked()) {
lock();
}
if ( value == null ) {
if (value == null) {
return new Label("");
}
/*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());
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;
}
}
private class AnswerListingBuilder implements DataQueryBuilder {
private final static String KEY_COLUMN = "optionID";
public boolean m_locked;
public AnswerListingBuilder() {
super();
}
public DataQuery makeDataQuery(DataTable t, PageState ps) {
final String query = "com.arsdigita.simplesurvey.getAnswerOptions";
DataQuery dq = SessionManager.getSession().retrieveQuery(query);
@ -364,9 +387,11 @@ public class AnswerValuesPanel extends SimpleContainer {
public String getKeyColumn() {
return KEY_COLUMN;
}
public void lock() {
m_locked = true;
}
public boolean isLocked() {
return m_locked;
}

View File

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

View File

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

View File

@ -103,15 +103,16 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
try {
HttpServletRequest request = state.getRequest();
id = new BigDecimal(request.getParameter(Webpage.ID));
}
catch (Exception ex) {
} catch (Exception ex) {
}
m_createForm.setVisible(state, id == null);
m_editForm.setVisible(state, id != null);
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;
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.");
webpage = null;
}
}
catch (Exception ex) {
} catch (Exception ex) {
}
m_categories.setPrintListener(new CategoriesPrintListener(section));
@ -266,8 +266,7 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
assignedCats.add(catID);
}
m_categories.setValue(state, assignedCats.toArray());
}
else {
} else {
m_categories.setValue(state, new String[]{request.getParameter("categoryID")});
if (m_displayDates) {
final java.util.Date start = new java.util.Date(System.currentTimeMillis());
@ -280,15 +279,13 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
// return 12.
if (calendar.get(Calendar.HOUR) == 0) {
m_startHour.setValue(state, new Integer(12));
}
else {
} else {
m_startHour.setValue(state, new Integer(calendar.get(Calendar.HOUR)));
}
final Integer min = new Integer(calendar.get(Calendar.MINUTE));
if (min.intValue() < 10) {
m_startMinute.setValue(state, "0" + min.toString());
}
else {
} else {
m_startMinute.setValue(state, min.toString());
}
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");
}
}
@ -369,8 +366,7 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
BigDecimal id = new BigDecimal(idTxt);
webpage = new Webpage(id);
}
}
catch (Exception ex) {
} catch (Exception ex) {
throw new FormProcessException(ex);
}
@ -381,7 +377,7 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
User user = Web.getWebContext().getUser();
if (webpage != null) {
if ( !sm.canAccess(user, SecurityConstants.EDIT_ITEM, webpage ) ) {
if (!sm.canAccess(user, SecurityConstants.EDIT_ITEM, webpage)) {
throw new FormProcessException("Insufficient permissions");
}
if (!webpage.getContentSection().equals(section)) {
@ -394,9 +390,8 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
webpage.setCategories((String[]) m_categories.getValue(state));
webpage.setDescription((String) m_desc.getValue(state));
webpage.save();
}
else {
if ( !sm.canAccess(user, SecurityConstants.NEW_ITEM ) ) {
} else {
if (!sm.canAccess(user, SecurityConstants.NEW_ITEM)) {
throw new FormProcessException("Insufficient permissions");
}
webpage = new Webpage();
@ -421,8 +416,7 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
if (lfColl.next()) {
lifecycleDefinition = lfColl.getLifecycleDefinition();
}
}
finally {
} finally {
if (lfColl != null) {
lfColl.close();
}
@ -440,8 +434,7 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
flow.start(Web.getWebContext().getUser());
flow.save();
}
}
finally {
} finally {
if (taskColl != null) {
taskColl.close();
}
@ -452,22 +445,22 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
Engine engine = Engine.getInstance();
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;
do {
while (i.hasNext()) {
task = (CMSTask) i.next();
try {
task.finish();
}
catch (Exception ex) {
} catch (Exception ex) {
throw new FormProcessException(ex);
}
}
i = engine.getEnabledTasks(Web.getWebContext().getUser(), workflow.getID()).iterator();
}
while (i.hasNext());
i = engine.getEnabledTasks(Web.getWebContext().getUser(), workflow.
getID()).iterator();
} while (i.hasNext());
// publish
if (lifecycleDefinition != null) {
@ -485,22 +478,22 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
}
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();
start.setTime(startDate);
start.set(Calendar.AM_PM, startAmpm.intValue());
start.set(Calendar.MINUTE, startMinute.intValue());
start.set(Calendar.AM_PM, startAmpm.intValue());
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());
}
else {
} else {
if (startAmpm.intValue() == 0) {
start.set(Calendar.HOUR_OF_DAY, 0);
start.set(Calendar.HOUR, 0);
}
else {
} else {
start.set(Calendar.HOUR_OF_DAY, 12);
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.AM_PM, endAmpm.intValue());
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());
}
else {
} else {
if (endAmpm.intValue() == 0) {
end.set(Calendar.HOUR_OF_DAY, 0);
end.set(Calendar.HOUR, 0);
}
else {
} else {
end.set(Calendar.HOUR_OF_DAY, 12);
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());
}
@ -562,13 +553,11 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
}
}
commitTransaction = true;
}
finally {
} finally {
if (txn != null && isMyTransaction) {
if (commitTransaction) {
txn.commitTxn();
}
else {
} else {
txn.abortTxn();
}
}
@ -577,13 +566,13 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
try {
DispatcherHelper.sendRedirect(request, state.getResponse(), section.getPath());
}
catch (IOException ex) {
} catch (IOException ex) {
throw new FormProcessException(ex);
}
}
public class TimeZonePrinter implements PrintListener {
public void prepare(PrintEvent e) {
final Label target = (Label) e.getTarget();
final PageState state = e.getPageState();