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,37 +74,39 @@ 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()));
}
m_item = new SingleSelect(new StringParameter("item"));
try {
m_item.addPrintListener(new PrintListener() {
public void prepare(PrintEvent event) {
OptionGroup group = (SingleSelect) event.getTarget();
PageState state = event.getPageState();
boolean valueSet = false;
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();
Category category = ((ItemProvider) m_provider.getSelectedObject(state))
.getCategory();
CategorizedCollection children = category.getObjects(ContentItem.BASE_DATA_OBJECT_TYPE);
children.addOrder("name");
CategorizedCollection children = category.getObjects(
ContentItem.BASE_DATA_OBJECT_TYPE);
children.addOrder("name");
while (children.next()) {
ACSObject item = (ACSObject) children.getDomainObject();
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()));
}
group.addOption(new Option(item.getID().toString(),
((ContentItem) item).getName()));
}
}
});
}
});
} catch (TooManyListenersException e) {
//s_log.error("Error adding init listener to Radio Group", e);
throw new UncheckedWrapperException(e);
@ -123,8 +124,9 @@ public class ItemProviderAliasForm extends Form {
}
private class ProviderSubmissionListener implements FormSubmissionListener {
public void submitted(FormSectionEvent e)
throws FormProcessException {
throws FormProcessException {
PageState state = e.getPageState();
if (m_buttons.getCancelButton().isSelected(state)) {
@ -135,27 +137,27 @@ public class ItemProviderAliasForm extends Form {
}
private class ProviderProcessListener implements FormProcessListener {
public void process(FormSectionEvent e)
throws FormProcessException {
throws FormProcessException {
PageState state = e.getPageState();
ItemProvider provider = (ItemProvider) m_provider
.getSelectedObject(state);
.getSelectedObject(state);
BigDecimal itemId = new BigDecimal(m_item.getValue(state).toString());
ContentItem item = new ContentItem(itemId);
ContentItem item = new ContentItem(itemId);
String letter = (String)m_letter.getValue(state);
String 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);
alias.setContentItem(item);
alias.setItemProvider(provider);
alias.save();
ItemAlias alias = (ItemAlias) Classes.newInstance(ItemAlias.class);
alias.setTitle(title);
alias.setLetter(letter);
alias.setContentItem(item);
alias.setItemProvider(provider);
alias.save();
fireCompletionEvent(state);
}

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

@ -56,12 +56,12 @@ import com.arsdigita.cms.ItemSelectionModel;
* @version $Id$
*/
public class DecisionTreeOptionEditForm extends Form
implements FormInitListener,
FormProcessListener,
FormSubmissionListener {
implements FormInitListener,
FormProcessListener,
FormSubmissionListener {
private final static Logger s_log = Logger.getLogger(
DecisionTreeOptionEditForm.class);
DecisionTreeOptionEditForm.class);
private ItemSelectionModel m_selTree;
private ItemSelectionModel m_selOption;
@ -71,9 +71,9 @@ public class DecisionTreeOptionEditForm extends Form
private SaveCancelSection m_saveCancelSection;
private SingleSelect m_sectionWidget;
public static final String LABEL = "label";
public static final String VALUE = "value";
public static final String SECTION = "section";
public static final String LABEL = "label";
public static final String VALUE = "value";
public static final String SECTION = "section";
/**
* Constructor.
@ -82,14 +82,14 @@ public class DecisionTreeOptionEditForm extends Form
* @param selOption the current section
*/
public DecisionTreeOptionEditForm(ItemSelectionModel selTree,
ItemSelectionModel selOption) {
ItemSelectionModel selOption) {
this(selTree, selOption, null);
}
/**
* Constructor.
*
* @param selTree the current decision tree
* @param selTree the current decision tree
* @param selOption the current section
* @param container container which this form is added to
*/
@ -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() {
@ -143,9 +144,11 @@ public class DecisionTreeOptionEditForm extends Form
* Set up the dynamic options for the section select widget.
*/
private void initSectionOptions(PrintEvent e) {
PageState state = e.getPageState();
SingleSelect target = (SingleSelect) e.getTarget();
DecisionTree tree = (DecisionTree)m_selTree.getSelectedObject(state);
PageState state = e.getPageState();
SingleSelect target = (SingleSelect) e.getTarget();
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
@ -185,111 +189,109 @@ public class DecisionTreeOptionEditForm extends Form
*/
protected void addWidgets() {
Option pleaseSelect = new Option(
"",
new Label(DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.options.form.please_select")
));
"",
new Label(DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.options.form.please_select")
));
add(new Label(DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.options.form.section")));
m_sectionWidget = new SingleSelect(SECTION);
m_sectionWidget.addValidationListener(new NotNullValidationListener());
m_sectionWidget = new SingleSelect(SECTION);
m_sectionWidget.addValidationListener(new NotNullValidationListener());
m_sectionWidget.addOption(pleaseSelect);
try {
m_sectionWidget.addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) {
initSectionOptions(e);
}
});
} catch (TooManyListenersException e) {
try {
m_sectionWidget.addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) {
initSectionOptions(e);
}
});
} catch (TooManyListenersException e) {
throw new RuntimeException(e);
}
add(m_sectionWidget);
add(m_sectionWidget);
// add(new Label(DecisionTreeGlobalizationUtil.globalize(
// "cms.contenttypes.ui.decisiontree.options.form.label")));
TextField labelWidget = new TextField(new TrimmedStringParameter(LABEL));
// "cms.contenttypes.ui.decisiontree.options.form.label")));
TextField labelWidget = new TextField(new TrimmedStringParameter(LABEL));
labelWidget.setLabel(DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.options.form.label"));
labelWidget.addValidationListener(new NotNullValidationListener());
labelWidget.setSize(60);
add(labelWidget);
labelWidget.addValidationListener(new NotNullValidationListener());
labelWidget.setSize(60);
add(labelWidget);
// add(new Label(DecisionTreeGlobalizationUtil.globalize(
// "cms.contenttypes.ui.decisiontree.options.form.value")));
TextField valueWidget = new TextField(new TrimmedStringParameter(VALUE));
// "cms.contenttypes.ui.decisiontree.options.form.value")));
TextField valueWidget = new TextField(new TrimmedStringParameter(VALUE));
valueWidget.setLabel(DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.options.form.value"));
valueWidget.addValidationListener(new NotNullValidationListener());
valueWidget.setSize(60);
add(valueWidget);
valueWidget.addValidationListener(new NotNullValidationListener());
valueWidget.setSize(60);
add(valueWidget);
}
/**
* @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();
throws FormProcessException {
PageState state = event.getPageState();
if ( m_saveCancelSection.getCancelButton()
.isSelected(state) && m_container != null) {
m_container.onlyShowComponent(
state, DecisionTreeOptionStep.OPTION_TABLE +
m_container.getTypeIDStr());
throw new FormProcessException(
DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.options.form.submission_cancelled")
);
}
if (m_saveCancelSection.getCancelButton()
.isSelected(state) && m_container != null) {
m_container.onlyShowComponent(
state, DecisionTreeOptionStep.OPTION_TABLE + m_container.getTypeIDStr());
throw new FormProcessException(
DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.options.form.submission_cancelled")
);
}
}
/**
* 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
*/
@Override
public void process(FormSectionEvent event) throws FormProcessException {
PageState state = event.getPageState();
FormData data = event.getFormData();
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;
DecisionTreeSectionOption option;
if (m_selOption.getSelectedKey(state) != null) {
BigDecimal id = new BigDecimal(m_selOption
.getSelectedKey(state).toString());
.getSelectedKey(state).toString());
// retrieve the selected Option from the persistence layer
option = new DecisionTreeSectionOption(id);
} else {
option = new DecisionTreeSectionOption();
option.setName("DecisionTreeSectionOption " + option.getID());
int rank = section.getMaxOptionRank() + 1;
option.setRank(Integer.valueOf(rank));
}
option = new DecisionTreeSectionOption();
option.setName("DecisionTreeSectionOption " + option.getID());
int rank = section.getMaxOptionRank() + 1;
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);
option.setValue(value);
option.setSection(section);
option.setLabel(label);
option.setValue(value);
if (m_container != null) {
m_container.onlyShowComponent(
state,
DecisionTreeOptionStep.OPTION_TABLE +
m_container.getTypeIDStr());
}
if (m_container != null) {
m_container.onlyShowComponent(
state,
DecisionTreeOptionStep.OPTION_TABLE + m_container.getTypeIDStr());
}
}
@Override

View File

@ -59,12 +59,12 @@ import com.arsdigita.globalization.GlobalizedMessage;
* @version $Id$
*/
public class DecisionTreeTargetEditForm extends Form
implements FormInitListener,
FormProcessListener,
FormSubmissionListener {
implements FormInitListener,
FormProcessListener,
FormSubmissionListener {
private final static Logger s_log = Logger.getLogger(
DecisionTreeTargetEditForm.class);
DecisionTreeTargetEditForm.class);
private ItemSelectionModel m_selTree;
private ItemSelectionModel m_selTarget;
@ -74,11 +74,11 @@ public class DecisionTreeTargetEditForm extends Form
private SaveCancelSection m_saveCancelSection;
// private SingleSelect m_sectionWidget;
private SingleSelect m_matchValueWidget;
private SingleSelect m_targetSectionWidget;
private TextField m_targetURLWidget;
private SingleSelect m_targetSectionWidget;
private TextField m_targetURLWidget;
public static final String MATCH_OPTION = "matchOption";
public static final String TARGET_URL = "targetURL";
public static final String MATCH_OPTION = "matchOption";
public static final String TARGET_URL = "targetURL";
public static final String TARGET_SECTION = "targetSection";
/**
@ -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() {
@ -149,9 +150,11 @@ public class DecisionTreeTargetEditForm extends Form
* Set up the dynamic options for the section select widget.
*/
private void initSectionOptions(PrintEvent e) {
PageState state = e.getPageState();
SingleSelect target = (SingleSelect) e.getTarget();
DecisionTree tree = (DecisionTree)m_selTree.getSelectedObject(state);
PageState state = e.getPageState();
SingleSelect target = (SingleSelect) e.getTarget();
target.clearOptions();
DecisionTree tree = (DecisionTree) m_selTree.getSelectedObject(state);
if (tree != null) {
DecisionTreeSectionCollection sections = tree.getSections();
@ -171,9 +174,10 @@ public class DecisionTreeTargetEditForm extends Form
* Set up the dynamic options for the target select widget.
*/
private void initTargetOptions(PrintEvent e) {
PageState state = e.getPageState();
SingleSelect target = (SingleSelect) e.getTarget();
DecisionTree tree = (DecisionTree)m_selTree.getSelectedObject(state);
PageState state = e.getPageState();
SingleSelect target = (SingleSelect) e.getTarget();
target.clearOptions();
DecisionTree tree = (DecisionTree) m_selTree.getSelectedObject(state);
if (tree != null) {
DecisionTreeSectionCollection sections = tree.getSections();
@ -193,28 +197,31 @@ public class DecisionTreeTargetEditForm extends Form
* Set up the dynamic options for the match value select widget.
*/
private void initMatchOptions(PrintEvent e) {
PageState state = e.getPageState();
SingleSelect target = (SingleSelect) e.getTarget();
DecisionTree tree = (DecisionTree)m_selTree.getSelectedObject(state);
PageState state = e.getPageState();
SingleSelect target = (SingleSelect) e.getTarget();
target.clearOptions();
DecisionTree tree = (DecisionTree) m_selTree.getSelectedObject(state);
if (tree != null) {
DecisionTreeSectionOptionCollection sectionOptions = tree.getOptions();
if (sectionOptions != null) {
while (sectionOptions.next()) {
DecisionTreeSectionOption sectionOption = sectionOptions
.getOption();
String label = sectionOption.getSection().getTitle() +
" : " + sectionOption.getLabel();
Option option = new Option(sectionOption.getID().toString(),
while (sectionOptions.next()) {
DecisionTreeSectionOption sectionOption = sectionOptions
.getOption();
String label = sectionOption.getSection().getTitle() + " : " + sectionOption.
getLabel();
Option option = new Option(sectionOption.getID().toString(),
label);
target.addOption(option, state);
}
sectionOptions.close();
target.addOption(option, state);
}
sectionOptions.close();
}
}
}
/** Form initialisation hook. Sets the options for select widgets.
/**
* Form initialisation hook. Sets the options for select widgets.
*
* @param fse
*/
@Override
@ -224,15 +231,16 @@ public class DecisionTreeTargetEditForm extends Form
if (m_selTarget.getSelectedKey(state) != null) {
BigDecimal id = new BigDecimal(m_selTarget.getSelectedKey(state)
.toString());
.toString());
DecisionTreeOptionTarget target = new DecisionTreeOptionTarget(id);
data.put(MATCH_OPTION, target.getMatchOption().getID());
data.put(TARGET_URL, target.getTargetURL());
DecisionTreeSection targetSection = target.getTargetSection();
if (targetSection != null)
data.put(TARGET_SECTION, targetSection.getID());
if (targetSection != null) {
data.put(TARGET_SECTION, targetSection.getID());
}
}
}
@ -241,47 +249,47 @@ public class DecisionTreeTargetEditForm extends Form
*/
protected void addWidgets() {
Option pleaseSelect = new Option(
"",
new Label(DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.targets.form.please_select") ));
"",
new Label(DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.targets.form.please_select")));
Option none = new Option(
"",
new Label( DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.targets.form.none")));
"",
new Label(DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.targets.form.none")));
// add(new Label(DecisionTreeGlobalizationUtil.globalize(
// "cms.contenttypes.ui.decisiontree.targets.form.match_value")));
m_matchValueWidget = new SingleSelect(MATCH_OPTION);
// "cms.contenttypes.ui.decisiontree.targets.form.match_value")));
m_matchValueWidget = new SingleSelect(MATCH_OPTION);
m_matchValueWidget.setLabel(DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.targets.form.match_value"));
m_matchValueWidget.addValidationListener(new NotNullValidationListener());
m_matchValueWidget.addOption(pleaseSelect);
"cms.contenttypes.ui.decisiontree.targets.form.match_value"));
m_matchValueWidget.addValidationListener(new NotNullValidationListener());
m_matchValueWidget.addOption(pleaseSelect);
try {
m_matchValueWidget.addPrintListener(new PrintListener() {
@Override
public void prepare(PrintEvent e) {
initMatchOptions(e);
}
@Override
public void prepare(PrintEvent e) {
initMatchOptions(e);
}
});
} catch (TooManyListenersException e) {
} catch (TooManyListenersException e) {
throw new RuntimeException(e);
}
add(m_matchValueWidget);
// add(new Label(DecisionTreeGlobalizationUtil.globalize(
// "cms.contenttypes.ui.decisiontree.targets.form.target_url_label")));
m_targetURLWidget = new TextField(TARGET_URL);
// "cms.contenttypes.ui.decisiontree.targets.form.target_url_label")));
m_targetURLWidget = new TextField(TARGET_URL);
m_targetURLWidget.setLabel(DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.targets.form.target_url_label"));
m_targetURLWidget.setSize(60);
add(m_targetURLWidget);
m_targetURLWidget.setSize(60);
add(m_targetURLWidget);
// add(new Label(DecisionTreeGlobalizationUtil.globalize(
// "cms.contenttypes.ui.decisiontree.targets.form.target_section_label")));
m_targetSectionWidget = new SingleSelect(TARGET_SECTION);
// "cms.contenttypes.ui.decisiontree.targets.form.target_section_label")));
m_targetSectionWidget = new SingleSelect(TARGET_SECTION);
m_targetSectionWidget.setLabel(DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.targets.form.target_section_label"));
m_targetSectionWidget.addOption(none);
m_targetSectionWidget.addOption(none);
try {
m_targetSectionWidget.addPrintListener(new PrintListener() {
@Override
@ -289,7 +297,7 @@ public class DecisionTreeTargetEditForm extends Form
initTargetOptions(e);
}
});
} catch (TooManyListenersException e) {
} catch (TooManyListenersException e) {
throw new RuntimeException(e);
}
add(m_targetSectionWidget);
@ -300,87 +308,86 @@ public class DecisionTreeTargetEditForm extends Form
throws FormProcessException {
final PageState state = event.getPageState();
if ("".equals(m_targetURLWidget.getValue(state))
&& "".equals(m_targetSectionWidget.getValue(state))) {
GlobalizedMessage msg = DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.targets.form.target_required");
throw new FormProcessException(msg);
&& "".equals(m_targetSectionWidget.getValue(state))) {
GlobalizedMessage msg = DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.targets.form.target_required");
throw new FormProcessException(msg);
}
if (!"".equals(m_targetURLWidget.getValue(state))
&& !"".equals(m_targetSectionWidget.getValue(state))) {
GlobalizedMessage msg = DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.targets.form.duplicate_target");
throw new FormProcessException(msg);
&& !"".equals(m_targetSectionWidget.getValue(state))) {
GlobalizedMessage msg = DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.targets.form.duplicate_target");
throw new FormProcessException(msg);
}
}
});
}
/**
* 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
*/
@Override
public void submitted(FormSectionEvent event)
throws FormProcessException {
PageState state = event.getPageState();
throws FormProcessException {
PageState state = event.getPageState();
if ( m_saveCancelSection.getCancelButton().isSelected(state)
&& m_container != null) {
if (m_saveCancelSection.getCancelButton().isSelected(state)
&& m_container != null) {
m_container.onlyShowComponent(state,
DecisionTreeTargetStep.TARGET_TABLE +
m_container.getTypeIDStr());
throw new FormProcessException(
DecisionTreeTargetStep.TARGET_TABLE + m_container.
getTypeIDStr());
throw new FormProcessException(
DecisionTreeGlobalizationUtil.globalize(
"cms.contenttypes.ui.decisiontree.targets.form.submission_cancelled")
);
"cms.contenttypes.ui.decisiontree.targets.form.submission_cancelled")
);
}
}
/**
* 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
*/
@Override
public void process(FormSectionEvent event) throws FormProcessException {
PageState state = event.getPageState();
FormData data = event.getFormData();
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);
if (!"".equals(sectionID)) {
targetSection = new DecisionTreeSection(new BigDecimal(sectionID));
}
DecisionTreeSection targetSection = null;
String sectionID = (String) data.get(TARGET_SECTION);
if (!"".equals(sectionID)) {
targetSection = new DecisionTreeSection(new BigDecimal(sectionID));
}
DecisionTreeOptionTarget target;
DecisionTreeOptionTarget target;
if (m_selTarget.getSelectedKey(state) != null) {
BigDecimal id = new BigDecimal(m_selTarget
.getSelectedKey(state).toString());
.getSelectedKey(state).toString());
target = new DecisionTreeOptionTarget(id);
} else {
target = new DecisionTreeOptionTarget();
target.setName("OptionTarget " + target.getID());
}
target = new DecisionTreeOptionTarget();
target.setName("OptionTarget " + target.getID());
}
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());
}
if (m_container != null) {
m_container.onlyShowComponent(
state,
DecisionTreeTargetStep.TARGET_TABLE + m_container.getTypeIDStr());
}
}
@Override

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

@ -57,12 +57,12 @@ import org.apache.log4j.Logger;
* @author quasi, Created on 8. Juli 2009, 10:27
*/
public class GenericContactEditAddressPropertyForm extends BasicPageForm
implements FormProcessListener,
FormInitListener,
FormSubmissionListener {
implements FormProcessListener,
FormInitListener,
FormSubmissionListener {
private static final Logger logger = Logger.getLogger(
GenericContactPropertyForm.class);
GenericContactPropertyForm.class);
public static final String ADDRESS = GenericAddress.ADDRESS;
public static final String POSTAL_CODE = GenericAddress.POSTAL_CODE;
@ -106,7 +106,7 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm
addressParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextArea address = new TextArea(addressParam);
address.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.address"));
.globalize("cms.contenttypes.ui.address.address"));
address.setRows(5);
address.setCols(30);
add(address);
@ -115,7 +115,7 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm
ParameterModel postalCodeParam = new StringParameter(POSTAL_CODE);
TextField postalCode = new TextField(postalCodeParam);
postalCode.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.postal_code"));
.globalize("cms.contenttypes.ui.address.postal_code"));
/* XXX NumberListener ?*/
add(postalCode);
}
@ -123,14 +123,14 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm
ParameterModel cityParam = new StringParameter(CITY);
TextField city = new TextField(cityParam);
city.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.city"));
.globalize("cms.contenttypes.ui.address.city"));
add(city);
if (!GenericContact.getConfig().getHideAddressState()) {
ParameterModel stateParam = new StringParameter(STATE);
TextField state = new TextField(stateParam);
state.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.state"));
.globalize("cms.contenttypes.ui.address.state"));
add(state);
}
@ -140,11 +140,7 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm
SingleSelect country = new SingleSelect(countryParam);
country.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.address.iso_country_code"));
country.addOption(new Option("",
new Label(ContenttypesGlobalizationUtil
.globalize("cms.ui.select_one"))));
"cms.contenttypes.ui.address.iso_country_code"));
try {
country.addPrintListener(new PrintListener() {
@ -152,14 +148,19 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm
@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();
.entrySet().iterator();
while (countries.hasNext()) {
Map.Entry<String, String> elem = (Map.Entry<String, String>) countries
.next();
.next();
target.addOption(new Option(elem.getValue().toString(),
elem.getKey().toString()));
elem.getKey().toString()));
}
}
@ -169,21 +170,21 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm
}
country.addValidationListener(
new ParameterListener() {
new ParameterListener() {
@Override
public void validate(ParameterEvent e) throws FormProcessException {
ParameterData data = e.getParameterData();
String isoCode = (String) data.getValue();
if (isoCode == null || isoCode.length() == 0) {
data.addError((String) ContenttypesGlobalizationUtil
.globalize(
"cms.contenttypes.ui.address.error_iso_country")
.localize());
@Override
public void validate(ParameterEvent e) throws FormProcessException {
ParameterData data = e.getParameterData();
String isoCode = (String) data.getValue();
if (isoCode == null || isoCode.length() == 0) {
data.addError((String) ContenttypesGlobalizationUtil
.globalize(
"cms.contenttypes.ui.address.error_iso_country")
.localize());
}
}
}
});
});
add(country);
}
@ -210,7 +211,7 @@ public class GenericContactEditAddressPropertyForm extends BasicPageForm
@Override
public void submitted(FormSectionEvent fse) {
if (m_step != null
&& getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) {
&& getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) {
m_step.cancelStreamlinedCreation(fse.getPageState());
}
}

View File

@ -56,9 +56,9 @@ import org.apache.log4j.Logger;
* @author quasi
*/
public class GenericContactEditPersonPropertyForm extends BasicPageForm
implements FormProcessListener,
FormInitListener,
FormSubmissionListener {
implements FormProcessListener,
FormInitListener,
FormSubmissionListener {
private static final Logger logger = Logger.getLogger(GenericContactPropertyForm.class);
private GenericContactPersonPropertiesStep m_step;
@ -106,7 +106,7 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm
surnameParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextField surname = new TextField(surnameParam);
surname.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.surname"));
.globalize("cms.contenttypes.ui.person.surname"));
add(surname);
ParameterModel givennameParam = new StringParameter(GIVENNAME);
@ -114,43 +114,45 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm
givennameParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextField givenname = new TextField(givennameParam);
givenname.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.givenname"));
.globalize("cms.contenttypes.ui.person.givenname"));
add(givenname);
ParameterModel titlepreParam = new StringParameter(TITLEPRE);
titlepreParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextField titlepre = new TextField(titlepreParam);
titlepre.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.titlepre"));
.globalize("cms.contenttypes.ui.person.titlepre"));
add(titlepre);
ParameterModel titlepostParam = new StringParameter(TITLEPOST);
titlepostParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextField titlepost = new TextField(titlepostParam);
titlepost.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.titlepost"));
.globalize("cms.contenttypes.ui.person.titlepost"));
add(titlepost);
// GenericContact type field
ParameterModel contactTypeParam = new StringParameter(CONTACTS_KEY);
SingleSelect contactType = new SingleSelect(contactTypeParam);
contactType.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.person.contact.type"));
.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();
contacttypes.addLanguageFilter(GlobalizationHelper
.getNegotiatedLocale().getLanguage());
.getNegotiatedLocale().getLanguage());
while (contacttypes.next()) {
RelationAttribute ct = contacttypes.getRelationAttribute();
@ -171,7 +173,7 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm
FormData data = fse.getFormData();
PageState state = fse.getPageState();
GenericContact contact = (GenericContact) getItemSelectionModel()
.getSelectedObject(state);
.getSelectedObject(state);
if (contact.getPerson() != null) {
data.put(SURNAME, contact.getPerson().getSurname());
@ -184,7 +186,7 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm
public void submitted(FormSectionEvent fse) {
if (m_step != null
&& getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) {
&& getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) {
m_step.cancelStreamlinedCreation(fse.getPageState());
}
}
@ -193,7 +195,7 @@ public class GenericContactEditPersonPropertyForm extends BasicPageForm
FormData data = fse.getFormData();
PageState state = fse.getPageState();
GenericContact contact = (GenericContact) getItemSelectionModel()
.getSelectedObject(state);
.getSelectedObject(state);
if (getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) {

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,15 +45,15 @@ 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>
*/
public class GenericContactTypeAddForm extends BasicItemForm {
private static final Logger s_log = Logger.getLogger(
GenericContactTypeAddForm.class);
GenericContactTypeAddForm.class);
public final static String KEY = RelationAttribute.KEY;
public final static String LANGUAGE = RelationAttribute.LANGUAGE;
@ -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);
@ -79,16 +81,17 @@ public class GenericContactTypeAddForm extends BasicItemForm {
keyParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextField key = new TextField(keyParam);
key.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.contacttypes.key"));
.globalize("cms.contenttypes.ui.contacttypes.key"));
add(key);
// Language
ParameterModel languageParam = new StringParameter(LANGUAGE);
language = new SingleSelect(languageParam);
language.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.contacttypes.language"));
.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);
@ -96,20 +99,18 @@ public class GenericContactTypeAddForm extends BasicItemForm {
nameParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
TextField name = new TextField(nameParam);
name.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.contacttypes.name"));
.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()
.getSelectedObject(state);
GenericContactTypeCollection contacttypeCollection = new
GenericContactTypeCollection(contacttype.getKey());
RelationAttribute contacttype = (RelationAttribute) getItemSelectionModel()
.getSelectedObject(state);
GenericContactTypeCollection contacttypeCollection = new GenericContactTypeCollection(
contacttype.getKey());
// all supported languages (by registry entry)
KernelConfig kernelConfig = Kernel.getConfig();
@ -121,10 +122,9 @@ public class GenericContactTypeAddForm extends BasicItemForm {
// If lanuage exists, remove it from the selection list
if (!contacttypeCollection.hasLanguage(code)) {
language.addOption(new
Option(code,
new Locale(code).getDisplayLanguage()),
state);
language.addOption(new Option(code,
new Locale(code).getDisplayLanguage()),
state);
}
}
@ -138,9 +138,8 @@ public class GenericContactTypeAddForm extends BasicItemForm {
public void process(FormSectionEvent fse) {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
RelationAttribute contacttype = (RelationAttribute)
getItemSelectionModel()
.getSelectedObject(state);
RelationAttribute contacttype = (RelationAttribute) getItemSelectionModel()
.getSelectedObject(state);
//
if (!this.getSaveCancelSection().getCancelButton().isSelected(state)) {

View File

@ -56,11 +56,11 @@ import org.apache.log4j.Logger;
* @author Jens Pelzetter
*/
public class GenericOrganizationalUnitContactAddForm
extends BasicItemForm
implements FormSubmissionListener {
extends BasicItemForm
implements FormSubmissionListener {
private final static Logger s_log = Logger.getLogger(
GenericOrganizationalUnitContactAddForm.class);
GenericOrganizationalUnitContactAddForm.class);
private GenericOrganizationalUnitPropertiesStep m_step;
private ItemSearchWidget m_itemSearch;
private SaveCancelSection m_saveCancelSection;
@ -80,12 +80,12 @@ public class GenericOrganizationalUnitContactAddForm
@Override
protected void addWidgets() {
// add(new Label(ContenttypesGlobalizationUtil.globalize(
// "cms.contenttypes.ui.genericorgaunit.select_contact")));
// "cms.contenttypes.ui.genericorgaunit.select_contact")));
m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
findByAssociatedObjectType(GenericContact.class
.getName()));
.getName()));
m_itemSearch.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.select_contact"));
"cms.contenttypes.ui.genericorgaunit.select_contact"));
m_itemSearch.setDisableCreatePane(false);
add(m_itemSearch);
@ -93,25 +93,28 @@ public class GenericOrganizationalUnitContactAddForm
add(selectedContactLabel);
ParameterModel contactTypeParam = new StringParameter(
GenericOrganizationalUnitContactCollection.CONTACT_TYPE);
GenericOrganizationalUnitContactCollection.CONTACT_TYPE);
SingleSelect contactType = new SingleSelect(contactTypeParam);
contactType.setLabel(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.contact.type"));
"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();
= new GenericOrganizationContactTypeCollection();
contacttypes.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().
getLanguage());
getLanguage());
while (contacttypes.next()) {
RelationAttribute ct = contacttypes.getRelationAttribute();
@ -154,7 +157,7 @@ public class GenericOrganizationalUnitContactAddForm
FormData data = fse.getFormData();
PageState state = fse.getPageState();
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) getItemSelectionModel().
getSelectedObject(state);
getSelectedObject(state);
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
GenericContact selectedContact;
@ -164,17 +167,17 @@ public class GenericOrganizationalUnitContactAddForm
GenericContact contact = (GenericContact) data.get(ITEM_SEARCH);
if (orgaunit.getLanguage().equals(
GlobalizationHelper.LANG_INDEPENDENT)) {
GlobalizationHelper.LANG_INDEPENDENT)) {
contact = (GenericContact) contact.getContentBundle().
getPrimaryInstance();
getPrimaryInstance();
} else {
contact = (GenericContact) contact.getContentBundle().
getInstance(orgaunit.getLanguage());
getInstance(orgaunit.getLanguage());
}
orgaunit.addContact(contact,
(String) data.get(
GenericOrganizationalUnitContactCollection.CONTACT_TYPE));
GenericOrganizationalUnitContactCollection.CONTACT_TYPE));
} else {
GenericOrganizationalUnitContactCollection contacts;
@ -187,7 +190,7 @@ public class GenericOrganizationalUnitContactAddForm
}
contacts.setContactType((String) data.get(
GenericOrganizationalUnitContactCollection.CONTACT_TYPE));
GenericOrganizationalUnitContactCollection.CONTACT_TYPE));
editStep.setSelectedContact(null);
editStep.setSelectedContactType(null);
@ -200,7 +203,7 @@ public class GenericOrganizationalUnitContactAddForm
public void submitted(FormSectionEvent fse) throws FormProcessException {
if (getSaveCancelSection().getCancelButton().isSelected(
fse.getPageState())) {
fse.getPageState())) {
editStep.setSelectedContact(null);
editStep.setSelectedContactType(null);
@ -214,16 +217,16 @@ public class GenericOrganizationalUnitContactAddForm
final FormData data = fse.getFormData();
if ((editStep.getSelectedContact() == null)
&& (data.get(ITEM_SEARCH) == null)) {
&& (data.get(ITEM_SEARCH) == null)) {
data.addError((ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.select_contact.no_contact_selected")));
"cms.contenttypes.ui.genericorgaunit.select_contact.no_contact_selected")));
return;
}
if (editStep.getSelectedContact() == null) {
GenericOrganizationalUnit orgaunit = (GenericOrganizationalUnit) getItemSelectionModel()
.getSelectedObject(state);
.getSelectedObject(state);
GenericContact contact = (GenericContact) data.get(ITEM_SEARCH);
@ -234,30 +237,30 @@ public class GenericOrganizationalUnitContactAddForm
Kernel.getConfig().
languageIndependentItems()))) {
data.addError(
ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.select_contact.no_suitable_language_variant"));
ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.select_contact.no_suitable_language_variant"));
return;
}
}
if (orgaunit.getLanguage().equals(
GlobalizationHelper.LANG_INDEPENDENT)) {
GlobalizationHelper.LANG_INDEPENDENT)) {
contact = (GenericContact) contact.getContentBundle().
getPrimaryInstance();
getPrimaryInstance();
} else {
contact = (GenericContact) contact.getContentBundle().
getInstance(orgaunit.getLanguage());
getInstance(orgaunit.getLanguage());
}
GenericOrganizationalUnitContactCollection contacts = orgaunit.
getContacts();
getContacts();
contacts.addFilter(String.format("id = %s",
contact.getID().toString()));
if (contacts.size() > 0) {
data.addError(
ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.select_contact.already_added"));
ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericorgaunit.select_contact.already_added"));
}
contacts.close();

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

@ -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);
@ -89,23 +89,23 @@ public class CategoriesPrintListener implements PrintListener {
BigDecimal id = (BigDecimal) state.getValue(m_selectedFileParam);
if (id != null) {
ContentItem ci = new ContentItem(id);
CategoryCollection cats = ci.getCategoryCollection();
Category cat;
if (cats.next()) {
cat = cats.getCategory();
String catID = cat.getID().toString();
assignedIDs.add(catID);
CategoryCollection cats = ci.getCategoryCollection();
Category cat;
if (cats.next()) {
cat = cats.getCategory();
String catID = cat.getID().toString();
assignedIDs.add(catID);
}
}
}
}
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,21 +79,21 @@ 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
* @author Stefan Deusch
* @author Crag Wolfe
*/
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);
implements FormValidationListener,
FormProcessListener,
FormInitListener,
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,9 +153,8 @@ class FileEditForm extends Form
add(new Label(FILE_UPLOAD_ADD_FILE));
m_fileUpload = new FileUpload(FILE_UPLOAD);
add(m_fileUpload);
}
else {
add(new Label(FILE_NAME_REQUIRED));
} else {
add(new Label(FILE_NAME_REQUIRED));
m_FileName = new StringParameter(FILE_EDIT_FNAME);
TextField fnameEntry = new TextField(m_FileName);
add(fnameEntry);
@ -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 {
@ -183,17 +181,15 @@ class FileEditForm extends Form
add(new Label(FILE_CATEGORIES));
MultipleSelect catSelect
= new MultipleSelect(FILE_EDIT_CATS);
= new MultipleSelect(FILE_EDIT_CATS);
catSelect.setSize(20);
try {
BigDecimalParameter fileIDParam = null;
if (!m_creation) {
fileIDParam = getFileIDParam();
}
catSelect.addPrintListener
(new CategoriesPrintListener
(getContentSection(),
fileIDParam));
catSelect.addPrintListener(new CategoriesPrintListener(getContentSection(),
fileIDParam));
} catch (java.util.TooManyListenersException tmex) {
throw new UncheckedWrapperException(tmex.getMessage());
}
@ -215,7 +211,7 @@ class FileEditForm extends Form
add(sc);
addInitListener(this);
addInitListener(this);
addProcessListener(this);
addValidationListener(this);
}
@ -224,34 +220,34 @@ class FileEditForm extends Form
* Initializer to pre-fill name and description
*/
public void init(FormSectionEvent e)
throws FormProcessException {
throws FormProcessException {
if (m_creation) {
initCreate(e);
}
else {
initEdit(e);
if (m_creation) {
initCreate(e);
} else {
initEdit(e);
}
}
public void initEdit(FormSectionEvent e)
throws FormProcessException {
throws FormProcessException {
PageState state = e.getPageState();
FormData data = e.getFormData();
BigDecimal id = getSelectedDocID(state);
BigDecimal id = getSelectedDocID(state);
Document doc = DMUtils.getFile(id);
ArrayList assignedCats = new ArrayList();
// Iterator i = doc.getCategories();
CategoryCollection cats = doc.getCategoryCollection();
Category cat;
if (cats.next()) {
cat = cats.getCategory();
String catID = cat.getID().toString();
CategoryCollection cats = doc.getCategoryCollection();
Category cat;
if (cats.next()) {
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()));
@ -263,7 +259,7 @@ class FileEditForm extends Form
}
private void initCreate(FormSectionEvent e)
throws FormProcessException {
throws FormProcessException {
if (m_parent instanceof BrowsePane) {
PageState state = e.getPageState();
@ -281,9 +277,9 @@ class FileEditForm extends Form
* read form and update
*/
public void process(FormSectionEvent e)
throws FormProcessException {
throws FormProcessException {
Document doc = null;
Document doc = null;
if (m_submit.isSelected(e.getPageState())) {
if (m_creation) {
doc = processCreate(e);
@ -295,24 +291,24 @@ class FileEditForm extends Form
}
private Document processEdit(FormSectionEvent e)
throws FormProcessException {
throws FormProcessException {
PageState state = e.getPageState();
FormData data = e.getFormData();
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;
}
private Document processCreate(FormSectionEvent e)
throws FormProcessException {
throws FormProcessException {
PageState state = e.getPageState();
final FormData data = e.getFormData();
@ -321,15 +317,14 @@ class FileEditForm extends Form
final String fname = getUploadFileName(e);
String titleTmp = (String) data.get(FILE_EDIT_TITLE);
if (titleTmp == null || titleTmp.trim().length() == 0) {
titleTmp = fname;
MimeType mime = MimeType.guessMimeTypeFromFile(fname);
int index;
if (mime != null && (index = fname.lastIndexOf('.')) > -1) {
titleTmp = fname.substring(0, index);
}
else {
titleTmp = fname;
}
titleTmp = fname;
MimeType mime = MimeType.guessMimeTypeFromFile(fname);
int index;
if (mime != null && (index = fname.lastIndexOf('.')) > -1) {
titleTmp = fname.substring(0, index);
} else {
titleTmp = fname;
}
}
final String title = titleTmp;
String fpath = (String) data.get(FILE_UPLOAD);
@ -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
@ -380,39 +373,40 @@ class FileEditForm extends Form
final FileAsset fa = new FileAsset();
new KernelExcursion() {
protected void excurse() {
protected void excurse() {
// Create all the objects inside the kernel excursion
// so persistence doesn't barf...
setParty(Kernel.getSystemParty());
// so persistence doesn't barf...
setParty(Kernel.getSystemParty());
//f1.setTitle(title);
//f1.setName(URLEncoder.encode(fname));
//f1.setLanguage("en");
fa.setName("temp");
f1.setFile(fa);
bundle.setDefaultLanguage(f1.getLanguage());
//bundle.addInstance(f1);
bundle.setName(fname);
bundle.setParent(parent);
bundle.setContentSection(parent.getContentSection());
PermissionService.setContext(bundle,parent);
PermissionService.setContext(f1,bundle);
PermissionService.setContext(fa,f1);
bundle.save();
f1.save();
}}.run();
//f1.setName(URLEncoder.encode(fname));
//f1.setLanguage("en");
fa.setName("temp");
f1.setFile(fa);
bundle.setDefaultLanguage(f1.getLanguage());
//bundle.addInstance(f1);
bundle.setName(fname);
bundle.setParent(parent);
bundle.setContentSection(parent.getContentSection());
PermissionService.setContext(bundle, parent);
PermissionService.setContext(f1, bundle);
PermissionService.setContext(fa, f1);
bundle.save();
f1.save();
}
}.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
.localize(req)
.toString()));
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,18 +416,17 @@ 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();
return f1;
return f1;
}
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,21 +453,22 @@ class FileEditForm extends Form
/**
* Test if the new name already exists in the current folder
*/
public void validate(FormSectionEvent event)
throws FormProcessException {
throws FormProcessException {
if (m_submit.isSelected(event.getPageState())) {
FormData data = event.getFormData();
//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) {
@ -486,29 +480,28 @@ class FileEditForm extends Form
}
private void validateCreate(FormSectionEvent e)
throws FormProcessException {
throws FormProcessException {
PageState state = e.getPageState();
FormData data = e.getFormData();
HttpServletRequest req = state.getRequest();
String fname = (String) data.get(FILE_UPLOAD);
if (fname == null || fname.length() == 0) {
data.addError(FILE_UPLOAD, "This parameter is required.");
data.addError(FILE_UPLOAD, "This parameter is required.");
}
fname = DMUtils.extractFileName(getUploadFileName(e), state);
// XXX Not localized as the other errors are.
if (fname.length() > 200) {
data.addError
(FILE_UPLOAD,
"This filename is too long. It must be fewer than 200 characters.");
data.addError(FILE_UPLOAD,
"This filename is too long. It must be fewer than 200 characters.");
}
String title = (String) data.get(FILE_EDIT_TITLE);
if (title != null && title.length() > 200) {
data.addError(FILE_EDIT_TITLE,
"This title is too long. It must be fewer than 200 characters.");
"This title is too long. It must be fewer than 200 characters.");
}
DocFolder parent = null;
@ -520,9 +513,9 @@ 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());
.localize(req).toString());
}
}
@ -534,86 +527,77 @@ 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) {
}
private void validateEdit(FormSectionEvent event)
throws FormProcessException {
throws FormProcessException {
// PageState state = event.getPageState();
FormData data = event.getFormData();
String fname = (String) data.get(FILE_EDIT_FNAME);
if (fname == null || fname.trim().length() == 0) {
data.addError(FILE_EDIT_FNAME, "This parameter is required");
data.addError(FILE_EDIT_FNAME, "This parameter is required");
}
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.");
"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
/*
if (!name.equals(file.getName())) {
try {
Folder parent = (Folder) file.getParent();
parent.getResourceID(name);
data.addError(FILE_EDIT_FNAME,
(String)RESOURCE_EXISTS_ERROR.localize(req));
} catch(DataObjectNotFoundException nfe) {
// good, so we can rename it
} catch (InvalidNameException ex) {
data.addError(FILE_EDIT_FNAME,
ex.getMessage());
}
}
*/
/*
if (!name.equals(file.getName())) {
try {
Folder parent = (Folder) file.getParent();
parent.getResourceID(name);
data.addError(FILE_EDIT_FNAME,
(String)RESOURCE_EXISTS_ERROR.localize(req));
} catch(DataObjectNotFoundException nfe) {
// good, so we can rename it
} catch (InvalidNameException ex) {
data.addError(FILE_EDIT_FNAME,
ex.getMessage());
}
}
*/
}
/* Initialize form data for document's intended audience.
*/
private void initAudienceFormData(FormData data,
Document doc) {
ObjectPermissionCollection opc =
PermissionService.getDirectGrantedPermissions(doc.getOID());
Document doc) {
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;
}
}
@ -626,38 +610,35 @@ class FileEditForm extends Form
}
/* Grant/revoke direct permissions as needed.
Note that workspace permissions is always implied.
*/
Note that workspace permissions is always implied.
*/
private void setDocumentPermission(FormData data,
Document doc)
throws FormProcessException {
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,
doc.getOID(),
new OID(User.BASE_DATA_OBJECT_TYPE,
PermissionManager.VIRTUAL_PUBLIC_ID));
final PermissionDescriptor internalDescriptor =
new PermissionDescriptor
(PrivilegeDescriptor.READ,
doc.getOID(),
new OID(Group.BASE_DATA_OBJECT_TYPE,
DocMgr.getConfig().getInternalGroupID()));
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(Group.BASE_DATA_OBJECT_TYPE,
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",
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)));
select.addOption(new Option("internal",
new Label(FILE_INTENDED_AUDIENCE_INTERNAL)));
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();
@ -727,36 +710,31 @@ class FileEditForm extends Form
}
private BigDecimalParameter getFileIDParam() {
if (m_parent instanceof FileInfoPropertiesPane) {
return ((FileInfoPropertiesPane) m_parent).getFileIDParam();
}
else {
if (m_parent instanceof BrowseFileInfoPropertiesPane) {
((BrowseFileInfoPropertiesPane) m_parent).getFileIDParam();
}
}
return null;
if (m_parent instanceof FileInfoPropertiesPane) {
return ((FileInfoPropertiesPane) m_parent).getFileIDParam();
} else {
if (m_parent instanceof BrowseFileInfoPropertiesPane) {
((BrowseFileInfoPropertiesPane) m_parent).getFileIDParam();
}
}
return null;
}
private void backCancel(PageState state, BigDecimal docID) {
if (m_parent instanceof BrowsePane) {
if (docID != null) {
((BrowsePane) m_parent).displayFilePropPanel(state, docID);
}
else {
((BrowsePane) m_parent).displayFolderContentPanel(state);
}
}
else {
if (m_parent instanceof FileInfoPropertiesPane) {
((FileInfoPropertiesPane) m_parent).displayPropertiesAndActions(state);
}
else {
if (m_parent instanceof BrowseFileInfoPropertiesPane) {
((BrowseFileInfoPropertiesPane) m_parent).displayPropertiesPane(state);
}
}
}
if (m_parent instanceof BrowsePane) {
if (docID != null) {
((BrowsePane) m_parent).displayFilePropPanel(state, docID);
} else {
((BrowsePane) m_parent).displayFolderContentPanel(state);
}
} else {
if (m_parent instanceof FileInfoPropertiesPane) {
((FileInfoPropertiesPane) m_parent).displayPropertiesAndActions(state);
} else {
if (m_parent instanceof BrowseFileInfoPropertiesPane) {
((BrowseFileInfoPropertiesPane) m_parent).displayPropertiesPane(state);
}
}
}
}
}

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);
@ -124,9 +123,9 @@ class SearchPane extends SimpleContainer implements DMConstants
m_segmentHeader.setDefaultComponent(m_emptyLabel);
rightSide.addSegment(
// (new Label(new EmptySearchPrintListener(leftSide)),
m_segmentHeader,
m_searchList);
// (new Label(new EmptySearchPrintListener(leftSide)),
m_segmentHeader,
m_searchList);
m_mainBrowseContainer.add(rightSide);
@ -152,10 +151,11 @@ class SearchPane extends SimpleContainer implements DMConstants
}
private class DocsSearchForm extends Form
implements SearchForm, FormValidationListener,
FormProcessListener, FormInitListener {
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);
@ -206,26 +201,23 @@ class SearchPane extends SimpleContainer implements DMConstants
}
public void validate(FormSectionEvent e)
throws FormProcessException {
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,
@ -313,7 +298,7 @@ class SearchPane extends SimpleContainer implements DMConstants
sections,
user,
categoryIDs);
//}
//}
m_coln.set(state, coln);
}
return coln;
@ -322,50 +307,51 @@ 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,
new OID(Document.BASE_DATA_OBJECT_TYPE,
dq.get("workspaceID")),
user.getOID()))) {
o.addOption(new Option
(((BigDecimal) dq.get("workspaceID")).toString(),
(String) dq.get("title")));
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(),
(String) dq.get("title")));
}
dq.close();

View File

@ -50,23 +50,24 @@ public class CategoryWidget extends SingleSelect implements Constants {
try {
addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) {
PageState s = e.getPageState();
final Forum forum = getForum(s);
SingleSelect target = (SingleSelect) e.getTarget();
public void prepare(PrintEvent e) {
PageState s = e.getPageState();
final Forum forum = getForum(s);
SingleSelect target = (SingleSelect) e.getTarget();
target.clearOptions();
// Get categories for this forum
if (forum.noCategoryPostsAllowed()) {
target.addOption(new Option(
TOPIC_NONE.toString(),
new Label(GlobalizationUtil.gz("forum.ui.topic.none"))));
}
final Category root = forum.getRootCategory();
if (root != null) {
addCategories(root, target);
}
// Get categories for this forum
if (forum.noCategoryPostsAllowed()) {
target.addOption(new Option(
TOPIC_NONE.toString(),
new Label(GlobalizationUtil.gz("forum.ui.topic.none"))));
}
});
final Category root = forum.getRootCategory();
if (root != null) {
addCategories(root, target);
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException(ex);
}
@ -83,9 +84,8 @@ public class CategoryWidget extends SingleSelect implements Constants {
try {
while (children.next()) {
Category c = children.getCategory();
target.addOption(new Option
(c.getID().toString(),
c.getName()));
target.addOption(new Option(c.getID().toString(),
c.getName()));
}
} finally {
@ -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).
getMessageThread().getRootMessage();
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;
/**
*
*
@ -81,19 +79,20 @@ public class DomainContextForm extends Form {
m_app.addValidationListener(new NotNullValidationListener());
try {
m_app.addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) {
SingleSelect t = (SingleSelect)e.getTarget();
ApplicationCollection apps = Application
public void prepare(PrintEvent e) {
SingleSelect t = (SingleSelect) e.getTarget();
t.clearOptions();
ApplicationCollection apps = Application
.retrieveAllApplications();
apps.addOrder(Application.PRIMARY_URL);
t.addOption(new Option(null, "--select one--"));
while (apps.next()) {
Application app = apps.getApplication();
t.addOption(new Option(app.getOID().toString(),
app.getPath()));
}
apps.addOrder(Application.PRIMARY_URL);
t.addOption(new Option(null, "--select one--"));
while (apps.next()) {
Application app = apps.getApplication();
t.addOption(new Option(app.getOID().toString(),
app.getPath()));
}
});
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("cannot happen", ex);
}
@ -111,8 +110,9 @@ public class DomainContextForm extends Form {
}
private class DomainInitListener implements FormInitListener {
public void init(FormSectionEvent ev)
throws FormProcessException {
throws FormProcessException {
PageState state = ev.getPageState();
m_app.setValue(state, null);
@ -121,8 +121,9 @@ public class DomainContextForm extends Form {
}
private class DomainSubmissionListener implements FormSubmissionListener {
public void submitted(FormSectionEvent ev)
throws FormProcessException {
throws FormProcessException {
PageState state = ev.getPageState();
if (m_buttons.getCancelButton().isSelected(state)) {
@ -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);
Application app = (Application)m_app.getValue(state);
public void process(FormSectionEvent ev)
throws FormProcessException {
PageState state = ev.getPageState();
Domain domain = (Domain) state.getValue(m_domain);
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,45 +52,42 @@ 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() {
@Override
public Object initialValue(PageState ps) {
return new Label();
}
};
@Override
public Object initialValue(PageState ps) {
return new Label();
}
};
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)) {
// Skip create privileges. They are created
// and destroyed implicitly when the other
// privileges are used.
|| opc.getPrivilege().equals(PrivilegeDescriptor.CREATE)) {
continue;
}
@ -105,8 +100,8 @@ public class ObjectPermissionEdit extends CompoundComponent {
}
if (grant.objectType != null
&& types != null
&& !types.contains(grant.objectType)) {
&& types != null
&& !types.contains(grant.objectType)) {
continue;
}
@ -134,7 +129,6 @@ public class ObjectPermissionEdit extends CompoundComponent {
}
}
public ObjectGrantsTable(RequestLocal grantsRL,
RequestLocal typesRL,
boolean isEditable) {
@ -143,140 +137,140 @@ public class ObjectPermissionEdit extends CompoundComponent {
// COLUMN 0: The party with the grant
TableColumn partyColumn = new TableColumn(0, "User or Role");
partyColumn.setCellRenderer(new TableCellRenderer() {
final RequestLocal m_userNameDisplay = new RequestLocal() {
public Object initialValue(PageState ps) {
SimpleContainer result = new SimpleContainer();
result.add(Icons.USER_16);
result.add((Component) s_dynamicLabel.get(ps));
return result;
}
};
final RequestLocal m_groupNameDisplay = new RequestLocal() {
public Object initialValue(PageState ps) {
SimpleContainer result = new SimpleContainer();
result.add(Icons.GROUP_16);
result.add((Component)s_dynamicLabel.get(ps));
return result;
}
};
public Component getComponent(Table table,
PageState ps,
Object value,
boolean isSelected,
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);
if (grant.granteeIsUser) {
return (Component) m_userNameDisplay.get(ps);
} else {
return (Component) m_groupNameDisplay.get(ps);
}
final RequestLocal m_userNameDisplay = new RequestLocal() {
public Object initialValue(PageState ps) {
SimpleContainer result = new SimpleContainer();
result.add(Icons.USER_16);
result.add((Component) s_dynamicLabel.get(ps));
return result;
}
});
};
final RequestLocal m_groupNameDisplay = new RequestLocal() {
public Object initialValue(PageState ps) {
SimpleContainer result = new SimpleContainer();
result.add(Icons.GROUP_16);
result.add((Component) s_dynamicLabel.get(ps));
return result;
}
};
public Component getComponent(Table table,
PageState ps,
Object value,
boolean isSelected,
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);
if (grant.granteeIsUser) {
return (Component) m_userNameDisplay.get(ps);
} else {
return (Component) m_groupNameDisplay.get(ps);
}
}
});
getColumnModel().add(0, partyColumn);
}
}
private static class ObjectDirectGrantsTable extends ObjectGrantsTable {
public ObjectDirectGrantsTable(final RequestLocal objectRL,
final RequestLocal typesRL) {
super(new RequestLocal() {
public Object initialValue(PageState ps) {
LinkedList ordering = new LinkedList();
getGrantsHelper((ACSObject) objectRL.get(ps),
(Collection) typesRL.get(ps),
ordering);
return ordering.iterator();
}
}, typesRL, true);
public Object initialValue(PageState ps) {
LinkedList ordering = new LinkedList();
getGrantsHelper((ACSObject) objectRL.get(ps),
(Collection) typesRL.get(ps),
ordering);
return ordering.iterator();
}
}, typesRL, true);
}
}
private static class ObjectIndirectGrantsTable extends ObjectGrantsTable {
public ObjectIndirectGrantsTable(final RequestLocal objectRL,
final RequestLocal typesRL) {
super(new RequestLocal() {
public Object initialValue(PageState ps) {
LinkedList ordering = new LinkedList();
public Object initialValue(PageState ps) {
LinkedList ordering = new LinkedList();
ACSObject object = (ACSObject) objectRL.get(ps);
Collection types = (Collection) typesRL.get(ps);
ACSObject object = (ACSObject) objectRL.get(ps);
Collection types = (Collection) typesRL.get(ps);
// FIXME: May need to do this by getting the OID
// and doing a verifySubtype check
while (!(object instanceof PortalSite)) {
DataObject ctx = PermissionService.getContext(object);
if (ctx == null) {
break;
}
object = (ACSObject) DomainObjectFactory.newInstance
(ctx);
getGrantsHelper(object, types, ordering);
// and doing a verifySubtype check
while (!(object instanceof PortalSite)) {
DataObject ctx = PermissionService.getContext(object);
if (ctx == null) {
break;
}
return ordering.iterator();
object = (ACSObject) DomainObjectFactory.newInstance(ctx);
getGrantsHelper(object, types, ordering);
}
}, typesRL, false);
return ordering.iterator();
}
}, typesRL, false);
// 'Target' column
TableColumn targetColumn = new TableColumn(1, "On");
targetColumn.setCellRenderer(new TableCellRenderer() {
public Component getComponent(Table table,
PageState ps,
Object value,
boolean isSelected,
Object key,
int row,
int column) {
Grant grant = (Grant) value;
Label l = (Label) s_dynamicLabel.get(ps);
l.setLabel(grant.objectName);
return l;
}
});
public Component getComponent(Table table,
PageState ps,
Object value,
boolean isSelected,
Object key,
int row,
int column) {
Grant grant = (Grant) value;
Label l = (Label) s_dynamicLabel.get(ps);
l.setLabel(grant.objectName);
return l;
}
});
getColumnModel().add(1, targetColumn);
}
}
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,43 +306,44 @@ 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());
public Object initialValue(PageState ps) {
PortalSite psite
= PortalSite.getCurrentPortalSite(ps.getRequest());
String queryString = (String) ps.getValue(m_queryParam);
String queryString = (String) ps.getValue(m_queryParam);
PartyCollection parties;
Boolean limit = (Boolean) ps.getValue(m_limitParam);
PartyCollection parties;
Boolean limit = (Boolean) ps.getValue(m_limitParam);
if (limit != null && limit.booleanValue()) {
parties = psite.getParticipants();
} else {
parties = Party.retrieveAllParties();
}
parties.filter(queryString);
return parties;
if (limit != null && limit.booleanValue()) {
parties = psite.getParticipants();
} else {
parties = Party.retrieveAllParties();
}
};
parties.filter(queryString);
return parties;
}
};
private void clearQuery(PageState ps) {
ps.setValue(m_queryParam, 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) {
@ -391,24 +386,23 @@ public class ObjectPermissionEdit extends CompoundComponent {
add(new BoldLabel("Select Grantee:"));
add(new BoldLabel("On:") {
public void generateXML(PageState ps, Element parent) {
Collection types = (Collection)m_typesRL.get(ps);
public void generateXML(PageState ps, Element parent) {
Collection types = (Collection) m_typesRL.get(ps);
if ((types == null) || (types.size() <= 1)) {
parent.newChildElement("bebop:label", BEBOP_XML_NS);
return;
} else {
super.generateXML(ps, parent);
}
if ((types == null) || (types.size() <= 1)) {
parent.newChildElement("bebop:label", BEBOP_XML_NS);
return;
} else {
super.generateXML(ps, parent);
}
});
}
});
add(new BoldLabel("Privilege:"));
add(new Label(""));
// Row 2: Widgets
// Create a hidden widget for the objectID
add(new Hidden(getObjectParameter()));
@ -427,20 +421,20 @@ public class ObjectPermissionEdit extends CompoundComponent {
// Init listener to initialize the objectID parameter
addInitListener(new FormInitListener() {
public void init(FormSectionEvent ev) {
PageState ps = ev.getPageState();
FormData fd = ev.getFormData();
fd.put(getObjectParameter().getName(),
((ACSObject)m_objectRL.get(ps)).getID());
}
});
public void init(FormSectionEvent ev) {
PageState ps = ev.getPageState();
FormData fd = ev.getFormData();
fd.put(getObjectParameter().getName(),
((ACSObject) m_objectRL.get(ps)).getID());
}
});
addProcessListener(new FormProcessListener() {
public void process(FormSectionEvent ev) {
PageState ps = ev.getPageState();
NewGrantDisplay.this.fireCompletionEvent(ps);
}
});
public void process(FormSectionEvent ev) {
PageState ps = ev.getPageState();
NewGrantDisplay.this.fireCompletionEvent(ps);
}
});
}
}
@ -451,32 +445,30 @@ 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);
long n = pc.size();
return (n == 0 || n > MAX_RESULTS);
public boolean isVisible(PageState ps) {
if (!haveQuery(ps)) {
return true;
}
};
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:");
}
});
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:");
}
});
screen1.add(roleFormTitle);
// Form for granting to a portal role
@ -484,19 +476,19 @@ public class ObjectPermissionEdit extends CompoundComponent {
SingleSelect roleField = new SingleSelect("roleField");
roleField.setPrintListener(new PrintListener() {
public void prepare(PrintEvent ev) {
SingleSelect tgt = (SingleSelect)ev.getTarget();
PageState ps = ev.getPageState();
PortalSite psite =
PortalSite.getCurrentPortalSite(ps.getRequest());
RoleCollection rc = psite.getRoles();
while (rc.next()) {
Option o = new Option
(rc.getID().toString(), rc.getRoleName());
tgt.addOption(o);
}
public void prepare(PrintEvent ev) {
SingleSelect tgt = (SingleSelect) ev.getTarget();
tgt.clearOptions();
PageState ps = ev.getPageState();
PortalSite psite
= PortalSite.getCurrentPortalSite(ps.getRequest());
RoleCollection rc = psite.getRoles();
while (rc.next()) {
Option o = new Option(rc.getID().toString(), rc.getRoleName());
tgt.addOption(o);
}
});
}
});
Form roleForm = new MyAddGrantForm("roleGrant",
roleField,
rfErrorMessageRL);
@ -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);
@ -521,19 +510,18 @@ public class ObjectPermissionEdit extends CompoundComponent {
Label limitLabel = new Label("");
limitLabel.addPrintListener(new PrintListener() {
public void prepare(PrintEvent ev) {
Label tgt = (Label)ev.getTarget();
PageState ps = ev.getPageState();
PortalSite psite =
PortalSite.getCurrentPortalSite(ps.getRequest());
tgt.setLabel("Limit search to \"" + psite.getTitle() +
"\" participants");
}
});
public void prepare(PrintEvent ev) {
Label tgt = (Label) ev.getTarget();
PageState ps = ev.getPageState();
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,21 +529,22 @@ 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")) {
public boolean isVisible(PageState ps) {
if (!haveQuery(ps)) {
return false;
}
Label noMatchLabel = new Label(GlobalizationUtil.globalize(
"cw.cw.permissions.no_matches_found")) {
public boolean isVisible(PageState ps) {
if (!haveQuery(ps)) {
return false;
}
PartyCollection pc = getQueryResults(ps);
PartyCollection pc = getQueryResults(ps);
if (pc == null || pc.size() > 0) {
return false;
} else {
return true;
if (pc == null || pc.size() > 0) {
return false;
} else {
return true;
}
}
}
};
};
// @deprecated bebop must not specify design properties, just
// logical properties.
// TODO: add as error condition to the widget.
@ -563,120 +552,120 @@ 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")) {
public boolean isVisible(PageState ps) {
if (!haveQuery(ps)) {
return false;
}
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;
}
PartyCollection pc = getQueryResults(ps);
PartyCollection pc = getQueryResults(ps);
if (pc == null || pc.size() <= MAX_RESULTS) {
return false;
} else {
return true;
}
}
};
if (pc == null || pc.size() <= MAX_RESULTS) {
return false;
} else {
return true;
}
}
};
// @deprecated bebop must not specify design properties, just
// logical properties.
// TODO: add as error condition to the widget.
// noMatchLabel.setColor(Color.red);
// tooManyLabel.setColor(Color.red);
otherSearch.add(tooManyLabel);
// logical properties.
// TODO: add as error condition to the widget.
// noMatchLabel.setColor(Color.red);
// tooManyLabel.setColor(Color.red);
otherSearch.add(tooManyLabel);
// SECOND Add screen: Search results
final BoxPanel screen2 = new BoxPanel(BoxPanel.VERTICAL) {
public boolean isVisible(PageState ps) {
if (!haveQuery(ps)) {
return false;
}
PartyCollection pc = getQueryResults(ps);
long n = pc.size();
return (n > 0 && n <= MAX_RESULTS);
}
};
add(screen2);
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);
if (limit != null && limit.length > 0) {
setQuery(ps, queryString, Boolean.TRUE);
} else {
setQuery(ps, queryString, Boolean.FALSE);
}
}
});
// SECOND Add screen: Search results
final BoxPanel screen2 = new BoxPanel(BoxPanel.VERTICAL) {
public boolean isVisible(PageState ps) {
if (!haveQuery(ps)) {
return false;
}
PartyCollection pc = getQueryResults(ps);
long n = pc.size();
return (n > 0 && n <= MAX_RESULTS);
}
};
add(screen2);
screen1.add(otherSearch);
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);
if (limit != null && limit.length > 0) {
setQuery(ps, queryString, Boolean.TRUE);
} else {
setQuery(ps, queryString, Boolean.FALSE);
}
}
});
screen1.add(otherSearch);
screen1.add(new Label(""));
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) {
fireCompletionEvent(ev.getPageState());
}
});
screen1.add(returnLink);
screen1.add(new Label(""));
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) {
fireCompletionEvent(ev.getPageState());
}
});
screen1.add(returnLink);
// Build Search results form
RequestLocal pfErrorMessageRL = new RequestLocal();
RequestLocal pfErrorMessageRL = new RequestLocal();
RadioGroup partyField = new RadioGroup("partyField");
partyField.setLayout(RadioGroup.VERTICAL);
partyField.setPrintListener(new PrintListener() {
public void prepare(PrintEvent ev) {
PageState ps = ev.getPageState();
RadioGroup target = (RadioGroup) ev.getTarget();
PartyCollection parties = getQueryResults(ps);
while (parties.next()) {
target.addOption(new Option(parties.getID().toString(),
parties.getDisplayName()));
}
}
});
RadioGroup partyField = new RadioGroup("partyField");
partyField.setLayout(RadioGroup.VERTICAL);
partyField.setPrintListener(new PrintListener() {
public void prepare(PrintEvent ev) {
PageState ps = ev.getPageState();
RadioGroup target = (RadioGroup)ev.getTarget();
PartyCollection parties = getQueryResults(ps);
while (parties.next()) {
target.addOption(new Option(parties.getID().toString(),
parties.getDisplayName()));
}
}
});
Form partyForm = new MyAddGrantForm("partyGrant",
partyField,
pfErrorMessageRL);
screen2.add(partyForm);
Form partyForm = new MyAddGrantForm("partyGrant",
partyField,
pfErrorMessageRL);
screen2.add(new ErrorMessageDisplay(pfErrorMessageRL));
screen2.add(partyForm);
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) {
clearQuery(ev.getPageState());
}
});
screen2.add(newSearchLink);
screen2.add(new ErrorMessageDisplay(pfErrorMessageRL));
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) {
clearQuery(ev.getPageState());
}
});
screen2.add(newSearchLink);
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) {
NewGrantDisplay.this.fireCompletionEvent(ev.getPageState());
}
});
screen2.add(returnToMainLink);
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) {
NewGrantDisplay.this.fireCompletionEvent(ev.getPageState());
}
});
screen2.add(returnToMainLink);
}
public void fireCompletionEvent(PageState ps) {
clearQuery(ps);
super.fireCompletionEvent(ps);
@ -690,71 +679,66 @@ public class ObjectPermissionEdit extends CompoundComponent {
}
public void register(Page p) {
// Assert.assertTrue((p instanceof CWPage),
// 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) {
public void register(Page p) {
super.register(p);
p.setVisibleDefault(this, false);
}
};
final Completable newGrantDisplay
= new NewGrantDisplay(objectRL, directTypesRL) {
public void register(Page p) {
super.register(p);
p.setVisibleDefault(this, false);
}
};
ActionListener onAddClick = new ActionListener() {
public void actionPerformed(ActionEvent ev) {
PageState ps = ev.getPageState();
CWPage page = (CWPage)ps.getPage();
page.goModal(ps, newGrantDisplay);
}
};
public void actionPerformed(ActionEvent ev) {
PageState ps = ev.getPageState();
CWPage page = (CWPage) ps.getPage();
page.goModal(ps, newGrantDisplay);
}
};
final Component mainDisplay =
new MainDisplay(objectRL,
directTypesRL,
indirectTypesRL,
onAddClick);
final Component mainDisplay
= new MainDisplay(objectRL,
directTypesRL,
indirectTypesRL,
onAddClick);
newGrantDisplay.addCompletionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
PageState ps = ev.getPageState();
CWPage page = (CWPage)ps.getPage();
page.goUnmodal(ps);
}
});
public void actionPerformed(ActionEvent ev) {
PageState ps = ev.getPageState();
CWPage page = (CWPage) ps.getPage();
page.goUnmodal(ps);
}
});
add(mainDisplay);
add(newGrantDisplay);
}
public ObjectPermissionEdit(final RequestLocal objectRL) {
super(new SimpleContainer());
initialize(objectRL, new RequestLocal(), new RequestLocal());
/*
{
public Object initialValue(PageState ps) {
ACSObject object = (ACSObject)objectRL.get(ps);
HashSet result = new HashSet(1);
result.add(object.getObjectType());
return result;
}
});
*/
{
public Object initialValue(PageState ps) {
ACSObject object = (ACSObject)objectRL.get(ps);
HashSet result = new HashSet(1);
result.add(object.getObjectType());
return result;
}
});
*/
}

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,
@ -39,22 +39,23 @@ class TypeSingleSelect extends SingleSelect {
addOption(new Option(AddGrantForm.ALL_TYPES,
"All Contained Items"));
setPrintListener(new PrintListener() {
public void prepare(PrintEvent ev) {
SingleSelect tgt = (SingleSelect)ev.getTarget();
PageState ps = ev.getPageState();
Iterator types =
((Collection)m_typesRL.get(ps)).iterator();
while (types.hasNext()) {
ObjectType type = (ObjectType)types.next();
tgt.addOption(new Option(type.getQualifiedName(),
type.getName()));
}
public void prepare(PrintEvent ev) {
SingleSelect tgt = (SingleSelect) ev.getTarget();
tgt.clearOptions();
PageState ps = ev.getPageState();
Iterator types
= ((Collection) m_typesRL.get(ps)).iterator();
while (types.hasNext()) {
ObjectType type = (ObjectType) types.next();
tgt.addOption(new Option(type.getQualifiedName(),
type.getName()));
}
});
}
});
}
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,138 +113,142 @@ 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);
psite.addPortalTab(newTab);
newTab.save();
psite.save();
PortalSite psite = (PortalSite) portalsiteRL.get(ps);
PortalTab newTab
= PortalTab.createTab((String) newTabName.getValue(ps), psite);
psite.addPortalTab(newTab);
newTab.save();
psite.save();
List list = (List) dlw.getListingComponent();
List list = (List) dlw.getListingComponent();
list.getSelectionModel()
list.getSelectionModel()
.setSelectedKey(ps, newTab.getID().toString());
}
});
}
});
setAddPane(addForm);
// CONSTRUCT EDIT COMPONENT
selectedTabIDRL = new RequestLocal() {
protected Object initialValue(PageState ps) {
String tabIDstr = (String)dlw.getSelectionModel()
protected Object initialValue(PageState ps) {
String tabIDstr = (String) dlw.getSelectionModel()
.getSelectedKey(ps);
return new BigDecimal(tabIDstr);
}
};
return new BigDecimal(tabIDstr);
}
};
m_selectedPortletParam = new BigDecimalParameter("selectedPortlet");
m_mainDisplay = new BoxPanel(BoxPanel.VERTICAL);
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);
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);
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()) {
public boolean isVisible(PageState ps) {
PortalSite psite = (PortalSite)portalsiteRL.get(ps);
PortalTabCollection pstc = psite.getTabsForPortalSite();
return (pstc.size() > 1);
}
};
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);
PortalTabCollection pstc = psite.getTabsForPortalSite();
return (pstc.size() > 1);
}
};
deleteLink.setClassAttr("actionLink");
deleteLink.addActionListener(new DeleteLinkListener());
links.add(deleteLink);
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);
p.addComponentStateParam(this, portletTypeParam);
}
};
public void register(Page p) {
super.register(p);
p.addComponentStateParam(this, portletTypeParam);
}
};
Image image = new Image("/assets/cw/general/add.gif");
image.setBorder("0");
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);
final SingleSelect portletTypeSelect = new SingleSelect("ptype");
portletTypeSelect.addValidationListener(
new NotNullValidationListener());
new NotNullValidationListener());
PortletTypeCollection ptc = PortletType.retrieveAllPortletTypes();
//Alphabetize by title
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()));
}
@ -253,37 +260,33 @@ public class DisplayPane extends DynamicListWizard {
addPortlet.add(selectorSC);
addPortlet.addProcessListener(new FormProcessListener() {
public void process(FormSectionEvent ev) {
PageState ps = ev.getPageState();
m_editContainer.setVisibleComponent(ps, m_portletAddForm);
ps.setValue(portletTypeParam, new BigDecimal(
(String) portletTypeSelect.getValue(ps)));
m_portletAddForm.activate(ps);
}
});
public void process(FormSectionEvent ev) {
PageState ps = ev.getPageState();
m_editContainer.setVisibleComponent(ps, m_portletAddForm);
ps.setValue(portletTypeParam, new BigDecimal(
(String) portletTypeSelect.getValue(ps)));
m_portletAddForm.activate(ps);
}
});
m_mainDisplay.add(addPortlet);
BoxPanel tabLayouts = new BoxPanel(BoxPanel.HORIZONTAL, true);
ListModelBuilder lmb = new ListModelBuilder()
{
boolean m_isLocked;
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()
{
m_isLocked = true;
}
public void lock() {
m_isLocked = true;
}
public boolean isLocked()
{
return m_isLocked;
}
};
public boolean isLocked() {
return m_isLocked;
}
};
m_layouts = new List(lmb);
@ -291,62 +294,59 @@ public class DisplayPane extends DynamicListWizard {
m_layouts.setCellRenderer(new LayoutListCellRenderer());
m_layouts.addChangeListener(new ChangeListener () {
public void stateChanged(ChangeEvent e)
{
PageState ps = e.getPageState();
String key = (String) ((List) dlw.getListingComponent())
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);
Integer lk = new Integer(laykey);
ptab.setLayout(m_layoutNames[lk.intValue()]);
ptab.save();
}
});
BigDecimal bd = new BigDecimal(key);
PortalTab ptab = PortalTab.retrieveTab(bd);
String laykey = (String) m_layouts.getSelectedKey(ps);
Integer lk = new Integer(laykey);
ptab.setLayout(m_layoutNames[lk.intValue()]);
ptab.save();
}
});
tabLayouts.add(m_layouts);
m_mainDisplay.add(tabLayouts);
m_portletAddForm =
new PortletAddForm(portalsiteRL, selectedTabIDRL, new RequestLocal() {
protected Object initialValue(PageState ps) {
BigDecimal id = (BigDecimal) ps.getValue(portletTypeParam);
if (id == null) {
return null;
m_portletAddForm
= new PortletAddForm(portalsiteRL, selectedTabIDRL, new RequestLocal() {
protected Object initialValue(PageState ps) {
BigDecimal id = (BigDecimal) ps.getValue(portletTypeParam);
if (id == null) {
return null;
}
return PortletType.retrievePortletType(id);
}
return PortletType.retrievePortletType(id);
}
});
});
m_portletAddForm.addCompletionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
PageState ps = ev.getPageState();
ps.reset(m_editContainer);
}
});
public void actionPerformed(ActionEvent ev) {
PageState ps = ev.getPageState();
ps.reset(m_editContainer);
}
});
RequestLocal selectedPortletRL = new RequestLocal() {
public Object initialValue(PageState ps) {
BigDecimal portletID =
(BigDecimal)ps.getValue(m_selectedPortletParam);
if (portletID == null) {
return null;
}
return Portlet.retrievePortlet(portletID);
public Object initialValue(PageState ps) {
BigDecimal portletID
= (BigDecimal) ps.getValue(m_selectedPortletParam);
if (portletID == null) {
return null;
}
};
return Portlet.retrievePortlet(portletID);
}
};
ActionListener reset = new ActionListener() {
public void actionPerformed(ActionEvent ev) {
PageState ps = ev.getPageState();
ps.reset(m_editContainer);
ps.setValue(m_selectedPortletParam, null);
}
};
m_portletModify = new ApplicationModifyComponent
(selectedPortletRL, true, reset, reset);
public void actionPerformed(ActionEvent ev) {
PageState ps = ev.getPageState();
ps.reset(m_editContainer);
ps.setValue(m_selectedPortletParam, null);
}
};
m_portletModify = new ApplicationModifyComponent(selectedPortletRL, true, reset, reset);
m_renameTabForm = new RenameTabForm(selectedTabIDRL);
m_deleteTabForm = new DeleteTabForm(selectedTabIDRL);
@ -359,10 +359,10 @@ public class DisplayPane extends DynamicListWizard {
setEditPane(m_editContainer);
((List) getListingComponent()).addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
ev.getPageState().reset(m_editContainer);
}
});
public void stateChanged(ChangeEvent ev) {
ev.getPageState().reset(m_editContainer);
}
});
//
//This cell renderer attempts to do the following:
@ -377,118 +377,110 @@ 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;
boolean isFirst = false;
boolean isLast = false;
Label tabName;
int indent_ctr = 0;
boolean isFirst = false;
boolean isLast = false;
SimpleContainer container = new SimpleContainer();
SimpleContainer container = new SimpleContainer();
//get the collection of tabs, its size, and use this info
//to determine where in the collection this tab name resides...
BigDecimal bd = new BigDecimal(key);
PortalTab ptab = PortalTab.retrieveTab(bd);
PortalSite psite = ptab.getPortalSite();
PortalTabCollection ptcoll = psite.getTabsForPortalSite();
long size = ptcoll.size();
//to determine where in the collection this tab name resides...
BigDecimal bd = new BigDecimal(key);
PortalTab ptab = PortalTab.retrieveTab(bd);
PortalSite psite = ptab.getPortalSite();
PortalTabCollection ptcoll = psite.getTabsForPortalSite();
long size = ptcoll.size();
//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);
tabName = new Label(value.toString());
container.add(tabName);
//Update tab request local
selectedTabIDRL.set(state,bd);
return container;
}
}
else //more than one tab...
{
indent_ctr = 0;
while(ptcoll.next())
{
indent_ctr++;
if(bd.compareTo(ptcoll.getID()) == 0) //we found tab...
{
if(indent_ctr == 1)
isFirst = true;
if(indent_ctr == size)
isLast = true;
break;
}
}
// and then get outa here...
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);
return container;
}
ptcoll.close();
//Code below constructs proper indent for tab
StringBuffer buf = new StringBuffer(200);
for(int i = 0; i < (indent_ctr - 1); i++)
} else //more than one tab...
{
indent_ctr = 0;
while (ptcoll.next()) {
indent_ctr++;
if (bd.compareTo(ptcoll.getID()) == 0) //we found tab...
{
buf.append(FOUR_SPACE_INDENT_STRING);
if (indent_ctr == 1) {
isFirst = true;
}
if (indent_ctr == size) {
isLast = true;
}
break;
}
}
}
ptcoll.close();
//Code below constructs proper indent for tab
StringBuffer buf = new StringBuffer(200);
for (int i = 0; i < (indent_ctr - 1); i++) {
buf.append(FOUR_SPACE_INDENT_STRING);
}
//Here we construct the control links for arrows
//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...
{
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"));
ControlLink linkLeft = new ControlLink(labelLeft) {
public void setControlEvent(PageState s) {
s.setControlEvent(dlw,"left","1");
}
};
ControlLink linkRight = new ControlLink(labelRight) {
public void setControlEvent(PageState s) {
s.setControlEvent(dlw,"right","1");
}
};
linkLeft.setClassAttr("shiftleft");
linkRight.setClassAttr("shiftright");
if(isFirst)
{
container.add(tabName);
container.add(linkRight);
}
else if(isLast)
{
container.add(linkLeft);
container.add(tabName);
}
else //This tab is somewhere in the middle...
{
container.add(linkLeft);
container.add(tabName);
container.add(linkRight);
}
//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...
{
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"));
ControlLink linkLeft = new ControlLink(labelLeft) {
public void setControlEvent(PageState s) {
s.setControlEvent(dlw, "left", "1");
}
else //this tab is NOT selected...return a link
{
String ttab = buf.toString() + value.toString();
tabName = new Label(ttab,false);
ControlLink l = new ControlLink(tabName);
container.add(l);
};
ControlLink linkRight = new ControlLink(labelRight) {
public void setControlEvent(PageState s) {
s.setControlEvent(dlw, "right", "1");
}
return container;
};
linkLeft.setClassAttr("shiftleft");
linkRight.setClassAttr("shiftright");
if (isFirst) {
container.add(tabName);
container.add(linkRight);
} else if (isLast) {
container.add(linkLeft);
container.add(tabName);
} 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
{
String ttab = buf.toString() + value.toString();
tabName = new Label(ttab, false);
ControlLink l = new ControlLink(tabName);
container.add(l);
}
});
return container;
}
});
} //end of constructor
@ -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()
.getSelectedKey(state);
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);
PortalTab ptab = PortalTab.retrieveTab(tabID);
TextField tf = (TextField)e.getTarget();
tf.setValue(s,ptab.getTitle());
}
});
} catch(java.util.TooManyListenersException e) { }
public void prepare(PrintEvent e) {
PageState s = e.getPageState();
BigDecimal tabID = (BigDecimal) m_tabIDRL.get(s);
PortalTab ptab = PortalTab.retrieveTab(tabID);
TextField tf = (TextField) e.getTarget();
tf.setValue(s, ptab.getTitle());
}
});
} 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,28 +564,29 @@ 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);
PortalTab ptab = PortalTab.retrieveTab(tabID);
Label t = (Label)e.getTarget();
t.setLabel(prefixstr + ptab.getTitle() + " tab?");
}
});
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);
PortalTab ptab = PortalTab.retrieveTab(tabID);
Label t = (Label) e.getTarget();
t.setLabel(prefixstr + ptab.getTitle() + " tab?");
}
});
button = new Submit("Delete this tab");
button.setButtonLabel("Delete this 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,34 +661,28 @@ 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)
{
Label label = new Label(val);
label.setClassAttr(val);
return label;
}
else
{
ControlLink link = new ControlLink(val);
link.setClassAttr(val);
link.setStyleAttr("HooHaH");
return link;
}
if (isSelected) {
Label label = new Label(val);
label.setClassAttr(val);
return label;
} else {
ControlLink link = new ControlLink(val);
link.setClassAttr(val);
link.setStyleAttr("HooHaH");
return link;
}
}
}
}

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,15 +108,16 @@ public class ApplicationSelector extends Form {
*
*/
private class AppSubmissionListener implements FormSubmissionListener {
public void submitted(FormSectionEvent e)
throws FormProcessException {
if (m_buttons.getCancelButton().isSelected(e.getPageState())) {
s_log.debug("Firing event for cancel");
fireCompletionEvent(e.getPageState());
throw new FormProcessException("canncelled");
}
s_log.debug("Falling through for process");
}
throws FormProcessException {
if (m_buttons.getCancelButton().isSelected(e.getPageState())) {
s_log.debug("Firing event for cancel");
fireCompletionEvent(e.getPageState());
throw new FormProcessException("canncelled");
}
s_log.debug("Falling through for process");
}
}
/**
@ -130,7 +131,7 @@ public class ApplicationSelector extends Form {
PageState state = e.getPageState();
state.setValue(m_app, m_apps.getValue(state));
fireCompletionEvent(e.getPageState());
fireCompletionEvent(e.getPageState());
}
}
@ -148,15 +149,16 @@ public class ApplicationSelector extends Form {
apps.addEqualsFilter("resourceType.id",
m_type.getID());
if (m_privilege != null) {
Party user = Kernel.getContext().getParty();
Party user = Kernel.getContext().getParty();
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;
@ -53,94 +52,95 @@ import com.arsdigita.util.UncheckedWrapperException;
* @version $Id: LayoutForm.java 1174 2006-06-14 14:14:15Z fabrice $
*/
public class LayoutForm extends Form implements FormProcessListener,
FormInitListener {
FormInitListener {
private WorkspaceSelectionAbstractModel m_workspace;
private WorkspaceSelectionAbstractModel m_workspace;
private PortalSelectionModel m_portal;
private PortalSelectionModel m_portal;
private SingleSelect m_layout;
private SingleSelect m_layout;
private Submit m_save;
private Submit m_save;
public LayoutForm(PortalSelectionModel portal) {
this(null, portal);
}
public LayoutForm(PortalSelectionModel portal) {
this(null, portal);
}
public LayoutForm(WorkspaceSelectionAbstractModel workspace,
PortalSelectionModel portal) {
super("editLayout", new SimpleContainer("portal:editLayout",
WorkspacePage.PORTAL_XML_NS));
public LayoutForm(WorkspaceSelectionAbstractModel workspace,
PortalSelectionModel portal) {
super("editLayout", new SimpleContainer("portal:editLayout",
WorkspacePage.PORTAL_XML_NS));
m_workspace = workspace;
m_portal = portal;
m_workspace = workspace;
m_portal = portal;
m_layout = new SingleSelect(new OIDParameter("layout"));
m_layout.addValidationListener(new NotNullValidationListener());
try {
m_layout.addPrintListener(new PrintListener() {
public void prepare(PrintEvent ev) {
SingleSelect target = (SingleSelect) ev.getTarget();
DomainCollection layouts = PageLayout.retrieveAll();
layouts.addOrder(PageLayout.TITLE);
while (layouts.next()) {
PageLayout layout = (PageLayout) layouts
.getDomainObject();
target.addOption(new Option(layout.getOID().toString(),
layout.getTitle()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("this cannot happen", ex);
}
m_layout = new SingleSelect(new OIDParameter("layout"));
m_layout.addValidationListener(new NotNullValidationListener());
try {
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()) {
PageLayout layout = (PageLayout) layouts
.getDomainObject();
target.addOption(new Option(layout.getOID().toString(),
layout.getTitle()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("this cannot happen", ex);
}
m_save = new Submit("Save");
m_save = new Submit("Save");
add(m_layout);
add(m_save);
add(m_layout);
add(m_save);
addProcessListener(this);
addInitListener(this);
}
addProcessListener(this);
addInitListener(this);
}
public void setWorkspaceModel(WorkspaceSelectionAbstractModel workspace) {
m_workspace = workspace;
}
public void setWorkspaceModel(WorkspaceSelectionAbstractModel workspace) {
m_workspace = workspace;
}
public Workspace getSelectedWorkspace(PageState state) {
return m_workspace.getSelectedWorkspace(state);
}
public Workspace getSelectedWorkspace(PageState state) {
return m_workspace.getSelectedWorkspace(state);
}
public void init(FormSectionEvent e) {
PageState state = e.getPageState();
public void init(FormSectionEvent e) {
PageState state = e.getPageState();
WorkspacePage portal = (WorkspacePage) m_portal
.getSelectedPortal(state);
WorkspacePage portal = (WorkspacePage) m_portal
.getSelectedPortal(state);
Assert.exists(portal, WorkspacePage.class);
Assert.exists(portal, WorkspacePage.class);
m_layout.setValue(state, portal.getLayout().getOID());
}
m_layout.setValue(state, portal.getLayout().getOID());
}
public void process(FormSectionEvent e) {
PageState state = e.getPageState();
public void process(FormSectionEvent e) {
PageState state = e.getPageState();
Workspace workspace = getSelectedWorkspace(state);
Party party = Kernel.getContext().getParty();
if (!PortalHelper.canCustomize(party, workspace)) {
throw new AccessDeniedException(
"no permissions to customize workspace");
}
Workspace workspace = getSelectedWorkspace(state);
Party party = Kernel.getContext().getParty();
if (!PortalHelper.canCustomize(party, workspace)) {
throw new AccessDeniedException(
"no permissions to customize workspace");
}
WorkspacePage portal = (WorkspacePage) m_portal
.getSelectedPortal(state);
WorkspacePage portal = (WorkspacePage) m_portal
.getSelectedPortal(state);
Assert.exists(portal, WorkspacePage.class);
Assert.exists(portal, WorkspacePage.class);
OID layoutOID = (OID) m_layout.getValue(state);
PageLayout layout = (PageLayout) DomainObjectFactory
.newInstance(layoutOID);
portal.setLayout(layout);
}
OID layoutOID = (OID) m_layout.getValue(state);
PageLayout layout = (PageLayout) DomainObjectFactory
.newInstance(layoutOID);
portal.setLayout(layout);
}
}

View File

@ -12,7 +12,6 @@
* rights and limitations under the License.
*
*/
package com.arsdigita.portalworkspace.ui;
import java.math.BigDecimal;
@ -46,97 +45,98 @@ import com.arsdigita.web.Application;
public class PortletTypeForm extends Form {
private Label m_portletTypeLabel;
private Label m_portletTypeLabel;
private SingleSelect m_portletType;
private SingleSelect m_portletType;
private Submit m_submit;
private Submit m_submit;
private static Logger s_log = Logger.getLogger(PortletTypeForm.class);
private static Logger s_log = Logger.getLogger(PortletTypeForm.class);
private PrintListener m_portletTypePrintListener = new PrintListener() {
public void prepare(PrintEvent e) {
PageState pageState = e.getPageState();
private PrintListener m_portletTypePrintListener = new PrintListener() {
public void prepare(PrintEvent e) {
PageState pageState = e.getPageState();
OptionGroup optionGroup = (OptionGroup) e.getTarget();
OptionGroup optionGroup = (OptionGroup) e.getTarget();
optionGroup.clearOptions();
PortletTypeCollection portletTypes = PortletType
.retrieveAllPortletTypes();
List excludedTypes = Workspace.getConfig()
.getExcludedPortletTypes();
if (!excludedTypes.isEmpty()) {
Filter excludedTypesFilter = portletTypes
.addFilter(Application.OBJECT_TYPE
+ " not in :nonDisplayTypes");
excludedTypesFilter.set("nonDisplayTypes", excludedTypes);
}
User thisUser = (User) Kernel.getContext().getParty();
if (thisUser == null) {
PortletTypeCollection portletTypes = PortletType
.retrieveAllPortletTypes();
List excludedTypes = Workspace.getConfig()
.getExcludedPortletTypes();
if (!excludedTypes.isEmpty()) {
Filter excludedTypesFilter = portletTypes
.addFilter(Application.OBJECT_TYPE
+ " not in :nonDisplayTypes");
excludedTypesFilter.set("nonDisplayTypes", excludedTypes);
}
User thisUser = (User) Kernel.getContext().getParty();
if (thisUser == null) {
// can't actually happen, as user must be logged in at the point
// when the page with this portal in edit mode was requested
thisUser = Kernel.getPublicUser();
}
Workspace mainWorkspace;
if (Subsite.getContext().hasSite()) {
mainWorkspace = (Workspace) Subsite.getContext().getSite()
.getFrontPage();
} else {
mainWorkspace = Workspace.getDefaultHomepageWorkspace();
}
// when the page with this portal in edit mode was requested
thisUser = Kernel.getPublicUser();
}
Workspace mainWorkspace;
if (Subsite.getContext().hasSite()) {
mainWorkspace = (Workspace) Subsite.getContext().getSite()
.getFrontPage();
} else {
mainWorkspace = Workspace.getDefaultHomepageWorkspace();
}
PermissionDescriptor admin = new PermissionDescriptor(
PrivilegeDescriptor.ADMIN, mainWorkspace, thisUser);
if (PermissionService.checkPermission(admin)) {
s_log.debug(thisUser.getName()
+ " has admin rights on the current workspace");
} else {
s_log.debug(thisUser.getName()
+ " cannot administer the current main workspace");
List adminTypes = Workspace.getConfig().getAdminPortletTypes();
if (!adminTypes.isEmpty()) {
Filter adminTypesFilter = portletTypes
.addFilter(Application.OBJECT_TYPE
+ " not in :adminTypes");
adminTypesFilter.set("adminTypes", adminTypes);
}
}
portletTypes.addOrder("title");
while (portletTypes.next()) {
PortletType portletType = portletTypes.getPortletType();
Option option = new Option(portletType.getID().toString(),
portletType.getTitle());
PermissionDescriptor admin = new PermissionDescriptor(
PrivilegeDescriptor.ADMIN, mainWorkspace, thisUser);
if (PermissionService.checkPermission(admin)) {
s_log.debug(thisUser.getName()
+ " has admin rights on the current workspace");
} else {
s_log.debug(thisUser.getName()
+ " cannot administer the current main workspace");
List adminTypes = Workspace.getConfig().getAdminPortletTypes();
if (!adminTypes.isEmpty()) {
Filter adminTypesFilter = portletTypes
.addFilter(Application.OBJECT_TYPE
+ " not in :adminTypes");
adminTypesFilter.set("adminTypes", adminTypes);
}
}
portletTypes.addOrder("title");
while (portletTypes.next()) {
PortletType portletType = portletTypes.getPortletType();
Option option = new Option(portletType.getID().toString(),
portletType.getTitle());
optionGroup.addOption(option);
}
}
};
optionGroup.addOption(option);
}
}
};
/**
/**
* Default constructor
*/
public PortletTypeForm() {
this("portletTypeForm");
}
this("portletTypeForm");
}
public PortletTypeForm(String name) {
super(name, new SimpleContainer());
setRedirecting(true);
public PortletTypeForm(String name) {
super(name, new SimpleContainer());
setRedirecting(true);
m_portletType = new SingleSelect("portletTypeID");
try {
m_portletType.addPrintListener(m_portletTypePrintListener);
} catch (TooManyListenersException e) {
/* Nothing here yet. */
}
m_portletType.addValidationListener(new NotNullValidationListener(
"You must select a Portlet Type"));
add(m_portletType);
m_portletType = new SingleSelect("portletTypeID");
try {
m_portletType.addPrintListener(m_portletTypePrintListener);
} catch (TooManyListenersException e) {
/* Nothing here yet. */
}
m_portletType.addValidationListener(new NotNullValidationListener(
"You must select a Portlet Type"));
add(m_portletType);
m_submit = new Submit("Add");
add(m_submit);
}
m_submit = new Submit("Add");
add(m_submit);
}
public BigDecimal getPortletType(PageState state) {
return new BigDecimal((String) m_portletType.getValue(state));
}
public BigDecimal getPortletType(PageState state) {
return new BigDecimal((String) m_portletType.getValue(state));
}
}

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;
@ -46,113 +45,113 @@ import com.arsdigita.util.UncheckedWrapperException;
public abstract class GroupMemberPicker extends UserPicker {
private StringParameter m_restrictParam;
private StringParameter m_restrictParam;
private SingleSelect m_restrict;
private SingleSelect m_restrict;
private Option m_both;
private Option m_both;
private Option m_users;
private Option m_users;
private Option m_groups;
private Option m_groups;
public GroupMemberPicker() {
}
public GroupMemberPicker() {
}
protected void addWidgets() {
m_restrictParam = new StringParameter("restrict");
protected void addWidgets() {
m_restrictParam = new StringParameter("restrict");
m_restrict = new SingleSelect("restrict1");
m_both = new Option("both", "Users & Groups");
m_users = new Option("users", "Users Only");
m_groups = new Option("groups", "Groups Only");
m_restrict = new SingleSelect("restrict1");
m_both = new Option("both", "Users & Groups");
m_users = new Option("users", "Users Only");
m_groups = new Option("groups", "Groups Only");
m_restrict.addOption(m_both);
m_restrict.addOption(m_users);
m_restrict.addOption(m_groups);
m_restrict.setOptionSelected(m_users);
m_restrict.addOption(m_both);
m_restrict.addOption(m_users);
m_restrict.addOption(m_groups);
m_restrict.setOptionSelected(m_users);
BoxPanel opt = new BoxPanel(BoxPanel.HORIZONTAL);
opt.add(new Label("Search for"));
opt.add(m_restrict);
add(opt);
BoxPanel opt = new BoxPanel(BoxPanel.HORIZONTAL);
opt.add(new Label("Search for"));
opt.add(m_restrict);
add(opt);
super.addWidgets();
}
super.addWidgets();
}
public void register(Page p) {
super.register(p);
public void register(Page p) {
super.register(p);
p.addGlobalStateParam(m_restrictParam);
}
p.addGlobalStateParam(m_restrictParam);
}
public void init(FormSectionEvent e) {
PageState ps = e.getPageState();
public void init(FormSectionEvent e) {
PageState ps = e.getPageState();
super.init(e);
super.init(e);
m_restrict.setValue(ps, ps.getValue(m_restrictParam));
}
m_restrict.setValue(ps, ps.getValue(m_restrictParam));
}
public void process(FormSectionEvent e) {
PageState ps = e.getPageState();
public void process(FormSectionEvent e) {
PageState ps = e.getPageState();
super.process(e);
super.process(e);
ps.setValue(m_restrictParam, m_restrict.getValue(ps));
}
ps.setValue(m_restrictParam, m_restrict.getValue(ps));
}
protected abstract Group getGroup(PageState ps);
protected abstract Group getGroup(PageState ps);
protected DataQuery getUsers(PageState ps, String search) {
String bdot = Party.BASE_DATA_OBJECT_TYPE;
if (m_users.getValue().equals(ps.getValue(m_restrictParam))) {
bdot = User.BASE_DATA_OBJECT_TYPE;
} else if (m_groups.getValue().equals(ps.getValue(m_restrictParam))) {
bdot = Group.BASE_DATA_OBJECT_TYPE;
}
protected DataQuery getUsers(PageState ps, String search) {
String bdot = Party.BASE_DATA_OBJECT_TYPE;
if (m_users.getValue().equals(ps.getValue(m_restrictParam))) {
bdot = User.BASE_DATA_OBJECT_TYPE;
} else if (m_groups.getValue().equals(ps.getValue(m_restrictParam))) {
bdot = Group.BASE_DATA_OBJECT_TYPE;
}
DataCollection parties = SessionManager.getSession().retrieve(bdot);
DataCollection parties = SessionManager.getSession().retrieve(bdot);
CompoundFilter or = parties.getFilterFactory().or();
CompoundFilter or = parties.getFilterFactory().or();
Filter nameFilter = parties.getFilterFactory().simple(
"lower(displayName) like lower(:term)");
nameFilter.set("term", "%" + search + "%");
Filter emailFilter = parties.getFilterFactory().simple(
"lower(primaryEmail) like lower(:term)");
emailFilter.set("term", "%" + search + "%");
Filter nameFilter = parties.getFilterFactory().simple(
"lower(displayName) like lower(:term)");
nameFilter.set("term", "%" + search + "%");
Filter emailFilter = parties.getFilterFactory().simple(
"lower(primaryEmail) like lower(:term)");
emailFilter.set("term", "%" + search + "%");
or.addFilter(nameFilter);
or.addFilter(emailFilter);
parties.addFilter(or);
parties.addOrder(ACSObject.DISPLAY_NAME);
or.addFilter(nameFilter);
or.addFilter(emailFilter);
parties.addFilter(or);
parties.addOrder(ACSObject.DISPLAY_NAME);
return parties;
}
return parties;
}
protected String getDisplayName(DataQuery q) {
DataObject party = ((DataCollection) q).getDataObject();
return (String) party.get(ACSObject.DISPLAY_NAME);
}
protected String getDisplayName(DataQuery q) {
DataObject party = ((DataCollection) q).getDataObject();
return (String) party.get(ACSObject.DISPLAY_NAME);
}
protected String getKey(DataQuery q) {
DataObject party = ((DataCollection) q).getDataObject();
return party.get(ACSObject.ID).toString();
}
protected String getKey(DataQuery q) {
DataObject party = ((DataCollection) q).getDataObject();
return party.get(ACSObject.ID).toString();
}
protected void addUser(PageState ps, BigDecimal userID) {
Party party = null;
protected void addUser(PageState ps, BigDecimal userID) {
Party party = null;
try {
party = (Party) DomainObjectFactory.newInstance(new OID(
Party.BASE_DATA_OBJECT_TYPE, userID));
} catch (DataObjectNotFoundException ex) {
throw new UncheckedWrapperException("cannot find user", ex);
}
try {
party = (Party) DomainObjectFactory.newInstance(new OID(
Party.BASE_DATA_OBJECT_TYPE, userID));
} catch (DataObjectNotFoundException ex) {
throw new UncheckedWrapperException("cannot find user", ex);
}
Group group = getGroup(ps);
group.addMemberOrSubgroup(party);
group.save();
}
Group group = getGroup(ps);
group.addMemberOrSubgroup(party);
group.save();
}
}

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,77 +40,75 @@ 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)
/**
*
*
*/
public class WorkspaceConfigFormSection extends ApplicationConfigFormSection {
private SingleSelect m_layout;
private SingleSelect m_layout;
public WorkspaceConfigFormSection(ResourceType resType,
RequestLocal parentAppRL) {
super(resType, parentAppRL);
}
public WorkspaceConfigFormSection(ResourceType resType,
RequestLocal parentAppRL) {
super(resType, parentAppRL);
}
public WorkspaceConfigFormSection(RequestLocal application) {
super(application);
}
public WorkspaceConfigFormSection(RequestLocal application) {
super(application);
}
protected void addWidgets() {
super.addWidgets();
protected void addWidgets() {
super.addWidgets();
m_layout = new SingleSelect(new OIDParameter("layout"));
m_layout.addValidationListener(new NotNullValidationListener());
try {
m_layout.addPrintListener(new PrintListener() {
public void prepare(PrintEvent ev) {
SingleSelect target = (SingleSelect) ev.getTarget();
DomainCollection layouts = PageLayout.retrieveAll();
layouts.addOrder(PageLayout.TITLE);
while (layouts.next()) {
PageLayout layout = (PageLayout) layouts
.getDomainObject();
target.addOption(new Option(layout.getOID().toString(),
layout.getTitle()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("this cannot happen", ex);
}
add(new Label("Default Page Layout:", Label.BOLD), ColumnPanel.RIGHT);
add(m_layout);
}
m_layout = new SingleSelect(new OIDParameter("layout"));
m_layout.addValidationListener(new NotNullValidationListener());
try {
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()) {
PageLayout layout = (PageLayout) layouts
.getDomainObject();
target.addOption(new Option(layout.getOID().toString(),
layout.getTitle()));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("this cannot happen", ex);
}
add(new Label("Default Page Layout:", Label.BOLD), ColumnPanel.RIGHT);
add(m_layout);
}
protected void initWidgets(PageState state, Application app)
throws FormProcessException {
super.initWidgets(state, app);
protected void initWidgets(PageState state, Application app)
throws FormProcessException {
super.initWidgets(state, app);
if (app != null) {
Workspace workspace = (Workspace) app;
m_layout.setValue(state, workspace.getDefaultLayout().getOID());
} else {
m_layout.setValue(state, PageLayout.getDefaultLayout().getOID());
}
}
if (app != null) {
Workspace workspace = (Workspace) app;
m_layout.setValue(state, workspace.getDefaultLayout().getOID());
} else {
m_layout.setValue(state, PageLayout.getDefaultLayout().getOID());
}
}
protected void processWidgets(PageState state, Application app)
throws FormProcessException {
super.processWidgets(state, app);
protected void processWidgets(PageState state, Application app)
throws FormProcessException {
super.processWidgets(state, app);
Workspace workspace = (Workspace) app;
Workspace workspace = (Workspace) app;
OID layoutOID = (OID) m_layout.getValue(state);
PageLayout layout = (PageLayout) DomainObjectFactory
.newInstance(layoutOID);
workspace.setDefaultLayout(layout);
}
OID layoutOID = (OID) m_layout.getValue(state);
PageLayout layout = (PageLayout) DomainObjectFactory
.newInstance(layoutOID);
workspace.setDefaultLayout(layout);
}
}

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;
@ -55,134 +54,137 @@ import com.arsdigita.web.Web;
*/
public class ContentDirectoryPortletEditor extends PortletConfigFormSection {
private static final Logger s_log = Logger
.getLogger(ContentDirectoryPortletEditor.class);
private static final Logger s_log = Logger
.getLogger(ContentDirectoryPortletEditor.class);
private SingleSelect m_root;
private SingleSelect m_root;
private SingleSelect m_layout;
private SingleSelect m_layout;
private SingleSelect m_depth;
private SingleSelect m_depth;
/**
/**
* Constructor
*
* @param resType
* @param parentAppRL
*/
public ContentDirectoryPortletEditor(ResourceType resType,
RequestLocal parentAppRL) {
super(resType, parentAppRL);
}
RequestLocal parentAppRL) {
super(resType, parentAppRL);
}
/**
/**
*
* @param application
*/
public ContentDirectoryPortletEditor(RequestLocal application) {
super(application);
}
super(application);
}
/**
/**
*
*/
public void addWidgets() {
super.addWidgets();
super.addWidgets();
m_root = new SingleSelect(new BigDecimalParameter("root"));
try {
m_root.addPrintListener(new CategoryPrintListener());
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("this cannot happen", ex);
}
m_root = new SingleSelect(new BigDecimalParameter("root"));
try {
m_root.addPrintListener(new CategoryPrintListener());
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("this cannot happen", ex);
}
m_layout = new SingleSelect(new StringParameter("layout"));
m_layout.addOption(new Option("grid", "Grid"));
m_layout.addOption(new Option("panel", "Panel"));
m_layout = new SingleSelect(new StringParameter("layout"));
m_layout.addOption(new Option("grid", "Grid"));
m_layout.addOption(new Option("panel", "Panel"));
m_depth = new SingleSelect(new IntegerParameter("depth"));
m_depth.addOption(new Option("1", "1 Level"));
m_depth.addOption(new Option("2", "2 Levels"));
m_depth = new SingleSelect(new IntegerParameter("depth"));
m_depth.addOption(new Option("1", "1 Level"));
m_depth.addOption(new Option("2", "2 Levels"));
add(new Label("Root category:", Label.BOLD), ColumnPanel.RIGHT);
add(m_root);
add(new Label("Root category:", Label.BOLD), ColumnPanel.RIGHT);
add(m_root);
add(new Label("Layout:", Label.BOLD), ColumnPanel.RIGHT);
add(m_layout);
add(new Label("Layout:", Label.BOLD), ColumnPanel.RIGHT);
add(m_layout);
add(new Label("Depth:", Label.BOLD), ColumnPanel.RIGHT);
add(m_depth);
}
add(new Label("Depth:", Label.BOLD), ColumnPanel.RIGHT);
add(m_depth);
}
/**
/**
*
* @param state
* @param portlet
* @throws FormProcessException
*/
public void initWidgets(PageState state, Portlet portlet)
throws FormProcessException {
super.initWidgets(state, portlet);
throws FormProcessException {
super.initWidgets(state, portlet);
if (portlet != null) {
ContentDirectoryPortlet myportlet = (ContentDirectoryPortlet) portlet;
if (portlet != null) {
ContentDirectoryPortlet myportlet = (ContentDirectoryPortlet) portlet;
m_root.setValue(state, myportlet.getRoot().getID());
m_layout.setValue(state, myportlet.getLayout());
m_depth.setValue(state, new Integer(myportlet.getDepth()));
}
}
m_root.setValue(state, myportlet.getRoot().getID());
m_layout.setValue(state, myportlet.getLayout());
m_depth.setValue(state, new Integer(myportlet.getDepth()));
}
}
/**
/**
*
* @param state
* @param portlet
* @throws FormProcessException
*/
public void processWidgets(PageState state, Portlet portlet)
throws FormProcessException {
super.processWidgets(state, portlet);
throws FormProcessException {
super.processWidgets(state, portlet);
ContentDirectoryPortlet myportlet = (ContentDirectoryPortlet) portlet;
myportlet.setLayout((String) m_layout.getValue(state));
myportlet.setDepth(((Integer) m_depth.getValue(state)).intValue());
ContentDirectoryPortlet myportlet = (ContentDirectoryPortlet) portlet;
myportlet.setLayout((String) m_layout.getValue(state));
myportlet.setDepth(((Integer) m_depth.getValue(state)).intValue());
BigDecimal id = (BigDecimal) m_root.getValue(state);
Category root;
try {
root = (Category) DomainObjectFactory.newInstance(new OID(
Category.BASE_DATA_OBJECT_TYPE, id));
} catch (DataObjectNotFoundException ex) {
throw new UncheckedWrapperException("cannot find category", ex);
}
myportlet.setRoot(root);
}
BigDecimal id = (BigDecimal) m_root.getValue(state);
Category root;
try {
root = (Category) DomainObjectFactory.newInstance(new OID(
Category.BASE_DATA_OBJECT_TYPE, id));
} catch (DataObjectNotFoundException ex) {
throw new UncheckedWrapperException("cannot find category", ex);
}
myportlet.setRoot(root);
}
/**
/**
*
* @return
*/
protected String getUseContext() {
return null;
}
return null;
}
/**
/**
*
*/
private class CategoryPrintListener implements PrintListener {
public void prepare(PrintEvent e) {
SingleSelect target = (SingleSelect) e.getTarget();
Application app = Web.getWebContext().getApplication();
Category root = Category.getRootForObject(app, getUseContext());
public void prepare(PrintEvent e) {
SingleSelect target = (SingleSelect) e.getTarget();
target.clearOptions();
Map cats = CategorizationTree.getSubtreePath(root, " > ");
Iterator i = cats.keySet().iterator();
while (i.hasNext()) {
String path = (String) i.next();
Category cat = (Category) cats.get(path);
Application app = Web.getWebContext().getApplication();
Category root = Category.getRootForObject(app, getUseContext());
target.addOption(new Option(cat.getID().toString(), path));
}
}
}
Map cats = CategorizationTree.getSubtreePath(root, " > ");
Iterator i = cats.keySet().iterator();
while (i.hasNext()) {
String path = (String) i.next();
Category cat = (Category) cats.get(path);
target.addOption(new Option(cat.getID().toString(), path));
}
}
}
}

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;
@ -39,140 +38,142 @@ import com.arsdigita.xml.Element;
public class RSSFeedPortletBrowserForm extends Form {
private BoxPanel m_hosts_pnl;
private BoxPanel m_hosts_pnl;
private BoxPanel m_feeds_pnl;
private BoxPanel m_feeds_pnl;
private SingleSelect m_hosts;
private SingleSelect m_hosts;
private SingleSelect m_feeds;
private SingleSelect m_feeds;
private Label m_no_feeds;
private Label m_no_feeds;
private Submit m_display;
private Submit m_display;
private Submit m_cancel;
private Submit m_cancel;
private Submit m_select;
private Submit m_select;
private Submit m_back;
private Submit m_back;
private RequestLocal m_feed = new RequestLocal();
private RequestLocal m_feed = new RequestLocal();
public RSSFeedPortletBrowserForm() {
super("Browser");
public RSSFeedPortletBrowserForm() {
super("Browser");
m_hosts_pnl = new BoxPanel(BoxPanel.HORIZONTAL);
m_feeds_pnl = new BoxPanel(BoxPanel.HORIZONTAL);
m_hosts_pnl = new BoxPanel(BoxPanel.HORIZONTAL);
m_feeds_pnl = new BoxPanel(BoxPanel.HORIZONTAL);
add(m_hosts_pnl);
add(m_feeds_pnl);
add(m_hosts_pnl);
add(m_feeds_pnl);
Label hosts_lbl = new Label("Hosts:");
Label feeds_lbl = new Label("Feeds:");
m_no_feeds = new Label("none available");
Label hosts_lbl = new Label("Hosts:");
Label feeds_lbl = new Label("Feeds:");
m_no_feeds = new Label("none available");
m_hosts_pnl.add(hosts_lbl);
m_feeds_pnl.add(feeds_lbl);
m_feeds_pnl.add(m_no_feeds);
m_hosts_pnl.add(hosts_lbl);
m_feeds_pnl.add(feeds_lbl);
m_feeds_pnl.add(m_no_feeds);
m_hosts = new SingleSelect(new StringParameter("host"));
m_feeds = new SingleSelect(new StringParameter("feed"));
m_hosts = new SingleSelect(new StringParameter("host"));
m_feeds = new SingleSelect(new StringParameter("feed"));
m_hosts_pnl.add(m_hosts);
m_feeds_pnl.add(m_feeds);
m_hosts_pnl.add(m_hosts);
m_feeds_pnl.add(m_feeds);
m_back = new Submit("back", "Back");
m_cancel = new Submit("cancel", "Back");
m_display = new Submit("display", "Display feeds");
m_select = new Submit("select", "Select feed");
m_back = new Submit("back", "Back");
m_cancel = new Submit("cancel", "Back");
m_display = new Submit("display", "Display feeds");
m_select = new Submit("select", "Select feed");
m_feeds_pnl.add(m_back);
m_feeds_pnl.add(m_select);
m_hosts_pnl.add(m_cancel);
m_hosts_pnl.add(m_display);
m_feeds_pnl.add(m_back);
m_feeds_pnl.add(m_select);
m_hosts_pnl.add(m_cancel);
m_hosts_pnl.add(m_display);
addProcessListener(new FormProcessListener() {
public void process(FormSectionEvent e) throws FormProcessException {
PageState state = e.getPageState();
addProcessListener(new FormProcessListener() {
public void process(FormSectionEvent e) throws FormProcessException {
PageState state = e.getPageState();
if (m_select.isSelected(state)) {
fireCompletionEvent(state);
} else if (m_display.isSelected(state)) {
setDisplay(state, false);
} else if (m_back.isSelected(state)) {
setDisplay(state, true);
} else if (m_cancel.isSelected(state)) {
fireCompletionEvent(state);
}
}
});
if (m_select.isSelected(state)) {
fireCompletionEvent(state);
} else if (m_display.isSelected(state)) {
setDisplay(state, false);
} else if (m_back.isSelected(state)) {
setDisplay(state, true);
} else if (m_cancel.isSelected(state)) {
fireCompletionEvent(state);
}
}
});
try {
m_hosts.addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) {
SingleSelect group = (SingleSelect) e.getTarget();
try {
m_hosts.addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) {
SingleSelect group = (SingleSelect) e.getTarget();
group.clearOptions();
Iterator hosts = RSSFeedPortletHelper.getACSJHosts();
while (hosts.hasNext()) {
String host[] = (String[]) hosts.next();
Iterator hosts = RSSFeedPortletHelper.getACSJHosts();
while (hosts.hasNext()) {
String host[] = (String[]) hosts.next();
group.addOption(new Option(host[0], host[1]));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("This can never happen", ex);
}
group.addOption(new Option(host[0], host[1]));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("This can never happen", ex);
}
try {
m_feeds.addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) {
SingleSelect group = (SingleSelect) e.getTarget();
try {
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()) {
String feed[] = (String[]) feeds.next();
Iterator feeds = (Iterator) m_feed.get(e.getPageState());
while (feeds != null && feeds.hasNext()) {
String feed[] = (String[]) feeds.next();
group.addOption(new Option(feed[0], feed[1]));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("This can never happen", ex);
}
}
group.addOption(new Option(feed[0], feed[1]));
}
}
});
} catch (TooManyListenersException ex) {
throw new UncheckedWrapperException("This can never happen", ex);
}
}
public String getFeedURL(PageState state) {
return (String) m_feeds.getValue(state);
}
public String getFeedURL(PageState state) {
return (String) m_feeds.getValue(state);
}
public void register(Page p) {
super.register(p);
public void register(Page p) {
super.register(p);
p.setVisibleDefault(m_hosts_pnl, true);
p.setVisibleDefault(m_feeds_pnl, false);
}
p.setVisibleDefault(m_hosts_pnl, true);
p.setVisibleDefault(m_feeds_pnl, false);
}
private void setDisplay(PageState state, boolean initial) {
m_hosts_pnl.setVisible(state, initial);
m_feeds_pnl.setVisible(state, !initial);
}
private void setDisplay(PageState state, boolean initial) {
m_hosts_pnl.setVisible(state, initial);
m_feeds_pnl.setVisible(state, !initial);
}
public void generateXML(PageState state, Element parent) {
if (m_hosts.getValue(state) == null) {
m_feed.set(state, null);
setDisplay(state, true);
} else {
String host = (String) m_hosts.getValue(state);
Iterator feed = RSSFeedPortletHelper.getACSJFeeds(host);
m_feed.set(state, feed);
public void generateXML(PageState state, Element parent) {
if (m_hosts.getValue(state) == null) {
m_feed.set(state, null);
setDisplay(state, true);
} else {
String host = (String) m_hosts.getValue(state);
Iterator feed = RSSFeedPortletHelper.getACSJFeeds(host);
m_feed.set(state, feed);
m_no_feeds.setVisible(state, !feed.hasNext());
m_feeds.setVisible(state, feed.hasNext());
m_select.setVisible(state, feed.hasNext());
}
m_no_feeds.setVisible(state, !feed.hasNext());
m_feeds.setVisible(state, feed.hasNext());
m_select.setVisible(state, feed.hasNext());
}
super.generateXML(state, parent);
}
super.generateXML(state, parent);
}
}

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;
@ -30,7 +31,7 @@ import com.arsdigita.bebop.event.RequestEvent;
import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.ActionEvent;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.Link;
import com.arsdigita.bebop.Page;
@ -62,11 +63,10 @@ import com.arsdigita.simplesurvey.ui.SurveySelectionModel;
import java.math.BigDecimal;
public class AnswerValuesPanel extends SimpleContainer {
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,291 +85,316 @@ 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;
public AnswerValuesPanel(SurveySelectionModel survey) {
super();
m_survey = survey;
super();
m_survey = survey;
m_answerText = new RequestLocal();
m_questionText = new RequestLocal();
m_answerValue = new RequestLocal();
m_answerText = new RequestLocal();
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.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_back.setVisible(ps, true);
}
});
m_back = new Link(new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.back_to_survey_list")), "../admin");
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_back.setVisible(ps, true);
}
});
m_back = new Link(new Label(GlobalizationUtil.globalize(
"simplesurvey.ui.admin.back_to_survey_list")), "../admin");
add(m_complete);
add(m_back);
setupAnswerTable();
setupAnswerValuesForm();
add(m_complete);
add(m_back);
setupAnswerTable();
setupAnswerValuesForm();
}
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() {
public void pageRequested(RequestEvent e) {
PageState ps = e.getPageState();
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_back.setVisible(ps, true);
} /*else {
m_answerTable.setVisible(ps, false);
m_answerValuesForm.setVisible(ps, true);
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() {
public void pageRequested(RequestEvent e) {
PageState ps = e.getPageState();
BigDecimal optionID = (BigDecimal) ps.getValue(m_optionID);
final String query = "com.arsdigita.simplesurvey.getAnswerOption";
DataQuery dq = SessionManager.getSession().retrieveQuery(query);
dq.setParameter("optionID", optionID);
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_back.setVisible(ps, true);
} /*else {
m_answerTable.setVisible(ps, false);
m_answerValuesForm.setVisible(ps, true);
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));
}
dq.close();
}*/
}
});
BigDecimal optionID = (BigDecimal) ps.getValue(m_optionID);
final String query = "com.arsdigita.simplesurvey.getAnswerOption";
DataQuery dq = SessionManager.getSession().retrieveQuery(query);
dq.setParameter("optionID", optionID);
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));
}
dq.close();
}*/
}
});
}
private String getQuestionText(PageState ps) {
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;
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
m_answerTable = new DataTable(new AnswerListingBuilder());
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);
c1.setHeaderRenderer(new GlobalizedHeaderRenderer());
c2.setHeaderRenderer(new GlobalizedHeaderRenderer());
c3.setHeaderRenderer(new GlobalizedHeaderRenderer());
// This is the table that holds the list of all answer options in the survey
m_answerTable = new DataTable(new AnswerListingBuilder());
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);
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();
editValueColumn.setCellRenderer(new EditLinkRenderer());
m_answerTable.getColumnModel().add(editValueColumn);
m_answerTable.addTableActionListener(new AnswerValueActionListener());
add(m_answerTable);
// The admin can select a point value for each answer
TableColumn editValueColumn = new TableColumn();
editValueColumn.setCellRenderer(new EditLinkRenderer());
m_answerTable.getColumnModel().add(editValueColumn);
m_answerTable.addTableActionListener(new AnswerValueActionListener());
add(m_answerTable);
}
private BigDecimal getSurveyID(PageState ps) {
BigDecimal surveyID = null;
if ( ps.getValue(m_surveyID) == null ) {
Survey s = m_survey.getSelectedSurvey(ps);
surveyID = s.getID();
} else {
surveyID = (BigDecimal) ps.getValue(m_surveyID);
}
return surveyID;
}
private BigDecimal getSurveyID(PageState ps) {
BigDecimal surveyID = null;
if (ps.getValue(m_surveyID) == null) {
Survey s = m_survey.getSelectedSurvey(ps);
surveyID = s.getID();
} else {
surveyID = (BigDecimal) ps.getValue(m_surveyID);
}
return surveyID;
}
private void setupAnswerValuesForm() {
m_answerValuesForm = new AnswerValuesForm();
add(m_answerValuesForm);
}
private class AnswerValueActionListener extends TableActionAdapter{
m_answerValuesForm = new AnswerValuesForm();
add(m_answerValuesForm);
}
public void cellSelected(TableActionEvent e) {
PageState ps = e.getPageState();
ps.setValue(m_optionID, new BigDecimal(e.getRowKey().toString()));
m_answerTable.setVisible(ps, false);
m_back.setVisible(ps, false);
m_complete.setVisible(ps, true);
m_answerValuesForm.setVisible(ps, true);
private class AnswerValueActionListener extends TableActionAdapter {
BigDecimal optionID = (BigDecimal) ps.getValue(m_optionID);
final String query = "com.arsdigita.simplesurvey.getAnswerOption";
DataQuery dq = SessionManager.getSession().retrieveQuery(query);
dq.setParameter("optionID", optionID);
public void cellSelected(TableActionEvent e) {
PageState ps = e.getPageState();
ps.setValue(m_optionID, new BigDecimal(e.getRowKey().toString()));
m_answerTable.setVisible(ps, false);
m_back.setVisible(ps, false);
m_complete.setVisible(ps, true);
m_answerValuesForm.setVisible(ps, true);
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));
}
dq.close();
BigDecimal optionID = (BigDecimal) ps.getValue(m_optionID);
final String query = "com.arsdigita.simplesurvey.getAnswerOption";
DataQuery dq = SessionManager.getSession().retrieveQuery(query);
dq.setParameter("optionID", optionID);
}
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));
}
dq.close();
}
}
private class AnswerValuesForm extends Form {
private AnswerValuesForm() {
private AnswerValuesForm() {
super("answerValuesForm");
Label questionText = new Label(new PrintListener() {
public void prepare(PrintEvent e) {
PageState ps = e.getPageState();
Label target = (Label) e.getTarget();
target.setLabel(getQuestionText(ps));
}
});
super("answerValuesForm");
Label questionText = new Label(new PrintListener() {
public void prepare(PrintEvent e) {
PageState ps = e.getPageState();
Label target = (Label) e.getTarget();
target.setLabel(getQuestionText(ps));
}
});
Label answerText = new Label(new PrintListener() {
public void prepare(PrintEvent e) {
PageState ps = e.getPageState();
Label target = (Label) e.getTarget();
target.setLabel(getAnswerText(ps));
}
});
add(questionText);
add(answerText);
m_select = new SingleSelect(ANSWER_VALUE);
m_select.addOption(new Option("0", new Label("0")));
m_select.addOption(new Option("1", new Label("1")));
m_select.addOption(new Option("2", new Label("2")));
m_select.addOption(new Option("3", new Label("3")));
m_select.addOption(new Option("4", new Label("4")));
m_select.addOption(new Option("5", new Label("5")));
m_select.addOption(new Option("6", new Label("6")));
m_select.addOption(new Option("7", new Label("7")));
m_select.addOption(new Option("8", new Label("8")));
m_select.addOption(new Option("9", new Label("9")));
m_select.addOption(new Option("10", new Label("10")));
add(m_select);
add(new Submit(GlobalizationUtil.globalize("simplesurvey.ui.admin.submit")));
//add(new Submit(GlobalizationUtil.globalize("simplesurvey.ui.admin.done_editing")));
addProcessListener(new AnswerValuesProcessListener());
addInitListener(new AnswerValuesInitListener());
}
Label answerText = new Label(new PrintListener() {
public void prepare(PrintEvent e) {
PageState ps = e.getPageState();
Label target = (Label) e.getTarget();
target.setLabel(getAnswerText(ps));
}
});
add(questionText);
add(answerText);
m_select = new SingleSelect(ANSWER_VALUE);
m_select.addOption(new Option("0", new Label("0")));
m_select.addOption(new Option("1", new Label("1")));
m_select.addOption(new Option("2", new Label("2")));
m_select.addOption(new Option("3", new Label("3")));
m_select.addOption(new Option("4", new Label("4")));
m_select.addOption(new Option("5", new Label("5")));
m_select.addOption(new Option("6", new Label("6")));
m_select.addOption(new Option("7", new Label("7")));
m_select.addOption(new Option("8", new Label("8")));
m_select.addOption(new Option("9", new Label("9")));
m_select.addOption(new Option("10", new Label("10")));
add(m_select);
add(new Submit(GlobalizationUtil.globalize("simplesurvey.ui.admin.submit")));
//add(new Submit(GlobalizationUtil.globalize("simplesurvey.ui.admin.done_editing")));
addProcessListener(new AnswerValuesProcessListener());
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");
dao.setParameter("optionID", optionID);
dao.setParameter("answerValue", answerValue);
dao.execute();
ps.setValue(m_optionID, null);
}
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");
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));
}
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) {
Label label = new Label(GlobalizationUtil.globalize((String) value));
public Component getComponent(Table table, PageState state, Object value,
boolean isSelected, Object key, int row,
int column) {
Label label = new Label(GlobalizationUtil.globalize((String) value));
// Removed. Is is the responsibility of the theme to position Labels
// appropriately. We have to check for side effects in older themes!
// label.setVerticalAlignment(CENTER);
return label;
}
// appropriately. We have to check for side effects in older themes!
// label.setVerticalAlignment(CENTER);
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() ) {
lock();
}
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()));
}
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()) {
lock();
}
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()));
}
}
private class EditLinkRenderer implements TableCellRenderer {
@Override
public Component getComponent(Table table, PageState ps, Object value,
boolean isSelected, Object key, int row,
int column) {
@Override
public Component getComponent(Table table, PageState ps, Object value,
boolean isSelected, Object key, int row,
int column) {
if ( ! isLocked() && table != null && table.isLocked() ) {
lock();
}
if ( value == null ) {
return new Label("");
}
/*Link l = new Link(new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.edit_value")),"../admin");
BigDecimal surveyID = getSurveyID(ps);
if (!isLocked() && table != null && table.isLocked()) {
lock();
}
if (value == null) {
return new Label("");
}
/*Link l = new Link(new Label(GlobalizationUtil.globalize("simplesurvey.ui.admin.edit_value")),"../admin");
BigDecimal surveyID = getSurveyID(ps);
//Sometimes we can get the surveyID from the global parameter, sometimes from the selection
l.setVar("survey_id", surveyID.toString());
l.setVar("option_id", ((BigDecimal) key).toString());
//Sometimes we can get the surveyID from the global parameter, sometimes from the selection
l.setVar("survey_id", surveyID.toString());
l.setVar("option_id", ((BigDecimal) key).toString());
return l; */
ControlLink cl = new ControlLink(new Label (GlobalizationUtil.globalize("simplesurvey.ui.admin.edit_value")));
return cl;
}
return l; */
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);
dq.setParameter("surveyID", getSurveyID(ps));
return dq;
}
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);
dq.setParameter("surveyID", getSurveyID(ps));
return dq;
}
public String getKeyColumn() {
return KEY_COLUMN;
}
public String getKeyColumn() {
return KEY_COLUMN;
}
public void lock() {
m_locked = true;
}
public boolean isLocked() {
return m_locked;
}
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

@ -71,533 +71,522 @@ import com.arsdigita.xml.Document;
*/
public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants {
private static final Logger s_log = Logger.getLogger(WebpageCMSEditorPage.class);
private static final Logger s_log = Logger.getLogger(WebpageCMSEditorPage.class);
private WebpageCMSEditorForm m_createForm;
private WebpageCMSEditorForm m_editForm;
private WebpageCMSEditorForm m_createForm;
private WebpageCMSEditorForm m_editForm;
public WebpageCMSEditorPage() {
super("Story Editor", new SimpleContainer());
public WebpageCMSEditorPage() {
super("Story Editor", new SimpleContainer());
SimpleContainer header = new SimpleContainer(HEADER_ELEMENT, XML_NS);
SimpleContainer body = new SimpleContainer(BODY_ELEMENT, XML_NS);
SimpleContainer footer = new SimpleContainer(FOOTER_ELEMENT, XML_NS);
SimpleContainer header = new SimpleContainer(HEADER_ELEMENT, XML_NS);
SimpleContainer body = new SimpleContainer(BODY_ELEMENT, XML_NS);
SimpleContainer footer = new SimpleContainer(FOOTER_ELEMENT, XML_NS);
m_createForm = new WebpageCMSEditorForm(true);
m_editForm = new WebpageCMSEditorForm(false);
body.add(m_createForm);
body.add(m_editForm);
m_createForm = new WebpageCMSEditorForm(true);
m_editForm = new WebpageCMSEditorForm(false);
body.add(m_createForm);
body.add(m_editForm);
add(header);
add(body);
add(footer);
}
add(header);
add(body);
add(footer);
}
protected void buildPage() {
super.buildPage();
setClassAttr("webpage");
}
protected void buildPage() {
super.buildPage();
setClassAttr("webpage");
}
public void generateXML(PageState state, Document parent) {
BigDecimal id = null;
try {
HttpServletRequest request = state.getRequest();
id = new BigDecimal(request.getParameter(Webpage.ID));
}
catch (Exception ex) {
}
m_createForm.setVisible(state, id == null);
m_editForm.setVisible(state, id != null);
super.generateXML(state, parent);
}
public void generateXML(PageState state, Document parent) {
BigDecimal id = null;
try {
HttpServletRequest request = state.getRequest();
id = new BigDecimal(request.getParameter(Webpage.ID));
} 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;
MultipleSelect m_categories;
CMSDHTMLEditor m_body;
CMSDHTMLEditor m_desc;
Submit m_save;
Date m_startDate;
TextField m_startHour;
TextField m_startMinute;
SingleSelect m_startAmpm;
Date m_endDate;
TextField m_endHour;
TextField m_endMinute;
SingleSelect m_endAmpm;
boolean m_displayDates;
Hidden m_itemID;
TextField m_author, m_title;
MultipleSelect m_categories;
CMSDHTMLEditor m_body;
CMSDHTMLEditor m_desc;
Submit m_save;
Date m_startDate;
TextField m_startHour;
TextField m_startMinute;
SingleSelect m_startAmpm;
Date m_endDate;
TextField m_endHour;
TextField m_endMinute;
SingleSelect m_endAmpm;
boolean m_displayDates;
public WebpageCMSEditorForm(boolean displayDates) {
super("WebpageCMSEditorForm");
public WebpageCMSEditorForm(boolean displayDates) {
super("WebpageCMSEditorForm");
m_displayDates = displayDates;
m_displayDates = displayDates;
m_title = new TextField(new StringParameter("title"));
m_title.setSize(35);
add(new Label("Title:"), RIGHT | TOP);
add(m_title);
m_title = new TextField(new StringParameter("title"));
m_title.setSize(35);
add(new Label("Title:"), RIGHT | TOP);
add(m_title);
m_author = new TextField(Webpage.AUTHOR);
add(new Label(new AuthorLabelPrinter()), RIGHT | TOP);
add(m_author);
m_author = new TextField(Webpage.AUTHOR);
add(new Label(new AuthorLabelPrinter()), RIGHT | TOP);
add(m_author);
m_desc = new CMSDHTMLEditor("desc");//CMSDHTMLEditor.m_configWithoutToolbar
m_desc.setRows(10);
m_desc.setCols(80);
m_desc = new CMSDHTMLEditor("desc");//CMSDHTMLEditor.m_configWithoutToolbar
m_desc.setRows(10);
m_desc.setCols(80);
add(new Label("Lead:", false), RIGHT | TOP);//<br /><font size=-1>(this field is currently not displayed on the website)</font>
add(m_desc);
add(new Label("Lead:", false), RIGHT | TOP);//<br /><font size=-1>(this field is currently not displayed on the website)</font>
add(m_desc);
add(new Label("Location:"), RIGHT | TOP);
m_categories = new MultipleSelect("categories");
m_categories.setSize(5);
add(m_categories);
add(new Label("Location:"), RIGHT | TOP);
m_categories = new MultipleSelect("categories");
m_categories.setSize(5);
add(m_categories);
add(new Label("Body:"), RIGHT | TOP);
StringParameter bodyParam = new StringParameter(Webpage.BODY);
m_body = new CMSDHTMLEditor(bodyParam);
m_body.setCols(80);
m_body.setRows(20);
add(m_body);
add(new Label("Body:"), RIGHT | TOP);
StringParameter bodyParam = new StringParameter(Webpage.BODY);
m_body = new CMSDHTMLEditor(bodyParam);
m_body.setCols(80);
m_body.setRows(20);
add(m_body);
if (displayDates) {
add(new Label("Start date:"), RIGHT | TOP);
m_startDate = new Date(new DateParameter("start_date") {
protected final Calendar getCalendar(final HttpServletRequest sreq) {
final Calendar cal = super.getCalendar(sreq);
cal.setLenient(false);
return cal;
}
});
add(m_startDate);
if (displayDates) {
add(new Label("Start date:"), RIGHT | TOP);
m_startDate = new Date(new DateParameter("start_date") {
protected final Calendar getCalendar(final HttpServletRequest sreq) {
final Calendar cal = super.getCalendar(sreq);
cal.setLenient(false);
return cal;
}
});
add(m_startDate);
add(new Label("Start time:"), RIGHT | TOP);
BoxPanel startTime = new BoxPanel(BoxPanel.HORIZONTAL);
m_startHour = new TextField(new IntegerParameter("start_hour"));
m_startHour.setSize(3);
startTime.add(m_startHour);
m_startMinute = new TextField(new IntegerParameter("start_minute"));
m_startMinute.setSize(3);
startTime.add(m_startMinute);
m_startAmpm = new SingleSelect(new IntegerParameter("start_ampm"));
m_startAmpm.addOption(new Option("0", "am"));
m_startAmpm.addOption(new Option("1", "pm"));
startTime.add(m_startAmpm);
startTime.add(new Label(new TimeZonePrinter()));
add(startTime);
add(new Label("Start time:"), RIGHT | TOP);
BoxPanel startTime = new BoxPanel(BoxPanel.HORIZONTAL);
m_startHour = new TextField(new IntegerParameter("start_hour"));
m_startHour.setSize(3);
startTime.add(m_startHour);
m_startMinute = new TextField(new IntegerParameter("start_minute"));
m_startMinute.setSize(3);
startTime.add(m_startMinute);
m_startAmpm = new SingleSelect(new IntegerParameter("start_ampm"));
m_startAmpm.addOption(new Option("0", "am"));
m_startAmpm.addOption(new Option("1", "pm"));
startTime.add(m_startAmpm);
startTime.add(new Label(new TimeZonePrinter()));
add(startTime);
add(new Label("End date:"), RIGHT | TOP);
m_endDate = new Date(new DateParameter("end_date") {
protected final Calendar getCalendar(final HttpServletRequest sreq) {
final Calendar cal = super.getCalendar(sreq);
cal.setLenient(false);
return cal;
}
});
add(m_endDate);
add(new Label("End date:"), RIGHT | TOP);
m_endDate = new Date(new DateParameter("end_date") {
protected final Calendar getCalendar(final HttpServletRequest sreq) {
final Calendar cal = super.getCalendar(sreq);
cal.setLenient(false);
return cal;
}
});
add(m_endDate);
add(new Label("End time:"), RIGHT | TOP);
BoxPanel endTime = new BoxPanel(BoxPanel.HORIZONTAL);
m_endHour = new TextField(new IntegerParameter("end_hour"));
m_endHour.setSize(3);
endTime.add(m_endHour);
m_endMinute = new TextField(new IntegerParameter("end_minute"));
m_endMinute.setSize(3);
endTime.add(m_endMinute);
m_endAmpm = new SingleSelect(new IntegerParameter("end_ampm"));
m_endAmpm.addOption(new Option("0", "am"));
m_endAmpm.addOption(new Option("1", "pm"));
endTime.add(m_endAmpm);
endTime.add(new Label(new TimeZonePrinter()));
add(endTime);
}
add(new Label("End time:"), RIGHT | TOP);
BoxPanel endTime = new BoxPanel(BoxPanel.HORIZONTAL);
m_endHour = new TextField(new IntegerParameter("end_hour"));
m_endHour.setSize(3);
endTime.add(m_endHour);
m_endMinute = new TextField(new IntegerParameter("end_minute"));
m_endMinute.setSize(3);
endTime.add(m_endMinute);
m_endAmpm = new SingleSelect(new IntegerParameter("end_ampm"));
m_endAmpm.addOption(new Option("0", "am"));
m_endAmpm.addOption(new Option("1", "pm"));
endTime.add(m_endAmpm);
endTime.add(new Label(new TimeZonePrinter()));
add(endTime);
}
m_itemID = new Hidden(Webpage.ID);
add(m_itemID);
m_itemID = new Hidden(Webpage.ID);
add(m_itemID);
SimpleContainer buttons = new SimpleContainer();
m_save = new Submit("Save");
buttons.add(m_save);
buttons.add(new Label(""));
buttons.add(new Submit("Cancel"));
SimpleContainer buttons = new SimpleContainer();
m_save = new Submit("Save");
buttons.add(m_save);
buttons.add(new Label(""));
buttons.add(new Submit("Cancel"));
add(new Label(""));
add(buttons);
add(new Label(""));
add(buttons);
addInitListener(this);
addValidationListener(this);
addProcessListener(this);
}
addInitListener(this);
addValidationListener(this);
addProcessListener(this);
}
public void init(FormSectionEvent e) throws FormProcessException {
s_log.debug("init");
PageState state = e.getPageState();
HttpServletRequest request = state.getRequest();
// ContentSection section = ContentSectionDispatcher.getContentSection(request);
public void init(FormSectionEvent e) throws FormProcessException {
s_log.debug("init");
PageState state = e.getPageState();
HttpServletRequest request = state.getRequest();
// ContentSection section = ContentSectionDispatcher.getContentSection(request);
ContentSection section = ContentSectionServlet.getContentSection(request);
Webpage webpage = null;
try {
BigDecimal id = new BigDecimal(request.getParameter(Webpage.ID));
webpage = new Webpage(id);
if (!webpage.getContentSection().equals(section)) {
s_log.error("content section doesn't match! create new webpage entity.");
webpage = null;
}
}
catch (Exception ex) {
}
Webpage webpage = null;
try {
BigDecimal id = new BigDecimal(request.getParameter(Webpage.ID));
webpage = new Webpage(id);
if (!webpage.getContentSection().equals(section)) {
s_log.error("content section doesn't match! create new webpage entity.");
webpage = null;
}
} catch (Exception ex) {
}
m_categories.setPrintListener(new CategoriesPrintListener(section));
m_categories.setPrintListener(new CategoriesPrintListener(section));
if (webpage != null) {
m_itemID.setValue(state, webpage.getID().toString());
m_author.setValue(state, webpage.getAuthor());
m_title.setValue(state, webpage.getTitle());
m_desc.setValue(state, webpage.getDescription());
m_body.setValue(state, webpage.getBody());
if (webpage != null) {
m_itemID.setValue(state, webpage.getID().toString());
m_author.setValue(state, webpage.getAuthor());
m_title.setValue(state, webpage.getTitle());
m_desc.setValue(state, webpage.getDescription());
m_body.setValue(state, webpage.getBody());
ArrayList assignedCats = new ArrayList();
CategoryCollection cc = webpage.getCategoryCollection();
while (cc.next()) {
String catID = cc.getCategory().getID().toString();
assignedCats.add(catID);
}
m_categories.setValue(state, assignedCats.toArray());
}
else {
m_categories.setValue(state, new String[]{request.getParameter("categoryID")});
if (m_displayDates) {
final java.util.Date start = new java.util.Date(System.currentTimeMillis());
m_startDate.setValue(state, start);
ArrayList assignedCats = new ArrayList();
CategoryCollection cc = webpage.getCategoryCollection();
while (cc.next()) {
String catID = cc.getCategory().getID().toString();
assignedCats.add(catID);
}
m_categories.setValue(state, assignedCats.toArray());
} else {
m_categories.setValue(state, new String[]{request.getParameter("categoryID")});
if (m_displayDates) {
final java.util.Date start = new java.util.Date(System.currentTimeMillis());
m_startDate.setValue(state, start);
final Calendar calendar = Calendar.getInstance();
calendar.setTime(start);
final Calendar calendar = Calendar.getInstance();
calendar.setTime(start);
// If the hour is 12, then Calendar.get(Calendar.HOUR)
// returns 0 (from the 24 hour time - 12). We want it to
// return 12.
if (calendar.get(Calendar.HOUR) == 0) {
m_startHour.setValue(state, new Integer(12));
}
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 {
m_startMinute.setValue(state, min.toString());
}
m_startAmpm.setValue(state, new Integer(calendar.get(Calendar.AM_PM)));
}
}
}
// returns 0 (from the 24 hour time - 12). We want it to
// return 12.
if (calendar.get(Calendar.HOUR) == 0) {
m_startHour.setValue(state, new Integer(12));
} 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 {
m_startMinute.setValue(state, min.toString());
}
m_startAmpm.setValue(state, new Integer(calendar.get(Calendar.AM_PM)));
}
}
}
public void validate(FormSectionEvent e) throws FormProcessException {
s_log.debug("validate");
PageState state = e.getPageState();
boolean valid = true;
if (m_save.isSelected(state)) {
String title = (String) m_title.getValue(state);
if (title == null || title.length() == 0) {
m_title.addError("This parameter is required");
valid = false;
}
if (title != null && (title.length() < 1 || title.length() > 200)) {
m_title.addError("This parameter is not between 1 and 200 characters long");
valid = false;
}
String desc = (String) m_desc.getValue(state);
if (desc != null && (desc.length() < 1 || desc.length() > 4000)) {
m_desc.addError("This parameter is not between 1 and 4000 characters long");
valid = false;
}
if (m_displayDates) {
Integer startHour = (Integer) m_startHour.getValue(state);
if (startHour != null && (startHour.intValue() < 1 || startHour.intValue() > 12)) {
m_startHour.addError("This parameter is not between 1 and 12");
valid = false;
}
Integer startMin = (Integer) m_startMinute.getValue(state);
if (startMin != null && (startMin.intValue() < 0 || startMin.intValue() > 59)) {
m_startMinute.addError("This parameter is not between 0 and 59");
valid = false;
}
Integer endHour = (Integer) m_endHour.getValue(state);
if (endHour != null && (endHour.intValue() < 1 || endHour.intValue() > 12)) {
m_endHour.addError("This parameter is not between 1 and 12");
valid = false;
}
Integer endMin = (Integer) m_endMinute.getValue(state);
if (endMin != null && (endMin.intValue() < 0 || endMin.intValue() > 59)) {
m_endMinute.addError("This parameter is not between 0 and 59");
valid = false;
}
}
}
if (! valid) {
throw new FormProcessException("There is an error on the form");
}
}
public void validate(FormSectionEvent e) throws FormProcessException {
s_log.debug("validate");
PageState state = e.getPageState();
boolean valid = true;
if (m_save.isSelected(state)) {
String title = (String) m_title.getValue(state);
if (title == null || title.length() == 0) {
m_title.addError("This parameter is required");
valid = false;
}
if (title != null && (title.length() < 1 || title.length() > 200)) {
m_title.addError("This parameter is not between 1 and 200 characters long");
valid = false;
}
String desc = (String) m_desc.getValue(state);
if (desc != null && (desc.length() < 1 || desc.length() > 4000)) {
m_desc.addError("This parameter is not between 1 and 4000 characters long");
valid = false;
}
if (m_displayDates) {
Integer startHour = (Integer) m_startHour.getValue(state);
if (startHour != null && (startHour.intValue() < 1 || startHour.intValue() > 12)) {
m_startHour.addError("This parameter is not between 1 and 12");
valid = false;
}
Integer startMin = (Integer) m_startMinute.getValue(state);
if (startMin != null && (startMin.intValue() < 0 || startMin.intValue() > 59)) {
m_startMinute.addError("This parameter is not between 0 and 59");
valid = false;
}
Integer endHour = (Integer) m_endHour.getValue(state);
if (endHour != null && (endHour.intValue() < 1 || endHour.intValue() > 12)) {
m_endHour.addError("This parameter is not between 1 and 12");
valid = false;
}
Integer endMin = (Integer) m_endMinute.getValue(state);
if (endMin != null && (endMin.intValue() < 0 || endMin.intValue() > 59)) {
m_endMinute.addError("This parameter is not between 0 and 59");
valid = false;
}
}
}
if (!valid) {
throw new FormProcessException("There is an error on the form");
}
}
public void process(FormSectionEvent e) throws FormProcessException {
s_log.debug("process");
PageState state = e.getPageState();
HttpServletRequest request = state.getRequest();
// ContentSection section = ContentSectionDispatcher.getContentSection(request);
public void process(FormSectionEvent e) throws FormProcessException {
s_log.debug("process");
PageState state = e.getPageState();
HttpServletRequest request = state.getRequest();
// ContentSection section = ContentSectionDispatcher.getContentSection(request);
ContentSection section = ContentSectionServlet.getContentSection(request);
if (m_save.isSelected(state)) {
Webpage webpage = null;
if (m_save.isSelected(state)) {
Webpage webpage = null;
boolean commitTransaction = false;
boolean isMyTransaction = false;
TransactionContext txn = null;
try {
Session session = SessionManager.getSession();
txn = session.getTransactionContext();
if (!txn.inTxn()) {
txn.beginTxn();
isMyTransaction = true;
}
try {
String idTxt = (String) m_itemID.getValue(state);
if (idTxt != null && idTxt.length() > 0) {
BigDecimal id = new BigDecimal(idTxt);
webpage = new Webpage(id);
}
}
catch (Exception ex) {
throw new FormProcessException(ex);
}
boolean commitTransaction = false;
boolean isMyTransaction = false;
TransactionContext txn = null;
try {
Session session = SessionManager.getSession();
txn = session.getTransactionContext();
if (!txn.inTxn()) {
txn.beginTxn();
isMyTransaction = true;
}
try {
String idTxt = (String) m_itemID.getValue(state);
if (idTxt != null && idTxt.length() > 0) {
BigDecimal id = new BigDecimal(idTxt);
webpage = new Webpage(id);
}
} catch (Exception ex) {
throw new FormProcessException(ex);
}
if (section == null) {
throw new FormProcessException("ContentSection is null");
}
SecurityManager sm = new SecurityManager(section);
User user = Web.getWebContext().getUser();
if (section == null) {
throw new FormProcessException("ContentSection is null");
}
SecurityManager sm = new SecurityManager(section);
User user = Web.getWebContext().getUser();
if (webpage != null) {
if ( !sm.canAccess(user, SecurityConstants.EDIT_ITEM, webpage ) ) {
throw new FormProcessException("Insufficient permissions");
}
if (!webpage.getContentSection().equals(section)) {
throw new FormProcessException("content section doesn't match!");
}
webpage.setTitle((String) m_title.getValue(state));
webpage.setName("webpage" + webpage.getID());
webpage.setBody((String) m_body.getValue(state));
webpage.setAuthor((String) m_author.getValue(state));
webpage.setCategories((String[]) m_categories.getValue(state));
webpage.setDescription((String) m_desc.getValue(state));
webpage.save();
}
else {
if ( !sm.canAccess(user, SecurityConstants.NEW_ITEM ) ) {
throw new FormProcessException("Insufficient permissions");
}
webpage = new Webpage();
webpage.setLanguage("en");
webpage.setName("webpage" + webpage.getID());
webpage.setTitle((String) m_title.getValue(state));
webpage.setBody((String) m_body.getValue(state));
webpage.setAuthor((String) m_author.getValue(state));
webpage.setDescription((String) m_desc.getValue(state));
webpage.save();
if (webpage != null) {
if (!sm.canAccess(user, SecurityConstants.EDIT_ITEM, webpage)) {
throw new FormProcessException("Insufficient permissions");
}
if (!webpage.getContentSection().equals(section)) {
throw new FormProcessException("content section doesn't match!");
}
webpage.setTitle((String) m_title.getValue(state));
webpage.setName("webpage" + webpage.getID());
webpage.setBody((String) m_body.getValue(state));
webpage.setAuthor((String) m_author.getValue(state));
webpage.setCategories((String[]) m_categories.getValue(state));
webpage.setDescription((String) m_desc.getValue(state));
webpage.save();
} else {
if (!sm.canAccess(user, SecurityConstants.NEW_ITEM)) {
throw new FormProcessException("Insufficient permissions");
}
webpage = new Webpage();
webpage.setLanguage("en");
webpage.setName("webpage" + webpage.getID());
webpage.setTitle((String) m_title.getValue(state));
webpage.setBody((String) m_body.getValue(state));
webpage.setAuthor((String) m_author.getValue(state));
webpage.setDescription((String) m_desc.getValue(state));
webpage.save();
ContentBundle bundle = new ContentBundle(webpage);
bundle.setContentSection(section);
bundle.setParent(section.getRootFolder());
webpage.setCategories((String[]) m_categories.getValue(state));
ContentBundle bundle = new ContentBundle(webpage);
bundle.setContentSection(section);
bundle.setParent(section.getRootFolder());
webpage.setCategories((String[]) m_categories.getValue(state));
// get lifecycleDefinition
LifecycleDefinitionCollection lfColl = null;
LifecycleDefinition lifecycleDefinition = null;
try {
lfColl = section.getLifecycleDefinitions();
if (lfColl.next()) {
lifecycleDefinition = lfColl.getLifecycleDefinition();
}
}
finally {
if (lfColl != null) {
lfColl.close();
}
}
// get lifecycleDefinition
LifecycleDefinitionCollection lfColl = null;
LifecycleDefinition lifecycleDefinition = null;
try {
lfColl = section.getLifecycleDefinitions();
if (lfColl.next()) {
lifecycleDefinition = lfColl.getLifecycleDefinition();
}
} finally {
if (lfColl != null) {
lfColl.close();
}
}
// set workflow
TaskCollection taskColl = null;
try {
taskColl = section.getWorkflowTemplates();
if (taskColl.next()) {
Task task = taskColl.getTask();
final WorkflowTemplate wfTemp = new WorkflowTemplate(task.getID());
final Workflow flow = wfTemp.instantiateNewWorkflow();
flow.setObjectID(webpage.getID());
flow.start(Web.getWebContext().getUser());
flow.save();
}
}
finally {
if (taskColl != null) {
taskColl.close();
}
}
// set workflow
TaskCollection taskColl = null;
try {
taskColl = section.getWorkflowTemplates();
if (taskColl.next()) {
Task task = taskColl.getTask();
final WorkflowTemplate wfTemp = new WorkflowTemplate(task.getID());
final Workflow flow = wfTemp.instantiateNewWorkflow();
flow.setObjectID(webpage.getID());
flow.start(Web.getWebContext().getUser());
flow.save();
}
} finally {
if (taskColl != null) {
taskColl.close();
}
}
// finish all task
Workflow workflow = Workflow.getObjectWorkflow(webpage);
// finish all task
Workflow workflow = Workflow.getObjectWorkflow(webpage);
Engine engine = Engine.getInstance();
Assert.exists(engine, Engine.class);
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) {
throw new FormProcessException(ex);
}
}
Engine engine = Engine.getInstance();
Assert.exists(engine, Engine.class);
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) {
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) {
if (m_displayDates) {
final Integer startHour = (Integer) m_startHour.getValue(state);
Integer startMinute = (Integer) m_startMinute.getValue(state);
if (startMinute == null) {
startMinute = new Integer(0);
}
final Integer startAmpm = (Integer) m_startAmpm.getValue(state);
final Integer endHour = (Integer) m_endHour.getValue(state);
Integer endMinute = (Integer) m_endMinute.getValue(state);
if (endMinute == null) {
endMinute = new Integer(0);
}
final Integer endAmpm = (Integer) m_endAmpm.getValue(state);
// publish
if (lifecycleDefinition != null) {
if (m_displayDates) {
final Integer startHour = (Integer) m_startHour.getValue(state);
Integer startMinute = (Integer) m_startMinute.getValue(state);
if (startMinute == null) {
startMinute = new Integer(0);
}
final Integer startAmpm = (Integer) m_startAmpm.getValue(state);
final Integer endHour = (Integer) m_endHour.getValue(state);
Integer endMinute = (Integer) m_endMinute.getValue(state);
if (endMinute == null) {
endMinute = new Integer(0);
}
final Integer endAmpm = (Integer) m_endAmpm.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, startHour.intValue());
}
else {
if (startAmpm.intValue() == 0) {
start.set(Calendar.HOUR_OF_DAY, 0);
start.set(Calendar.HOUR, 0);
}
else {
start.set(Calendar.HOUR_OF_DAY, 12);
start.set(Calendar.HOUR, 0);
}
}
startDate = start.getTime();
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, startHour.intValue());
} else {
if (startAmpm.intValue() == 0) {
start.set(Calendar.HOUR_OF_DAY, 0);
start.set(Calendar.HOUR, 0);
} else {
start.set(Calendar.HOUR_OF_DAY, 12);
start.set(Calendar.HOUR, 0);
}
}
startDate = start.getTime();
java.util.Date endDate = (java.util.Date) m_endDate.getValue(state);
if (endDate != null) {
final Calendar end = Calendar.getInstance();
end.setTime(endDate);
end.set(Calendar.AM_PM, endAmpm.intValue());
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, endHour.intValue());
}
else {
if (endAmpm.intValue() == 0) {
end.set(Calendar.HOUR_OF_DAY, 0);
end.set(Calendar.HOUR, 0);
}
else {
end.set(Calendar.HOUR_OF_DAY, 12);
end.set(Calendar.HOUR, 0);
}
}
endDate = end.getTime();
}
java.util.Date endDate = (java.util.Date) m_endDate.getValue(state);
if (endDate != null) {
final Calendar end = Calendar.getInstance();
end.setTime(endDate);
end.set(Calendar.AM_PM, endAmpm.intValue());
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, endHour.intValue());
} else {
if (endAmpm.intValue() == 0) {
end.set(Calendar.HOUR_OF_DAY, 0);
end.set(Calendar.HOUR, 0);
} else {
end.set(Calendar.HOUR_OF_DAY, 12);
end.set(Calendar.HOUR, 0);
}
}
endDate = end.getTime();
}
webpage.publish(lifecycleDefinition, startDate);
webpage.publish(lifecycleDefinition, startDate);
if (endDate != null) {
final Lifecycle lifecycle = webpage.getLifecycle();
if (endDate != null) {
final Lifecycle lifecycle = webpage.getLifecycle();
// update individual phases
final PhaseCollection phases = lifecycle.getPhases();
// update individual phases
final PhaseCollection phases = lifecycle.getPhases();
while (phases.next()) {
final Phase phase = phases.getPhase();
java.util.Date thisEnd = phase.getEndDate();
if (thisEnd == null || thisEnd.compareTo(endDate) > 0) {
phase.setEndDate(endDate);
phase.save();
}
}
}
}
else {
webpage.publish(lifecycleDefinition, new java.util.Date());
}
while (phases.next()) {
final Phase phase = phases.getPhase();
java.util.Date thisEnd = phase.getEndDate();
if (thisEnd == null || thisEnd.compareTo(endDate) > 0) {
phase.setEndDate(endDate);
phase.save();
}
}
}
} else {
webpage.publish(lifecycleDefinition, new java.util.Date());
}
// Force the lifecycle scheduler to run to avoid any
// scheduler delay for items that should be published
// immediately.
webpage.getLifecycle().start();
// scheduler delay for items that should be published
// immediately.
webpage.getLifecycle().start();
webpage.save();
}
}
commitTransaction = true;
}
finally {
if (txn != null && isMyTransaction) {
if (commitTransaction) {
txn.commitTxn();
}
else {
txn.abortTxn();
}
}
}
}
webpage.save();
}
}
commitTransaction = true;
} finally {
if (txn != null && isMyTransaction) {
if (commitTransaction) {
txn.commitTxn();
} else {
txn.abortTxn();
}
}
}
}
try {
DispatcherHelper.sendRedirect(request, state.getResponse(), section.getPath());
}
catch (IOException ex) {
throw new FormProcessException(ex);
}
}
try {
DispatcherHelper.sendRedirect(request, state.getResponse(), section.getPath());
} 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();
final Calendar mStart = Calendar.getInstance();
java.util.Date st = (java.util.Date) m_startDate.getValue(state);
public class TimeZonePrinter implements PrintListener {
if (st != null) {
mStart.setTime((java.util.Date) m_startDate.getValue(state));
}
public void prepare(PrintEvent e) {
final Label target = (Label) e.getTarget();
final PageState state = e.getPageState();
final Calendar mStart = Calendar.getInstance();
java.util.Date st = (java.util.Date) m_startDate.getValue(state);
final String zone = mStart.getTimeZone().getDisplayName(true, TimeZone.SHORT);
if (st != null) {
mStart.setTime((java.util.Date) m_startDate.getValue(state));
}
target.setLabel(zone);
}
}
}
final String zone = mStart.getTimeZone().getDisplayName(true, TimeZone.SHORT);
target.setLabel(zone);
}
}
}
}