Unterstützung für Forum Applikation im neuen Applications Tab.
git-svn-id: https://svn.libreccm.org/ccm/trunk@2235 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
c289ddee10
commit
06048fc05a
|
|
@ -38,8 +38,8 @@ public abstract class AbstractApplicationManager<T extends Application> implemen
|
||||||
* @param appClass
|
* @param appClass
|
||||||
* @return The standard form for creating new instances of an application.
|
* @return The standard form for creating new instances of an application.
|
||||||
*/
|
*/
|
||||||
public Form getApplicationCreateForm(final Class<T> appClass) {
|
public Form getApplicationCreateForm() {
|
||||||
return new ApplicationCreateForm<T>(appClass);
|
return new ApplicationCreateForm<T>(getApplication());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,15 @@ import com.arsdigita.bebop.Form;
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
import com.arsdigita.bebop.Label;
|
import com.arsdigita.bebop.Label;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.SaveCancelSection;
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
import com.arsdigita.bebop.event.FormValidationListener;
|
import com.arsdigita.bebop.event.FormValidationListener;
|
||||||
|
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.TextArea;
|
import com.arsdigita.bebop.form.TextArea;
|
||||||
import com.arsdigita.bebop.form.TextField;
|
import com.arsdigita.bebop.form.TextField;
|
||||||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||||
|
|
@ -35,8 +41,11 @@ import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.persistence.Session;
|
import com.arsdigita.persistence.Session;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
import com.arsdigita.ui.admin.GlobalizationUtil;
|
import com.arsdigita.ui.admin.GlobalizationUtil;
|
||||||
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
import com.arsdigita.web.Application;
|
import com.arsdigita.web.Application;
|
||||||
|
import com.arsdigita.web.ApplicationCollection;
|
||||||
import com.arsdigita.web.ApplicationType;
|
import com.arsdigita.web.ApplicationType;
|
||||||
|
import java.util.TooManyListenersException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic form for creating new Application instances. Should be suitable for
|
* Basic form for creating new Application instances. Should be suitable for
|
||||||
|
|
@ -51,19 +60,20 @@ import com.arsdigita.web.ApplicationType;
|
||||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class ApplicationCreateForm<T extends Application>
|
public class ApplicationCreateForm<T extends Application> extends Form {
|
||||||
extends Form
|
|
||||||
implements FormProcessListener, FormValidationListener {
|
|
||||||
|
|
||||||
public static final String FORM_NAME = "ApplicationCreateForm";
|
public static final String FORM_NAME = "ApplicationCreateForm";
|
||||||
|
private static final String PARENT_APP = "parentAll";
|
||||||
private static final String APPLICATION_URL = "applicationUrl";
|
private static final String APPLICATION_URL = "applicationUrl";
|
||||||
private static final String APPLICATION_TITLE = "applicationTitle";
|
private static final String APPLICATION_TITLE = "applicationTitle";
|
||||||
private static final String APPLICATION_DESC = "applicationDesc";
|
private static final String APPLICATION_DESC = "applicationDesc";
|
||||||
private final String appClassName;
|
private final String appClassName;
|
||||||
private final ApplicationType applicationType;
|
private final ApplicationType applicationType;
|
||||||
|
private final SingleSelect parentApp;
|
||||||
private final TextField applicationUrl;
|
private final TextField applicationUrl;
|
||||||
private final TextField applicationTitle;
|
private final TextField applicationTitle;
|
||||||
private final TextArea applicationDesc;
|
private final TextArea applicationDesc;
|
||||||
|
private final SaveCancelSection saveCancelSection;
|
||||||
|
|
||||||
public ApplicationCreateForm(final Class<T> appClass) {
|
public ApplicationCreateForm(final Class<T> appClass) {
|
||||||
|
|
||||||
|
|
@ -82,6 +92,26 @@ public class ApplicationCreateForm<T extends Application>
|
||||||
|
|
||||||
appTypes.next();
|
appTypes.next();
|
||||||
applicationType = (ApplicationType) DomainObjectFactory.newInstance(appTypes.getDataObject());
|
applicationType = (ApplicationType) DomainObjectFactory.newInstance(appTypes.getDataObject());
|
||||||
|
appTypes.close();
|
||||||
|
|
||||||
|
parentApp = new SingleSelect(PARENT_APP);
|
||||||
|
try {
|
||||||
|
parentApp.addPrintListener(new PrintListener() {
|
||||||
|
public void prepare(final PrintEvent event) {
|
||||||
|
final SingleSelect target = (SingleSelect) event.getTarget();
|
||||||
|
target.addOption(new Option("", ""));
|
||||||
|
|
||||||
|
final ApplicationCollection applications = Application.retrieveAllApplications();
|
||||||
|
while (applications.next()) {
|
||||||
|
target.addOption(new Option(applications.getApplication().getPath(),
|
||||||
|
applications.getApplication().getPath()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
} catch (TooManyListenersException ex) {
|
||||||
|
throw new UncheckedWrapperException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
applicationUrl = new TextField(new StringParameter(APPLICATION_URL));
|
applicationUrl = new TextField(new StringParameter(APPLICATION_URL));
|
||||||
applicationUrl.setSize(42);
|
applicationUrl.setSize(42);
|
||||||
|
|
@ -103,6 +133,8 @@ public class ApplicationCreateForm<T extends Application>
|
||||||
applicationDesc.addValidationListener(new StringInRangeValidationListener(0, 4000, GlobalizationUtil.globalize(
|
applicationDesc.addValidationListener(new StringInRangeValidationListener(0, 4000, GlobalizationUtil.globalize(
|
||||||
"ui.admin.applications.desc.valiation.minmaxlength")));
|
"ui.admin.applications.desc.valiation.minmaxlength")));
|
||||||
|
|
||||||
|
add(new Label(GlobalizationUtil.globalize("ui.admin.applications.parent.label")));
|
||||||
|
add(parentApp);
|
||||||
add(new Label(GlobalizationUtil.globalize("ui.admin.applications.url.label")));
|
add(new Label(GlobalizationUtil.globalize("ui.admin.applications.url.label")));
|
||||||
add(applicationUrl);
|
add(applicationUrl);
|
||||||
add(new Label(GlobalizationUtil.globalize("ui.admin.applications.title.label")));
|
add(new Label(GlobalizationUtil.globalize("ui.admin.applications.title.label")));
|
||||||
|
|
@ -110,9 +142,37 @@ public class ApplicationCreateForm<T extends Application>
|
||||||
add(new Label(GlobalizationUtil.globalize("ui.admin.applications.desc.label")));
|
add(new Label(GlobalizationUtil.globalize("ui.admin.applications.desc.label")));
|
||||||
add(applicationDesc);
|
add(applicationDesc);
|
||||||
|
|
||||||
|
saveCancelSection = new SaveCancelSection();
|
||||||
|
add(saveCancelSection);
|
||||||
|
|
||||||
|
addValidationListener(new ValidationListener());
|
||||||
|
addSubmissionListener(new SubmissionListener());
|
||||||
|
addProcessListener(new ProcessListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAppClassName() {
|
||||||
|
return appClassName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SubmissionListener implements FormSubmissionListener {
|
||||||
|
|
||||||
|
public void submitted(final FormSectionEvent event) throws FormProcessException {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
if (saveCancelSection.getCancelButton().isSelected(state)) {
|
||||||
|
parentApp.setValue(state, "");
|
||||||
|
applicationTitle.setValue(state, "");
|
||||||
|
applicationUrl.setValue(state, "");
|
||||||
|
applicationDesc.setValue(state, "");
|
||||||
|
|
||||||
|
throw new FormProcessException("Canceled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class ProcessListener implements FormProcessListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new application instance using the provided data.
|
* Creates a new application instance using the provided data.
|
||||||
*
|
*
|
||||||
|
|
@ -122,13 +182,40 @@ public class ApplicationCreateForm<T extends Application>
|
||||||
public void process(final FormSectionEvent event) throws FormProcessException {
|
public void process(final FormSectionEvent event) throws FormProcessException {
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
final Application application = Application.createApplication(applicationType,
|
if (saveCancelSection.getSaveButton().isSelected(state)) {
|
||||||
(String)applicationUrl.getValue(state),
|
Application parent;
|
||||||
(String)applicationTitle.getValue(state),
|
boolean createContainerGroup;
|
||||||
null,
|
|
||||||
false);
|
final String parentPath = (String) parentApp.getValue(state);
|
||||||
application.setDescription((String) applicationDesc.getValue(state));
|
if ((parentPath == null) && parentPath.isEmpty()) {
|
||||||
|
parent = null;
|
||||||
|
createContainerGroup = false;
|
||||||
|
} else {
|
||||||
|
final ApplicationCollection applications = Application.retrieveAllApplications();
|
||||||
|
applications.addEqualsFilter(Application.PRIMARY_URL, parentPath + "/");
|
||||||
|
if (applications.next()) {
|
||||||
|
parent = applications.getApplication();
|
||||||
|
createContainerGroup = true;
|
||||||
|
} else {
|
||||||
|
parent = null;
|
||||||
|
createContainerGroup = false;
|
||||||
}
|
}
|
||||||
|
applications.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
final Application application = Application.createApplication(applicationType,
|
||||||
|
(String) applicationUrl.getValue(state),
|
||||||
|
(String) applicationTitle.getValue(state),
|
||||||
|
parent,
|
||||||
|
createContainerGroup);
|
||||||
|
application.setDescription((String) applicationDesc.getValue(state));
|
||||||
|
application.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ValidationListener implements FormValidationListener {
|
||||||
|
|
||||||
public void validate(final FormSectionEvent event) throws FormProcessException {
|
public void validate(final FormSectionEvent event) throws FormProcessException {
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
|
|
@ -146,8 +233,5 @@ public class ApplicationCreateForm<T extends Application>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAppClassName() {
|
|
||||||
return appClassName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
com.arsdigita.forum.ForumApplicationManager
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* 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.forum;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.BoxPanel;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
import com.arsdigita.ui.admin.applications.AbstractApplicationManager;
|
||||||
|
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class ForumApplicationManager extends AbstractApplicationManager<Forum> {
|
||||||
|
|
||||||
|
public Class<Forum> getApplication() {
|
||||||
|
return Forum.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationInstanceAwareContainer getApplicationAdminForm() {
|
||||||
|
final ApplicationInstanceAwareContainer container = new ApplicationInstanceAwareContainer();
|
||||||
|
|
||||||
|
final BoxPanel panel = new BoxPanel();
|
||||||
|
panel.add(new Label(new GlobalizedMessage("forum.ui.admin.no_settings", "com.arsdigita.forum.ui.ForumResources")));
|
||||||
|
|
||||||
|
container.add(panel);
|
||||||
|
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -20,15 +20,9 @@ package com.arsdigita.forum;
|
||||||
|
|
||||||
import com.arsdigita.bebop.Page;
|
import com.arsdigita.bebop.Page;
|
||||||
import com.arsdigita.bebop.page.BebopApplicationServlet;
|
import com.arsdigita.bebop.page.BebopApplicationServlet;
|
||||||
// unused import
|
|
||||||
// import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
|
||||||
import com.arsdigita.forum.ui.Constants;
|
import com.arsdigita.forum.ui.Constants;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
// unused import
|
|
||||||
//import java.util.Map;
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -65,3 +65,4 @@ forum.ui.validation.image_not_uploaded=To add the specified image, use the Add I
|
||||||
forum.ui.validation.file_not_uploaded=To add the specified file, use the Add File button before leaving this page. If you don't want to add the file, click Next or Previous.
|
forum.ui.validation.file_not_uploaded=To add the specified file, use the Add File button before leaving this page. If you don't want to add the file, click Next or Previous.
|
||||||
forum.ui.validation.introduction_too_long=Your introduction is too long, only 4000 characters can be stored
|
forum.ui.validation.introduction_too_long=Your introduction is too long, only 4000 characters can be stored
|
||||||
forum.ui.settings.public=Forum is public
|
forum.ui.settings.public=Forum is public
|
||||||
|
forum.ui.admin.no_settings=No settings available
|
||||||
|
|
|
||||||
|
|
@ -65,3 +65,4 @@ forum.ui.validation.image_not_uploaded=To add the specified image, use the Add I
|
||||||
forum.ui.validation.file_not_uploaded=To add the specified file, use the Add File button before leaving this page. If you don't want to add the file, click Next or Previous.
|
forum.ui.validation.file_not_uploaded=To add the specified file, use the Add File button before leaving this page. If you don't want to add the file, click Next or Previous.
|
||||||
forum.ui.validation.introduction_too_long=Die Einf\u00fchrung ist zu lang, maximal 4000 Zeichen sind zugelassen.
|
forum.ui.validation.introduction_too_long=Die Einf\u00fchrung ist zu lang, maximal 4000 Zeichen sind zugelassen.
|
||||||
forum.ui.settings.public=Forum ist \u00f6ffentlich
|
forum.ui.settings.public=Forum ist \u00f6ffentlich
|
||||||
|
forum.ui.admin.no_settings=Keine Einstellungen verf\u00fcgbar.
|
||||||
|
|
|
||||||
|
|
@ -59,3 +59,4 @@ forum.ui.threads=Threads
|
||||||
forum.ui.topics=Topics
|
forum.ui.topics=Topics
|
||||||
forum.ui.thread.viewAll=View all threads
|
forum.ui.thread.viewAll=View all threads
|
||||||
forum.ui.settings.public=
|
forum.ui.settings.public=
|
||||||
|
forum.ui.admin.no_settings=
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
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.ui.admin.applications.AbstractSingletonApplicationManager;
|
||||||
|
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class TermsAppManager extends AbstractSingletonApplicationManager<Terms> {
|
||||||
|
|
||||||
|
public Class<Terms> getApplication() {
|
||||||
|
return Terms.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
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"));
|
||||||
|
|
||||||
|
panel.add(container);
|
||||||
|
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue