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.PageState;
|
||||
import com.arsdigita.bebop.Resettable;
|
||||
import com.arsdigita.bebop.SingleSelectionModel;
|
||||
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.ChangeListener;
|
||||
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.SingleSelect;
|
||||
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.persistence.OID;
|
||||
import com.arsdigita.toolbox.ui.OIDParameter;
|
||||
|
|
@ -44,10 +49,12 @@ import com.arsdigita.cms.CMS;
|
|||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.ContentSectionCollection;
|
||||
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.FolderTreeModelBuilder;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import com.arsdigita.util.Assert;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
|
@ -67,11 +74,15 @@ public class ItemSearchBrowsePane extends CMSContainer
|
|||
private static final Logger s_log =
|
||||
Logger.getLogger(ItemSearchBrowsePane.class);
|
||||
private FolderSelectionModel m_folderSel;
|
||||
private FolderRequestLocal m_folder;
|
||||
private Tree m_tree;
|
||||
private ItemSearchFolderBrowser m_browser;
|
||||
private SingleSelect m_section;
|
||||
// private NewItemForm m_newItem;
|
||||
private SingleSelectionModel m_typeSel;
|
||||
|
||||
public ItemSearchBrowsePane() {
|
||||
|
||||
setClassAttr("sidebarNavPanel");
|
||||
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.addChangeListener(this);
|
||||
m_folder = new FolderRequestLocal(m_folderSel);
|
||||
|
||||
if (!linksOnlyInSameSubsite) {
|
||||
// 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.getPaginator());
|
||||
|
||||
// m_newItem = new SectionNewItemForm("newItem");
|
||||
// m_newItem.addProcessListener(this);
|
||||
// container.add(m_newItem);
|
||||
|
||||
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() {
|
||||
Form sectionForm = new Form("isfbSectionForm",
|
||||
new BoxPanel(BoxPanel.HORIZONTAL));
|
||||
|
|
@ -137,6 +163,7 @@ public class ItemSearchBrowsePane extends CMSContainer
|
|||
|
||||
sectionForm.addInitListener(new FormInitListener() {
|
||||
|
||||
@Override
|
||||
public void init(FormSectionEvent ev) {
|
||||
PageState ps = ev.getPageState();
|
||||
|
||||
|
|
@ -178,6 +205,7 @@ public class ItemSearchBrowsePane extends CMSContainer
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(Page p) {
|
||||
super.register(p);
|
||||
p.addComponentStateParam(this, m_folderSel.getStateParameter());
|
||||
|
|
@ -186,8 +214,46 @@ public class ItemSearchBrowsePane extends CMSContainer
|
|||
if (m_section != null) {
|
||||
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) {
|
||||
//m_browser.reset(s);
|
||||
}
|
||||
|
|
@ -220,15 +286,18 @@ public class ItemSearchBrowsePane extends CMSContainer
|
|||
}
|
||||
|
||||
// Implement TreeExpansionListener
|
||||
@Override
|
||||
public void treeCollapsed(TreeExpansionEvent e) {
|
||||
PageState s = e.getPageState();
|
||||
m_folderSel.setSelectedKey(s, e.getNodeKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void treeExpanded(TreeExpansionEvent e) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
PageState s = e.getPageState();
|
||||
Folder current = (Folder) m_folderSel.getSelectedObject(s);
|
||||
|
|
@ -242,32 +311,43 @@ public class ItemSearchBrowsePane extends CMSContainer
|
|||
//m_browser.setPermissionLinkVis(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(FormSectionEvent e) {
|
||||
/*
|
||||
PageState s = e.getPageState();
|
||||
if ( e.getSource() == m_browser.getManipulator().getItemView() ) {
|
||||
// Hide everything except for the flat item list
|
||||
m_tree.setVisible(s, false);
|
||||
} else if ( e.getSource() == m_browser.getManipulator().getTargetSelector() ) {
|
||||
m_tree.setVisible(s, true);
|
||||
}
|
||||
*/
|
||||
final Object source = e.getSource();
|
||||
// if (source == m_newItem) {
|
||||
// BigDecimal typeID = m_newItem.getTypeID(s);
|
||||
// m_typeSel.setSelectedKey(s, typeID);
|
||||
// newItemMode(s);
|
||||
// } else {
|
||||
browseMode(s);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submitted(FormSectionEvent e) {
|
||||
/*
|
||||
PageState s = e.getPageState();
|
||||
if ( e.getSource() == m_browser.getManipulator().getTargetSelector() ) {
|
||||
if ( ! m_browser.getManipulator().getTargetSelector().isVisible(s) ) {
|
||||
m_tree.setVisible(s, true);
|
||||
}
|
||||
}
|
||||
*/
|
||||
final Object source = e.getSource();
|
||||
// if (source == m_newItem) {
|
||||
// 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() {
|
||||
return new FolderSelectionModel("folder") {
|
||||
|
||||
@Override
|
||||
protected BigDecimal getRootFolderID(PageState 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 ItemSearchBrowsePane m_browse;
|
||||
private ItemSearchPopup m_search;
|
||||
// private ItemSearchCreateItemPane m_create;
|
||||
private BigDecimalParameter m_sectionId;
|
||||
private static final CMSConfig s_conf = CMSConfig.getInstance();
|
||||
public static final String CONTENT_SECTION = "section_id";
|
||||
|
|
@ -75,6 +76,7 @@ public class ItemSearchPage extends CMSPage {
|
|||
|
||||
m_browse = getBrowsePane();
|
||||
m_search = getSearchPane();
|
||||
// m_create = getCreatePane();
|
||||
|
||||
m_tabbedPane = createTabbedPane();
|
||||
m_tabbedPane.setIdAttr("page-body");
|
||||
|
|
@ -106,6 +108,14 @@ public class ItemSearchPage extends CMSPage {
|
|||
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
|
||||
* 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, "search", getSearchPane());
|
||||
// addToPane(pane, "create", getCreatePane());
|
||||
|
||||
if(s_conf.getItemSearchDefaultTab().equals("browse")) {
|
||||
pane.setDefaultPane(m_browse);
|
||||
|
|
@ -175,6 +186,7 @@ public class ItemSearchPage extends CMSPage {
|
|||
throws IOException, ServletException {
|
||||
new CMSExcursion() {
|
||||
|
||||
@Override
|
||||
public void excurse()
|
||||
throws IOException, ServletException {
|
||||
ContentSection section = null;
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ public class FolderTreeModelBuilder extends LockableImpl
|
|||
* @return a tree model that lists the hierarchy of folders underneath the
|
||||
* folder returnedby {@link #getRoot getRoot}.
|
||||
*/
|
||||
@Override
|
||||
public com.arsdigita.bebop.tree.TreeModel makeModel(final Tree t, PageState s) {
|
||||
return new DataQueryTreeModel(getRoot(s).getID(),
|
||||
"com.arsdigita.cms.getRootFolder",
|
||||
|
|
@ -81,7 +82,7 @@ public class FolderTreeModelBuilder extends LockableImpl
|
|||
String nodeKey = node.getKey().toString();
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
|
@ -187,6 +188,7 @@ public class FolderTreeModelBuilder extends LockableImpl
|
|||
new String[]{"id", "name", "nchild"});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object next() {
|
||||
BigDecimal id = new BigDecimal(0);
|
||||
try {
|
||||
|
|
@ -205,10 +207,12 @@ public class FolderTreeModelBuilder extends LockableImpl
|
|||
return new DataQueryTreeNode(id, name, count.intValue() > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException("cannot remove nodes via iterator");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return m_nodes.next();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue