pickUserDialog to finish
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@73237 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c28c06c2c5
commit
700efdcf64
|
@ -0,0 +1,29 @@
|
|||
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.form.SingleUserTemplate;
|
||||
|
||||
import com.google.gwt.user.client.ui.PopupPanel;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
|
||||
public class PickUsersDialog extends PopupPanel {
|
||||
|
||||
private VerticalPanel mainPanel = new VerticalPanel();
|
||||
|
||||
public PickUsersDialog() {
|
||||
super(true, false);
|
||||
setWidth("515px");
|
||||
setWidget(mainPanel);
|
||||
setStyleName("pickDialog");
|
||||
}
|
||||
|
||||
public void fill(ArrayList<String> users) {
|
||||
for (String user : users) {
|
||||
mainPanel.add(new SingleUserTemplate(new Like("", "", new Date(), "", user, "")));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package org.gcube.portlets.user.shareupdates.client.elements;
|
||||
|
||||
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
|
||||
*
|
||||
*/
|
||||
public class Div extends HTML implements HasText {
|
||||
|
||||
public Div() {
|
||||
super(DOM.createElement("div"));
|
||||
//important to make it act like a textarea
|
||||
DOM.setElementAttribute(getElement(), "contentEditable", "true");
|
||||
}
|
||||
|
||||
public Div(String text) {
|
||||
this();
|
||||
setText(text);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
DOM.setElementPropertyBoolean(getElement(), "disabled", !enabled);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package org.gcube.portlets.user.shareupdates.client.elements;
|
||||
|
||||
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 Span extends HTML implements HasText {
|
||||
|
||||
public Span() {
|
||||
super(DOM.createElement("span"));
|
||||
}
|
||||
|
||||
public Span(String text) {
|
||||
this();
|
||||
setText(text);
|
||||
}
|
||||
}
|
|
@ -3,59 +3,103 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.shareupdates.client.form;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.shareupdates.client.dialog.PickUsersDialog;
|
||||
import org.gcube.portlets.user.shareupdates.client.elements.Div;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Element;
|
||||
import com.google.gwt.user.client.Event;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.ui.TextArea;
|
||||
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author massi
|
||||
*
|
||||
*/
|
||||
public class MyTextArea extends TextArea {
|
||||
public class MyTextArea extends Div {
|
||||
final MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
|
||||
int limit = 10;
|
||||
|
||||
void showSuggestions(String query) {
|
||||
if (query.length() > 0) {
|
||||
oracle.requestSuggestions(new Request(query, limit), new Callback() {
|
||||
public void onSuggestionsReady(Request request, Response response) {
|
||||
for (Suggestion s : response.getSuggestions()) {
|
||||
GWT.log("s:"+s.getReplacementString());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
PickUsersDialog pickUserDlg = new PickUsersDialog();
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public MyTextArea() {
|
||||
sinkEvents(Event.ONPASTE);
|
||||
sinkEvents(Event.ONCONTEXTMENU);
|
||||
}
|
||||
sinkEvents(Event.ONKEYUP);
|
||||
|
||||
/**
|
||||
* @param element
|
||||
*/
|
||||
public MyTextArea(Element element) {
|
||||
super(element);
|
||||
ArrayList<String> users = new ArrayList<String>();
|
||||
users.add("Massi");
|
||||
users.add("Gino");
|
||||
users.add("Marco");
|
||||
users.add("Franco");
|
||||
users.add("Anna");
|
||||
users.add("Antonio");
|
||||
pickUserDlg.fill(users);
|
||||
|
||||
oracle.add("Massi");
|
||||
oracle.add("Gino");
|
||||
oracle.add("Marco");
|
||||
oracle.add("Franco");
|
||||
oracle.add("Anna");
|
||||
oracle.add("Antonio");
|
||||
}
|
||||
|
||||
/**
|
||||
* paste event overridden
|
||||
*/
|
||||
public void onBrowserEvent(Event event) {
|
||||
super.onBrowserEvent(event);
|
||||
switch (event.getTypeInt()) {
|
||||
case Event.ONPASTE: {
|
||||
final String before = getText();
|
||||
GWT.log("BEFORE:" + before);
|
||||
Timer t = new Timer() {
|
||||
@Override
|
||||
public void run() {
|
||||
String toCheck = getText().replaceAll(before, "");
|
||||
ShareUpdateForm.get().checkLink(toCheck);
|
||||
}
|
||||
};
|
||||
t.schedule(100);
|
||||
break;
|
||||
}
|
||||
case Event.ONCONTEXTMENU: {
|
||||
removeSampleText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
super.onBrowserEvent(event);
|
||||
switch (event.getTypeInt()) {
|
||||
case Event.ONPASTE: {
|
||||
final String before = getText();
|
||||
GWT.log("BEFORE:" + before);
|
||||
Timer t = new Timer() {
|
||||
@Override
|
||||
public void run() {
|
||||
String toCheck = getText().replaceAll(before, "");
|
||||
ShareUpdateForm.get().checkLink(toCheck);
|
||||
}
|
||||
};
|
||||
t.schedule(100);
|
||||
break;
|
||||
}
|
||||
case Event.ONCONTEXTMENU: {
|
||||
removeSampleText();
|
||||
break;
|
||||
}
|
||||
case Event.ONKEYUP: {
|
||||
final String before = getText();
|
||||
//showSuggestions(before);
|
||||
if (before.endsWith("@")) { //the only way i found to intercept @
|
||||
pickUserDlg.setPopupPosition(this.getAbsoluteLeft(), this.getAbsoluteTop()+65);
|
||||
pickUserDlg.show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void removeSampleText() {
|
||||
if (getText().equals(ShareUpdateForm.SHARE_UPDATE_TEXT) || getText().equals(ShareUpdateForm.ERROR_UPDATE_TEXT) ) {
|
||||
setText("");
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package org.gcube.portlets.user.shareupdates.client.form;
|
||||
|
||||
import org.gcube.portal.databook.client.GCubeSocialNetworking;
|
||||
import org.gcube.portal.databook.shared.Like;
|
||||
|
||||
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.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> {
|
||||
}
|
||||
|
||||
public SingleUserTemplate(Like like) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
if (like.getThumbnailURL() != null)
|
||||
avatarImage.setUrl(like.getThumbnailURL());
|
||||
|
||||
avatarImage.setPixelSize(30, 30);
|
||||
contentArea.setHTML("<a class=\"person-link\" style=\"font-size:16px;\" href=\""+GCubeSocialNetworking.USER_PROFILE_LINK+"\">"+like.getFullName()+"</a> ");
|
||||
}
|
||||
@UiField
|
||||
Image avatarImage;
|
||||
@UiField
|
||||
HTML contentArea;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<!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 ui:field="mainHTML">
|
||||
<div class="user-table-500">
|
||||
<div class="user-table-row">
|
||||
<div class="user-table-col smallphoto">
|
||||
<a href="">
|
||||
<g:Image title="" styleName="member-photo" url=""
|
||||
ui:field="avatarImage" width="30px" height="30px" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="user-table-col content">
|
||||
<div class="liked-person">
|
||||
<g:HTML styleName="" ui:field="contentArea" />
|
||||
</div>
|
||||
<div class="liked-aux">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</g:HTMLPanel>
|
||||
</ui:UiBinder>
|
|
@ -98,9 +98,9 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
|
||||
if (user == null) {
|
||||
_log.warn("USER IS NULL setting test.user and Running OUTSIDE PORTAL");
|
||||
user = "test.user";
|
||||
// user = "massimiliano.assante";
|
||||
// SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE");
|
||||
// user = "test.user";
|
||||
user = "massimiliano.assante";
|
||||
SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE");
|
||||
withinPortal = false;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -137,8 +137,7 @@ a.link:hover {
|
|||
font-size: 13px;
|
||||
padding: 4px 2px;
|
||||
width: 99%;
|
||||
border-color: #999;
|
||||
border-width: 1px;
|
||||
border: 1px solid #999;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
|
@ -186,3 +185,67 @@ a.link:hover {
|
|||
-moz-transition: background .45s ease-in-out;
|
||||
-webkit-transition: background .45s ease-in-out;
|
||||
}
|
||||
|
||||
|
||||
/* Pick User Dialog part */
|
||||
|
||||
.pickDialog {
|
||||
border: 1px solid #333;
|
||||
background-color: #FFF;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.liked-person {
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
a.person-link {
|
||||
font-family: 'Helvetica Neue', Arial, sans-serif;
|
||||
font-size: 16x;
|
||||
line-height: 18px;
|
||||
color: #3B5998;
|
||||
}
|
||||
|
||||
a.person-link,a.person-link:visited {
|
||||
cursor: pointer;
|
||||
cursor: hand;
|
||||
font-size: 16x;
|
||||
text-decoration: none;
|
||||
color: #3B5998;
|
||||
}
|
||||
|
||||
a.person-link:hover {
|
||||
opacity: 0.8;
|
||||
font-size: 16x;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
|
||||
.user-table-500 {
|
||||
margin-top: 3px;
|
||||
display: table;
|
||||
width: 500px;
|
||||
background-clip: border-box;
|
||||
background-image: none;
|
||||
background-origin: padding-box;
|
||||
padding: 12px 7px 3px 7px;
|
||||
}
|
||||
|
||||
.user-table-row {
|
||||
display: table-row;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.user-table-col {
|
||||
display: table-cell;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.user-table-col.content {
|
||||
padding-left: 10px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.user-table-col.smallphoto {
|
||||
width: 40px;
|
||||
}
|
Loading…
Reference in New Issue