ItemSearchWidget
* Der Basisordner wird nun automatisch aufgeklappt. Ich habe dafür die isVisible-Methode überschrieben. Ich bin mir nicht sicher, daß das die richtige Vorgehensweise ist, aber mir ist keine besser eingefallen. git-svn-id: https://svn.libreccm.org/ccm/trunk@801 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
eaaf561d73
commit
8dcc07ac9b
|
|
@ -24,7 +24,10 @@ import com.arsdigita.bebop.Label;
|
||||||
import com.arsdigita.bebop.Page;
|
import com.arsdigita.bebop.Page;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.Resettable;
|
import com.arsdigita.bebop.Resettable;
|
||||||
|
import com.arsdigita.bebop.SingleSelectionModel;
|
||||||
import com.arsdigita.bebop.Tree;
|
import com.arsdigita.bebop.Tree;
|
||||||
|
import com.arsdigita.bebop.event.ActionEvent;
|
||||||
|
import com.arsdigita.bebop.event.ActionListener;
|
||||||
import com.arsdigita.bebop.event.ChangeEvent;
|
import com.arsdigita.bebop.event.ChangeEvent;
|
||||||
import com.arsdigita.bebop.event.ChangeListener;
|
import com.arsdigita.bebop.event.ChangeListener;
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
|
@ -36,6 +39,8 @@ import com.arsdigita.bebop.event.TreeExpansionListener;
|
||||||
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.bebop.form.Submit;
|
import com.arsdigita.bebop.form.Submit;
|
||||||
|
import com.arsdigita.cms.SecurityManager;
|
||||||
|
import com.arsdigita.cms.dispatcher.Utilities;
|
||||||
import com.arsdigita.domain.DomainObjectFactory;
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
import com.arsdigita.toolbox.ui.OIDParameter;
|
import com.arsdigita.toolbox.ui.OIDParameter;
|
||||||
|
|
@ -44,10 +49,12 @@ import com.arsdigita.cms.CMS;
|
||||||
import com.arsdigita.cms.ContentSection;
|
import com.arsdigita.cms.ContentSection;
|
||||||
import com.arsdigita.cms.ContentSectionCollection;
|
import com.arsdigita.cms.ContentSectionCollection;
|
||||||
import com.arsdigita.cms.Folder;
|
import com.arsdigita.cms.Folder;
|
||||||
import com.arsdigita.cms.ui.CMSContainer;
|
import com.arsdigita.cms.ui.authoring.NewItemForm;
|
||||||
|
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;
|
||||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
|
@ -67,11 +74,15 @@ public class ItemSearchBrowsePane extends CMSContainer
|
||||||
private static final Logger s_log =
|
private static final Logger s_log =
|
||||||
Logger.getLogger(ItemSearchBrowsePane.class);
|
Logger.getLogger(ItemSearchBrowsePane.class);
|
||||||
private FolderSelectionModel m_folderSel;
|
private FolderSelectionModel m_folderSel;
|
||||||
|
private FolderRequestLocal m_folder;
|
||||||
private Tree m_tree;
|
private Tree m_tree;
|
||||||
private ItemSearchFolderBrowser m_browser;
|
private ItemSearchFolderBrowser m_browser;
|
||||||
private SingleSelect m_section;
|
private SingleSelect m_section;
|
||||||
|
// private NewItemForm m_newItem;
|
||||||
|
private SingleSelectionModel m_typeSel;
|
||||||
|
|
||||||
public ItemSearchBrowsePane() {
|
public ItemSearchBrowsePane() {
|
||||||
|
|
||||||
setClassAttr("sidebarNavPanel");
|
setClassAttr("sidebarNavPanel");
|
||||||
setAttribute("navbar-title", GlobalizationUtil.globalize("cms.ui.folder_browser").localize().toString());
|
setAttribute("navbar-title", GlobalizationUtil.globalize("cms.ui.folder_browser").localize().toString());
|
||||||
|
|
||||||
|
|
@ -99,6 +110,7 @@ public class ItemSearchBrowsePane extends CMSContainer
|
||||||
});
|
});
|
||||||
m_folderSel = createFolderSelectionModel();
|
m_folderSel = createFolderSelectionModel();
|
||||||
m_folderSel.addChangeListener(this);
|
m_folderSel.addChangeListener(this);
|
||||||
|
m_folder = new FolderRequestLocal(m_folderSel);
|
||||||
|
|
||||||
if (!linksOnlyInSameSubsite) {
|
if (!linksOnlyInSameSubsite) {
|
||||||
// The client should be able to pick between the subsites
|
// The client should be able to pick between the subsites
|
||||||
|
|
@ -119,9 +131,23 @@ public class ItemSearchBrowsePane extends CMSContainer
|
||||||
container.add(m_browser);
|
container.add(m_browser);
|
||||||
container.add(m_browser.getPaginator());
|
container.add(m_browser.getPaginator());
|
||||||
|
|
||||||
|
// m_newItem = new SectionNewItemForm("newItem");
|
||||||
|
// m_newItem.addProcessListener(this);
|
||||||
|
// container.add(m_newItem);
|
||||||
|
|
||||||
add(container);
|
add(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVisible(PageState s) {
|
||||||
|
// Always expand root node
|
||||||
|
if (m_tree.isCollapsed(getRootFolder(s).getID().toString(), s)) {
|
||||||
|
m_tree.expand(getRootFolder(s).getID().toString(), s);
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.isVisible(s);
|
||||||
|
}
|
||||||
|
|
||||||
private Form getSectionForm() {
|
private Form getSectionForm() {
|
||||||
Form sectionForm = new Form("isfbSectionForm",
|
Form sectionForm = new Form("isfbSectionForm",
|
||||||
new BoxPanel(BoxPanel.HORIZONTAL));
|
new BoxPanel(BoxPanel.HORIZONTAL));
|
||||||
|
|
@ -137,6 +163,7 @@ public class ItemSearchBrowsePane extends CMSContainer
|
||||||
|
|
||||||
sectionForm.addInitListener(new FormInitListener() {
|
sectionForm.addInitListener(new FormInitListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
public void init(FormSectionEvent ev) {
|
public void init(FormSectionEvent ev) {
|
||||||
PageState ps = ev.getPageState();
|
PageState ps = ev.getPageState();
|
||||||
|
|
||||||
|
|
@ -178,6 +205,7 @@ public class ItemSearchBrowsePane extends CMSContainer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void register(Page p) {
|
public void register(Page p) {
|
||||||
super.register(p);
|
super.register(p);
|
||||||
p.addComponentStateParam(this, m_folderSel.getStateParameter());
|
p.addComponentStateParam(this, m_folderSel.getStateParameter());
|
||||||
|
|
@ -186,8 +214,46 @@ public class ItemSearchBrowsePane extends CMSContainer
|
||||||
if (m_section != null) {
|
if (m_section != null) {
|
||||||
p.addComponentStateParam(this, m_section.getParameterModel());
|
p.addComponentStateParam(this, m_section.getParameterModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save the state of the new item component
|
||||||
|
// p.addComponentStateParam(this, m_typeSel.getStateParameter());
|
||||||
|
|
||||||
|
p.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
final PageState state = e.getPageState();
|
||||||
|
|
||||||
|
if (state.isVisibleOnPage(ItemSearchBrowsePane.this)) {
|
||||||
|
showHideSegments(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show/hide segments based on access checks.
|
||||||
|
*
|
||||||
|
* @param state The page state
|
||||||
|
* @pre ( state != null )
|
||||||
|
*/
|
||||||
|
private void showHideSegments(PageState state) {
|
||||||
|
SecurityManager sm = Utilities.getSecurityManager(state);
|
||||||
|
Folder folder = m_folder.getFolder(state);
|
||||||
|
Assert.exists(folder);
|
||||||
|
|
||||||
|
// MP: This should be checked on the current folder instead of just
|
||||||
|
// the content section.
|
||||||
|
// boolean newItem =
|
||||||
|
// sm.canAccess(state.getRequest(), SecurityManager.NEW_ITEM, folder);
|
||||||
|
//
|
||||||
|
// if (!newItem) {
|
||||||
|
browseMode(state);
|
||||||
|
// }
|
||||||
|
// m_newItem.setVisible(state, newItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void reset(PageState s) {
|
public void reset(PageState s) {
|
||||||
//m_browser.reset(s);
|
//m_browser.reset(s);
|
||||||
}
|
}
|
||||||
|
|
@ -220,15 +286,18 @@ public class ItemSearchBrowsePane extends CMSContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implement TreeExpansionListener
|
// Implement TreeExpansionListener
|
||||||
|
@Override
|
||||||
public void treeCollapsed(TreeExpansionEvent e) {
|
public void treeCollapsed(TreeExpansionEvent e) {
|
||||||
PageState s = e.getPageState();
|
PageState s = e.getPageState();
|
||||||
m_folderSel.setSelectedKey(s, e.getNodeKey());
|
m_folderSel.setSelectedKey(s, e.getNodeKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void treeExpanded(TreeExpansionEvent e) {
|
public void treeExpanded(TreeExpansionEvent e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void stateChanged(ChangeEvent e) {
|
public void stateChanged(ChangeEvent e) {
|
||||||
PageState s = e.getPageState();
|
PageState s = e.getPageState();
|
||||||
Folder current = (Folder) m_folderSel.getSelectedObject(s);
|
Folder current = (Folder) m_folderSel.getSelectedObject(s);
|
||||||
|
|
@ -242,32 +311,43 @@ public class ItemSearchBrowsePane extends CMSContainer
|
||||||
//m_browser.setPermissionLinkVis(s);
|
//m_browser.setPermissionLinkVis(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void process(FormSectionEvent e) {
|
public void process(FormSectionEvent e) {
|
||||||
/*
|
|
||||||
PageState s = e.getPageState();
|
PageState s = e.getPageState();
|
||||||
if ( e.getSource() == m_browser.getManipulator().getItemView() ) {
|
final Object source = e.getSource();
|
||||||
// Hide everything except for the flat item list
|
// if (source == m_newItem) {
|
||||||
m_tree.setVisible(s, false);
|
// BigDecimal typeID = m_newItem.getTypeID(s);
|
||||||
} else if ( e.getSource() == m_browser.getManipulator().getTargetSelector() ) {
|
// m_typeSel.setSelectedKey(s, typeID);
|
||||||
m_tree.setVisible(s, true);
|
// newItemMode(s);
|
||||||
}
|
// } else {
|
||||||
*/
|
browseMode(s);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void submitted(FormSectionEvent e) {
|
public void submitted(FormSectionEvent e) {
|
||||||
/*
|
|
||||||
PageState s = e.getPageState();
|
PageState s = e.getPageState();
|
||||||
if ( e.getSource() == m_browser.getManipulator().getTargetSelector() ) {
|
final Object source = e.getSource();
|
||||||
if ( ! m_browser.getManipulator().getTargetSelector().isVisible(s) ) {
|
// if (source == m_newItem) {
|
||||||
m_tree.setVisible(s, true);
|
// BigDecimal typeID = m_newItem.getTypeID(s);
|
||||||
}
|
// m_typeSel.setSelectedKey(s, typeID);
|
||||||
}
|
// //newItemMode(s);
|
||||||
*/
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void browseMode(PageState s) {
|
||||||
|
// m_browseSeg.setVisible(s, true);
|
||||||
|
// m_typeSel.clearSelection(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void newItemMode(PageState s) {
|
||||||
|
// m_newItemSeg.setVisible(s, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private FolderSelectionModel createFolderSelectionModel() {
|
private FolderSelectionModel createFolderSelectionModel() {
|
||||||
return new FolderSelectionModel("folder") {
|
return new FolderSelectionModel("folder") {
|
||||||
|
|
||||||
|
@Override
|
||||||
protected BigDecimal getRootFolderID(PageState ps) {
|
protected BigDecimal getRootFolderID(PageState ps) {
|
||||||
Folder root = getRootFolder(ps);
|
Folder root = getRootFolder(ps);
|
||||||
|
|
||||||
|
|
@ -278,4 +358,16 @@ public class ItemSearchBrowsePane extends CMSContainer
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class SectionNewItemForm extends NewItemForm {
|
||||||
|
|
||||||
|
public SectionNewItemForm(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ContentSection getContentSection(PageState s) {
|
||||||
|
return CMS.getContext().getContentSection();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ public class ItemSearchPage extends CMSPage {
|
||||||
private TabbedPane m_tabbedPane;
|
private TabbedPane m_tabbedPane;
|
||||||
private ItemSearchBrowsePane m_browse;
|
private ItemSearchBrowsePane m_browse;
|
||||||
private ItemSearchPopup m_search;
|
private ItemSearchPopup m_search;
|
||||||
|
// 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();
|
||||||
public static final String CONTENT_SECTION = "section_id";
|
public static final String CONTENT_SECTION = "section_id";
|
||||||
|
|
@ -75,6 +76,7 @@ public class ItemSearchPage extends CMSPage {
|
||||||
|
|
||||||
m_browse = getBrowsePane();
|
m_browse = getBrowsePane();
|
||||||
m_search = getSearchPane();
|
m_search = getSearchPane();
|
||||||
|
// m_create = getCreatePane();
|
||||||
|
|
||||||
m_tabbedPane = createTabbedPane();
|
m_tabbedPane = createTabbedPane();
|
||||||
m_tabbedPane.setIdAttr("page-body");
|
m_tabbedPane.setIdAttr("page-body");
|
||||||
|
|
@ -106,6 +108,14 @@ public class ItemSearchPage extends CMSPage {
|
||||||
return m_search;
|
return m_search;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// protected ItemSearchCreateItemPane getCreatePane() {
|
||||||
|
// if(m_create == null) {
|
||||||
|
// m_create = new ItemSearchCreateItemPane();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return m_create;
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created the TabbedPane to use for this page. Sets the class
|
* Created the TabbedPane to use for this page. Sets the class
|
||||||
* attribute for this tabbed pane. The default implementation uses a
|
* attribute for this tabbed pane. The default implementation uses a
|
||||||
|
|
@ -123,6 +133,7 @@ public class ItemSearchPage extends CMSPage {
|
||||||
|
|
||||||
addToPane(pane, "browse", getBrowsePane());
|
addToPane(pane, "browse", getBrowsePane());
|
||||||
addToPane(pane, "search", getSearchPane());
|
addToPane(pane, "search", getSearchPane());
|
||||||
|
// addToPane(pane, "create", getCreatePane());
|
||||||
|
|
||||||
if(s_conf.getItemSearchDefaultTab().equals("browse")) {
|
if(s_conf.getItemSearchDefaultTab().equals("browse")) {
|
||||||
pane.setDefaultPane(m_browse);
|
pane.setDefaultPane(m_browse);
|
||||||
|
|
@ -175,6 +186,7 @@ public class ItemSearchPage extends CMSPage {
|
||||||
throws IOException, ServletException {
|
throws IOException, ServletException {
|
||||||
new CMSExcursion() {
|
new CMSExcursion() {
|
||||||
|
|
||||||
|
@Override
|
||||||
public void excurse()
|
public void excurse()
|
||||||
throws IOException, ServletException {
|
throws IOException, ServletException {
|
||||||
ContentSection section = null;
|
ContentSection section = null;
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ public class FolderTreeModelBuilder extends LockableImpl
|
||||||
* @return a tree model that lists the hierarchy of folders underneath the
|
* @return a tree model that lists the hierarchy of folders underneath the
|
||||||
* folder returnedby {@link #getRoot getRoot}.
|
* folder returnedby {@link #getRoot getRoot}.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public com.arsdigita.bebop.tree.TreeModel makeModel(final Tree t, PageState s) {
|
public com.arsdigita.bebop.tree.TreeModel makeModel(final Tree t, PageState s) {
|
||||||
return new DataQueryTreeModel(getRoot(s).getID(),
|
return new DataQueryTreeModel(getRoot(s).getID(),
|
||||||
"com.arsdigita.cms.getRootFolder",
|
"com.arsdigita.cms.getRootFolder",
|
||||||
|
|
@ -81,7 +82,7 @@ public class FolderTreeModelBuilder extends LockableImpl
|
||||||
String nodeKey = node.getKey().toString();
|
String nodeKey = node.getKey().toString();
|
||||||
|
|
||||||
// Always expand root node
|
// Always expand root node
|
||||||
if (nodeKey.equals(getRoot(data).getKey().toString())/* && t.isCollapsed(nodeKey, data)*/) {
|
if (nodeKey.equals(getRoot(data).getKey().toString()) && t.isCollapsed(nodeKey, data)) {
|
||||||
t.expand(nodeKey, data);
|
t.expand(nodeKey, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -187,6 +188,7 @@ public class FolderTreeModelBuilder extends LockableImpl
|
||||||
new String[]{"id", "name", "nchild"});
|
new String[]{"id", "name", "nchild"});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object next() {
|
public Object next() {
|
||||||
BigDecimal id = new BigDecimal(0);
|
BigDecimal id = new BigDecimal(0);
|
||||||
try {
|
try {
|
||||||
|
|
@ -205,10 +207,12 @@ public class FolderTreeModelBuilder extends LockableImpl
|
||||||
return new DataQueryTreeNode(id, name, count.intValue() > 0);
|
return new DataQueryTreeNode(id, name, count.intValue() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
throw new UnsupportedOperationException("cannot remove nodes via iterator");
|
throw new UnsupportedOperationException("cannot remove nodes via iterator");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return m_nodes.next();
|
return m_nodes.next();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue