Verschiedene Änderungen am ItemSearchWidget (noch nicht abgeschlossen) um die Usabilty zu verbessern.
git-svn-id: https://svn.libreccm.org/ccm/trunk@1713 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
909377f7d9
commit
7d27c686bf
|
|
@ -1099,3 +1099,4 @@ cms.ui.item_search.flat.place=Place
|
||||||
cms.ui.item_search.flat.type=Type
|
cms.ui.item_search.flat.type=Type
|
||||||
cms.ui.item_search.flatBrowse=Select item
|
cms.ui.item_search.flatBrowse=Select item
|
||||||
cms.ui.category.undeletable=This category can't be deleted.
|
cms.ui.category.undeletable=This category can't be deleted.
|
||||||
|
cms.ui.item_search.flat.filter.submit=Filter
|
||||||
|
|
|
||||||
|
|
@ -1090,3 +1090,4 @@ cms.ui.item_search.flat.place=Ort
|
||||||
cms.ui.item_search.flat.type=Typ
|
cms.ui.item_search.flat.type=Typ
|
||||||
cms.ui.item_search.flatBrowse=Item ausw\u00e4hlen
|
cms.ui.item_search.flatBrowse=Item ausw\u00e4hlen
|
||||||
cms.ui.category.undeletable=Diese Kategorie kann nicht gel\u00f6scht werden.
|
cms.ui.category.undeletable=Diese Kategorie kann nicht gel\u00f6scht werden.
|
||||||
|
cms.ui.item_search.flat.filter.submit=Filtern
|
||||||
|
|
|
||||||
|
|
@ -38,3 +38,4 @@ cms.ui.item_search.flat.place=Place
|
||||||
cms.ui.item_search.flat.type=Type
|
cms.ui.item_search.flat.type=Type
|
||||||
cms.ui.item_search.flatBrowse=Select item
|
cms.ui.item_search.flatBrowse=Select item
|
||||||
cms.ui.category.undeletable=
|
cms.ui.category.undeletable=
|
||||||
|
cms.ui.item_search.flat.filter.submit=
|
||||||
|
|
|
||||||
|
|
@ -569,3 +569,4 @@ cms.ui.item_search.flat.place=Place
|
||||||
cms.ui.item_search.flat.type=Type
|
cms.ui.item_search.flat.type=Type
|
||||||
cms.ui.item_search.flatBrowse=Select item
|
cms.ui.item_search.flatBrowse=Select item
|
||||||
cms.ui.category.undeletable=
|
cms.ui.category.undeletable=
|
||||||
|
cms.ui.item_search.flat.filter.submit=
|
||||||
|
|
|
||||||
|
|
@ -5,18 +5,23 @@ import com.arsdigita.bebop.Component;
|
||||||
import com.arsdigita.bebop.Form;
|
import com.arsdigita.bebop.Form;
|
||||||
import com.arsdigita.bebop.FormData;
|
import com.arsdigita.bebop.FormData;
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.GridPanel;
|
||||||
import com.arsdigita.bebop.Label;
|
import com.arsdigita.bebop.Label;
|
||||||
import com.arsdigita.bebop.Link;
|
import com.arsdigita.bebop.Link;
|
||||||
import com.arsdigita.bebop.Page;
|
import com.arsdigita.bebop.Page;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.PaginationModelBuilder;
|
||||||
|
import com.arsdigita.bebop.Paginator;
|
||||||
|
import com.arsdigita.bebop.RequestLocal;
|
||||||
|
import com.arsdigita.bebop.SimpleContainer;
|
||||||
import com.arsdigita.bebop.Table;
|
import com.arsdigita.bebop.Table;
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
import com.arsdigita.bebop.event.PrintEvent;
|
import com.arsdigita.bebop.form.Submit;
|
||||||
import com.arsdigita.bebop.event.PrintListener;
|
|
||||||
import com.arsdigita.bebop.form.TextField;
|
import com.arsdigita.bebop.form.TextField;
|
||||||
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||||
|
import com.arsdigita.bebop.parameters.ParameterData;
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||||
import com.arsdigita.bebop.table.TableColumn;
|
import com.arsdigita.bebop.table.TableColumn;
|
||||||
|
|
@ -31,11 +36,14 @@ import com.arsdigita.cms.Folder;
|
||||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||||
import com.arsdigita.domain.DomainObjectFactory;
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
import com.arsdigita.persistence.DataCollection;
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.persistence.DataObject;
|
import com.arsdigita.persistence.DataQuery;
|
||||||
import com.arsdigita.persistence.Session;
|
import com.arsdigita.persistence.Session;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
|
import com.arsdigita.toolbox.ui.DataQueryBuilder;
|
||||||
|
import com.arsdigita.toolbox.ui.DataTable;
|
||||||
import com.arsdigita.util.LockableImpl;
|
import com.arsdigita.util.LockableImpl;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import org.bouncycastle.asn1.ess.ContentIdentifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -44,47 +52,36 @@ import java.math.BigDecimal;
|
||||||
*/
|
*/
|
||||||
public class ItemSearchFlatBrowsePane extends Form implements FormInitListener, FormProcessListener {
|
public class ItemSearchFlatBrowsePane extends Form implements FormInitListener, FormProcessListener {
|
||||||
|
|
||||||
private static final String QUERY_PARAM = "query";
|
private static final String QUERY_PARAM = "queryStr";
|
||||||
public static final String WIDGET_PARAM = "widget";
|
public static final String WIDGET_PARAM = "widget";
|
||||||
public static final String SEARCHWIDGET_PARAM = "searchWidget";
|
public static final String SEARCHWIDGET_PARAM = "searchWidget";
|
||||||
|
public static final String FILTER_SUBMIT = "filterSubmit";
|
||||||
private final Table resultsTable;
|
private final Table resultsTable;
|
||||||
|
private final Paginator paginator;
|
||||||
private final StringParameter queryParam;
|
private final StringParameter queryParam;
|
||||||
private final Label jsLabel;
|
|
||||||
|
|
||||||
|
|
||||||
public ItemSearchFlatBrowsePane(final String name) {
|
public ItemSearchFlatBrowsePane(final String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
|
||||||
|
final BoxPanel mainPanel = new BoxPanel(BoxPanel.VERTICAL);
|
||||||
|
|
||||||
queryParam = new StringParameter(QUERY_PARAM);
|
queryParam = new StringParameter(QUERY_PARAM);
|
||||||
|
|
||||||
final BoxPanel boxPanel = new BoxPanel(BoxPanel.HORIZONTAL);
|
final BoxPanel boxPanel = new BoxPanel(BoxPanel.HORIZONTAL);
|
||||||
boxPanel.add(new Label(GlobalizationUtil.globalize("cms.ui.item_search.flat.filter")));
|
boxPanel.add(new Label(GlobalizationUtil.globalize("cms.ui.item_search.flat.filter")));
|
||||||
final TextField filter = new TextField(new StringParameter(QUERY_PARAM));
|
final TextField filter = new TextField(new StringParameter(QUERY_PARAM));
|
||||||
boxPanel.add(filter);
|
boxPanel.add(filter);
|
||||||
jsLabel = new Label("", false);
|
boxPanel.add(new Submit(FILTER_SUBMIT, GlobalizationUtil.globalize("cms.ui.item_search.flat.filter.submit")));
|
||||||
jsLabel.addPrintListener(new PrintListener() {
|
mainPanel.add(boxPanel);
|
||||||
|
|
||||||
public void prepare(final PrintEvent event) {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final String searchWidget = (String) state.getValue(new StringParameter(SEARCHWIDGET_PARAM));
|
|
||||||
((Label)event.getTarget()).setLabel(String.format(
|
|
||||||
" <script language=javascript type=\"text/javascript\">"
|
|
||||||
+ "<!--"
|
|
||||||
+ "alert(\"test\")"
|
|
||||||
+ "self.elements['%s'].value='test';"//window.opener.document.%s.value;"
|
|
||||||
+ "-->"
|
|
||||||
+ "</script> ",
|
|
||||||
filter.getName(),
|
|
||||||
searchWidget));
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
boxPanel.add(jsLabel);
|
|
||||||
add(boxPanel);
|
|
||||||
|
|
||||||
resultsTable = new ResultsTable();
|
resultsTable = new ResultsTable();
|
||||||
add(resultsTable);
|
paginator = new Paginator((PaginationModelBuilder) resultsTable.getModelBuilder(), 5);
|
||||||
|
mainPanel.add(paginator);
|
||||||
|
|
||||||
|
mainPanel.add(resultsTable);
|
||||||
|
|
||||||
|
add(mainPanel);
|
||||||
|
|
||||||
addInitListener(this);
|
addInitListener(this);
|
||||||
addProcessListener(this);
|
addProcessListener(this);
|
||||||
}
|
}
|
||||||
|
|
@ -95,8 +92,15 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
||||||
page.addComponentStateParam(this, queryParam);
|
page.addComponentStateParam(this, queryParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(final FormSectionEvent fse) throws FormProcessException {
|
public void init(final FormSectionEvent fse) throws FormProcessException {
|
||||||
|
final PageState state = fse.getPageState();
|
||||||
|
final FormData data = fse.getFormData();
|
||||||
|
|
||||||
|
final String query = (String) data.get(QUERY_PARAM);
|
||||||
|
if ((query == null) || query.isEmpty()) {
|
||||||
|
data.setParameter(QUERY_PARAM,
|
||||||
|
new ParameterData(queryParam, state.getValue(new StringParameter(ItemSearchPopup.QUERY))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void process(final FormSectionEvent fse) throws FormProcessException {
|
public void process(final FormSectionEvent fse) throws FormProcessException {
|
||||||
|
|
@ -104,6 +108,7 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
||||||
final PageState state = fse.getPageState();
|
final PageState state = fse.getPageState();
|
||||||
|
|
||||||
state.setValue(queryParam, data.get(QUERY_PARAM));
|
state.setValue(queryParam, data.get(QUERY_PARAM));
|
||||||
|
state.setValue(new StringParameter(ItemSearchPopup.QUERY), data.get(QUERY_PARAM));
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ResultsTable extends Table {
|
private class ResultsTable extends Table {
|
||||||
|
|
@ -115,6 +120,7 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
||||||
public ResultsTable() {
|
public ResultsTable() {
|
||||||
super();
|
super();
|
||||||
setEmptyView(new Label(GlobalizationUtil.globalize("cms.ui.item_search.flat.no_items")));
|
setEmptyView(new Label(GlobalizationUtil.globalize("cms.ui.item_search.flat.no_items")));
|
||||||
|
setClassAttr("dataTable");
|
||||||
|
|
||||||
final TableColumnModel columnModel = getColumnModel();
|
final TableColumnModel columnModel = getColumnModel();
|
||||||
columnModel.add(new TableColumn(0,
|
columnModel.add(new TableColumn(0,
|
||||||
|
|
@ -128,16 +134,61 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
||||||
TABLE_COL_TYPE));
|
TABLE_COL_TYPE));
|
||||||
|
|
||||||
setModelBuilder(new ResultsTableModelBuilder());
|
setModelBuilder(new ResultsTableModelBuilder());
|
||||||
|
|
||||||
columnModel.get(0).setCellRenderer(new TitleCellRenderer());
|
columnModel.get(0).setCellRenderer(new TitleCellRenderer());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ResultsTableModelBuilder extends LockableImpl implements TableModelBuilder {
|
private class ResultsTableModelBuilder extends LockableImpl implements TableModelBuilder, PaginationModelBuilder {
|
||||||
|
|
||||||
|
//private DataCollection collection;
|
||||||
|
private RequestLocal collection = new RequestLocal();
|
||||||
|
|
||||||
public TableModel makeModel(final Table table, final PageState state) {
|
public TableModel makeModel(final Table table, final PageState state) {
|
||||||
return new ResultsTableModel(table, state);
|
|
||||||
|
if (collection.get(state) == null) {
|
||||||
|
query(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
((DataCollection) collection.get(state)).setRange(paginator.getFirst(state), paginator.getLast(state) + 1);
|
||||||
|
|
||||||
|
return new ResultsTableModel(table, state, (DataCollection) collection.get(state));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTotalSize(final Paginator paginator, final PageState state) {
|
||||||
|
if (collection.get(state) == null) {
|
||||||
|
query(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
//((DataCollection)collection.get(state)).setRange(paginator.getFirst(state), paginator.getLast(state) + 1);
|
||||||
|
|
||||||
|
return (int) ((DataCollection)collection.get(state)).size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVisible(PageState state) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void query(final PageState state) {
|
||||||
|
final Session session = SessionManager.getSession();
|
||||||
|
final BigDecimal typeId = (BigDecimal) state.getValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM));
|
||||||
|
if (typeId == null) {
|
||||||
|
collection.set(state, session.retrieve(ContentPage.BASE_DATA_OBJECT_TYPE));
|
||||||
|
} else {
|
||||||
|
final ContentType type = new ContentType(typeId);
|
||||||
|
collection.set(state, session.retrieve(type.getClassName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
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%%'))",
|
||||||
|
ContentItem.NAME, query,
|
||||||
|
ContentPage.TITLE, query));
|
||||||
|
}
|
||||||
|
|
||||||
|
((DataCollection) collection.get(state)).addOrder("title asc, name asc");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -148,23 +199,22 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
||||||
private final DataCollection collection;
|
private final DataCollection collection;
|
||||||
private ContentItem currentItem;
|
private ContentItem currentItem;
|
||||||
|
|
||||||
public ResultsTableModel(final Table table, final PageState state) {
|
public ResultsTableModel(final Table table, final PageState state, final DataCollection collection) {
|
||||||
this.table = table;
|
this.table = table;
|
||||||
final Session session = SessionManager.getSession();
|
|
||||||
final BigDecimal typeId = (BigDecimal) state.getValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM));
|
|
||||||
if (typeId == null) {
|
|
||||||
collection = session.retrieve(ContentPage.BASE_DATA_OBJECT_TYPE);
|
|
||||||
} else {
|
|
||||||
final ContentType type = new ContentType(typeId);
|
|
||||||
collection = session.retrieve(type.getClassName());
|
|
||||||
}
|
|
||||||
|
|
||||||
final String query = (String) state.getValue(queryParam);
|
this.collection = collection;
|
||||||
if ((query != null) && !query.isEmpty()) {
|
|
||||||
collection.addFilter(String.format("(lower(%s) like lower('%%%s%%')) or (lower(%s) like lower('%%%s%%'))",
|
/*
|
||||||
ContentItem.NAME, query,
|
* final Session session = SessionManager.getSession(); final BigDecimal typeId = (BigDecimal)
|
||||||
ContentPage.TITLE, query));
|
* state.getValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM)); if (typeId == null) { collection =
|
||||||
|
* session.retrieve(ContentPage.BASE_DATA_OBJECT_TYPE); } else { final ContentType type = new
|
||||||
|
* ContentType(typeId); collection = session.retrieve(type.getClassName()); }
|
||||||
|
*
|
||||||
|
* final String query = (String) state.getValue(queryParam); if ((query != null) && !query.isEmpty()) {
|
||||||
|
* collection.addFilter(String.format( "(lower(%s) like lower('%%%s%%')) or (lower(%s) like
|
||||||
|
* lower('%%%s%%'))", ContentItem.NAME, query, ContentPage.TITLE, query));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getColumnCount() {
|
public int getColumnCount() {
|
||||||
|
|
@ -227,35 +277,39 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
||||||
public Object getKeyAt(final int columnIndex) {
|
public Object getKeyAt(final int columnIndex) {
|
||||||
return currentItem.getID();
|
return currentItem.getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TitleCellRenderer extends LockableImpl implements TableCellRenderer {
|
private class TitleCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||||
|
|
||||||
public Component getComponent(final Table table,
|
public Component getComponent(final Table table,
|
||||||
final PageState state,
|
final PageState state,
|
||||||
final Object value,
|
final Object value,
|
||||||
final boolean isSelected,
|
final boolean isSelected,
|
||||||
final Object key,
|
final Object key,
|
||||||
final int row,
|
final int row,
|
||||||
final int column) {
|
final int column) {
|
||||||
|
|
||||||
|
if (value == null) {
|
||||||
|
return new Label("???");
|
||||||
|
}
|
||||||
|
|
||||||
final Link link = new Link(value.toString(), "");
|
final Link link = new Link(value.toString(), "");
|
||||||
|
|
||||||
final String widget = (String) state.getValue(new StringParameter(WIDGET_PARAM));
|
final String widget = (String) state.getValue(new StringParameter(WIDGET_PARAM));
|
||||||
final String searchWidget = (String) state.getValue(new StringParameter(SEARCHWIDGET_PARAM));
|
final String searchWidget = (String) state.getValue(new StringParameter(SEARCHWIDGET_PARAM));
|
||||||
|
|
||||||
final ContentPage page = new ContentPage((BigDecimal) key);
|
final ContentPage page = new ContentPage((BigDecimal) key);
|
||||||
|
|
||||||
link.setOnClick(String.format(
|
link.setOnClick(String.format(
|
||||||
"window.opener.document.%s.value=\"%s\";window.opener.document.%s.value=\"%s\";self.close();return false;",
|
"window.opener.document.%s.value=\"%s\";window.opener.document.%s.value=\"%s\";self.close();return false;",
|
||||||
widget,
|
widget,
|
||||||
key.toString(),
|
key.toString(),
|
||||||
searchWidget,
|
searchWidget,
|
||||||
page.getTitle()));
|
page.getTitle()));
|
||||||
|
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ import com.arsdigita.bebop.table.TableModel;
|
||||||
import com.arsdigita.bebop.util.BebopConstants;
|
import com.arsdigita.bebop.util.BebopConstants;
|
||||||
import com.arsdigita.cms.CMS;
|
import com.arsdigita.cms.CMS;
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.ContentPage;
|
||||||
import com.arsdigita.cms.ContentSection;
|
import com.arsdigita.cms.ContentSection;
|
||||||
import com.arsdigita.cms.ContentType;
|
import com.arsdigita.cms.ContentType;
|
||||||
import com.arsdigita.cms.Folder;
|
import com.arsdigita.cms.Folder;
|
||||||
|
|
@ -347,6 +348,7 @@ public class ItemSearchFolderBrowser extends Table {
|
||||||
String widget =
|
String widget =
|
||||||
(String) state.getValue(new StringParameter(
|
(String) state.getValue(new StringParameter(
|
||||||
ItemSearchPopup.WIDGET_PARAM));
|
ItemSearchPopup.WIDGET_PARAM));
|
||||||
|
String searchWidget = (String) state.getValue(new StringParameter("searchWidget"));
|
||||||
boolean useURL =
|
boolean useURL =
|
||||||
"true".equals(state.getValue(new StringParameter(
|
"true".equals(state.getValue(new StringParameter(
|
||||||
ItemSearchPopup.URL_PARAM)));
|
ItemSearchPopup.URL_PARAM)));
|
||||||
|
|
@ -358,9 +360,9 @@ public class ItemSearchFolderBrowser extends Table {
|
||||||
getDomainObject().getOID())
|
getDomainObject().getOID())
|
||||||
: id
|
: id
|
||||||
+ " (" + name + ")";
|
+ " (" + name + ")";
|
||||||
|
String title = ((ContentPage) coll.getDomainObject()).getTitle();
|
||||||
|
|
||||||
Label js = new Label(generateJSLabel(id, widget,
|
Label js = new Label(generateJSLabel(id, widget, searchWidget, fillString, title),
|
||||||
fillString),
|
|
||||||
false);
|
false);
|
||||||
container.add(js);
|
container.add(js);
|
||||||
|
|
||||||
|
|
@ -377,15 +379,13 @@ public class ItemSearchFolderBrowser extends Table {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateJSLabel(BigDecimal id, String widget, String fill) {
|
private String generateJSLabel(BigDecimal id, String widget, String searchWidget, String fill, String title) {
|
||||||
StringBuilder buffer = new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append(" <script language=javascript> "
|
buffer.append(" <script language=javascript> ");
|
||||||
+ " <!-- \n"
|
buffer.append( " <!-- \n");
|
||||||
+ " function fillItem"
|
buffer.append(" function fillItem").append(id).append("() { \n");
|
||||||
+ id
|
buffer.append(" window.opener.document.").append(widget).append(".value=\"").append(fill).append("\";\n");
|
||||||
+ "() { \n"
|
buffer.append(" window.opener.document.").append(searchWidget).append(".value=\"").append(title).append("\";\n");
|
||||||
+ " window.opener.document."
|
|
||||||
+ widget + ".value=\"" + fill + "\";\n");
|
|
||||||
// set protocol to 'other' in FCKEditor, else relative url prepended by http://
|
// set protocol to 'other' in FCKEditor, else relative url prepended by http://
|
||||||
if (Bebop.getConfig().getDHTMLEditor().equals(
|
if (Bebop.getConfig().getDHTMLEditor().equals(
|
||||||
BebopConstants.BEBOP_FCKEDITOR)) {
|
BebopConstants.BEBOP_FCKEDITOR)) {
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ public class ItemSearchPage extends CMSPage {
|
||||||
private static final CMSConfig s_conf = CMSConfig.getInstance();
|
private static final CMSConfig s_conf = CMSConfig.getInstance();
|
||||||
private static final boolean LIMIT_TO_CONTENT_SECTION = false;
|
private static final boolean LIMIT_TO_CONTENT_SECTION = false;
|
||||||
public static final String CONTENT_SECTION = "section_id";
|
public static final String CONTENT_SECTION = "section_id";
|
||||||
|
private boolean showFlatBrowsePane = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new ItemSearchPage
|
* Construct a new ItemSearchPage
|
||||||
|
|
@ -73,13 +74,15 @@ public class ItemSearchPage extends CMSPage {
|
||||||
|
|
||||||
addGlobalStateParam(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM));
|
addGlobalStateParam(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM));
|
||||||
addGlobalStateParam(new StringParameter(ItemSearchPopup.WIDGET_PARAM));
|
addGlobalStateParam(new StringParameter(ItemSearchPopup.WIDGET_PARAM));
|
||||||
addGlobalStateParam(new StringParameter("searchWidget"));
|
addGlobalStateParam(new StringParameter("searchWidget"));
|
||||||
|
|
||||||
m_sectionId = new BigDecimalParameter(CONTENT_SECTION);
|
m_sectionId = new BigDecimalParameter(CONTENT_SECTION);
|
||||||
addGlobalStateParam(m_sectionId);
|
addGlobalStateParam(m_sectionId);
|
||||||
|
|
||||||
m_browse = getBrowsePane();
|
m_browse = getBrowsePane();
|
||||||
m_flatBrowse = getFlatBrowsePane();
|
if (showFlatBrowsePane) {
|
||||||
|
m_flatBrowse = getFlatBrowsePane();
|
||||||
|
}
|
||||||
m_search = getSearchPane();
|
m_search = getSearchPane();
|
||||||
// m_create = getCreatePane();
|
// m_create = getCreatePane();
|
||||||
|
|
||||||
|
|
@ -89,9 +92,8 @@ public class ItemSearchPage extends CMSPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates, and then caches, the Browse pane. Overriding this
|
* Creates, and then caches, the Browse pane. Overriding this method to return null will prevent this tab from
|
||||||
* method to return null will prevent this tab from appearing.
|
* appearing. Note: not implemented yet.
|
||||||
* Note: not implemented yet.
|
|
||||||
*/
|
*/
|
||||||
protected ItemSearchBrowsePane getBrowsePane() {
|
protected ItemSearchBrowsePane getBrowsePane() {
|
||||||
if (m_browse == null) {
|
if (m_browse == null) {
|
||||||
|
|
@ -101,17 +103,17 @@ public class ItemSearchPage extends CMSPage {
|
||||||
return m_browse;
|
return m_browse;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ItemSearchFlatBrowsePane getFlatBrowsePane() {
|
protected ItemSearchFlatBrowsePane getFlatBrowsePane() {
|
||||||
if (m_flatBrowse == null) {
|
if (m_flatBrowse == null) {
|
||||||
m_flatBrowse = new ItemSearchFlatBrowsePane("flatBrowse");
|
m_flatBrowse = new ItemSearchFlatBrowsePane("flatBrowse");
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_flatBrowse;
|
return m_flatBrowse;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates, and then caches, the Creation pane. Overriding this
|
* Creates, and then caches, the Creation pane. Overriding this method to return null will prevent this tab from
|
||||||
* method to return null will prevent this tab from appearing.
|
* appearing.
|
||||||
*/
|
*/
|
||||||
protected ItemSearchPopup getSearchPane() {
|
protected ItemSearchPopup getSearchPane() {
|
||||||
if (m_search == null) {
|
if (m_search == null) {
|
||||||
|
|
@ -130,46 +132,48 @@ public class ItemSearchPage extends CMSPage {
|
||||||
//
|
//
|
||||||
// return m_create;
|
// 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
|
||||||
* attribute for this tabbed pane. The default implementation uses a
|
* implementation uses a
|
||||||
* {@link com.arsdigita.bebop.TabbedPane} and sets the class
|
* {@link com.arsdigita.bebop.TabbedPane} and sets the class attribute to "CMS Admin." This implementation also adds
|
||||||
* attribute to "CMS Admin." This implementation also adds tasks,
|
* tasks, content sections, and search panes.
|
||||||
* content sections, and search panes.
|
|
||||||
*
|
*
|
||||||
* Developers can override this method to add only the tabs they
|
* Developers can override this method to add only the tabs they want, or to add additional tabs after the default
|
||||||
* want, or to add additional tabs after the default CMS tabs are
|
* CMS tabs are added.
|
||||||
* added.
|
|
||||||
*/
|
*/
|
||||||
protected TabbedPane createTabbedPane() {
|
protected TabbedPane createTabbedPane() {
|
||||||
TabbedPane pane = new TabbedPane();
|
TabbedPane pane = new TabbedPane();
|
||||||
pane.setClassAttr(XSL_CLASS);
|
pane.setClassAttr(XSL_CLASS);
|
||||||
|
|
||||||
addToPane(pane, "flatBrowse", getFlatBrowsePane());
|
if (showFlatBrowsePane) {
|
||||||
|
addToPane(pane, "flatBrowse", getFlatBrowsePane());
|
||||||
|
}
|
||||||
addToPane(pane, "browse", getBrowsePane());
|
addToPane(pane, "browse", getBrowsePane());
|
||||||
addToPane(pane, "search", getSearchPane());
|
addToPane(pane, "search", getSearchPane());
|
||||||
// addToPane(pane, "create", getCreatePane());
|
// addToPane(pane, "create", getCreatePane());
|
||||||
|
|
||||||
if(s_conf.getItemSearchDefaultTab().equals("browse")) {
|
if (s_conf.getItemSearchDefaultTab().equals("browse")) {
|
||||||
pane.setDefaultPane(m_browse);
|
pane.setDefaultPane(m_browse);
|
||||||
}
|
}
|
||||||
if(s_conf.getItemSearchDefaultTab().equals("search")) {
|
if (s_conf.getItemSearchDefaultTab().equals("search")) {
|
||||||
pane.setDefaultPane(m_search);
|
pane.setDefaultPane(m_search);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (showFlatBrowsePane) {
|
||||||
|
pane.setDefaultPane(m_flatBrowse);
|
||||||
|
}
|
||||||
|
|
||||||
//pane.addActionListener(this);
|
//pane.addActionListener(this);
|
||||||
// pane.setTabVisible(null, pane, true);
|
// pane.setTabVisible(null, pane, true);
|
||||||
return pane;
|
return pane;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the specified component, with the specified tab name, to the
|
* Adds the specified component, with the specified tab name, to the tabbed pane only if it is not null.
|
||||||
* tabbed pane only if it is not null.
|
|
||||||
*
|
*
|
||||||
* @param pane The pane to which to add the tab
|
* @param pane The pane to which to add the tab
|
||||||
* @param tabName The name of the tab if it's added
|
* @param tabName The name of the tab if it's added
|
||||||
* @param comp The component to add to the pane
|
* @param comp The component to add to the pane
|
||||||
*/
|
*/
|
||||||
protected void addToPane(TabbedPane pane, String tabName, Component comp) {
|
protected void addToPane(TabbedPane pane, String tabName, Component comp) {
|
||||||
if (comp != null) {
|
if (comp != null) {
|
||||||
|
|
@ -178,8 +182,7 @@ public class ItemSearchPage extends CMSPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When a new tab is selected, reset the state of the
|
* When a new tab is selected, reset the state of the formerly-selected pane.
|
||||||
* formerly-selected pane.
|
|
||||||
*
|
*
|
||||||
* @param event The event fired by selecting a tab
|
* @param event The event fired by selecting a tab
|
||||||
*/
|
*/
|
||||||
|
|
@ -197,8 +200,8 @@ public class ItemSearchPage extends CMSPage {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void dispatch(final HttpServletRequest request,
|
public void dispatch(final HttpServletRequest request,
|
||||||
final HttpServletResponse response,
|
final HttpServletResponse response,
|
||||||
RequestContext actx)
|
RequestContext actx)
|
||||||
throws IOException, ServletException {
|
throws IOException, ServletException {
|
||||||
new CMSExcursion() {
|
new CMSExcursion() {
|
||||||
|
|
||||||
|
|
@ -220,10 +223,12 @@ public class ItemSearchPage extends CMSPage {
|
||||||
|
|
||||||
final Document doc = buildDocument(request, response);
|
final Document doc = buildDocument(request, response);
|
||||||
final PresentationManager pm =
|
final PresentationManager pm =
|
||||||
Templating.getPresentationManager();
|
Templating.getPresentationManager();
|
||||||
|
|
||||||
pm.servePage(doc, request, response);
|
pm.servePage(doc, request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
}.run();
|
}.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,10 +34,8 @@ import java.math.BigDecimal;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An extension of {@link ItemSearch} for use in a popup
|
* An extension of {@link ItemSearch} for use in a popup search window. The display of results is altered so that
|
||||||
* search window. The display of results is altered so that
|
* selecting a result closes the window & passes the id of the selected item back to the opener.
|
||||||
* selecting a result closes the window & passes the id of
|
|
||||||
* the selected item back to the opener.
|
|
||||||
*
|
*
|
||||||
* @author Stanislav Freidin (sfreidin@arsdigita.com)
|
* @author Stanislav Freidin (sfreidin@arsdigita.com)
|
||||||
* @version $Id: ItemSearchPopup.java 1397 2006-11-29 14:10:38Z sskracic $
|
* @version $Id: ItemSearchPopup.java 1397 2006-11-29 14:10:38Z sskracic $
|
||||||
|
|
@ -45,14 +43,16 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
public class ItemSearchPopup extends ItemSearch {
|
public class ItemSearchPopup extends ItemSearch {
|
||||||
|
|
||||||
private static final org.apache.log4j.Logger s_log =
|
private static final org.apache.log4j.Logger s_log =
|
||||||
org.apache.log4j.Logger.getLogger(ItemSearchPopup.class);
|
org.apache.log4j.Logger.getLogger(ItemSearchPopup.class);
|
||||||
public static final String WIDGET_PARAM = "widget";
|
public static final String WIDGET_PARAM = "widget";
|
||||||
public static final String URL_PARAM = "useURL";
|
public static final String URL_PARAM = "useURL";
|
||||||
|
public static final String QUERY = "query";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new <code>ItemSearchPopup</code> component
|
* Construct a new
|
||||||
|
* <code>ItemSearchPopup</code> component
|
||||||
*
|
*
|
||||||
* @param context the context for the retrieved items. Should be
|
* @param context the context for the retrieved items. Should be
|
||||||
* {@link ContentItem#DRAFT} or {@link ContentItem#LIVE}
|
* {@link ContentItem#DRAFT} or {@link ContentItem#LIVE}
|
||||||
* @param limitToContentSection limit the search to the current content section
|
* @param limitToContentSection limit the search to the current content section
|
||||||
*/
|
*/
|
||||||
|
|
@ -66,6 +66,7 @@ public class ItemSearchPopup extends ItemSearch {
|
||||||
super.register(p);
|
super.register(p);
|
||||||
p.addGlobalStateParam(new StringParameter(WIDGET_PARAM));
|
p.addGlobalStateParam(new StringParameter(WIDGET_PARAM));
|
||||||
p.addGlobalStateParam(new StringParameter(URL_PARAM));
|
p.addGlobalStateParam(new StringParameter(URL_PARAM));
|
||||||
|
p.addGlobalStateParam(new StringParameter(QUERY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -83,6 +84,7 @@ public class ItemSearchPopup extends ItemSearch {
|
||||||
protected Component createResultsPane(QueryGenerator generator) {
|
protected Component createResultsPane(QueryGenerator generator) {
|
||||||
return new PopupResultsPane(generator);
|
return new PopupResultsPane(generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -112,38 +114,39 @@ public class ItemSearchPopup extends ItemSearch {
|
||||||
|
|
||||||
String widget = (String) state.getValue(
|
String widget = (String) state.getValue(
|
||||||
new StringParameter(WIDGET_PARAM));
|
new StringParameter(WIDGET_PARAM));
|
||||||
|
String searchWidget = (String) state.getValue(new StringParameter("searchWidget"));
|
||||||
|
|
||||||
boolean useURL = "true".equals(
|
boolean useURL = "true".equals(
|
||||||
state.getValue(new StringParameter(URL_PARAM)));
|
state.getValue(new StringParameter(URL_PARAM)));
|
||||||
|
|
||||||
String fillString = useURL
|
String fillString = useURL
|
||||||
? getItemURL(state.getRequest(), doc.getOID())
|
? getItemURL(state.getRequest(), doc.getOID())
|
||||||
: doc.getOID().get("id").toString()
|
: doc.getOID().get("id").toString()
|
||||||
+ " (" + doc.getTitle() + ")";
|
+ " (" + doc.getTitle() + ")";
|
||||||
|
String title = doc.getTitle();
|
||||||
|
|
||||||
Element jsLabel = Search.newElement("jsAction");
|
Element jsLabel = Search.newElement("jsAction");
|
||||||
jsLabel.addAttribute("name", "fillItem"
|
jsLabel.addAttribute("name", "fillItem"
|
||||||
+ doc.getOID().get("id") + "()");
|
+ doc.getOID().get("id") + "()");
|
||||||
jsLabel.setText(generateJSLabel((BigDecimal) doc.getOID().get("id"),
|
jsLabel.setText(generateJSLabel((BigDecimal) doc.getOID().get("id"),
|
||||||
widget, fillString));
|
widget, searchWidget, fillString, title));
|
||||||
element.addContent(jsLabel);
|
element.addContent(jsLabel);
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateJSLabel(BigDecimal id, String widget, String fill) {
|
private String generateJSLabel(BigDecimal id, String widget, String searchWidget, String fill, String title) {
|
||||||
return " <script language=javascript> "
|
return " <script language=javascript> "
|
||||||
+ " <!-- \n"
|
+ " <!-- \n"
|
||||||
+ " function fillItem"
|
+ " function fillItem" + id + "() { \n"
|
||||||
+ id
|
+ " window.opener.document." + widget + ".value=\"" + fill + "\";\n"
|
||||||
+ "() { \n"
|
+ " window.opener.document." + searchWidget + ".value=\"" + title + "\";\n"
|
||||||
+ " window.opener.document."
|
+ " self.close(); \n"
|
||||||
+ widget + ".value=\"" + fill + "\";\n"
|
+ " return false; \n"
|
||||||
+ " self.close(); \n"
|
+ " } \n"
|
||||||
+ " return false; \n"
|
+ " --> \n"
|
||||||
+ " } \n"
|
+ " </script> ";
|
||||||
+ " --> \n"
|
|
||||||
+ " </script> ";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ public class ItemSearchWidget extends FormSection
|
||||||
//this.setReadOnly();
|
//this.setReadOnly();
|
||||||
this.setSize(35);
|
this.setSize(35);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SearchFragment extends Submit {
|
private class SearchFragment extends Submit {
|
||||||
|
|
@ -105,6 +106,7 @@ public class ItemSearchWidget extends FormSection
|
||||||
|| parent.m_searchComponent.hasQuery(ps))
|
|| parent.m_searchComponent.hasQuery(ps))
|
||||||
&& super.isVisible(ps));
|
&& super.isVisible(ps));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ClearFragment extends Submit {
|
private class ClearFragment extends Submit {
|
||||||
|
|
@ -118,6 +120,7 @@ public class ItemSearchWidget extends FormSection
|
||||||
+ ".value = \"\"; return false;");
|
+ ".value = \"\"; return false;");
|
||||||
this.setAttribute("value", "Clear");
|
this.setAttribute("value", "Clear");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class LabelFragment extends Label {
|
private class LabelFragment extends Label {
|
||||||
|
|
@ -129,6 +132,7 @@ public class ItemSearchWidget extends FormSection
|
||||||
super(name, escaping);
|
super(name, escaping);
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ItemSearchFragment extends ItemSearchSectionInline {
|
private class ItemSearchFragment extends ItemSearchSectionInline {
|
||||||
|
|
@ -156,6 +160,7 @@ public class ItemSearchWidget extends FormSection
|
||||||
|| hasQuery(ps))
|
|| hasQuery(ps))
|
||||||
&& super.isVisible(ps));
|
&& super.isVisible(ps));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class HRLabel extends Label {
|
private class HRLabel extends Label {
|
||||||
|
|
@ -170,6 +175,7 @@ public class ItemSearchWidget extends FormSection
|
||||||
|| m_searchComponent.hasQuery(ps))
|
|| m_searchComponent.hasQuery(ps))
|
||||||
&& super.isVisible(ps));
|
&& super.isVisible(ps));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -204,7 +210,7 @@ public class ItemSearchWidget extends FormSection
|
||||||
} else {
|
} else {
|
||||||
typeURLFrag = null;
|
typeURLFrag = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_searchModel = new StringParameter(SEARCH);
|
m_searchModel = new StringParameter(SEARCH);
|
||||||
|
|
||||||
m_contentType = contentType;
|
m_contentType = contentType;
|
||||||
|
|
@ -226,7 +232,7 @@ public class ItemSearchWidget extends FormSection
|
||||||
CMS.getContext().getContentSection().getID());
|
CMS.getContext().getContentSection().getID());
|
||||||
params.setParameter("widget", formName + ".elements['" + m_selected. //m_item.
|
params.setParameter("widget", formName + ".elements['" + m_selected. //m_item.
|
||||||
getName() + "']");
|
getName() + "']");
|
||||||
params.setParameter("searchWidget", formName + ".elements['" + m_item.getName() + "']");
|
params.setParameter("searchWidget", formName + ".elements['" + m_item.getName() + "']");
|
||||||
if (typeURLFrag != null) {
|
if (typeURLFrag != null) {
|
||||||
params.setParameter("single_type", typeURLFrag);
|
params.setParameter("single_type", typeURLFrag);
|
||||||
}
|
}
|
||||||
|
|
@ -248,13 +254,15 @@ public class ItemSearchWidget extends FormSection
|
||||||
//+ m_item.getName().replace('.', '_')
|
//+ m_item.getName().replace('.', '_')
|
||||||
+ m_selected.getName().replace('.', '_')
|
+ m_selected.getName().replace('.', '_')
|
||||||
+ "Popup(theForm) { \n"
|
+ "Popup(theForm) { \n"
|
||||||
+ " aWindow = window.open(\"" + url + "\", "
|
+ " 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=800,height=600,status=no,scrollbars=yes,resize=yes\");\n"
|
||||||
|
+ "\"search\", \"toolbar=yes,width=\" + screen.width*0.5 + \",height=\" + screen.height*0.5 + \",status=no,scrollbars=yes,resize=yes\");\n"
|
||||||
+ "return false;\n"
|
+ "return false;\n"
|
||||||
+ " } \n"
|
+ " } \n"
|
||||||
+ " --> \n"
|
+ " --> \n"
|
||||||
+ " </script> ");
|
+ " </script> ");
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
m_topHR = new HRLabel();
|
m_topHR = new HRLabel();
|
||||||
add(m_topHR);
|
add(m_topHR);
|
||||||
|
|
@ -417,4 +425,5 @@ public class ItemSearchWidget extends FormSection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue