Zwei Fehlerkorrekturen:

- AuthoringKitWizard erlaubt das überschreiben von AuthoringSteps. Dabei wurde bisher aber nur auf das gleiche Label 
  geprüft, aber nicht auf den gleichen Typ.
- ItemSearchFolderBrowser hat für die Einschränkung auf einen bestimmten ContentTyp nur die direkten Nachfahren 
  berücksichtig, aber nicht die weiteren, eventuell vorhandenen Ebenen.


git-svn-id: https://svn.libreccm.org/ccm/trunk@1254 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2011-11-14 15:04:09 +00:00
parent 4354fee731
commit 299dc8d746
2 changed files with 258 additions and 181 deletions

View File

@ -69,8 +69,8 @@ import java.util.StringTokenizer;
public class ItemSearchFolderBrowser extends Table { public class ItemSearchFolderBrowser extends Table {
private static final org.apache.log4j.Logger s_log = private static final org.apache.log4j.Logger s_log =
org.apache.log4j.Logger.getLogger(ItemSearchFolderBrowser.class); org.apache.log4j.Logger.
getLogger(ItemSearchFolderBrowser.class);
private static GlobalizedMessage[] s_headers = { private static GlobalizedMessage[] s_headers = {
globalize("cms.ui.folder.name"), globalize("cms.ui.folder.name"),
globalize("cms.ui.folder.title"), globalize("cms.ui.folder.title"),
@ -88,7 +88,8 @@ public class ItemSearchFolderBrowser extends Table {
FolderTableModelBuilder builder = new FolderTableModelBuilder(); FolderTableModelBuilder builder = new FolderTableModelBuilder();
setModelBuilder(builder); setModelBuilder(builder);
m_paginator = new Paginator(builder, ContentSection.getConfig().getFolderBrowseListSize()); m_paginator = new Paginator(builder, ContentSection.getConfig().
getFolderBrowseListSize());
m_currentFolder = currentFolder; m_currentFolder = currentFolder;
@ -155,7 +156,6 @@ public class ItemSearchFolderBrowser extends Table {
return new Integer((int) itemColl.size()); return new Integer((int) itemColl.size());
} }
}; };
private RequestLocal m_itemColl = new RequestLocal() { private RequestLocal m_itemColl = new RequestLocal() {
@Override @Override
@ -171,14 +171,16 @@ public class ItemSearchFolderBrowser extends Table {
}; };
public TableModel makeModel(Table t, PageState s) { public TableModel makeModel(Table t, PageState s) {
FolderSelectionModel sel = ((ItemSearchFolderBrowser) t).getFolderSelectionModel(); FolderSelectionModel sel = ((ItemSearchFolderBrowser) t).
getFolderSelectionModel();
Folder f = getCurrentFolder(s); Folder f = getCurrentFolder(s);
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
if (null == f) { if (null == f) {
s_log.debug("Selected folder is null"); s_log.debug("Selected folder is null");
} else { } else {
s_log.debug("Selected folder: " + f.getLabel() + " " + f.getOID().toString()); s_log.debug("Selected folder: " + f.getLabel() + " " + f.
getOID().toString());
} }
} }
@ -186,7 +188,8 @@ public class ItemSearchFolderBrowser extends Table {
return Table.EMPTY_MODEL; return Table.EMPTY_MODEL;
} else { } else {
t.getRowSelectionModel().clearSelection(s); t.getRowSelectionModel().clearSelection(s);
return new FolderTableModel((Folder.ItemCollection) m_itemColl.get(s)); return new FolderTableModel((Folder.ItemCollection) m_itemColl.
get(s));
} }
} }
@ -199,7 +202,8 @@ public class ItemSearchFolderBrowser extends Table {
} }
BigDecimal singleTypeID = BigDecimal singleTypeID =
(BigDecimal) state.getValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM)); (BigDecimal) state.getValue(new BigDecimalParameter(
ItemSearch.SINGLE_TYPE_PARAM));
if (singleTypeID != null) { if (singleTypeID != null) {
@ -210,19 +214,37 @@ public class ItemSearchFolderBrowser extends Table {
CompoundFilter or = ff.or(); CompoundFilter or = ff.or();
// The content type must be either of the requested type // The content type must be either of the requested type
or.addFilter(ff.equals(ContentItem.CONTENT_TYPE + "." + ContentType.ID, singleTypeID)); or.addFilter(ff.equals(ContentItem.CONTENT_TYPE + "."
+ ContentType.ID, singleTypeID));
// Or must be a sibling of the requested type // Or must be a sibling of the requested type
try { /*
* jensp 2011-11-14: The orginal code here was only traversing
* one level, but ContentType hierarchies may have several
* levels. Therefore, this code was replaced by method which is
* called recursivly until the type with no descendents is
* reached.
*/
createSiblingFilter(or, ff, singleTypeID);
/*try {
ContentType ct = new ContentType(singleTypeID); ContentType ct = new ContentType(singleTypeID);
StringTokenizer strTok = new StringTokenizer(ct.getDescendants(), "/"); StringTokenizer strTok = new StringTokenizer(ct.
getDescendants(), "/");
while (strTok.hasMoreElements()) { while (strTok.hasMoreElements()) {
or.addFilter(ff.equals(ContentItem.CONTENT_TYPE + "." + ContentType.ID, (String) strTok.nextElement())); or.addFilter(ff.equals(ContentItem.CONTENT_TYPE + "."
+ ContentType.ID,
(String) strTok.nextElement()));
} }
} catch (Exception ex) { } catch (Exception ex) {
// WTF? The selected content type does not exist in the table??? // WTF? The selected content type does not exist in the table???
} s_log.error(String.format(
"Something is very wrong here, the ContentType '%s' "
+ "seems not to exist. Ignoring for now, but please "
+ "make your checks.",
singleTypeID.toString()),
ex);
}*/
itemColl.addFilter(or); itemColl.addFilter(or);
@ -233,6 +255,38 @@ public class ItemSearchFolderBrowser extends Table {
return itemColl; return itemColl;
} }
private void createSiblingFilter(final CompoundFilter filter,
final FilterFactory filterFactory,
final BigDecimal typeId) {
final ContentType type = new ContentType(typeId);
if ((type.getDescendants() == null)
|| type.getDescendants().trim().isEmpty()) {
return;
} else {
final String[] descendantsIds = type.getDescendants().split("/");
for (String descendantId : descendantsIds) {
filter.addFilter(filterFactory.equals(String.format(
ContentItem.CONTENT_TYPE + "." + ContentType.ID),
descendantId));
createSiblingFilter(filter, filterFactory, descendantId);
}
}
}
private void createSiblingFilter(final CompoundFilter filter,
final FilterFactory filterFactory,
final String typeId) {
try {
final BigDecimal _typeId = new BigDecimal(typeId);
createSiblingFilter(filter, filterFactory, _typeId);
} catch (NumberFormatException ex) {
s_log.error(String.format("Failed to parse typeId '%s'.",
typeId),
ex);
}
}
public int getTotalSize(Paginator paginator, PageState state) { public int getTotalSize(Paginator paginator, PageState state) {
Integer size = (Integer) m_size.get(state); Integer size = (Integer) m_size.get(state);
@ -251,7 +305,8 @@ public class ItemSearchFolderBrowser extends Table {
int size = ((Integer) m_size.get(state)).intValue(); int size = ((Integer) m_size.get(state)).intValue();
return ItemSearchFolderBrowser.this.isVisible(state) return ItemSearchFolderBrowser.this.isVisible(state)
&& (size > ContentSection.getConfig().getFolderBrowseListSize()); && (size
> ContentSection.getConfig().getFolderBrowseListSize());
} }
} }
@ -272,7 +327,8 @@ public class ItemSearchFolderBrowser extends Table {
Folder.ItemCollection coll = (Folder.ItemCollection) value; Folder.ItemCollection coll = (Folder.ItemCollection) value;
String name = coll.getName(); String name = coll.getName();
if (coll.isFolder()) { if (coll.isFolder()) {
return super.getComponent(table, state, name, isSelected, key, row, column); return super.getComponent(table, state, name, isSelected, key,
row, column);
} else { } else {
ContentSection section = CMS.getContext().getContentSection(); ContentSection section = CMS.getContext().getContentSection();
BigDecimal id = (BigDecimal) key; BigDecimal id = (BigDecimal) key;
@ -289,12 +345,17 @@ public class ItemSearchFolderBrowser extends Table {
SimpleContainer container = new SimpleContainer(); SimpleContainer container = new SimpleContainer();
String widget = String widget =
(String) state.getValue(new StringParameter(ItemSearchPopup.WIDGET_PARAM)); (String) state.getValue(new StringParameter(
boolean useURL = "true".equals(state.getValue(new StringParameter(ItemSearchPopup.URL_PARAM))); ItemSearchPopup.WIDGET_PARAM));
boolean useURL =
"true".equals(state.getValue(new StringParameter(
ItemSearchPopup.URL_PARAM)));
String fillString = useURL String fillString = useURL
? ItemSearchPopup.getItemURL(state.getRequest(), ? ItemSearchPopup.getItemURL(state.
coll.getDomainObject().getOID()) getRequest(),
coll.
getDomainObject().getOID())
: id : id
+ " (" + name + ")"; + " (" + name + ")";
@ -326,9 +387,12 @@ public class ItemSearchFolderBrowser extends Table {
+ " window.opener.document." + " window.opener.document."
+ widget + ".value=\"" + fill + "\";\n"); + widget + ".value=\"" + fill + "\";\n");
// set protocol to 'other' in FCKEditor, else relative url prepended by http:// // set protocol to 'other' in FCKEditor, else relative url prepended by http://
if (Bebop.getConfig().getDHTMLEditor().equals(BebopConstants.BEBOP_FCKEDITOR)) { if (Bebop.getConfig().getDHTMLEditor().equals(
buffer.append(" if(window.opener.document.getElementById('cmbLinkProtocol')) {\n"); BebopConstants.BEBOP_FCKEDITOR)) {
buffer.append(" window.opener.document.getElementById('cmbLinkProtocol').value=\"\";\n"); buffer.append(
" if(window.opener.document.getElementById('cmbLinkProtocol')) {\n");
buffer.append(
" window.opener.document.getElementById('cmbLinkProtocol').value=\"\";\n");
buffer.append(" }\n"); buffer.append(" }\n");
} }
@ -373,7 +437,8 @@ public class ItemSearchFolderBrowser extends Table {
case TYPE: case TYPE:
return m_itemColl.getTypeLabel(); return m_itemColl.getTypeLabel();
default: default:
throw new IndexOutOfBoundsException("Column index " + columnIndex throw new IndexOutOfBoundsException("Column index "
+ columnIndex
+ " not in table model."); + " not in table model.");
} }
} }

View File

@ -91,24 +91,19 @@ import java.util.ArrayList;
public class AuthoringKitWizard extends LayoutPanel implements Resettable { public class AuthoringKitWizard extends LayoutPanel implements Resettable {
/** Private Logger instance for this class */ /** Private Logger instance for this class */
private static final Logger s_log = Logger.getLogger private static final Logger s_log = Logger.getLogger(
(AuthoringKitWizard.class); AuthoringKitWizard.class);
private static Class[] s_args = new Class[]{ private static Class[] s_args = new Class[]{
ItemSelectionModel.class, ItemSelectionModel.class,
AuthoringKitWizard.class AuthoringKitWizard.class
}; };
private static Class[] s_userDefinedArgs = new Class[]{ private static Class[] s_userDefinedArgs = new Class[]{
ItemSelectionModel.class, ItemSelectionModel.class,
AuthoringKitWizard.class, AuthoringKitWizard.class,
ContentType.class ContentType.class
}; };
private static final ArrayList s_assets = new ArrayList(); private static final ArrayList s_assets = new ArrayList();
private final Object[] m_vals; private final Object[] m_vals;
private final ContentType m_type; private final ContentType m_type;
private final AuthoringKit m_kit; private final AuthoringKit m_kit;
private final ItemSelectionModel m_sel; private final ItemSelectionModel m_sel;
@ -116,19 +111,16 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
private final AssignedTaskTable m_tasks; private final AssignedTaskTable m_tasks;
private final SequentialMap m_labels; private final SequentialMap m_labels;
private final List m_list; private final List m_list;
private String m_defaultKey; private String m_defaultKey;
private final GridPanel m_left; private final GridPanel m_left;
private final ModalPanel m_body; private final ModalPanel m_body;
private final SimpleContainer m_steps; private final SimpleContainer m_steps;
private final TaskFinishForm m_taskFinishForm; private final TaskFinishForm m_taskFinishForm;
/** /**
* The name of the state parameter that determines whether the * The name of the state parameter that determines whether the
* wizard is in item creation mode or item editing mode. * wizard is in item creation mode or item editing mode.
*/ */
public static final String IS_EDITING = "is_edit"; public static final String IS_EDITING = "is_edit";
/** /**
* The key for the item creation step. * The key for the item creation step.
*/ */
@ -147,8 +139,8 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
public AuthoringKitWizard(final ContentType type, public AuthoringKitWizard(final ContentType type,
final ItemSelectionModel model) { final ItemSelectionModel model) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Authoring kit wizard for type " + type + " " + s_log.debug("Authoring kit wizard for type " + type + " "
"undergoing creation"); + "undergoing creation");
} }
m_type = type; m_type = type;
@ -173,6 +165,7 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
m_list.setListData(m_labels); m_list.setListData(m_labels);
m_list.setCellRenderer(new ListCellRenderer() { m_list.setCellRenderer(new ListCellRenderer() {
public Component getComponent( public Component getComponent(
List list, List list,
PageState state, PageState state,
@ -205,9 +198,9 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
if (Assert.isEnabled()) { if (Assert.isEnabled()) {
Assert.isTrue(!steps.isEmpty(), Assert.isTrue(!steps.isEmpty(),
"The authoring kit for " + type.getID() + " " + "The authoring kit for " + type.getID() + " "
"(java class " + type.getClassName() + ") " + + "(java class " + type.getClassName() + ") "
"has no steps."); + "has no steps.");
} }
StepComponent panel = null; StepComponent panel = null;
@ -238,10 +231,10 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
m_steps.add(panel); m_steps.add(panel);
final Component comp; final Component comp;
if (str.equals("com.arsdigita.cms.ui.authoring." + if (str.equals("com.arsdigita.cms.ui.authoring."
"SecondaryPageEditDynamic") + "SecondaryPageEditDynamic")
|| str.equals("com.arsdigita.cms.ui.authoring." + || str.equals("com.arsdigita.cms.ui.authoring."
"PageEditDynamic")) { + "PageEditDynamic")) {
comp = instantiateUserDefinedStep(str, m_type); comp = instantiateUserDefinedStep(str, m_type);
} else { } else {
comp = instantiateStep(str); comp = instantiateStep(str);
@ -249,8 +242,8 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
panel.add(comp); panel.add(comp);
// XXX should be optional // XXX should be optional
if (comp instanceof AuthoringStepComponent) { if (comp instanceof AuthoringStepComponent) {
((AuthoringStepComponent)comp) ((AuthoringStepComponent) comp).addCompletionListener(
.addCompletionListener(new StepCompletionListener()); new StepCompletionListener());
} }
GlobalizedMessage gzLabel = null; GlobalizedMessage gzLabel = null;
@ -265,9 +258,10 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
gzLabel == null ? (Object) label : (Object) gzLabel); gzLabel == null ? (Object) label : (Object) gzLabel);
} }
ObjectType thisType = MetadataRoot.getMetadataRoot() ObjectType thisType = MetadataRoot.getMetadataRoot().getObjectType(type.
.getObjectType(type.getAssociatedObjectType()); getAssociatedObjectType());
Collection skipSteps = ContentSection.getConfig().getAssetStepsToSkip(type); Collection skipSteps = ContentSection.getConfig().getAssetStepsToSkip(
type);
Iterator it = skipSteps.iterator(); Iterator it = skipSteps.iterator();
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
while (it.hasNext()) { while (it.hasNext()) {
@ -295,8 +289,8 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
Component comp = instantiateStep(step.getName()); Component comp = instantiateStep(step.getName());
if (comp instanceof AuthoringStepComponent) { if (comp instanceof AuthoringStepComponent) {
((AuthoringStepComponent)comp) ((AuthoringStepComponent) comp).addCompletionListener(
.addCompletionListener(new StepCompletionListener()); new StepCompletionListener());
} }
panel.add(comp); panel.add(comp);
@ -306,14 +300,14 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
m_list.addChangeListener(new StepListener()); m_list.addChangeListener(new StepListener());
m_taskFinishForm = new TaskFinishForm m_taskFinishForm = new TaskFinishForm(new TaskSelectionRequestLocal());
(new TaskSelectionRequestLocal());
m_body.add(m_taskFinishForm); m_body.add(m_taskFinishForm);
m_body.connect(m_tasks, 2, m_taskFinishForm); m_body.connect(m_tasks, 2, m_taskFinishForm);
m_body.connect(m_taskFinishForm); m_body.connect(m_taskFinishForm);
m_taskFinishForm.addProcessListener(new FormProcessListener() { m_taskFinishForm.addProcessListener(new FormProcessListener() {
public final void process(final FormSectionEvent e) public final void process(final FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
final PageState state = e.getPageState(); final PageState state = e.getPageState();
@ -327,6 +321,7 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
* *
*/ */
private final class StepListener implements ChangeListener { private final class StepListener implements ChangeListener {
public final void stateChanged(final ChangeEvent e) { public final void stateChanged(final ChangeEvent e) {
final PageState state = e.getPageState(); final PageState state = e.getPageState();
final String key = m_list.getSelectedKey(state).toString(); final String key = m_list.getSelectedKey(state).toString();
@ -349,6 +344,7 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
* *
*/ */
private final class StepCompletionListener implements ActionListener { private final class StepCompletionListener implements ActionListener {
public final void actionPerformed(final ActionEvent e) { public final void actionPerformed(final ActionEvent e) {
final PageState state = e.getPageState(); final PageState state = e.getPageState();
if (ContentItemPage.isStreamlinedCreationActive(state)) { if (ContentItemPage.isStreamlinedCreationActive(state)) {
@ -361,8 +357,9 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
if (step.getStepKey().toString().equals(key)) { if (step.getStepKey().toString().equals(key)) {
Object nextStep = step.getNextStepKey(); Object nextStep = step.getNextStepKey();
if (nextStep != null) { if (nextStep != null) {
m_list.getSelectionModel() m_list.getSelectionModel().setSelectedKey(state,
.setSelectedKey(state, nextStep.toString()); nextStep.
toString());
} }
} }
} }
@ -387,6 +384,7 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
} }
page.addActionListener(new ActionListener() { page.addActionListener(new ActionListener() {
public final void actionPerformed(final ActionEvent e) { public final void actionPerformed(final ActionEvent e) {
final PageState state = e.getPageState(); final PageState state = e.getPageState();
@ -430,9 +428,21 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
Iterator assets = s_assets.iterator(); Iterator assets = s_assets.iterator();
while (assets.hasNext()) { while (assets.hasNext()) {
Object[] data = (Object[]) assets.next(); Object[] data = (Object[]) assets.next();
String thisObjectType = (String) data[0];
GlobalizedMessage thisLabel = (GlobalizedMessage) data[2]; GlobalizedMessage thisLabel = (GlobalizedMessage) data[2];
if (thisLabel.localize().equals(label.localize())) { /**
s_log.debug("registering authoring step with same label as previously registered step"); * jensp 2011-11-14: The code above was only testing for the same
* label, but not for the same object type. I don't think that
* this was indented since this made it impossible to attach the
* same step to different object types.
* The orginal line was
* if (thisLabel.localize().equals(label.localize())) {
*
*/
if ((thisObjectType.equals(baseObjectType))
&& (thisLabel.localize().equals(label.localize()))) {
s_log.debug(
"registering authoring step with same label as previously registered step");
s_assets.remove(data); s_assets.remove(data);
break; break;
} }
@ -477,8 +487,8 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
*/ */
protected Component instantiateStep(String name) { protected Component instantiateStep(String name) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Instantiating kit wizard '" + name + "' with " + s_log.debug("Instantiating kit wizard '" + name + "' with "
"arguments " + s_args); + "arguments " + s_args);
} }
Object[] vals; Object[] vals;
@ -494,9 +504,8 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
cause = e; cause = e;
} }
throw new UncheckedWrapperException( throw new UncheckedWrapperException(
"Failed to instantiate authoring kit component " + "Failed to instantiate authoring kit component " + m_kit.
m_kit.getCreateComponent() + ": " + e.getMessage(), cause getCreateComponent() + ": " + e.getMessage(), cause);
);
} }
} }
@ -516,7 +525,8 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
// Get the creation component // Get the creation component
Class createClass = Class.forName(name); Class createClass = Class.forName(name);
Constructor constr = createClass.getConstructor(s_userDefinedArgs); Constructor constr = createClass.getConstructor(s_userDefinedArgs);
Object [] userDefinedVals = new Object[]{m_sel, this, originatingType}; Object[] userDefinedVals =
new Object[]{m_sel, this, originatingType};
Component c = (Component) constr.newInstance(userDefinedVals); Component c = (Component) constr.newInstance(userDefinedVals);
return c; return c;
} catch (ClassNotFoundException cnfe) { } catch (ClassNotFoundException cnfe) {
@ -540,7 +550,6 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
// public static void redirectBack(PageState state) { // public static void redirectBack(PageState state) {
// ((ContentItemPage)state.getPage()).redirectBack(state); // ((ContentItemPage)state.getPage()).redirectBack(state);
// } // }
/** /**
* Reset the state of this wizard * Reset the state of this wizard
*/ */
@ -549,6 +558,7 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
} }
private final class StepComponent extends SimpleContainer { private final class StepComponent extends SimpleContainer {
private final Object m_key; private final Object m_key;
private Object m_nextKey; private Object m_nextKey;
@ -563,15 +573,17 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
public Object getNextStepKey() { public Object getNextStepKey() {
return m_nextKey; return m_nextKey;
} }
public void setNextStepKey(Object nextKey) { public void setNextStepKey(Object nextKey) {
m_nextKey = nextKey; m_nextKey = nextKey;
} }
} }
private final class TaskSelectionRequestLocal extends TaskRequestLocal { private final class TaskSelectionRequestLocal extends TaskRequestLocal {
protected final Object initialValue(final PageState state) { protected final Object initialValue(final PageState state) {
final String id = m_tasks.getRowSelectionModel().getSelectedKey final String id = m_tasks.getRowSelectionModel().getSelectedKey(
(state).toString(); state).toString();
return new CMSTask(new BigDecimal(id)); return new CMSTask(new BigDecimal(id));
} }