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
@ -164,21 +164,23 @@ public class ItemSearchFolderBrowser extends Table {
itemColl.addOrder("item.name"); itemColl.addOrder("item.name");
itemColl.setRange(new Integer(m_paginator.getFirst(state)), itemColl.setRange(new Integer(m_paginator.getFirst(state)),
new Integer(m_paginator.getLast(state) + 1)); new Integer(m_paginator.getLast(state) + 1));
return itemColl; return itemColl;
} }
}; };
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,29 +214,79 @@ 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 { /*
ContentType ct = new ContentType(singleTypeID); * jensp 2011-11-14: The orginal code here was only traversing
* one level, but ContentType hierarchies may have several
StringTokenizer strTok = new StringTokenizer(ct.getDescendants(), "/"); * levels. Therefore, this code was replaced by method which is
while (strTok.hasMoreElements()) { * called recursivly until the type with no descendents is
or.addFilter(ff.equals(ContentItem.CONTENT_TYPE + "." + ContentType.ID, (String) strTok.nextElement())); * reached.
} */
createSiblingFilter(or, ff, singleTypeID);
/*try {
ContentType ct = new ContentType(singleTypeID);
StringTokenizer strTok = new StringTokenizer(ct.
getDescendants(), "/");
while (strTok.hasMoreElements()) {
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);
} }
itemColl.addOrder("isFolder desc"); itemColl.addOrder("isFolder desc");
itemColl.addOrder("lower(item." + ContentItem.NAME + ") "); itemColl.addOrder("lower(item." + ContentItem.NAME + ") ");
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());
} }
} }
@ -267,12 +322,13 @@ public class ItemSearchFolderBrowser extends Table {
@Override @Override
public Component getComponent(Table table, PageState state, public Component getComponent(Table table, PageState state,
Object value, boolean isSelected, Object value, boolean isSelected,
Object key, int row, int column) { Object key, int row, int column) {
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,18 +345,23 @@ 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(),
: id coll.
+ " (" + name + ")"; getDomainObject().getOID())
: id
+ " (" + name + ")";
Label js = new Label(generateJSLabel(id, widget, Label js = new Label(generateJSLabel(id, widget,
fillString), fillString),
false); false);
container.add(js); container.add(js);
String url = "#"; String url = "#";
@ -319,24 +380,27 @@ public class ItemSearchFolderBrowser extends Table {
private String generateJSLabel(BigDecimal id, String widget, String fill) { private String generateJSLabel(BigDecimal id, String widget, String fill) {
StringBuilder buffer = new StringBuilder(); StringBuilder buffer = new StringBuilder();
buffer.append(" <script language=javascript> " buffer.append(" <script language=javascript> "
+ " <!-- \n" + " <!-- \n"
+ " function fillItem" + " function fillItem"
+ id + id
+ "() { \n" + "() { \n"
+ " 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");
} }
buffer.append(" self.close(); \n" buffer.append(" self.close(); \n"
+ " return false; \n" + " return false; \n"
+ " } \n" + " } \n"
+ " --> \n" + " --> \n"
+ " </script> "); + " </script> ");
return buffer.toString(); return buffer.toString();
} }
@ -360,7 +424,7 @@ public class ItemSearchFolderBrowser extends Table {
return 3; return 3;
} }
public boolean nextRow() { public boolean nextRow() {
return m_itemColl != null ? m_itemColl.next() : false; return m_itemColl != null ? m_itemColl.next() : false;
} }
@ -373,15 +437,16 @@ 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 "
+ " not in table model."); + columnIndex
+ " not in table model.");
} }
} }
public Object getKeyAt(int columnIndex) { public Object getKeyAt(int columnIndex) {
// Mark folders by using their negative ID (dirty, dirty) // Mark folders by using their negative ID (dirty, dirty)
return (m_itemColl.isFolder()) ? m_itemColl.getID().negate() return (m_itemColl.isFolder()) ? m_itemColl.getID().negate()
: m_itemColl.getID(); : m_itemColl.getID();
} }
} }

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,14 +139,14 @@ 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;
m_kit = type.getAuthoringKit(); m_kit = type.getAuthoringKit();
m_sel = model; m_sel = model;
m_vals = new Object[]{ m_sel, this }; m_vals = new Object[]{m_sel, this};
m_workflow = new ItemWorkflowRequestLocal(); m_workflow = new ItemWorkflowRequestLocal();
m_labels = new SequentialMap(); m_labels = new SequentialMap();
@ -173,26 +165,27 @@ 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(
List list, public Component getComponent(
PageState state, List list,
PageState state,
Object value, Object value,
String key, String key,
int index, int index,
boolean isSelected) { boolean isSelected) {
Label l = null; Label l = null;
if (value instanceof GlobalizedMessage) { if (value instanceof GlobalizedMessage) {
l = new Label((GlobalizedMessage)value); l = new Label((GlobalizedMessage) value);
} else { } else {
l = new Label((String)value); l = new Label((String) value);
}
if (isSelected) {
l.setFontWeight(Label.BOLD);
return l;
}
return new ControlLink(l);
} }
}); if (isSelected) {
l.setFontWeight(Label.BOLD);
return l;
}
return new ControlLink(l);
}
});
m_body = new ModalPanel(); m_body = new ModalPanel();
setBody(m_body); setBody(m_body);
@ -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;
@ -261,72 +254,74 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
gzLabel = new GlobalizedMessage(labelKey, labelBundle); gzLabel = new GlobalizedMessage(labelKey, labelBundle);
} }
} }
m_labels.put(key, m_labels.put(key,
gzLabel == null ? (Object)label : (Object)gzLabel); gzLabel == null ? (Object) label : (Object) gzLabel);
}
ObjectType thisType = MetadataRoot.getMetadataRoot().getObjectType(type.
getAssociatedObjectType());
Collection skipSteps = ContentSection.getConfig().getAssetStepsToSkip(
type);
Iterator it = skipSteps.iterator();
if (s_log.isDebugEnabled()) {
while (it.hasNext()) {
s_log.debug("skip step " + it.next());
}
} }
ObjectType thisType = MetadataRoot.getMetadataRoot()
.getObjectType(type.getAssociatedObjectType());
Collection skipSteps = ContentSection.getConfig().getAssetStepsToSkip(type);
Iterator it = skipSteps.iterator();
if (s_log.isDebugEnabled()) {
while (it.hasNext()) {
s_log.debug("skip step " + it.next());
}
}
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 baseObjectType = (String)data[0]; String baseObjectType = (String) data[0];
Class step = (Class)data[1]; Class step = (Class) data[1];
s_log.debug("possibly adding asset step " + step.getName()); s_log.debug("possibly adding asset step " + step.getName());
if (!skipSteps.contains(step.getName())) { if (!skipSteps.contains(step.getName())) {
GlobalizedMessage label = (GlobalizedMessage)data[2]; GlobalizedMessage label = (GlobalizedMessage) data[2];
if (!thisType.isSubtypeOf(baseObjectType)) { if (!thisType.isSubtypeOf(baseObjectType)) {
continue; continue;
} }
if (panel != null) { if (panel != null) {
panel.setNextStepKey(step); panel.setNextStepKey(step);
}
panel = new StepComponent(step);
m_steps.add(panel);
Component comp = instantiateStep(step.getName());
if (comp instanceof AuthoringStepComponent) {
((AuthoringStepComponent) comp).addCompletionListener(
new StepCompletionListener());
}
panel.add(comp);
m_labels.put(step, label);
} }
panel = new StepComponent(step);
m_steps.add(panel);
Component comp = instantiateStep(step.getName());
if (comp instanceof AuthoringStepComponent) {
((AuthoringStepComponent)comp)
.addCompletionListener(new StepCompletionListener());
}
panel.add(comp);
m_labels.put(step, label);
} }
}
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)
throws FormProcessException {
final PageState state = e.getPageState();
m_tasks.getRowSelectionModel().clearSelection(state); public final void process(final FormSectionEvent e)
} throws FormProcessException {
}); final PageState state = e.getPageState();
m_tasks.getRowSelectionModel().clearSelection(state);
}
});
} }
/** /**
* *
*/ */
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,20 +344,22 @@ 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)) {
final String key = m_list.getSelectedKey(state).toString(); final String key = m_list.getSelectedKey(state).toString();
final Iterator iter = m_steps.children(); final Iterator iter = m_steps.children();
while (iter.hasNext()) { while (iter.hasNext()) {
final StepComponent step = (StepComponent) iter.next(); final StepComponent step = (StepComponent) iter.next();
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,19 +384,20 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
} }
page.addActionListener(new ActionListener() { page.addActionListener(new ActionListener() {
public final void actionPerformed(final ActionEvent e) {
final PageState state = e.getPageState();
if (state.isVisibleOnPage(AuthoringKitWizard.this)) { public final void actionPerformed(final ActionEvent e) {
final SingleSelectionModel model = final PageState state = e.getPageState();
m_list.getSelectionModel();
if (!model.isSelected(state)) { if (state.isVisibleOnPage(AuthoringKitWizard.this)) {
model.setSelectedKey(state, m_defaultKey); final SingleSelectionModel model =
} m_list.getSelectionModel();
if (!model.isSelected(state)) {
model.setSelectedKey(state, m_defaultKey);
} }
} }
}); }
});
} }
/** /**
@ -415,29 +413,41 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
GlobalizedMessage label, GlobalizedMessage label,
GlobalizedMessage description, GlobalizedMessage description,
int sortKey) { int sortKey) {
// cg - allow registered steps to be overridden by registering a step with the same label // cg - allow registered steps to be overridden by registering a step with the same label
// this is a bit of a hack used specifically for creating a specialised version of image // this is a bit of a hack used specifically for creating a specialised version of image
// step. There is no straightforward way of preventing the original image step from being // step. There is no straightforward way of preventing the original image step from being
// registered, but I needed the image step to use a different step class if the specialised // registered, but I needed the image step to use a different step class if the specialised
// image step application was loaded. Solution is to ensure initialiser in new project // image step application was loaded. Solution is to ensure initialiser in new project
// runs after original ccm-ldn-image-step initializer and override the registered step here // runs after original ccm-ldn-image-step initializer and override the registered step here
s_log.debug( s_log.debug(
"registering asset step - label: " "registering asset step - label: "
+ label.localize() + label.localize()
+ " step class: " + " step class: "
+ step.getName()); + step.getName());
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();
GlobalizedMessage thisLabel = (GlobalizedMessage) data[2]; String thisObjectType = (String) data[0];
if (thisLabel.localize().equals(label.localize())) { GlobalizedMessage thisLabel = (GlobalizedMessage) data[2];
s_log.debug("registering authoring step with same label as previously registered step"); /**
s_assets.remove(data); * jensp 2011-11-14: The code above was only testing for the same
break; * 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.
s_assets.add(new Object[] {baseObjectType, step, label, description}); * 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);
break;
}
}
s_assets.add(new Object[]{baseObjectType, step, label, description});
} }
/** /**
@ -477,16 +487,16 @@ 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;
try { try {
// Get the creation component // Get the creation component
Class createClass = Class.forName(name); Class createClass = Class.forName(name);
Constructor constr = createClass.getConstructor(s_args); Constructor constr = createClass.getConstructor(s_args);
Component c = (Component)constr.newInstance(m_vals); Component c = (Component) constr.newInstance(m_vals);
return c; return c;
} catch (Exception e) { } catch (Exception e) {
Throwable cause = e.getCause(); // JDK1.4 Throwable cause = e.getCause(); // JDK1.4
@ -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);
);
} }
} }
@ -509,14 +518,15 @@ public class AuthoringKitWizard extends LayoutPanel implements Resettable {
* @param description The step description, which for dynamically generated * @param description The step description, which for dynamically generated
* steps will be the object type which originally defined the step. * steps will be the object type which originally defined the step.
*/ */
protected Component instantiateUserDefinedStep(String name, protected Component instantiateUserDefinedStep(String name,
ContentType originatingType) { ContentType originatingType) {
Object [] vals; Object[] vals;
try { try {
// 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));
} }