seems working, need to implement share with people tags now
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@73467 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d406884a86
commit
909a27d17e
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/share-updates-0.2.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/share-updates-0.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
@ -31,5 +31,5 @@
|
|||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/share-updates-0.2.1-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/share-updates-0.3.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#Thu Apr 11 19:01:38 CEST 2013
|
||||
#Tue Apr 16 18:09:11 CEST 2013
|
||||
eclipse.preferences.version=1
|
||||
jarsExcludedFromWebInfLib=
|
||||
lastWarOutDir=/Users/massi/Documents/workspace/share-updates/target/share-updates-0.2.1-SNAPSHOT
|
||||
lastWarOutDir=/Users/massi/Documents/workspace/share-updates/target/share-updates-0.3.0-SNAPSHOT
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||
<dependent-module archiveName="pickuser-widget-0.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/pickuser-widget/pickuser-widget">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
||||
<property name="context-root" value="share-updates"/>
|
||||
</wb-module>
|
||||
|
|
19
pom.xml
19
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>share-updates</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>0.2.1-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
|
||||
<name>gCube Share Updates Portlet</name>
|
||||
<description>
|
||||
|
@ -77,6 +77,11 @@
|
|||
<version>[1.4.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>pickuser-widget</artifactId>
|
||||
<version>[0.1.0-SNAPSHOT, 1.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>custom-portal-handler</artifactId>
|
||||
|
@ -89,6 +94,18 @@
|
|||
<version>[3.2.0-SNAPSHOT, 4.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>home-library</artifactId>
|
||||
<version>[4.3.0-SNAPSHOT, 5.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.dvos</groupId>
|
||||
<artifactId>usermanagement-core</artifactId>
|
||||
<version>[1.3.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google</groupId>
|
||||
<artifactId>gwt-jsonmaker</artifactId>
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package org.gcube.portlets.user.shareupdates.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portal.databook.shared.ClientFeed;
|
||||
import org.gcube.portal.databook.shared.FeedType;
|
||||
import org.gcube.portal.databook.shared.PrivacyLevel;
|
||||
import org.gcube.portlets.user.pickuser.shared.PickingUser;
|
||||
import org.gcube.portlets.user.shareupdates.shared.LinkPreview;
|
||||
import org.gcube.portlets.user.shareupdates.shared.UserSettings;
|
||||
|
||||
|
@ -19,4 +22,6 @@ public interface ShareUpdateService extends RemoteService {
|
|||
UserSettings getUserSettings();
|
||||
|
||||
LinkPreview checkLink(String linkToCheck);
|
||||
|
||||
ArrayList<PickingUser> getPortalUsers();
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package org.gcube.portlets.user.shareupdates.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portal.databook.shared.ClientFeed;
|
||||
import org.gcube.portal.databook.shared.FeedType;
|
||||
import org.gcube.portal.databook.shared.PrivacyLevel;
|
||||
import org.gcube.portlets.user.pickuser.shared.PickingUser;
|
||||
import org.gcube.portlets.user.shareupdates.shared.LinkPreview;
|
||||
import org.gcube.portlets.user.shareupdates.shared.UserSettings;
|
||||
|
||||
|
@ -19,4 +22,6 @@ public interface ShareUpdateServiceAsync {
|
|||
void checkLink(String linkToCheck, AsyncCallback<LinkPreview> callback);
|
||||
|
||||
void getUserSettings(AsyncCallback<UserSettings> callback);
|
||||
|
||||
void getPortalUsers(AsyncCallback<ArrayList<PickingUser>> callback);
|
||||
}
|
||||
|
|
|
@ -1,204 +0,0 @@
|
|||
package org.gcube.portlets.user.shareupdates.client.dialog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
import org.gcube.portal.databook.shared.Like;
|
||||
import org.gcube.portlets.user.shareupdates.client.events.PickedUserEvent;
|
||||
import org.gcube.portlets.user.shareupdates.client.form.SingleUserTemplate;
|
||||
import org.gcube.portlets.user.shareupdates.shared.PickingUser;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.KeyCodes;
|
||||
import com.google.gwt.event.dom.client.KeyDownEvent;
|
||||
import com.google.gwt.event.dom.client.KeyDownHandler;
|
||||
import com.google.gwt.event.dom.client.MouseOutEvent;
|
||||
import com.google.gwt.event.dom.client.MouseOutHandler;
|
||||
import com.google.gwt.event.dom.client.MouseOverEvent;
|
||||
import com.google.gwt.event.dom.client.MouseOverHandler;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.user.client.Event;
|
||||
import com.google.gwt.user.client.ui.FocusPanel;
|
||||
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
|
||||
import com.google.gwt.user.client.ui.PopupPanel;
|
||||
import com.google.gwt.user.client.ui.SuggestOracle.Callback;
|
||||
import com.google.gwt.user.client.ui.SuggestOracle.Request;
|
||||
import com.google.gwt.user.client.ui.SuggestOracle.Response;
|
||||
import com.google.gwt.user.client.ui.SuggestOracle.Suggestion;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
|
||||
public class PickUsersDialog extends PopupPanel {
|
||||
|
||||
public final static int ARROW_UP = 38;
|
||||
public final static int ARROW_DOWN = 40;
|
||||
|
||||
public final static int DELETE = KeyCodes.KEY_DELETE;
|
||||
public final static int ENTER = KeyCodes.KEY_ENTER;
|
||||
public final static int ESCAPE = KeyCodes.KEY_ESCAPE;
|
||||
public final static int TAB = KeyCodes.KEY_TAB;
|
||||
|
||||
private HandlerManager eventBus;
|
||||
|
||||
private int limit = 10;
|
||||
|
||||
private final MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
|
||||
|
||||
private ArrayList<String> users = new ArrayList<String>();
|
||||
private int displayIndexSelected;
|
||||
|
||||
private FocusPanel focusPanel = new FocusPanel();
|
||||
private VerticalPanel mainPanel = new VerticalPanel();
|
||||
|
||||
//needed because is selected when it popups
|
||||
private SingleUserTemplate first;
|
||||
|
||||
public PickUsersDialog(HandlerManager eventBus) {
|
||||
super(true, false);
|
||||
this.eventBus = eventBus;
|
||||
focusPanel.setWidth("525px");
|
||||
mainPanel.setWidth("525px");
|
||||
setWidth("525px");
|
||||
focusPanel.add(mainPanel);
|
||||
setWidget(focusPanel);
|
||||
setStyleName("pickDialog");
|
||||
|
||||
oracle.add("Massimiliano Assante");
|
||||
oracle.add("Pasquale Pagano");
|
||||
oracle.add("Leonardo Candela");
|
||||
oracle.add("Anton Ellenbroek");
|
||||
oracle.add("Ward Appeltans");
|
||||
oracle.add("Gianpaolo Coro");
|
||||
oracle.add("Federico De Faveri");
|
||||
oracle.add("Marco Pozzi");
|
||||
oracle.add("Marino Marini");
|
||||
oracle.add("Franco Zoppi");
|
||||
oracle.add("Valentina Marioli");
|
||||
oracle.add("Antonio Gioia");
|
||||
|
||||
//remove the first selected when hovering
|
||||
focusPanel.addMouseOverHandler(new MouseOverHandler() {
|
||||
@Override
|
||||
public void onMouseOver(MouseOverEvent event) {
|
||||
if (first != null)
|
||||
first.removeStyleName("pickperson-selected");
|
||||
}
|
||||
});
|
||||
|
||||
focusPanel.addMouseOutHandler(new MouseOutHandler() {
|
||||
@Override
|
||||
public void onMouseOut(MouseOutEvent event) {
|
||||
select(displayIndexSelected);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* called for each keyUp event from the user
|
||||
* @param event
|
||||
* @param x
|
||||
* @param y
|
||||
* @param currText
|
||||
*/
|
||||
public void onKeyUp(Event event, int x, int y, String currText) {
|
||||
if (currText.endsWith("@")) { //the only way i found to intercept @
|
||||
setPopupPosition(x, y);
|
||||
hide();
|
||||
} else if (currText.contains("@")) {
|
||||
if (pickingUser(currText)) {
|
||||
handleNonCharKeys(event);
|
||||
}
|
||||
} else if (!currText.contains("@"))
|
||||
hide();
|
||||
}
|
||||
|
||||
/**
|
||||
* split the text and keeps listening for user keyboard events
|
||||
* @param currText the text being typed
|
||||
*/
|
||||
private boolean pickingUser(String currText) {
|
||||
String[] toSplit = currText.split("@"); //get the interesting part
|
||||
if (toSplit[1].trim().length() > 0) {
|
||||
showSuggestions(toSplit[1]);
|
||||
return true;
|
||||
}
|
||||
hide();
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* handles the nonchar events (arrows, esc, enter etc)
|
||||
* @param event
|
||||
*/
|
||||
private void handleNonCharKeys(Event event) {
|
||||
switch (event.getKeyCode()) {
|
||||
case ARROW_UP:
|
||||
if (displayIndexSelected > 0)
|
||||
select(--displayIndexSelected);
|
||||
break;
|
||||
case ARROW_DOWN:
|
||||
case TAB:
|
||||
if (displayIndexSelected+1 < mainPanel.getWidgetCount())
|
||||
select(displayIndexSelected+1);
|
||||
break;
|
||||
case ESCAPE:
|
||||
case DELETE:
|
||||
hide();
|
||||
case ENTER: //selectd with keyboard
|
||||
SingleUserTemplate ut = null;
|
||||
if (mainPanel.getWidgetCount() > 0) {
|
||||
if (displayIndexSelected < 0 || displayIndexSelected >= mainPanel.getWidgetCount()) //when there's only one left sometimes here i get -sth, no time to see why :)
|
||||
ut = (SingleUserTemplate) mainPanel.getWidget(0);
|
||||
else
|
||||
ut = (SingleUserTemplate) mainPanel.getWidget(displayIndexSelected);
|
||||
eventBus.fireEvent(new PickedUserEvent(new PickingUser("id", "username", ut.getFullName(), "thumb")));
|
||||
hide();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void showSuggestions(String query) {
|
||||
if (query.length() > 0) {
|
||||
oracle.requestSuggestions(new Request(query, limit), new Callback() {
|
||||
public void onSuggestionsReady(Request request, Response response) {
|
||||
mainPanel.clear();
|
||||
int i = 0;
|
||||
for (Suggestion s : response.getSuggestions()) {
|
||||
if (i == 0) {
|
||||
first = getUserTemplate(new PickingUser("", "", s.getDisplayString(), ""), i);
|
||||
first.addStyleName("pickperson-selected");
|
||||
mainPanel.add(first);
|
||||
}
|
||||
else
|
||||
mainPanel.add(getUserTemplate(new PickingUser("", "", s.getDisplayString(), ""), i));
|
||||
i++;
|
||||
}
|
||||
if (i > 0)
|
||||
show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private SingleUserTemplate getUserTemplate(PickingUser user, int displayIndex) {
|
||||
return new SingleUserTemplate(this, user, displayIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* select the user in the model and in the view
|
||||
* @param displayIndex
|
||||
*/
|
||||
public void select(int displayIndex) {
|
||||
for (int i = 0; i < mainPanel.getWidgetCount(); i++) {
|
||||
SingleUserTemplate ut = (SingleUserTemplate) mainPanel.getWidget(i);
|
||||
if (i == displayIndex) {
|
||||
ut.addStyleName("pickperson-selected");
|
||||
displayIndexSelected = i;
|
||||
//GWT.log("Selected: "+ut.getFullName());
|
||||
}
|
||||
else
|
||||
ut.removeStyleName("pickperson-selected");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ public class TagBox extends TextBox {
|
|||
this.setStylePrimaryName("user-token");
|
||||
getElement().setAttribute("value", text);
|
||||
//random heuristic, the "i" and "l" char occupies very few px :)
|
||||
int iCounter = 12 - 2*(text.split("i").length + (text.split("l").length));
|
||||
int iCounter = 14 - 2*(text.split("i").length + (text.split("l").length));
|
||||
setWidth((text.length()*6+iCounter)+"px");
|
||||
setReadOnly(true);
|
||||
}
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
package org.gcube.portlets.user.shareupdates.client.events;
|
||||
|
||||
import org.gcube.portlets.user.shareupdates.shared.PickingUser;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
|
||||
|
||||
public class PickedUserEvent extends GwtEvent<PickedUserEventHandler> {
|
||||
public static Type<PickedUserEventHandler> TYPE = new Type<PickedUserEventHandler>();
|
||||
|
||||
private PickingUser user;
|
||||
|
||||
|
||||
public PickingUser getSelectedUser() {
|
||||
return user;
|
||||
}
|
||||
public PickedUserEvent(PickingUser user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<PickedUserEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatch(PickedUserEventHandler handler) {
|
||||
handler.onSelectedUser(this);
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package org.gcube.portlets.user.shareupdates.client.events;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
public interface PickedUserEventHandler extends EventHandler {
|
||||
void onSelectedUser(PickedUserEvent event);
|
||||
}
|
|
@ -129,26 +129,27 @@ public class ShareUpdateForm extends Composite {
|
|||
|
||||
@UiHandler("submitButton")
|
||||
void onClick(ClickEvent e) {
|
||||
shareupdateService.getUserSettings(new AsyncCallback<UserSettings>() {
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert("Ops! we encountered some problems delivering your message, server is not responding, please try again in a short while.");
|
||||
}
|
||||
public void onSuccess(UserSettings result) {
|
||||
if (result.getUserInfo().getUsername().equals("test.user")) {
|
||||
Window.alert("Your session has expired, please log out and login again");
|
||||
return;
|
||||
}
|
||||
myUserInfo = result.getUserInfo();
|
||||
String toShare = shareTextArea.getText().trim();
|
||||
if (toShare.equals(SHARE_UPDATE_TEXT) || toShare.equals(ERROR_UPDATE_TEXT) || toShare.equals("")) {
|
||||
shareTextArea.addStyleName("error");
|
||||
shareTextArea.setText(ERROR_UPDATE_TEXT);
|
||||
return;
|
||||
}
|
||||
//then you can post
|
||||
postTweet(toShare);
|
||||
}
|
||||
});
|
||||
Window.alert("Please wait, Implementation to be completed");
|
||||
// shareupdateService.getUserSettings(new AsyncCallback<UserSettings>() {
|
||||
// public void onFailure(Throwable caught) {
|
||||
// Window.alert("Ops! we encountered some problems delivering your message, server is not responding, please try again in a short while.");
|
||||
// }
|
||||
// public void onSuccess(UserSettings result) {
|
||||
// if (result.getUserInfo().getUsername().equals("test.user")) {
|
||||
// Window.alert("Your session has expired, please log out and login again");
|
||||
// return;
|
||||
// }
|
||||
// myUserInfo = result.getUserInfo();
|
||||
// String toShare = shareTextArea.getText().trim();
|
||||
// if (toShare.equals(SHARE_UPDATE_TEXT) || toShare.equals(ERROR_UPDATE_TEXT) || toShare.equals("")) {
|
||||
// shareTextArea.addStyleName("error");
|
||||
// shareTextArea.setText(ERROR_UPDATE_TEXT);
|
||||
// return;
|
||||
// }
|
||||
// //then you can post
|
||||
// postTweet(toShare);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
package org.gcube.portlets.user.shareupdates.client.form;
|
||||
|
||||
import org.gcube.portlets.user.shareupdates.client.dialog.PickUsersDialog;
|
||||
import org.gcube.portlets.user.shareupdates.shared.PickingUser;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.MouseOverEvent;
|
||||
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.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.FocusPanel;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
public class SingleUserTemplate extends Composite {
|
||||
|
||||
private static LikedTemplateUiBinder uiBinder = GWT
|
||||
.create(LikedTemplateUiBinder.class);
|
||||
|
||||
interface LikedTemplateUiBinder extends UiBinder<Widget, SingleUserTemplate> {
|
||||
}
|
||||
PickUsersDialog owner;
|
||||
private int currDisplayIndex;
|
||||
|
||||
@UiField
|
||||
FocusPanel focusDiv;
|
||||
@UiField
|
||||
Image avatarImage;
|
||||
@UiField
|
||||
HTML contentArea;
|
||||
|
||||
public SingleUserTemplate(PickUsersDialog owner, PickingUser user, int displayIndex) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.owner = owner;
|
||||
currDisplayIndex = displayIndex;
|
||||
if (user.getThumbnailURL() != null)
|
||||
avatarImage.setUrl(user.getThumbnailURL());
|
||||
|
||||
avatarImage.setPixelSize(30, 30);
|
||||
contentArea.setHTML(user.getFullName());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@UiHandler("focusDiv")
|
||||
void onMouseOver(MouseOverEvent e) {
|
||||
owner.select(currDisplayIndex);
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return contentArea.getText();
|
||||
}
|
||||
}
|
|
@ -1,22 +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:FocusPanel ui:field="focusDiv" styleName="user-table pickperson">
|
||||
<g:HTMLPanel ui:field="mainDiv">
|
||||
<div class="user-table-row">
|
||||
<div class="user-table-col smallphoto">
|
||||
<a href="">
|
||||
<g:Image title="" styleName="pickperson-photo" url=""
|
||||
ui:field="avatarImage" width="30px" height="30px" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="user-table-col content">
|
||||
<div>
|
||||
<g:HTML styleName="pick-label" ui:field="contentArea" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</g:HTMLPanel>
|
||||
</g:FocusPanel>
|
||||
</ui:UiBinder>
|
|
@ -3,12 +3,17 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.shareupdates.client.form;
|
||||
|
||||
import org.gcube.portlets.user.shareupdates.client.dialog.PickUsersDialog;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.pickuser.client.dialog.PickUsersDialog;
|
||||
import org.gcube.portlets.user.pickuser.client.events.PickedUserEvent;
|
||||
import org.gcube.portlets.user.pickuser.client.events.PickedUserEventHandler;
|
||||
import org.gcube.portlets.user.pickuser.shared.PickingUser;
|
||||
import org.gcube.portlets.user.shareupdates.client.ShareUpdateService;
|
||||
import org.gcube.portlets.user.shareupdates.client.ShareUpdateServiceAsync;
|
||||
import org.gcube.portlets.user.shareupdates.client.elements.ContentEditDiv;
|
||||
import org.gcube.portlets.user.shareupdates.client.elements.Span;
|
||||
import org.gcube.portlets.user.shareupdates.client.elements.TagBox;
|
||||
import org.gcube.portlets.user.shareupdates.client.events.PickedUserEvent;
|
||||
import org.gcube.portlets.user.shareupdates.client.events.PickedUserEventHandler;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.DomEvent;
|
||||
|
@ -17,17 +22,27 @@ import com.google.gwt.event.shared.HandlerManager;
|
|||
import com.google.gwt.user.client.DOM;
|
||||
import com.google.gwt.user.client.Event;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
|
||||
/**
|
||||
* @author massi
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
*
|
||||
* SmartTextArea allows pasting of links with preview generation and tagging of people
|
||||
*
|
||||
*/
|
||||
public class SmartTextArea extends ContentEditDiv {
|
||||
/**
|
||||
* Create a remote service proxy to talk to the server-side Greeting service.
|
||||
*/
|
||||
private final ShareUpdateServiceAsync shareupdateService = GWT
|
||||
.create(ShareUpdateService.class);
|
||||
private final HandlerManager eventBus = new HandlerManager(null);
|
||||
|
||||
public final static int ARROW_UP = 38;
|
||||
public final static int ARROW_DOWN = 40;
|
||||
PickUsersDialog pickUserDlg = new PickUsersDialog(eventBus);
|
||||
PickUsersDialog pickUserDlg;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -37,6 +52,18 @@ public class SmartTextArea extends ContentEditDiv {
|
|||
sinkEvents(Event.ONCONTEXTMENU);
|
||||
sinkEvents(Event.ONKEYUP);
|
||||
sinkEvents(Event.ONKEYDOWN);
|
||||
|
||||
shareupdateService.getPortalUsers(new AsyncCallback<ArrayList<PickingUser>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(ArrayList<PickingUser> users) {
|
||||
pickUserDlg = new PickUsersDialog(users, eventBus, 525);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,6 +82,17 @@ public class SmartTextArea extends ContentEditDiv {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String extractLink(String textToCheck) {
|
||||
String [] parts = textToCheck.split("\\s");
|
||||
// Attempt to convert each item into an URL.
|
||||
for( String item : parts ) {
|
||||
if (item.startsWith("http")) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* paste and other events overridden
|
||||
*/
|
||||
|
@ -62,13 +100,19 @@ public class SmartTextArea extends ContentEditDiv {
|
|||
super.onBrowserEvent(event);
|
||||
switch (event.getTypeInt()) {
|
||||
case Event.ONPASTE: {
|
||||
final String before = getText();
|
||||
final String before = getHTML();
|
||||
GWT.log("BEFORE:" + before);
|
||||
Timer t = new Timer() {
|
||||
@Override
|
||||
public void run() {
|
||||
String toCheck = getText().replaceAll(before, "");
|
||||
ShareUpdateForm.get().checkLink(toCheck);
|
||||
String toCheck = extractLink(getText());
|
||||
if (toCheck != null) {
|
||||
GWT.log("toCheck1:" + toCheck);
|
||||
ShareUpdateForm.get().checkLink(new HTML(toCheck).getText());
|
||||
String sanitized = before + toCheck;
|
||||
setHTML(sanitized);
|
||||
setEndOfContenteditable();
|
||||
}
|
||||
}
|
||||
};
|
||||
t.schedule(100);
|
||||
|
@ -79,7 +123,7 @@ public class SmartTextArea extends ContentEditDiv {
|
|||
break;
|
||||
}
|
||||
case Event.ONKEYUP: {
|
||||
pickUserDlg.onKeyUp(event, this.getAbsoluteLeft(), this.getAbsoluteTop()+65, getText());
|
||||
pickUserDlg.onKeyUp(event.getKeyCode(), this.getAbsoluteLeft(), this.getAbsoluteTop()+65, getText());
|
||||
break;
|
||||
}
|
||||
case Event.ONKEYDOWN: { //avoid the arrow up to move the cursor at the beginning of the textbox and the TAB to move around inputs and enter to go newline
|
||||
|
|
|
@ -30,14 +30,25 @@ import org.gcube.portal.databook.shared.FeedType;
|
|||
import org.gcube.portal.databook.shared.PrivacyLevel;
|
||||
import org.gcube.portal.databook.shared.UserInfo;
|
||||
import org.gcube.portal.databook.shared.ex.FeedIDNotFoundException;
|
||||
import org.gcube.portlets.user.homelibrary.home.HomeLibrary;
|
||||
import org.gcube.portlets.user.homelibrary.home.User;
|
||||
import org.gcube.portlets.user.homelibrary.home.exceptions.HomeNotFoundException;
|
||||
import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||
import org.gcube.portlets.user.pickuser.shared.PickingUser;
|
||||
import org.gcube.portlets.user.shareupdates.client.ShareUpdateService;
|
||||
import org.gcube.portlets.user.shareupdates.server.metaseeker.MetaSeeker;
|
||||
import org.gcube.portlets.user.shareupdates.server.opengraph.OpenGraph;
|
||||
import org.gcube.portlets.user.shareupdates.shared.LinkPreview;
|
||||
import org.gcube.portlets.user.shareupdates.shared.UserSettings;
|
||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
|
||||
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager;
|
||||
import org.gcube.vomanagement.usermanagement.model.GroupModel;
|
||||
import org.gcube.vomanagement.usermanagement.model.UserModel;
|
||||
import org.htmlparser.beans.StringBean;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
@ -49,8 +60,6 @@ import com.liferay.portal.kernel.exception.SystemException;
|
|||
import com.liferay.portal.kernel.util.WebKeys;
|
||||
import com.liferay.portal.model.Organization;
|
||||
import com.liferay.portal.model.Role;
|
||||
import com.liferay.portal.model.User;
|
||||
import com.liferay.portal.model.UserModel;
|
||||
import com.liferay.portal.service.OrganizationLocalServiceUtil;
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
import com.liferay.portal.theme.ThemeDisplay;
|
||||
|
@ -228,7 +237,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
|
||||
if (withinPortal) {
|
||||
getUserVREs(username);
|
||||
UserModel user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), username);
|
||||
com.liferay.portal.model.UserModel user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), username);
|
||||
thumbnailURL = "/image/user_male_portrait?img_id="+user.getPortraitId();
|
||||
fullName = user.getFirstName() + " " + user.getLastName();
|
||||
email = user.getEmailAddress();
|
||||
|
@ -285,7 +294,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
* @throws PortalException
|
||||
*/
|
||||
private boolean isAdmin() throws PortalException, SystemException {
|
||||
User currUser = OrganizationsUtil.validateUser(getASLSession().getUsername());
|
||||
com.liferay.portal.model.User currUser = OrganizationsUtil.validateUser(getASLSession().getUsername());
|
||||
List<Organization> organizations = OrganizationLocalServiceUtil.getOrganizations(0, OrganizationLocalServiceUtil.getOrganizationsCount());
|
||||
Organization rootOrganization = null;
|
||||
for (Organization organization : organizations) {
|
||||
|
@ -312,7 +321,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
* @return
|
||||
* @throws SystemException
|
||||
*/
|
||||
private boolean hasRole(String rolename, String organizationName, User user) throws SystemException {
|
||||
private boolean hasRole(String rolename, String organizationName, com.liferay.portal.model.User user) throws SystemException {
|
||||
for (Role role : user.getRoles())
|
||||
if (role.getName().compareTo(rolename) == 0 )
|
||||
return true;
|
||||
|
@ -325,7 +334,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
*/
|
||||
private ArrayList<GroupModel> getUserVREs(String username) {
|
||||
ArrayList<GroupModel> toReturn = new ArrayList<GroupModel>();
|
||||
User currUser;
|
||||
com.liferay.portal.model.User currUser;
|
||||
try {
|
||||
GroupManager gm = new LiferayGroupManager();
|
||||
currUser = OrganizationsUtil.validateUser(username);
|
||||
|
@ -587,4 +596,64 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
private boolean isInfrastructureScope() {
|
||||
return getASLSession().getScope().isInfrastructure();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<PickingUser> getPortalUsers() {
|
||||
ArrayList<PickingUser> portalUsers = new ArrayList<PickingUser>();
|
||||
try {
|
||||
if (withinPortal) {
|
||||
UserManager um = new LiferayUserManager();
|
||||
Workspace workspace = getWorkspace();
|
||||
List<User> users = workspace.getHome().getHomeManager().getUsers();
|
||||
for (User user : users) {
|
||||
_log.trace("Trying to get additional info for "+user.getPortalLogin());
|
||||
if (user.getPortalLogin().compareTo("test.user") != 0) { //skip test.user
|
||||
UserModel curr = null;
|
||||
String thumbnailURL = "";
|
||||
try {
|
||||
curr = um.getUserByScreenName(user.getPortalLogin());
|
||||
com.liferay.portal.model.UserModel lifeUser = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), user.getPortalLogin());
|
||||
thumbnailURL = "/image/user_male_portrait?img_id="+lifeUser.getPortraitId();
|
||||
} catch (UserManagementPortalException ume) {
|
||||
_log.error("Error while getUserByScreenName for " + user.getPortalLogin());
|
||||
portalUsers.add(new PickingUser(user.getId(), user.getPortalLogin(), user.getPortalLogin(), "unknown image"));
|
||||
}
|
||||
if (curr != null)
|
||||
portalUsers.add(new PickingUser(user.getId(), curr.getScreenName(), curr.getFullname(), thumbnailURL));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else { //test users
|
||||
portalUsers.add(new PickingUser("11111", "massimiliano.assante", "Massimiliano Assante", "image"));
|
||||
portalUsers.add(new PickingUser("11111", "massimiliano.assante", "Massimiliano Pazzante", "image"));
|
||||
portalUsers.add(new PickingUser("11111", "massimiliano.assante", "Massimiliano Ruzzante", "image"));
|
||||
portalUsers.add(new PickingUser("11111", "massimiliano.assante", "Massimiliano Cantante", "image"));
|
||||
portalUsers.add(new PickingUser("11111", "massimiliano.assante", "Massimiliano Ballerino", "image"));
|
||||
portalUsers.add(new PickingUser("11111", "massimiliano.assante", "Massimiliano Violante", "image"));
|
||||
portalUsers.add(new PickingUser("11111", "giogio.giorgi", "Giorgio Giorgietti", "image"));
|
||||
portalUsers.add(new PickingUser("2222", "pino.pinetti", "Pino Dall'ara", "image"));
|
||||
portalUsers.add(new PickingUser("11333111", "rino.gattuso", "Rino Gattuso", "image"));
|
||||
portalUsers.add(new PickingUser("114444111", "alex.delpiero", "Alessandro Del Piero", "image"));
|
||||
portalUsers.add(new PickingUser("3462", "sandro.nesta", "Alessandro Nesta", "image"));
|
||||
portalUsers.add(new PickingUser("11464321", "samsung.mobile", "Samsung Mobile", "image"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
_log.error("Error in server get all contacts ", e);
|
||||
}
|
||||
return portalUsers;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return the workspace instance
|
||||
* @throws InternalErrorException
|
||||
* @throws HomeNotFoundException
|
||||
* @throws WorkspaceFolderNotFoundException
|
||||
*/
|
||||
private Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException {
|
||||
final ASLSession session = getASLSession();
|
||||
Workspace workspace = HomeLibrary.getUserWorkspace(session);
|
||||
return workspace;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
package org.gcube.portlets.user.shareupdates.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class PickingUser implements Serializable {
|
||||
private String id;
|
||||
private String username;
|
||||
private String fullName;
|
||||
private String thumbnailURL;
|
||||
|
||||
public PickingUser() {
|
||||
super();
|
||||
}
|
||||
public PickingUser(String id, String username, String fullName, String thumbnailURL) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
this.fullName = fullName;
|
||||
this.thumbnailURL = thumbnailURL;
|
||||
}
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public String getThumbnailURL() {
|
||||
return thumbnailURL;
|
||||
}
|
||||
public void setThumbnailURL(String thumbnailURL) {
|
||||
this.thumbnailURL = thumbnailURL;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PickingUser [id=" + id + ", username=" + username
|
||||
+ ", fullName=" + fullName + ", thumbnailURL=" + thumbnailURL
|
||||
+ "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -18,7 +18,7 @@
|
|||
<!-- Other module inherits -->
|
||||
|
||||
<inherits name='org.gcube.portal.databook.GCubeSocialNetworking' />
|
||||
|
||||
<inherits name='org.gcube.portlets.user.pickuser.PickUser' />
|
||||
<!-- Specify the app entry point class. -->
|
||||
<entry-point class='org.gcube.portlets.user.shareupdates.client.ShareUpdates' />
|
||||
|
||||
|
|
|
@ -142,6 +142,7 @@ a.link:hover {
|
|||
-webkit-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
letter-spacing: normal;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.dark-color {
|
||||
|
@ -186,89 +187,14 @@ a.link:hover {
|
|||
-webkit-transition: background .45s ease-in-out;
|
||||
}
|
||||
|
||||
/* smart textarea */
|
||||
|
||||
/* Pick User Dialog part */
|
||||
|
||||
.pickDialog {
|
||||
border: 1px solid #333;
|
||||
background-color: #FFF;
|
||||
}
|
||||
|
||||
.pick-label {
|
||||
font-family: 'Helvetica Neue', Arial, sans-serif;
|
||||
font-size: 15x;
|
||||
line-height: 18px;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
|
||||
.pickperson {
|
||||
color: #0B61A4;
|
||||
cursor: pointer;
|
||||
cursor: hand;
|
||||
background: #FFF;
|
||||
|
||||
-webkit-transition: background-color .25s ease-in-out;
|
||||
-moz-transition: background-color .25s ease-in-out;
|
||||
-o-transition: background-color .25s ease-in-out;
|
||||
transition: background-color .25s ease-in-out;
|
||||
}
|
||||
|
||||
.pickperson-selected {
|
||||
background-color: #033E6B;
|
||||
color: whitesmoke;
|
||||
}
|
||||
|
||||
.pickperson:active,.pickperson:focus,.pickperson:hover {
|
||||
background-color: #033E6B;
|
||||
color: whitesmoke;
|
||||
}
|
||||
|
||||
.pickperson-photo {
|
||||
display: block;
|
||||
padding: 2px;
|
||||
border: 1px solid #E6E6E6;
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
.user-table {
|
||||
margin: 1px 0px;
|
||||
display: table;
|
||||
width: 100%;
|
||||
background-clip: border-box;
|
||||
background-image: none;
|
||||
background-origin: padding-box;
|
||||
}
|
||||
|
||||
.user-table-row {
|
||||
display: table-row;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.user-table-col {
|
||||
display: table-cell;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.user-table-col.content {
|
||||
padding: 10px 0px 0px 10px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.user-table-col.smallphoto {
|
||||
width: 40px;
|
||||
}
|
||||
|
||||
.user-token {
|
||||
margin: 3px;
|
||||
height: auto !important;
|
||||
padding: 1px 3px;
|
||||
background-color: #E2E6F0 !important;
|
||||
border: 1px solid #9DACCC;
|
||||
color: #1C2A47;
|
||||
cursor: default;
|
||||
#mycontentEditableElement input[type="text"] {
|
||||
font-family: verdana, arial, sans-serif;
|
||||
font-size: 11px;
|
||||
padding: 1px 3px;
|
||||
color: #1C2A47;
|
||||
border: 1px solid #9DACCC;
|
||||
border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
|
|
Loading…
Reference in New Issue