Aktueller stand ItemSearchWidget

git-svn-id: https://svn.libreccm.org/ccm/trunk@1759 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2012-07-09 07:27:53 +00:00
parent c321d8d89c
commit 7d1e47dc6f
11 changed files with 204 additions and 109 deletions

View File

@ -1101,3 +1101,5 @@ cms.ui.item_search.flatBrowse=Select item
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

View File

@ -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.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=Order ausw\u00e4hlen

View File

@ -40,3 +40,5 @@ cms.ui.item_search.flatBrowse=Select item
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=

View File

@ -571,3 +571,5 @@ cms.ui.item_search.flatBrowse=Select item
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=

View File

@ -269,7 +269,7 @@ public class FlatItemList extends SegmentedPanel
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")));

View File

@ -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,23 +34,35 @@ import java.math.BigDecimal;
/**
*
* @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 NewItemForm m_newItem;
private SingleSelectionModel m_typeSel;
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();
this.parent = parent;
// m_newItem = new SectionNewItemForm("newItem");
// 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_model = m_tree.getSelectionModel();
@ -52,27 +72,64 @@ class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListen
// 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) {
}
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 {
@ -84,5 +141,6 @@ class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListen
public ContentSection getContentSection(PageState s) {
return CMS.getContext().getContentSection();
}
}
}

View File

@ -65,6 +65,8 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
public ItemSearchFlatBrowsePane(final String name) {
super(name);
setIdAttr("itemSearchFlatBrowse");
final BoxPanel mainPanel = new BoxPanel(BoxPanel.VERTICAL);
queryParam = new StringParameter(QUERY_PARAM);

View File

@ -61,12 +61,11 @@ public class ItemSearchPage extends CMSPage {
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 @@ public class ItemSearchPage extends CMSPage {
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,17 +96,21 @@ public class ItemSearchPage extends CMSPage {
final PageState state = event.getPageState();
final String query = (String) state.getValue(new StringParameter(ItemSearchPopup.QUERY));
if ((query == null) || query.isEmpty()) {
m_tabbedPane.setSelectedIndex(state, 1);
} else {
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 +150,14 @@ public class ItemSearchPage extends CMSPage {
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 +171,11 @@ public class ItemSearchPage extends CMSPage {
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 +183,10 @@ public class ItemSearchPage extends CMSPage {
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 +252,12 @@ public class ItemSearchPage extends CMSPage {
}.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);
}
}

View File

@ -21,6 +21,7 @@ package com.arsdigita.cms.ui.authoring;
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 abstract class NewItemForm extends Form {
*
*/
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 @@ public abstract class NewItemForm extends Form {
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);

View File

@ -7,21 +7,36 @@ package com.arsdigita.cms.ui.folder;
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) <sbernstein@zes.uni-bremen.de>
* @author Jens Pelzetter <jens@jp-digital.de>
* @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 @@ public class FlatFolderPicker extends AbstractFolderPicker {
// 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);
}
}
}

View File

@ -55,33 +55,18 @@ class Upgrade extends Command {
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 @@ class Upgrade extends Command {
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 @@ class Upgrade extends Command {
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 @@ class Upgrade extends Command {
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 @@ class Upgrade extends Command {
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 @@ class Upgrade extends Command {
}
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 @@ class Upgrade extends Command {
} 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 @@ class Upgrade extends Command {
}
/**
*
*
*/
private class Parser extends DefaultHandler {
private String m_version;
@Override
@ -265,14 +249,12 @@ class Upgrade extends Command {
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 @@ class Upgrade extends Command {
m_version = null;
}
}
}
}