ItemSearchWidget aktueller Stand
git-svn-id: https://svn.libreccm.org/ccm/trunk@1772 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
9eca176561
commit
b988c2de2b
|
|
@ -5,7 +5,7 @@
|
|||
package com.arsdigita.cms.ui;
|
||||
|
||||
import com.arsdigita.bebop.BoxPanel;
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.FormData;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Link;
|
||||
|
|
@ -15,7 +15,7 @@ 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.FormCancelListener;
|
||||
import com.arsdigita.bebop.event.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||
|
|
@ -25,32 +25,31 @@ import com.arsdigita.bebop.form.Option;
|
|||
import com.arsdigita.bebop.form.SingleSelect;
|
||||
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.AuthoringKit;
|
||||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ContentPage;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.ContentType;
|
||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||
import com.arsdigita.cms.ui.authoring.CreationSelector;
|
||||
import com.arsdigita.cms.ui.authoring.NewItemForm;
|
||||
import com.arsdigita.cms.ui.authoring.WizardSelector;
|
||||
import com.arsdigita.cms.ui.folder.FlatFolderPicker;
|
||||
import com.arsdigita.cms.ui.folder.FolderRequestLocal;
|
||||
import com.arsdigita.cms.ui.folder.FolderSelectionModel;
|
||||
import com.arsdigita.cms.ui.item.ContentItemRequestLocal;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.web.RedirectSignal;
|
||||
import com.arsdigita.web.URL;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.TooManyListenersException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
*/
|
||||
class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListener, FormSubmissionListener {
|
||||
class ItemSearchCreateItemPane extends CMSContainer implements FormInitListener,
|
||||
FormProcessListener,
|
||||
FormSubmissionListener {
|
||||
|
||||
public static final String WIDGET_PARAM = "widget";
|
||||
public static final String SEARCHWIDGET_PARAM = "searchWidget";
|
||||
|
|
@ -60,12 +59,10 @@ class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListen
|
|||
private final NewItemForm m_newItem;
|
||||
private final SingleSelectionModel m_typeSel;
|
||||
private final 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 final FolderSelectionModel m_folderSel; // To support legacy UI code
|
||||
private String defaultFolder;
|
||||
private final CreationSelector m_creator;
|
||||
private final ItemSearchPage m_parent;
|
||||
private final ContentItemRequestLocal m_contentItem = new ContentItemRequestLocal() {
|
||||
};
|
||||
private final Link m_selectCloseLink;
|
||||
|
|
@ -78,41 +75,25 @@ class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListen
|
|||
public ItemSearchCreateItemPane(final ItemSearchPage parent) {
|
||||
super();
|
||||
|
||||
this.m_parent = parent;
|
||||
|
||||
m_segPanel = new SegmentedPanel("itemSearchCreate");
|
||||
m_creationSeg = new Segment();
|
||||
m_newItemSeg = new Segment();
|
||||
m_linkSeg = new Segment();
|
||||
|
||||
m_newItem = new SectionNewItemForm("newItem");
|
||||
//m_newItem.addProcessListener(this);
|
||||
|
||||
//m_tree = new BaseTree(new FolderTreeModelBuilder());
|
||||
//m_model = m_tree.getSelectionModel();
|
||||
m_model = new ParameterSingleSelectionModel(new BigDecimalParameter(FOLDER_ID));
|
||||
m_folderSel = new FolderSelectionModel(m_model);
|
||||
m_folder = new FolderRequestLocal(m_folderSel);
|
||||
|
||||
// m_newItemSeg = addSegment();
|
||||
this.setIdAttr("folder-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_creator = new CreationSelector(m_typeSel, m_folderSel) {
|
||||
|
||||
@Override
|
||||
public void editItem(final PageState state, final ContentItem item) {
|
||||
|
||||
//final ContentSection section = getContentSection(state);
|
||||
//final String nodeURL = URL.getDispatcherPath() + section.getPath() + "/";
|
||||
//final String target = ItemSearchContentItemPage.getItemURL(nodeURL, item.getID(),
|
||||
// ContentItemPage.AUTHORING_TAB, true);
|
||||
|
||||
//throw new RedirectSignal(target, true);
|
||||
|
||||
m_creationSeg.setVisible(state, false);
|
||||
m_linkSeg.setVisible(state, true);
|
||||
|
||||
|
|
@ -126,12 +107,11 @@ class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListen
|
|||
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.addInitListener(this);
|
||||
m_newItem.addProcessListener(this);
|
||||
m_newItem.addSubmissionListener(this);
|
||||
|
||||
|
|
@ -234,6 +214,17 @@ class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListen
|
|||
page.addComponentStateParam(this, m_folderSel.getStateParameter());
|
||||
}
|
||||
|
||||
public void init(final FormSectionEvent fse) throws FormProcessException {
|
||||
final PageState state = fse.getPageState();
|
||||
final FormData data = fse.getFormData();
|
||||
if (((data.get("flatFolder") == null) || "".equals(data.get("flatFolder")))
|
||||
&& (defaultFolder != null)) {
|
||||
data.put("flatFolder", defaultFolder.toString());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void submitted(final FormSectionEvent fse) {
|
||||
final PageState state = fse.getPageState();
|
||||
|
||||
|
|
@ -260,4 +251,13 @@ class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListen
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
protected String getDefaultFolder() {
|
||||
return defaultFolder;
|
||||
}
|
||||
|
||||
protected void setDefaultFolder(final String defaultFolder) {
|
||||
this.defaultFolder = defaultFolder;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
|||
private final Table resultsTable;
|
||||
private final Paginator paginator;
|
||||
private final StringParameter queryParam;
|
||||
private final Submit submit;
|
||||
private final static CMSConfig CMS_CONFIG = CMSConfig.getInstance();
|
||||
|
||||
public ItemSearchFlatBrowsePane(final String name) {
|
||||
|
|
@ -69,7 +70,8 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
|||
boxPanel.add(new Label(GlobalizationUtil.globalize("cms.ui.item_search.flat.filter")));
|
||||
final TextField filter = new TextField(new StringParameter(QUERY_PARAM));
|
||||
boxPanel.add(filter);
|
||||
boxPanel.add(new Submit(FILTER_SUBMIT, GlobalizationUtil.globalize("cms.ui.item_search.flat.filter.submit")));
|
||||
submit = new Submit(FILTER_SUBMIT, GlobalizationUtil.globalize("cms.ui.item_search.flat.filter.submit"));
|
||||
boxPanel.add(submit);
|
||||
mainPanel.add(boxPanel);
|
||||
|
||||
resultsTable = new ResultsTable();
|
||||
|
|
@ -179,13 +181,14 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
|||
final ContentType type = new ContentType(typeId);
|
||||
collection.set(state, session.retrieve(type.getClassName()));
|
||||
}
|
||||
((DataCollection)collection.get(state)).addFilter("version = 'draft'");
|
||||
|
||||
final String query = (String) state.getValue(queryParam);
|
||||
if ((query != null) && !query.isEmpty()) {
|
||||
((DataCollection) collection.get(state)).addFilter(String.format(
|
||||
"(lower(%s) like lower('%%%s%%')) or (lower(%s) like lower('%%%s%%'))",
|
||||
"((lower(%s) like lower('%%%s%%')) or (lower(%s) like lower('%%%s%%')))",
|
||||
ContentItem.NAME, query,
|
||||
ContentPage.TITLE, query));
|
||||
ContentPage.TITLE, query));
|
||||
}
|
||||
|
||||
((DataCollection) collection.get(state)).addOrder("title asc, name asc");
|
||||
|
|
@ -302,6 +305,9 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
|||
|
||||
return link;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected Submit getSubmit() {
|
||||
return submit;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,18 +25,21 @@ import com.arsdigita.bebop.TabbedPane;
|
|||
import com.arsdigita.bebop.event.RequestEvent;
|
||||
import com.arsdigita.bebop.event.RequestListener;
|
||||
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||
import com.arsdigita.bebop.parameters.IntegerParameter;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.CMSConfig;
|
||||
import com.arsdigita.cms.CMSExcursion;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.Folder;
|
||||
import com.arsdigita.cms.dispatcher.CMSPage;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import com.arsdigita.dispatcher.RequestContext;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.templating.PresentationManager;
|
||||
import com.arsdigita.templating.Templating;
|
||||
import com.arsdigita.toolbox.ui.OIDParameter;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
import com.arsdigita.xml.Document;
|
||||
import com.arsdigita.web.Web;
|
||||
|
|
@ -63,6 +66,7 @@ public class ItemSearchPage extends CMSPage {
|
|||
private ItemSearchPopup m_search;
|
||||
private ItemSearchCreateItemPane m_create;
|
||||
private BigDecimalParameter m_sectionId;
|
||||
private int m_lastTab;
|
||||
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";
|
||||
|
|
@ -79,7 +83,8 @@ public class ItemSearchPage extends CMSPage {
|
|||
addGlobalStateParam(new StringParameter(ItemSearchPopup.WIDGET_PARAM));
|
||||
addGlobalStateParam(new StringParameter("searchWidget"));
|
||||
addGlobalStateParam(new StringParameter("publishWidget"));
|
||||
|
||||
addGlobalStateParam(new StringParameter("defaultCreationFolder"));
|
||||
addGlobalStateParam(new IntegerParameter("lastTab"));
|
||||
m_sectionId = new BigDecimalParameter(CONTENT_SECTION);
|
||||
addGlobalStateParam(m_sectionId);
|
||||
|
||||
|
|
@ -91,6 +96,7 @@ public class ItemSearchPage extends CMSPage {
|
|||
m_tabbedPane = createTabbedPane();
|
||||
m_tabbedPane.setIdAttr("page-body");
|
||||
add(m_tabbedPane);
|
||||
|
||||
addRequestListener(new RequestListener() {
|
||||
|
||||
public void pageRequested(final RequestEvent event) {
|
||||
|
|
@ -98,17 +104,8 @@ public class ItemSearchPage extends CMSPage {
|
|||
|
||||
final String query = (String) state.getValue(new StringParameter(ItemSearchPopup.QUERY));
|
||||
|
||||
if (m_tabbedPane.getCurrentPane(state) == m_create) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((query == null) || query.isEmpty()) {
|
||||
m_tabbedPane.setSelectedIndex(state, 1);
|
||||
} else {
|
||||
m_tabbedPane.setSelectedIndex(state, 0);
|
||||
}
|
||||
|
||||
BigDecimal typeParam = (BigDecimal) state.getValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM));
|
||||
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);
|
||||
|
|
@ -116,11 +113,81 @@ public class ItemSearchPage extends CMSPage {
|
|||
m_tabbedPane.setTabVisible(state, m_create, true);
|
||||
m_create.setVisible(state, true);
|
||||
}
|
||||
|
||||
if (state.getValue(new IntegerParameter("lastTab")) == null) {
|
||||
if ((query == null) || query.isEmpty()) {
|
||||
m_tabbedPane.setSelectedIndex(state, 1);
|
||||
} else {
|
||||
m_tabbedPane.setSelectedIndex(state, 0);
|
||||
}
|
||||
|
||||
// m_tabbedPane.setTabVisible(state, m_create, false);
|
||||
// m_create.setVisible(state, false);
|
||||
|
||||
}
|
||||
|
||||
state.setValue(new IntegerParameter("lastTab"), m_tabbedPane.getSelectedIndex(state));
|
||||
|
||||
if (state.getValue(new StringParameter("defaultCreationFolder")) != null) {
|
||||
m_create.setDefaultFolder((String) state.getValue(new StringParameter("defaultCreationFolder")));
|
||||
}
|
||||
|
||||
// if (m_lastTab != m_tabbedPane.getSelectedIndex(state)) {
|
||||
// m_lastTab = m_tabbedPane.getSelectedIndex(state);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// //If create pane is selected do nothing (else we don't stay in the create pane)
|
||||
// if (m_tabbedPane.getCurrentPane(state) == m_create) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if ((query == null) || query.isEmpty()) {
|
||||
// m_tabbedPane.setSelectedIndex(state, 1);
|
||||
// } else {
|
||||
// m_tabbedPane.setSelectedIndex(state, 1);
|
||||
// }
|
||||
|
||||
// if (m_tabbedPane.getCurrentPane(state) == m_create) {
|
||||
// m_tabbedPane.setTabVisible(state, m_create, false);
|
||||
// m_create.setVisible(state, false);
|
||||
// }
|
||||
//
|
||||
// m_lastTab = m_tabbedPane.getSelectedIndex(state);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// m_tabbedPane.addActionListener(new ActionListener() {
|
||||
//
|
||||
// public void actionPerformed(final ActionEvent event) {
|
||||
// final PageState state = event.getPageState();
|
||||
//
|
||||
// }
|
||||
//
|
||||
// });
|
||||
|
||||
// m_flatBrowse.addProcessListener(new FormProcessListener() {
|
||||
//
|
||||
// public void process(final FormSectionEvent fse) throws FormProcessException {
|
||||
// if (m_flatBrowse.getSubmit().isSelected(fse.getPageState())) {
|
||||
// enableCreatePane(fse.getPageState());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// });
|
||||
}
|
||||
|
||||
// private void enableCreatePane(final PageState state) {
|
||||
// final 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);
|
||||
// }
|
||||
// }
|
||||
/**
|
||||
* Creates, and then caches, the Browse pane. Overriding this method to return null will prevent this tab from
|
||||
* appearing. Note: not implemented yet.
|
||||
|
|
@ -257,12 +324,17 @@ 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) {
|
||||
protected void setTabActive(final PageState state, final int index, final boolean value) {
|
||||
m_tabbedPane.setTabVisible(state, index, value);
|
||||
}
|
||||
|
||||
protected void setDefaultCreationFolder(final Folder folder) {
|
||||
m_create.setDefaultFolder(folder.getOID().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,12 +40,17 @@ import com.arsdigita.bebop.util.BebopConstants;
|
|||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ContentType;
|
||||
import com.arsdigita.cms.ContentTypeLifecycleDefinition;
|
||||
import com.arsdigita.cms.Folder;
|
||||
import com.arsdigita.cms.Workspace;
|
||||
import com.arsdigita.cms.WorkspaceServlet;
|
||||
import com.arsdigita.cms.lifecycle.LifecycleDefinition;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.web.ParameterMap;
|
||||
import com.arsdigita.web.URL;
|
||||
import com.arsdigita.workflow.simple.Workflow;
|
||||
import java.util.Date;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
|
|
@ -72,6 +77,7 @@ public class ItemSearchWidget extends FormSection
|
|||
private String m_name;
|
||||
private String m_searchName;
|
||||
private String m_clearName;
|
||||
private Folder m_defaultCreationFolder;
|
||||
private ParameterModel m_model;
|
||||
private ParameterModel m_searchModel;
|
||||
private String searchLabelText = (String) GlobalizationUtil.globalize("cms.ui.item_search.search").localize();
|
||||
|
|
@ -245,7 +251,7 @@ public class ItemSearchWidget extends FormSection
|
|||
});
|
||||
//m_item = new ItemFragment(model, this);
|
||||
|
||||
m_publish = new Hidden(PUBLISH);
|
||||
m_publish = new Hidden(PUBLISH);
|
||||
add(m_publish);
|
||||
|
||||
m_item = new TextField(m_searchModel);
|
||||
|
|
@ -270,6 +276,10 @@ public class ItemSearchWidget extends FormSection
|
|||
}
|
||||
params.setParameter("publishWidget", formName + ".elements['" + m_publish.getName() + "']");
|
||||
|
||||
if (m_defaultCreationFolder != null) {
|
||||
params.setParameter("defaultCreationFolder", m_defaultCreationFolder.getOID().toString());
|
||||
}
|
||||
|
||||
String searchURL = WorkspaceServlet.getURLStubForClass(
|
||||
ItemSearchPage.class.getName());
|
||||
s_log.debug("Search URL stub is: " + searchURL);
|
||||
|
|
@ -280,28 +290,28 @@ public class ItemSearchWidget extends FormSection
|
|||
|
||||
URL url = URL.there(state.getRequest(), searchURL, params);
|
||||
|
||||
t.setLabel(" <script language=javascript> "
|
||||
+ " <!-- \n"
|
||||
+ " function "
|
||||
//+ m_item.getName().replace('.', '_')
|
||||
+ m_selected.getName().replace('.', '_')
|
||||
+ "Popup(theForm) { \n"
|
||||
+ "var width = screen.width * 0.5;\n"
|
||||
+ "var height = screen.height * 0.5;\n"
|
||||
+ "if ((width < 800) && (screen.width >= 800)) {\n"
|
||||
+ "width = 800;\n"
|
||||
+ "}\n"
|
||||
+ "if ((height < 600) && (screen.height >= 600)) {\n"
|
||||
+ "height = 600;\n"
|
||||
+ "}\n"
|
||||
+ " aWindow = window.open(\"" + url + "&query=\" + document.getElementById('" + m_item.
|
||||
getName() + "').value , "
|
||||
//+ "\"search\", \"toolbar=no,width=800,height=600,status=no,scrollbars=yes,resize=yes\");\n"
|
||||
+ "\"search\", \"toolbar=no,width=\" + width + \",height=\" + height + \",status=no,scrollbars=yes,resize=yes\");\n "
|
||||
+ "return false;\n"
|
||||
+ " } \n"
|
||||
+ " --> \n"
|
||||
+ " </script> ");
|
||||
t.setLabel(
|
||||
" <script language=javascript> "
|
||||
+ " <!-- \n"
|
||||
+ " function "
|
||||
+ m_selected.getName().replace('.', '_')
|
||||
+ "Popup(theForm) { \n"
|
||||
+ "var width = screen.width * 0.5;\n"
|
||||
+ "var height = screen.height * 0.5;\n"
|
||||
+ "if ((width < 800) && (screen.width >= 800)) {\n"
|
||||
+ "width = 800;\n"
|
||||
+ "}\n"
|
||||
+ "if ((height < 600) && (screen.height >= 600)) {\n"
|
||||
+ "height = 600;\n"
|
||||
+ "}\n"
|
||||
+ " aWindow = window.open(\"" + url + "&query=\" + document.getElementById('"
|
||||
+ m_item.getName() + "').value , "
|
||||
+ "\"search\", \"toolbar=no,width=\" + width + \",height=\" + height + \",status=no,scrollbars=yes,resize=yes\");\n"
|
||||
+ "document." + formName + "." + m_publish.getName() + ".value = \"false\";\n "
|
||||
+ "return false;\n"
|
||||
+ " } \n"
|
||||
+ " --> \n"
|
||||
+ " </script> ");
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -485,8 +495,32 @@ public class ItemSearchWidget extends FormSection
|
|||
return selectedLabelText;
|
||||
}
|
||||
|
||||
public void setSelectedLabelText(String selectedLabelText) {
|
||||
public void setSelectedLabelText(final String selectedLabelText) {
|
||||
this.selectedLabelText = selectedLabelText;
|
||||
}
|
||||
|
||||
}
|
||||
public void setDefaultCreationFolder(final Folder folder) {
|
||||
m_defaultCreationFolder = folder;
|
||||
}
|
||||
|
||||
public void publishCreatedItem(final FormData data, final ContentItem item) {
|
||||
final String publishStr = data.getString(ItemSearchWidget.PUBLISH);
|
||||
final Boolean publish = Boolean.valueOf(publishStr);
|
||||
if (publish) {
|
||||
final LifecycleDefinition lifecycleDef = ContentTypeLifecycleDefinition.getLifecycleDefinition(
|
||||
item.getContentSection(), item.getContentType());
|
||||
|
||||
if (lifecycleDef == null) {
|
||||
s_log.warn(String.format("Cannot publish item %s because it has no default lifecycle",
|
||||
item.getOID().toString()));
|
||||
} else {
|
||||
item.publish(lifecycleDef, new Date());
|
||||
item.getLifecycle().start();
|
||||
final Workflow workflow = Workflow.getObjectWorkflow(item);
|
||||
if (workflow != null) {
|
||||
workflow.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,15 +4,14 @@
|
|||
*/
|
||||
package com.arsdigita.cms.ui.folder;
|
||||
|
||||
import com.arsdigita.bebop.form.SingleSelect;
|
||||
import com.arsdigita.bebop.event.PrintListener;
|
||||
import com.arsdigita.bebop.event.PrintEvent;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.event.PrintEvent;
|
||||
import com.arsdigita.bebop.event.PrintListener;
|
||||
import com.arsdigita.bebop.form.SingleSelect;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.Folder;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.toolbox.ui.OIDParameter;
|
||||
import java.util.TooManyListenersException;
|
||||
|
||||
/**
|
||||
|
|
@ -21,8 +20,7 @@ import java.util.TooManyListenersException;
|
|||
*/
|
||||
public abstract class AbstractFolderPicker extends SingleSelect {
|
||||
|
||||
public AbstractFolderPicker(String name) {
|
||||
//super(new OIDParameter(name));
|
||||
public AbstractFolderPicker(String name) {
|
||||
super(new StringParameter(name));
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -27,33 +27,13 @@ public class FlatFolderPicker extends AbstractFolderPicker {
|
|||
protected void addOptions(PageState state, SingleSelect target) {
|
||||
target.addOption(new Option("", ""));
|
||||
|
||||
final ContentSection section = CMS.getContext().getContentSection();
|
||||
//final String sectionName = section.getName();
|
||||
final ContentSection section = CMS.getContext().getContentSection();
|
||||
final Folder root = section.getRootFolder();
|
||||
|
||||
final String path = ""; // String.format("%s:", sectionName);
|
||||
|
||||
//addFolders(target, path, root.getChildren().addEqualsFilter("objectType", Folder.BASE_DATA_OBJECT_TYPE));
|
||||
final String path = "";
|
||||
|
||||
addFolder(target, path, root);
|
||||
|
||||
|
||||
// DataCollection terms = SessionManager.getSession()
|
||||
// .retrieve(Term.BASE_DATA_OBJECT_TYPE);
|
||||
// terms.addPath("model.id");
|
||||
// terms.addPath("model.objectType");
|
||||
// terms.addPath("model.name");
|
||||
// terms.addPath("domain.title");
|
||||
// terms.addOrder("domain.title");
|
||||
// terms.addOrder("model.name");
|
||||
//
|
||||
// target.addOption(new Option(null, "-- pick one --"));
|
||||
// while (terms.next()) {
|
||||
// target.addOption(
|
||||
// new Option(new OID((String)terms.get("model.objectType"),
|
||||
// terms.get("model.id")).toString(),
|
||||
// terms.get("domain.title") + " -> " +
|
||||
// terms.get("model.name")));
|
||||
// }
|
||||
}
|
||||
|
||||
private void addFolders(final SingleSelect target, final String path, ItemCollection folders) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.runtime.AbstractConfig;
|
||||
|
||||
import com.arsdigita.util.parameter.BooleanParameter;
|
||||
import com.arsdigita.util.parameter.IntegerParameter;
|
||||
import com.arsdigita.util.parameter.Parameter;
|
||||
import com.arsdigita.util.parameter.StringParameter;
|
||||
|
||||
|
|
@ -14,6 +16,7 @@ public class PublicationsConfig extends AbstractConfig {
|
|||
|
||||
private final Parameter attachOrgaUnitsStep;
|
||||
private final Parameter attachPublicationsStepTo;
|
||||
private final Parameter defaultAuthorsFolder;
|
||||
|
||||
public PublicationsConfig() {
|
||||
attachOrgaUnitsStep =
|
||||
|
|
@ -21,24 +24,40 @@ public class PublicationsConfig extends AbstractConfig {
|
|||
"com.arsdigita.cms.contenttypes.publications.attach_orgaunits_step",
|
||||
Parameter.REQUIRED,
|
||||
Boolean.FALSE);
|
||||
|
||||
|
||||
attachPublicationsStepTo =
|
||||
new StringParameter(
|
||||
"com.arsdigita.cms.contenttypes.publications.attach_publications_step_to",
|
||||
Parameter.REQUIRED,
|
||||
"com.arsdigita.cms.contenttypes.publications.attach_publications_step_to",
|
||||
Parameter.REQUIRED,
|
||||
"");
|
||||
|
||||
|
||||
defaultAuthorsFolder = new IntegerParameter(
|
||||
"com.arsdigita.cms.contenttypes.publications.default_authors_folder",
|
||||
Parameter.REQUIRED,
|
||||
null);
|
||||
|
||||
|
||||
register(attachOrgaUnitsStep);
|
||||
register(attachPublicationsStepTo);
|
||||
|
||||
register(defaultAuthorsFolder);
|
||||
|
||||
loadInfo();
|
||||
}
|
||||
|
||||
|
||||
public Boolean getAttachOrgaUnitsStep() {
|
||||
return (Boolean) get(attachOrgaUnitsStep);
|
||||
}
|
||||
|
||||
|
||||
public String getAttachPublicationsStepTo() {
|
||||
return (String) get(attachPublicationsStepTo);
|
||||
}
|
||||
|
||||
public Integer getDefaultAuthorsFolder() {
|
||||
if (get(defaultAuthorsFolder) == null) {
|
||||
return null;
|
||||
} else {
|
||||
return (Integer) get(defaultAuthorsFolder);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,3 +7,8 @@ com.arsdigita.cms.contenttypes.publications.attach_publications_step_to.title =
|
|||
com.arsdigita.cms.contenttypes.publications.attach_publications_step_to.purpose = Attaches the authoring step for associating a publication to organizationalunit to the authoring steps of the content types in the string.
|
||||
com.arsdigita.cms.contenttypes.publications.attach_publications_step_to.example = com.arsdigita.cms.contenttypes.SciInstitute;com.arsdigita.cms.contenttypes.SciDepartment;com.arsdigita.cms.contenttypes.SciProject
|
||||
com.arsdigita.cms.contenttypes.publications.attach_publications_step_to.format = [String]
|
||||
|
||||
com.arsdigita.cms.contenttypes.publications.default_authors_folder.title = ID of the default folder for items created using the create pane of the ItemSearchWidget
|
||||
com.arsdigita.cms.contenttypes.publications.default_authors_folder.purpose = Default folder for items created using the create pane of the ItemSearchWidget
|
||||
com.arsdigita.cms.contenttypes.publications.default_authors_folder.example = 10002
|
||||
com.arsdigita.cms.contenttypes.publications.default_authors_folder.format = Integer
|
||||
|
|
@ -31,10 +31,12 @@ import com.arsdigita.bebop.form.CheckboxGroup;
|
|||
import com.arsdigita.bebop.form.Option;
|
||||
import com.arsdigita.cms.ContentType;
|
||||
import com.arsdigita.cms.ContentTypeLifecycleDefinition;
|
||||
import com.arsdigita.cms.Folder;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.AuthorshipCollection;
|
||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||
import com.arsdigita.cms.contenttypes.Publication;
|
||||
import com.arsdigita.cms.contenttypes.PublicationsConfig;
|
||||
import com.arsdigita.cms.lifecycle.Lifecycle;
|
||||
import com.arsdigita.cms.lifecycle.LifecycleDefinition;
|
||||
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||
|
|
@ -43,6 +45,7 @@ import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
|||
import com.arsdigita.kernel.Kernel;
|
||||
import com.arsdigita.workflow.simple.TaskException;
|
||||
import com.arsdigita.workflow.simple.Workflow;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -67,6 +70,11 @@ public class PublicationAuthorAddForm
|
|||
private Label selectedAuthorLabel;
|
||||
private static final String ISEDITOR = "isEditor";
|
||||
private CheckboxGroup isEditor;
|
||||
private final static PublicationsConfig config = new PublicationsConfig();
|
||||
|
||||
static {
|
||||
config.load();
|
||||
}
|
||||
|
||||
public PublicationAuthorAddForm(ItemSelectionModel itemModel,
|
||||
SimpleEditStep editStep) {
|
||||
|
|
@ -84,6 +92,9 @@ public class PublicationAuthorAddForm
|
|||
ITEM_SEARCH,
|
||||
ContentType.findByAssociatedObjectType(GenericPerson.class.getName()));
|
||||
add(m_itemSearch);
|
||||
if ((config.getDefaultAuthorsFolder() != null) && (config.getDefaultAuthorsFolder() != 0)) {
|
||||
m_itemSearch.setDefaultCreationFolder(new Folder(new BigDecimal(config.getDefaultAuthorsFolder())));
|
||||
}
|
||||
|
||||
selectedAuthorLabel = new Label("");
|
||||
add(selectedAuthorLabel);
|
||||
|
|
@ -157,24 +168,25 @@ public class PublicationAuthorAddForm
|
|||
|
||||
publication.addAuthor(authorToAdd, editor);
|
||||
|
||||
final String publishStr = data.getString(ItemSearchWidget.PUBLISH);
|
||||
final Boolean publish = Boolean.valueOf(publishStr);
|
||||
if (publish) {
|
||||
final LifecycleDefinition lifecycleDef = ContentTypeLifecycleDefinition.getLifecycleDefinition(
|
||||
authorToAdd.getContentSection(), authorToAdd.getContentType());
|
||||
|
||||
if (lifecycleDef == null) {
|
||||
s_log.warn(String.format("Cannot publish item %s because it has no default lifecycle",
|
||||
authorToAdd.getOID().toString()));
|
||||
} else {
|
||||
authorToAdd.publish(lifecycleDef, new Date());
|
||||
authorToAdd.getLifecycle().start();
|
||||
final Workflow workflow = Workflow.getObjectWorkflow(authorToAdd);
|
||||
if (workflow != null) {
|
||||
workflow.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
// final String publishStr = data.getString(ItemSearchWidget.PUBLISH);
|
||||
// final Boolean publish = Boolean.valueOf(publishStr);
|
||||
// if (publish) {
|
||||
// final LifecycleDefinition lifecycleDef = ContentTypeLifecycleDefinition.getLifecycleDefinition(
|
||||
// authorToAdd.getContentSection(), authorToAdd.getContentType());
|
||||
//
|
||||
// if (lifecycleDef == null) {
|
||||
// s_log.warn(String.format("Cannot publish item %s because it has no default lifecycle",
|
||||
// authorToAdd.getOID().toString()));
|
||||
// } else {
|
||||
// authorToAdd.publish(lifecycleDef, new Date());
|
||||
// authorToAdd.getLifecycle().start();
|
||||
// final Workflow workflow = Workflow.getObjectWorkflow(authorToAdd);
|
||||
// if (workflow != null) {
|
||||
// workflow.delete();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
m_itemSearch.publishCreatedItem(data, authorToAdd);
|
||||
} else {
|
||||
AuthorshipCollection authors;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue