A to Z application checked, Admin UI integrated into Application tab at /ccm/admin
git-svn-id: https://svn.libreccm.org/ccm/trunk@2405 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
2fde32df93
commit
478bc98131
|
|
@ -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.atoz.siteproxy.ui.admin;
|
||||
|
||||
import com.arsdigita.atoz.ui.admin.AbstractProviderForm;
|
||||
|
|
@ -27,6 +26,7 @@ import com.arsdigita.atoz.AtoZ;
|
|||
import com.arsdigita.atoz.AtoZProvider;
|
||||
import com.arsdigita.atoz.siteproxy.SiteProxyProvider;
|
||||
import com.arsdigita.categorization.ui.CategoryPicker;
|
||||
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
|
||||
import com.arsdigita.util.Classes;
|
||||
|
||||
public class SiteProxyProviderForm extends AbstractProviderForm {
|
||||
|
|
@ -34,7 +34,12 @@ public class SiteProxyProviderForm extends AbstractProviderForm {
|
|||
private CategoryPicker m_category_picker;
|
||||
|
||||
public SiteProxyProviderForm(ACSObjectSelectionModel provider) {
|
||||
super("siteProxyProvider", SiteProxyProvider.class, provider);
|
||||
this(provider, null);
|
||||
}
|
||||
|
||||
public SiteProxyProviderForm(ACSObjectSelectionModel provider,
|
||||
ApplicationInstanceAwareContainer parent) {
|
||||
super("siteProxyProvider", SiteProxyProvider.class, provider, parent);
|
||||
|
||||
setMetaDataAttribute("title", "SiteProxy provider properties");
|
||||
}
|
||||
|
|
@ -43,18 +48,20 @@ public class SiteProxyProviderForm extends AbstractProviderForm {
|
|||
super.addWidgets();
|
||||
m_category_picker = (CategoryPicker) Classes.newInstance(AtoZ
|
||||
.getConfig().getRootCategoryPicker(),
|
||||
new Class[] { String.class }, new Object[] { "rootCategory" });
|
||||
new Class[]{String.class},
|
||||
new Object[]{"rootCategory"});
|
||||
((SimpleComponent) m_category_picker).setMetaDataAttribute("label",
|
||||
"Root category");
|
||||
"Root category");
|
||||
add(m_category_picker);
|
||||
}
|
||||
|
||||
protected void initWidgets(PageState state, AtoZProvider provider) {
|
||||
super.initWidgets(state, provider);
|
||||
SiteProxyProvider siteProxyProvider = (SiteProxyProvider) provider;
|
||||
if (siteProxyProvider != null)
|
||||
if (siteProxyProvider != null) {
|
||||
m_category_picker.setCategory(state, siteProxyProvider
|
||||
.getCategory());
|
||||
}
|
||||
}
|
||||
|
||||
protected void processWidgets(PageState state, AtoZProvider provider) {
|
||||
|
|
@ -64,4 +71,5 @@ public class SiteProxyProviderForm extends AbstractProviderForm {
|
|||
|
||||
siteProxyProvider.setCategory(m_category_picker.getCategory(state));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,4 +17,4 @@
|
|||
--
|
||||
-- $Id$
|
||||
|
||||
UPDATE application_types SET singleton_p = true WHERE object_type = 'com.arsdigita.atoz.AtoZ';
|
||||
UPDATE application_types SET singleton_p = false WHERE object_type = 'com.arsdigita.atoz.AtoZ';
|
||||
|
|
@ -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.atoz;
|
||||
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
|
|
@ -35,12 +34,12 @@ import java.util.Set;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Application domain class and main entry ponit of AtoZ application (package).
|
||||
* Application domain class and main entry point of AtoZ application (package).
|
||||
*
|
||||
* The package enables a site to present content in alphabetical oder as an
|
||||
* additional service to it's users. The content tp present is retrieved from
|
||||
* additional service to it's users. The content to present is retrieved from
|
||||
* the storage by 'providers'. A generic provider for content items is part
|
||||
* of the package, additional specialized providers may provide specific kind
|
||||
* of the package, additional specialised providers may provide specific kind
|
||||
* of content.
|
||||
*
|
||||
* It manages an registry of available providers which generate the content for
|
||||
|
|
@ -53,15 +52,12 @@ public class AtoZ extends Application {
|
|||
private static final Logger logger = Logger.getLogger(AtoZ.class);
|
||||
/** PDL Stuff - Base object */
|
||||
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.atoz.AtoZ";
|
||||
|
||||
/* Convenient Strings */
|
||||
public static final String PROVIDERS = "atozProviders";
|
||||
public static final String SORT_KEY = "sortKey";
|
||||
|
||||
/** Internal registry of available providers. A provider delivers for a
|
||||
* specific content type the title to include in AtoZ list. */
|
||||
private static Set s_types = new HashSet();
|
||||
|
||||
/** Config object containing various parameter */
|
||||
private static final AtoZConfig s_config = AtoZConfig.getConfig();
|
||||
|
||||
|
|
@ -82,7 +78,7 @@ public class AtoZ extends Application {
|
|||
public AtoZ(OID oid) {
|
||||
super(oid);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provides client classes with the config object.
|
||||
*/
|
||||
|
|
@ -101,25 +97,24 @@ public class AtoZ extends Application {
|
|||
}
|
||||
|
||||
public DomainCollection getProviders() {
|
||||
DataCollection providers = (DataCollection)get(PROVIDERS);
|
||||
DataCollection providers = (DataCollection) get(PROVIDERS);
|
||||
providers.addOrder("link." + SORT_KEY);
|
||||
return new DomainCollection(providers);
|
||||
}
|
||||
|
||||
public AtoZGenerator[] getGenerators() {
|
||||
DataCollection providers = (DataCollection)get(PROVIDERS);
|
||||
|
||||
DataCollection providers = (DataCollection) get(PROVIDERS);
|
||||
|
||||
List generators = new ArrayList();
|
||||
while (providers.next()) {
|
||||
AtoZProvider provider = (AtoZProvider)DomainObjectFactory
|
||||
.newInstance(providers.getDataObject());
|
||||
AtoZProvider provider = (AtoZProvider) DomainObjectFactory
|
||||
.newInstance(providers.getDataObject());
|
||||
generators.add(provider.getGenerator());
|
||||
}
|
||||
|
||||
return (AtoZGenerator[])generators.toArray(
|
||||
new AtoZGenerator[generators.size()]);
|
||||
}
|
||||
|
||||
return (AtoZGenerator[]) generators.toArray(
|
||||
new AtoZGenerator[generators.size()]);
|
||||
}
|
||||
|
||||
public static Element newElement(String name) {
|
||||
Assert.isTrue(name.indexOf(":") == -1, "name does not contain :");
|
||||
|
|
@ -138,8 +133,7 @@ public class AtoZ extends Application {
|
|||
}
|
||||
|
||||
public static AtoZProviderType[] getProviderTypes() {
|
||||
return (AtoZProviderType[])s_types
|
||||
.toArray(new AtoZProviderType[s_types.size()]);
|
||||
return (AtoZProviderType[]) s_types.toArray(new AtoZProviderType[s_types.size()]);
|
||||
}
|
||||
|
||||
// /*
|
||||
|
|
@ -149,7 +143,6 @@ public class AtoZ extends Application {
|
|||
// public String getContextPath() {
|
||||
// return "/ccm-atoz";
|
||||
// }
|
||||
|
||||
/**
|
||||
* Returns the path name of the location of the applications servlet/JSP.
|
||||
*
|
||||
|
|
@ -184,4 +177,3 @@ public class AtoZ extends Application {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,13 +15,12 @@
|
|||
* 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.atoz;
|
||||
|
||||
|
||||
import com.arsdigita.atoz.ui.admin.AbstractProviderForm;
|
||||
import com.arsdigita.atoz.ui.admin.ProviderAdmin;
|
||||
import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
||||
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
|
||||
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.util.Classes;
|
||||
|
|
@ -31,7 +30,7 @@ import com.arsdigita.util.Classes;
|
|||
* @author pb
|
||||
*/
|
||||
public class AtoZProviderType {
|
||||
|
||||
|
||||
private String m_title;
|
||||
private String m_description;
|
||||
private Class m_provider;
|
||||
|
|
@ -44,11 +43,11 @@ public class AtoZProviderType {
|
|||
Class providerCreate,
|
||||
Class providerAdmin) {
|
||||
Assert.isTrue(AtoZProvider.class.isAssignableFrom(provider),
|
||||
"provider is a subclass of AtoZProvider");
|
||||
"provider is a subclass of AtoZProvider");
|
||||
Assert.isTrue(ProviderAdmin.class.isAssignableFrom(providerAdmin),
|
||||
"providerAdmin is a subclass of ProviderAdmin");
|
||||
"providerAdmin is a subclass of ProviderAdmin");
|
||||
Assert.isTrue(AbstractProviderForm.class.isAssignableFrom(providerCreate),
|
||||
"providerCreate is a subclass of ProviderForm");
|
||||
"providerCreate is a subclass of ProviderForm");
|
||||
|
||||
m_title = title;
|
||||
m_description = description;
|
||||
|
|
@ -60,11 +59,11 @@ public class AtoZProviderType {
|
|||
public String getTitle() {
|
||||
return m_title;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return m_description;
|
||||
}
|
||||
|
||||
|
||||
public Class getProvider() {
|
||||
return m_provider;
|
||||
}
|
||||
|
|
@ -72,25 +71,34 @@ public class AtoZProviderType {
|
|||
public Class getProviderCreate() {
|
||||
return m_providerCreate;
|
||||
}
|
||||
|
||||
|
||||
public Class getProviderAdmin() {
|
||||
return m_providerAdmin;
|
||||
}
|
||||
|
||||
|
||||
public AtoZProvider createProvider() {
|
||||
return (AtoZProvider)Classes.newInstance(m_provider);
|
||||
return (AtoZProvider) Classes.newInstance(m_provider);
|
||||
}
|
||||
|
||||
public AbstractProviderForm createProviderCreate(ACSObjectSelectionModel provider) {
|
||||
return (AbstractProviderForm)Classes
|
||||
.newInstance(m_providerCreate,
|
||||
new Class[] { ACSObjectSelectionModel.class },
|
||||
new Object[] { provider });
|
||||
return (AbstractProviderForm) Classes.newInstance(m_providerCreate,
|
||||
new Class[]{ACSObjectSelectionModel.class},
|
||||
new Object[]{provider});
|
||||
}
|
||||
|
||||
public AbstractProviderForm createProviderCreate(ACSObjectSelectionModel provider,
|
||||
ApplicationInstanceAwareContainer parent) {
|
||||
return (AbstractProviderForm) Classes.newInstance(
|
||||
m_providerCreate,
|
||||
new Class[]{ACSObjectSelectionModel.class,
|
||||
ApplicationInstanceAwareContainer.class},
|
||||
new Object[]{provider, parent});
|
||||
}
|
||||
|
||||
public ProviderAdmin createProviderAdmin(ACSObjectSelectionModel provider) {
|
||||
return (ProviderAdmin)Classes
|
||||
.newInstance(m_providerAdmin,
|
||||
new Class[] { ACSObjectSelectionModel.class },
|
||||
new Object[] { provider });
|
||||
return (ProviderAdmin) Classes.newInstance(m_providerAdmin,
|
||||
new Class[]{ACSObjectSelectionModel.class},
|
||||
new Object[]{provider});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,13 +15,12 @@
|
|||
* 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.atoz;
|
||||
|
||||
// import com.arsdigita.atoz.siteproxy.AtoZSiteProxyProvider;
|
||||
// import com.arsdigita.atoz.siteproxy.ui.admin.SiteProxyProviderAdmin;
|
||||
// import com.arsdigita.atoz.siteproxy.ui.admin.SiteProxyProviderForm;
|
||||
|
||||
import com.arsdigita.atoz.ui.admin.AtoZApplicationManager;
|
||||
import com.arsdigita.atoz.ui.admin.CategoryProviderAdmin;
|
||||
import com.arsdigita.atoz.ui.admin.CategoryProviderForm;
|
||||
import com.arsdigita.atoz.ui.admin.ItemProviderAdmin;
|
||||
|
|
@ -41,6 +40,7 @@ import com.arsdigita.runtime.CompoundInitializer;
|
|||
import com.arsdigita.runtime.DomainInitEvent;
|
||||
import com.arsdigita.runtime.PDLInitializer;
|
||||
import com.arsdigita.runtime.RuntimeConfig;
|
||||
import com.arsdigita.ui.admin.ApplicationManagers;
|
||||
import com.arsdigita.xml.XML;
|
||||
|
||||
/**
|
||||
|
|
@ -59,7 +59,8 @@ public class Initializer extends CompoundInitializer {
|
|||
final int database = DbHelper.getDatabaseFromURL(url);
|
||||
|
||||
add(new PDLInitializer(new ManifestSource("ccm-atoz.pdl.mf",
|
||||
new NameFilter(DbHelper.getDatabaseSuffix(database), "pdl"))));
|
||||
new NameFilter(DbHelper.
|
||||
getDatabaseSuffix(database), "pdl"))));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -67,39 +68,40 @@ public class Initializer extends CompoundInitializer {
|
|||
* @param evt
|
||||
*/
|
||||
@Override
|
||||
public void init(DomainInitEvent evt) {
|
||||
super.init(evt);
|
||||
public void init(DomainInitEvent evt) {
|
||||
super.init(evt);
|
||||
|
||||
// Was previously invoked by ApplicationSetup, added here in the process
|
||||
// of code cleanup. See release notes version 2.0
|
||||
/* Register object instantiator for AtoZ domain class */
|
||||
evt.getFactory().registerInstantiator
|
||||
(AtoZ.BASE_DATA_OBJECT_TYPE,
|
||||
new ACSObjectInstantiator() {
|
||||
@Override
|
||||
public DomainObject doNewInstance(DataObject dataObject) {
|
||||
return new AtoZ(dataObject);
|
||||
}
|
||||
} );
|
||||
evt.getFactory().registerInstantiator(AtoZ.BASE_DATA_OBJECT_TYPE,
|
||||
new ACSObjectInstantiator() {
|
||||
@Override
|
||||
public DomainObject doNewInstance(DataObject dataObject) {
|
||||
return new AtoZ(dataObject);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
DomainObjectFactory f = evt.getFactory();
|
||||
f.registerInstantiator(CategoryAlias.BASE_DATA_OBJECT_TYPE,
|
||||
f.registerInstantiator(CategoryAlias.BASE_DATA_OBJECT_TYPE,
|
||||
new DomainObjectInstantiator() {
|
||||
protected DomainObject doNewInstance(DataObject dataObject) {
|
||||
return new CategoryAlias(dataObject);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
XML.parse(AtoZ.getConfig().getTraversalAdapters(),
|
||||
new TraversalHandler());
|
||||
|
||||
|
||||
|
||||
AtoZ.registerProviderType(
|
||||
new AtoZProviderType("Item Provider",
|
||||
new AtoZProviderType("Item Provider",
|
||||
"Provides an item A-Z",
|
||||
ItemProvider.class,
|
||||
ItemProvider.class,
|
||||
ItemProviderForm.class,
|
||||
ItemProviderAdmin.class));
|
||||
|
||||
|
|
@ -113,13 +115,13 @@ public class Initializer extends CompoundInitializer {
|
|||
// Introduces a dependency on ccm-types-siteproxy
|
||||
// Must be refactored into its own package.
|
||||
/* MOVED to ccm-atoz-siteproxy
|
||||
AtoZ.registerProviderType(
|
||||
new AtoZProviderType("SiteProxy Provider",
|
||||
"Provides a SiteProxy A-Z",
|
||||
AtoZSiteProxyProvider.class,
|
||||
SiteProxyProviderForm.class,
|
||||
SiteProxyProviderAdmin.class));
|
||||
*/
|
||||
AtoZ.registerProviderType(
|
||||
new AtoZProviderType("SiteProxy Provider",
|
||||
"Provides a SiteProxy A-Z",
|
||||
AtoZSiteProxyProvider.class,
|
||||
SiteProxyProviderForm.class,
|
||||
SiteProxyProviderAdmin.class));
|
||||
*/
|
||||
|
||||
// Introduces dependenciy on navigation package
|
||||
// Function / purpose ??
|
||||
|
|
@ -128,12 +130,15 @@ public class Initializer extends CompoundInitializer {
|
|||
|
||||
// Introduces dependency on ccm-ldn-typesesdervise ??
|
||||
/* AtoZ.registerProviderType(
|
||||
new AtoZProviderType("ESD Toolkit Domain Provider",
|
||||
"Provides a ESD Toolkit A-Z",
|
||||
DomainProvider.class,
|
||||
DomainProviderForm.class,
|
||||
DomainProviderAdmin.class));
|
||||
*/
|
||||
new AtoZProviderType("ESD Toolkit Domain Provider",
|
||||
"Provides a ESD Toolkit A-Z",
|
||||
DomainProvider.class,
|
||||
DomainProviderForm.class,
|
||||
DomainProviderAdmin.class));
|
||||
*/
|
||||
|
||||
//Register the ApplicationManager implementation for the AtoZ application
|
||||
ApplicationManagers.register(new AtoZApplicationManager());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,9 +82,9 @@ public class Loader extends PackageLoader {
|
|||
* hyphen and converted to lower case.
|
||||
* "AtoZ" will become "atoz". */
|
||||
final ApplicationType type = new ApplicationType("AtoZ",
|
||||
AtoZ.BASE_DATA_OBJECT_TYPE);
|
||||
AtoZ.BASE_DATA_OBJECT_TYPE);
|
||||
type.setDescription("A-Z of content.");
|
||||
type.setSingleton(true);
|
||||
type.setSingleton(false);
|
||||
type.save();
|
||||
|
||||
if (!Application.isInstalled(AtoZ.BASE_DATA_OBJECT_TYPE,
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
|||
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
|
||||
import com.arsdigita.kernel.Kernel;
|
||||
import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
||||
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.util.Classes;
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -49,16 +50,27 @@ public abstract class AbstractProviderForm extends Form {
|
|||
private TextField title;
|
||||
private TextArea description;
|
||||
private final SaveCancelSection buttons;
|
||||
private final ApplicationInstanceAwareContainer parent;
|
||||
|
||||
public AbstractProviderForm(final String name, final Class providerType, final ACSObjectSelectionModel provider) {
|
||||
public AbstractProviderForm(final String name,
|
||||
final Class providerType,
|
||||
final ACSObjectSelectionModel provider) {
|
||||
this(name, providerType, provider, null);
|
||||
}
|
||||
|
||||
public AbstractProviderForm(final String name,
|
||||
final Class providerType,
|
||||
final ACSObjectSelectionModel provider,
|
||||
final ApplicationInstanceAwareContainer parent) {
|
||||
super(name, new ColumnPanel(2));
|
||||
setRedirecting(true);
|
||||
|
||||
this.providerModel = provider;
|
||||
this.providerType = providerType;
|
||||
this.parent = parent;
|
||||
|
||||
buttons = new SaveCancelSection(new SimpleContainer());
|
||||
|
||||
buttons = new SaveCancelSection(new SimpleContainer());
|
||||
|
||||
addWidgets();
|
||||
add(buttons);
|
||||
|
||||
|
|
@ -108,6 +120,7 @@ public abstract class AbstractProviderForm extends Form {
|
|||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submitted(final FormSectionEvent event) throws FormProcessException {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
|
|
@ -125,13 +138,19 @@ public abstract class AbstractProviderForm extends Form {
|
|||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(final FormSectionEvent event) throws FormProcessException {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
AtoZProvider provider = (AtoZProvider) providerModel.getSelectedObject(state);
|
||||
|
||||
if (provider == null) {
|
||||
final AtoZ atoz = (AtoZ) Kernel.getContext().getResource();
|
||||
final AtoZ atoz;
|
||||
if (parent == null) {
|
||||
atoz = (AtoZ) Kernel.getContext().getResource();
|
||||
} else {
|
||||
atoz = (AtoZ) parent.getAppInstance();
|
||||
}
|
||||
Assert.exists(atoz, AtoZ.class);
|
||||
provider = (AtoZProvider) Classes.newInstance(providerType);
|
||||
atoz.addProvider(provider);
|
||||
|
|
|
|||
|
|
@ -39,6 +39,12 @@ import java.util.Map;
|
|||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @depcreated UI integrated into Application tab at /ccm/admin. This class is now obsolete
|
||||
* and has been replaced by {@link AtoZAdminPane}. This class is kept here for now, but will be
|
||||
* removed in a further release, together with the Admin UI at /ccm/atoz/admin.
|
||||
*/
|
||||
public class AdminPane extends SimpleContainer {
|
||||
|
||||
private static final String XMLNS = "http://xmlns.redhat.com/atoz/1.0";
|
||||
|
|
@ -49,6 +55,7 @@ public class AdminPane extends SimpleContainer {
|
|||
private AtoZProviderTable m_providerTable;
|
||||
private ProviderCreateForm m_createForm;
|
||||
|
||||
|
||||
public AdminPane(BigDecimalParameter provider) {
|
||||
super("atoz:adminPane", XMLNS);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,178 @@
|
|||
/*
|
||||
* 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.atoz.ui.admin;
|
||||
|
||||
import com.arsdigita.atoz.AtoZ;
|
||||
import com.arsdigita.atoz.AtoZProvider;
|
||||
import com.arsdigita.atoz.AtoZProviderType;
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.Page;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.SimpleContainer;
|
||||
import com.arsdigita.bebop.event.ActionEvent;
|
||||
import com.arsdigita.bebop.event.ActionListener;
|
||||
import com.arsdigita.bebop.event.ChangeEvent;
|
||||
import com.arsdigita.bebop.event.ChangeListener;
|
||||
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||
import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
||||
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
|
||||
import com.arsdigita.util.Assert;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
*/
|
||||
public class AtoZAdminPane extends SimpleContainer {
|
||||
|
||||
private final ACSObjectSelectionModel providerSelectionModel;
|
||||
private final BigDecimalParameter providerParam;
|
||||
private final Map providerCreateMap;
|
||||
private final Map providerAdminMap;
|
||||
private final AtoZProviderTable providerTable;
|
||||
private final ProviderCreateForm createForm;
|
||||
|
||||
public AtoZAdminPane(final ApplicationInstanceAwareContainer parent,
|
||||
final BigDecimalParameter providerParam) {
|
||||
super();
|
||||
|
||||
this.providerParam = providerParam;
|
||||
|
||||
providerSelectionModel = new ACSObjectSelectionModel(providerParam);
|
||||
providerSelectionModel.addChangeListener(new ProviderEditStart());
|
||||
|
||||
providerTable = new AtoZProviderTable(providerSelectionModel, parent);
|
||||
add(providerTable);
|
||||
|
||||
createForm = new ProviderCreateForm();
|
||||
createForm.addCompletionListener(new ProviderCreateComplete());
|
||||
add(createForm);
|
||||
|
||||
AtoZProviderType[] providerTypes = AtoZ.getProviderTypes();
|
||||
providerCreateMap = new HashMap();
|
||||
providerAdminMap = new HashMap();
|
||||
|
||||
for (AtoZProviderType providerType : providerTypes) {
|
||||
final ProviderAdmin admin = providerType.createProviderAdmin(providerSelectionModel);
|
||||
admin.addCompletionListener(new ProviderAdminComplete(admin));
|
||||
providerAdminMap.put(providerType.getProvider(), admin);
|
||||
add(admin);
|
||||
|
||||
final AbstractProviderForm create = providerType.createProviderCreate(
|
||||
providerSelectionModel, parent);
|
||||
create.addCompletionListener(new ProviderAdminComplete(create));
|
||||
providerCreateMap.put(providerType.getProvider(), create);
|
||||
add(create);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(final Page page) {
|
||||
super.register(page);
|
||||
|
||||
page.addGlobalStateParam(providerParam);
|
||||
|
||||
Iterator providers = providerAdminMap.values().iterator();
|
||||
while (providers.hasNext()) {
|
||||
final ProviderAdmin admin = (ProviderAdmin) providers.next();
|
||||
page.setVisibleDefault(admin, false);
|
||||
}
|
||||
|
||||
providers = providerCreateMap.values().iterator();
|
||||
while (providers.hasNext()) {
|
||||
final AbstractProviderForm create = (AbstractProviderForm) providers.next();
|
||||
page.setVisibleDefault(create, false);
|
||||
}
|
||||
}
|
||||
|
||||
private class ProviderEditStart implements ChangeListener {
|
||||
|
||||
public ProviderEditStart() {
|
||||
//Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateChanged(final ChangeEvent event) {
|
||||
PageState state = event.getPageState();
|
||||
|
||||
AtoZProvider provider = (AtoZProvider) providerSelectionModel.getSelectedObject(state);
|
||||
|
||||
if (provider == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProviderAdmin admin = (ProviderAdmin) providerAdminMap.get(provider.getClass());
|
||||
Assert.exists(admin, ProviderAdmin.class);
|
||||
|
||||
admin.setVisible(state, true);
|
||||
createForm.setVisible(state, false);
|
||||
//m_providerList.setVisible(state, false);
|
||||
providerTable.setVisible(state, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ProviderCreateComplete implements ActionListener {
|
||||
|
||||
public ProviderCreateComplete() {
|
||||
//Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
final Class provider = createForm.getProviderType(state);
|
||||
Assert.exists(provider, Class.class);
|
||||
|
||||
final AbstractProviderForm create = (AbstractProviderForm) providerCreateMap.get(
|
||||
provider);
|
||||
Assert.exists(create, AbstractProviderForm.class);
|
||||
|
||||
create.setVisible(state, true);
|
||||
createForm.setVisible(state, false);
|
||||
//m_providerList.setVisible(state, false);
|
||||
providerTable.setVisible(state, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ProviderAdminComplete implements ActionListener {
|
||||
|
||||
private final Component admin;
|
||||
|
||||
public ProviderAdminComplete(final Component admin) {
|
||||
this.admin = admin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
PageState state = event.getPageState();
|
||||
admin.setVisible(state, false);
|
||||
createForm.setVisible(state, true);
|
||||
//m_providerList.setVisible(state, true);
|
||||
providerTable.setVisible(state, true);
|
||||
providerSelectionModel.clearSelection(state);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* 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.atoz.ui.admin;
|
||||
|
||||
import com.arsdigita.atoz.AtoZ;
|
||||
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||
import com.arsdigita.ui.admin.applications.AbstractApplicationManager;
|
||||
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
|
||||
|
||||
/**
|
||||
* Application Manager implementation for the AtoZ application integrating the admin UI for AtoZ
|
||||
* into the Applications tab at {@code /ccm/admin/}.
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class AtoZApplicationManager extends AbstractApplicationManager<AtoZ> {
|
||||
|
||||
@Override
|
||||
public Class<AtoZ> getApplication() {
|
||||
return AtoZ.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationInstanceAwareContainer getApplicationAdminForm() {
|
||||
final ApplicationInstanceAwareContainer container = new ApplicationInstanceAwareContainer();
|
||||
|
||||
final BigDecimalParameter providerParam = new BigDecimalParameter("provider");
|
||||
final AtoZAdminPane adminPane = new AtoZAdminPane(container, providerParam);
|
||||
container.add(adminPane);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowRoot() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,6 @@ import com.arsdigita.atoz.ui.AtoZGlobalizationUtil;
|
|||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Link;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.Table;
|
||||
import com.arsdigita.bebop.event.TableActionEvent;
|
||||
|
|
@ -17,15 +16,12 @@ 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.kernel.Kernel;
|
||||
import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -34,15 +30,22 @@ import java.math.BigDecimal;
|
|||
*/
|
||||
public class AtoZProviderTable extends Table implements TableActionListener {
|
||||
|
||||
private static final String EDIT = "edit";
|
||||
private static final String DELETE = "delete";
|
||||
//private static final String EDIT = "edit";
|
||||
//private static final String DELETE = "delete";
|
||||
private final static String TABLE_COL_DELETE = "table_col_delete";
|
||||
private final static String TABLE_COL_EDIT = "table_col_edit";
|
||||
private final ACSObjectSelectionModel selectedProvider;
|
||||
private final ApplicationInstanceAwareContainer parent;
|
||||
|
||||
public AtoZProviderTable(final ACSObjectSelectionModel provider) {
|
||||
this(provider, null);
|
||||
}
|
||||
|
||||
public AtoZProviderTable(final ACSObjectSelectionModel provider,
|
||||
final ApplicationInstanceAwareContainer parent) {
|
||||
super();
|
||||
|
||||
this.parent = parent;
|
||||
this.selectedProvider = provider;
|
||||
|
||||
setEmptyView(new Label(AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.empty")));
|
||||
|
|
@ -79,6 +82,7 @@ public class AtoZProviderTable extends Table implements TableActionListener {
|
|||
addTableActionListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cellSelected(final TableActionEvent event) {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
|
|
@ -96,6 +100,7 @@ public class AtoZProviderTable extends Table implements TableActionListener {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void headSelected(final TableActionEvent event) {
|
||||
//Nothing
|
||||
}
|
||||
|
|
@ -106,12 +111,12 @@ public class AtoZProviderTable extends Table implements TableActionListener {
|
|||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableModel makeModel(final Table table,
|
||||
final PageState state) {
|
||||
table.getRowSelectionModel().clearSelection(state);
|
||||
return new AtoZTableModel(table);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class AtoZTableModel implements TableModel {
|
||||
|
|
@ -121,19 +126,26 @@ public class AtoZProviderTable extends Table implements TableActionListener {
|
|||
|
||||
public AtoZTableModel(final Table table) {
|
||||
this.table = table;
|
||||
|
||||
final AtoZ atoz = (AtoZ) Kernel.getContext().getResource();
|
||||
final AtoZ atoz;
|
||||
if (parent == null) {
|
||||
atoz = (AtoZ) Kernel.getContext().getResource();
|
||||
} else {
|
||||
atoz = (AtoZ) parent.getAppInstance();
|
||||
}
|
||||
providers = atoz.getProviders();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return table.getColumnModel().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nextRow() {
|
||||
return providers.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(final int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
|
|
@ -143,14 +155,17 @@ public class AtoZProviderTable extends Table implements TableActionListener {
|
|||
case 2:
|
||||
return ((AtoZProvider) providers.getDomainObject()).getObjectType().getName();
|
||||
case 3:
|
||||
return AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.edit").localize();
|
||||
return AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.edit").
|
||||
localize();
|
||||
case 4:
|
||||
return AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.delete").localize();
|
||||
return AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.delete").
|
||||
localize();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKeyAt(final int columnIndex) {
|
||||
return providers.getDomainObject().getOID();
|
||||
}
|
||||
|
|
@ -163,6 +178,7 @@ public class AtoZProviderTable extends Table implements TableActionListener {
|
|||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getComponent(final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
|
|
@ -188,6 +204,7 @@ public class AtoZProviderTable extends Table implements TableActionListener {
|
|||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getComponent(final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
|
|
@ -198,7 +215,8 @@ public class AtoZProviderTable extends Table implements TableActionListener {
|
|||
final ControlLink link = new ControlLink((String) AtoZGlobalizationUtil.globalize(
|
||||
"atoz.ui.providers_table.delete").localize());
|
||||
|
||||
link.setConfirmation((String) AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.delete.confirm").
|
||||
link.setConfirmation((String) AtoZGlobalizationUtil.globalize(
|
||||
"atoz.ui.providers_table.delete.confirm").
|
||||
localize());
|
||||
|
||||
return link;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import com.arsdigita.bebop.SimpleComponent;
|
|||
import com.arsdigita.categorization.Category;
|
||||
import com.arsdigita.categorization.ui.CategoryPicker;
|
||||
import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
||||
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
|
||||
import com.arsdigita.util.Classes;
|
||||
|
||||
/**
|
||||
|
|
@ -39,7 +40,12 @@ public class CategoryProviderForm extends AbstractProviderForm {
|
|||
private CategoryPicker rootCategory;
|
||||
|
||||
public CategoryProviderForm(final ACSObjectSelectionModel provider) {
|
||||
super("categoryProvider", CategoryProvider.class, provider);
|
||||
this(provider, null);
|
||||
}
|
||||
|
||||
public CategoryProviderForm(final ACSObjectSelectionModel provider,
|
||||
final ApplicationInstanceAwareContainer parent) {
|
||||
super("categoryProvider", CategoryProvider.class, provider, parent);
|
||||
|
||||
setMetaDataAttribute("title", "Category provider properties");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
|||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
@ -52,7 +53,12 @@ public class ItemProviderForm extends AbstractProviderForm {
|
|||
private TextField loadPaths;
|
||||
|
||||
public ItemProviderForm(final ACSObjectSelectionModel provider) {
|
||||
super("itemProvider", ItemProvider.class, provider);
|
||||
this(provider, null);
|
||||
}
|
||||
|
||||
public ItemProviderForm(final ACSObjectSelectionModel provider,
|
||||
final ApplicationInstanceAwareContainer parent) {
|
||||
super("itemProvider", ItemProvider.class, provider, parent);
|
||||
|
||||
setMetaDataAttribute("title", "Item provider properties");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ import com.arsdigita.bebop.form.Submit;
|
|||
|
||||
import com.arsdigita.util.Classes;
|
||||
import com.arsdigita.util.Assert;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class ProviderCreateForm extends Form {
|
||||
|
||||
|
|
@ -53,6 +55,11 @@ public class ProviderCreateForm extends Form {
|
|||
m_providerType.addOption(new Option(null, "--Select one--"));
|
||||
|
||||
AtoZProviderType[] providers = AtoZ.getProviderTypes();
|
||||
Arrays.sort(providers, new Comparator<AtoZProviderType>() {
|
||||
public int compare(AtoZProviderType type1, AtoZProviderType type2) {
|
||||
return type1.getTitle().compareTo(type2.getTitle());
|
||||
}
|
||||
});
|
||||
for (int i = 0; i < providers.length; i++) {
|
||||
m_providerType.addOption(
|
||||
new Option(providers[i].getProvider().getName(),
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
|||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
|
||||
|
||||
import java.util.TooManyListenersException;
|
||||
|
||||
|
|
@ -44,12 +45,19 @@ public class DomainProviderForm extends AbstractProviderForm {
|
|||
|
||||
private SingleSelect m_domain;
|
||||
|
||||
public DomainProviderForm(ACSObjectSelectionModel provider) {
|
||||
this(provider, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public DomainProviderForm(ACSObjectSelectionModel provider) {
|
||||
public DomainProviderForm(ACSObjectSelectionModel provider,
|
||||
ApplicationInstanceAwareContainer parent) {
|
||||
super("domainProvider",
|
||||
DomainProvider.class, provider);
|
||||
DomainProvider.class,
|
||||
provider,
|
||||
parent);
|
||||
|
||||
setMetaDataAttribute("title", "Domain provider properties");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue