libreccm/ccm-cms/src/main/java/com/arsdigita/cms/ui/BrowsePane.java

162 lines
5.0 KiB
Java
Executable File

/*
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.ui;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Resettable;
import com.arsdigita.bebop.SegmentedPanel;
import com.arsdigita.bebop.SingleSelectionModel;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.event.ActionEvent;
import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.cms.CMS;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.toolbox.ui.LayoutPanel;
import org.libreccm.categorization.Category;
import org.libreccm.cdi.utils.CdiUtil;
import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.Folder;
import java.util.List;
/**
* A pane that contains a folder tree on the left and a folder manipulator on
* the right. It is a part of the content section main page and is displayed as
* the "Browse" tab.
*
* @author David LutterKort <dlutter@redhat.com>
* @author <a href="jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class BrowsePane extends LayoutPanel implements Resettable {
private SingleSelectionModel selectionModel;
private FlatItemList flatItemList;
public BrowsePane() {
final SegmentedPanel left = new SegmentedPanel();
setLeft(left);
final Label heading = new Label(
new GlobalizedMessage("cms.ui.folder_browser",
CmsConstants.CMS_BUNDLE));
}
@Override
public final void register(final Page page) {
super.register(page);
page.addActionListener(new FolderListener());
page.addActionListener(new TreeListener());
}
@Override
public final void reset(final PageState state) {
super.reset(state);
flatItemList.reset(state);
}
// Private classes and methods
/**
*
*/
private final class ProcessListener implements FormProcessListener {
@Override
public final void process(final FormSectionEvent event) {
final PageState state = event.getPageState();
}
}
private final class SubmissionListener implements FormSubmissionListener {
@Override
public final void submitted(final FormSectionEvent event) {
final PageState state = event.getPageState();
}
}
private final class FolderListener implements ActionListener {
@Override
public final void actionPerformed(final ActionEvent event) {
final PageState state = event.getPageState();
if (!selectionModel.isSelected(state)) {
final String folder = state
.getRequest()
.getParameter(ContentSectionPage.SET_FOLDER);
if (folder == null) {
final Category root = CMS
.getContext()
.getContentSection()
.getRootDocumentsFolder();
final Long folderID = root.getObjectId();
/*
ToDo
User user = Web.getWebContext().getUser();
if (user != null) {
Folder homeFolder = Folder.getUserHomeFolder(
user, CMS.getContext().getContentSection());
if (homeFolder != null) {
folderID = homeFolder.getID();
}
}*/
selectionModel.setSelectedKey(state, folderID);
} else {
selectionModel.setSelectedKey(state, Long.parseLong(folder));
}
}
}
}
private final class TreeListener implements ActionListener {
@Override
public final void actionPerformed(final ActionEvent event) {
final PageState state = event.getPageState();
final Category root = CMS
.getContext()
.getContentSection()
.getRootDocumentsFolder();
}
}
}