Aktueller stand ItemSearchWidget
git-svn-id: https://svn.libreccm.org/ccm/trunk@1759 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
c321d8d89c
commit
7d1e47dc6f
|
|
@ -1101,3 +1101,5 @@ cms.ui.item_search.flatBrowse=Select item
|
||||||
cms.ui.category.undeletable=This category can't be deleted.
|
cms.ui.category.undeletable=This category can't be deleted.
|
||||||
cms.ui.item_search.flat.filter.submit=Filter
|
cms.ui.item_search.flat.filter.submit=Filter
|
||||||
cms.ui.item_search.selected=Selected content item (id)
|
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
|
||||||
|
|
|
||||||
|
|
@ -1092,3 +1092,5 @@ cms.ui.item_search.flatBrowse=Item ausw\u00e4hlen
|
||||||
cms.ui.category.undeletable=Diese Kategorie kann nicht gel\u00f6scht werden.
|
cms.ui.category.undeletable=Diese Kategorie kann nicht gel\u00f6scht werden.
|
||||||
cms.ui.item_search.flat.filter.submit=Filtern
|
cms.ui.item_search.flat.filter.submit=Filtern
|
||||||
cms.ui.item_search.selected=Ausgew\u00e4hltes Content Item (ID)
|
cms.ui.item_search.selected=Ausgew\u00e4hltes Content Item (ID)
|
||||||
|
cms.ui.item_search.create=Neu anlegen
|
||||||
|
cms.ui.item_search.create.folder_select=Order ausw\u00e4hlen
|
||||||
|
|
|
||||||
|
|
@ -40,3 +40,5 @@ cms.ui.item_search.flatBrowse=Select item
|
||||||
cms.ui.category.undeletable=
|
cms.ui.category.undeletable=
|
||||||
cms.ui.item_search.flat.filter.submit=
|
cms.ui.item_search.flat.filter.submit=
|
||||||
cms.ui.item_search.selected=
|
cms.ui.item_search.selected=
|
||||||
|
cms.ui.item_search.create=
|
||||||
|
cms.ui.item_search.create.folder_select=
|
||||||
|
|
|
||||||
|
|
@ -571,3 +571,5 @@ cms.ui.item_search.flatBrowse=Select item
|
||||||
cms.ui.category.undeletable=
|
cms.ui.category.undeletable=
|
||||||
cms.ui.item_search.flat.filter.submit=
|
cms.ui.item_search.flat.filter.submit=
|
||||||
cms.ui.item_search.selected=
|
cms.ui.item_search.selected=
|
||||||
|
cms.ui.item_search.create=
|
||||||
|
cms.ui.item_search.create.folder_select=
|
||||||
|
|
|
||||||
|
|
@ -269,7 +269,7 @@ public class FlatItemList extends SegmentedPanel
|
||||||
|
|
||||||
m_selector = new CreationSelector(m_typeSel, m_folderSel);
|
m_selector = new CreationSelector(m_typeSel, m_folderSel);
|
||||||
m_newItemSeg.add(m_selector);
|
m_newItemSeg.add(m_selector);
|
||||||
m_newItemSeg.add(new Label("<br/>", false));
|
//m_newItemSeg.add(new Label("<br/>", false));
|
||||||
|
|
||||||
// The 'new folder' segment
|
// The 'new folder' segment
|
||||||
m_newFolderSeg.addHeader(new Label(globalize("cms.ui.new_folder")));
|
m_newFolderSeg.addHeader(new Label(globalize("cms.ui.new_folder")));
|
||||||
|
|
|
||||||
|
|
@ -4,19 +4,27 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.cms.ui;
|
package com.arsdigita.cms.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.BoxPanel;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
import com.arsdigita.bebop.Label;
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.Page;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||||
import com.arsdigita.bebop.SegmentedPanel;
|
import com.arsdigita.bebop.SegmentedPanel;
|
||||||
import com.arsdigita.bebop.SegmentedPanel.Segment;
|
import com.arsdigita.bebop.SegmentedPanel.Segment;
|
||||||
import com.arsdigita.bebop.SingleSelectionModel;
|
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.FormProcessListener;
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||||
import com.arsdigita.cms.CMS;
|
import com.arsdigita.cms.CMS;
|
||||||
import com.arsdigita.cms.ContentSection;
|
import com.arsdigita.cms.ContentSection;
|
||||||
import com.arsdigita.cms.ui.authoring.CreationSelector;
|
import com.arsdigita.cms.ui.authoring.CreationSelector;
|
||||||
import com.arsdigita.cms.ui.authoring.NewItemForm;
|
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.FolderRequestLocal;
|
||||||
import com.arsdigita.cms.ui.folder.FolderSelectionModel;
|
import com.arsdigita.cms.ui.folder.FolderSelectionModel;
|
||||||
import com.arsdigita.cms.ui.folder.FolderTreeModelBuilder;
|
import com.arsdigita.cms.ui.folder.FolderTreeModelBuilder;
|
||||||
|
|
@ -26,23 +34,35 @@ import java.math.BigDecimal;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
|
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
*/
|
*/
|
||||||
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 CONTENT_TYPE_ID = "ct";
|
||||||
private NewItemForm m_newItem;
|
private NewItemForm m_newItem;
|
||||||
private SingleSelectionModel m_typeSel;
|
private SingleSelectionModel m_typeSel;
|
||||||
|
private FlatFolderPicker m_folderPicker;
|
||||||
private final BaseTree m_tree;
|
private final BaseTree m_tree;
|
||||||
private final SingleSelectionModel m_model;
|
private final SingleSelectionModel m_model;
|
||||||
private final FolderSelectionModel m_folderSel; // To support legacy UI code
|
private final FolderSelectionModel m_folderSel; // To support legacy UI code
|
||||||
private final FolderRequestLocal m_folder;
|
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;
|
private Segment m_newItemSeg;
|
||||||
|
|
||||||
public ItemSearchCreateItemPane() {
|
public ItemSearchCreateItemPane(final ItemSearchPage parent) {
|
||||||
|
super();
|
||||||
|
|
||||||
// m_newItem = new SectionNewItemForm("newItem");
|
this.parent = parent;
|
||||||
// m_newItem.addProcessListener(this);
|
|
||||||
|
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_tree = new BaseTree(new FolderTreeModelBuilder());
|
||||||
m_model = m_tree.getSelectionModel();
|
m_model = m_tree.getSelectionModel();
|
||||||
|
|
@ -56,23 +76,60 @@ class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListen
|
||||||
m_typeSel = new ParameterSingleSelectionModel(new BigDecimalParameter(CONTENT_TYPE_ID));
|
m_typeSel = new ParameterSingleSelectionModel(new BigDecimalParameter(CONTENT_TYPE_ID));
|
||||||
// m_typeSel.addChangeListener(this);
|
// m_typeSel.addChangeListener(this);
|
||||||
|
|
||||||
m_selector = new CreationSelector(m_typeSel, m_folderSel);
|
m_creator = new CreationSelector(m_typeSel, m_folderSel);
|
||||||
this.add(m_selector);
|
m_creationSeg.add(m_creator);
|
||||||
this.add(new Label("<br/>", false));
|
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) {
|
@Override
|
||||||
PageState s = e.getPageState();
|
public void register(final Page page) {
|
||||||
final Object source = e.getSource();
|
super.register(page);
|
||||||
if (source == m_newItem) {
|
|
||||||
BigDecimal typeID = m_newItem.getTypeID(s);
|
page.setVisibleDefault(m_newItemSeg, true);
|
||||||
m_typeSel.setSelectedKey(s, typeID);
|
page.setVisibleDefault(m_creationSeg, false);
|
||||||
//newItemMode(s);
|
|
||||||
}
|
page.addComponentStateParam(this, m_typeSel.getStateParameter());
|
||||||
|
page.addComponentStateParam(this, m_folderSel.getStateParameter());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void submitted(final FormSectionEvent fse) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void process(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 {
|
private static class SectionNewItemForm extends NewItemForm {
|
||||||
|
|
@ -84,5 +141,6 @@ class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListen
|
||||||
public ContentSection getContentSection(PageState s) {
|
public ContentSection getContentSection(PageState s) {
|
||||||
return CMS.getContext().getContentSection();
|
return CMS.getContext().getContentSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,8 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
||||||
public ItemSearchFlatBrowsePane(final String name) {
|
public ItemSearchFlatBrowsePane(final String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
|
||||||
|
setIdAttr("itemSearchFlatBrowse");
|
||||||
|
|
||||||
final BoxPanel mainPanel = new BoxPanel(BoxPanel.VERTICAL);
|
final BoxPanel mainPanel = new BoxPanel(BoxPanel.VERTICAL);
|
||||||
|
|
||||||
queryParam = new StringParameter(QUERY_PARAM);
|
queryParam = new StringParameter(QUERY_PARAM);
|
||||||
|
|
|
||||||
|
|
@ -61,12 +61,11 @@ public class ItemSearchPage extends CMSPage {
|
||||||
private ItemSearchFlatBrowsePane m_flatBrowse;
|
private ItemSearchFlatBrowsePane m_flatBrowse;
|
||||||
private ItemSearchBrowsePane m_browse;
|
private ItemSearchBrowsePane m_browse;
|
||||||
private ItemSearchPopup m_search;
|
private ItemSearchPopup m_search;
|
||||||
//private ItemSearchCreateItemPane m_create;
|
private ItemSearchCreateItemPane m_create;
|
||||||
private BigDecimalParameter m_sectionId;
|
private BigDecimalParameter m_sectionId;
|
||||||
private static final CMSConfig s_conf = CMSConfig.getInstance();
|
private static final CMSConfig s_conf = CMSConfig.getInstance();
|
||||||
private static final boolean LIMIT_TO_CONTENT_SECTION = false;
|
private static final boolean LIMIT_TO_CONTENT_SECTION = false;
|
||||||
public static final String CONTENT_SECTION = "section_id";
|
public static final String CONTENT_SECTION = "section_id";
|
||||||
//private final boolean showFlatBrowsePane;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new ItemSearchPage
|
* Construct a new ItemSearchPage
|
||||||
|
|
@ -80,18 +79,13 @@ public class ItemSearchPage extends CMSPage {
|
||||||
addGlobalStateParam(new StringParameter(ItemSearchPopup.WIDGET_PARAM));
|
addGlobalStateParam(new StringParameter(ItemSearchPopup.WIDGET_PARAM));
|
||||||
addGlobalStateParam(new StringParameter("searchWidget"));
|
addGlobalStateParam(new StringParameter("searchWidget"));
|
||||||
|
|
||||||
//showFlatBrowsePane = s_conf.getItemSearchFlatBrowsePaneEnable();
|
|
||||||
|
|
||||||
|
|
||||||
m_sectionId = new BigDecimalParameter(CONTENT_SECTION);
|
m_sectionId = new BigDecimalParameter(CONTENT_SECTION);
|
||||||
addGlobalStateParam(m_sectionId);
|
addGlobalStateParam(m_sectionId);
|
||||||
|
|
||||||
|
m_flatBrowse = getFlatBrowsePane();
|
||||||
m_browse = getBrowsePane();
|
m_browse = getBrowsePane();
|
||||||
// if (showFlatBrowsePane) {
|
|
||||||
// m_flatBrowse = getFlatBrowsePane();
|
|
||||||
// }
|
|
||||||
m_search = getSearchPane();
|
m_search = getSearchPane();
|
||||||
// m_create = getCreatePane();
|
m_create = getCreatePane();
|
||||||
|
|
||||||
m_tabbedPane = createTabbedPane();
|
m_tabbedPane = createTabbedPane();
|
||||||
m_tabbedPane.setIdAttr("page-body");
|
m_tabbedPane.setIdAttr("page-body");
|
||||||
|
|
@ -109,10 +103,14 @@ public class ItemSearchPage extends CMSPage {
|
||||||
m_tabbedPane.setSelectedIndex(state, 0);
|
m_tabbedPane.setSelectedIndex(state, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (showFlatBrowsePane) {
|
BigDecimal typeParam = (BigDecimal) state.getValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM));
|
||||||
// m_tabbedPane.setTabVisible(state, 0, false);
|
if (typeParam == null) {
|
||||||
// m_tabbedPane.setSelectedIndex(state, 1);
|
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 +150,14 @@ public class ItemSearchPage extends CMSPage {
|
||||||
return m_search;
|
return m_search;
|
||||||
}
|
}
|
||||||
|
|
||||||
// protected ItemSearchCreateItemPane getCreatePane() {
|
protected ItemSearchCreateItemPane getCreatePane() {
|
||||||
// if(m_create == null) {
|
if (m_create == null) {
|
||||||
// m_create = new ItemSearchCreateItemPane();
|
m_create = new ItemSearchCreateItemPane(this);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// return m_create;
|
return m_create;
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created the TabbedPane to use for this page. Sets the class attribute for this tabbed pane. The default
|
* Created the TabbedPane to use for this page. Sets the class attribute for this tabbed pane. The default
|
||||||
* implementation uses a
|
* implementation uses a
|
||||||
|
|
@ -172,12 +171,11 @@ public class ItemSearchPage extends CMSPage {
|
||||||
TabbedPane pane = new TabbedPane();
|
TabbedPane pane = new TabbedPane();
|
||||||
pane.setClassAttr(XSL_CLASS);
|
pane.setClassAttr(XSL_CLASS);
|
||||||
|
|
||||||
//if (showFlatBrowsePane) {
|
|
||||||
addToPane(pane, "flatBrowse", getFlatBrowsePane());
|
addToPane(pane, "flatBrowse", getFlatBrowsePane());
|
||||||
//}
|
|
||||||
addToPane(pane, "browse", getBrowsePane());
|
addToPane(pane, "browse", getBrowsePane());
|
||||||
addToPane(pane, "search", getSearchPane());
|
addToPane(pane, "search", getSearchPane());
|
||||||
// addToPane(pane, "create", getCreatePane());
|
addToPane(pane, "create", getCreatePane());
|
||||||
|
|
||||||
if ("browse".equals(s_conf.getItemSearchDefaultTab())) {
|
if ("browse".equals(s_conf.getItemSearchDefaultTab())) {
|
||||||
pane.setDefaultPane(m_browse);
|
pane.setDefaultPane(m_browse);
|
||||||
|
|
@ -185,14 +183,10 @@ public class ItemSearchPage extends CMSPage {
|
||||||
if ("search".equals(s_conf.getItemSearchDefaultTab())) {
|
if ("search".equals(s_conf.getItemSearchDefaultTab())) {
|
||||||
pane.setDefaultPane(m_search);
|
pane.setDefaultPane(m_search);
|
||||||
}
|
}
|
||||||
//if ("flatBrowse".equals(s_conf.getItemSearchDefaultTab()) && showFlatBrowsePane) {
|
|
||||||
pane.setDefaultPane(m_flatBrowse);
|
|
||||||
//} else {
|
|
||||||
pane.setDefaultPane(m_browse);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//pane.addActionListener(this);
|
//pane.setDefaultPane(m_flatBrowse);
|
||||||
// pane.setTabVisible(null, pane, true);
|
pane.setDefaultPane(m_browse);
|
||||||
|
|
||||||
return pane;
|
return pane;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -259,4 +253,11 @@ public class ItemSearchPage extends CMSPage {
|
||||||
}.run();
|
}.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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ package com.arsdigita.cms.ui.authoring;
|
||||||
import com.arsdigita.bebop.BoxPanel;
|
import com.arsdigita.bebop.BoxPanel;
|
||||||
import com.arsdigita.bebop.Form;
|
import com.arsdigita.bebop.Form;
|
||||||
import com.arsdigita.bebop.Label;
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.Page;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.event.PrintEvent;
|
import com.arsdigita.bebop.event.PrintEvent;
|
||||||
import com.arsdigita.bebop.event.PrintListener;
|
import com.arsdigita.bebop.event.PrintListener;
|
||||||
|
|
@ -72,20 +73,21 @@ public abstract class NewItemForm extends Form {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public NewItemForm(String name) {
|
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");
|
setIdAttr("new_item_form");
|
||||||
|
|
||||||
BoxPanel panel = (BoxPanel) getPanel();
|
BoxPanel panel = new BoxPanel(BoxPanel.HORIZONTAL);//(BoxPanel) getPanel();
|
||||||
panel.setWidth("2%");
|
panel.setWidth("2%");
|
||||||
panel.setBorder(0);
|
panel.setBorder(0);
|
||||||
|
|
||||||
m_emptyLabel = new Label(globalize("cms.ui.authoring.no_types_registered"), false);
|
m_emptyLabel = new Label(globalize("cms.ui.authoring.no_types_registered"), false);
|
||||||
m_emptyLabel.setIdAttr("empty_label");
|
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 = new Label(globalize("cms.ui.authoring.create_new"), false);
|
||||||
m_createLabel.setIdAttr("create_label");
|
m_createLabel.setIdAttr("create_label");
|
||||||
add(m_createLabel);
|
panel.add(m_createLabel);
|
||||||
|
|
||||||
m_typeWidget = new SingleSelect(new BigDecimalParameter(TYPE_ID));
|
m_typeWidget = new SingleSelect(new BigDecimalParameter(TYPE_ID));
|
||||||
try {
|
try {
|
||||||
|
|
@ -162,11 +164,12 @@ public abstract class NewItemForm extends Form {
|
||||||
throw new UncheckedWrapperException("Too many listeners: " + e.getMessage(), e);
|
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"));
|
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);
|
public abstract ContentSection getContentSection(PageState state);
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,16 @@ package com.arsdigita.cms.ui.folder;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.form.Option;
|
import com.arsdigita.bebop.form.Option;
|
||||||
import com.arsdigita.bebop.form.SingleSelect;
|
import com.arsdigita.bebop.form.SingleSelect;
|
||||||
import com.arsdigita.persistence.DataCollection;
|
import com.arsdigita.cms.CMS;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.cms.ContentSection;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.cms.Folder;
|
||||||
|
import com.arsdigita.cms.ItemCollection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
|
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class FlatFolderPicker extends AbstractFolderPicker {
|
public class FlatFolderPicker extends AbstractFolderPicker {
|
||||||
|
|
||||||
|
|
@ -22,6 +25,18 @@ public class FlatFolderPicker extends AbstractFolderPicker {
|
||||||
}
|
}
|
||||||
|
|
||||||
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()
|
// DataCollection terms = SessionManager.getSession()
|
||||||
// .retrieve(Term.BASE_DATA_OBJECT_TYPE);
|
// .retrieve(Term.BASE_DATA_OBJECT_TYPE);
|
||||||
// terms.addPath("model.id");
|
// terms.addPath("model.id");
|
||||||
|
|
@ -40,4 +55,29 @@ public class FlatFolderPicker extends AbstractFolderPicker {
|
||||||
// terms.get("model.name")));
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,33 +55,18 @@ class Upgrade extends Command {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(Upgrade.class);
|
private static final Logger logger = Logger.getLogger(Upgrade.class);
|
||||||
private static final Options s_options = getOptions();
|
private static final Options s_options = getOptions();
|
||||||
|
|
||||||
private String m_from;
|
private String m_from;
|
||||||
private String m_to;
|
private String m_to;
|
||||||
private final List m_scripts;
|
private final List m_scripts;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
logger.debug("Static initalizer starting...");
|
logger.debug("Static initalizer starting...");
|
||||||
s_options.addOption
|
s_options.addOption(OptionBuilder.isRequired().hasArg().withLongOpt("from-version").withDescription(
|
||||||
(OptionBuilder
|
"Upgrade from version VERSION").create());
|
||||||
.isRequired()
|
s_options.addOption(OptionBuilder.isRequired().hasArg().withLongOpt("to-version").withDescription(
|
||||||
.hasArg()
|
"Upgrade to version VERSION").create());
|
||||||
.withLongOpt("from-version")
|
s_options.addOption(OptionBuilder.hasArg().withLongOpt("parameters").withDescription(
|
||||||
.withDescription("Upgrade from version VERSION")
|
"Parameters to pass to upgrade scripts").create());
|
||||||
.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.");
|
logger.debug("Static initalizer finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -147,8 +132,7 @@ class Upgrade extends Command {
|
||||||
|
|
||||||
final String spec = key + ".upgrade";
|
final String spec = key + ".upgrade";
|
||||||
|
|
||||||
final InputStream in = Thread.currentThread().getContextClassLoader
|
final InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(spec);
|
||||||
().getResourceAsStream(spec);
|
|
||||||
|
|
||||||
if (in == null) {
|
if (in == null) {
|
||||||
System.err.println("Cannot find " + spec);
|
System.err.println("Cannot find " + spec);
|
||||||
|
|
@ -158,18 +142,19 @@ class Upgrade extends Command {
|
||||||
XML.parse(in, new Parser());
|
XML.parse(in, new Parser());
|
||||||
|
|
||||||
if (m_scripts.isEmpty()) {
|
if (m_scripts.isEmpty()) {
|
||||||
System.err.println("No appropriate upgrades found; make sure " +
|
System.err.println("No appropriate upgrades found; make sure " + "that your 'to' and 'from' versions match "
|
||||||
"that your 'to' and 'from' versions match " +
|
+ "the intended upgrade exactly");
|
||||||
"the intended upgrade exactly");
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Number of scripts: " + m_scripts.size() );
|
System.out.println("Number of scripts: " + m_scripts.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator iter = m_scripts.iterator();
|
//Iterator iter = m_scripts.iterator();
|
||||||
while (iter.hasNext()) {
|
//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 classname = parts[0];
|
||||||
final String sql = parts[1];
|
final String sql = parts[1];
|
||||||
|
|
@ -183,7 +168,7 @@ class Upgrade extends Command {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
method = clacc.getMethod("main",
|
method = clacc.getMethod("main",
|
||||||
new Class[] {String[].class});
|
new Class[]{String[].class});
|
||||||
} catch (NoSuchMethodException nsme) {
|
} catch (NoSuchMethodException nsme) {
|
||||||
throw new UncheckedWrapperException(nsme);
|
throw new UncheckedWrapperException(nsme);
|
||||||
} catch (SecurityException se) {
|
} catch (SecurityException se) {
|
||||||
|
|
@ -194,7 +179,7 @@ class Upgrade extends Command {
|
||||||
LinkedList ll = new LinkedList();
|
LinkedList ll = new LinkedList();
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
for (int i = 0; i < params.length; i++) {
|
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++) {
|
for (int j = 0; j < split.length; j++) {
|
||||||
ll.add(split[j]);
|
ll.add(split[j]);
|
||||||
}
|
}
|
||||||
|
|
@ -202,7 +187,7 @@ class Upgrade extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
method.invoke(null, new Object[] {ll.toArray(new String[] {})});
|
method.invoke(null, new Object[]{ll.toArray(new String[]{})});
|
||||||
} catch (IllegalAccessException iae) {
|
} catch (IllegalAccessException iae) {
|
||||||
throw new UncheckedWrapperException(iae);
|
throw new UncheckedWrapperException(iae);
|
||||||
} catch (InvocationTargetException ite) {
|
} catch (InvocationTargetException ite) {
|
||||||
|
|
@ -212,11 +197,9 @@ class Upgrade extends Command {
|
||||||
} else if (sql != null) {
|
} else if (sql != null) {
|
||||||
final SchemaLoader loader = new SchemaLoader(sql);
|
final SchemaLoader loader = new SchemaLoader(sql);
|
||||||
|
|
||||||
System.out.println("Running SQL upgrade " + loader + ", " +
|
System.out.println("Running SQL upgrade " + loader + ", " + "loaded from the classpath");
|
||||||
"loaded from the classpath");
|
|
||||||
|
|
||||||
final Connection conn = Connections.acquire
|
final Connection conn = Connections.acquire(RuntimeConfig.getConfig().getJDBCURL());
|
||||||
(RuntimeConfig.getConfig().getJDBCURL());
|
|
||||||
|
|
||||||
loader.run(conn);
|
loader.run(conn);
|
||||||
|
|
||||||
|
|
@ -238,6 +221,7 @@ class Upgrade extends Command {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private class Parser extends DefaultHandler {
|
private class Parser extends DefaultHandler {
|
||||||
|
|
||||||
private String m_version;
|
private String m_version;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -265,14 +249,12 @@ class Upgrade extends Command {
|
||||||
final String sql = attrs.getValue(uri, "sql");
|
final String sql = attrs.getValue(uri, "sql");
|
||||||
|
|
||||||
if (classname == null && sql == null
|
if (classname == null && sql == null
|
||||||
|| classname != null && sql != null) {
|
|| classname != null && sql != null) {
|
||||||
throw new IllegalArgumentException
|
throw new IllegalArgumentException("The script element must have a 'class' "
|
||||||
("The script element must have a 'class' " +
|
+ "argument or a 'sql' argument; it may not " + "have both");
|
||||||
"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 @@ class Upgrade extends Command {
|
||||||
m_version = null;
|
m_version = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue