Skip to content

Commit 65b4e90

Browse files
author
svuillet
committed
Feature #14423
1 parent b07ee2e commit 65b4e90

File tree

12 files changed

+657
-290
lines changed

12 files changed

+657
-290
lines changed

mobile-war/src/main/java/org/silverpeas/mobile/client/apps/contacts/ContactsApp.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@
2525
package org.silverpeas.mobile.client.apps.contacts;
2626

2727
import com.google.gwt.core.client.GWT;
28+
import com.google.gwt.user.client.Window;
2829
import org.fusesource.restygwt.client.Method;
29-
import org.silverpeas.mobile.client.apps.contacts.events.app.AbstractContactsAppEvent;
30-
import org.silverpeas.mobile.client.apps.contacts.events.app.ContactsAppEventHandler;
31-
import org.silverpeas.mobile.client.apps.contacts.events.app.ContactsFilteredLoadEvent;
32-
import org.silverpeas.mobile.client.apps.contacts.events.app.ContactsLoadEvent;
30+
import org.silverpeas.mobile.client.apps.contacts.events.app.*;
3331
import org.silverpeas.mobile.client.apps.contacts.events.pages.ContactsLoadedEvent;
32+
import org.silverpeas.mobile.client.apps.contacts.pages.ContactPage;
3433
import org.silverpeas.mobile.client.apps.contacts.pages.ContactsPage;
3534
import org.silverpeas.mobile.client.apps.navigation.events.app.external.AbstractNavigationEvent;
3635
import org.silverpeas.mobile.client.apps.navigation.events.app.external.NavigationAppInstanceChangedEvent;
@@ -88,6 +87,27 @@ public void onSuccess(final Method method, final List<DetailUserDTO> result) {
8887
action.attempt();
8988
}
9089

90+
@Override
91+
public void loadContact(ContactLoadEvent event) {
92+
MethodCallbackOnlineOnly action = new MethodCallbackOnlineOnly<DetailUserDTO>() {
93+
@Override
94+
public void attempt() {
95+
super.attempt();
96+
ServicesLocator.getServiceContact().getContact(event.getUserId(), this);
97+
}
98+
99+
@Override
100+
public void onSuccess(Method method, DetailUserDTO detailUserDTO) {
101+
super.onSuccess(method, detailUserDTO);
102+
ContactPage page = new ContactPage();
103+
page.setPageTitle(detailUserDTO.getFirstName() + " " + detailUserDTO.getLastName());
104+
page.setData(detailUserDTO);
105+
page.show();
106+
}
107+
};
108+
action.attempt();
109+
}
110+
91111
@Override
92112
public void loadContactsFiltered(final ContactsFilteredLoadEvent event) {
93113
ContactsPage page = (ContactsPage) getMainPage();
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (C) 2000 - 2024 Silverpeas
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Affero General Public License as
6+
* published by the Free Software Foundation, either version 3 of the
7+
* License, or (at your option) any later version.
8+
*
9+
* As a special exception to the terms and conditions of version 3.0 of
10+
* the GPL, you may redistribute this Program in connection with Free/Libre
11+
* Open Source Software ("FLOSS") applications as described in Silverpeas's
12+
* FLOSS exception. You should have received a copy of the text describing
13+
* the FLOSS exception, and it is also available here:
14+
* "https://www.silverpeas.org/legal/floss_exception.html"
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU Affero General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU Affero General Public License
22+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23+
*/
24+
25+
package org.silverpeas.mobile.client.apps.contacts.events.app;
26+
27+
28+
public class ContactLoadEvent extends AbstractContactsAppEvent{
29+
30+
private String userId;
31+
32+
public ContactLoadEvent(String userId) {
33+
super();
34+
this.userId = userId;
35+
}
36+
37+
@Override
38+
protected void dispatch(ContactsAppEventHandler handler) {
39+
handler.loadContact(this);
40+
}
41+
42+
public String getUserId() {
43+
return userId;
44+
}
45+
}

mobile-war/src/main/java/org/silverpeas/mobile/client/apps/contacts/events/app/ContactsAppEventHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828

2929
public interface ContactsAppEventHandler extends EventHandler{
3030
void loadContacts(ContactsLoadEvent event);
31-
32-
void loadContactsFiltered(ContactsFilteredLoadEvent contactsFilteredLoadEvent);
31+
void loadContact(ContactLoadEvent event);
32+
void loadContactsFiltered(ContactsFilteredLoadEvent contactsFilteredLoadEvent);
3333
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* Copyright (C) 2000 - 2024 Silverpeas
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Affero General Public License as
6+
* published by the Free Software Foundation, either version 3 of the
7+
* License, or (at your option) any later version.
8+
*
9+
* As a special exception to the terms and conditions of version 3.0 of
10+
* the GPL, you may redistribute this Program in connection with Free/Libre
11+
* Open Source Software ("FLOSS") applications as described in Silverpeas's
12+
* FLOSS exception. You should have received a copy of the text describing
13+
* the FLOSS exception, and it is also available here:
14+
* "https://www.silverpeas.org/legal/floss_exception.html"
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU Affero General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU Affero General Public License
22+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23+
*/
24+
25+
package org.silverpeas.mobile.client.apps.contacts.pages;
26+
27+
import com.google.gwt.core.client.GWT;
28+
import com.google.gwt.uibinder.client.UiBinder;
29+
import com.google.gwt.uibinder.client.UiField;
30+
import com.google.gwt.user.client.ui.HTMLPanel;
31+
import com.google.gwt.user.client.ui.Image;
32+
import com.google.gwt.user.client.ui.Widget;
33+
import org.silverpeas.mobile.client.apps.contacts.pages.widgets.FieldItem;
34+
import org.silverpeas.mobile.client.apps.contacts.resources.ContactsMessages;
35+
import org.silverpeas.mobile.client.components.UnorderedList;
36+
import org.silverpeas.mobile.client.components.base.PageContent;
37+
import org.silverpeas.mobile.shared.dto.DetailUserDTO;
38+
import org.silverpeas.mobile.shared.dto.PropertyDTO;
39+
40+
public class ContactPage extends PageContent {
41+
42+
private static ContactPageUiBinder uiBinder = GWT.create(ContactPageUiBinder.class);
43+
44+
@UiField(provided = true) protected ContactsMessages msg = null;
45+
@UiField HTMLPanel container;
46+
@UiField UnorderedList fields;
47+
48+
private DetailUserDTO data;
49+
50+
public void setData(DetailUserDTO data) {
51+
this.data = data;
52+
fields.clear();
53+
54+
Image pic = new Image();
55+
pic.setUrl(data.getAvatar());
56+
pic.setStyleName("avatar");
57+
FieldItem avatar = new FieldItem();
58+
avatar.setContent(pic);
59+
fields.add(avatar);
60+
FieldItem mail = new FieldItem();
61+
mail.setData("email", "Email", data.geteMail());
62+
fields.add(mail);
63+
for (PropertyDTO propertie : data.getProperties()) {
64+
FieldItem f = new FieldItem();
65+
f.setData(propertie.getKey(), data.getPropertiesLabel().get(propertie.getKey()), propertie.getValue());
66+
fields.add(f);
67+
}
68+
}
69+
70+
interface ContactPageUiBinder extends UiBinder<Widget, ContactPage> {
71+
}
72+
73+
public ContactPage() {
74+
msg = GWT.create(ContactsMessages.class);
75+
setPageTitle(msg.title());
76+
initWidget(uiBinder.createAndBindUi(this));
77+
78+
79+
}
80+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!--
2+
~ Copyright (C) 2000 - 2024 Silverpeas
3+
~
4+
~ This program is free software: you can redistribute it and/or modify
5+
~ it under the terms of the GNU Affero General Public License as
6+
~ published by the Free Software Foundation, either version 3 of the
7+
~ License, or (at your option) any later version.
8+
~
9+
~ As a special exception to the terms and conditions of version 3.0 of
10+
~ the GPL, you may redistribute this Program in connection with Free/Libre
11+
~ Open Source Software ("FLOSS") applications as described in Silverpeas's
12+
~ FLOSS exception. You should have received a copy of the text describing
13+
~ the FLOSS exception, and it is also available here:
14+
~ "https://www.silverpeas.org/legal/floss_exception.html"
15+
~
16+
~ This program is distributed in the hope that it will be useful,
17+
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
~ GNU Affero General Public License for more details.
20+
~
21+
~ You should have received a copy of the GNU Affero General Public License
22+
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
23+
-->
24+
25+
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
26+
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
27+
xmlns:g="urn:import:com.google.gwt.user.client.ui"
28+
xmlns:components="urn:import:org.silverpeas.mobile.client.components">
29+
30+
<ui:with field='msg' type='org.silverpeas.mobile.client.apps.contacts.resources.ContactsMessages' />
31+
32+
33+
<g:HTMLPanel ui:field="container" styleName="ui-content ui-body-a">
34+
<components:UnorderedList ui:field="fields" styleName="fields-contact"></components:UnorderedList>
35+
</g:HTMLPanel>
36+
</ui:UiBinder>

mobile-war/src/main/java/org/silverpeas/mobile/client/apps/contacts/pages/widgets/ContactItem.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import com.google.gwt.dom.client.Document;
2929
import com.google.gwt.dom.client.SpanElement;
3030
import com.google.gwt.dom.client.Style;
31+
import com.google.gwt.event.dom.client.ClickEvent;
32+
import com.google.gwt.event.dom.client.ClickHandler;
3133
import com.google.gwt.uibinder.client.UiBinder;
3234
import com.google.gwt.uibinder.client.UiField;
3335
import com.google.gwt.user.client.ui.Anchor;
@@ -37,14 +39,15 @@
3739
import com.google.gwt.user.client.ui.Image;
3840
import com.google.gwt.user.client.ui.InlineHTML;
3941
import com.google.gwt.user.client.ui.Widget;
42+
import org.silverpeas.mobile.client.apps.contacts.events.app.ContactLoadEvent;
4043
import org.silverpeas.mobile.client.apps.contacts.resources.ContactsResources;
41-
import org.silverpeas.mobile.client.common.network.NetworkHelper;
44+
import org.silverpeas.mobile.client.common.EventBus;
4245
import org.silverpeas.mobile.client.common.resources.ResourcesManager;
4346
import org.silverpeas.mobile.client.resources.ApplicationResources;
4447
import org.silverpeas.mobile.shared.dto.DetailUserDTO;
4548
import org.silverpeas.mobile.shared.dto.PropertyDTO;
4649

47-
public class ContactItem extends Composite {
50+
public class ContactItem extends Composite implements ClickHandler {
4851

4952
private static ContactItemUiBinder uiBinder = GWT.create(ContactItemUiBinder.class);
5053
@UiField Anchor mail;
@@ -53,6 +56,12 @@ public class ContactItem extends Composite {
5356
private ApplicationResources resources = GWT.create(ApplicationResources.class);
5457
private ContactsResources resourcesContact = GWT.create(ContactsResources.class);
5558

59+
@Override
60+
public void onClick(ClickEvent event) {
61+
Widget w = (Widget) event.getSource();
62+
EventBus.getInstance().fireEvent(new ContactLoadEvent(w.getElement().getAttribute("user-id")));
63+
}
64+
5665
interface ContactItemUiBinder extends UiBinder<Widget, ContactItem> {
5766
}
5867

@@ -65,9 +74,14 @@ public void setData(DetailUserDTO userData) {
6574
Image avatar = new Image(resources.avatar());
6675
avatar.getElement().removeAttribute("height");
6776
avatar.getElement().removeAttribute("width");
77+
avatar.getElement().setAttribute("user-id", userData.getId());
78+
avatar.addClickHandler(this);
6879
user.add(avatar);
6980
} else {
70-
user.add(new Image(userData.getAvatar()));
81+
Image avatar = new Image(userData.getAvatar());
82+
avatar.getElement().setAttribute("user-id", userData.getId());
83+
avatar.addClickHandler(this);
84+
user.add(avatar);
7185
}
7286

7387
Boolean firstnameAtFirst = Boolean.parseBoolean(ResourcesManager.getParam("directory.display.firstname.at.first"));
@@ -80,7 +94,10 @@ public void setData(DetailUserDTO userData) {
8094
html += " <span class='status'>" + userData.getStatus() + "</span>";
8195

8296
if (userData.getConnected()) html += "<span class='connected'></span>";
83-
user.add(new HTML(html));
97+
HTML h = new HTML(html);
98+
h.getElement().setAttribute("user-id", userData.getId());
99+
h.addClickHandler(this);
100+
user.add(h);
84101
mail.setText(userData.geteMail());
85102
if (userData.geteMail() == null || userData.geteMail().isEmpty()) {
86103
mail.setHTML("&nbsp");
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright (C) 2000 - 2024 Silverpeas
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Affero General Public License as
6+
* published by the Free Software Foundation, either version 3 of the
7+
* License, or (at your option) any later version.
8+
*
9+
* As a special exception to the terms and conditions of version 3.0 of
10+
* the GPL, you may redistribute this Program in connection with Free/Libre
11+
* Open Source Software ("FLOSS") applications as described in Silverpeas's
12+
* FLOSS exception. You should have received a copy of the text describing
13+
* the FLOSS exception, and it is also available here:
14+
* "https://www.silverpeas.org/legal/floss_exception.html"
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU Affero General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU Affero General Public License
22+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23+
*/
24+
25+
package org.silverpeas.mobile.client.apps.contacts.pages.widgets;
26+
27+
import com.google.gwt.core.client.GWT;
28+
import com.google.gwt.uibinder.client.UiBinder;
29+
import com.google.gwt.uibinder.client.UiField;
30+
import com.google.gwt.user.client.ui.*;
31+
import org.silverpeas.mobile.client.apps.contacts.resources.ContactsResources;
32+
import org.silverpeas.mobile.client.resources.ApplicationResources;
33+
34+
public class FieldItem extends Composite {
35+
36+
private static FieldItemUiBinder uiBinder = GWT.create(FieldItemUiBinder.class);
37+
@UiField HTMLPanel container;
38+
39+
private ApplicationResources resources = GWT.create(ApplicationResources.class);
40+
private ContactsResources resourcesContact = GWT.create(ContactsResources.class);
41+
42+
public void setContent(Widget pic) {
43+
container.add(pic);
44+
}
45+
46+
interface FieldItemUiBinder extends UiBinder<Widget, FieldItem> {
47+
}
48+
49+
public FieldItem() {
50+
initWidget(uiBinder.createAndBindUi(this));
51+
}
52+
53+
public void setData(String name, String label, String value) {
54+
setStyleName(name);
55+
InlineHTML lb = new InlineHTML();
56+
lb.setStyleName("");
57+
lb.setText(label + " : ");
58+
container.add(lb);
59+
InlineHTML vl = new InlineHTML();
60+
vl.setStyleName("");
61+
vl.setText(value);
62+
container.add(vl);
63+
64+
}
65+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!--
2+
~ Copyright (C) 2000 - 2024 Silverpeas
3+
~
4+
~ This program is free software: you can redistribute it and/or modify
5+
~ it under the terms of the GNU Affero General Public License as
6+
~ published by the Free Software Foundation, either version 3 of the
7+
~ License, or (at your option) any later version.
8+
~
9+
~ As a special exception to the terms and conditions of version 3.0 of
10+
~ the GPL, you may redistribute this Program in connection with Free/Libre
11+
~ Open Source Software ("FLOSS") applications as described in Silverpeas's
12+
~ FLOSS exception. You should have received a copy of the text describing
13+
~ the FLOSS exception, and it is also available here:
14+
~ "https://www.silverpeas.org/legal/floss_exception.html"
15+
~
16+
~ This program is distributed in the hope that it will be useful,
17+
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
~ GNU Affero General Public License for more details.
20+
~
21+
~ You should have received a copy of the GNU Affero General Public License
22+
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
23+
-->
24+
25+
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
26+
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui">
27+
<g:HTMLPanel tag="li" ui:field="container">
28+
</g:HTMLPanel>
29+
</ui:UiBinder>

0 commit comments

Comments
 (0)