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-94f89814c4df
master
jensp 2013-10-30 13:35:06 +00:00
parent 2fde32df93
commit 478bc98131
15 changed files with 416 additions and 99 deletions

View File

@ -15,7 +15,6 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.atoz.siteproxy.ui.admin; package com.arsdigita.atoz.siteproxy.ui.admin;
import com.arsdigita.atoz.ui.admin.AbstractProviderForm; 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.AtoZProvider;
import com.arsdigita.atoz.siteproxy.SiteProxyProvider; import com.arsdigita.atoz.siteproxy.SiteProxyProvider;
import com.arsdigita.categorization.ui.CategoryPicker; import com.arsdigita.categorization.ui.CategoryPicker;
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
import com.arsdigita.util.Classes; import com.arsdigita.util.Classes;
public class SiteProxyProviderForm extends AbstractProviderForm { public class SiteProxyProviderForm extends AbstractProviderForm {
@ -34,7 +34,12 @@ public class SiteProxyProviderForm extends AbstractProviderForm {
private CategoryPicker m_category_picker; private CategoryPicker m_category_picker;
public SiteProxyProviderForm(ACSObjectSelectionModel provider) { 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"); setMetaDataAttribute("title", "SiteProxy provider properties");
} }
@ -43,18 +48,20 @@ public class SiteProxyProviderForm extends AbstractProviderForm {
super.addWidgets(); super.addWidgets();
m_category_picker = (CategoryPicker) Classes.newInstance(AtoZ m_category_picker = (CategoryPicker) Classes.newInstance(AtoZ
.getConfig().getRootCategoryPicker(), .getConfig().getRootCategoryPicker(),
new Class[] { String.class }, new Object[] { "rootCategory" }); new Class[]{String.class},
new Object[]{"rootCategory"});
((SimpleComponent) m_category_picker).setMetaDataAttribute("label", ((SimpleComponent) m_category_picker).setMetaDataAttribute("label",
"Root category"); "Root category");
add(m_category_picker); add(m_category_picker);
} }
protected void initWidgets(PageState state, AtoZProvider provider) { protected void initWidgets(PageState state, AtoZProvider provider) {
super.initWidgets(state, provider); super.initWidgets(state, provider);
SiteProxyProvider siteProxyProvider = (SiteProxyProvider) provider; SiteProxyProvider siteProxyProvider = (SiteProxyProvider) provider;
if (siteProxyProvider != null) if (siteProxyProvider != null) {
m_category_picker.setCategory(state, siteProxyProvider m_category_picker.setCategory(state, siteProxyProvider
.getCategory()); .getCategory());
}
} }
protected void processWidgets(PageState state, AtoZProvider provider) { protected void processWidgets(PageState state, AtoZProvider provider) {
@ -64,4 +71,5 @@ public class SiteProxyProviderForm extends AbstractProviderForm {
siteProxyProvider.setCategory(m_category_picker.getCategory(state)); siteProxyProvider.setCategory(m_category_picker.getCategory(state));
} }
} }

View File

@ -17,4 +17,4 @@
-- --
-- $Id$ -- $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';

View File

@ -15,7 +15,6 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.atoz; package com.arsdigita.atoz;
import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.domain.DomainObjectFactory;
@ -35,12 +34,12 @@ import java.util.Set;
import org.apache.log4j.Logger; 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 * 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 * 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. * of content.
* *
* It manages an registry of available providers which generate the content for * 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); private static final Logger logger = Logger.getLogger(AtoZ.class);
/** PDL Stuff - Base object */ /** PDL Stuff - Base object */
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.atoz.AtoZ"; public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.atoz.AtoZ";
/* Convenient Strings */ /* Convenient Strings */
public static final String PROVIDERS = "atozProviders"; public static final String PROVIDERS = "atozProviders";
public static final String SORT_KEY = "sortKey"; public static final String SORT_KEY = "sortKey";
/** Internal registry of available providers. A provider delivers for a /** Internal registry of available providers. A provider delivers for a
* specific content type the title to include in AtoZ list. */ * specific content type the title to include in AtoZ list. */
private static Set s_types = new HashSet(); private static Set s_types = new HashSet();
/** Config object containing various parameter */ /** Config object containing various parameter */
private static final AtoZConfig s_config = AtoZConfig.getConfig(); private static final AtoZConfig s_config = AtoZConfig.getConfig();
@ -101,26 +97,25 @@ public class AtoZ extends Application {
} }
public DomainCollection getProviders() { public DomainCollection getProviders() {
DataCollection providers = (DataCollection)get(PROVIDERS); DataCollection providers = (DataCollection) get(PROVIDERS);
providers.addOrder("link." + SORT_KEY); providers.addOrder("link." + SORT_KEY);
return new DomainCollection(providers); return new DomainCollection(providers);
} }
public AtoZGenerator[] getGenerators() { public AtoZGenerator[] getGenerators() {
DataCollection providers = (DataCollection)get(PROVIDERS); DataCollection providers = (DataCollection) get(PROVIDERS);
List generators = new ArrayList(); List generators = new ArrayList();
while (providers.next()) { while (providers.next()) {
AtoZProvider provider = (AtoZProvider)DomainObjectFactory AtoZProvider provider = (AtoZProvider) DomainObjectFactory
.newInstance(providers.getDataObject()); .newInstance(providers.getDataObject());
generators.add(provider.getGenerator()); generators.add(provider.getGenerator());
} }
return (AtoZGenerator[])generators.toArray( return (AtoZGenerator[]) generators.toArray(
new AtoZGenerator[generators.size()]); new AtoZGenerator[generators.size()]);
} }
public static Element newElement(String name) { public static Element newElement(String name) {
Assert.isTrue(name.indexOf(":") == -1, "name does not contain :"); Assert.isTrue(name.indexOf(":") == -1, "name does not contain :");
return new Element("atoz:" + name, return new Element("atoz:" + name,
@ -138,8 +133,7 @@ public class AtoZ extends Application {
} }
public static AtoZProviderType[] getProviderTypes() { public static AtoZProviderType[] getProviderTypes() {
return (AtoZProviderType[])s_types return (AtoZProviderType[]) s_types.toArray(new AtoZProviderType[s_types.size()]);
.toArray(new AtoZProviderType[s_types.size()]);
} }
// /* // /*
@ -149,7 +143,6 @@ public class AtoZ extends Application {
// public String getContextPath() { // public String getContextPath() {
// return "/ccm-atoz"; // return "/ccm-atoz";
// } // }
/** /**
* Returns the path name of the location of the applications servlet/JSP. * Returns the path name of the location of the applications servlet/JSP.
* *
@ -184,4 +177,3 @@ public class AtoZ extends Application {
} }
} }

View File

@ -15,13 +15,12 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.atoz; package com.arsdigita.atoz;
import com.arsdigita.atoz.ui.admin.AbstractProviderForm; import com.arsdigita.atoz.ui.admin.AbstractProviderForm;
import com.arsdigita.atoz.ui.admin.ProviderAdmin; import com.arsdigita.atoz.ui.admin.ProviderAdmin;
import com.arsdigita.kernel.ui.ACSObjectSelectionModel; import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.util.Classes; import com.arsdigita.util.Classes;
@ -44,11 +43,11 @@ public class AtoZProviderType {
Class providerCreate, Class providerCreate,
Class providerAdmin) { Class providerAdmin) {
Assert.isTrue(AtoZProvider.class.isAssignableFrom(provider), Assert.isTrue(AtoZProvider.class.isAssignableFrom(provider),
"provider is a subclass of AtoZProvider"); "provider is a subclass of AtoZProvider");
Assert.isTrue(ProviderAdmin.class.isAssignableFrom(providerAdmin), Assert.isTrue(ProviderAdmin.class.isAssignableFrom(providerAdmin),
"providerAdmin is a subclass of ProviderAdmin"); "providerAdmin is a subclass of ProviderAdmin");
Assert.isTrue(AbstractProviderForm.class.isAssignableFrom(providerCreate), Assert.isTrue(AbstractProviderForm.class.isAssignableFrom(providerCreate),
"providerCreate is a subclass of ProviderForm"); "providerCreate is a subclass of ProviderForm");
m_title = title; m_title = title;
m_description = description; m_description = description;
@ -78,19 +77,28 @@ public class AtoZProviderType {
} }
public AtoZProvider createProvider() { public AtoZProvider createProvider() {
return (AtoZProvider)Classes.newInstance(m_provider); return (AtoZProvider) Classes.newInstance(m_provider);
} }
public AbstractProviderForm createProviderCreate(ACSObjectSelectionModel provider) { public AbstractProviderForm createProviderCreate(ACSObjectSelectionModel provider) {
return (AbstractProviderForm)Classes return (AbstractProviderForm) Classes.newInstance(m_providerCreate,
.newInstance(m_providerCreate, new Class[]{ACSObjectSelectionModel.class},
new Class[] { ACSObjectSelectionModel.class }, new Object[]{provider});
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) { public ProviderAdmin createProviderAdmin(ACSObjectSelectionModel provider) {
return (ProviderAdmin)Classes return (ProviderAdmin) Classes.newInstance(m_providerAdmin,
.newInstance(m_providerAdmin, new Class[]{ACSObjectSelectionModel.class},
new Class[] { ACSObjectSelectionModel.class }, new Object[]{provider});
new Object[] { provider });
} }
} }

View File

@ -15,13 +15,12 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.atoz; package com.arsdigita.atoz;
// import com.arsdigita.atoz.siteproxy.AtoZSiteProxyProvider; // import com.arsdigita.atoz.siteproxy.AtoZSiteProxyProvider;
// import com.arsdigita.atoz.siteproxy.ui.admin.SiteProxyProviderAdmin; // import com.arsdigita.atoz.siteproxy.ui.admin.SiteProxyProviderAdmin;
// import com.arsdigita.atoz.siteproxy.ui.admin.SiteProxyProviderForm; // 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.CategoryProviderAdmin;
import com.arsdigita.atoz.ui.admin.CategoryProviderForm; import com.arsdigita.atoz.ui.admin.CategoryProviderForm;
import com.arsdigita.atoz.ui.admin.ItemProviderAdmin; 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.DomainInitEvent;
import com.arsdigita.runtime.PDLInitializer; import com.arsdigita.runtime.PDLInitializer;
import com.arsdigita.runtime.RuntimeConfig; import com.arsdigita.runtime.RuntimeConfig;
import com.arsdigita.ui.admin.ApplicationManagers;
import com.arsdigita.xml.XML; import com.arsdigita.xml.XML;
/** /**
@ -59,7 +59,8 @@ public class Initializer extends CompoundInitializer {
final int database = DbHelper.getDatabaseFromURL(url); final int database = DbHelper.getDatabaseFromURL(url);
add(new PDLInitializer(new ManifestSource("ccm-atoz.pdl.mf", add(new PDLInitializer(new ManifestSource("ccm-atoz.pdl.mf",
new NameFilter(DbHelper.getDatabaseSuffix(database), "pdl")))); new NameFilter(DbHelper.
getDatabaseSuffix(database), "pdl"))));
} }
/** /**
@ -67,28 +68,29 @@ public class Initializer extends CompoundInitializer {
* @param evt * @param evt
*/ */
@Override @Override
public void init(DomainInitEvent evt) { public void init(DomainInitEvent evt) {
super.init(evt); super.init(evt);
// Was previously invoked by ApplicationSetup, added here in the process // Was previously invoked by ApplicationSetup, added here in the process
// of code cleanup. See release notes version 2.0 // of code cleanup. See release notes version 2.0
/* Register object instantiator for AtoZ domain class */ /* Register object instantiator for AtoZ domain class */
evt.getFactory().registerInstantiator evt.getFactory().registerInstantiator(AtoZ.BASE_DATA_OBJECT_TYPE,
(AtoZ.BASE_DATA_OBJECT_TYPE, new ACSObjectInstantiator() {
new ACSObjectInstantiator() { @Override
@Override public DomainObject doNewInstance(DataObject dataObject) {
public DomainObject doNewInstance(DataObject dataObject) { return new AtoZ(dataObject);
return new AtoZ(dataObject); }
}
} ); });
DomainObjectFactory f = evt.getFactory(); DomainObjectFactory f = evt.getFactory();
f.registerInstantiator(CategoryAlias.BASE_DATA_OBJECT_TYPE, f.registerInstantiator(CategoryAlias.BASE_DATA_OBJECT_TYPE,
new DomainObjectInstantiator() { new DomainObjectInstantiator() {
protected DomainObject doNewInstance(DataObject dataObject) { protected DomainObject doNewInstance(DataObject dataObject) {
return new CategoryAlias(dataObject); return new CategoryAlias(dataObject);
} }
}); });
@ -113,13 +115,13 @@ public class Initializer extends CompoundInitializer {
// Introduces a dependency on ccm-types-siteproxy // Introduces a dependency on ccm-types-siteproxy
// Must be refactored into its own package. // Must be refactored into its own package.
/* MOVED to ccm-atoz-siteproxy /* MOVED to ccm-atoz-siteproxy
AtoZ.registerProviderType( AtoZ.registerProviderType(
new AtoZProviderType("SiteProxy Provider", new AtoZProviderType("SiteProxy Provider",
"Provides a SiteProxy A-Z", "Provides a SiteProxy A-Z",
AtoZSiteProxyProvider.class, AtoZSiteProxyProvider.class,
SiteProxyProviderForm.class, SiteProxyProviderForm.class,
SiteProxyProviderAdmin.class)); SiteProxyProviderAdmin.class));
*/ */
// Introduces dependenciy on navigation package // Introduces dependenciy on navigation package
// Function / purpose ?? // Function / purpose ??
@ -128,12 +130,15 @@ public class Initializer extends CompoundInitializer {
// Introduces dependency on ccm-ldn-typesesdervise ?? // Introduces dependency on ccm-ldn-typesesdervise ??
/* AtoZ.registerProviderType( /* AtoZ.registerProviderType(
new AtoZProviderType("ESD Toolkit Domain Provider", new AtoZProviderType("ESD Toolkit Domain Provider",
"Provides a ESD Toolkit A-Z", "Provides a ESD Toolkit A-Z",
DomainProvider.class, DomainProvider.class,
DomainProviderForm.class, DomainProviderForm.class,
DomainProviderAdmin.class)); DomainProviderAdmin.class));
*/ */
//Register the ApplicationManager implementation for the AtoZ application
ApplicationManagers.register(new AtoZApplicationManager());
} }
} }

View File

@ -84,7 +84,7 @@ public class Loader extends PackageLoader {
final ApplicationType type = new ApplicationType("AtoZ", final ApplicationType type = new ApplicationType("AtoZ",
AtoZ.BASE_DATA_OBJECT_TYPE); AtoZ.BASE_DATA_OBJECT_TYPE);
type.setDescription("A-Z of content."); type.setDescription("A-Z of content.");
type.setSingleton(true); type.setSingleton(false);
type.save(); type.save();
if (!Application.isInstalled(AtoZ.BASE_DATA_OBJECT_TYPE, if (!Application.isInstalled(AtoZ.BASE_DATA_OBJECT_TYPE,

View File

@ -37,6 +37,7 @@ import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.StringInRangeValidationListener; import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.ui.ACSObjectSelectionModel; import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.util.Classes; import com.arsdigita.util.Classes;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -49,13 +50,24 @@ public abstract class AbstractProviderForm extends Form {
private TextField title; private TextField title;
private TextArea description; private TextArea description;
private final SaveCancelSection buttons; 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)); super(name, new ColumnPanel(2));
setRedirecting(true); setRedirecting(true);
this.providerModel = provider; this.providerModel = provider;
this.providerType = providerType; this.providerType = providerType;
this.parent = parent;
buttons = new SaveCancelSection(new SimpleContainer()); buttons = new SaveCancelSection(new SimpleContainer());
@ -108,6 +120,7 @@ public abstract class AbstractProviderForm extends Form {
super(); super();
} }
@Override
public void submitted(final FormSectionEvent event) throws FormProcessException { public void submitted(final FormSectionEvent event) throws FormProcessException {
final PageState state = event.getPageState(); final PageState state = event.getPageState();
@ -125,13 +138,19 @@ public abstract class AbstractProviderForm extends Form {
super(); super();
} }
@Override
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();
AtoZProvider provider = (AtoZProvider) providerModel.getSelectedObject(state); AtoZProvider provider = (AtoZProvider) providerModel.getSelectedObject(state);
if (provider == null) { 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); Assert.exists(atoz, AtoZ.class);
provider = (AtoZProvider) Classes.newInstance(providerType); provider = (AtoZProvider) Classes.newInstance(providerType);
atoz.addProvider(provider); atoz.addProvider(provider);

View File

@ -39,6 +39,12 @@ import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; 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 { public class AdminPane extends SimpleContainer {
private static final String XMLNS = "http://xmlns.redhat.com/atoz/1.0"; 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 AtoZProviderTable m_providerTable;
private ProviderCreateForm m_createForm; private ProviderCreateForm m_createForm;
public AdminPane(BigDecimalParameter provider) { public AdminPane(BigDecimalParameter provider) {
super("atoz:adminPane", XMLNS); super("atoz:adminPane", XMLNS);

View File

@ -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);
}
}
}

View File

@ -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;
}
}

View File

@ -6,7 +6,6 @@ import com.arsdigita.atoz.ui.AtoZGlobalizationUtil;
import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.ControlLink; import com.arsdigita.bebop.ControlLink;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Link;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Table; import com.arsdigita.bebop.Table;
import com.arsdigita.bebop.event.TableActionEvent; 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.TableModel;
import com.arsdigita.bebop.table.TableModelBuilder; import com.arsdigita.bebop.table.TableModelBuilder;
import com.arsdigita.domain.DomainCollection; import com.arsdigita.domain.DomainCollection;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.ui.ACSObjectSelectionModel; import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
import com.arsdigita.persistence.OID; import com.arsdigita.persistence.OID;
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
import com.arsdigita.util.LockableImpl; 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 { public class AtoZProviderTable extends Table implements TableActionListener {
private static final String EDIT = "edit"; //private static final String EDIT = "edit";
private static final String DELETE = "delete"; //private static final String DELETE = "delete";
private final static String TABLE_COL_DELETE = "table_col_delete"; private final static String TABLE_COL_DELETE = "table_col_delete";
private final static String TABLE_COL_EDIT = "table_col_edit"; private final static String TABLE_COL_EDIT = "table_col_edit";
private final ACSObjectSelectionModel selectedProvider; private final ACSObjectSelectionModel selectedProvider;
private final ApplicationInstanceAwareContainer parent;
public AtoZProviderTable(final ACSObjectSelectionModel provider) { public AtoZProviderTable(final ACSObjectSelectionModel provider) {
this(provider, null);
}
public AtoZProviderTable(final ACSObjectSelectionModel provider,
final ApplicationInstanceAwareContainer parent) {
super(); super();
this.parent = parent;
this.selectedProvider = provider; this.selectedProvider = provider;
setEmptyView(new Label(AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.empty"))); setEmptyView(new Label(AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.empty")));
@ -79,6 +82,7 @@ public class AtoZProviderTable extends Table implements TableActionListener {
addTableActionListener(this); addTableActionListener(this);
} }
@Override
public void cellSelected(final TableActionEvent event) { public void cellSelected(final TableActionEvent event) {
final PageState state = event.getPageState(); final PageState state = event.getPageState();
@ -96,6 +100,7 @@ public class AtoZProviderTable extends Table implements TableActionListener {
} }
} }
@Override
public void headSelected(final TableActionEvent event) { public void headSelected(final TableActionEvent event) {
//Nothing //Nothing
} }
@ -106,12 +111,12 @@ public class AtoZProviderTable extends Table implements TableActionListener {
super(); super();
} }
@Override
public TableModel makeModel(final Table table, public TableModel makeModel(final Table table,
final PageState state) { final PageState state) {
table.getRowSelectionModel().clearSelection(state); table.getRowSelectionModel().clearSelection(state);
return new AtoZTableModel(table); return new AtoZTableModel(table);
} }
} }
private class AtoZTableModel implements TableModel { private class AtoZTableModel implements TableModel {
@ -121,19 +126,26 @@ public class AtoZProviderTable extends Table implements TableActionListener {
public AtoZTableModel(final Table table) { public AtoZTableModel(final Table table) {
this.table = table; this.table = table;
final AtoZ atoz;
final AtoZ atoz = (AtoZ) Kernel.getContext().getResource(); if (parent == null) {
atoz = (AtoZ) Kernel.getContext().getResource();
} else {
atoz = (AtoZ) parent.getAppInstance();
}
providers = atoz.getProviders(); providers = atoz.getProviders();
} }
@Override
public int getColumnCount() { public int getColumnCount() {
return table.getColumnModel().size(); return table.getColumnModel().size();
} }
@Override
public boolean nextRow() { public boolean nextRow() {
return providers.next(); return providers.next();
} }
@Override
public Object getElementAt(final int columnIndex) { public Object getElementAt(final int columnIndex) {
switch (columnIndex) { switch (columnIndex) {
case 0: case 0:
@ -143,14 +155,17 @@ public class AtoZProviderTable extends Table implements TableActionListener {
case 2: case 2:
return ((AtoZProvider) providers.getDomainObject()).getObjectType().getName(); return ((AtoZProvider) providers.getDomainObject()).getObjectType().getName();
case 3: case 3:
return AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.edit").localize(); return AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.edit").
localize();
case 4: case 4:
return AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.delete").localize(); return AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.delete").
localize();
default: default:
return null; return null;
} }
} }
@Override
public Object getKeyAt(final int columnIndex) { public Object getKeyAt(final int columnIndex) {
return providers.getDomainObject().getOID(); return providers.getDomainObject().getOID();
} }
@ -163,6 +178,7 @@ public class AtoZProviderTable extends Table implements TableActionListener {
super(); super();
} }
@Override
public Component getComponent(final Table table, public Component getComponent(final Table table,
final PageState state, final PageState state,
final Object value, final Object value,
@ -188,6 +204,7 @@ public class AtoZProviderTable extends Table implements TableActionListener {
super(); super();
} }
@Override
public Component getComponent(final Table table, public Component getComponent(final Table table,
final PageState state, final PageState state,
final Object value, final Object value,
@ -198,7 +215,8 @@ public class AtoZProviderTable extends Table implements TableActionListener {
final ControlLink link = new ControlLink((String) AtoZGlobalizationUtil.globalize( final ControlLink link = new ControlLink((String) AtoZGlobalizationUtil.globalize(
"atoz.ui.providers_table.delete").localize()); "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()); localize());
return link; return link;

View File

@ -27,6 +27,7 @@ import com.arsdigita.bebop.SimpleComponent;
import com.arsdigita.categorization.Category; import com.arsdigita.categorization.Category;
import com.arsdigita.categorization.ui.CategoryPicker; import com.arsdigita.categorization.ui.CategoryPicker;
import com.arsdigita.kernel.ui.ACSObjectSelectionModel; import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
import com.arsdigita.util.Classes; import com.arsdigita.util.Classes;
/** /**
@ -39,7 +40,12 @@ public class CategoryProviderForm extends AbstractProviderForm {
private CategoryPicker rootCategory; private CategoryPicker rootCategory;
public CategoryProviderForm(final ACSObjectSelectionModel provider) { 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"); setMetaDataAttribute("title", "Category provider properties");
} }

View File

@ -37,6 +37,7 @@ import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.SessionManager;
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -52,7 +53,12 @@ public class ItemProviderForm extends AbstractProviderForm {
private TextField loadPaths; private TextField loadPaths;
public ItemProviderForm(final ACSObjectSelectionModel provider) { 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"); setMetaDataAttribute("title", "Item provider properties");
} }

View File

@ -38,6 +38,8 @@ import com.arsdigita.bebop.form.Submit;
import com.arsdigita.util.Classes; import com.arsdigita.util.Classes;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import java.util.Arrays;
import java.util.Comparator;
public class ProviderCreateForm extends Form { public class ProviderCreateForm extends Form {
@ -53,6 +55,11 @@ public class ProviderCreateForm extends Form {
m_providerType.addOption(new Option(null, "--Select one--")); m_providerType.addOption(new Option(null, "--Select one--"));
AtoZProviderType[] providers = AtoZ.getProviderTypes(); 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++) { for (int i = 0; i < providers.length; i++) {
m_providerType.addOption( m_providerType.addOption(
new Option(providers[i].getProvider().getName(), new Option(providers[i].getProvider().getName(),

View File

@ -34,6 +34,7 @@ import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
import com.arsdigita.persistence.OID; import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.SessionManager;
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
import java.util.TooManyListenersException; import java.util.TooManyListenersException;
@ -44,12 +45,19 @@ public class DomainProviderForm extends AbstractProviderForm {
private SingleSelect m_domain; private SingleSelect m_domain;
public DomainProviderForm(ACSObjectSelectionModel provider) {
this(provider, null);
}
/** /**
* Constructor * Constructor
*/ */
public DomainProviderForm(ACSObjectSelectionModel provider) { public DomainProviderForm(ACSObjectSelectionModel provider,
ApplicationInstanceAwareContainer parent) {
super("domainProvider", super("domainProvider",
DomainProvider.class, provider); DomainProvider.class,
provider,
parent);
setMetaDataAttribute("title", "Domain provider properties"); setMetaDataAttribute("title", "Domain provider properties");
} }