PublicPersonalProfile: Verwaltungsoberfläche für mögliche Navigationspunkte (noch nicht fertiggestellt!)
git-svn-id: https://svn.libreccm.org/ccm/trunk@1064 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
618ff041d4
commit
5a9c50928f
|
|
@ -29,7 +29,7 @@ association {
|
||||||
|
|
||||||
object type PublicPersonalProfileNavItem {
|
object type PublicPersonalProfileNavItem {
|
||||||
|
|
||||||
BigDecimal[1..1] id = ct_public_personal_profile_nav_items.object_id INTEGER;
|
BigDecimal[1..1] navItemId = ct_public_personal_profile_nav_items.object_id INTEGER;
|
||||||
String[0..1] key = ct_public_personal_profile_nav_items.key VARCHAR(128);
|
String[0..1] key = ct_public_personal_profile_nav_items.key VARCHAR(128);
|
||||||
String[0..1] lang = ct_public_personal_profile_nav_items.lang VARCHAR(2);
|
String[0..1] lang = ct_public_personal_profile_nav_items.lang VARCHAR(2);
|
||||||
String[0..1] label = ct_public_personal_profile_nav_items.label VARCHAR(128);
|
String[0..1] label = ct_public_personal_profile_nav_items.label VARCHAR(128);
|
||||||
|
|
@ -37,5 +37,7 @@ object type PublicPersonalProfileNavItem {
|
||||||
String[0..1] generatorClass = ct_public_personal_profile_nav_items.generator_class VARCHAR(1024);
|
String[0..1] generatorClass = ct_public_personal_profile_nav_items.generator_class VARCHAR(1024);
|
||||||
|
|
||||||
unique(key, lang, label);
|
unique(key, lang, label);
|
||||||
object key (id);
|
object key (navItemId);
|
||||||
|
//reference key ( ct_public_personal_profile_nav_items.id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import java.math.BigDecimal;
|
||||||
*/
|
*/
|
||||||
public class PublicPersonalProfileNavItem extends DomainObject {
|
public class PublicPersonalProfileNavItem extends DomainObject {
|
||||||
|
|
||||||
public static final String ID = "id";
|
public static final String ID = "navItemId";
|
||||||
public static final String KEY = "key";
|
public static final String KEY = "key";
|
||||||
public static final String LANG = "lang";
|
public static final String LANG = "lang";
|
||||||
public static final String LABEL = "label";
|
public static final String LABEL = "label";
|
||||||
|
|
@ -64,6 +64,10 @@ public class PublicPersonalProfileNavItem extends DomainObject {
|
||||||
return(BigDecimal) get(ID);
|
return(BigDecimal) get(ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void setId(final BigDecimal id) {
|
||||||
|
set(ID, id);
|
||||||
|
}
|
||||||
|
|
||||||
public final String getKey() {
|
public final String getKey() {
|
||||||
return (String) get(KEY);
|
return (String) get(KEY);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,12 @@
|
||||||
package com.arsdigita.cms.contenttypes;
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.PublicPersonalProfileNavItem;
|
||||||
import com.arsdigita.domain.DomainCollection;
|
import com.arsdigita.domain.DomainCollection;
|
||||||
import com.arsdigita.persistence.DataCollection;
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.persistence.Filter;
|
import com.arsdigita.persistence.Filter;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -16,12 +19,15 @@ public class PublicPersonalProfileNavItemCollection extends DomainCollection {
|
||||||
private Filter languageFilter = null;
|
private Filter languageFilter = null;
|
||||||
|
|
||||||
public PublicPersonalProfileNavItemCollection() {
|
public PublicPersonalProfileNavItemCollection() {
|
||||||
super(SessionManager.getSession().retrieve(PublicPersonalProfileNavItem.BASE_DATA_OBJECT_TYPE));
|
this(SessionManager.getSession().retrieve(
|
||||||
|
PublicPersonalProfileNavItem.BASE_DATA_OBJECT_TYPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public PublicPersonalProfileNavItemCollection(
|
public PublicPersonalProfileNavItemCollection(
|
||||||
final DataCollection dataCollection) {
|
final DataCollection dataCollection) {
|
||||||
super(dataCollection);
|
super(dataCollection);
|
||||||
|
|
||||||
|
addOrder("navItemOrder, key, lang");
|
||||||
}
|
}
|
||||||
|
|
||||||
public PublicPersonalProfileNavItem getNavItem() {
|
public PublicPersonalProfileNavItem getNavItem() {
|
||||||
|
|
@ -30,7 +36,7 @@ public class PublicPersonalProfileNavItemCollection extends DomainCollection {
|
||||||
|
|
||||||
public final void addKeyFilter(final String key) {
|
public final void addKeyFilter(final String key) {
|
||||||
keyFilter = this.addEqualsFilter(PublicPersonalProfileNavItem.KEY,
|
keyFilter = this.addEqualsFilter(PublicPersonalProfileNavItem.KEY,
|
||||||
key);
|
key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeKeyFilter(final String key) {
|
public boolean removeKeyFilter(final String key) {
|
||||||
|
|
@ -45,7 +51,7 @@ public class PublicPersonalProfileNavItemCollection extends DomainCollection {
|
||||||
|
|
||||||
public final void addLanguageFilter(final String language) {
|
public final void addLanguageFilter(final String language) {
|
||||||
languageFilter = this.addEqualsFilter(PublicPersonalProfileNavItem.LANG,
|
languageFilter = this.addEqualsFilter(PublicPersonalProfileNavItem.LANG,
|
||||||
language);
|
language);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeLanguageFilter(final String language) {
|
public boolean removeLanguageFilter(final String language) {
|
||||||
|
|
@ -80,13 +86,15 @@ public class PublicPersonalProfileNavItemCollection extends DomainCollection {
|
||||||
|
|
||||||
public PublicPersonalProfileNavItem getNavItem(final String key,
|
public PublicPersonalProfileNavItem getNavItem(final String key,
|
||||||
final String language) {
|
final String language) {
|
||||||
if (!(this.isBeforeFirst()) && key.equals(this.getKey()) && language.equals(this.getLanguage())) {
|
if (!(this.isBeforeFirst()) && key.equals(this.getKey()) && language.
|
||||||
|
equals(this.getLanguage())) {
|
||||||
return this.getNavItem();
|
return this.getNavItem();
|
||||||
} else {
|
} else {
|
||||||
this.rewind();
|
this.rewind();
|
||||||
|
|
||||||
while(this.next()) {
|
while (this.next()) {
|
||||||
if ( key.equals(this.getKey()) && language.equals(this.getLanguage())) {
|
if (key.equals(this.getKey()) && language.equals(this.
|
||||||
|
getLanguage())) {
|
||||||
return this.getNavItem();
|
return this.getNavItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -95,4 +103,81 @@ public class PublicPersonalProfileNavItemCollection extends DomainCollection {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void swapWithNext(final PublicPersonalProfileNavItem navItem) {
|
||||||
|
final int order1 = navItem.getOrder();
|
||||||
|
final int order2 = order1 + 1;
|
||||||
|
|
||||||
|
final PublicPersonalProfileNavItemCollection navItems1 =
|
||||||
|
new PublicPersonalProfileNavItemCollection();
|
||||||
|
navItems1.addFilter(String.format("navItemOrder = %d", order1));
|
||||||
|
|
||||||
|
final PublicPersonalProfileNavItemCollection navItems2 =
|
||||||
|
new PublicPersonalProfileNavItemCollection();
|
||||||
|
navItems2.addFilter(String.format("navItemOrder = %d", order2));
|
||||||
|
|
||||||
|
final List<PublicPersonalProfileNavItem> navItemsList1 =
|
||||||
|
new ArrayList<PublicPersonalProfileNavItem>();
|
||||||
|
final List<PublicPersonalProfileNavItem> navItemsList2 =
|
||||||
|
new ArrayList<PublicPersonalProfileNavItem>();
|
||||||
|
|
||||||
|
while (navItems1.next()) {
|
||||||
|
navItemsList1.add(navItems1.getNavItem());
|
||||||
|
}
|
||||||
|
navItems1.rewind();
|
||||||
|
|
||||||
|
while (navItems2.next()) {
|
||||||
|
navItemsList2.add(navItems2.getNavItem());
|
||||||
|
}
|
||||||
|
navItems2.rewind();
|
||||||
|
|
||||||
|
navItems1.close();
|
||||||
|
navItems2.close();
|
||||||
|
|
||||||
|
for (PublicPersonalProfileNavItem item : navItemsList1) {
|
||||||
|
item.setOrder(order2);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (PublicPersonalProfileNavItem item : navItemsList2) {
|
||||||
|
item.setOrder(order1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void swapWithPrevious(final PublicPersonalProfileNavItem navItem) {
|
||||||
|
final int order1 = navItem.getOrder();
|
||||||
|
final int order2 = order1 - 1;
|
||||||
|
|
||||||
|
final PublicPersonalProfileNavItemCollection navItems1 =
|
||||||
|
new PublicPersonalProfileNavItemCollection();
|
||||||
|
navItems1.addFilter(String.format("navItemOrder = %d", order1));
|
||||||
|
|
||||||
|
final PublicPersonalProfileNavItemCollection navItems2 =
|
||||||
|
new PublicPersonalProfileNavItemCollection();
|
||||||
|
navItems2.addFilter(String.format("navItemOrder = %d", order2));
|
||||||
|
|
||||||
|
final List<PublicPersonalProfileNavItem> navItemsList1 =
|
||||||
|
new ArrayList<PublicPersonalProfileNavItem>();
|
||||||
|
final List<PublicPersonalProfileNavItem> navItemsList2 =
|
||||||
|
new ArrayList<PublicPersonalProfileNavItem>();
|
||||||
|
|
||||||
|
while (navItems1.next()) {
|
||||||
|
navItemsList1.add(navItems1.getNavItem());
|
||||||
|
}
|
||||||
|
navItems1.rewind();
|
||||||
|
|
||||||
|
while (navItems2.next()) {
|
||||||
|
navItemsList2.add(navItems2.getNavItem());
|
||||||
|
}
|
||||||
|
navItems2.rewind();
|
||||||
|
|
||||||
|
navItems1.close();
|
||||||
|
navItems2.close();
|
||||||
|
|
||||||
|
for (PublicPersonalProfileNavItem item : navItemsList1) {
|
||||||
|
item.setOrder(order2);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (PublicPersonalProfileNavItem item : navItemsList2) {
|
||||||
|
item.setOrder(order1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ import com.arsdigita.dispatcher.DispatcherHelper;
|
||||||
import com.arsdigita.persistence.DataCollection;
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.util.LockableImpl;
|
import com.arsdigita.util.LockableImpl;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -131,17 +130,11 @@ public class PublicPersonalProfileNavigationTable
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColumnCount() {
|
public int getColumnCount() {
|
||||||
return mockNav.length;
|
return table.getColumnModel().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean nextRow() {
|
public boolean nextRow() {
|
||||||
/*if (index < (mockNav.length - 1)) {
|
|
||||||
index++;
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}*/
|
|
||||||
return linkCollection.next();
|
return linkCollection.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,3 +7,11 @@ publicpersonalprofile.ui.nav.remove=Remove
|
||||||
publicpersonalprofile.ui.profile_properties.title=Basic properties
|
publicpersonalprofile.ui.profile_properties.title=Basic properties
|
||||||
publicpersonalprofile.ui.profile_nav.title=Navigation
|
publicpersonalprofile.ui.profile_nav.title=Navigation
|
||||||
publicpersonalprofile.ui.profile.nav_add=Add item
|
publicpersonalprofile.ui.profile.nav_add=Add item
|
||||||
|
publicpersonalprofile.ui.navitem.key=Key
|
||||||
|
publicpersonalprofile.ui.navitem.lang=Language
|
||||||
|
publicpersonalprofile.ui.navitem.label=Label
|
||||||
|
publicpersonalprofile.ui.navitem.generatorclass=Generator
|
||||||
|
publicpersonalprofile.ui.navitem.edit=Edit
|
||||||
|
publicpersonalprofile.ui.navitem.delete=Delete
|
||||||
|
publicpersonalprofile.ui.navitem.up=Up
|
||||||
|
publicpersonalprofile.ui.navitem.down=Down
|
||||||
|
|
|
||||||
|
|
@ -7,3 +7,11 @@ publicpersonalprofile.ui.nav.remove=Entfernen
|
||||||
publicpersonalprofile.ui.profile_properties.title=Basiseigenschaften
|
publicpersonalprofile.ui.profile_properties.title=Basiseigenschaften
|
||||||
publicpersonalprofile.ui.profile_nav.title=Navigation
|
publicpersonalprofile.ui.profile_nav.title=Navigation
|
||||||
publicpersonalprofile.ui.profile.nav_add=Navigationspunkt hinzuf\u00fcgen
|
publicpersonalprofile.ui.profile.nav_add=Navigationspunkt hinzuf\u00fcgen
|
||||||
|
publicpersonalprofile.ui.navitem.key=Key
|
||||||
|
publicpersonalprofile.ui.navitem.lang=Sprache
|
||||||
|
publicpersonalprofile.ui.navitem.label=Bezeichnung
|
||||||
|
publicpersonalprofile.ui.navitem.generatorclass=Generator
|
||||||
|
publicpersonalprofile.ui.navitem.edit=Bearbeiten
|
||||||
|
publicpersonalprofile.ui.navitem.delete=L\u00f6schen
|
||||||
|
publicpersonalprofile.ui.navitem.up=Hoch
|
||||||
|
publicpersonalprofile.ui.navitem.down=Runter
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,19 @@
|
||||||
package com.arsdigita.cms.publicpersonalprofile;
|
package com.arsdigita.cms.publicpersonalprofile;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.publicpersonalprofile.ui.PublicPersonalProfileNavItemsTable;
|
||||||
|
import com.arsdigita.bebop.BoxPanel;
|
||||||
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
|
import com.arsdigita.bebop.Form;
|
||||||
|
import com.arsdigita.bebop.FormSection;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
import com.arsdigita.bebop.Page;
|
import com.arsdigita.bebop.Page;
|
||||||
import com.arsdigita.bebop.PageFactory;
|
import com.arsdigita.bebop.PageFactory;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.Table;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.bebop.table.TableColumn;
|
||||||
|
import com.arsdigita.bebop.table.TableColumnModel;
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
import com.arsdigita.cms.contentassets.RelatedLink;
|
import com.arsdigita.cms.contentassets.RelatedLink;
|
||||||
import com.arsdigita.cms.contenttypes.GenericAddress;
|
import com.arsdigita.cms.contenttypes.GenericAddress;
|
||||||
|
|
@ -15,8 +26,9 @@ import com.arsdigita.cms.contenttypes.Link;
|
||||||
import com.arsdigita.cms.contenttypes.PublicPersonalProfile;
|
import com.arsdigita.cms.contenttypes.PublicPersonalProfile;
|
||||||
import com.arsdigita.cms.contenttypes.PublicPersonalProfileNavItem;
|
import com.arsdigita.cms.contenttypes.PublicPersonalProfileNavItem;
|
||||||
import com.arsdigita.cms.contenttypes.PublicPersonalProfileNavItemCollection;
|
import com.arsdigita.cms.contenttypes.PublicPersonalProfileNavItemCollection;
|
||||||
|
import com.arsdigita.cms.contenttypes.ui.PublicPersonalProfileGlobalizationUtil;
|
||||||
|
import com.arsdigita.cms.publicpersonalprofile.ui.PublicPersonalProfileNavItemsAddForm;
|
||||||
import com.arsdigita.dispatcher.DispatcherHelper;
|
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||||
import com.arsdigita.domain.DomainObject;
|
|
||||||
import com.arsdigita.domain.DomainObjectFactory;
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
import com.arsdigita.persistence.DataCollection;
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.persistence.DataObject;
|
import com.arsdigita.persistence.DataObject;
|
||||||
|
|
@ -24,6 +36,7 @@ import com.arsdigita.persistence.Session;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
import com.arsdigita.templating.PresentationManager;
|
import com.arsdigita.templating.PresentationManager;
|
||||||
import com.arsdigita.templating.Templating;
|
import com.arsdigita.templating.Templating;
|
||||||
|
import com.arsdigita.toolbox.ui.ApplicationAuthenticationListener;
|
||||||
import com.arsdigita.web.Application;
|
import com.arsdigita.web.Application;
|
||||||
import com.arsdigita.web.BaseApplicationServlet;
|
import com.arsdigita.web.BaseApplicationServlet;
|
||||||
import com.arsdigita.xml.Document;
|
import com.arsdigita.xml.Document;
|
||||||
|
|
@ -48,6 +61,7 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
||||||
private static final Logger logger =
|
private static final Logger logger =
|
||||||
Logger.getLogger(
|
Logger.getLogger(
|
||||||
PublicPersonalProfilesServlet.class);
|
PublicPersonalProfilesServlet.class);
|
||||||
|
private static final String ADMIN = "admin";
|
||||||
private static final String PREVIEW = "preview";
|
private static final String PREVIEW = "preview";
|
||||||
private static final String PPP_NS =
|
private static final String PPP_NS =
|
||||||
"http://www.arsdigita.com/PublicPersonalProfile/1.0";
|
"http://www.arsdigita.com/PublicPersonalProfile/1.0";
|
||||||
|
|
@ -99,126 +113,119 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
||||||
String navPath = null;
|
String navPath = null;
|
||||||
|
|
||||||
Page page;
|
Page page;
|
||||||
/*Form form;
|
|
||||||
Label label;*/
|
|
||||||
|
|
||||||
page = PageFactory.buildPage("PublicPersonalProfile",
|
page = PageFactory.buildPage("PublicPersonalProfile",
|
||||||
"");
|
"");
|
||||||
/*form = new Form("HelloWorld");*/
|
|
||||||
|
|
||||||
if (pathTokens.length < 1) {
|
if (pathTokens.length < 1) {
|
||||||
//ToDo: Fehlerbehandlung?
|
//ToDo: Fehlerbehandlung?
|
||||||
} else {
|
} else {
|
||||||
if ((pathTokens.length > 1)
|
if (ADMIN.equals(pathTokens[0])) {
|
||||||
&& PREVIEW.equals(pathTokens[0])) {
|
showAdminPage(page, request, response);
|
||||||
preview = true;
|
return;
|
||||||
profileOwner = pathTokens[1];
|
|
||||||
if (pathTokens.length > 2) {
|
|
||||||
navPath = pathTokens[2];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
profileOwner = pathTokens[0];
|
|
||||||
if (pathTokens.length > 1) {
|
|
||||||
navPath = pathTokens[1];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*form.add(new Label(String.format("Member: %s", member)));
|
if (pathTokens.length > 1) {
|
||||||
|
if (PREVIEW.equals(pathTokens[0])) {
|
||||||
if (pathTokens.length > 1) {
|
preview = true;
|
||||||
for(int i = 1; i < pathTokens.length; i++) {
|
profileOwner = pathTokens[1];
|
||||||
form.add(new Label(String.format("%d: %s", i, pathTokens[i])));
|
if (pathTokens.length > 2) {
|
||||||
}
|
navPath = pathTokens[2];
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
label = new Label(String.format(
|
profileOwner = pathTokens[0];
|
||||||
"Hello World! From profiles, path = %s", path));
|
if (pathTokens.length > 1) {
|
||||||
|
navPath = pathTokens[1];
|
||||||
form.add(label);
|
|
||||||
page.add(form);*/
|
|
||||||
|
|
||||||
page.lock();
|
|
||||||
|
|
||||||
Document document = page.buildDocument(request, response);
|
|
||||||
Element root = document.getRootElement();
|
|
||||||
//Element test = root.newChildElement("test");
|
|
||||||
//test.setText("test");
|
|
||||||
|
|
||||||
final Session session = SessionManager.getSession();
|
|
||||||
|
|
||||||
DataCollection profiles =
|
|
||||||
session.retrieve(
|
|
||||||
com.arsdigita.cms.contenttypes.PublicPersonalProfile.BASE_DATA_OBJECT_TYPE);
|
|
||||||
profiles.addFilter(String.format("profileUrl = '%s'", profileOwner));
|
|
||||||
if (preview) {
|
|
||||||
profiles.addFilter(String.format("version = '%s'",
|
|
||||||
ContentItem.DRAFT));
|
|
||||||
} else {
|
|
||||||
profiles.addFilter(String.format("version = '%s'",
|
|
||||||
ContentItem.LIVE));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (profiles.size() == 0) {
|
|
||||||
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
|
||||||
return;
|
|
||||||
} else if (profiles.size() > 1) {
|
|
||||||
throw new IllegalStateException(
|
|
||||||
"More than one matching members found...");
|
|
||||||
} else {
|
|
||||||
final PageState state = new PageState(page, request, response);
|
|
||||||
|
|
||||||
profiles.next();
|
|
||||||
PublicPersonalProfile profile =
|
|
||||||
(PublicPersonalProfile) DomainObjectFactory.
|
|
||||||
newInstance(profiles.getDataObject());
|
|
||||||
Element profileElem =
|
|
||||||
root.newChildElement("ppp:profile", PPP_NS);
|
|
||||||
GenericPerson owner = profile.getOwner();
|
|
||||||
if (owner == null) {
|
|
||||||
throw new IllegalStateException(
|
|
||||||
"Failed to get owner of profile.");
|
|
||||||
}
|
|
||||||
Element profileOwnerName = profileElem.newChildElement(
|
|
||||||
"ppp:ownerName", PPP_NS);
|
|
||||||
profileOwnerName.setText(owner.getFullName());
|
|
||||||
|
|
||||||
createNavigation(profile, root, navPath);
|
|
||||||
|
|
||||||
if (navPath == null) {
|
|
||||||
generateProfileOwnerXml(profileElem, owner, state);
|
|
||||||
} else {
|
|
||||||
final DataCollection links =
|
|
||||||
RelatedLink.getRelatedLinks(profile,
|
|
||||||
PublicPersonalProfile.LINK_LIST_NAME);
|
|
||||||
links.addFilter(String.format("linkTitle = '%s'", navPath));
|
|
||||||
|
|
||||||
if (links.size() == 0) {
|
|
||||||
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
if (config.getShowPersonInfoEverywhere()) {
|
|
||||||
generateProfileOwnerXml(profileElem, owner, state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
links.next();
|
|
||||||
final RelatedLink link =
|
|
||||||
(RelatedLink) DomainObjectFactory.
|
|
||||||
newInstance(links.getDataObject());
|
|
||||||
final ContentItem item = link.getTargetItem();
|
|
||||||
final PublicPersonalProfileXmlGenerator generator =
|
|
||||||
new PublicPersonalProfileXmlGenerator(
|
|
||||||
item);
|
|
||||||
generator.generateXML(new PageState(page, request,
|
|
||||||
response),
|
|
||||||
root, "");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
page.lock();
|
||||||
|
|
||||||
|
Document document = page.buildDocument(request, response);
|
||||||
|
Element root = document.getRootElement();
|
||||||
|
|
||||||
|
final Session session = SessionManager.getSession();
|
||||||
|
|
||||||
|
DataCollection profiles =
|
||||||
|
session.retrieve(
|
||||||
|
com.arsdigita.cms.contenttypes.PublicPersonalProfile.BASE_DATA_OBJECT_TYPE);
|
||||||
|
profiles.addFilter(String.format("profileUrl = '%s'",
|
||||||
|
profileOwner));
|
||||||
|
if (preview) {
|
||||||
|
profiles.addFilter(String.format("version = '%s'",
|
||||||
|
ContentItem.DRAFT));
|
||||||
|
} else {
|
||||||
|
profiles.addFilter(String.format("version = '%s'",
|
||||||
|
ContentItem.LIVE));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (profiles.size() == 0) {
|
||||||
|
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||||
|
return;
|
||||||
|
} else if (profiles.size() > 1) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"More than one matching members found...");
|
||||||
|
} else {
|
||||||
|
final PageState state = new PageState(page, request,
|
||||||
|
response);
|
||||||
|
|
||||||
|
profiles.next();
|
||||||
|
PublicPersonalProfile profile =
|
||||||
|
(PublicPersonalProfile) DomainObjectFactory.
|
||||||
|
newInstance(profiles.getDataObject());
|
||||||
|
Element profileElem =
|
||||||
|
root.newChildElement("ppp:profile", PPP_NS);
|
||||||
|
GenericPerson owner = profile.getOwner();
|
||||||
|
if (owner == null) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"Failed to get owner of profile.");
|
||||||
|
}
|
||||||
|
Element profileOwnerName = profileElem.newChildElement(
|
||||||
|
"ppp:ownerName", PPP_NS);
|
||||||
|
profileOwnerName.setText(owner.getFullName());
|
||||||
|
|
||||||
|
createNavigation(profile, root, navPath);
|
||||||
|
|
||||||
|
if (navPath == null) {
|
||||||
|
generateProfileOwnerXml(profileElem, owner, state);
|
||||||
|
} else {
|
||||||
|
final DataCollection links =
|
||||||
|
RelatedLink.getRelatedLinks(profile,
|
||||||
|
PublicPersonalProfile.LINK_LIST_NAME);
|
||||||
|
links.addFilter(String.format("linkTitle = '%s'",
|
||||||
|
navPath));
|
||||||
|
|
||||||
|
if (links.size() == 0) {
|
||||||
|
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
if (config.getShowPersonInfoEverywhere()) {
|
||||||
|
generateProfileOwnerXml(profileElem, owner,
|
||||||
|
state);
|
||||||
|
}
|
||||||
|
|
||||||
|
links.next();
|
||||||
|
final RelatedLink link =
|
||||||
|
(RelatedLink) DomainObjectFactory.
|
||||||
|
newInstance(links.getDataObject());
|
||||||
|
final ContentItem item = link.getTargetItem();
|
||||||
|
final PublicPersonalProfileXmlGenerator generator =
|
||||||
|
new PublicPersonalProfileXmlGenerator(
|
||||||
|
item);
|
||||||
|
generator.generateXML(new PageState(page, request,
|
||||||
|
response),
|
||||||
|
root, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PresentationManager presentationManager = Templating.
|
||||||
|
getPresentationManager();
|
||||||
|
presentationManager.servePage(document, request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
PresentationManager presentationManager = Templating.
|
|
||||||
getPresentationManager();
|
|
||||||
presentationManager.servePage(document, request, response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -391,7 +398,8 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DataCollection imgAttachments = (DataCollection) owner.get("imageAttachments");
|
DataCollection imgAttachments = (DataCollection) owner.get(
|
||||||
|
"imageAttachments");
|
||||||
if (imgAttachments.size() > 0) {
|
if (imgAttachments.size() > 0) {
|
||||||
imgAttachments.next();
|
imgAttachments.next();
|
||||||
final DataObject imgAttachment = imgAttachments.getDataObject();
|
final DataObject imgAttachment = imgAttachments.getDataObject();
|
||||||
|
|
@ -445,4 +453,46 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
||||||
isoCodeElem.setText(address.getIsoCountryCode());
|
isoCodeElem.setText(address.getIsoCountryCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showAdminPage(final Page page,
|
||||||
|
final HttpServletRequest request,
|
||||||
|
final HttpServletResponse response)
|
||||||
|
throws ServletException {
|
||||||
|
|
||||||
|
page.addRequestListener(new ApplicationAuthenticationListener());
|
||||||
|
|
||||||
|
final Form form = new Form("PublicPersonalProfileAdmin");
|
||||||
|
|
||||||
|
//form.add(new Label("Admin"));
|
||||||
|
|
||||||
|
//final Label label = new Label("for PublicPersonalProfile");
|
||||||
|
|
||||||
|
//form.add(label);
|
||||||
|
|
||||||
|
page.setClassAttr("adminPage");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final BoxPanel box = new BoxPanel(BoxPanel.VERTICAL);
|
||||||
|
final FormSection tableSection = new FormSection(box);
|
||||||
|
|
||||||
|
final PublicPersonalProfileNavItemsTable table =
|
||||||
|
new PublicPersonalProfileNavItemsTable();
|
||||||
|
|
||||||
|
|
||||||
|
box.add(table);
|
||||||
|
form.add(tableSection);
|
||||||
|
|
||||||
|
box.add(new PublicPersonalProfileNavItemsAddForm());
|
||||||
|
|
||||||
|
page.add(form);
|
||||||
|
page.lock();
|
||||||
|
|
||||||
|
final Document document = page.buildDocument(request, response);
|
||||||
|
|
||||||
|
final PresentationManager presentationManager = Templating.
|
||||||
|
getPresentationManager();
|
||||||
|
presentationManager.servePage(document, request, response);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,154 @@
|
||||||
|
package com.arsdigita.cms.publicpersonalprofile.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.FormSection;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.SaveCancelSection;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormValidationListener;
|
||||||
|
import com.arsdigita.bebop.form.Option;
|
||||||
|
import com.arsdigita.bebop.form.SingleSelect;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.parameters.NotEmptyValidationListener;
|
||||||
|
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||||
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.cms.contenttypes.PublicPersonalProfileNavItem;
|
||||||
|
import com.arsdigita.cms.contenttypes.PublicPersonalProfileNavItemCollection;
|
||||||
|
import com.arsdigita.cms.contenttypes.ui.PublicPersonalProfileGlobalizationUtil;
|
||||||
|
import com.arsdigita.cms.util.LanguageUtil;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
import com.arsdigita.util.Pair;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class PublicPersonalProfileNavItemsAddForm
|
||||||
|
extends FormSection
|
||||||
|
implements FormInitListener,
|
||||||
|
FormProcessListener,
|
||||||
|
FormValidationListener {
|
||||||
|
|
||||||
|
private final FormSection widgetSection;
|
||||||
|
private final SaveCancelSection saveCancelSection;
|
||||||
|
|
||||||
|
public PublicPersonalProfileNavItemsAddForm() {
|
||||||
|
super(new ColumnPanel(2));
|
||||||
|
widgetSection = new FormSection(new ColumnPanel(2, true));
|
||||||
|
super.add(widgetSection, ColumnPanel.INSERT);
|
||||||
|
|
||||||
|
ColumnPanel panel = (ColumnPanel) getPanel();
|
||||||
|
|
||||||
|
panel.add(new Label(PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"publicpersonalprofile.ui.navitem.key")));
|
||||||
|
final ParameterModel keyParam =
|
||||||
|
new StringParameter(
|
||||||
|
PublicPersonalProfileNavItem.KEY);
|
||||||
|
final TextField keyField = new TextField(keyParam);
|
||||||
|
keyField.setMaxLength(32);
|
||||||
|
keyField.addValidationListener(new NotNullValidationListener());
|
||||||
|
keyField.addValidationListener(new NotEmptyValidationListener());
|
||||||
|
panel.add(keyField);
|
||||||
|
|
||||||
|
panel.add(new Label(PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"publicpersonalprofile.ui.navitem.lang")));
|
||||||
|
final Collection languages = LanguageUtil.convertToG11N(LanguageUtil.
|
||||||
|
getSupportedLanguages2LA());
|
||||||
|
final ParameterModel langModel =
|
||||||
|
new StringParameter(
|
||||||
|
PublicPersonalProfileNavItem.LANG);
|
||||||
|
final SingleSelect langSelect = new SingleSelect(langModel);
|
||||||
|
langSelect.addValidationListener(new NotNullValidationListener());
|
||||||
|
langSelect.addValidationListener(new NotEmptyValidationListener());
|
||||||
|
|
||||||
|
langSelect.addOption(new Option("", ""));
|
||||||
|
Pair pair;
|
||||||
|
for (Object obj : languages) {
|
||||||
|
pair = (Pair) obj;
|
||||||
|
|
||||||
|
langSelect.addOption(new Option((String) pair.getKey(),
|
||||||
|
(String) ((GlobalizedMessage) pair.
|
||||||
|
getValue()).localize()));
|
||||||
|
}
|
||||||
|
panel.add(langSelect);
|
||||||
|
|
||||||
|
panel.add(new Label(PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"publicpersonalprofile.ui.navitem.label")));
|
||||||
|
final ParameterModel labelParam =
|
||||||
|
new StringParameter(
|
||||||
|
PublicPersonalProfileNavItem.LABEL);
|
||||||
|
final TextField labelField = new TextField(labelParam);
|
||||||
|
labelField.setMaxLength(32);
|
||||||
|
labelField.addValidationListener(new NotNullValidationListener());
|
||||||
|
labelField.addValidationListener(new NotEmptyValidationListener());
|
||||||
|
panel.add(labelField);
|
||||||
|
|
||||||
|
saveCancelSection = new SaveCancelSection();
|
||||||
|
super.add(saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
|
||||||
|
|
||||||
|
addInitListener(this);
|
||||||
|
addProcessListener(this);
|
||||||
|
addValidationListener(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(final FormSectionEvent fse) throws FormProcessException {
|
||||||
|
FormData data = fse.getFormData();
|
||||||
|
|
||||||
|
data.put(PublicPersonalProfileNavItem.KEY, "");
|
||||||
|
data.put(PublicPersonalProfileNavItem.LANG, "");
|
||||||
|
data.put(PublicPersonalProfileNavItem.LABEL, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void process(final FormSectionEvent fse)
|
||||||
|
throws FormProcessException {
|
||||||
|
final PageState state = fse.getPageState();
|
||||||
|
final FormData data = fse.getFormData();
|
||||||
|
|
||||||
|
PublicPersonalProfileNavItemCollection navItems =
|
||||||
|
new PublicPersonalProfileNavItemCollection();
|
||||||
|
|
||||||
|
final Map<String, PublicPersonalProfileNavItem> navItemMap =
|
||||||
|
new HashMap<String, PublicPersonalProfileNavItem>();
|
||||||
|
while (navItems.next()) {
|
||||||
|
navItemMap.put(navItems.getNavItem().getKey(), navItems.getNavItem());
|
||||||
|
}
|
||||||
|
final int numberOfKeys = navItemMap.size();
|
||||||
|
|
||||||
|
PublicPersonalProfileNavItem item = new PublicPersonalProfileNavItem();
|
||||||
|
|
||||||
|
item.setId(new BigDecimal(navItems.size() + 1));
|
||||||
|
item.setKey((String) data.get(PublicPersonalProfileNavItem.KEY));
|
||||||
|
item.setLang((String) data.get(PublicPersonalProfileNavItem.LANG));
|
||||||
|
item.setLabel((String) data.get(PublicPersonalProfileNavItem.LABEL));
|
||||||
|
final PublicPersonalProfileNavItem navItem =
|
||||||
|
navItemMap.get((String) data.get(
|
||||||
|
PublicPersonalProfileNavItem.KEY));
|
||||||
|
if (navItem == null) {
|
||||||
|
item.setOrder(numberOfKeys + 1);
|
||||||
|
} else {
|
||||||
|
item.setOrder(navItem.getOrder());
|
||||||
|
}
|
||||||
|
|
||||||
|
item.save();
|
||||||
|
|
||||||
|
data.put(PublicPersonalProfileNavItem.KEY, "");
|
||||||
|
data.put(PublicPersonalProfileNavItem.LANG, "");
|
||||||
|
data.put(PublicPersonalProfileNavItem.LABEL, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validate(final FormSectionEvent fse)
|
||||||
|
throws FormProcessException {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,304 @@
|
||||||
|
package com.arsdigita.cms.publicpersonalprofile.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.ControlLink;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.Table;
|
||||||
|
import com.arsdigita.bebop.event.TableActionEvent;
|
||||||
|
import com.arsdigita.bebop.event.TableActionListener;
|
||||||
|
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||||
|
import com.arsdigita.bebop.table.TableColumn;
|
||||||
|
import com.arsdigita.bebop.table.TableColumnModel;
|
||||||
|
import com.arsdigita.bebop.table.TableModel;
|
||||||
|
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||||
|
import com.arsdigita.cms.contenttypes.PublicPersonalProfileNavItem;
|
||||||
|
import com.arsdigita.cms.contenttypes.PublicPersonalProfileNavItemCollection;
|
||||||
|
import com.arsdigita.cms.contenttypes.ui.PublicPersonalProfileGlobalizationUtil;
|
||||||
|
import com.arsdigita.cms.dispatcher.Utilities;
|
||||||
|
import com.arsdigita.util.LockableImpl;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class PublicPersonalProfileNavItemsTable
|
||||||
|
extends Table
|
||||||
|
implements TableActionListener {
|
||||||
|
|
||||||
|
private final static String TABLE_COL_UP = "table_col_up";
|
||||||
|
private final static String TABLE_COL_DOWN = "table_col_down";
|
||||||
|
private final static String TABLE_COL_DELETE = "table_col_delete";
|
||||||
|
private final static String TABLE_COL_EDIT = "table_col_delete";
|
||||||
|
|
||||||
|
public PublicPersonalProfileNavItemsTable() {
|
||||||
|
setEmptyView(new Label(PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"publicpersonalprofile.ui.no_nav_items")));
|
||||||
|
|
||||||
|
TableColumnModel columnModel = getColumnModel();
|
||||||
|
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
0,
|
||||||
|
PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"publicpersonalprofile.ui.navitem.key").localize()));
|
||||||
|
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
1,
|
||||||
|
PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"publicpersonalprofile.ui.navitem.lang").localize()));
|
||||||
|
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
2,
|
||||||
|
PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"publicpersonalprofile.ui.navitem.label").localize()));
|
||||||
|
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
3,
|
||||||
|
PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"publicpersonalprofile.ui.navitem.generatorclass").localize()));
|
||||||
|
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
4,
|
||||||
|
PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"publicpersonalprofile.ui.navitem.edit").localize(),
|
||||||
|
TABLE_COL_EDIT));
|
||||||
|
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
5,
|
||||||
|
PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"publicpersonalprofile.ui.navitem.delete").localize(),
|
||||||
|
TABLE_COL_DELETE));
|
||||||
|
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
6,
|
||||||
|
PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"publicpersonalprofile.ui.navitem.up").localize(),
|
||||||
|
TABLE_COL_UP));
|
||||||
|
columnModel.add(new TableColumn(
|
||||||
|
7,
|
||||||
|
PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"publicpersonalprofile.ui.navitem.down").localize(),
|
||||||
|
TABLE_COL_DOWN));
|
||||||
|
|
||||||
|
setModelBuilder(new PublicPersonalProfileNavItemsTableModelBuilder());
|
||||||
|
|
||||||
|
columnModel.get(4).setCellRenderer(new EditCellRenderer());
|
||||||
|
columnModel.get(5).setCellRenderer(new DeleteCellRenderer());
|
||||||
|
columnModel.get(6).setCellRenderer(new UpCellRenderer());
|
||||||
|
columnModel.get(7).setCellRenderer(new DownCellRenderer());
|
||||||
|
|
||||||
|
addTableActionListener(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PublicPersonalProfileNavItemsTableModelBuilder
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableModelBuilder {
|
||||||
|
|
||||||
|
public TableModel makeModel(final Table table,
|
||||||
|
final PageState state) {
|
||||||
|
table.getRowSelectionModel().clearSelection(state);
|
||||||
|
return new PublicPersonalProfileNavItemsTableModel(table, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PublicPersonalProfileNavItemsTableModel
|
||||||
|
implements TableModel {
|
||||||
|
|
||||||
|
private final Table table;
|
||||||
|
private final PageState state;
|
||||||
|
private final PublicPersonalProfileNavItemCollection navItems =
|
||||||
|
new PublicPersonalProfileNavItemCollection();
|
||||||
|
private int lastOrder = 0;
|
||||||
|
private int numberOfKeys;
|
||||||
|
|
||||||
|
public PublicPersonalProfileNavItemsTableModel(final Table table,
|
||||||
|
final PageState state) {
|
||||||
|
this.table = table;
|
||||||
|
this.state = state;
|
||||||
|
final PublicPersonalProfileNavItemCollection items = new PublicPersonalProfileNavItemCollection();
|
||||||
|
final Set<String> keys = new HashSet<String>();
|
||||||
|
while(items.next()) {
|
||||||
|
keys.add(items.getNavItem().getKey());
|
||||||
|
}
|
||||||
|
numberOfKeys = keys.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getColumnCount() {
|
||||||
|
return table.getColumnModel().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean nextRow() {
|
||||||
|
if (!navItems.isBeforeFirst()) {
|
||||||
|
lastOrder = navItems.getNavItem().getOrder();
|
||||||
|
}
|
||||||
|
return navItems.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getElementAt(int columnIndex) {
|
||||||
|
switch (columnIndex) {
|
||||||
|
case 0:
|
||||||
|
return navItems.getNavItem().getKey();
|
||||||
|
case 1:
|
||||||
|
return navItems.getNavItem().getLang();
|
||||||
|
case 2:
|
||||||
|
return navItems.getNavItem().getLabel();
|
||||||
|
case 3:
|
||||||
|
return navItems.getNavItem().getGeneratorClass();
|
||||||
|
case 4:
|
||||||
|
return PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"publicpersonalprofile.ui.navitem.edit").localize();
|
||||||
|
case 5:
|
||||||
|
return PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"publicpersonalprofile.ui.navitem.delete").localize();
|
||||||
|
case 6:
|
||||||
|
if (navItems.getNavItem().getOrder() == lastOrder) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"publicpersonalprofile.ui.navitem.up").localize();
|
||||||
|
}
|
||||||
|
case 7:
|
||||||
|
if ((navItems.getNavItem().getOrder() == lastOrder)
|
||||||
|
|| (navItems.getNavItem().getOrder() == numberOfKeys)) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"publicpersonalprofile.ui.navitem.down").
|
||||||
|
localize();
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getKeyAt(int columnIndex) {
|
||||||
|
return navItems.getNavItem().getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class EditCellRenderer
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableCellRenderer {
|
||||||
|
|
||||||
|
public Component getComponent(final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Object value,
|
||||||
|
final boolean isSelected,
|
||||||
|
final Object key,
|
||||||
|
final int row,
|
||||||
|
final int column) {
|
||||||
|
|
||||||
|
final ControlLink link = new ControlLink(value.toString());
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DeleteCellRenderer
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableCellRenderer {
|
||||||
|
|
||||||
|
public Component getComponent(final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Object value,
|
||||||
|
final boolean isSelected,
|
||||||
|
final Object key,
|
||||||
|
final int row,
|
||||||
|
final int column) {
|
||||||
|
|
||||||
|
final ControlLink link = new ControlLink(value.toString());
|
||||||
|
link.setConfirmation((String) PublicPersonalProfileGlobalizationUtil.
|
||||||
|
globalize("publicpersonalprofile.ui.navitems.delete.confirm").
|
||||||
|
localize());
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class UpCellRenderer
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableCellRenderer {
|
||||||
|
|
||||||
|
public Component getComponent(final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Object value,
|
||||||
|
final boolean isSelected,
|
||||||
|
final Object key,
|
||||||
|
final int row,
|
||||||
|
final int column) {
|
||||||
|
if (row == 0) {
|
||||||
|
final Label label = new Label("");
|
||||||
|
return label;
|
||||||
|
} else if (value == null) {
|
||||||
|
final Label label = new Label("");
|
||||||
|
return label;
|
||||||
|
} else {
|
||||||
|
final ControlLink link =
|
||||||
|
new ControlLink((String) PublicPersonalProfileGlobalizationUtil.
|
||||||
|
globalize("publicpersonalprofile.ui.navitems.up").
|
||||||
|
localize());
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DownCellRenderer
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableCellRenderer {
|
||||||
|
|
||||||
|
private final PublicPersonalProfileNavItemCollection navItems =
|
||||||
|
new PublicPersonalProfileNavItemCollection();
|
||||||
|
|
||||||
|
public Component getComponent(final Table table,
|
||||||
|
final PageState state,
|
||||||
|
final Object value,
|
||||||
|
final boolean isSelected,
|
||||||
|
final Object key,
|
||||||
|
final int row,
|
||||||
|
final int column) {
|
||||||
|
if ((navItems.size() - 1) == row) {
|
||||||
|
final Label label = new Label("");
|
||||||
|
return label;
|
||||||
|
} else if (value == null) {
|
||||||
|
final Label label = new Label("");
|
||||||
|
return label;
|
||||||
|
} else {
|
||||||
|
final ControlLink link =
|
||||||
|
new ControlLink((String) PublicPersonalProfileGlobalizationUtil.
|
||||||
|
globalize("publicpersonalprofile.ui.navitems.down").
|
||||||
|
localize());
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cellSelected(final TableActionEvent event) {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
final PublicPersonalProfileNavItem navItem =
|
||||||
|
new PublicPersonalProfileNavItem(
|
||||||
|
new BigDecimal(event.getRowKey().toString()));
|
||||||
|
|
||||||
|
final PublicPersonalProfileNavItemCollection navItems =
|
||||||
|
new PublicPersonalProfileNavItemCollection();
|
||||||
|
|
||||||
|
final TableColumn column = getColumnModel().get(event.getColumn().
|
||||||
|
intValue());
|
||||||
|
|
||||||
|
if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) {
|
||||||
|
} else if (TABLE_COL_DELETE.equals(column.getHeaderKey().toString())) {
|
||||||
|
} else if (TABLE_COL_UP.equals(column.getHeaderKey().toString())) {
|
||||||
|
navItems.swapWithPrevious(navItem);
|
||||||
|
} else if (TABLE_COL_DOWN.equals(column.getHeaderKey().toString())) {
|
||||||
|
navItems.swapWithNext(navItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void headSelected(final TableActionEvent event) {
|
||||||
|
//Nothing to do
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue