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.flatBrowse=Select item
|
||||
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.flatBrowse=Item ausw\u00e4hlen
|
||||
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.flatBrowse=Select item
|
||||
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.flatBrowse=Select item
|
||||
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.FormData;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.GridPanel;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Link;
|
||||
import com.arsdigita.bebop.Page;
|
||||
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.event.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.event.PrintEvent;
|
||||
import com.arsdigita.bebop.event.PrintListener;
|
||||
import com.arsdigita.bebop.form.Submit;
|
||||
import com.arsdigita.bebop.form.TextField;
|
||||
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||
import com.arsdigita.bebop.parameters.ParameterData;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||
import com.arsdigita.bebop.table.TableColumn;
|
||||
|
|
@ -31,11 +36,14 @@ import com.arsdigita.cms.Folder;
|
|||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.DataQuery;
|
||||
import com.arsdigita.persistence.Session;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.toolbox.ui.DataQueryBuilder;
|
||||
import com.arsdigita.toolbox.ui.DataTable;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
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 {
|
||||
|
||||
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 SEARCHWIDGET_PARAM = "searchWidget";
|
||||
public static final String FILTER_SUBMIT = "filterSubmit";
|
||||
private final Table resultsTable;
|
||||
private final Paginator paginator;
|
||||
private final StringParameter queryParam;
|
||||
private final Label jsLabel;
|
||||
|
||||
|
||||
public ItemSearchFlatBrowsePane(final String name) {
|
||||
super(name);
|
||||
|
||||
final BoxPanel mainPanel = new BoxPanel(BoxPanel.VERTICAL);
|
||||
|
||||
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")));
|
||||
final TextField filter = new TextField(new StringParameter(QUERY_PARAM));
|
||||
boxPanel.add(filter);
|
||||
jsLabel = new Label("", false);
|
||||
jsLabel.addPrintListener(new PrintListener() {
|
||||
|
||||
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);
|
||||
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")));
|
||||
mainPanel.add(boxPanel);
|
||||
|
||||
resultsTable = new ResultsTable();
|
||||
add(resultsTable);
|
||||
|
||||
paginator = new Paginator((PaginationModelBuilder) resultsTable.getModelBuilder(), 5);
|
||||
mainPanel.add(paginator);
|
||||
|
||||
mainPanel.add(resultsTable);
|
||||
|
||||
add(mainPanel);
|
||||
|
||||
addInitListener(this);
|
||||
addProcessListener(this);
|
||||
}
|
||||
|
|
@ -95,8 +92,15 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
|||
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 {
|
||||
|
|
@ -104,6 +108,7 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
|||
final PageState state = fse.getPageState();
|
||||
|
||||
state.setValue(queryParam, data.get(QUERY_PARAM));
|
||||
state.setValue(new StringParameter(ItemSearchPopup.QUERY), data.get(QUERY_PARAM));
|
||||
}
|
||||
|
||||
private class ResultsTable extends Table {
|
||||
|
|
@ -115,6 +120,7 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
|||
public ResultsTable() {
|
||||
super();
|
||||
setEmptyView(new Label(GlobalizationUtil.globalize("cms.ui.item_search.flat.no_items")));
|
||||
setClassAttr("dataTable");
|
||||
|
||||
final TableColumnModel columnModel = getColumnModel();
|
||||
columnModel.add(new TableColumn(0,
|
||||
|
|
@ -128,16 +134,61 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
|||
TABLE_COL_TYPE));
|
||||
|
||||
setModelBuilder(new ResultsTableModelBuilder());
|
||||
|
||||
|
||||
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) {
|
||||
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 ContentItem currentItem;
|
||||
|
||||
public ResultsTableModel(final Table table, final PageState state) {
|
||||
public ResultsTableModel(final Table table, final PageState state, final DataCollection collection) {
|
||||
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);
|
||||
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));
|
||||
this.collection = collection;
|
||||
|
||||
/*
|
||||
* 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); 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() {
|
||||
|
|
@ -227,35 +277,39 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener,
|
|||
public Object getKeyAt(final int columnIndex) {
|
||||
return currentItem.getID();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private class TitleCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
public Component getComponent(final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final boolean isSelected,
|
||||
public Component getComponent(final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final boolean isSelected,
|
||||
final Object key,
|
||||
final int row,
|
||||
final int row,
|
||||
final int column) {
|
||||
|
||||
if (value == null) {
|
||||
return new Label("???");
|
||||
}
|
||||
|
||||
final Link link = new Link(value.toString(), "");
|
||||
|
||||
|
||||
final String widget = (String) state.getValue(new StringParameter(WIDGET_PARAM));
|
||||
final String searchWidget = (String) state.getValue(new StringParameter(SEARCHWIDGET_PARAM));
|
||||
|
||||
|
||||
final ContentPage page = new ContentPage((BigDecimal) key);
|
||||
|
||||
|
||||
link.setOnClick(String.format(
|
||||
"window.opener.document.%s.value=\"%s\";window.opener.document.%s.value=\"%s\";self.close();return false;",
|
||||
widget,
|
||||
key.toString(),
|
||||
searchWidget,
|
||||
page.getTitle()));
|
||||
|
||||
widget,
|
||||
key.toString(),
|
||||
searchWidget,
|
||||
page.getTitle()));
|
||||
|
||||
return link;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ import com.arsdigita.bebop.table.TableModel;
|
|||
import com.arsdigita.bebop.util.BebopConstants;
|
||||
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.Folder;
|
||||
|
|
@ -347,6 +348,7 @@ public class ItemSearchFolderBrowser extends Table {
|
|||
String widget =
|
||||
(String) state.getValue(new StringParameter(
|
||||
ItemSearchPopup.WIDGET_PARAM));
|
||||
String searchWidget = (String) state.getValue(new StringParameter("searchWidget"));
|
||||
boolean useURL =
|
||||
"true".equals(state.getValue(new StringParameter(
|
||||
ItemSearchPopup.URL_PARAM)));
|
||||
|
|
@ -358,9 +360,9 @@ public class ItemSearchFolderBrowser extends Table {
|
|||
getDomainObject().getOID())
|
||||
: id
|
||||
+ " (" + name + ")";
|
||||
String title = ((ContentPage) coll.getDomainObject()).getTitle();
|
||||
|
||||
Label js = new Label(generateJSLabel(id, widget,
|
||||
fillString),
|
||||
Label js = new Label(generateJSLabel(id, widget, searchWidget, fillString, title),
|
||||
false);
|
||||
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();
|
||||
buffer.append(" <script language=javascript> "
|
||||
+ " <!-- \n"
|
||||
+ " function fillItem"
|
||||
+ id
|
||||
+ "() { \n"
|
||||
+ " window.opener.document."
|
||||
+ widget + ".value=\"" + fill + "\";\n");
|
||||
buffer.append(" <script language=javascript> ");
|
||||
buffer.append( " <!-- \n");
|
||||
buffer.append(" function fillItem").append(id).append("() { \n");
|
||||
buffer.append(" window.opener.document.").append(widget).append(".value=\"").append(fill).append("\";\n");
|
||||
buffer.append(" window.opener.document.").append(searchWidget).append(".value=\"").append(title).append("\";\n");
|
||||
// set protocol to 'other' in FCKEditor, else relative url prepended by http://
|
||||
if (Bebop.getConfig().getDHTMLEditor().equals(
|
||||
BebopConstants.BEBOP_FCKEDITOR)) {
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ public class ItemSearchPage extends CMSPage {
|
|||
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";
|
||||
private boolean showFlatBrowsePane = false;
|
||||
|
||||
/**
|
||||
* Construct a new ItemSearchPage
|
||||
|
|
@ -73,13 +74,15 @@ public class ItemSearchPage extends CMSPage {
|
|||
|
||||
addGlobalStateParam(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM));
|
||||
addGlobalStateParam(new StringParameter(ItemSearchPopup.WIDGET_PARAM));
|
||||
addGlobalStateParam(new StringParameter("searchWidget"));
|
||||
addGlobalStateParam(new StringParameter("searchWidget"));
|
||||
|
||||
m_sectionId = new BigDecimalParameter(CONTENT_SECTION);
|
||||
addGlobalStateParam(m_sectionId);
|
||||
|
||||
m_browse = getBrowsePane();
|
||||
m_flatBrowse = getFlatBrowsePane();
|
||||
if (showFlatBrowsePane) {
|
||||
m_flatBrowse = getFlatBrowsePane();
|
||||
}
|
||||
m_search = getSearchPane();
|
||||
// m_create = getCreatePane();
|
||||
|
||||
|
|
@ -89,9 +92,8 @@ public class ItemSearchPage extends CMSPage {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates, and then caches, the Browse pane. Overriding this
|
||||
* method to return null will prevent this tab from appearing.
|
||||
* Note: not implemented yet.
|
||||
* Creates, and then caches, the Browse pane. Overriding this method to return null will prevent this tab from
|
||||
* appearing. Note: not implemented yet.
|
||||
*/
|
||||
protected ItemSearchBrowsePane getBrowsePane() {
|
||||
if (m_browse == null) {
|
||||
|
|
@ -101,17 +103,17 @@ public class ItemSearchPage extends CMSPage {
|
|||
return m_browse;
|
||||
}
|
||||
|
||||
protected ItemSearchFlatBrowsePane getFlatBrowsePane() {
|
||||
protected ItemSearchFlatBrowsePane getFlatBrowsePane() {
|
||||
if (m_flatBrowse == null) {
|
||||
m_flatBrowse = new ItemSearchFlatBrowsePane("flatBrowse");
|
||||
}
|
||||
|
||||
|
||||
return m_flatBrowse;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates, and then caches, the Creation pane. Overriding this
|
||||
* method to return null will prevent this tab from appearing.
|
||||
* Creates, and then caches, the Creation pane. Overriding this method to return null will prevent this tab from
|
||||
* appearing.
|
||||
*/
|
||||
protected ItemSearchPopup getSearchPane() {
|
||||
if (m_search == null) {
|
||||
|
|
@ -130,46 +132,48 @@ public class ItemSearchPage extends CMSPage {
|
|||
//
|
||||
// return m_create;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Created the TabbedPane to use for this page. Sets the class
|
||||
* attribute for this tabbed pane. The default implementation uses a
|
||||
* {@link com.arsdigita.bebop.TabbedPane} and sets the class
|
||||
* attribute to "CMS Admin." This implementation also adds tasks,
|
||||
* content sections, and search panes.
|
||||
* Created the TabbedPane to use for this page. Sets the class attribute for this tabbed pane. The default
|
||||
* implementation uses a
|
||||
* {@link com.arsdigita.bebop.TabbedPane} and sets the class attribute to "CMS Admin." This implementation also adds
|
||||
* tasks, content sections, and search panes.
|
||||
*
|
||||
* Developers can override this method to add only the tabs they
|
||||
* want, or to add additional tabs after the default CMS tabs are
|
||||
* added.
|
||||
* Developers can override this method to add only the tabs they want, or to add additional tabs after the default
|
||||
* CMS tabs are added.
|
||||
*/
|
||||
protected TabbedPane createTabbedPane() {
|
||||
TabbedPane pane = new TabbedPane();
|
||||
pane.setClassAttr(XSL_CLASS);
|
||||
|
||||
addToPane(pane, "flatBrowse", getFlatBrowsePane());
|
||||
if (showFlatBrowsePane) {
|
||||
addToPane(pane, "flatBrowse", getFlatBrowsePane());
|
||||
}
|
||||
addToPane(pane, "browse", getBrowsePane());
|
||||
addToPane(pane, "search", getSearchPane());
|
||||
// addToPane(pane, "create", getCreatePane());
|
||||
|
||||
if(s_conf.getItemSearchDefaultTab().equals("browse")) {
|
||||
if (s_conf.getItemSearchDefaultTab().equals("browse")) {
|
||||
pane.setDefaultPane(m_browse);
|
||||
}
|
||||
if(s_conf.getItemSearchDefaultTab().equals("search")) {
|
||||
if (s_conf.getItemSearchDefaultTab().equals("search")) {
|
||||
pane.setDefaultPane(m_search);
|
||||
}
|
||||
|
||||
if (showFlatBrowsePane) {
|
||||
pane.setDefaultPane(m_flatBrowse);
|
||||
}
|
||||
|
||||
//pane.addActionListener(this);
|
||||
// pane.setTabVisible(null, pane, true);
|
||||
return pane;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified component, with the specified tab name, to the
|
||||
* tabbed pane only if it is not null.
|
||||
* Adds the specified component, with the specified tab name, to the 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 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) {
|
||||
if (comp != null) {
|
||||
|
|
@ -178,8 +182,7 @@ public class ItemSearchPage extends CMSPage {
|
|||
}
|
||||
|
||||
/**
|
||||
* When a new tab is selected, reset the state of the
|
||||
* formerly-selected pane.
|
||||
* When a new tab is selected, reset the state of the formerly-selected pane.
|
||||
*
|
||||
* @param event The event fired by selecting a tab
|
||||
*/
|
||||
|
|
@ -197,8 +200,8 @@ public class ItemSearchPage extends CMSPage {
|
|||
*/
|
||||
@Override
|
||||
public void dispatch(final HttpServletRequest request,
|
||||
final HttpServletResponse response,
|
||||
RequestContext actx)
|
||||
final HttpServletResponse response,
|
||||
RequestContext actx)
|
||||
throws IOException, ServletException {
|
||||
new CMSExcursion() {
|
||||
|
||||
|
|
@ -220,10 +223,12 @@ public class ItemSearchPage extends CMSPage {
|
|||
|
||||
final Document doc = buildDocument(request, response);
|
||||
final PresentationManager pm =
|
||||
Templating.getPresentationManager();
|
||||
Templating.getPresentationManager();
|
||||
|
||||
pm.servePage(doc, request, response);
|
||||
}
|
||||
|
||||
}.run();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,10 +34,8 @@ import java.math.BigDecimal;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* An extension of {@link ItemSearch} for use in a popup
|
||||
* 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.
|
||||
* An extension of {@link ItemSearch} for use in a popup 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.
|
||||
*
|
||||
* @author Stanislav Freidin (sfreidin@arsdigita.com)
|
||||
* @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 {
|
||||
|
||||
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 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}
|
||||
* @param limitToContentSection limit the search to the current content section
|
||||
*/
|
||||
|
|
@ -66,6 +66,7 @@ public class ItemSearchPopup extends ItemSearch {
|
|||
super.register(p);
|
||||
p.addGlobalStateParam(new StringParameter(WIDGET_PARAM));
|
||||
p.addGlobalStateParam(new StringParameter(URL_PARAM));
|
||||
p.addGlobalStateParam(new StringParameter(QUERY));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -83,6 +84,7 @@ public class ItemSearchPopup extends ItemSearch {
|
|||
protected Component createResultsPane(QueryGenerator generator) {
|
||||
return new PopupResultsPane(generator);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -112,38 +114,39 @@ public class ItemSearchPopup extends ItemSearch {
|
|||
|
||||
String widget = (String) state.getValue(
|
||||
new StringParameter(WIDGET_PARAM));
|
||||
String searchWidget = (String) state.getValue(new StringParameter("searchWidget"));
|
||||
|
||||
boolean useURL = "true".equals(
|
||||
state.getValue(new StringParameter(URL_PARAM)));
|
||||
|
||||
String fillString = useURL
|
||||
? getItemURL(state.getRequest(), doc.getOID())
|
||||
: doc.getOID().get("id").toString()
|
||||
+ " (" + doc.getTitle() + ")";
|
||||
? getItemURL(state.getRequest(), doc.getOID())
|
||||
: doc.getOID().get("id").toString()
|
||||
+ " (" + doc.getTitle() + ")";
|
||||
String title = doc.getTitle();
|
||||
|
||||
Element jsLabel = Search.newElement("jsAction");
|
||||
jsLabel.addAttribute("name", "fillItem"
|
||||
+ doc.getOID().get("id") + "()");
|
||||
+ doc.getOID().get("id") + "()");
|
||||
jsLabel.setText(generateJSLabel((BigDecimal) doc.getOID().get("id"),
|
||||
widget, fillString));
|
||||
widget, searchWidget, fillString, title));
|
||||
element.addContent(jsLabel);
|
||||
|
||||
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> "
|
||||
+ " <!-- \n"
|
||||
+ " function fillItem"
|
||||
+ id
|
||||
+ "() { \n"
|
||||
+ " window.opener.document."
|
||||
+ widget + ".value=\"" + fill + "\";\n"
|
||||
+ " self.close(); \n"
|
||||
+ " return false; \n"
|
||||
+ " } \n"
|
||||
+ " --> \n"
|
||||
+ " </script> ";
|
||||
+ " <!-- \n"
|
||||
+ " function fillItem" + id + "() { \n"
|
||||
+ " window.opener.document." + widget + ".value=\"" + fill + "\";\n"
|
||||
+ " window.opener.document." + searchWidget + ".value=\"" + title + "\";\n"
|
||||
+ " self.close(); \n"
|
||||
+ " return false; \n"
|
||||
+ " } \n"
|
||||
+ " --> \n"
|
||||
+ " </script> ";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ public class ItemSearchWidget extends FormSection
|
|||
//this.setReadOnly();
|
||||
this.setSize(35);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class SearchFragment extends Submit {
|
||||
|
|
@ -105,6 +106,7 @@ public class ItemSearchWidget extends FormSection
|
|||
|| parent.m_searchComponent.hasQuery(ps))
|
||||
&& super.isVisible(ps));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ClearFragment extends Submit {
|
||||
|
|
@ -118,6 +120,7 @@ public class ItemSearchWidget extends FormSection
|
|||
+ ".value = \"\"; return false;");
|
||||
this.setAttribute("value", "Clear");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class LabelFragment extends Label {
|
||||
|
|
@ -129,6 +132,7 @@ public class ItemSearchWidget extends FormSection
|
|||
super(name, escaping);
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ItemSearchFragment extends ItemSearchSectionInline {
|
||||
|
|
@ -156,6 +160,7 @@ public class ItemSearchWidget extends FormSection
|
|||
|| hasQuery(ps))
|
||||
&& super.isVisible(ps));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class HRLabel extends Label {
|
||||
|
|
@ -170,6 +175,7 @@ public class ItemSearchWidget extends FormSection
|
|||
|| m_searchComponent.hasQuery(ps))
|
||||
&& super.isVisible(ps));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -204,7 +210,7 @@ public class ItemSearchWidget extends FormSection
|
|||
} else {
|
||||
typeURLFrag = null;
|
||||
}
|
||||
|
||||
|
||||
m_searchModel = new StringParameter(SEARCH);
|
||||
|
||||
m_contentType = contentType;
|
||||
|
|
@ -226,7 +232,7 @@ public class ItemSearchWidget extends FormSection
|
|||
CMS.getContext().getContentSection().getID());
|
||||
params.setParameter("widget", formName + ".elements['" + m_selected. //m_item.
|
||||
getName() + "']");
|
||||
params.setParameter("searchWidget", formName + ".elements['" + m_item.getName() + "']");
|
||||
params.setParameter("searchWidget", formName + ".elements['" + m_item.getName() + "']");
|
||||
if (typeURLFrag != null) {
|
||||
params.setParameter("single_type", typeURLFrag);
|
||||
}
|
||||
|
|
@ -248,13 +254,15 @@ public class ItemSearchWidget extends FormSection
|
|||
//+ m_item.getName().replace('.', '_')
|
||||
+ m_selected.getName().replace('.', '_')
|
||||
+ "Popup(theForm) { \n"
|
||||
+ " aWindow = window.open(\"" + url + "\", "
|
||||
+ "\"search\", \"toolbar=no,width=800,height=600,status=no,scrollbars=yes,resize=yes\");\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=yes,width=\" + screen.width*0.5 + \",height=\" + screen.height*0.5 + \",status=no,scrollbars=yes,resize=yes\");\n"
|
||||
+ "return false;\n"
|
||||
+ " } \n"
|
||||
+ " --> \n"
|
||||
+ " </script> ");
|
||||
}
|
||||
|
||||
});
|
||||
m_topHR = new HRLabel();
|
||||
add(m_topHR);
|
||||
|
|
@ -417,4 +425,5 @@ public class ItemSearchWidget extends FormSection
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue