Verschiedene Änderungen am den AtoZ Modulen. Kompiliert, aber noch nicht weiter getestet
git-svn-id: https://svn.libreccm.org/ccm/trunk@2127 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
49f2735ec5
commit
6c2cb6e1d8
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
package com.arsdigita.atoz.siteproxy.ui.admin;
|
package com.arsdigita.atoz.siteproxy.ui.admin;
|
||||||
|
|
||||||
import com.arsdigita.atoz.ui.admin.ProviderForm;
|
import com.arsdigita.atoz.ui.admin.AbstractProviderForm;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.SimpleComponent;
|
import com.arsdigita.bebop.SimpleComponent;
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
|
@ -26,11 +26,10 @@ import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
||||||
import com.arsdigita.atoz.AtoZ;
|
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.atoz.ui.admin.ProviderForm;
|
|
||||||
import com.arsdigita.categorization.ui.CategoryPicker;
|
import com.arsdigita.categorization.ui.CategoryPicker;
|
||||||
import com.arsdigita.util.Classes;
|
import com.arsdigita.util.Classes;
|
||||||
|
|
||||||
public class SiteProxyProviderForm extends ProviderForm {
|
public class SiteProxyProviderForm extends AbstractProviderForm {
|
||||||
|
|
||||||
private CategoryPicker m_category_picker;
|
private CategoryPicker m_category_picker;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
package com.arsdigita.atoz;
|
package com.arsdigita.atoz;
|
||||||
|
|
||||||
|
|
||||||
import com.arsdigita.atoz.ui.admin.ProviderForm;
|
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;
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ public class AtoZProviderType {
|
||||||
"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(ProviderForm.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;
|
||||||
|
|
@ -81,8 +81,8 @@ public class AtoZProviderType {
|
||||||
return (AtoZProvider)Classes.newInstance(m_provider);
|
return (AtoZProvider)Classes.newInstance(m_provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProviderForm createProviderCreate(ACSObjectSelectionModel provider) {
|
public AbstractProviderForm createProviderCreate(ACSObjectSelectionModel provider) {
|
||||||
return (ProviderForm)Classes
|
return (AbstractProviderForm)Classes
|
||||||
.newInstance(m_providerCreate,
|
.newInstance(m_providerCreate,
|
||||||
new Class[] { ACSObjectSelectionModel.class },
|
new Class[] { ACSObjectSelectionModel.class },
|
||||||
new Object[] { provider });
|
new Object[] { provider });
|
||||||
|
|
|
||||||
|
|
@ -18,19 +18,15 @@
|
||||||
|
|
||||||
package com.arsdigita.atoz.ui;
|
package com.arsdigita.atoz.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.atoz.AtoZ;
|
||||||
|
import com.arsdigita.atoz.AtoZAtomicEntry;
|
||||||
|
import com.arsdigita.atoz.AtoZCompoundEntry;
|
||||||
|
import com.arsdigita.atoz.AtoZEntry;
|
||||||
|
import com.arsdigita.atoz.AtoZGenerator;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.SimpleContainer;
|
import com.arsdigita.bebop.SimpleContainer;
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
// import com.arsdigita.cms.dispatcher.SiteProxyPanel;
|
|
||||||
|
|
||||||
import com.arsdigita.kernel.Kernel;
|
import com.arsdigita.kernel.Kernel;
|
||||||
|
|
||||||
import com.arsdigita.atoz.AtoZ;
|
|
||||||
import com.arsdigita.atoz.AtoZEntry;
|
|
||||||
import com.arsdigita.atoz.AtoZAtomicEntry;
|
|
||||||
import com.arsdigita.atoz.AtoZCompoundEntry;
|
|
||||||
import com.arsdigita.atoz.AtoZGenerator;
|
|
||||||
|
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
|
|
||||||
public class AtoZPane extends SimpleContainer {
|
public class AtoZPane extends SimpleContainer {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,180 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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.ui.AtoZGlobalizationUtil;
|
||||||
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
|
import com.arsdigita.bebop.Form;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.SaveCancelSection;
|
||||||
|
import com.arsdigita.bebop.SimpleContainer;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.bebop.form.TextArea;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
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.util.Assert;
|
||||||
|
import com.arsdigita.util.Classes;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
public abstract class AbstractProviderForm extends Form {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(AbstractProviderForm.class);
|
||||||
|
private final ACSObjectSelectionModel providerModel;
|
||||||
|
private final Class providerType;
|
||||||
|
private TextField title;
|
||||||
|
private TextArea description;
|
||||||
|
private final SaveCancelSection buttons;
|
||||||
|
|
||||||
|
public AbstractProviderForm(final String name, final Class providerType, final ACSObjectSelectionModel provider) {
|
||||||
|
super(name, new ColumnPanel(2));
|
||||||
|
setRedirecting(true);
|
||||||
|
|
||||||
|
this.providerModel = provider;
|
||||||
|
this.providerType = providerType;
|
||||||
|
|
||||||
|
buttons = new SaveCancelSection(new SimpleContainer());
|
||||||
|
|
||||||
|
addWidgets();
|
||||||
|
add(buttons);
|
||||||
|
|
||||||
|
addProcessListener(new ProviderProcessListener());
|
||||||
|
addSubmissionListener(new ProviderSubmissionListener());
|
||||||
|
addInitListener(new ProviderInitListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addWidgets() {
|
||||||
|
|
||||||
|
title = new TextField("title");
|
||||||
|
//m_title.setMetaDataAttribute("label", "Title");
|
||||||
|
title.addValidationListener(new StringInRangeValidationListener(1, 200));
|
||||||
|
title.addValidationListener(new NotNullValidationListener());
|
||||||
|
title.setSize(80);
|
||||||
|
|
||||||
|
description = new TextArea("description");
|
||||||
|
//m_description.setMetaDataAttribute("label", "Description");
|
||||||
|
description.addValidationListener(
|
||||||
|
new StringInRangeValidationListener(1, 4000));
|
||||||
|
description.addValidationListener(new NotNullValidationListener());
|
||||||
|
description.setCols(80);
|
||||||
|
description.setRows(5);
|
||||||
|
|
||||||
|
add(new Label(AtoZGlobalizationUtil.globalize("atoz.ui.provider_title")));
|
||||||
|
add(title);
|
||||||
|
add(new Label(AtoZGlobalizationUtil.globalize("atoz.ui.provider_description")));
|
||||||
|
add(description);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void processWidgets(final PageState state, final AtoZProvider provider) {
|
||||||
|
provider.setTitle((String) title.getValue(state));
|
||||||
|
provider.setDescription((String) description.getValue(state));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initWidgets(final PageState state,
|
||||||
|
final AtoZProvider provider) {
|
||||||
|
if (provider != null) {
|
||||||
|
title.setValue(state, provider.getTitle());
|
||||||
|
description.setValue(state, provider.getDescription());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ProviderSubmissionListener implements FormSubmissionListener {
|
||||||
|
|
||||||
|
public ProviderSubmissionListener() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void submitted(final FormSectionEvent event) throws FormProcessException {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
if (buttons.getCancelButton().isSelected(state)) {
|
||||||
|
fireCompletionEvent(state);
|
||||||
|
throw new FormProcessException("cancel hit");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ProviderProcessListener implements FormProcessListener {
|
||||||
|
|
||||||
|
public ProviderProcessListener() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
Assert.exists(atoz, AtoZ.class);
|
||||||
|
provider = (AtoZProvider) Classes.newInstance(providerType);
|
||||||
|
atoz.addProvider(provider);
|
||||||
|
//provider.setAtoZ(atoz);
|
||||||
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
LOGGER.debug("Creating provider " + provider.getOID());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
LOGGER.debug("Loading provider " + provider.getOID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
processWidgets(state, provider);
|
||||||
|
|
||||||
|
fireCompletionEvent(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ProviderInitListener implements FormInitListener {
|
||||||
|
|
||||||
|
public ProviderInitListener() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
final AtoZProvider provider = (AtoZProvider) providerModel.getSelectedObject(state);
|
||||||
|
if (provider == null) {
|
||||||
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
LOGGER.debug("No provider available");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
LOGGER.debug("Loading provider " + provider.getOID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
initWidgets(state, provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -15,10 +15,8 @@
|
||||||
* 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.ui.admin;
|
package com.arsdigita.atoz.ui.admin;
|
||||||
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.SimpleContainer;
|
import com.arsdigita.bebop.SimpleContainer;
|
||||||
import com.arsdigita.bebop.Component;
|
import com.arsdigita.bebop.Component;
|
||||||
import com.arsdigita.bebop.Page;
|
import com.arsdigita.bebop.Page;
|
||||||
|
|
@ -43,14 +41,12 @@ import java.util.Iterator;
|
||||||
|
|
||||||
public class AdminPane extends SimpleContainer {
|
public class AdminPane extends SimpleContainer {
|
||||||
|
|
||||||
private static final String XMLNS =
|
private static final String XMLNS = "http://xmlns.redhat.com/atoz/1.0";
|
||||||
"http://xmlns.redhat.com/atoz/1.0";
|
|
||||||
|
|
||||||
private ACSObjectSelectionModel m_provider;
|
private ACSObjectSelectionModel m_provider;
|
||||||
|
|
||||||
private Map m_providerCreateMap;
|
private Map m_providerCreateMap;
|
||||||
private Map m_providerAdminMap;
|
private Map m_providerAdminMap;
|
||||||
private ProviderList m_providerList;
|
//private ProviderList m_providerList;
|
||||||
|
private AtoZProviderTable m_providerTable;
|
||||||
private ProviderCreateForm m_createForm;
|
private ProviderCreateForm m_createForm;
|
||||||
|
|
||||||
public AdminPane(BigDecimalParameter provider) {
|
public AdminPane(BigDecimalParameter provider) {
|
||||||
|
|
@ -59,8 +55,11 @@ public class AdminPane extends SimpleContainer {
|
||||||
m_provider = new ACSObjectSelectionModel(provider);
|
m_provider = new ACSObjectSelectionModel(provider);
|
||||||
m_provider.addChangeListener(new ProviderEditStart());
|
m_provider.addChangeListener(new ProviderEditStart());
|
||||||
|
|
||||||
m_providerList = new ProviderList(m_provider);
|
// m_providerList = new ProviderList(m_provider);
|
||||||
add(m_providerList);
|
// add(m_providerList);
|
||||||
|
|
||||||
|
m_providerTable = new AtoZProviderTable(m_provider);
|
||||||
|
add(m_providerTable);
|
||||||
|
|
||||||
m_createForm = new ProviderCreateForm();
|
m_createForm = new ProviderCreateForm();
|
||||||
m_createForm.addCompletionListener(new ProviderCreateComplete());
|
m_createForm.addCompletionListener(new ProviderCreateComplete());
|
||||||
|
|
@ -70,17 +69,15 @@ public class AdminPane extends SimpleContainer {
|
||||||
m_providerCreateMap = new HashMap();
|
m_providerCreateMap = new HashMap();
|
||||||
m_providerAdminMap = new HashMap();
|
m_providerAdminMap = new HashMap();
|
||||||
|
|
||||||
for (int i = 0 ; i < providers.length ; i++) {
|
for (int i = 0; i < providers.length; i++) {
|
||||||
ProviderAdmin admin = providers[i].createProviderAdmin(m_provider);
|
ProviderAdmin admin = providers[i].createProviderAdmin(m_provider);
|
||||||
admin.addCompletionListener(new ProviderAdminComplete(admin));
|
admin.addCompletionListener(new ProviderAdminComplete(admin));
|
||||||
m_providerAdminMap.put(providers[i].getProvider(),
|
m_providerAdminMap.put(providers[i].getProvider(), admin);
|
||||||
admin);
|
|
||||||
add(admin);
|
add(admin);
|
||||||
|
|
||||||
ProviderForm create = providers[i].createProviderCreate(m_provider);
|
AbstractProviderForm create = providers[i].createProviderCreate(m_provider);
|
||||||
create.addCompletionListener(new ProviderAdminComplete(create));
|
create.addCompletionListener(new ProviderAdminComplete(create));
|
||||||
m_providerCreateMap.put(providers[i].getProvider(),
|
m_providerCreateMap.put(providers[i].getProvider(), create);
|
||||||
create);
|
|
||||||
add(create);
|
add(create);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -91,55 +88,60 @@ public class AdminPane extends SimpleContainer {
|
||||||
|
|
||||||
Iterator providers = m_providerAdminMap.values().iterator();
|
Iterator providers = m_providerAdminMap.values().iterator();
|
||||||
while (providers.hasNext()) {
|
while (providers.hasNext()) {
|
||||||
ProviderAdmin admin = (ProviderAdmin)providers.next();
|
ProviderAdmin admin = (ProviderAdmin) providers.next();
|
||||||
p.setVisibleDefault(admin, false);
|
p.setVisibleDefault(admin, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
providers = m_providerCreateMap.values().iterator();
|
providers = m_providerCreateMap.values().iterator();
|
||||||
while (providers.hasNext()) {
|
while (providers.hasNext()) {
|
||||||
ProviderForm create = (ProviderForm)providers.next();
|
AbstractProviderForm create = (AbstractProviderForm) providers.next();
|
||||||
p.setVisibleDefault(create, false);
|
p.setVisibleDefault(create, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ProviderEditStart implements ChangeListener {
|
private class ProviderEditStart implements ChangeListener {
|
||||||
|
|
||||||
public void stateChanged(ChangeEvent e) {
|
public void stateChanged(ChangeEvent e) {
|
||||||
PageState state = e.getPageState();
|
PageState state = e.getPageState();
|
||||||
|
|
||||||
AtoZProvider provider = (AtoZProvider)
|
AtoZProvider provider = (AtoZProvider) m_provider.getSelectedObject(state);
|
||||||
m_provider.getSelectedObject(state);
|
|
||||||
|
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProviderAdmin admin = (ProviderAdmin)
|
ProviderAdmin admin = (ProviderAdmin) m_providerAdminMap.get(provider.getClass());
|
||||||
m_providerAdminMap.get(provider.getClass());
|
|
||||||
Assert.exists(admin, ProviderAdmin.class);
|
Assert.exists(admin, ProviderAdmin.class);
|
||||||
|
|
||||||
admin.setVisible(state, true);
|
admin.setVisible(state, true);
|
||||||
m_createForm.setVisible(state, false);
|
m_createForm.setVisible(state, false);
|
||||||
m_providerList.setVisible(state, false);
|
//m_providerList.setVisible(state, false);
|
||||||
|
m_providerTable.setVisible(state, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ProviderCreateComplete implements ActionListener {
|
private class ProviderCreateComplete implements ActionListener {
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
PageState state = e.getPageState();
|
PageState state = e.getPageState();
|
||||||
|
|
||||||
Class provider = m_createForm.getProviderType(state);
|
Class provider = m_createForm.getProviderType(state);
|
||||||
Assert.exists(provider, Class.class);
|
Assert.exists(provider, Class.class);
|
||||||
|
|
||||||
ProviderForm create = (ProviderForm)m_providerCreateMap.get(provider);
|
AbstractProviderForm create = (AbstractProviderForm) m_providerCreateMap.get(provider);
|
||||||
Assert.exists(create, ProviderForm.class);
|
Assert.exists(create, AbstractProviderForm.class);
|
||||||
|
|
||||||
create.setVisible(state, true);
|
create.setVisible(state, true);
|
||||||
m_createForm.setVisible(state, false);
|
m_createForm.setVisible(state, false);
|
||||||
m_providerList.setVisible(state, false);
|
//m_providerList.setVisible(state, false);
|
||||||
|
m_providerTable.setVisible(state, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ProviderAdminComplete implements ActionListener {
|
private class ProviderAdminComplete implements ActionListener {
|
||||||
|
|
||||||
private Component m_admin;
|
private Component m_admin;
|
||||||
|
|
||||||
public ProviderAdminComplete(Component admin) {
|
public ProviderAdminComplete(Component admin) {
|
||||||
|
|
@ -150,8 +152,10 @@ public class AdminPane extends SimpleContainer {
|
||||||
PageState state = e.getPageState();
|
PageState state = e.getPageState();
|
||||||
m_admin.setVisible(state, false);
|
m_admin.setVisible(state, false);
|
||||||
m_createForm.setVisible(state, true);
|
m_createForm.setVisible(state, true);
|
||||||
m_providerList.setVisible(state, true);
|
//m_providerList.setVisible(state, true);
|
||||||
|
m_providerTable.setVisible(state, true);
|
||||||
m_provider.clearSelection(state);
|
m_provider.clearSelection(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,33 +15,31 @@
|
||||||
* 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.ui.admin;
|
package com.arsdigita.atoz.ui.admin;
|
||||||
|
|
||||||
import com.arsdigita.atoz.AtoZ;
|
import com.arsdigita.atoz.AtoZ;
|
||||||
import com.arsdigita.atoz.AtoZProvider;
|
import com.arsdigita.atoz.AtoZProvider;
|
||||||
import com.arsdigita.atoz.CategoryProvider;
|
import com.arsdigita.atoz.CategoryProvider;
|
||||||
|
import com.arsdigita.atoz.ui.AtoZGlobalizationUtil;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.SimpleComponent;
|
import com.arsdigita.bebop.SimpleComponent;
|
||||||
import com.arsdigita.bebop.form.CheckboxGroup;
|
|
||||||
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.util.Classes;
|
import com.arsdigita.util.Classes;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CategoryProviderForm extends ProviderForm {
|
public class CategoryProviderForm extends AbstractProviderForm {
|
||||||
|
|
||||||
private CheckboxGroup m_compound;
|
//private CheckboxGroup m_compound;
|
||||||
private CategoryPicker m_rootCategory;
|
private CategoryPicker rootCategory;
|
||||||
|
|
||||||
public CategoryProviderForm(ACSObjectSelectionModel provider) {
|
public CategoryProviderForm(final ACSObjectSelectionModel provider) {
|
||||||
super("categoryProvider",
|
super("categoryProvider", CategoryProvider.class, provider);
|
||||||
CategoryProvider.class, provider);
|
|
||||||
|
|
||||||
setMetaDataAttribute("title", "Category provider properties");
|
setMetaDataAttribute("title", "Category provider properties");
|
||||||
}
|
}
|
||||||
|
|
@ -55,38 +53,38 @@ public class CategoryProviderForm extends ProviderForm {
|
||||||
//m_compound.addOption(new Option(Boolean.TRUE.toString(), "yes"));
|
//m_compound.addOption(new Option(Boolean.TRUE.toString(), "yes"));
|
||||||
//add(m_compound);
|
//add(m_compound);
|
||||||
|
|
||||||
m_rootCategory = (CategoryPicker)Classes.newInstance(
|
rootCategory = (CategoryPicker) Classes.newInstance(
|
||||||
AtoZ.getConfig().getRootCategoryPicker(),
|
AtoZ.getConfig().getRootCategoryPicker(),
|
||||||
new Class[] { String.class },
|
new Class[]{String.class},
|
||||||
new Object[] { "rootCategory" });
|
new Object[]{"rootCategory"});
|
||||||
((SimpleComponent)m_rootCategory).setMetaDataAttribute("label", "Root category");
|
((SimpleComponent) rootCategory).setMetaDataAttribute("label", "Root category");
|
||||||
add(m_rootCategory);
|
|
||||||
|
add(new Label(AtoZGlobalizationUtil.globalize("atoz.ui.category_picker.root_category")));
|
||||||
|
add(rootCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void processWidgets(PageState state,
|
protected void processWidgets(final PageState state, final AtoZProvider provider) {
|
||||||
AtoZProvider provider) {
|
|
||||||
super.processWidgets(state, provider);
|
super.processWidgets(state, provider);
|
||||||
|
|
||||||
CategoryProvider myprovider = (CategoryProvider)provider;
|
final CategoryProvider myprovider = (CategoryProvider) provider;
|
||||||
myprovider.setCompound(false);
|
myprovider.setCompound(false);
|
||||||
//myprovider.setCompound(Boolean.TRUE.equals(m_compound.getValue(state)));
|
//myprovider.setCompound(Boolean.TRUE.equals(m_compound.getValue(state)));
|
||||||
|
|
||||||
Category root = m_rootCategory.getCategory(state);
|
final Category root = rootCategory.getCategory(state);
|
||||||
myprovider.setRootCategory(root);
|
myprovider.setRootCategory(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initWidgets(PageState state,
|
protected void initWidgets(final PageState state, final AtoZProvider provider) {
|
||||||
AtoZProvider provider) {
|
|
||||||
super.initWidgets(state, provider);
|
super.initWidgets(state, provider);
|
||||||
|
|
||||||
CategoryProvider myprovider = (CategoryProvider)provider;
|
final CategoryProvider myprovider = (CategoryProvider) provider;
|
||||||
if (provider != null) {
|
if (provider != null) {
|
||||||
//m_compound.setValue(state, new Boolean(myprovider.isCompound()));
|
//m_compound.setValue(state, new Boolean(myprovider.isCompound()));
|
||||||
|
|
||||||
Category root = myprovider.getRootCategory();
|
final Category root = myprovider.getRootCategory();
|
||||||
m_rootCategory.setCategory(state, root);
|
rootCategory.setCategory(state, root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,11 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.atoz.ui.admin;
|
package com.arsdigita.atoz.ui.admin;
|
||||||
|
|
||||||
import com.arsdigita.atoz.ItemProvider;
|
|
||||||
import com.arsdigita.atoz.AtoZProvider;
|
import com.arsdigita.atoz.AtoZProvider;
|
||||||
|
import com.arsdigita.atoz.ItemProvider;
|
||||||
|
import com.arsdigita.atoz.ui.AtoZGlobalizationUtil;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.SimpleComponent;
|
|
||||||
import com.arsdigita.bebop.form.Option;
|
import com.arsdigita.bebop.form.Option;
|
||||||
import com.arsdigita.bebop.form.SingleSelect;
|
import com.arsdigita.bebop.form.SingleSelect;
|
||||||
import com.arsdigita.bebop.form.TextField;
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
|
@ -36,7 +37,6 @@ 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 java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -46,12 +46,12 @@ import java.util.TreeMap;
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ItemProviderForm extends ProviderForm {
|
public class ItemProviderForm extends AbstractProviderForm {
|
||||||
|
|
||||||
private CategoryPicker m_picker;
|
private CategoryPicker picker;
|
||||||
private TextField m_loadPaths;
|
private TextField loadPaths;
|
||||||
|
|
||||||
public ItemProviderForm(ACSObjectSelectionModel provider) {
|
public ItemProviderForm(final ACSObjectSelectionModel provider) {
|
||||||
super("itemProvider", ItemProvider.class, provider);
|
super("itemProvider", ItemProvider.class, provider);
|
||||||
|
|
||||||
setMetaDataAttribute("title", "Item provider properties");
|
setMetaDataAttribute("title", "Item provider properties");
|
||||||
|
|
@ -61,63 +61,65 @@ public class ItemProviderForm extends ProviderForm {
|
||||||
protected void addWidgets() {
|
protected void addWidgets() {
|
||||||
super.addWidgets();
|
super.addWidgets();
|
||||||
|
|
||||||
m_loadPaths = new TextField(ItemProvider.LOAD_PATHS);
|
loadPaths = new TextField(ItemProvider.LOAD_PATHS);
|
||||||
((SimpleComponent) m_loadPaths).setMetaDataAttribute("label", "Attributes to retrieve");
|
//((SimpleComponent) loadPaths).setMetaDataAttribute("label", "Attributes to retrieve");
|
||||||
add(m_loadPaths);
|
loadPaths.addValidationListener(new StringInRangeValidationListener(0, 200));
|
||||||
m_loadPaths.addValidationListener(new StringInRangeValidationListener(0, 200));
|
|
||||||
m_picker = new AllCategoryPicker("rootCategory");
|
picker = new AllCategoryPicker("rootCategory");
|
||||||
((SimpleComponent) m_picker).setMetaDataAttribute("label", "Category filter");
|
//((SimpleComponent) picker).setMetaDataAttribute("label", "Category filter");
|
||||||
((SingleSelect) m_picker).addValidationListener(new NotNullValidationListener());
|
((SingleSelect) picker).addValidationListener(new NotNullValidationListener());
|
||||||
add(m_picker);
|
|
||||||
|
add(new Label(AtoZGlobalizationUtil.globalize("atoz.ui.load_paths")));
|
||||||
|
add(loadPaths);
|
||||||
|
add(new Label(AtoZGlobalizationUtil.globalize("atoz.ui.category_filter")));
|
||||||
|
add(picker);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void processWidgets(PageState state,
|
protected void processWidgets(final PageState state, final AtoZProvider provider) {
|
||||||
AtoZProvider provider) {
|
|
||||||
super.processWidgets(state, provider);
|
super.processWidgets(state, provider);
|
||||||
|
|
||||||
ItemProvider myprovider = (ItemProvider) provider;
|
final ItemProvider myprovider = (ItemProvider) provider;
|
||||||
|
|
||||||
myprovider.setCategory(m_picker.getCategory(state));
|
myprovider.setCategory(picker.getCategory(state));
|
||||||
myprovider.setLoadPaths((String) m_loadPaths.getValue(state));
|
myprovider.setLoadPaths((String) loadPaths.getValue(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initWidgets(PageState state,
|
protected void initWidgets(final PageState state, final AtoZProvider provider) {
|
||||||
AtoZProvider provider) {
|
|
||||||
super.initWidgets(state, provider);
|
super.initWidgets(state, provider);
|
||||||
|
|
||||||
ItemProvider myprovider = (ItemProvider) provider;
|
final ItemProvider myprovider = (ItemProvider) provider;
|
||||||
if (provider != null) {
|
if (provider != null) {
|
||||||
//m_compound.setValue(state, new Boolean(myprovider.isCompound()));
|
//m_compound.setValue(state, new Boolean(myprovider.isCompound()));
|
||||||
|
|
||||||
m_picker.setCategory(state, myprovider.getCategory());
|
picker.setCategory(state, myprovider.getCategory());
|
||||||
m_loadPaths.setValue(state, myprovider.getLoadPaths());
|
loadPaths.setValue(state, myprovider.getLoadPaths());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class AllCategoryPicker extends AbstractCategoryPicker {
|
private class AllCategoryPicker extends AbstractCategoryPicker {
|
||||||
|
|
||||||
public AllCategoryPicker(String name) {
|
public AllCategoryPicker(final String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addOptions(PageState state,
|
protected void addOptions(final PageState state, final SingleSelect target) {
|
||||||
SingleSelect target) {
|
|
||||||
target.addOption(new Option(null, "-- pick one --"));
|
target.addOption(new Option(null, "-- pick one --"));
|
||||||
|
|
||||||
DataCollection domains = SessionManager.getSession().retrieve("com.arsdigita.london.terms.Domain");
|
final DataCollection domains = SessionManager.getSession().retrieve("com.arsdigita.london.terms.Domain");
|
||||||
domains.addPath("model.id");
|
domains.addPath("model.id");
|
||||||
domains.addPath("model.objectType");
|
domains.addPath("model.objectType");
|
||||||
domains.addOrder("title");
|
domains.addOrder("title");
|
||||||
while (domains.next()) {
|
while (domains.next()) {
|
||||||
Category rootCategory = (Category) DomainObjectFactory.newInstance((DataObject) domains.get("model"));
|
final Category rootCategory = (Category) DomainObjectFactory.newInstance((DataObject) domains.get(
|
||||||
|
"model"));
|
||||||
categorySubtreePath(target, rootCategory, " > ");
|
categorySubtreePath(target, rootCategory, " > ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void categorySubtreePath(SingleSelect target, Category root, String join) {
|
private void categorySubtreePath(final SingleSelect target, final Category root, final String join) {
|
||||||
DomainCollection cats = new DomainCollection(
|
final DomainCollection cats = new DomainCollection(
|
||||||
SessionManager.getSession().retrieve(Category.BASE_DATA_OBJECT_TYPE));
|
SessionManager.getSession().retrieve(Category.BASE_DATA_OBJECT_TYPE));
|
||||||
cats.addFilter("defaultAncestors like :ancestors")
|
cats.addFilter("defaultAncestors like :ancestors")
|
||||||
.set("ancestors",
|
.set("ancestors",
|
||||||
|
|
@ -127,8 +129,8 @@ public class ItemProviderForm extends ProviderForm {
|
||||||
cats.addOrder("defaultAncestors");
|
cats.addOrder("defaultAncestors");
|
||||||
cats.addPath("parents.id");
|
cats.addPath("parents.id");
|
||||||
|
|
||||||
Map path2cat = new TreeMap();
|
final Map path2cat = new TreeMap();
|
||||||
Map cat2path = new HashMap();
|
final Map cat2path = new HashMap();
|
||||||
|
|
||||||
path2cat.put(root.getName(), root);
|
path2cat.put(root.getName(), root);
|
||||||
cat2path.put(root.getID(), root.getName());
|
cat2path.put(root.getID(), root.getName());
|
||||||
|
|
@ -138,8 +140,8 @@ public class ItemProviderForm extends ProviderForm {
|
||||||
+ " +++++++++++++++++++++++++ "));
|
+ " +++++++++++++++++++++++++ "));
|
||||||
|
|
||||||
while (cats.next()) {
|
while (cats.next()) {
|
||||||
Category cat = (Category) cats.getDomainObject();
|
final Category cat = (Category) cats.getDomainObject();
|
||||||
BigDecimal parent = (BigDecimal) cats.get("parents.id");
|
final BigDecimal parent = (BigDecimal) cats.get("parents.id");
|
||||||
|
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
path2cat.put(cat.getName(), cat);
|
path2cat.put(cat.getName(), cat);
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,14 @@
|
||||||
* 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.ui.admin;
|
package com.arsdigita.atoz.ui.admin;
|
||||||
|
|
||||||
import com.arsdigita.atoz.AtoZ;
|
import com.arsdigita.atoz.AtoZ;
|
||||||
import com.arsdigita.atoz.AtoZProviderType;
|
import com.arsdigita.atoz.AtoZProviderType;
|
||||||
|
import com.arsdigita.atoz.ui.AtoZGlobalizationUtil;
|
||||||
|
|
||||||
import com.arsdigita.bebop.Form;
|
import com.arsdigita.bebop.Form;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.SimpleContainer;
|
import com.arsdigita.bebop.SimpleContainer;
|
||||||
|
|
||||||
|
|
@ -38,7 +39,6 @@ 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;
|
||||||
|
|
||||||
|
|
||||||
public class ProviderCreateForm extends Form {
|
public class ProviderCreateForm extends Form {
|
||||||
|
|
||||||
private OptionGroup m_providerType;
|
private OptionGroup m_providerType;
|
||||||
|
|
@ -53,22 +53,21 @@ 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();
|
||||||
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(),
|
||||||
providers[i].getTitle())
|
providers[i].getTitle()));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add(new Label(AtoZGlobalizationUtil.globalize("atoz.ui.create_provider")));
|
||||||
add(m_providerType);
|
add(m_providerType);
|
||||||
add(new Submit("create", "Create"));
|
add(new Submit("create", (String) AtoZGlobalizationUtil.globalize("atoz.ui.provider.create").localize()));
|
||||||
addProcessListener(new ProviderCreateProcess());
|
addProcessListener(new ProviderCreateProcess());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class getProviderType(PageState state) {
|
public Class getProviderType(PageState state) {
|
||||||
String providerName = (String)m_providerType.getValue(state);
|
String providerName = (String) m_providerType.getValue(state);
|
||||||
if (providerName != null &&
|
if (providerName != null && !"".equals(providerName)) {
|
||||||
!"".equals(providerName)) {
|
|
||||||
Class provider = Classes.loadClass(providerName);
|
Class provider = Classes.loadClass(providerName);
|
||||||
Assert.exists(provider, Class.class);
|
Assert.exists(provider, Class.class);
|
||||||
return provider;
|
return provider;
|
||||||
|
|
@ -77,6 +76,7 @@ public class ProviderCreateForm extends Form {
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ProviderCreateProcess implements FormProcessListener {
|
private class ProviderCreateProcess implements FormProcessListener {
|
||||||
|
|
||||||
public void process(FormSectionEvent e) {
|
public void process(FormSectionEvent e) {
|
||||||
PageState state = e.getPageState();
|
PageState state = e.getPageState();
|
||||||
|
|
||||||
|
|
@ -84,5 +84,6 @@ public class ProviderCreateForm extends Form {
|
||||||
fireCompletionEvent(state);
|
fireCompletionEvent(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,45 +15,85 @@
|
||||||
* 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.ui.admin;
|
package com.arsdigita.atoz.ui.admin;
|
||||||
|
|
||||||
import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
||||||
|
|
||||||
import com.arsdigita.atoz.AtoZ;
|
import com.arsdigita.atoz.AtoZ;
|
||||||
import com.arsdigita.atoz.AtoZProvider;
|
import com.arsdigita.atoz.AtoZProvider;
|
||||||
|
import com.arsdigita.atoz.ui.AtoZGlobalizationUtil;
|
||||||
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
|
||||||
import com.arsdigita.bebop.SimpleComponent;
|
import com.arsdigita.bebop.SimpleComponent;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.event.PrintEvent;
|
||||||
|
import com.arsdigita.bebop.event.PrintListener;
|
||||||
|
|
||||||
import com.arsdigita.domain.DomainObjectXMLRenderer;
|
import com.arsdigita.domain.DomainObjectXMLRenderer;
|
||||||
|
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
|
|
||||||
|
|
||||||
public class ProviderDetails extends SimpleComponent {
|
public class ProviderDetails extends SimpleComponent {
|
||||||
|
|
||||||
private ACSObjectSelectionModel m_provider;
|
private final ACSObjectSelectionModel m_provider;
|
||||||
|
private final ColumnPanel panel;
|
||||||
|
|
||||||
public ProviderDetails(ACSObjectSelectionModel provider) {
|
public ProviderDetails(final ACSObjectSelectionModel provider) {
|
||||||
m_provider = provider;
|
m_provider = provider;
|
||||||
|
|
||||||
|
panel = new ColumnPanel(2);
|
||||||
|
|
||||||
|
panel.add(new Label(AtoZGlobalizationUtil.globalize("atoz.ui.provider_details.title")));
|
||||||
|
final Label titleLabel = new Label();
|
||||||
|
titleLabel.addPrintListener(new PrintListener() {
|
||||||
|
public void prepare(final PrintEvent event) {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
final AtoZProvider provider = (AtoZProvider) m_provider.getSelectedObject(state);
|
||||||
|
|
||||||
|
final Label target = (Label) event.getTarget();
|
||||||
|
target.setLabel(provider.getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateXML(PageState state,
|
});
|
||||||
Element parent) {
|
panel.add(titleLabel);
|
||||||
Element content = AtoZ.newElement("providerDetails");
|
|
||||||
exportAttributes(content);
|
|
||||||
|
|
||||||
AtoZProvider provider = (AtoZProvider)
|
panel.add(new Label(AtoZGlobalizationUtil.globalize("atoz.ui.provider_details.description")));
|
||||||
m_provider.getSelectedObject(state);
|
final Label descLabel = new Label();
|
||||||
|
descLabel.addPrintListener(new PrintListener() {
|
||||||
|
public void prepare(final PrintEvent event) {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
DomainObjectXMLRenderer xr = new DomainObjectXMLRenderer(content);
|
final AtoZProvider provider = (AtoZProvider) m_provider.getSelectedObject(state);
|
||||||
xr.setWrapRoot(false);
|
|
||||||
xr.setWrapAttributes(true);
|
|
||||||
xr.setWrapObjects(false);
|
|
||||||
|
|
||||||
xr.walk(provider, ProviderDetails.class.getName());
|
final Label target = (Label) event.getTarget();
|
||||||
|
target.setLabel(provider.getDescription());
|
||||||
parent.addContent(content);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
panel.add(descLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generateXML(final PageState state, final Element parent) {
|
||||||
|
|
||||||
|
panel.generateXML(state, parent);
|
||||||
|
|
||||||
|
// Element content = AtoZ.newElement("providerDetails");
|
||||||
|
// exportAttributes(content);
|
||||||
|
//
|
||||||
|
// AtoZProvider provider = (AtoZProvider)
|
||||||
|
// m_provider.getSelectedObject(state);
|
||||||
|
//
|
||||||
|
// DomainObjectXMLRenderer xr = new DomainObjectXMLRenderer(content);
|
||||||
|
// xr.setWrapRoot(false);
|
||||||
|
// xr.setWrapAttributes(true);
|
||||||
|
// xr.setWrapObjects(false);
|
||||||
|
//
|
||||||
|
// xr.walk(provider, ProviderDetails.class.getName());
|
||||||
|
//
|
||||||
|
// parent.addContent(content);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,175 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* 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.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Form;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.SaveCancelSection;
|
|
||||||
import com.arsdigita.bebop.SimpleContainer;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.form.TextField;
|
|
||||||
import com.arsdigita.bebop.form.TextArea;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
|
||||||
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
|
|
||||||
import com.arsdigita.kernel.Kernel;
|
|
||||||
import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
|
||||||
|
|
||||||
import com.arsdigita.util.Classes;
|
|
||||||
import com.arsdigita.util.Assert;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
public abstract class ProviderForm extends Form {
|
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger(ProviderForm.class);
|
|
||||||
|
|
||||||
private ACSObjectSelectionModel m_provider;
|
|
||||||
private Class m_providerType;
|
|
||||||
|
|
||||||
private TextField m_title;
|
|
||||||
private TextArea m_description;
|
|
||||||
private SaveCancelSection m_buttons;
|
|
||||||
|
|
||||||
public ProviderForm(String name,
|
|
||||||
Class providerType,
|
|
||||||
ACSObjectSelectionModel provider) {
|
|
||||||
super(name, new SimpleContainer());
|
|
||||||
setRedirecting(true);
|
|
||||||
|
|
||||||
m_provider = provider;
|
|
||||||
m_providerType = providerType;
|
|
||||||
|
|
||||||
m_buttons = new SaveCancelSection(new SimpleContainer());
|
|
||||||
|
|
||||||
addWidgets();
|
|
||||||
add(m_buttons);
|
|
||||||
|
|
||||||
addProcessListener(new ProviderProcessListener());
|
|
||||||
addSubmissionListener(new ProviderSubmissionListener());
|
|
||||||
addInitListener(new ProviderInitListener());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected void addWidgets() {
|
|
||||||
m_title = new TextField("title");
|
|
||||||
m_title.setMetaDataAttribute("label", "Title");
|
|
||||||
m_title.addValidationListener(new StringInRangeValidationListener(1, 200));
|
|
||||||
m_title.addValidationListener(new NotNullValidationListener());
|
|
||||||
m_title.setSize(80);
|
|
||||||
|
|
||||||
m_description = new TextArea("description");
|
|
||||||
m_description.setMetaDataAttribute("label", "Description");
|
|
||||||
m_description.addValidationListener(
|
|
||||||
new StringInRangeValidationListener(1, 4000));
|
|
||||||
m_description.addValidationListener(new NotNullValidationListener());
|
|
||||||
m_description.setCols(80);
|
|
||||||
m_description.setRows(5);
|
|
||||||
|
|
||||||
add(m_title);
|
|
||||||
add(m_description);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void processWidgets(PageState state,
|
|
||||||
AtoZProvider provider) {
|
|
||||||
provider.setTitle((String)m_title.getValue(state));
|
|
||||||
provider.setDescription((String)m_description.getValue(state));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void initWidgets(PageState state,
|
|
||||||
AtoZProvider provider) {
|
|
||||||
if (provider != null) {
|
|
||||||
m_title.setValue(state, provider.getTitle());
|
|
||||||
m_description.setValue(state, provider.getDescription());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ProviderSubmissionListener implements FormSubmissionListener {
|
|
||||||
public void submitted(FormSectionEvent e)
|
|
||||||
throws FormProcessException {
|
|
||||||
PageState state = e.getPageState();
|
|
||||||
|
|
||||||
if (m_buttons.getCancelButton().isSelected(state)) {
|
|
||||||
fireCompletionEvent(state);
|
|
||||||
throw new FormProcessException("cancel hit");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ProviderProcessListener implements FormProcessListener {
|
|
||||||
public void process(FormSectionEvent e)
|
|
||||||
throws FormProcessException {
|
|
||||||
PageState state = e.getPageState();
|
|
||||||
|
|
||||||
AtoZProvider provider = (AtoZProvider)m_provider
|
|
||||||
.getSelectedObject(state);
|
|
||||||
|
|
||||||
if (provider == null) {
|
|
||||||
AtoZ atoz = (AtoZ)Kernel.getContext().getResource();
|
|
||||||
Assert.exists(atoz, AtoZ.class);
|
|
||||||
provider = (AtoZProvider)Classes.newInstance(m_providerType);
|
|
||||||
atoz.addProvider(provider);
|
|
||||||
//provider.setAtoZ(atoz);
|
|
||||||
if (s_log.isDebugEnabled()) {
|
|
||||||
s_log.debug("Creating provider " + provider.getOID());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (s_log.isDebugEnabled()) {
|
|
||||||
s_log.debug("Loading provider " + provider.getOID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
processWidgets(state,
|
|
||||||
provider);
|
|
||||||
|
|
||||||
fireCompletionEvent(state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ProviderInitListener implements FormInitListener {
|
|
||||||
public void init(FormSectionEvent e)
|
|
||||||
throws FormProcessException {
|
|
||||||
PageState state = e.getPageState();
|
|
||||||
|
|
||||||
AtoZProvider provider = (AtoZProvider)m_provider
|
|
||||||
.getSelectedObject(state);
|
|
||||||
if (provider != null) {
|
|
||||||
if (s_log.isDebugEnabled()) {
|
|
||||||
s_log.debug("Loading provider " + provider.getOID());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (s_log.isDebugEnabled()) {
|
|
||||||
s_log.debug("No provider available");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
initWidgets(state,provider);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
package com.arsdigita.london.atoz.ui;
|
package com.arsdigita.london.atoz.ui;
|
||||||
|
|
||||||
import com.arsdigita.atoz.AtoZProvider;
|
import com.arsdigita.atoz.AtoZProvider;
|
||||||
import com.arsdigita.atoz.ui.admin.ProviderForm;
|
import com.arsdigita.atoz.ui.admin.AbstractProviderForm;
|
||||||
import com.arsdigita.london.atoz.DomainProvider;
|
import com.arsdigita.london.atoz.DomainProvider;
|
||||||
import com.arsdigita.london.terms.Domain;
|
import com.arsdigita.london.terms.Domain;
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ import java.util.TooManyListenersException;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DomainProviderForm extends ProviderForm {
|
public class DomainProviderForm extends AbstractProviderForm {
|
||||||
|
|
||||||
private SingleSelect m_domain;
|
private SingleSelect m_domain;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue