integrated GQuery (GWT jQuery)

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/notifications@76802 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-06-05 16:45:10 +00:00
parent aca6fd95bd
commit 27802448c5
24 changed files with 589 additions and 136 deletions

View File

@ -50,6 +50,12 @@
<version>${gwtVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.googlecode.gwtquery</groupId>
<artifactId>gwtquery</artifactId>
<version>1.3.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>gcf</artifactId>

View File

@ -3,12 +3,15 @@ package org.gcube.portlets.user.notifications.client;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.TreeMap;
import org.gcube.portal.databook.shared.Notification;
import org.gcube.portal.databook.shared.NotificationChannelType;
import org.gcube.portal.databook.shared.NotificationType;
import org.gcube.portal.databook.shared.UserInfo;
import org.gcube.portlets.user.notifications.shared.NotificationPreference;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@ -23,7 +26,7 @@ public interface NotificationsService extends RemoteService {
boolean setAllUserNotificationsRead();
HashMap<NotificationType, NotificationChannelType[]> getUserNotificationPreferences();
LinkedHashMap<String, ArrayList<NotificationPreference>> getUserNotificationPreferences();
boolean setUserNotificationPreferences(Map<NotificationType, NotificationChannelType[]> enabledChannels);
}

View File

@ -3,12 +3,14 @@ package org.gcube.portlets.user.notifications.client;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import org.gcube.portal.databook.shared.Notification;
import org.gcube.portal.databook.shared.NotificationChannelType;
import org.gcube.portal.databook.shared.NotificationType;
import org.gcube.portal.databook.shared.UserInfo;
import org.gcube.portlets.user.notifications.shared.NotificationPreference;
import com.google.gwt.user.client.rpc.AsyncCallback;
@ -21,7 +23,8 @@ public interface NotificationsServiceAsync {
void setAllUserNotificationsRead(AsyncCallback<Boolean> callback);
void getUserNotificationPreferences(AsyncCallback<HashMap<NotificationType, NotificationChannelType[]>> callback);
void getUserNotificationPreferences(
AsyncCallback<LinkedHashMap<String, ArrayList<NotificationPreference>>> callback);
void setUserNotificationPreferences(
Map<NotificationType, NotificationChannelType[]> enabledChannels,

View File

@ -2,17 +2,23 @@ package org.gcube.portlets.user.notifications.client.view;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.TreeMap;
import org.gcube.portal.databook.shared.NotificationChannelType;
import org.gcube.portal.databook.shared.NotificationType;
import org.gcube.portlets.user.gcubewidgets.client.popup.GCubeDialog;
import org.gcube.portlets.user.notifications.client.NotificationsServiceAsync;
import org.gcube.portlets.user.notifications.client.view.templates.NotificationPreference;
import org.gcube.portlets.user.notifications.client.view.templates.CategoryWrapper;
import org.gcube.portlets.user.notifications.client.view.templates.NotificationPreferenceView;
import org.gcube.portlets.user.notifications.shared.NotificationPreference;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.HTML;
@ -21,8 +27,23 @@ import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.query.client.GQuery;
import com.google.gwt.query.client.Function;
import com.google.gwt.query.client.Selector;
import com.google.gwt.query.client.Selectors;
import com.google.gwt.query.client.css.CSS;
import com.google.gwt.query.client.css.RGBColor;
import static com.google.gwt.query.client.GQuery.*;
import static com.google.gwt.query.client.css.CSS.*;
import static com.google.gwt.query.client.plugins.Effects.Effects;
import static com.google.gwt.query.client.GQuery.$;
/**
* @author Massimiliano Assante ISTI-CNR
@ -38,47 +59,71 @@ public class NotificationSettings extends GCubeDialog {
public static final String mailSentOK = GWT.getModuleBaseURL() + "../images/yes.png";
public static final String mailSentNOK = GWT.getModuleBaseURL() + "../images/warning_blue.png";
private CheckBox portalCheckbox = new CheckBox("Infrastructure Gateway (this portal)");
private CheckBox emailCheckbox = new CheckBox("Email");
private HTML how = new HTML("<span style=\"font-size: 13px;\">How You Get Notifications:</span>");
private Button cancel = new Button("Cancel");
private Button save = new Button("Save");
private HashMap<NotificationType,NotificationChannelType[]> preferences;
private LinkedHashMap<String, ArrayList<NotificationPreference>> preferences;
public NotificationSettings(final HashMap<NotificationType,NotificationChannelType[]> preferences, final NotificationsServiceAsync notificationService) {
public NotificationSettings(LinkedHashMap<String, ArrayList<NotificationPreference>> preferences, final NotificationsServiceAsync notificationService) {
super();
ScrollPanel scroller = new ScrollPanel();
scroller.setWidth("1000px");
scroller.setHeight("500px");
this.preferences = preferences;
buttonsPanel.setWidth("100%");
buttonsPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
container.setStyleName("user-notification");
container.setWidth("800px");
container.add(how);
container.add(new HTML("&nbsp;"));
container.add(new NotificationPreference());
container.setWidth("950px");
for (String category : preferences.keySet()) {
container.add(new CategoryWrapper(category));
for (NotificationPreference pref : preferences.get(category)) {
container.add(new NotificationPreferenceView(pref));
}
}
container.add(portalCheckbox);
container.add(emailCheckbox);
buttonsContainerPanel.add(cancel);
buttonsContainerPanel.add(save);
buttonsPanel.add(buttonsContainerPanel);
container.add(buttonsPanel);
setText("Notification Settings");
setWidget(container);
scroller.add(container);
setWidget(scroller);
save.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Label label = new Label("test");
DOM.setElementProperty(label.getElement(), "id", "myId");
buttonsContainerPanel.add(label);
Timer t = new Timer() {
@Override
public void run() {
$("#myId").css(CSS.BACKGROUND_COLOR.with(RGBColor.RED));
$("#myId").click(new Function() {
@Override
public void f(Widget w) {
Window.alert("Ciao");
//fade out the button
$(w).fadeOut(1000);
}
});
}
});
};
t.schedule(1000);
// save.addClickHandler(new ClickHandler() {
// @Override
// public void onClick(ClickEvent event) {
//
// }
// });
cancel.addClickHandler(new ClickHandler() {

View File

@ -4,6 +4,9 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.TreeMap;
import org.gcube.portal.databook.shared.Notification;
import org.gcube.portal.databook.shared.NotificationChannelType;
@ -13,6 +16,7 @@ import org.gcube.portlets.user.notifications.client.NotificationsService;
import org.gcube.portlets.user.notifications.client.NotificationsServiceAsync;
import org.gcube.portlets.user.notifications.client.view.templates.DayWrapper;
import org.gcube.portlets.user.notifications.client.view.templates.SingleNotificationView;
import org.gcube.portlets.user.notifications.shared.NotificationPreference;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
@ -85,20 +89,19 @@ public class NotificationsPanel extends Composite {
@Override
public void onClick(ClickEvent event) {
notificationService.getUserNotificationPreferences(new AsyncCallback<HashMap<NotificationType,NotificationChannelType[]>>() {
notificationService.getUserNotificationPreferences(new AsyncCallback<LinkedHashMap<String,ArrayList<NotificationPreference>>>() {
@Override
public void onFailure(Throwable caught) {
}
public void onFailure(Throwable caught) { }
@Override
public void onSuccess(HashMap<NotificationType, NotificationChannelType[]> result) {
public void onSuccess(LinkedHashMap<String, ArrayList<NotificationPreference>> result) {
NotificationSettings dlg = new NotificationSettings(result, notificationService);
dlg.center();
dlg.show();
dlg.show();
}
});
});
}
});
}

View File

@ -0,0 +1,29 @@
package org.gcube.portlets.user.notifications.client.view.templates;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
/**
* @author Massimiliano Assante ISTI-CNR
*
*/
public class CategoryWrapper extends Composite {
private static CategoryWrapperUiBinder uiBinder = GWT
.create(CategoryWrapperUiBinder.class);
interface CategoryWrapperUiBinder extends UiBinder<Widget, CategoryWrapper> {
}
@UiField HTML categoryLabel;
public CategoryWrapper(String catName) {
initWidget(uiBinder.createAndBindUi(this));
categoryLabel.setHTML(catName);
}
}

View File

@ -0,0 +1,7 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:HTMLPanel styleName="day-wrapper">
<g:HTML ui:field="categoryLabel" styleName="day-label"/>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -0,0 +1,23 @@
package org.gcube.portlets.user.notifications.client.view.templates;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasText;
/**
*
* @author Massimiliano Assante, ISTI-CNR
* @version 0.1 Sep 2012
*
*/
public class Div extends HTML implements HasText {
public Div() {
super(DOM.createElement("div"));
}
public Div(String text) {
this();
setText(text);
}
}

View File

@ -1,29 +0,0 @@
package org.gcube.portlets.user.notifications.client.view.templates;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.Widget;
public class NotificationPreference extends Composite {
private static NotificationPreferenceUiBinder uiBinder = GWT
.create(NotificationPreferenceUiBinder.class);
interface NotificationPreferenceUiBinder extends
UiBinder<Widget, NotificationPreference> {
}
public NotificationPreference() {
initWidget(uiBinder.createAndBindUi(this));
}
}

View File

@ -1,13 +0,0 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:HTMLPanel>
<div id="preferenceContainer">
<div id="preferenceType">WP_FOLDER_SHARE</div>
<div id="preferenceDesc">use to notify a user he got a workspace folder shared</div>
<div id="preferenceSettingOff"></div>
<div id="preferenceSettingPortal"></div>
<div id="preferenceSettingEmail"></div>
</div>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -0,0 +1,36 @@
package org.gcube.portlets.user.notifications.client.view.templates;
import org.gcube.portlets.user.notifications.shared.NotificationPreference;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
public class NotificationPreferenceView extends Composite {
private static NotificationPreferenceUiBinder uiBinder = GWT
.create(NotificationPreferenceUiBinder.class);
interface NotificationPreferenceUiBinder extends
UiBinder<Widget, NotificationPreferenceView> {
}
@UiField Span prefType;
@UiField Span prefDesc;
@UiField CheckBox portalCheckbox;
@UiField CheckBox emailCheckbox;
//@UiField CheckBox noneCheckbox;
public NotificationPreferenceView(NotificationPreference toDisplay) {
initWidget(uiBinder.createAndBindUi(this));
prefType.setHTML(toDisplay.getTypeLabel());
prefDesc.setHTML(toDisplay.getTypeDesc());
}
}

View File

@ -0,0 +1,22 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:c="urn:import:org.gcube.portlets.user.notifications.client.view.templates"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:HTMLPanel>
<table class="single-notification-table">
<tr>
<td valign="TOP" style="width: 130px;" align="left">
<c:Span styleName="user-notification" ui:field="prefType" />
</td>
<td valign="TOP" style="width: 250px;">
<c:SwitchButton></c:SwitchButton>
<g:CheckBox ui:field="portalCheckbox">Portal</g:CheckBox>
<g:CheckBox ui:field="emailCheckbox">Email</g:CheckBox>
</td>
<td valign="TOP">
<c:Span styleName="user-notification" ui:field="prefDesc" />
</td>
</tr>
</table>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -0,0 +1,43 @@
package org.gcube.portlets.user.notifications.client.view.templates;
import static com.google.gwt.query.client.GQuery.$;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.query.client.Function;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
public class SlidingButton extends Composite {
private static SlidingButtonUiBinder uiBinder = GWT
.create(SlidingButtonUiBinder.class);
interface SlidingButtonUiBinder extends UiBinder<Widget, SlidingButton> {
}
@UiField FocusPanel switchContainer;
@UiField Div switcherButton;
public SlidingButton() {
initWidget(uiBinder.createAndBindUi(this));
switchContainer.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
//switcherButton.getElement().getStyle().setLeft(-1, Unit.PX);
//// Animate the switch
// this.button.animate({ left: newLeft }, 250, "easeInOutCubic");
$(switcherButton).animate("left: -1", 250);
}
});
}
}

View File

@ -0,0 +1,8 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:c="urn:import:org.gcube.portlets.user.notifications.client.view.templates"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:FocusPanel ui:field="switchContainer" styleName="switch-button-background">
<c:Div ui:field="switcherButton" styleName="switch-button-button"></c:Div>
</g:FocusPanel>
</ui:UiBinder>

View File

@ -0,0 +1,43 @@
package org.gcube.portlets.user.notifications.client.view.templates;
import static com.google.gwt.query.client.GQuery.$;
import com.google.gwt.core.client.GWT;
import com.google.gwt.query.client.Function;
import com.google.gwt.query.client.css.CSS;
import com.google.gwt.query.client.css.RGBColor;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
public class SwitchButton extends Composite {
private static SwitchButtonUiBinder uiBinder = GWT
.create(SwitchButtonUiBinder.class);
interface SwitchButtonUiBinder extends UiBinder<Widget, SwitchButton> {
}
public SwitchButton() {
initWidget(uiBinder.createAndBindUi(this));
Timer t = new Timer() {
@Override
public void run() {
$("#switchButton").click(new Function() {
@Override
public void f() {
Window.alert("Ciao");
//fade out the button
// $(w).fadeOut(1000);
}
});
}
};
t.schedule(1000);
}
}

View File

@ -0,0 +1,15 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:c="urn:import:org.gcube.portlets.user.notifications.client.view.templates"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:HTMLPanel styleName="floatingLeft">
<c:Span styleName="switch-button-label off">OFF</c:Span>
<c:SlidingButton></c:SlidingButton>
<c:Span styleName="switch-button-label on">ON</c:Span>
<div style="clear: left;"></div>
</g:HTMLPanel>
</ui:UiBinder>
<!-- <div id="switchButton" class="switch-button-background" style="width: 25px; height: 11px;"> -->
<!-- <div class="switch-button-button" style="width: 12px; height: 11px; left: 12px;"></div> -->
<!-- </div> -->

View File

@ -1,10 +1,18 @@
package org.gcube.portlets.user.notifications.server;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
import javax.servlet.ServletContext;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
@ -17,9 +25,8 @@ import org.gcube.portal.databook.shared.Notification;
import org.gcube.portal.databook.shared.NotificationChannelType;
import org.gcube.portal.databook.shared.NotificationType;
import org.gcube.portal.databook.shared.UserInfo;
import org.gcube.portal.databook.shared.ex.NotificationChannelTypeNotFoundException;
import org.gcube.portal.databook.shared.ex.NotificationTypeNotFoundException;
import org.gcube.portlets.user.notifications.client.NotificationsService;
import org.gcube.portlets.user.notifications.shared.NotificationPreference;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.liferay.portal.kernel.util.WebKeys;
@ -36,6 +43,9 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No
*
*/
private static GCUBEClientLog _log = new GCUBEClientLog(NotificationsServiceImpl.class);
private final static String TYPE_CATEGORIES_FILENAME = "categorybytype.properties";
private final static String TYPE_LABELS_FILENAME = "labelbytype.properties";
private final static String TYPE_DESCRIPTIONS_FILENAME = "descbytype.properties";
/**
* The store interface
*/
@ -103,7 +113,7 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No
}
return new UserInfo();
}
/**
* returns the notifications separated per days
*/
@ -155,17 +165,45 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No
}
return false;
}
@Override
public HashMap<NotificationType, NotificationChannelType[]> getUserNotificationPreferences() {
public LinkedHashMap<String, ArrayList<NotificationPreference>> getUserNotificationPreferences() {
String userid = getASLSession().getUsername();
HashMap<NotificationType, NotificationChannelType[]> toReturn = new HashMap<NotificationType, NotificationChannelType[]>();
try {
toReturn.putAll(store.getUserNotificationPreferences(userid));
//load the 3 prop files
Properties categories = getCategoriesByType();
Properties labels = getLabelsByType();
Properties descriptions = getDescriptionsByType();
TreeMap<String, ArrayList<NotificationPreference>> treeMap = new TreeMap<String, ArrayList<NotificationPreference>>();
try {
Map<NotificationType, NotificationChannelType[]> storePreferences = store.getUserNotificationPreferences(userid);
for (NotificationType type : storePreferences.keySet()) {
String category = categories.getProperty(type.toString());
String typeLabel = labels.getProperty(type.toString());
String typeDesc = descriptions.getProperty(type.toString());
if (category != null) {
if (treeMap.containsKey(category)) {
treeMap.get(category).add(new NotificationPreference(type, typeLabel, typeDesc, storePreferences.get(type.toString())));
} else {
ArrayList<NotificationPreference> toAdd = new ArrayList<NotificationPreference>();
toAdd.add(new NotificationPreference(type, typeLabel, typeDesc, storePreferences.get(type.toString())));
treeMap.put(category, toAdd);
}
}
}
} catch (Exception e) {
_log.error("While trying to get getUser Notification Preferences");
e.printStackTrace();
}
//need the key in revers order so that workspace appears first
LinkedHashMap<String, ArrayList<NotificationPreference>> toReturn = new LinkedHashMap<String, ArrayList<NotificationPreference>>();
for (String category : treeMap.descendingKeySet()) {
ArrayList<NotificationPreference> toAdd = new ArrayList<NotificationPreference>();
for (NotificationPreference pref : treeMap.get(category)) {
toAdd.add(pref);
}
toReturn.put(category, toAdd);
}
return toReturn;
}
@ -173,5 +211,69 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No
public boolean setUserNotificationPreferences(Map<NotificationType, NotificationChannelType[]> enabledChannels) {
return store.setUserNotificationPreferences(getASLSession().getUsername(), enabledChannels);
}
/**
*
* @param type the type to look for
* @return the Category if there is correspodance, null otherwise
*/
private Properties getCategoriesByType() {
Properties props = new Properties();
try {
ServletContext servletContext = getServletContext();
String contextPath = servletContext.getRealPath(File.separator);
String propertyfile = contextPath + "conf" + File.separator + TYPE_CATEGORIES_FILENAME;
File propsFile = new File(propertyfile);
FileInputStream fis = new FileInputStream(propsFile);
props.load( fis);
return props;
}
//catch exception in case properties file does not exist
catch(IOException e) {
_log.error(TYPE_CATEGORIES_FILENAME + "file not found under conf dir, returning null");
return null;
}
}
/**
*
* @return the properties for labels
*/
private Properties getLabelsByType() {
Properties props = new Properties();
try {
ServletContext servletContext = getServletContext();
String contextPath = servletContext.getRealPath(File.separator);
String propertyfile = contextPath + "conf" + File.separator + TYPE_LABELS_FILENAME;
File propsFile = new File(propertyfile);
FileInputStream fis = new FileInputStream(propsFile);
props.load( fis);
return props;
}
//catch exception in case properties file does not exist
catch(IOException e) {
_log.error(TYPE_LABELS_FILENAME + "file not found under conf dir, returning null");
return null;
}
}
/**
*
* @return the properties for descriptions
*/
private Properties getDescriptionsByType() {
Properties props = new Properties();
try {
ServletContext servletContext = getServletContext();
String contextPath = servletContext.getRealPath(File.separator);
String propertyfile = contextPath + "conf" + File.separator + TYPE_DESCRIPTIONS_FILENAME;
File propsFile = new File(propertyfile);
FileInputStream fis = new FileInputStream(propsFile);
props.load( fis);
return props;
}
//catch exception in case properties file does not exist
catch(IOException e) {
_log.error(TYPE_DESCRIPTIONS_FILENAME + "file not found under conf dir, returning null");
return null;
}
}
}

View File

@ -0,0 +1,78 @@
package org.gcube.portlets.user.notifications.shared;
import java.io.Serializable;
import java.util.Arrays;
import org.gcube.portal.databook.shared.NotificationChannelType;
import org.gcube.portal.databook.shared.NotificationType;
/**
* @author Massimiliano Assante, CNR-ISTI
* This class represent a notification preference with its type (allowing associating a label and a description)
* and the channels selected by the user for this type
*/
@SuppressWarnings("serial")
public class NotificationPreference implements Serializable {
NotificationType type;
String typeLabel;
String typeDesc;
NotificationChannelType[] selectedChannels;
public NotificationPreference() {
super();
}
public NotificationPreference(NotificationType type, String typeLabel,
String typeDesc, NotificationChannelType[] selectedChannels) {
super();
this.type = type;
this.typeLabel = typeLabel;
this.typeDesc = typeDesc;
this.selectedChannels = selectedChannels;
}
public NotificationChannelType[] getSelectedChannels() {
return selectedChannels;
}
public void setSelectedChannels(NotificationChannelType[] selectedChannels) {
this.selectedChannels = selectedChannels;
}
public NotificationType getType() {
return type;
}
public void setType(NotificationType type) {
this.type = type;
}
public String getTypeLabel() {
return typeLabel;
}
public void setTypeLabel(String typeLabel) {
this.typeLabel = typeLabel;
}
public String getTypeDesc() {
return typeDesc;
}
public void setTypeDesc(String typeDesc) {
this.typeDesc = typeDesc;
}
@Override
public String toString() {
return "NotificationPreference [type=" + type + ", typeLabel="
+ typeLabel + ", typeDesc=" + typeDesc + ", selectedChannels="
+ Arrays.toString(selectedChannels) + "]";
}
}

View File

@ -13,6 +13,8 @@
<!-- inherits gCube Widgets Library -->
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' />
<inherits name='org.gcube.portal.databook.GCubeSocialNetworking' />
<inherits name='com.google.gwt.query.Query'/>
<!-- Specify the app entry point class. -->
<entry-point
class='org.gcube.portlets.user.notifications.client.Notifications' />

View File

@ -3,57 +3,6 @@ table {
border-spacing: 0;
}
#preferenceContainer {
border: 1px solid black;
position: relative;
height: 50px;
}
#preferenceType {
border: 1px solid black;
position: absolute;
top: 0;
left: 0;
height: 50px;
width: 150px;
}
#preferenceDesc {
border: 1px solid black;
position: absolute;
top: 0;
left: 150px;
height: 50px;
width: 500px;
}
#preferenceSettingOff {
border: 1px solid black;
position: absolute;
top: 0;
left: 650px;
height: 50px;
width: 50px;
}
#preferenceSettingPortal {
border: 1px solid black;
position: absolute;
top: 0;
left: 700px;
height: 50px;
width: 50px;
}
#preferenceSettingEmail {
border: 1px solid black;
position: absolute;
top: 0;
left: 750px;
height: 50px;
width: 50px;
}
a.link,a.link:active,a.link:visited {
font-family: 'Lucida Grande', Verdana, 'Bitstream Vera Sans', Arial,
sans-serif;
@ -138,4 +87,65 @@ a.link:hover {
border-color: #999;
border-width: 1px;
letter-spacing: normal;
}
.gwt-CheckBox {
margin-right: 0;
padding-right: 0;
}
.floatingLeft {
float:left;
}
/* Switch Button */
.switch-button-label {
float: left;
font-size: 10pt;
cursor: pointer;
}
.switch-button-label.off {
color: #adadad;
}
.switch-button-label.on {
color: #0088CC;
}
.switch-button-background {
float: left;
position: relative;
background: #ccc;
border: 1px solid #aaa;
margin: 1px 10px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
cursor: pointer;
width: 25px;
height: 11px;
outline-style: none; /* this avoid the tabindex property to sorround this element with a (maybe dotted) rectangle*/
}
.switch-button-button {
position: absolute;
width: 12px;
height: 11px;
left: 12px;
top : -1px;
background: #FAFAFA;
border: 1px solid #aaa;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}

View File

@ -1,3 +0,0 @@
Sharing=WP_FOLDER_SHARE,WP_FOLDER_ADDEDUSER,WP_FOLDER_REMOVEDUSER,WP_FOLDER_RENAMED,WP_ITEM_DELETE,WP_ITEM_UPDATED,WP_ITEM_RENAMED,WP_ITEM_NEW
Social=OWN_COMMENT,COMMENT,MENTION,LIKE,MESSAGE
DocumentWorkflows=DOCUMENT_WORKFLOW_EDIT,DOCUMENT_WORKFLOW_VIEW,DOCUMENT_WORKFLOW_STEP_REQUEST_TASK,DOCUMENT_WORKFLOW_FIRST_STEP_REQUEST_INVOLVMENT,DOCUMENT_WORKFLOW_USER_FORWARD_TO_OWNER,DOCUMENT_WORKFLOW_FORWARD_STEP_COMPLETED_OWNER,DOCUMENT_WORKFLOW_STEP_FORWARD_PEER

View File

@ -0,0 +1,20 @@
DOCUMENT_WORKFLOW_EDIT=Document Workflow
DOCUMENT_WORKFLOW_VIEW=Document Workflow
DOCUMENT_WORKFLOW_STEP_REQUEST_TASK=Document Workflow
DOCUMENT_WORKFLOW_FIRST_STEP_REQUEST_INVOLVMENT=Document Workflow
DOCUMENT_WORKFLOW_USER_FORWARD_TO_OWNER=Document Workflow
DOCUMENT_WORKFLOW_FORWARD_STEP_COMPLETED_OWNER=Document Workflow
DOCUMENT_WORKFLOW_STEP_FORWARD_PEER=Document Workflow
WP_FOLDER_SHARE=Workspace Sharing
WP_FOLDER_ADDEDUSER=Workspace Sharing
WP_FOLDER_REMOVEDUSER=Workspace Sharing
WP_FOLDER_RENAMED=Workspace Sharing
WP_ITEM_DELETE=Workspace Sharing
WP_ITEM_UPDATED=Workspace Sharing
WP_ITEM_RENAMED=Workspace Sharing
WP_ITEM_NEW=Workspace Sharing
OWN_COMMENT=Social Networking
COMMENT=Social Networking
MENTION=Social Networking
LIKE=Social Networking
MESSAGE=Social Networking