ItemSearch Widget Optimierungen
git-svn-id: https://svn.libreccm.org/ccm/trunk@1741 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
74885251dd
commit
de45a6eb0c
|
|
@ -542,11 +542,11 @@ public final class CMSConfig extends AbstractConfig {
|
|||
private final Parameter m_itemSearchDefaultTab =
|
||||
new StringParameter(
|
||||
"com.arsdigita.cms.item_search.default_tab",
|
||||
Parameter.REQUIRED, "browse");
|
||||
private final Parameter m_itemSearchFlatBrowsePaneEnable = new BooleanParameter(
|
||||
"com.arsdigita.cms.item_search.flat_browse_pane.enable",
|
||||
Parameter.REQUIRED,
|
||||
true);
|
||||
Parameter.REQUIRED, "flatBrowse");
|
||||
// private final Parameter m_itemSearchFlatBrowsePaneEnable = new BooleanParameter(
|
||||
// "com.arsdigita.cms.item_search.flat_browse_pane.enable",
|
||||
// Parameter.REQUIRED,
|
||||
// true);
|
||||
private final Parameter m_itemSearchFlatBrowsePanePageSize = new IntegerParameter(
|
||||
"com.arsdigita.cms.item_search.flat_browse_pane.page_size",
|
||||
Parameter.REQUIRED,
|
||||
|
|
@ -705,7 +705,7 @@ public final class CMSConfig extends AbstractConfig {
|
|||
// register(m_disableItemPfs);
|
||||
// register(m_publishToFileClass);
|
||||
|
||||
register(m_itemSearchFlatBrowsePaneEnable);
|
||||
// register(m_itemSearchFlatBrowsePaneEnable);
|
||||
register(m_itemSearchFlatBrowsePanePageSize);
|
||||
|
||||
loadInfo();
|
||||
|
|
@ -1156,9 +1156,9 @@ public final class CMSConfig extends AbstractConfig {
|
|||
return (Integer) get(m_imageBrowserThumbnailMaxHeight);
|
||||
}
|
||||
|
||||
public Boolean getItemSearchFlatBrowsePaneEnable() {
|
||||
return (Boolean) get(m_itemSearchFlatBrowsePaneEnable);
|
||||
}
|
||||
// public Boolean getItemSearchFlatBrowsePaneEnable() {
|
||||
// return (Boolean) get(m_itemSearchFlatBrowsePaneEnable);
|
||||
// }
|
||||
|
||||
public Integer getItemSearchFlatBrowsePanePageSize() {
|
||||
return (Integer) get(m_itemSearchFlatBrowsePanePageSize);
|
||||
|
|
|
|||
|
|
@ -1100,3 +1100,4 @@ 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
|
||||
cms.ui.item_search.selected=Selected content item (id)
|
||||
|
|
|
|||
|
|
@ -1091,3 +1091,4 @@ 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
|
||||
cms.ui.item_search.selected=Ausgew\u00e4hltes Content Item (ID)
|
||||
|
|
|
|||
|
|
@ -39,3 +39,4 @@ 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=
|
||||
cms.ui.item_search.selected=
|
||||
|
|
|
|||
|
|
@ -570,3 +570,4 @@ 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=
|
||||
cms.ui.item_search.selected=
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
*
|
||||
* @author Scott Seago (scott@arsdigita.com)
|
||||
* @author Sören Bernstein (sbernstein@quasiweb.de)
|
||||
* @author Jens Pelzetter (jens@jp-digital.de)
|
||||
*/
|
||||
public class ItemSearchPage extends CMSPage {
|
||||
|
||||
|
|
@ -65,7 +66,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 final boolean showFlatBrowsePane;
|
||||
//private final boolean showFlatBrowsePane;
|
||||
|
||||
/**
|
||||
* Construct a new ItemSearchPage
|
||||
|
|
@ -79,16 +80,16 @@ public class ItemSearchPage extends CMSPage {
|
|||
addGlobalStateParam(new StringParameter(ItemSearchPopup.WIDGET_PARAM));
|
||||
addGlobalStateParam(new StringParameter("searchWidget"));
|
||||
|
||||
showFlatBrowsePane = s_conf.getItemSearchFlatBrowsePaneEnable();
|
||||
//showFlatBrowsePane = s_conf.getItemSearchFlatBrowsePaneEnable();
|
||||
|
||||
|
||||
m_sectionId = new BigDecimalParameter(CONTENT_SECTION);
|
||||
addGlobalStateParam(m_sectionId);
|
||||
|
||||
m_browse = getBrowsePane();
|
||||
if (showFlatBrowsePane) {
|
||||
m_flatBrowse = getFlatBrowsePane();
|
||||
}
|
||||
// if (showFlatBrowsePane) {
|
||||
// m_flatBrowse = getFlatBrowsePane();
|
||||
// }
|
||||
m_search = getSearchPane();
|
||||
// m_create = getCreatePane();
|
||||
|
||||
|
|
@ -100,6 +101,14 @@ public class ItemSearchPage extends CMSPage {
|
|||
public void pageRequested(final RequestEvent event) {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
final String query = (String) state.getValue(new StringParameter(ItemSearchPopup.QUERY));
|
||||
|
||||
if ((query == null) || query.isEmpty()) {
|
||||
m_tabbedPane.setSelectedIndex(state, 1);
|
||||
} else {
|
||||
m_tabbedPane.setSelectedIndex(state, 0);
|
||||
}
|
||||
|
||||
//if (showFlatBrowsePane) {
|
||||
// m_tabbedPane.setTabVisible(state, 0, false);
|
||||
// m_tabbedPane.setSelectedIndex(state, 1);
|
||||
|
|
@ -163,9 +172,9 @@ public class ItemSearchPage extends CMSPage {
|
|||
TabbedPane pane = new TabbedPane();
|
||||
pane.setClassAttr(XSL_CLASS);
|
||||
|
||||
if (showFlatBrowsePane) {
|
||||
//if (showFlatBrowsePane) {
|
||||
addToPane(pane, "flatBrowse", getFlatBrowsePane());
|
||||
}
|
||||
//}
|
||||
addToPane(pane, "browse", getBrowsePane());
|
||||
addToPane(pane, "search", getSearchPane());
|
||||
// addToPane(pane, "create", getCreatePane());
|
||||
|
|
@ -176,11 +185,11 @@ public class ItemSearchPage extends CMSPage {
|
|||
if ("search".equals(s_conf.getItemSearchDefaultTab())) {
|
||||
pane.setDefaultPane(m_search);
|
||||
}
|
||||
if ("flatBrowse".equals(s_conf.getItemSearchDefaultTab()) && showFlatBrowsePane) {
|
||||
//if ("flatBrowse".equals(s_conf.getItemSearchDefaultTab()) && showFlatBrowsePane) {
|
||||
pane.setDefaultPane(m_flatBrowse);
|
||||
} else {
|
||||
//} else {
|
||||
pane.setDefaultPane(m_browse);
|
||||
}
|
||||
//}
|
||||
|
||||
//pane.addActionListener(this);
|
||||
// pane.setTabVisible(null, pane, true);
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import com.arsdigita.cms.ContentItem;
|
|||
import com.arsdigita.cms.ContentType;
|
||||
import com.arsdigita.cms.Workspace;
|
||||
import com.arsdigita.cms.WorkspaceServlet;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.web.ParameterMap;
|
||||
import com.arsdigita.web.URL;
|
||||
|
|
@ -57,7 +58,8 @@ public class ItemSearchWidget extends FormSection
|
|||
implements BebopConstants, FormSubmissionListener, FormInitListener {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(ItemSearchWidget.class);
|
||||
private Hidden m_selected;
|
||||
//private Hidden m_selected;
|
||||
private TextField m_selected;
|
||||
private TextField m_item;
|
||||
private Submit m_search;
|
||||
private Submit m_clear;
|
||||
|
|
@ -71,6 +73,8 @@ public class ItemSearchWidget extends FormSection
|
|||
private String m_clearName;
|
||||
private ParameterModel m_model;
|
||||
private ParameterModel m_searchModel;
|
||||
private String searchLabelText = (String) GlobalizationUtil.globalize("cms.ui.item_search.search").localize();
|
||||
private String selectedLabelText = (String) GlobalizationUtil.globalize("cms.ui.item_search.selected").localize();
|
||||
public static final String BEBOP_ITEM_SEARCH = "bebop:itemSearch";
|
||||
public static final String SEARCH = "search";
|
||||
public static final boolean LIMIT_TO_CONTENT_SECTION = false;
|
||||
|
|
@ -82,7 +86,7 @@ public class ItemSearchWidget extends FormSection
|
|||
public ItemFragment(ParameterModel parameter, ItemSearchWidget parent) {
|
||||
super(parameter);
|
||||
this.parent = parent;
|
||||
//this.setReadOnly();
|
||||
this.setReadOnly();
|
||||
this.setSize(35);
|
||||
}
|
||||
|
||||
|
|
@ -116,8 +120,9 @@ public class ItemSearchWidget extends FormSection
|
|||
public ClearFragment(String name, ItemSearchWidget parent) {
|
||||
super(name, "Clear");
|
||||
this.parent = parent;
|
||||
this.setAttribute("onClick", "this.form." + parent.m_selected.getName() //parent.m_item.getName()
|
||||
+ ".value = \"\"; return false;");
|
||||
this.setAttribute("onClick", "this.form." + parent.m_selected.getName() + ".value = \"\";"
|
||||
+ "this.form." + parent.m_item.getName() + ".value = \"\";"
|
||||
+ "return false;");
|
||||
this.setAttribute("value", "Clear");
|
||||
}
|
||||
|
||||
|
|
@ -189,8 +194,10 @@ public class ItemSearchWidget extends FormSection
|
|||
/**
|
||||
* Construct a new ItemSearchWidget. The model must be an
|
||||
* ItemSearchParameter
|
||||
* @param model
|
||||
* @param contentType
|
||||
*/
|
||||
public ItemSearchWidget(ParameterModel model, ContentType contentType) {
|
||||
public ItemSearchWidget(final ParameterModel model, final ContentType contentType) {
|
||||
super(new BoxPanel(BoxPanel.VERTICAL));
|
||||
|
||||
if (!(model instanceof ItemSearchParameter)) {
|
||||
|
|
@ -214,7 +221,23 @@ public class ItemSearchWidget extends FormSection
|
|||
m_searchModel = new StringParameter(SEARCH);
|
||||
|
||||
m_contentType = contentType;
|
||||
m_selected = new Hidden(model);
|
||||
//m_selected = new Hidden(model);
|
||||
m_selected = new ItemFragment(model, this);
|
||||
final Label selectedItemLabel = new Label(selectedLabelText);
|
||||
selectedItemLabel.addPrintListener(new PrintListener() {
|
||||
public void prepare(final PrintEvent event) {
|
||||
final Label target = (Label) event.getTarget();
|
||||
target.setLabel(selectedLabelText);
|
||||
}
|
||||
});
|
||||
final Label searchLabel = new Label(searchLabelText);
|
||||
searchLabel.addPrintListener(new PrintListener() {
|
||||
|
||||
public void prepare(final PrintEvent event) {
|
||||
final Label target = (Label) event.getTarget();
|
||||
target.setLabel(searchLabelText);
|
||||
}
|
||||
});
|
||||
//m_item = new ItemFragment(model, this);
|
||||
m_item = new TextField(m_searchModel);
|
||||
m_search = new SearchFragment(m_searchName, this);
|
||||
|
|
@ -232,7 +255,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);
|
||||
}
|
||||
|
|
@ -256,7 +279,7 @@ public class ItemSearchWidget extends FormSection
|
|||
+ "Popup(theForm) { \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"
|
||||
+ "\"search\", \"toolbar=no,width=\" + screen.width*0.5 + \",height=\" + screen.height*0.5 + \",status=no,scrollbars=yes,resize=yes\");\n"
|
||||
+ "return false;\n"
|
||||
+ " } \n"
|
||||
+ " --> \n"
|
||||
|
|
@ -266,12 +289,17 @@ public class ItemSearchWidget extends FormSection
|
|||
});
|
||||
m_topHR = new HRLabel();
|
||||
add(m_topHR);
|
||||
FormSection searchSection = new FormSection(new BoxPanel(
|
||||
BoxPanel.HORIZONTAL));
|
||||
searchSection.add(m_item);
|
||||
searchSection.add(m_selected);
|
||||
searchSection.add(m_search);
|
||||
searchSection.add(m_clear);
|
||||
final FormSection searchSection = new FormSection(new BoxPanel(BoxPanel.VERTICAL));
|
||||
final BoxPanel searchRow = new BoxPanel(BoxPanel.HORIZONTAL);
|
||||
searchRow.add(searchLabel);
|
||||
searchRow.add(m_item);
|
||||
searchRow.add(m_search);
|
||||
searchRow.add(m_clear);
|
||||
final BoxPanel itemRow = new BoxPanel(BoxPanel.HORIZONTAL);
|
||||
itemRow.add(selectedItemLabel);
|
||||
itemRow.add(m_selected);
|
||||
searchSection.add(searchRow);
|
||||
searchSection.add(itemRow);
|
||||
searchSection.add(m_jsLabel);
|
||||
add(searchSection);
|
||||
if (m_contentType == null) {
|
||||
|
|
@ -340,75 +368,75 @@ public class ItemSearchWidget extends FormSection
|
|||
}
|
||||
}
|
||||
|
||||
public void submitted(FormSectionEvent e) throws FormProcessException {
|
||||
PageState s = e.getPageState();
|
||||
FormData data = e.getFormData();
|
||||
public void submitted(final FormSectionEvent event) throws FormProcessException {
|
||||
final PageState state = event.getPageState();
|
||||
final FormData data = event.getFormData();
|
||||
s_log.debug("Doing submission");
|
||||
if (m_searchComponent.isItemSelected(s)) {
|
||||
if (m_searchComponent.isItemSelected(state)) {
|
||||
s_log.debug("Item selected");
|
||||
ContentItem item = m_searchComponent.getSelectedItem(s);
|
||||
ContentItem item = m_searchComponent.getSelectedItem(state);
|
||||
if (item != null) {
|
||||
m_item.setValue(s, item);
|
||||
m_item.setValue(state, item);
|
||||
}
|
||||
try {
|
||||
m_searchComponent.setVisible(s, false);
|
||||
m_topHR.setVisible(s, false);
|
||||
m_bottomHR.setVisible(s, false);
|
||||
m_search.setVisible(s, true);
|
||||
m_searchComponent.setVisible(state, false);
|
||||
m_topHR.setVisible(state, false);
|
||||
m_bottomHR.setVisible(state, false);
|
||||
m_search.setVisible(state, true);
|
||||
} catch (IllegalStateException ex) {
|
||||
// component is in metaform. nothing to do here. Custom generateXML must hide for us
|
||||
}
|
||||
|
||||
throw new FormProcessException("item search FormSection submit");
|
||||
|
||||
} else if (m_searchComponent.hasQuery(s)) {
|
||||
} else if (m_searchComponent.hasQuery(state)) {
|
||||
s_log.debug("Has query");
|
||||
try {
|
||||
m_searchComponent.setVisible(s, true);
|
||||
m_searchComponent.processQuery(s);
|
||||
m_topHR.setVisible(s, true);
|
||||
m_bottomHR.setVisible(s, true);
|
||||
m_search.setVisible(s, false);
|
||||
m_searchComponent.setVisible(state, true);
|
||||
m_searchComponent.processQuery(state);
|
||||
m_topHR.setVisible(state, true);
|
||||
m_bottomHR.setVisible(state, true);
|
||||
m_search.setVisible(state, false);
|
||||
} catch (IllegalStateException ex) {
|
||||
// component is in metaform. nothing to do here. Custom generateXML must hide for us
|
||||
}
|
||||
|
||||
if (m_contentType != null) {
|
||||
s.setValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM),
|
||||
state.setValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM),
|
||||
m_contentType.getID());
|
||||
} else {
|
||||
s.setValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM),
|
||||
state.setValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM),
|
||||
null);
|
||||
}
|
||||
throw new FormProcessException("item search FormSection submit");
|
||||
} else if (m_search.isSelected(s)) {
|
||||
} else if (m_search.isSelected(state)) {
|
||||
s_log.debug("Search selected");
|
||||
try {
|
||||
m_searchComponent.setVisible(s, true);
|
||||
m_searchComponent.processQuery(s);
|
||||
m_topHR.setVisible(s, true);
|
||||
m_bottomHR.setVisible(s, true);
|
||||
m_search.setVisible(s, false);
|
||||
m_searchComponent.setVisible(state, true);
|
||||
m_searchComponent.processQuery(state);
|
||||
m_topHR.setVisible(state, true);
|
||||
m_bottomHR.setVisible(state, true);
|
||||
m_search.setVisible(state, false);
|
||||
} catch (IllegalStateException ex) {
|
||||
// component is in metaform. nothing to do here. Custom generateXML must hide for us
|
||||
}
|
||||
|
||||
if (m_contentType != null) {
|
||||
s.setValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM),
|
||||
state.setValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM),
|
||||
m_contentType.getID());
|
||||
} else {
|
||||
s.setValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM),
|
||||
state.setValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM),
|
||||
null);
|
||||
}
|
||||
throw new FormProcessException("item search FormSection submit");
|
||||
} else if (m_clear.isSelected(s)) {
|
||||
} else if (m_clear.isSelected(state)) {
|
||||
s_log.debug("Clear selected");
|
||||
m_item.setValue(s, null);
|
||||
m_item.setValue(state, null);
|
||||
try {
|
||||
m_searchComponent.setVisible(s, false);
|
||||
m_topHR.setVisible(s, false);
|
||||
m_bottomHR.setVisible(s, false);
|
||||
m_search.setVisible(s, true);
|
||||
m_searchComponent.setVisible(state, false);
|
||||
m_topHR.setVisible(state, false);
|
||||
m_bottomHR.setVisible(state, false);
|
||||
m_search.setVisible(state, true);
|
||||
} catch (IllegalStateException ex) {
|
||||
// component is in metaform. nothing to do here. Custom generateXML must hide for us
|
||||
}
|
||||
|
|
@ -416,14 +444,30 @@ public class ItemSearchWidget extends FormSection
|
|||
} else {
|
||||
s_log.debug("Something else");
|
||||
try {
|
||||
m_searchComponent.setVisible(s, false);
|
||||
m_topHR.setVisible(s, false);
|
||||
m_bottomHR.setVisible(s, false);
|
||||
m_search.setVisible(s, true);
|
||||
m_searchComponent.setVisible(state, false);
|
||||
m_topHR.setVisible(state, false);
|
||||
m_bottomHR.setVisible(state, false);
|
||||
m_search.setVisible(state, true);
|
||||
} catch (IllegalStateException ex) {
|
||||
// component is in metaform. nothing to do here. Custom generateXML must hide for us
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getSearchLabelText() {
|
||||
return searchLabelText;
|
||||
}
|
||||
|
||||
public void setSearchLabelText(final String searchLabelText) {
|
||||
this.searchLabelText = searchLabelText;
|
||||
}
|
||||
|
||||
public String getSelectedLabelText() {
|
||||
return selectedLabelText;
|
||||
}
|
||||
|
||||
public void setSelectedLabelText(String selectedLabelText) {
|
||||
this.selectedLabelText = selectedLabelText;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue