Admin-Oberfläche für Terms (Domains und Mapping) in Application-Tab unter /ccm/admin integriert.
git-svn-id: https://svn.libreccm.org/ccm/trunk@2302 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
dc69fcc9ae
commit
d4cc590f34
|
|
@ -20,9 +20,14 @@ package com.arsdigita.london.terms;
|
|||
|
||||
import com.arsdigita.bebop.BoxPanel;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Link;
|
||||
import com.arsdigita.bebop.SimpleContainer;
|
||||
import com.arsdigita.ui.admin.GlobalizationUtil;
|
||||
import com.arsdigita.bebop.Page;
|
||||
import com.arsdigita.bebop.SegmentedPanel;
|
||||
import com.arsdigita.london.terms.ui.TermGlobalizationUtil;
|
||||
import com.arsdigita.london.terms.ui.admin.DomainEditForm;
|
||||
import com.arsdigita.london.terms.ui.admin.DomainMappingAddForm;
|
||||
import com.arsdigita.london.terms.ui.admin.DomainMappingTable;
|
||||
import com.arsdigita.london.terms.ui.admin.DomainTable;
|
||||
import com.arsdigita.london.util.ui.parameters.DomainObjectParameter;
|
||||
import com.arsdigita.ui.admin.applications.AbstractSingletonApplicationManager;
|
||||
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
|
||||
|
||||
|
|
@ -33,22 +38,60 @@ import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
|
|||
*/
|
||||
public class TermsAppManager extends AbstractSingletonApplicationManager<Terms> {
|
||||
|
||||
private DomainObjectParameter selected = new DomainObjectParameter("selectedDomain");
|
||||
|
||||
;
|
||||
|
||||
@Override
|
||||
public Class<Terms> getApplication() {
|
||||
return Terms.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationInstanceAwareContainer getApplicationAdminForm() {
|
||||
final ApplicationInstanceAwareContainer container = new ApplicationInstanceAwareContainer();
|
||||
|
||||
final BoxPanel panel = new BoxPanel(BoxPanel.VERTICAL);
|
||||
final Label warnLabel = new Label(GlobalizationUtil.globalize("ui.admin.applications.form_not_compatible_now"));
|
||||
warnLabel.setClassAttr("warning");
|
||||
panel.add(warnLabel);
|
||||
panel.add(new Link("Terms Admin", "/admin/terms"));
|
||||
//final ApplicationInstanceAwareContainer container = new ApplicationInstanceAwareContainer();
|
||||
final TermAdminContainer container = new TermAdminContainer();
|
||||
|
||||
panel.add(container);
|
||||
// final BoxPanel panel = new BoxPanel(BoxPanel.VERTICAL);
|
||||
// final Label warnLabel = new Label(GlobalizationUtil.globalize("ui.admin.applications.form_not_compatible_now"));
|
||||
// warnLabel.setClassAttr("warning");
|
||||
// panel.add(warnLabel);
|
||||
// panel.add(new Link("Terms Admin", "/admin/terms"));
|
||||
//
|
||||
// panel.add(container);
|
||||
|
||||
final DomainTable domains = new DomainTable(selected);
|
||||
final DomainEditForm editForm = new DomainEditForm("domainEditForm", selected);
|
||||
final DomainMappingTable mappings = new DomainMappingTable(selected);
|
||||
final DomainMappingAddForm mappingAddForm = new DomainMappingAddForm(selected);
|
||||
final BoxPanel mappingPanel = new BoxPanel(BoxPanel.VERTICAL);
|
||||
|
||||
mappingPanel.add(mappings);
|
||||
mappingPanel.add(mappingAddForm);
|
||||
|
||||
container.add(domains);
|
||||
|
||||
final SegmentedPanel panel = new SegmentedPanel();
|
||||
panel.addSegment(new Label(TermGlobalizationUtil.globalize("term.domain.ui.basic_properties")),
|
||||
editForm);
|
||||
panel.addSegment(new Label(TermGlobalizationUtil.globalize("term.domain.ui.mappings")),
|
||||
mappingPanel);
|
||||
|
||||
// container.add(editForm);
|
||||
|
||||
container.add(panel);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
private class TermAdminContainer extends ApplicationInstanceAwareContainer {
|
||||
|
||||
@Override
|
||||
public void register(final Page page) {
|
||||
super.register(page);
|
||||
|
||||
page.addGlobalStateParam(selected);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package com.arsdigita.london.terms.ui;
|
||||
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class TermGlobalizationUtil {
|
||||
|
||||
public static final String BUNDLE_NAME = "com.arsdigita.london.terms.ui.TermResources";
|
||||
|
||||
public static GlobalizedMessage globalize(final String key) {
|
||||
return new GlobalizedMessage(key, BUNDLE_NAME);
|
||||
}
|
||||
|
||||
public static GlobalizedMessage globalize(final String key,
|
||||
final Object[] args) {
|
||||
return new GlobalizedMessage(key, BUNDLE_NAME, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
term.domain.ui.key.label=Key
|
||||
term.domain.ui.title.label=Title
|
||||
term.domain.ui.url.label=URL
|
||||
term.domain.ui.version.label=Version
|
||||
term.domain.ui.released=Released
|
||||
term.domain.ui.edit=Edit
|
||||
term.domain.ui.delete=Delete
|
||||
term.domain.ui.delete.confirm=Are you sure to delete this domain?
|
||||
term.domain.ui.description.label=Description
|
||||
term.domain.ui.no_domains=No domains found,
|
||||
term.domain.ui.no_mappings=No mappings found.
|
||||
term.domain.mapping.ui.delete.confirm=Are you sure to remove this mapping?
|
||||
term.domain.mapping.ui.delete=Remove
|
||||
term.domain.mapping.ui.app.select_one=Select an application to map the domain to.
|
||||
term.domain.mapping.ui.application=Application
|
||||
term.domain.ui.released.label=Released
|
||||
term.domain.mapping.ui.context=Context
|
||||
term.domain.ui.mappings=Mappings
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
term.domain.ui.key.label=Domain-ID
|
||||
term.domain.ui.title.label=Titel
|
||||
term.domain.ui.url.label=URL
|
||||
term.domain.ui.version.label=Version
|
||||
term.domain.ui.released=Freigegeben
|
||||
term.domain.ui.edit=Bearbeiten
|
||||
term.domain.ui.delete=L\u00f6schen
|
||||
term.domain.ui.delete.confirm=Sind sie sicher, dass Sie diese Domain l\u00f6schen wollen?
|
||||
term.domain.ui.description.label=Beschreibung
|
||||
term.domain.ui.no_domains=Keine Domains gefunden.
|
||||
term.domain.ui.no_mappings=Keine Mappings gefunden.
|
||||
term.domain.mapping.ui.delete.confirm=Sind Sie sicher, dass Sie dieses Mapping entfernen wollen?
|
||||
term.domain.mapping.ui.delete=L\u00f6schen
|
||||
term.domain.mapping.ui.app.select_one=W\u00e4hlen Sie die Applikation, auf die das Kategoriensystem gemappt werden soll.
|
||||
term.domain.mapping.ui.application=Applikation
|
||||
term.domain.ui.released.label=Freigegeben
|
||||
term.domain.mapping.ui.context=Kontext
|
||||
term.domain.ui.mappings=Mappings
|
||||
|
|
@ -0,0 +1,217 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Jens Pelzetter
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.london.terms.ui.admin;
|
||||
|
||||
import com.arsdigita.bebop.ColumnPanel;
|
||||
import com.arsdigita.bebop.Form;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.SaveCancelSection;
|
||||
import com.arsdigita.bebop.event.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||
import com.arsdigita.bebop.event.PrintEvent;
|
||||
import com.arsdigita.bebop.event.PrintListener;
|
||||
import com.arsdigita.bebop.form.Date;
|
||||
import com.arsdigita.bebop.form.TextArea;
|
||||
import com.arsdigita.bebop.form.TextField;
|
||||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
|
||||
import com.arsdigita.london.terms.Domain;
|
||||
import com.arsdigita.london.terms.ui.TermGlobalizationUtil;
|
||||
import com.arsdigita.london.util.ui.parameters.DomainObjectParameter;
|
||||
import com.arsdigita.london.util.ui.parameters.URLParameter;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
import java.net.URL;
|
||||
import java.util.TooManyListenersException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DomainEditForm extends Form {
|
||||
|
||||
private final DomainObjectParameter selected;
|
||||
private final TextField key;
|
||||
private final TextField title;
|
||||
private final TextField url;
|
||||
private final TextArea description;
|
||||
private final TextField version;
|
||||
private Date released;
|
||||
private SaveCancelSection saveCancel;
|
||||
|
||||
public DomainEditForm(final String name, final DomainObjectParameter selected) {
|
||||
super(name, new ColumnPanel(2));
|
||||
setClassAttr("domainEdit");
|
||||
|
||||
this.selected = selected;
|
||||
|
||||
key = new TextField("domainKey");
|
||||
key.setSize(20);
|
||||
key.addValidationListener(new NotNullValidationListener());
|
||||
key.addValidationListener(new StringInRangeValidationListener(1, 20));
|
||||
key.setHint("The short unique key for the domain, stable across versions");
|
||||
try {
|
||||
key.addPrintListener(new PrintListener() {
|
||||
@Override
|
||||
public void prepare(final PrintEvent event) {
|
||||
final TextField target = (TextField) event.getTarget();
|
||||
if (event.getPageState().getValue(selected) != null) {
|
||||
target.setReadOnly();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
} catch (TooManyListenersException ex) {
|
||||
throw new UncheckedWrapperException(ex);
|
||||
}
|
||||
add(new Label(TermGlobalizationUtil.globalize("term.domain.ui.key.label")));
|
||||
add(key);
|
||||
|
||||
title = new TextField("domainTitle");
|
||||
title.setSize(50);
|
||||
title.addValidationListener(new NotNullValidationListener());
|
||||
title.addValidationListener(new StringInRangeValidationListener(1, 300));
|
||||
title.setHint("The short title of the domain");
|
||||
add(new Label(TermGlobalizationUtil.globalize("term.domain.ui.title.label")));
|
||||
add(title);
|
||||
|
||||
url = new TextField(new URLParameter("domainUrl"));
|
||||
url.setSize(50);
|
||||
url.addValidationListener(new NotNullValidationListener());
|
||||
url.addValidationListener(new StringInRangeValidationListener(1, 255));
|
||||
url.setHint("The unique URL defining the current version of the domain");
|
||||
add(new Label(TermGlobalizationUtil.globalize("term.domain.ui.url.label")));
|
||||
add(url);
|
||||
|
||||
description = new TextArea("domainDesc");
|
||||
description.setCols(50);
|
||||
description.setRows(5);
|
||||
description.addValidationListener(new StringInRangeValidationListener(0, 4000));
|
||||
description.setHint("The long description of the domain");
|
||||
add(new Label(TermGlobalizationUtil.globalize("term.domain.ui.description.label")));
|
||||
add(description);
|
||||
|
||||
version = new TextField("domainVersion");
|
||||
version.setSize(20);
|
||||
version.addValidationListener(new NotNullValidationListener());
|
||||
version.addValidationListener(new StringInRangeValidationListener(1, 20));
|
||||
version.setHint("The current version number, eg 1.00");
|
||||
add(new Label(TermGlobalizationUtil.globalize("term.domain.ui.version.label")));
|
||||
add(version);
|
||||
|
||||
released = new Date("domainReleased");
|
||||
released.addValidationListener(new NotNullValidationListener());
|
||||
released.setHint("The release date of the current version");
|
||||
add(new Label(TermGlobalizationUtil.globalize("term.domain.ui.released.label")));
|
||||
add(released);
|
||||
|
||||
saveCancel = new SaveCancelSection();
|
||||
add(saveCancel);
|
||||
|
||||
addInitListener(new InitListener());
|
||||
addSubmissionListener(new SubmissionListener());
|
||||
addProcessListener(new Processlistener());
|
||||
}
|
||||
|
||||
private class InitListener implements FormInitListener {
|
||||
|
||||
@Override
|
||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||
final PageState state = event.getPageState();
|
||||
final Domain domain = (Domain) state.getValue(selected);
|
||||
|
||||
if (domain == null) {
|
||||
key.setValue(state, null);
|
||||
title.setValue(state, null);
|
||||
url.setValue(state, null);
|
||||
description.setValue(state, null);
|
||||
version.setValue(state, null);
|
||||
released.setValue(state, null);
|
||||
} else {
|
||||
key.setValue(state, domain.getKey());
|
||||
title.setValue(state, domain.getTitle());
|
||||
url.setValue(state, domain.getURL());
|
||||
description.setValue(state, domain.getDescription());
|
||||
version.setValue(state, domain.getVersion());
|
||||
released.setValue(state, domain.getReleased());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class SubmissionListener implements FormSubmissionListener {
|
||||
|
||||
@Override
|
||||
public void submitted(final FormSectionEvent event) throws FormProcessException {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
if (saveCancel.getCancelButton().isSelected(state)) {
|
||||
state.setValue(selected, null);
|
||||
//fireCompletionEvent(state);
|
||||
key.setValue(state, null);
|
||||
title.setValue(state, null);
|
||||
url.setValue(state, null);
|
||||
description.setValue(state, null);
|
||||
version.setValue(state, null);
|
||||
released.setValue(state, null);
|
||||
throw new FormProcessException("canceled");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class Processlistener implements FormProcessListener {
|
||||
|
||||
@Override
|
||||
public void process(final FormSectionEvent event) throws FormProcessException {
|
||||
final PageState state = event.getPageState();
|
||||
final Domain domain = (Domain) state.getValue(selected);
|
||||
|
||||
if (domain == null) {
|
||||
Domain.create((String) key.getValue(state),
|
||||
(URL) url.getValue(state),
|
||||
(String) title.getValue(state),
|
||||
(String) description.getValue(state),
|
||||
(String) version.getValue(state),
|
||||
(java.util.Date) released.getValue(state));
|
||||
} else {
|
||||
domain.setURL((URL) url.getValue(state));
|
||||
domain.setTitle((String) title.getValue(state));
|
||||
domain.setDescription((String) description.getValue(state));
|
||||
domain.setVersion((String) version.getValue(state));
|
||||
domain.setReleased((java.util.Date) released.getValue(state));
|
||||
}
|
||||
|
||||
state.setValue(selected, null);
|
||||
key.setValue(state, null);
|
||||
title.setValue(state, null);
|
||||
url.setValue(state, null);
|
||||
description.setValue(state, null);
|
||||
version.setValue(state, null);
|
||||
released.setValue(state, null);
|
||||
|
||||
fireCompletionEvent(state);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,203 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Jens Pelzetter
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.london.terms.ui.admin;
|
||||
|
||||
import com.arsdigita.bebop.BoxPanel;
|
||||
import com.arsdigita.bebop.Form;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.SaveCancelSection;
|
||||
import com.arsdigita.bebop.event.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||
import com.arsdigita.bebop.event.PrintEvent;
|
||||
import com.arsdigita.bebop.event.PrintListener;
|
||||
import com.arsdigita.bebop.form.Option;
|
||||
import com.arsdigita.bebop.form.SingleSelect;
|
||||
import com.arsdigita.bebop.form.Submit;
|
||||
import com.arsdigita.bebop.form.TextField;
|
||||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
|
||||
import com.arsdigita.london.terms.Domain;
|
||||
import com.arsdigita.london.terms.ui.TermGlobalizationUtil;
|
||||
import com.arsdigita.london.util.ui.parameters.DomainObjectParameter;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
import com.arsdigita.web.Application;
|
||||
import com.arsdigita.web.ApplicationCollection;
|
||||
import java.util.TooManyListenersException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DomainMappingAddForm extends Form {
|
||||
|
||||
private final DomainObjectParameter selected;
|
||||
private final SingleSelect application;
|
||||
private final TextField context;
|
||||
private final SaveCancelSection saveCancel;
|
||||
|
||||
public DomainMappingAddForm(final DomainObjectParameter selected) {
|
||||
super("domainMappingAddForm", new BoxPanel(BoxPanel.HORIZONTAL));
|
||||
|
||||
this.selected = selected;
|
||||
|
||||
application = new SingleSelect(new DomainObjectParameter("domainMappingApp"));
|
||||
application.addValidationListener(new NotNullValidationListener());
|
||||
|
||||
try {
|
||||
application.addPrintListener(new PrintListener() {
|
||||
@Override
|
||||
public void prepare(final PrintEvent event) {
|
||||
final SingleSelect target = (SingleSelect) event.getTarget();
|
||||
|
||||
if (event.getPageState().getValue(selected) == null) {
|
||||
target.setReadOnly();
|
||||
} else {
|
||||
final ApplicationCollection applications = Application.
|
||||
retrieveAllApplications();
|
||||
applications.addOrder(Application.PRIMARY_URL);
|
||||
target.addOption(new Option(null, new Label(TermGlobalizationUtil.globalize(
|
||||
"term.domain.mapping.ui.app.select_one"))));
|
||||
while (applications.next()) {
|
||||
final Application app = applications.getApplication();
|
||||
target.addOption(new Option(app.getOID().toString(),
|
||||
app.getPath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
} catch (TooManyListenersException ex) {
|
||||
throw new UncheckedWrapperException(ex);
|
||||
}
|
||||
add(new Label(TermGlobalizationUtil.globalize("term.domain.mapping.ui.application")));
|
||||
add(application);
|
||||
|
||||
context = new TextField("domainMappingContext");
|
||||
try {
|
||||
context.addPrintListener(new PrintListener() {
|
||||
@Override
|
||||
public void prepare(final PrintEvent event) {
|
||||
|
||||
if (event.getPageState().getValue(selected) == null) {
|
||||
final TextField target = (TextField) event.getTarget();
|
||||
target.setReadOnly();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
} catch (TooManyListenersException ex) {
|
||||
throw new UncheckedWrapperException(ex);
|
||||
}
|
||||
context.setSize(20);
|
||||
context.addValidationListener(new NotNullValidationListener());
|
||||
context.addValidationListener(new StringInRangeValidationListener(1, 100));
|
||||
add(new Label(TermGlobalizationUtil.globalize("term.domain.mapping.ui.context")));
|
||||
add(context);
|
||||
|
||||
saveCancel = new SaveCancelSection();
|
||||
try {
|
||||
saveCancel.getCancelButton().addPrintListener(new PrintListener() {
|
||||
@Override
|
||||
public void prepare(final PrintEvent event) {
|
||||
if (event.getPageState().getValue(selected) == null) {
|
||||
final Submit target = (Submit) event.getTarget();
|
||||
target.setDisabled();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
} catch (TooManyListenersException ex) {
|
||||
throw new UncheckedWrapperException(ex);
|
||||
}
|
||||
try {
|
||||
saveCancel.getSaveButton().addPrintListener(new PrintListener() {
|
||||
@Override
|
||||
public void prepare(final PrintEvent event) {
|
||||
if (event.getPageState().getValue(selected) == null) {
|
||||
final Submit target = (Submit) event.getTarget();
|
||||
target.setDisabled();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
} catch (TooManyListenersException ex) {
|
||||
throw new UncheckedWrapperException(ex);
|
||||
}
|
||||
add(saveCancel);
|
||||
|
||||
addInitListener(new InitListener());
|
||||
addSubmissionListener(new SubmissionListener());
|
||||
addProcessListener(new ProcessListener());
|
||||
}
|
||||
|
||||
private class InitListener implements FormInitListener {
|
||||
|
||||
@Override
|
||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
application.setValue(state, null);
|
||||
context.setValue(state, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class SubmissionListener implements FormSubmissionListener {
|
||||
|
||||
@Override
|
||||
public void submitted(final FormSectionEvent event) throws FormProcessException {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
if (saveCancel.getCancelButton().isSelected(state)) {
|
||||
application.setValue(state, null);
|
||||
context.setValue(state, null);
|
||||
|
||||
fireCompletionEvent(state);
|
||||
throw new FormProcessException("Cancelled");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ProcessListener implements FormProcessListener {
|
||||
|
||||
@Override
|
||||
public void process(final FormSectionEvent event) throws FormProcessException {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
final Domain domain = (Domain) state.getValue(selected);
|
||||
|
||||
final Application app = (Application) application.getValue(state);
|
||||
final String domainContext = (String) context.getValue(state);
|
||||
|
||||
domain.setAsRootForObject(app, domainContext);
|
||||
|
||||
application.setValue(state, null);
|
||||
context.setValue(state, null);
|
||||
|
||||
fireCompletionEvent(state);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Jens Pelzetter
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.london.terms.ui.admin;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.Table;
|
||||
import com.arsdigita.bebop.event.TableActionEvent;
|
||||
import com.arsdigita.bebop.event.TableActionListener;
|
||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||
import com.arsdigita.bebop.table.TableColumn;
|
||||
import com.arsdigita.bebop.table.TableColumnModel;
|
||||
import com.arsdigita.bebop.table.TableModel;
|
||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.domain.DomainObject;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.domain.DomainService;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.london.terms.Domain;
|
||||
import com.arsdigita.london.terms.ui.TermGlobalizationUtil;
|
||||
import com.arsdigita.london.util.ui.parameters.DomainObjectParameter;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import com.arsdigita.web.Application;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DomainMappingTable extends Table implements TableActionListener {
|
||||
|
||||
private static final String TABLE_COL_DEL = "table_col_del";
|
||||
private final DomainObjectParameter selected;
|
||||
|
||||
public DomainMappingTable(final DomainObjectParameter selected) {
|
||||
super();
|
||||
|
||||
this.selected = selected;
|
||||
|
||||
setEmptyView(new Label(TermGlobalizationUtil.globalize("term.domain.ui.no_mappings")));
|
||||
|
||||
final TableColumnModel columnModel = getColumnModel();
|
||||
|
||||
columnModel.add(new TableColumn(
|
||||
0, TermGlobalizationUtil.globalize("term.domain.mapping.ui.application")));
|
||||
columnModel.add(new TableColumn(
|
||||
1, TermGlobalizationUtil.globalize("term.domain.mapping.ui.context")));
|
||||
columnModel.add(new TableColumn(
|
||||
2, TermGlobalizationUtil.globalize("term.domain.mapping.ui.remove"), TABLE_COL_DEL));
|
||||
|
||||
setModelBuilder(new DomainMappingTableModelBuilder());
|
||||
|
||||
columnModel.get(2).setCellRenderer(new DeleteCellRenderer());
|
||||
|
||||
addTableActionListener(this);
|
||||
}
|
||||
|
||||
private class DomainMappingTableModelBuilder extends LockableImpl implements TableModelBuilder {
|
||||
|
||||
@Override
|
||||
public TableModel makeModel(final Table table,
|
||||
final PageState state) {
|
||||
table.getRowSelectionModel().clearSelection(state);
|
||||
|
||||
return new DomainMappingTableModel(table, state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class DomainMappingTableModel extends DomainService implements TableModel {
|
||||
|
||||
private final Table table;
|
||||
private final DomainCollection useContexts;
|
||||
|
||||
public DomainMappingTableModel(final Table table, final PageState state) {
|
||||
this.table = table;
|
||||
|
||||
final Domain domain = (Domain) state.getValue(selected);
|
||||
|
||||
if (domain == null) {
|
||||
useContexts = null;
|
||||
} else {
|
||||
useContexts = domain.getUseContexts();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return table.getColumnModel().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nextRow() {
|
||||
if (useContexts == null) {
|
||||
return false;
|
||||
} else {
|
||||
return useContexts.next();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(final int columnIndex) {
|
||||
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
final DomainObject obj = DomainObjectFactory.newInstance((DataObject) get(
|
||||
useContexts.getDomainObject(), "categoryOwner"));
|
||||
if (obj instanceof Application) {
|
||||
return ((Application) obj).getPath();
|
||||
} else {
|
||||
return obj.getOID().toString();
|
||||
}
|
||||
case 1:
|
||||
return get(useContexts.getDomainObject(), "useContext");
|
||||
case 2:
|
||||
return TermGlobalizationUtil.globalize("term.domain.mapping.ui.delete");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKeyAt(final int columnIndex) {
|
||||
return useContexts.getDomainObject().getOID().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final boolean isSelected,
|
||||
final Object key,
|
||||
final int row,
|
||||
final int column) {
|
||||
final ControlLink link = new ControlLink(new Label((GlobalizedMessage) value));
|
||||
link.setConfirmation(TermGlobalizationUtil.globalize(
|
||||
"term.domain.mapping.ui.delete.confirm"));
|
||||
return link;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cellSelected(final TableActionEvent event) {
|
||||
final PageState state = event.getPageState();
|
||||
final DomainObject obj = DomainObjectFactory.newInstance(OID.valueOf(event.getRowKey().
|
||||
toString()));
|
||||
|
||||
final TableColumn column = getColumnModel().get(event.getColumn().intValue());
|
||||
|
||||
if (TABLE_COL_DEL.equals(column.getHeaderKey().toString())) {
|
||||
obj.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void headSelected(final TableActionEvent event) {
|
||||
//Nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,214 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Jens Pelzetter
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.london.terms.ui.admin;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.Table;
|
||||
import com.arsdigita.bebop.event.TableActionEvent;
|
||||
import com.arsdigita.bebop.event.TableActionListener;
|
||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||
import com.arsdigita.bebop.table.TableColumn;
|
||||
import com.arsdigita.bebop.table.TableColumnModel;
|
||||
import com.arsdigita.bebop.table.TableModel;
|
||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.london.terms.Domain;
|
||||
import com.arsdigita.london.terms.ui.TermGlobalizationUtil;
|
||||
import com.arsdigita.london.util.ui.parameters.DomainObjectParameter;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DomainTable extends Table implements TableActionListener {
|
||||
|
||||
private static final String TABLE_COL_EDIT = "table_col_edit";
|
||||
private static final String TABLE_COL_DEL = "table_col_del";
|
||||
private final DomainObjectParameter selected;
|
||||
|
||||
public DomainTable(final DomainObjectParameter selected) {
|
||||
super();
|
||||
|
||||
this.selected = selected;
|
||||
|
||||
setEmptyView(new Label(TermGlobalizationUtil.globalize("term.domain.ui.no_domains")));
|
||||
|
||||
final TableColumnModel columnModel = getColumnModel();
|
||||
|
||||
columnModel.add(new TableColumn(
|
||||
0, TermGlobalizationUtil.globalize("term.domain.ui.key.label")));
|
||||
|
||||
columnModel.add(new TableColumn(
|
||||
1, TermGlobalizationUtil.globalize("term.domain.ui.title.label")));
|
||||
|
||||
columnModel.add(new TableColumn(
|
||||
2, TermGlobalizationUtil.globalize("term.domain.ui.url.label")));
|
||||
|
||||
columnModel.add(new TableColumn(
|
||||
3, TermGlobalizationUtil.globalize("term.domain.ui.version.label")));
|
||||
|
||||
columnModel.add(new TableColumn(
|
||||
4, TermGlobalizationUtil.globalize("term.domain.ui.released")));
|
||||
|
||||
columnModel.add(new TableColumn(
|
||||
5,
|
||||
TermGlobalizationUtil.globalize("term.domain.ui.edit"),
|
||||
TABLE_COL_EDIT));
|
||||
|
||||
columnModel.add(new TableColumn(
|
||||
6,
|
||||
TermGlobalizationUtil.globalize("term.domain.ui.delete"),
|
||||
TABLE_COL_DEL));
|
||||
|
||||
setModelBuilder(new DomainTableModelBuilder());
|
||||
|
||||
columnModel.get(5).setCellRenderer(new EditCellRenderer());
|
||||
columnModel.get(6).setCellRenderer(new DeleteCellRenderer());
|
||||
|
||||
addTableActionListener(this);
|
||||
|
||||
}
|
||||
|
||||
private class DomainTableModelBuilder extends LockableImpl implements TableModelBuilder {
|
||||
|
||||
@Override
|
||||
public TableModel makeModel(final Table table, final PageState state) {
|
||||
table.getRowSelectionModel().clearSelection(state);
|
||||
|
||||
return new DomainTableModel(table, state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class DomainTableModel implements TableModel {
|
||||
|
||||
private final Table table;
|
||||
private final DomainCollection domains;
|
||||
|
||||
public DomainTableModel(final Table table, final PageState state) {
|
||||
this.table = table;
|
||||
domains = new DomainCollection(SessionManager.getSession().retrieve(
|
||||
Domain.BASE_DATA_OBJECT_TYPE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return table.getColumnModel().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nextRow() {
|
||||
return domains.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(final int columnIndex) {
|
||||
final Domain domain = (Domain) domains.getDomainObject();
|
||||
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return domain.getKey();
|
||||
case 1:
|
||||
return domain.getTitle();
|
||||
case 2:
|
||||
return domain.getURL().toString();
|
||||
case 3:
|
||||
return domain.getVersion();
|
||||
case 4:
|
||||
return domain.getReleased().toString();
|
||||
case 5:
|
||||
return TermGlobalizationUtil.globalize("term.domain.ui.edit");
|
||||
case 6:
|
||||
return TermGlobalizationUtil.globalize("term.domain.ui.delete");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKeyAt(final int columnIndex) {
|
||||
return domains.getDomainObject().getOID().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class EditCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final boolean isSelected,
|
||||
final Object key,
|
||||
final int row,
|
||||
final int column) {
|
||||
final ControlLink link = new ControlLink(new Label((GlobalizedMessage) value));
|
||||
return link;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final boolean isSelected,
|
||||
final Object key,
|
||||
final int row,
|
||||
final int column) {
|
||||
final ControlLink link = new ControlLink(new Label((GlobalizedMessage) value));
|
||||
link.setConfirmation(TermGlobalizationUtil.globalize("term.domain.ui.delete.confirm"));
|
||||
return link;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cellSelected(final TableActionEvent event) {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
final Domain domain = (Domain) DomainObjectFactory.newInstance(OID.valueOf(
|
||||
event.getRowKey().toString()));
|
||||
|
||||
final TableColumn column = getColumnModel().get(event.getColumn().intValue());
|
||||
|
||||
if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) {
|
||||
state.setValue(selected, domain);
|
||||
} else if(TABLE_COL_DEL.equals(column.getHeaderKey().toString())) {
|
||||
domain.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void headSelected(final TableActionEvent event) {
|
||||
//Nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -15,7 +15,6 @@
|
|||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package com.arsdigita.london.util.ui;
|
||||
|
||||
import com.arsdigita.bebop.Page;
|
||||
|
|
@ -40,9 +39,9 @@ import com.arsdigita.web.Web;
|
|||
|
||||
import java.util.Iterator;
|
||||
|
||||
public abstract class AbstractDomainObjectList
|
||||
extends AbstractDomainObjectComponent {
|
||||
|
||||
public abstract class AbstractDomainObjectList
|
||||
extends AbstractDomainObjectComponent {
|
||||
|
||||
private String m_prefix;
|
||||
private int m_pageSize;
|
||||
private IntegerParameter m_pageNumber;
|
||||
|
|
@ -57,25 +56,25 @@ public abstract class AbstractDomainObjectList
|
|||
|
||||
public void register(Page p) {
|
||||
super.register(p);
|
||||
|
||||
|
||||
p.addComponentStateParam(this, m_pageNumber);
|
||||
}
|
||||
|
||||
|
||||
public void setPageSize(int pageSize) {
|
||||
m_pageSize = pageSize;
|
||||
}
|
||||
|
||||
protected abstract DomainCollection getDomainObjects(PageState state);
|
||||
|
||||
|
||||
public void generateXML(PageState state,
|
||||
Element parent) {
|
||||
Element content = generateParent(parent);
|
||||
|
||||
|
||||
DomainCollection objs = getDomainObjects(state);
|
||||
|
||||
if (m_pageSize != 0) {
|
||||
Element pagEl = generatePaginatorXML(state,
|
||||
objs);
|
||||
Element pagEl = generatePaginatorXML(state,
|
||||
objs);
|
||||
content.addContent(pagEl);
|
||||
}
|
||||
|
||||
|
|
@ -84,49 +83,46 @@ public abstract class AbstractDomainObjectList
|
|||
content.addContent(el);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected Element generateObjectXML(PageState state,
|
||||
DomainObject dobj) {
|
||||
Element objEl = new Element(m_prefix + ":object",
|
||||
getNamespace());
|
||||
|
||||
|
||||
DomainObjectXMLRenderer xr = new DomainObjectXMLRenderer(objEl);
|
||||
xr.setNamespace(m_prefix, getNamespace());
|
||||
xr.setWrapRoot(false);
|
||||
xr.setWrapAttributes(true);
|
||||
xr.setWrapObjects(false);
|
||||
|
||||
|
||||
xr.walk(dobj,
|
||||
getClass().getName());
|
||||
|
||||
|
||||
Iterator actions = getDomainObjectActions();
|
||||
while (actions.hasNext()) {
|
||||
String action = (String)actions.next();
|
||||
|
||||
String action = (String) actions.next();
|
||||
|
||||
if (isActionVisible(action, dobj, state)) {
|
||||
Element el = generateActionXML(state, dobj, action);
|
||||
objEl.addContent(el);
|
||||
Element el = generateActionXML(state, dobj, action);
|
||||
objEl.addContent(el);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return objEl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* determine whether this action should be rendered. Default
|
||||
* implementation returns true unless a privilege has been
|
||||
* specified for the action in which case a permission check
|
||||
* is carried out for the current user.
|
||||
* @param action
|
||||
* @param dobj
|
||||
* @param state
|
||||
* @return
|
||||
*/
|
||||
protected boolean isActionVisible (String action, DomainObject dobj, PageState state) {
|
||||
boolean actionVisible = true;
|
||||
* determine whether this action should be rendered. Default
|
||||
* implementation returns true unless a privilege has been
|
||||
* specified for the action in which case a permission check
|
||||
* is carried out for the current user.
|
||||
* @param action
|
||||
* @param dobj
|
||||
* @param state
|
||||
* @return
|
||||
*/
|
||||
protected boolean isActionVisible(String action, DomainObject dobj, PageState state) {
|
||||
boolean actionVisible = true;
|
||||
PrivilegeDescriptor privilege = getDomainObjectActionPrivilege(action);
|
||||
if (privilege != null) {
|
||||
Party party = Kernel.getContext().getParty();
|
||||
|
|
@ -135,9 +131,9 @@ public abstract class AbstractDomainObjectList
|
|||
}
|
||||
Assert
|
||||
.isTrue(
|
||||
dobj.getObjectType().isSubtypeOf(
|
||||
ACSObject.BASE_DATA_OBJECT_TYPE),
|
||||
"I can only check permissions on ACS Objects - this domain Object is not a subtype of ACSObject ");
|
||||
dobj.getObjectType().isSubtypeOf(
|
||||
ACSObject.BASE_DATA_OBJECT_TYPE),
|
||||
"I can only check permissions on ACS Objects - this domain Object is not a subtype of ACSObject ");
|
||||
|
||||
PermissionDescriptor permission = new PermissionDescriptor(
|
||||
privilege, (ACSObject) dobj, party);
|
||||
|
|
@ -145,16 +141,15 @@ public abstract class AbstractDomainObjectList
|
|||
}
|
||||
return actionVisible;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected Element generatePaginatorXML(PageState state,
|
||||
DomainCollection objs) {
|
||||
Integer pageNumberVal = (Integer)state.getValue(m_pageNumber);
|
||||
Integer pageNumberVal = (Integer) state.getValue(m_pageNumber);
|
||||
int pageNumber = pageNumberVal == null ? 1 : pageNumberVal.intValue();
|
||||
|
||||
|
||||
long objectCount = objs.size();
|
||||
int pageCount = (int)Math.ceil((double)objectCount / (double)m_pageSize);
|
||||
|
||||
int pageCount = (int) Math.ceil((double) objectCount / (double) m_pageSize);
|
||||
|
||||
if (pageNumber < 1) {
|
||||
pageNumber = 1;
|
||||
}
|
||||
|
|
@ -162,21 +157,21 @@ public abstract class AbstractDomainObjectList
|
|||
if (pageNumber > pageCount) {
|
||||
pageNumber = (pageCount == 0 ? 1 : pageCount);
|
||||
}
|
||||
|
||||
long begin = ((pageNumber-1) * m_pageSize);
|
||||
int count = (int)Math.min(m_pageSize, (objectCount - begin));
|
||||
|
||||
long begin = ((pageNumber - 1) * m_pageSize);
|
||||
int count = (int) Math.min(m_pageSize, (objectCount - begin));
|
||||
long end = begin + count;
|
||||
|
||||
|
||||
if (count != 0) {
|
||||
objs.setRange(new Integer((int)begin+1), new Integer((int)end+1));
|
||||
objs.setRange(new Integer((int) begin + 1), new Integer((int) end + 1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
URL url = Web.getContext().getRequestURL();
|
||||
ParameterMap map = new ParameterMap();
|
||||
Iterator current = url.getParameterMap().keySet().iterator();
|
||||
while (current.hasNext()) {
|
||||
String key = (String)current.next();
|
||||
String key = (String) current.next();
|
||||
if (key.equals(m_pageNumber.getName())) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -189,16 +184,15 @@ public abstract class AbstractDomainObjectList
|
|||
paginator.addAttribute("pageNumber", new Long(pageNumber).toString());
|
||||
paginator.addAttribute("pageCount", new Long(pageCount).toString());
|
||||
paginator.addAttribute("pageSize", new Long(m_pageSize).toString());
|
||||
paginator.addAttribute("objectBegin", new Long(begin+1).toString());
|
||||
paginator.addAttribute("objectBegin", new Long(begin + 1).toString());
|
||||
paginator.addAttribute("objectEnd", new Long(end).toString());
|
||||
paginator.addAttribute("objectCount", new Long(objectCount).toString());
|
||||
paginator.addAttribute("pageParam", m_pageNumber.getName());
|
||||
paginator.addAttribute("baseURL", URL.there(url.getPathInfo(), map)
|
||||
.toString());
|
||||
.toString());
|
||||
|
||||
return paginator;
|
||||
}
|
||||
|
||||
|
||||
protected Element generateActionXML(PageState state,
|
||||
DomainObject dobj,
|
||||
|
|
@ -206,8 +200,9 @@ public abstract class AbstractDomainObjectList
|
|||
Element actionEl = new Element(m_prefix + ":action",
|
||||
getNamespace());
|
||||
actionEl.addAttribute("name", action);
|
||||
actionEl.addAttribute("url",
|
||||
actionEl.addAttribute("url",
|
||||
getDomainObjectActionLink(state, dobj, action));
|
||||
return actionEl;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue