From fc69327e923a21d17eab5d4db8701e6475e9d10f Mon Sep 17 00:00:00 2001 From: jensp Date: Sat, 14 Jul 2012 16:56:33 +0000 Subject: [PATCH] ItemSearchWidget aktueller Stand git-svn-id: https://svn.libreccm.org/ccm/trunk@1768 8810af33-2d31-482b-a856-94f89814c4df --- .../com/arsdigita/cms/CMSResources.properties | 2 + .../arsdigita/cms/CMSResources_de.properties | 2 + .../cms/CMSResources_en_GB.properties | 2 + .../arsdigita/cms/CMSResources_fr.properties | 2 + .../src/com/arsdigita/cms/PageLocations.java | 1 + .../com/arsdigita/cms/ui/ContentItemPage.java | 19 +- .../cms/ui/ItemSearchCreateItemPane.java | 165 ++++++++++++++---- .../cms/ui/ItemSearchFlatBrowsePane.java | 11 +- .../arsdigita/cms/ui/ItemSearchWidget.java | 61 ++++--- .../ui/authoring/AuthoringKitSelector.java | 78 +++++---- .../cms/ui/authoring/BasicItemForm.java | 9 +- .../cms/ui/authoring/BasicPageForm.java | 1 + .../cms/ui/authoring/SimpleEditStep.java | 6 +- .../cms/ui/authoring/WizardSelector.java | 6 +- .../cms/ui/folder/AbstractFolderPicker.java | 43 +++-- .../cms/ui/folder/FlatFolderPicker.java | 4 +- .../src/com/arsdigita/bebop/TabbedPane.java | 2 +- 17 files changed, 290 insertions(+), 124 deletions(-) diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources.properties index d661d0ec2..6cf242e1a 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources.properties @@ -1103,3 +1103,5 @@ cms.ui.item_search.flat.filter.submit=Filter cms.ui.item_search.selected=Selected content item (id) cms.ui.item_search.create=Create new cms.ui.item_search.create.folder_select=Select folder +cms.ui.search.create.select_close=Select item and close +cms.ui.search.create.select_edit=Select item and edit diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties index 0fa625c62..84b19ec2e 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties @@ -1094,3 +1094,5 @@ cms.ui.item_search.flat.filter.submit=Filtern cms.ui.item_search.selected=Ausgew\u00e4hltes Content Item (ID) cms.ui.item_search.create=Neu anlegen cms.ui.item_search.create.folder_select=Ordner ausw\u00e4hlen +cms.ui.search.create.select_close=Item ausw\u00e4hlen und schlie\u00dfen +cms.ui.search.create.select_edit=Item ausw\u00e4hlen und weiter bearbeiten diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties index 4aeeed826..8be35afb6 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties @@ -42,3 +42,5 @@ cms.ui.item_search.flat.filter.submit= cms.ui.item_search.selected= cms.ui.item_search.create= cms.ui.item_search.create.folder_select= +cms.ui.search.create.select_close= +cms.ui.search.create.select_edit= diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties index a49de4db8..0aea40d54 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties @@ -573,3 +573,5 @@ cms.ui.item_search.flat.filter.submit= cms.ui.item_search.selected= cms.ui.item_search.create= cms.ui.item_search.create.folder_select= +cms.ui.search.create.select_close= +cms.ui.search.create.select_edit= diff --git a/ccm-cms/src/com/arsdigita/cms/PageLocations.java b/ccm-cms/src/com/arsdigita/cms/PageLocations.java index 778055566..e8d467cd4 100755 --- a/ccm-cms/src/com/arsdigita/cms/PageLocations.java +++ b/ccm-cms/src/com/arsdigita/cms/PageLocations.java @@ -29,4 +29,5 @@ package com.arsdigita.cms; public interface PageLocations { public String SECTION_PAGE = "admin/index.jsp"; public String ITEM_PAGE = "admin/item.jsp"; + public String ITEM_SEARCH_ITEM_PAGE = "admin/itemsearchitem.jsp"; } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ContentItemPage.java b/ccm-cms/src/com/arsdigita/cms/ui/ContentItemPage.java index ffd26db2b..55e86e2a1 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ContentItemPage.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ContentItemPage.java @@ -133,6 +133,8 @@ public class ContentItemPage extends CMSPage implements ActionListener { private ItemRevisionAdminPane m_revisionsPane; private ItemTemplates m_templatesPane; private Link m_previewLink; + private GlobalNavigation m_globalNavigation; + private ContentItemContextBar m_contextBar; private class ItemRequestLocal extends ContentItemRequestLocal { @@ -194,8 +196,11 @@ public class ContentItemPage extends CMSPage implements ActionListener { m_returnURL = new StringParameter(RETURN_URL); addGlobalStateParam(m_returnURL); - add(new GlobalNavigation()); - add(new ContentItemContextBar(m_itemModel)); + m_globalNavigation = new GlobalNavigation(); + add(m_globalNavigation); + + m_contextBar = new ContentItemContextBar(m_itemModel); + add(m_contextBar); // Create panels. m_summaryPane = new Summary(m_itemModel); @@ -416,7 +421,7 @@ public class ContentItemPage extends CMSPage implements ActionListener { * @param tab The index of the tab to display */ public static String getItemURL(ContentItem item, int tab) { - final ContentSection section = ContentSection.getContentSection(item); + final ContentSection section = item.getContentSection(); if (section == null) { return null; @@ -504,5 +509,13 @@ public class ContentItemPage extends CMSPage implements ActionListener { return ContentSection.getConfig().getUseStreamlinedCreation() && STREAMLINED_CREATION_ACTIVE.equals(state.getRequest(). getParameter(STREAMLINED_CREATION)); + } + + protected TabbedPane getTabbedPane() { + return m_tabbedPane; + } + + protected WizardSelector getWizardPane() { + return m_wizardPane; } } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchCreateItemPane.java b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchCreateItemPane.java index 087f1f138..6485c6037 100644 --- a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchCreateItemPane.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchCreateItemPane.java @@ -5,30 +5,44 @@ package com.arsdigita.cms.ui; import com.arsdigita.bebop.BoxPanel; +import com.arsdigita.bebop.Component; import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.Link; import com.arsdigita.bebop.Page; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.ParameterSingleSelectionModel; import com.arsdigita.bebop.SegmentedPanel; import com.arsdigita.bebop.SegmentedPanel.Segment; import com.arsdigita.bebop.SingleSelectionModel; -import com.arsdigita.bebop.event.ActionEvent; -import com.arsdigita.bebop.event.ActionListener; +import com.arsdigita.bebop.event.FormCancelListener; import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSubmissionListener; +import com.arsdigita.bebop.event.PrintEvent; +import com.arsdigita.bebop.event.PrintListener; +import com.arsdigita.bebop.form.Option; +import com.arsdigita.bebop.form.SingleSelect; import com.arsdigita.bebop.parameters.BigDecimalParameter; +import com.arsdigita.bebop.parameters.StringParameter; +import com.arsdigita.cms.AuthoringKit; import com.arsdigita.cms.CMS; +import com.arsdigita.cms.ContentItem; +import com.arsdigita.cms.ContentPage; import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.ui.authoring.BasicPageForm; import com.arsdigita.cms.ui.authoring.CreationSelector; import com.arsdigita.cms.ui.authoring.NewItemForm; +import com.arsdigita.cms.ui.authoring.WizardSelector; import com.arsdigita.cms.ui.folder.FlatFolderPicker; -import com.arsdigita.cms.ui.folder.FolderItemPane; import com.arsdigita.cms.ui.folder.FolderRequestLocal; import com.arsdigita.cms.ui.folder.FolderSelectionModel; -import com.arsdigita.cms.ui.folder.FolderTreeModelBuilder; +import com.arsdigita.cms.ui.item.ContentItemRequestLocal; import com.arsdigita.cms.util.GlobalizationUtil; +import com.arsdigita.persistence.OID; +import com.arsdigita.web.RedirectSignal; +import com.arsdigita.web.URL; import java.math.BigDecimal; /** @@ -38,29 +52,37 @@ import java.math.BigDecimal; */ class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListener, FormSubmissionListener { + public static final String WIDGET_PARAM = "widget"; + public static final String SEARCHWIDGET_PARAM = "searchWidget"; private static final String CONTENT_TYPE_ID = "ct"; private static final String FOLDER_ID = "folder_id"; - private NewItemForm m_newItem; - private SingleSelectionModel m_typeSel; - private FlatFolderPicker m_folderPicker; + private final NewItemForm m_newItem; + private final SingleSelectionModel m_typeSel; + private final FlatFolderPicker m_folderPicker; //private final BaseTree m_tree; private final SingleSelectionModel m_model; private final FolderSelectionModel m_folderSel; // To support legacy UI code private final FolderRequestLocal m_folder; private final CreationSelector m_creator; - private final ItemSearchPage parent; - private SegmentedPanel m_segPanel; - private Segment m_creationSeg; - private Segment m_newItemSeg; + private final ItemSearchPage m_parent; + private final ContentItemRequestLocal m_contentItem = new ContentItemRequestLocal() { + }; + private final Link m_selectCloseLink; + private final Link m_selectEditLink; + private final SegmentedPanel m_segPanel; + private final Segment m_creationSeg; + private final Segment m_newItemSeg; + private final Segment m_linkSeg; public ItemSearchCreateItemPane(final ItemSearchPage parent) { super(); - this.parent = parent; + this.m_parent = parent; m_segPanel = new SegmentedPanel("itemSearchCreate"); m_creationSeg = new Segment(); m_newItemSeg = new Segment(); + m_linkSeg = new Segment(); m_newItem = new SectionNewItemForm("newItem"); //m_newItem.addProcessListener(this); @@ -78,7 +100,25 @@ class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListen m_typeSel = new ParameterSingleSelectionModel(new BigDecimalParameter(CONTENT_TYPE_ID)); // m_typeSel.addChangeListener(this); - m_creator = new CreationSelector(m_typeSel, m_folderSel); + m_creator = new CreationSelector(m_typeSel, m_folderSel) { + + @Override + public void editItem(final PageState state, final ContentItem item) { + + //final ContentSection section = getContentSection(state); + //final String nodeURL = URL.getDispatcherPath() + section.getPath() + "/"; + //final String target = ItemSearchContentItemPage.getItemURL(nodeURL, item.getID(), + // ContentItemPage.AUTHORING_TAB, true); + + //throw new RedirectSignal(target, true); + + m_creationSeg.setVisible(state, false); + m_linkSeg.setVisible(state, true); + + m_contentItem.set(state, item); + } + + }; m_creationSeg.add(m_creator); m_creationSeg.add(new Label("
", false)); @@ -87,7 +127,7 @@ class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListen m_folderPicker = new FlatFolderPicker("flatFolder"); //m_newItem.add(m_folderPicker); folderRow.add(m_folderPicker); - m_newItem.add(folderRow); + m_newItem.add(folderRow); m_newItemSeg.add(m_newItem); @@ -96,9 +136,81 @@ class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListen m_segPanel.add(m_newItemSeg); m_segPanel.add(m_creationSeg); - add(m_segPanel); + m_selectCloseLink = new Link( + (String) GlobalizationUtil.globalize("cms.ui.search.create.select_close").localize(), + new PrintListener() { + + public void prepare(final PrintEvent event) { + final Link target = (Link) event.getTarget(); + final PageState state = event.getPageState(); + + final ContentItem item = m_contentItem.getContentItem(state); + final String title; + if (item instanceof ContentPage) { + title = ((ContentPage) item).getTitle(); + } else { + title = item.getName(); + } + + final String widget = (String) state.getValue(new StringParameter(WIDGET_PARAM)); + final String searchWidget = (String) state.getValue(new StringParameter(SEARCHWIDGET_PARAM)); + + target.setOnClick(String.format("window.opener.document.%s.value=\"%s\";" + + "window.opener.document.%s.value=\"%s\";" + + "self.close();" + + "return false;", + widget, + item.getID().toString(), + searchWidget, + title)); + } + + }); + + m_selectEditLink = new Link((String) GlobalizationUtil.globalize("cms.ui.search.create.select_edit").localize(), + new PrintListener() { + + public void prepare(final PrintEvent event) { + final Link target = (Link) event.getTarget(); + final PageState state = event.getPageState(); + + final ContentItem item = m_contentItem.getContentItem(state); + final String title; + if (item instanceof ContentPage) { + title = ((ContentPage) item).getTitle(); + } else { + title = item.getName(); + } + + + final String widget = (String) state.getValue(new StringParameter(WIDGET_PARAM)); + final String searchWidget = (String) state.getValue(new StringParameter(SEARCHWIDGET_PARAM)); + + final ContentSection section = item.getContentSection(); + final String nodeURL = section.getPath() + "/"; + final String linkTarget = ContentItemPage.getItemURL(nodeURL, item.getID(), + ContentItemPage.AUTHORING_TAB, true); + target.setTarget(linkTarget); + target.setOnClick(String.format("window.opener.document.%s.value=\"%s\";" + + "window.opener.document.%s.value=\"%s\";", + widget, + item.getID().toString(), + searchWidget, + title)); + + } + + }); + + final BoxPanel linkPanel = new BoxPanel(BoxPanel.VERTICAL); + linkPanel.add(m_selectCloseLink); + linkPanel.add(m_selectEditLink); + m_linkSeg.add(linkPanel); + + m_segPanel.add(m_linkSeg); + } @Override @@ -107,6 +219,7 @@ class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListen page.setVisibleDefault(m_newItemSeg, true); page.setVisibleDefault(m_creationSeg, false); + page.setVisibleDefault(m_linkSeg, false); page.addComponentStateParam(this, m_typeSel.getStateParameter()); page.addComponentStateParam(this, m_folderSel.getStateParameter()); @@ -117,29 +230,14 @@ class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListen final BigDecimal typeID = m_newItem.getTypeID(state); m_typeSel.setSelectedKey(state, typeID); - final BigDecimal folderId = (BigDecimal) m_folderPicker.getValue(state); - m_folderSel.setSelectedKey(state, folderId); - + final OID folderOID = OID.valueOf((String) m_folderPicker.getValue(state)); + m_folderSel.setSelectedKey(state, folderOID.get("id")); m_newItemSeg.setVisible(state, false); m_creationSeg.setVisible(state, true); } public void process(final FormSectionEvent fse) throws FormProcessException { - final PageState state = fse.getPageState(); - final Object source = fse.getSource(); - //if (source == m_newItem) { - final BigDecimal typeID = m_newItem.getTypeID(state); - m_typeSel.setSelectedKey(state, typeID); - final BigDecimal folderId = (BigDecimal) m_folderPicker.getValue(state); - m_folderSel.setSelectedKey(state, folderId); - - //m_newItem.setVisible(state, false); - //m_creator.setVisible(state, true); - m_newItemSeg.setVisible(state, false); - m_creationSeg.setVisible(state, true); - //parent.setTabActive(state, this, true); - //newItemMode(state); - //} + //Nothing } private static class SectionNewItemForm extends NewItemForm { @@ -151,5 +249,6 @@ class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListen public ContentSection getContentSection(PageState s) { return CMS.getContext().getContentSection(); } + } } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchFlatBrowsePane.java b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchFlatBrowsePane.java index 11b13643e..e6a84ca4f 100644 --- a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchFlatBrowsePane.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchFlatBrowsePane.java @@ -5,7 +5,6 @@ import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Form; import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.GridPanel; import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Link; import com.arsdigita.bebop.Page; @@ -13,7 +12,6 @@ import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PaginationModelBuilder; import com.arsdigita.bebop.Paginator; import com.arsdigita.bebop.RequestLocal; -import com.arsdigita.bebop.SimpleContainer; import com.arsdigita.bebop.Table; import com.arsdigita.bebop.event.FormInitListener; import com.arsdigita.bebop.event.FormProcessListener; @@ -37,14 +35,10 @@ import com.arsdigita.cms.Folder; import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.persistence.DataCollection; -import com.arsdigita.persistence.DataQuery; import com.arsdigita.persistence.Session; import com.arsdigita.persistence.SessionManager; -import com.arsdigita.toolbox.ui.DataQueryBuilder; -import com.arsdigita.toolbox.ui.DataTable; import com.arsdigita.util.LockableImpl; import java.math.BigDecimal; -import org.bouncycastle.asn1.ess.ContentIdentifier; /** * @@ -297,7 +291,10 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener, final ContentPage page = new ContentPage((BigDecimal) key); link.setOnClick(String.format( - "window.opener.document.%s.value=\"%s\";window.opener.document.%s.value=\"%s\";self.close();return false;", + "window.opener.document.%s.value=\"%s\";" + + "window.opener.document.%s.value=\"%s\";" + + "self.close();" + + "return false;", widget, key.toString(), searchWidget, diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchWidget.java b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchWidget.java index cdb945b28..24a522b37 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchWidget.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchWidget.java @@ -59,8 +59,9 @@ public class ItemSearchWidget extends FormSection private static final Logger s_log = Logger.getLogger(ItemSearchWidget.class); //private Hidden m_selected; - private TextField m_selected; + private TextField m_selected; private TextField m_item; + private Hidden m_publish; private Submit m_search; private Submit m_clear; private Label m_jsLabel; @@ -78,6 +79,7 @@ public class ItemSearchWidget extends FormSection public static final String BEBOP_ITEM_SEARCH = "bebop:itemSearch"; public static final String SEARCH = "search"; public static final boolean LIMIT_TO_CONTENT_SECTION = false; + public static final String PUBLISH = "publish"; private class ItemFragment extends TextField { @@ -184,18 +186,18 @@ public class ItemSearchWidget extends FormSection } /** - * Construct a new ItemSearchWidget. The model must be an - * ItemSearchParameter + * Construct a new ItemSearchWidget. The model must be an ItemSearchParameter */ public ItemSearchWidget(ParameterModel model) { this(model, null); } /** - * Construct a new ItemSearchWidget. The model must be an - * ItemSearchParameter + * Construct a new ItemSearchWidget. The model must be an ItemSearchParameter + * * @param model - * @param contentType + *param + * contentType */ public ItemSearchWidget(final ParameterModel model, final ContentType contentType) { super(new BoxPanel(BoxPanel.VERTICAL)); @@ -203,7 +205,7 @@ public class ItemSearchWidget extends FormSection if (!(model instanceof ItemSearchParameter)) { throw new IllegalArgumentException( "The ItemSearch widget " + model.getName() - + " must be backed by a ItemSearchParameter parmeter model"); + + " must be backed by a ItemSearchParameter parameter model"); } m_name = model.getName(); @@ -223,22 +225,29 @@ public class ItemSearchWidget extends FormSection m_contentType = contentType; //m_selected = new Hidden(model); m_selected = new ItemFragment(model, this); - final Label selectedItemLabel = new Label(selectedLabelText); + final Label selectedItemLabel = new Label(selectedLabelText); selectedItemLabel.addPrintListener(new PrintListener() { + public void prepare(final PrintEvent event) { - final Label target = (Label) event.getTarget(); - target.setLabel(selectedLabelText); + final Label target = (Label) event.getTarget(); + target.setLabel(selectedLabelText); } + }); final Label searchLabel = new Label(searchLabelText); searchLabel.addPrintListener(new PrintListener() { public void prepare(final PrintEvent event) { final Label target = (Label) event.getTarget(); - target.setLabel(searchLabelText); + target.setLabel(searchLabelText); } + }); //m_item = new ItemFragment(model, this); + + m_publish = new Hidden(PUBLISH); + add(m_publish); + m_item = new TextField(m_searchModel); m_search = new SearchFragment(m_searchName, this); m_clear = new ClearFragment(m_clearName, this); @@ -255,7 +264,7 @@ public class ItemSearchWidget extends FormSection CMS.getContext().getContentSection().getID()); params.setParameter("widget", formName + ".elements['" + m_selected. //m_item. getName() + "']"); - params.setParameter("searchWidget", formName + ".elements['" + m_item.getName() + "']"); + params.setParameter("searchWidget", formName + ".elements['" + m_item.getName() + "']"); if (typeURLFrag != null) { params.setParameter("single_type", typeURLFrag); } @@ -277,9 +286,10 @@ public class ItemSearchWidget extends FormSection //+ m_item.getName().replace('.', '_') + m_selected.getName().replace('.', '_') + "Popup(theForm) { \n" - + " aWindow = window.open(\"" + url + "&query=\" + document.getElementById('" + m_item.getName() + "').value , " + + " aWindow = window.open(\"" + url + "&query=\" + document.getElementById('" + m_item. + getName() + "').value , " //+ "\"search\", \"toolbar=no,width=800,height=600,status=no,scrollbars=yes,resize=yes\");\n" - + "\"search\", \"toolbar=no,width=\" + screen.width*0.5 + \",height=\" + screen.height*0.5 + \",status=no,scrollbars=yes,resize=yes\");\n" + + "\"search\", \"toolbar=yes,width=\" + screen.width*0.5 + \",height=\" + screen.height*0.5 + \",status=no,scrollbars=yes,resize=yes\");\n " + "return false;\n" + " } \n" + " --> \n" @@ -292,12 +302,12 @@ public class ItemSearchWidget extends FormSection final FormSection searchSection = new FormSection(new BoxPanel(BoxPanel.VERTICAL)); final BoxPanel searchRow = new BoxPanel(BoxPanel.HORIZONTAL); searchRow.add(searchLabel); - searchRow.add(m_item); + searchRow.add(m_item); searchRow.add(m_search); searchRow.add(m_clear); final BoxPanel itemRow = new BoxPanel(BoxPanel.HORIZONTAL); - itemRow.add(selectedItemLabel); - itemRow.add(m_selected); + itemRow.add(selectedItemLabel); + itemRow.add(m_selected); searchSection.add(searchRow); searchSection.add(itemRow); searchSection.add(m_jsLabel); @@ -363,6 +373,7 @@ public class ItemSearchWidget extends FormSection m_topHR.setVisible(s, false); m_bottomHR.setVisible(s, false); m_search.setVisible(s, true); + e.getFormData().put(PUBLISH, Boolean.TRUE.toString()); } catch (IllegalStateException ex) { // component is in metaform. nothing to do here. Custom generateXML must hide for us } @@ -403,10 +414,10 @@ public class ItemSearchWidget extends FormSection if (m_contentType != null) { state.setValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM), - m_contentType.getID()); + m_contentType.getID()); } else { state.setValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM), - null); + null); } throw new FormProcessException("item search FormSection submit"); } else if (m_search.isSelected(state)) { @@ -423,10 +434,10 @@ public class ItemSearchWidget extends FormSection if (m_contentType != null) { state.setValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM), - m_contentType.getID()); + m_contentType.getID()); } else { state.setValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM), - null); + null); } throw new FormProcessException("item search FormSection submit"); } else if (m_clear.isSelected(state)) { @@ -436,7 +447,7 @@ public class ItemSearchWidget extends FormSection m_searchComponent.setVisible(state, false); m_topHR.setVisible(state, false); m_bottomHR.setVisible(state, false); - m_search.setVisible(state, true); + m_search.setVisible(state, true); } catch (IllegalStateException ex) { // component is in metaform. nothing to do here. Custom generateXML must hide for us } @@ -455,9 +466,9 @@ public class ItemSearchWidget extends FormSection } public String getSearchLabelText() { - return searchLabelText; + return searchLabelText; } - + public void setSearchLabelText(final String searchLabelText) { this.searchLabelText = searchLabelText; } @@ -469,5 +480,5 @@ public class ItemSearchWidget extends FormSection public void setSelectedLabelText(String selectedLabelText) { this.selectedLabelText = selectedLabelText; } - + } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/authoring/AuthoringKitSelector.java b/ccm-cms/src/com/arsdigita/cms/ui/authoring/AuthoringKitSelector.java index a5ecade31..f9f6fce07 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/authoring/AuthoringKitSelector.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/authoring/AuthoringKitSelector.java @@ -18,46 +18,49 @@ */ package com.arsdigita.cms.ui.authoring; - import com.arsdigita.bebop.Component; +import com.arsdigita.bebop.Label; import com.arsdigita.bebop.MapComponentSelectionModel; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.SimpleContainer; import com.arsdigita.bebop.SingleSelectionModel; +import com.arsdigita.bebop.event.PrintEvent; +import com.arsdigita.bebop.event.PrintListener; import com.arsdigita.cms.AuthoringKit; import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ContentTypeCollection; +import com.arsdigita.cms.ui.ScriptPrinter; import com.arsdigita.cms.util.GlobalizationUtil; +import com.arsdigita.toolbox.ui.LayoutPanel; import com.arsdigita.xml.Element; import org.apache.log4j.Logger; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; - /** * Selects a component based on content type. Helper class for {@link * com.arsdigita.cms.ui.authoring.WizardSelector}. * - * @version $Id: AuthoringKitSelector.java 2090 2010-04-17 08:04:14Z pboy $ + * @version $Id: AuthoringKitSelector.java 2090 2010-04-17 08:04:14Z pboy $ */ public abstract class AuthoringKitSelector extends SimpleContainer { private static Logger s_log = - Logger.getLogger(AuthoringKitSelector.class); - + Logger.getLogger(AuthoringKitSelector.class); private Map m_comps; private MapComponentSelectionModel m_sel; ContentTypeCollection m_types; + private ScriptPrinter scriptPrinter; /** - * Construct a new AuthoringKitSelector. Load all the possible - * authoring kits from the database and construct components - * for them. + * Construct a new AuthoringKitSelector. Load all the possible authoring kits from the database and construct + * components for them. * - * @param model the {@link ItemSelectionModel} which will - * supply the selector with the id of a content type + * @param model the {@link ItemSelectionModel} which will supply the selector with the id of a content type * * @pre itemModel != null */ @@ -68,62 +71,78 @@ public abstract class AuthoringKitSelector extends SimpleContainer { m_sel = new MapComponentSelectionModel(model, m_comps); m_types = ContentType.getAllContentTypes(); - if ( m_types.isEmpty() ) { + if (m_types.isEmpty()) { m_types.close(); - throw new IllegalStateException( (String) GlobalizationUtil.globalize("cms.ui.authoring.no_content_types_were_found").localize()); + throw new IllegalStateException((String) GlobalizationUtil.globalize( + "cms.ui.authoring.no_content_types_were_found").localize()); } - } // Overloaded add methods + @Override public void add(Component c) { throw new UnsupportedOperationException(); } // Overloaded add methods + @Override public void add(Component c, int constraints) { throw new UnsupportedOperationException(); } /** - * Instantiate all the authoring kit wizards. - * The child class should call this method after it is done - * with initialization + * Instantiate all the authoring kit wizards. The child class should call this method after it is done with + * initialization */ protected void processKit() { - while(m_types.next()) { + while (m_types.next()) { ContentType type = m_types.getContentType(); AuthoringKit kit = type.getAuthoringKit(); - if(kit != null) { + if (kit != null) { Component c = instantiateKitComponent(kit, type); - if(c != null) { + if (c != null) { super.add(c); m_comps.put(type.getID(), c); s_log.info("Added component " + c + " for " + type.getAssociatedObjectType()); } + + if (c instanceof LayoutPanel) { + Label label = new Label("", false); + label.addPrintListener(new PrintListener() { + + public void prepare(final PrintEvent event) { + final Label label = (Label) event.getTarget(); + if (scriptPrinter != null) { + label.setLabel(scriptPrinter.printScript(event.getPageState())); + } + } + + }); + + ((LayoutPanel) c).setBottom(label); + } } } } /** - * Instantiate an authoring kit component. Child classes should - * override this to do the right thing. It is permissible for this - * method to return null. + * Instantiate an authoring kit component. Child classes should override this to do the right thing. It is + * permissible for this method to return null. * - * @param kit for this kit + * @param kit for this kit * @param type for this type */ protected abstract Component instantiateKitComponent( - AuthoringKit kit, ContentType type - ); + AuthoringKit kit, ContentType type); /** * @param id The content type id + * * @return The component the given type id */ public Component getComponent(BigDecimal id) { - return (Component)m_comps.get(id); + return (Component) m_comps.get(id); } /** @@ -135,14 +154,13 @@ public abstract class AuthoringKitSelector extends SimpleContainer { // Choose the right component and run it public void generateXML(PageState state, Element parent) { - if ( isVisible(state) ) { + if (isVisible(state)) { Component c = m_sel.getComponent(state); - if ( c == null) { + if (c == null) { throw new IllegalStateException("No component for " + m_sel.getSelectedKey(state)); } c.generateXML(state, parent); } - } - + } } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/authoring/BasicItemForm.java b/ccm-cms/src/com/arsdigita/cms/ui/authoring/BasicItemForm.java index 71e5e1658..7afa4dd59 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/authoring/BasicItemForm.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/authoring/BasicItemForm.java @@ -31,6 +31,7 @@ import com.arsdigita.bebop.event.FormInitListener; import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormValidationListener; +import com.arsdigita.bebop.form.Hidden; import com.arsdigita.bebop.form.TextField; import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.TrimmedStringParameter; @@ -66,6 +67,7 @@ public abstract class BasicItemForm private final ItemSelectionModel m_itemModel; private SaveCancelSection m_saveCancelSection; private FormSection m_widgetSection; + public static final String CONTENT_ITEM_ID = ContentItem.ID; public static final String NAME = ContentItem.NAME; public static final String TITLE = ContentPage.TITLE; public static final String LANGUAGE = ContentItem.LANGUAGE; @@ -137,7 +139,12 @@ public abstract class BasicItemForm */ protected void addWidgets() { //add(new FormErrorDisplay(this), ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT); - + + //add(new Label("id")); + final Hidden id = new Hidden(CONTENT_ITEM_ID); + //final TextField id = new TextField(CONTENT_ITEM_ID); + add(id); + // JavaScript auto-name generation is off by default. // It is turned on under the following circumstances // diff --git a/ccm-cms/src/com/arsdigita/cms/ui/authoring/BasicPageForm.java b/ccm-cms/src/com/arsdigita/cms/ui/authoring/BasicPageForm.java index 237c0a1d1..c8a679b44 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/authoring/BasicPageForm.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/authoring/BasicPageForm.java @@ -123,6 +123,7 @@ public abstract class BasicPageForm extends BasicItemForm { if (item != null) { // Preset fields + data.put(CONTENT_ITEM_ID, item.getID().toString()); data.put(NAME, item.getName()); data.put(TITLE, item.getTitle()); // data.put(DESCRIPTION, item.getDescription()); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/authoring/SimpleEditStep.java b/ccm-cms/src/com/arsdigita/cms/ui/authoring/SimpleEditStep.java index 67e386959..443a0f192 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/authoring/SimpleEditStep.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/authoring/SimpleEditStep.java @@ -18,6 +18,7 @@ */ package com.arsdigita.cms.ui.authoring; +import com.arsdigita.bebop.Label; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -26,9 +27,12 @@ import com.arsdigita.bebop.Page; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.event.ActionEvent; import com.arsdigita.bebop.event.ActionListener; +import com.arsdigita.bebop.event.PrintEvent; +import com.arsdigita.bebop.event.PrintListener; import com.arsdigita.bebop.event.RequestEvent; import com.arsdigita.bebop.event.RequestListener; import com.arsdigita.bebop.parameters.StringParameter; +import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.dispatcher.Utilities; import com.arsdigita.cms.ui.ContentItemPage; @@ -133,7 +137,7 @@ public class SimpleEditStep extends SecurityPropertyEditor component.setItemSelectionModel(itemModel); addDisplayComponent(component); - } + } } /** diff --git a/ccm-cms/src/com/arsdigita/cms/ui/authoring/WizardSelector.java b/ccm-cms/src/com/arsdigita/cms/ui/authoring/WizardSelector.java index 01cf48301..1a3388617 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/authoring/WizardSelector.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/authoring/WizardSelector.java @@ -22,6 +22,7 @@ package com.arsdigita.cms.ui.authoring; import com.arsdigita.bebop.Component; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.Resettable; +import com.arsdigita.bebop.SimpleContainer; import com.arsdigita.bebop.SingleSelectionModel; import com.arsdigita.bebop.parameters.BigDecimalParameter; import com.arsdigita.cms.AuthoringKit; @@ -29,6 +30,7 @@ import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.util.GlobalizationUtil; +import com.arsdigita.toolbox.ui.LayoutPanel; import com.arsdigita.xml.Element; import java.math.BigDecimal; @@ -81,7 +83,7 @@ public class WizardSelector extends AuthoringKitSelector new ItemSelectionModel(type, (BigDecimalParameter)m_itemSel.getStateParameter()); - AuthoringKitWizard w = new AuthoringKitWizard(type, itemModel); + AuthoringKitWizard w = new AuthoringKitWizard(type, itemModel); return w; } @@ -114,7 +116,7 @@ public class WizardSelector extends AuthoringKitSelector } else { typeId = type.getID(); } - + // Return the selected wizard return (Component)getComponent(typeId); } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/folder/AbstractFolderPicker.java b/ccm-cms/src/com/arsdigita/cms/ui/folder/AbstractFolderPicker.java index 9063ea33e..606c045c1 100644 --- a/ccm-cms/src/com/arsdigita/cms/ui/folder/AbstractFolderPicker.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/folder/AbstractFolderPicker.java @@ -8,6 +8,7 @@ import com.arsdigita.bebop.form.SingleSelect; import com.arsdigita.bebop.event.PrintListener; import com.arsdigita.bebop.event.PrintEvent; import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.cms.Folder; import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.persistence.OID; @@ -19,42 +20,46 @@ import java.util.TooManyListenersException; * @author Sören Bernstein (quasimodo) */ public abstract class AbstractFolderPicker extends SingleSelect { - + public AbstractFolderPicker(String name) { - super(new OIDParameter(name)); - + //super(new OIDParameter(name)); + super(new StringParameter(name)); + try { addPrintListener(new PrintListener() { + @Override - public void prepare(PrintEvent ev) { - addOptions(ev.getPageState(), - (SingleSelect)ev.getTarget()); - } - }); + public void prepare(PrintEvent ev) { + addOptions(ev.getPageState(), + (SingleSelect) ev.getTarget()); + } + + }); } catch (TooManyListenersException ex) { throw new RuntimeException("this cannot happen"); - } + } } - + public Folder getFolder(PageState state) { - OID oid = (OID)getValue(state); - + OID oid = OID.valueOf((String) getValue(state));//(OID) getValue(state); + if (oid == null) { return null; + } else { + return (Folder) DomainObjectFactory.newInstance(oid); } - return (Folder)DomainObjectFactory.newInstance(oid); } - - public void setCategory(PageState state, - Folder folder) { + + public void setFolder(PageState state, + Folder folder) { if (folder == null) { setValue(state, null); } else { - setValue(state, folder.getOID()); + setValue(state, folder.getOID().toString()); } } - + protected abstract void addOptions(PageState state, SingleSelect target); - + } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/folder/FlatFolderPicker.java b/ccm-cms/src/com/arsdigita/cms/ui/folder/FlatFolderPicker.java index d7b5b7f4d..76f77bf9a 100644 --- a/ccm-cms/src/com/arsdigita/cms/ui/folder/FlatFolderPicker.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/folder/FlatFolderPicker.java @@ -25,7 +25,7 @@ public class FlatFolderPicker extends AbstractFolderPicker { } protected void addOptions(PageState state, SingleSelect target) { - target.addOption(new Option(null, "")); + target.addOption(new Option("", "")); final ContentSection section = CMS.getContext().getContentSection(); //final String sectionName = section.getName(); @@ -70,7 +70,7 @@ public class FlatFolderPicker extends AbstractFolderPicker { path = String.format("%s/%s", prefix, folder.getName()); } - target.addOption(new Option(folder.getID().toString(), path)); + target.addOption(new Option(folder.getOID().toString(), path)); final ItemCollection children = folder.getChildren(); children.addEqualsFilter("objectType", Folder.BASE_DATA_OBJECT_TYPE); diff --git a/ccm-core/src/com/arsdigita/bebop/TabbedPane.java b/ccm-core/src/com/arsdigita/bebop/TabbedPane.java index a4514603a..4544b0a98 100755 --- a/ccm-core/src/com/arsdigita/bebop/TabbedPane.java +++ b/ccm-core/src/com/arsdigita/bebop/TabbedPane.java @@ -100,7 +100,7 @@ public class TabbedPane extends SimpleContainer { while (i.hasNext()) { Pane pane = (Pane) i.next(); p.setVisibleDefault(pane.getComponent(), pane == m_defaultPane); - } + } } /**