From: <pb...@fe...> - 2012-12-16 09:14:17
|
Author: pboy Date: 2012-12-16 09:14:07 +0000 (Sun, 16 Dec 2012) New Revision: 2371 Modified: trunk/ccm-cms/src/com/arsdigita/cms/CMSResources.properties trunk/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties trunk/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties trunk/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties trunk/ccm-cms/src/com/arsdigita/cms/ui/FlatItemList.java trunk/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchCreateItemPane.java trunk/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchFlatBrowsePane.java trunk/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchPage.java trunk/ccm-cms/src/com/arsdigita/cms/ui/authoring/NewItemForm.java trunk/ccm-cms/src/com/arsdigita/cms/ui/folder/FlatFolderPicker.java trunk/ccm-core/src/com/arsdigita/categorization/Category.java trunk/ccm-core/src/com/arsdigita/categorization/ui/ACSObjectCategoryForm.java trunk/ccm-core/src/com/arsdigita/packaging/Upgrade.java Log: Enhanced ItemSearchWidget, some minor fixes. Modified: trunk/ccm-cms/src/com/arsdigita/cms/CMSResources.properties =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/CMSResources.properties 2012-12-16 09:09:00 UTC (rev 2370) +++ trunk/ccm-cms/src/com/arsdigita/cms/CMSResources.properties 2012-12-16 09:14:07 UTC (rev 2371) @@ -1101,3 +1101,5 @@ cms.ui.category.undeletable=This category can't be deleted. 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 Modified: trunk/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties 2012-12-16 09:09:00 UTC (rev 2370) +++ trunk/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties 2012-12-16 09:14:07 UTC (rev 2371) @@ -1092,3 +1092,5 @@ cms.ui.category.undeletable=Diese Kategorie kann nicht gel\u00f6scht werden. 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 Modified: trunk/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties 2012-12-16 09:09:00 UTC (rev 2370) +++ trunk/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties 2012-12-16 09:14:07 UTC (rev 2371) @@ -40,3 +40,5 @@ cms.ui.category.undeletable= cms.ui.item_search.flat.filter.submit= cms.ui.item_search.selected= +cms.ui.item_search.create= +cms.ui.item_search.create.folder_select= Modified: trunk/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties 2012-12-16 09:09:00 UTC (rev 2370) +++ trunk/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties 2012-12-16 09:14:07 UTC (rev 2371) @@ -571,3 +571,5 @@ cms.ui.category.undeletable= cms.ui.item_search.flat.filter.submit= cms.ui.item_search.selected= +cms.ui.item_search.create= +cms.ui.item_search.create.folder_select= Modified: trunk/ccm-cms/src/com/arsdigita/cms/ui/FlatItemList.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ui/FlatItemList.java 2012-12-16 09:09:00 UTC (rev 2370) +++ trunk/ccm-cms/src/com/arsdigita/cms/ui/FlatItemList.java 2012-12-16 09:14:07 UTC (rev 2371) @@ -269,7 +269,7 @@ m_selector = new CreationSelector(m_typeSel, m_folderSel); m_newItemSeg.add(m_selector); - m_newItemSeg.add(new Label("<br/>", false)); + //m_newItemSeg.add(new Label("<br/>", false)); // The 'new folder' segment m_newFolderSeg.addHeader(new Label(globalize("cms.ui.new_folder"))); Modified: trunk/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchCreateItemPane.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchCreateItemPane.java 2012-12-16 09:09:00 UTC (rev 2370) +++ trunk/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchCreateItemPane.java 2012-12-16 09:14:07 UTC (rev 2371) @@ -4,19 +4,27 @@ */ package com.arsdigita.cms.ui; +import com.arsdigita.bebop.BoxPanel; +import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.Label; +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.FormProcessListener; import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.parameters.BigDecimalParameter; import com.arsdigita.cms.CMS; import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ui.authoring.CreationSelector; import com.arsdigita.cms.ui.authoring.NewItemForm; +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; @@ -26,55 +34,114 @@ /** * * @author Sören Bernstein (quasimodo) <sbe...@ze...> + * @author Jens Pelzetter <je...@jp...> */ -class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListener { +class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListener, FormSubmissionListener { 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 final BaseTree m_tree; + private 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 CreationSelector m_selector; + private final CreationSelector m_creator; + private final ItemSearchPage parent; + private SegmentedPanel m_segPanel; + private Segment m_creationSeg; private Segment m_newItemSeg; - public ItemSearchCreateItemPane() { + public ItemSearchCreateItemPane(final ItemSearchPage parent) { + super(); -// m_newItem = new SectionNewItemForm("newItem"); -// m_newItem.addProcessListener(this); + this.parent = parent; - m_tree = new BaseTree(new FolderTreeModelBuilder()); - m_model = m_tree.getSelectionModel(); + m_segPanel = new SegmentedPanel("itemSearchCreate"); + m_creationSeg = new Segment(); + m_newItemSeg = new Segment(); + + m_newItem = new SectionNewItemForm("newItem"); + //m_newItem.addProcessListener(this); + + //m_tree = new BaseTree(new FolderTreeModelBuilder()); + //m_model = m_tree.getSelectionModel(); + m_model = new ParameterSingleSelectionModel(new BigDecimalParameter(FOLDER_ID)); m_folderSel = new FolderSelectionModel(m_model); m_folder = new FolderRequestLocal(m_folderSel); // m_newItemSeg = addSegment(); this.setIdAttr("folder-new-item"); -// m_newItemSeg.addHeader(new Label(GlobalizationUtil.globalize("cms.ui.new_item"))); +// m_newItemSeg.addHeader(new Label(GlobalizationUtil.globalize("cms.ui.new_item"))); m_typeSel = new ParameterSingleSelectionModel(new BigDecimalParameter(CONTENT_TYPE_ID)); // m_typeSel.addChangeListener(this); - m_selector = new CreationSelector(m_typeSel, m_folderSel); - this.add(m_selector); - this.add(new Label("<br/>", false)); + m_creator = new CreationSelector(m_typeSel, m_folderSel); + m_creationSeg.add(m_creator); + m_creationSeg.add(new Label("<br/>", false)); -// add(m_newItem); + final BoxPanel folderRow = new BoxPanel(BoxPanel.HORIZONTAL); + folderRow.add(new Label(GlobalizationUtil.globalize("cms.ui.item_search.create.folder_select"))); + m_folderPicker = new FlatFolderPicker("flatFolder"); + //m_newItem.add(m_folderPicker); + folderRow.add(m_folderPicker); + m_newItem.add(folderRow); + m_newItemSeg.add(m_newItem); + m_newItem.addProcessListener(this); + m_newItem.addSubmissionListener(this); + + m_segPanel.add(m_newItemSeg); + m_segPanel.add(m_creationSeg); + + add(m_segPanel); + } - public void process(FormSectionEvent e) { - PageState s = e.getPageState(); - final Object source = e.getSource(); - if (source == m_newItem) { - BigDecimal typeID = m_newItem.getTypeID(s); - m_typeSel.setSelectedKey(s, typeID); - //newItemMode(s); - } + @Override + public void register(final Page page) { + super.register(page); + + page.setVisibleDefault(m_newItemSeg, true); + page.setVisibleDefault(m_creationSeg, false); + + page.addComponentStateParam(this, m_typeSel.getStateParameter()); + page.addComponentStateParam(this, m_folderSel.getStateParameter()); } + public void submitted(final FormSectionEvent fse) { + final PageState state = fse.getPageState(); + + 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_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); + //} + } + private static class SectionNewItemForm extends NewItemForm { public SectionNewItemForm(String name) { Modified: trunk/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchFlatBrowsePane.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchFlatBrowsePane.java 2012-12-16 09:09:00 UTC (rev 2370) +++ trunk/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchFlatBrowsePane.java 2012-12-16 09:14:07 UTC (rev 2371) @@ -65,6 +65,8 @@ public ItemSearchFlatBrowsePane(final String name) { super(name); + setIdAttr("itemSearchFlatBrowse"); + final BoxPanel mainPanel = new BoxPanel(BoxPanel.VERTICAL); queryParam = new StringParameter(QUERY_PARAM); Modified: trunk/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchPage.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchPage.java 2012-12-16 09:09:00 UTC (rev 2370) +++ trunk/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchPage.java 2012-12-16 09:14:07 UTC (rev 2371) @@ -61,12 +61,11 @@ private ItemSearchFlatBrowsePane m_flatBrowse; private ItemSearchBrowsePane m_browse; private ItemSearchPopup m_search; - //private ItemSearchCreateItemPane m_create; + private ItemSearchCreateItemPane m_create; private BigDecimalParameter m_sectionId; private static final CMSConfig s_conf = CMSConfig.getInstance(); private static final boolean LIMIT_TO_CONTENT_SECTION = false; public static final String CONTENT_SECTION = "section_id"; - //private final boolean showFlatBrowsePane; /** * Construct a new ItemSearchPage @@ -80,18 +79,13 @@ addGlobalStateParam(new StringParameter(ItemSearchPopup.WIDGET_PARAM)); addGlobalStateParam(new StringParameter("searchWidget")); - //showFlatBrowsePane = s_conf.getItemSearchFlatBrowsePaneEnable(); - - m_sectionId = new BigDecimalParameter(CONTENT_SECTION); addGlobalStateParam(m_sectionId); + m_flatBrowse = getFlatBrowsePane(); m_browse = getBrowsePane(); -// if (showFlatBrowsePane) { -// m_flatBrowse = getFlatBrowsePane(); -// } m_search = getSearchPane(); -// m_create = getCreatePane(); + m_create = getCreatePane(); m_tabbedPane = createTabbedPane(); m_tabbedPane.setIdAttr("page-body"); @@ -102,6 +96,10 @@ final PageState state = event.getPageState(); final String query = (String) state.getValue(new StringParameter(ItemSearchPopup.QUERY)); + + if (m_tabbedPane.getCurrentPane(state) == m_create) { + return; + } if ((query == null) || query.isEmpty()) { m_tabbedPane.setSelectedIndex(state, 1); @@ -109,10 +107,14 @@ m_tabbedPane.setSelectedIndex(state, 0); } - //if (showFlatBrowsePane) { - // m_tabbedPane.setTabVisible(state, 0, false); - // m_tabbedPane.setSelectedIndex(state, 1); - //} + BigDecimal typeParam = (BigDecimal) state.getValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM)); + if (typeParam == null) { + m_tabbedPane.setTabVisible(state, m_create, false); + m_create.setVisible(state, false); + } else { + m_tabbedPane.setTabVisible(state, m_create, true); + m_create.setVisible(state, true); + } } }); @@ -152,13 +154,14 @@ return m_search; } -// protected ItemSearchCreateItemPane getCreatePane() { -// if(m_create == null) { -// m_create = new ItemSearchCreateItemPane(); -// } -// -// return m_create; -// } + protected ItemSearchCreateItemPane getCreatePane() { + if (m_create == null) { + m_create = new ItemSearchCreateItemPane(this); + } + + return m_create; + } + /** * Created the TabbedPane to use for this page. Sets the class attribute for this tabbed pane. The default * implementation uses a @@ -172,12 +175,11 @@ TabbedPane pane = new TabbedPane(); pane.setClassAttr(XSL_CLASS); - //if (showFlatBrowsePane) { - addToPane(pane, "flatBrowse", getFlatBrowsePane()); - //} + + addToPane(pane, "flatBrowse", getFlatBrowsePane()); addToPane(pane, "browse", getBrowsePane()); addToPane(pane, "search", getSearchPane()); -// addToPane(pane, "create", getCreatePane()); + addToPane(pane, "create", getCreatePane()); if ("browse".equals(s_conf.getItemSearchDefaultTab())) { pane.setDefaultPane(m_browse); @@ -185,14 +187,10 @@ if ("search".equals(s_conf.getItemSearchDefaultTab())) { pane.setDefaultPane(m_search); } - //if ("flatBrowse".equals(s_conf.getItemSearchDefaultTab()) && showFlatBrowsePane) { - pane.setDefaultPane(m_flatBrowse); - //} else { - pane.setDefaultPane(m_browse); - //} - //pane.addActionListener(this); -// pane.setTabVisible(null, pane, true); + //pane.setDefaultPane(m_flatBrowse); + pane.setDefaultPane(m_browse); + return pane; } @@ -258,5 +256,12 @@ }.run(); } + + protected void setTabActive(final PageState state, final Component component, final boolean value) { + m_tabbedPane.setTabVisible(state, component, value); + } + protected void setTabActive(final PageState state, final int index, final boolean value) { + m_tabbedPane.setTabVisible(state, index, value); + } } Modified: trunk/ccm-cms/src/com/arsdigita/cms/ui/authoring/NewItemForm.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ui/authoring/NewItemForm.java 2012-12-16 09:09:00 UTC (rev 2370) +++ trunk/ccm-cms/src/com/arsdigita/cms/ui/authoring/NewItemForm.java 2012-12-16 09:14:07 UTC (rev 2371) @@ -21,6 +21,7 @@ import com.arsdigita.bebop.BoxPanel; import com.arsdigita.bebop.Form; import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.Page; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.event.PrintEvent; import com.arsdigita.bebop.event.PrintListener; @@ -72,20 +73,21 @@ * */ public NewItemForm(String name) { - super(name, new BoxPanel(BoxPanel.HORIZONTAL)); + //super(name, new BoxPanel(BoxPanel.HORIZONTAL)); + super(name, new BoxPanel(BoxPanel.VERTICAL)); setIdAttr("new_item_form"); - BoxPanel panel = (BoxPanel) getPanel(); + BoxPanel panel = new BoxPanel(BoxPanel.HORIZONTAL);//(BoxPanel) getPanel(); panel.setWidth("2%"); panel.setBorder(0); m_emptyLabel = new Label(globalize("cms.ui.authoring.no_types_registered"), false); m_emptyLabel.setIdAttr("empty_label"); - add(m_emptyLabel); + panel.add(m_emptyLabel); m_createLabel = new Label(globalize("cms.ui.authoring.create_new"), false); m_createLabel.setIdAttr("create_label"); - add(m_createLabel); + panel.add(m_createLabel); m_typeWidget = new SingleSelect(new BigDecimalParameter(TYPE_ID)); try { @@ -162,11 +164,12 @@ throw new UncheckedWrapperException("Too many listeners: " + e.getMessage(), e); } - add(m_typeWidget); + panel.add(m_typeWidget); m_submit = new Submit("new", globalize("cms.ui.authoring.go")); - add(m_submit); - + panel.add(m_submit); + + add(panel); } public abstract ContentSection getContentSection(PageState state); Modified: trunk/ccm-cms/src/com/arsdigita/cms/ui/folder/FlatFolderPicker.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ui/folder/FlatFolderPicker.java 2012-12-16 09:09:00 UTC (rev 2370) +++ trunk/ccm-cms/src/com/arsdigita/cms/ui/folder/FlatFolderPicker.java 2012-12-16 09:14:07 UTC (rev 2371) @@ -7,21 +7,36 @@ import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.form.SingleSelect; -import com.arsdigita.persistence.DataCollection; -import com.arsdigita.persistence.OID; -import com.arsdigita.persistence.SessionManager; +import com.arsdigita.cms.CMS; +import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.Folder; +import com.arsdigita.cms.ItemCollection; /** * * @author Sören Bernstein (quasimodo) <sbe...@ze...> + * @author Jens Pelzetter <je...@jp...> + * @version $Id$ */ public class FlatFolderPicker extends AbstractFolderPicker { - + public FlatFolderPicker(String name) { super(name); } - - protected void addOptions(PageState state, SingleSelect target) { + + protected void addOptions(PageState state, SingleSelect target) { + target.addOption(new Option(null, "")); + + final ContentSection section = CMS.getContext().getContentSection(); + //final String sectionName = section.getName(); + final Folder root = section.getRootFolder(); + + final String path = ""; // String.format("%s:", sectionName); + + //addFolders(target, path, root.getChildren().addEqualsFilter("objectType", Folder.BASE_DATA_OBJECT_TYPE)); + addFolder(target, path, root); + + // DataCollection terms = SessionManager.getSession() // .retrieve(Term.BASE_DATA_OBJECT_TYPE); // terms.addPath("model.id"); @@ -39,5 +54,30 @@ // terms.get("domain.title") + " -> " + // terms.get("model.name"))); // } - } + } + + private void addFolders(final SingleSelect target, final String path, ItemCollection folders) { + while (folders.next()) { + addFolder(target, path, (Folder) folders.getContentItem()); + } + } + + private void addFolder(final SingleSelect target, final String prefix, final Folder folder) { + final String path; + if ("/".equals(folder.getName()) || (prefix == null) || prefix.isEmpty() || prefix.endsWith("/")) { + path = String.format("%s%s", prefix, folder.getName()); + } else { + path = String.format("%s/%s", prefix, folder.getName()); + } + + target.addOption(new Option(folder.getID().toString(), path)); + + final ItemCollection children = folder.getChildren(); + children.addEqualsFilter("objectType", Folder.BASE_DATA_OBJECT_TYPE); + + if (!children.isEmpty()) { + addFolders(target, path, children); + } + } + } Modified: trunk/ccm-core/src/com/arsdigita/categorization/Category.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/categorization/Category.java 2012-12-16 09:09:00 UTC (rev 2370) +++ trunk/ccm-core/src/com/arsdigita/categorization/Category.java 2012-12-16 09:14:07 UTC (rev 2371) @@ -42,14 +42,12 @@ import com.arsdigita.util.HierarchyDenormalization; import com.arsdigita.util.StringUtils; import com.arsdigita.util.UncheckedWrapperException; - import java.math.BigDecimal; import java.sql.SQLException; import java.util.Collection; import java.util.LinkedList; import java.util.List; import java.util.StringTokenizer; - import org.apache.log4j.Logger; /** @@ -86,7 +84,7 @@ * @version $Revision: 1.1 $ $DateTime: $ * * <p>Localization is done with some new classes, so the category tree is - * now multilanguage. This is completly transparent to the rest of the + * now multilanguage. This is completly transparent to the rest of the * system (hopefully) and uses the negotiated language from the browser * environment. The following attributes are localizable: * @@ -178,6 +176,7 @@ private CategoryLocalizationCollection m_categoryLocalizationCollection; // Quasimodo: End + @Override protected String getBaseDataObjectType() { return BASE_DATA_OBJECT_TYPE; } @@ -378,7 +377,7 @@ public String getName(String locale) { // Test for localized version - if (locale != "" && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. + if (!locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. localizationExists(locale)) { // Return value of isEnabled from localized version, so categories could be disabled depending on locale @@ -468,7 +467,7 @@ * Returns the name of the <b>preferred</b> category along with its default ancestors. * Equivalent to #getQualifiedName(String,boolean) if this Category is not a synonym. * Synonym name is appended in parentheses. - * + * * @param delimiter string to separate category names * @param includeRoot should root category be shown * @return category path @@ -529,7 +528,7 @@ */ public void setName(String name, String locale) { - if (locale != "" && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. + if (!locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. localizationExists(locale)) { m_categoryLocalizationCollection.getCategoryLocalization().setName( name); @@ -558,7 +557,7 @@ // Test for localized version // HACK - if (locale != "" && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. + if (!locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. localizationExists(locale)) { // Return value of isEnabled from localized version, so categories could be disabled depending on locale @@ -603,7 +602,7 @@ */ public void setDescription(String description, String locale) { - if (locale != "" && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. + if (!locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. localizationExists(locale)) { m_categoryLocalizationCollection.getCategoryLocalization(). setDescription(description); @@ -631,7 +630,7 @@ public String getURL(String locale) { // Test for localized version - if (locale != "" && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. + if (!locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. localizationExists(locale)) { // Return value of isEnabled from localized version, so categories could be disabled depending on locale @@ -664,7 +663,7 @@ */ public void setURL(String url, String locale) { - if (locale != "" && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. + if (!locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. localizationExists(locale)) { m_categoryLocalizationCollection.getCategoryLocalization().setURL( url); @@ -693,19 +692,19 @@ * 2. If not, check if localized version exists * 2.1 If so, return isEnabled from localized version * 2.2 If not, return Category.getConfig().getShowInternalName() - * + * */ public boolean isEnabled(String locale) { - // If locale == "" return global status + // If locale is empty return global status // or if globally disabled, return category as disabled - if (locale == "" || ((Boolean) get(IS_ENABLED)).booleanValue() == false) { + if (locale.isEmpty() || ((Boolean) get(IS_ENABLED)).booleanValue() == false) { return ((Boolean) get(IS_ENABLED)).booleanValue(); } // Test for localized version // HACK - if (locale != "" && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. + if (!locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. localizationExists(locale)) { // Return value of isEnabled from localized version, so categories could be disabled depending on locale @@ -742,7 +741,7 @@ */ public void setEnabled(boolean isEnabled, String locale) { - if (locale != "" && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. + if (!locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. localizationExists(locale)) { m_categoryLocalizationCollection.getCategoryLocalization(). setEnabled(isEnabled); @@ -757,7 +756,7 @@ * <code>false</false> otherwise. */ public void setEnabled(boolean isEnabled) { - set(IS_ENABLED, new Boolean(isEnabled)); + set(IS_ENABLED, isEnabled); } /** @@ -777,7 +776,7 @@ * @see #isAbstract() */ public void setAbstract(boolean isAbstract) { - set(IS_ABSTRACT, new Boolean(isAbstract)); + set(IS_ABSTRACT, isAbstract); } /** @@ -799,7 +798,7 @@ * <code>false</code> otherwise */ public void setIgnoreParentIndexItem(boolean ignoreParentIndexItem) { - set(IGNORE_PARENT_INDEX_ITEM, new Boolean(ignoreParentIndexItem)); + set(IGNORE_PARENT_INDEX_ITEM, ignoreParentIndexItem); } /** @@ -851,6 +850,7 @@ /** * @see com.arsdigita.domain.DomainObject#beforeSave() */ + @Override protected void beforeSave() { super.beforeSave(); if (get(DEFAULT_ANCESTORS) == null) { @@ -861,6 +861,7 @@ /** * Placed a hook for a CategoryListener trigger. */ + @Override protected void beforeDelete() { Categorization.triggerDeletionEvent(this); super.beforeDelete(); @@ -890,6 +891,7 @@ * must call {@link #deleteCategoryAndOrphan()}, {@link * #deleteCategorySubtree()}, or {@link #deleteCategoryAndRemap()}. */ + @Override public void delete() { // see if the only "children" are non-default DataAssociationCursor children = getRelatedCategories(CHILD); @@ -1081,9 +1083,9 @@ } /** - * Add a preferred category, which marks the current category as a synonym. + * Add a preferred category, which marks the current category as a synonym. * When a synonym category is selected, preferred category should be used instead - * i.e. assigned to the item. + * i.e. assigned to the item. */ public void addPreferredCategory(Category preferred) { addMapping(preferred, PREFERRED); @@ -1206,7 +1208,7 @@ category.setDefaultAncestors(null); } } catch (CategoryNotFoundException e) { - ;// leave the context alone and thus we want to do nothing + // leave the context alone and thus we want to do nothing } remove(RELATED, category); Categorization.triggerRemoveChildEvent(this, category); @@ -1560,7 +1562,7 @@ int count = 0; while (cursor.next()) { DataObject link = cursor.getLink(); - link.set(SORT_KEY, new Integer(count)); + link.set(SORT_KEY, new BigDecimal(count)); count++; } } @@ -1601,8 +1603,8 @@ DataObject link1 = null; DataObject link2 = null; - BigDecimal key1 = null; - BigDecimal key2 = null; + BigDecimal key1; + BigDecimal key2; DataAssociationCursor cursor = ((DataAssociation) get(CHILD_OBJECTS)).cursor(); @@ -1729,8 +1731,8 @@ return pathExtension; } - StringBuffer sb = - new StringBuffer(path.length() + pathExtension.length() + 1); + StringBuilder sb = + new StringBuilder(path.length() + pathExtension.length() + 1); sb.append(path).append(".").append(pathExtension); return sb.toString(); } @@ -1855,7 +1857,7 @@ } StringTokenizer st = new StringTokenizer(path, delim); - StringBuffer subpath = new StringBuffer(); + StringBuilder subpath = new StringBuilder(); while (st.hasMoreTokens()) { subpath.append(st.nextToken()).append(delim); @@ -1890,7 +1892,7 @@ } private static String appendID(String path) { - StringBuffer sb = new StringBuffer(path.length() + 3); + StringBuilder sb = new StringBuilder(path.length() + 3); sb.append(path).append(".").append(ID); return sb.toString(); } @@ -1969,8 +1971,9 @@ } } + @Override public String toString() { - StringBuffer result = new StringBuffer(128); + StringBuilder result = new StringBuilder(128); result.append("name=").append(getName()).append("; "); result.append("oid=").append(getOID()); return result.toString(); @@ -2213,7 +2216,7 @@ String url) { // If locale don't exist - if (locale != "" && m_categoryLocalizationCollection != null && !m_categoryLocalizationCollection. + if (!locale.isEmpty() && m_categoryLocalizationCollection != null && !m_categoryLocalizationCollection. localizationExists(locale)) { // Get DataAssociation @@ -2241,7 +2244,7 @@ public boolean delLanguage(String locale) { // If locale exist - if (locale != "" && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. + if (!locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. localizationExists(locale)) { // Get DataAssociation Modified: trunk/ccm-core/src/com/arsdigita/categorization/ui/ACSObjectCategoryForm.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/categorization/ui/ACSObjectCategoryForm.java 2012-12-16 09:09:00 UTC (rev 2370) +++ trunk/ccm-core/src/com/arsdigita/categorization/ui/ACSObjectCategoryForm.java 2012-12-16 09:14:07 UTC (rev 2371) @@ -45,22 +45,22 @@ /** * abstract form for assigning categories to acs_objects. The assigned - * categories are those specified by the category widget, which is - * retrieved by the concrete subclass' implementation of getCategoryWidget. - * - * The category widget may be an implementation of CategoryWidget, which - * generates a javascript tree of categories. Implementations need only + * categories are those specified by the category widget, which is + * retrieved by the concrete subclass' implementation of getCategoryWidget. + * + * The category widget may be an implementation of CategoryWidget, which + * generates a javascript tree of categories. Implementations need only * specify an XML prefix and namespace. - * + * * The object that is to be assigned to the categories is specified * by the concrete subclass' implentation of getObject - * + * * @author chr...@we... * - * + * */ // this class has been abstracted out from the original cms specific category form -// in ccm-cms +// in ccm-cms public abstract class ACSObjectCategoryForm extends Form { private Widget m_category; @@ -111,10 +111,10 @@ ACSObject object = getObject(state); - HashSet curSelectesdCat = new HashSet(); + HashSet curSelectedCat = new HashSet(); CategoryCollection cats = new CategorizedObject(object).getParents(); while (cats.next()) { - curSelectesdCat.add(cats.getCategory().getID()); + curSelectedCat.add(cats.getCategory().getID()); } BigDecimal[] ids = (BigDecimal[]) m_category.getValue(state); @@ -123,7 +123,7 @@ new OID(Category.BASE_DATA_OBJECT_TYPE, ids[i])); - if(!curSelectesdCat.contains(ids[i])) { + if(!curSelectedCat.contains(ids[i])) { cat.addChild(object); } else { cat.removeChild(object); Modified: trunk/ccm-core/src/com/arsdigita/packaging/Upgrade.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/packaging/Upgrade.java 2012-12-16 09:09:00 UTC (rev 2370) +++ trunk/ccm-core/src/com/arsdigita/packaging/Upgrade.java 2012-12-16 09:14:07 UTC (rev 2371) @@ -55,33 +55,18 @@ private static final Logger logger = Logger.getLogger(Upgrade.class); private static final Options s_options = getOptions(); - private String m_from; private String m_to; private final List m_scripts; static { logger.debug("Static initalizer starting..."); - s_options.addOption - (OptionBuilder - .isRequired() - .hasArg() - .withLongOpt("from-version") - .withDescription("Upgrade from version VERSION") - .create()); - s_options.addOption - (OptionBuilder - .isRequired() - .hasArg() - .withLongOpt("to-version") - .withDescription("Upgrade to version VERSION") - .create()); - s_options.addOption - (OptionBuilder - .hasArg() - .withLongOpt("parameters") - .withDescription("Parameters to pass to upgrade scripts") - .create()); + s_options.addOption(OptionBuilder.isRequired().hasArg().withLongOpt("from-version").withDescription( + "Upgrade from version VERSION").create()); + s_options.addOption(OptionBuilder.isRequired().hasArg().withLongOpt("to-version").withDescription( + "Upgrade to version VERSION").create()); + s_options.addOption(OptionBuilder.hasArg().withLongOpt("parameters").withDescription( + "Parameters to pass to upgrade scripts").create()); logger.debug("Static initalizer finished."); } @@ -147,8 +132,7 @@ final String spec = key + ".upgrade"; - final InputStream in = Thread.currentThread().getContextClassLoader - ().getResourceAsStream(spec); + final InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(spec); if (in == null) { System.err.println("Cannot find " + spec); @@ -158,18 +142,19 @@ XML.parse(in, new Parser()); if (m_scripts.isEmpty()) { - System.err.println("No appropriate upgrades found; make sure " + - "that your 'to' and 'from' versions match " + - "the intended upgrade exactly"); + System.err.println("No appropriate upgrades found; make sure " + "that your 'to' and 'from' versions match " + + "the intended upgrade exactly"); return false; } else { - System.out.println("Number of scripts: " + m_scripts.size() ); + System.out.println("Number of scripts: " + m_scripts.size()); } - Iterator iter = m_scripts.iterator(); - while (iter.hasNext()) { + //Iterator iter = m_scripts.iterator(); + //while (iter.hasNext()) { + for (int k = 0; k < m_scripts.size(); k++) { - final String[] parts = (String[]) iter.next(); + System.out.printf("Running script %d/%d\n", (k + 1), m_scripts.size()); + final String[] parts = (String[]) m_scripts.get(k); //(String[]) iter.next(); final String classname = parts[0]; final String sql = parts[1]; @@ -183,7 +168,7 @@ try { method = clacc.getMethod("main", - new Class[] {String[].class}); + new Class[]{String[].class}); } catch (NoSuchMethodException nsme) { throw new UncheckedWrapperException(nsme); } catch (SecurityException se) { @@ -194,7 +179,7 @@ LinkedList ll = new LinkedList(); if (params != null) { for (int i = 0; i < params.length; i++) { - String[] split = StringUtils.split(params[i],','); + String[] split = StringUtils.split(params[i], ','); for (int j = 0; j < split.length; j++) { ll.add(split[j]); } @@ -202,7 +187,7 @@ } try { - method.invoke(null, new Object[] {ll.toArray(new String[] {})}); + method.invoke(null, new Object[]{ll.toArray(new String[]{})}); } catch (IllegalAccessException iae) { throw new UncheckedWrapperException(iae); } catch (InvocationTargetException ite) { @@ -212,11 +197,9 @@ } else if (sql != null) { final SchemaLoader loader = new SchemaLoader(sql); - System.out.println("Running SQL upgrade " + loader + ", " + - "loaded from the classpath"); + System.out.println("Running SQL upgrade " + loader + ", " + "loaded from the classpath"); - final Connection conn = Connections.acquire - (RuntimeConfig.getConfig().getJDBCURL()); + final Connection conn = Connections.acquire(RuntimeConfig.getConfig().getJDBCURL()); loader.run(conn); @@ -235,9 +218,10 @@ } /** - * + * */ private class Parser extends DefaultHandler { + private String m_version; @Override @@ -265,14 +249,12 @@ final String sql = attrs.getValue(uri, "sql"); if (classname == null && sql == null - || classname != null && sql != null) { - throw new IllegalArgumentException - ("The script element must have a 'class' " + - "argument or a 'sql' argument; it may not " + - "have both"); + || classname != null && sql != null) { + throw new IllegalArgumentException("The script element must have a 'class' " + + "argument or a 'sql' argument; it may not " + "have both"); } - m_scripts.add(new String[] {classname, sql}); + m_scripts.add(new String[]{classname, sql}); } } } @@ -285,5 +267,6 @@ m_version = null; } } + } } |