Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

changes for commenting

  • Loading branch information...
commit 84bd0bf94f741d9ec22754dc3f7b1e5ffaf23b23 1 parent e12cb34
@lfaggioli lfaggioli authored
View
24 src/org/onesocialweb/gwt/client/ui/widget/activity/AbstractActivityPanel.java
@@ -12,6 +12,13 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
+ * 2010-08-17 Modified by Luca Faggioli Copyright 2010 Openliven S.r.l
+ *
+ * added addEmptyModelMessage so that nothing is shown in the subclass
+ * RepliesPanel when the model is empty and getModelItems() so we can
+ * sort the activities in RepliesPanel (for replies we put the oldest
+ * on the top and the newest at the bottom
*
*/
package org.onesocialweb.gwt.client.ui.widget.activity;
@@ -32,7 +39,7 @@
public abstract class AbstractActivityPanel<T> extends FlowPanel {
- private Stream<T> model;
+ protected Stream<T> model;
private DefaultTaskInfo task;
@@ -50,9 +57,9 @@ public void setModel(Stream<T> model) {
protected void repaint() {
clear();
- List<T> items = model.getItems();
if (model.isReady()) {
+ List<T> items = getModelItems();
if (items.size() > 0) {
// render the items
for (int i = items.size(); i >= 1; i--) {
@@ -61,9 +68,7 @@ protected void repaint() {
}
} else {
// if there are no results
- StyledLabel msg = new StyledLabel("message",
- "There are no status updates available.");
- add(msg);
+ addEmptyModelMessage();
}
if (task != null) {
@@ -99,5 +104,14 @@ public void handleEvent(StreamEvent<T> event) {
}
}
+
+ protected void addEmptyModelMessage() {
+ StyledLabel msg = new StyledLabel("message",
+ "There are no status updates available.");
+ add(msg);
+ }
+ protected List<T> getModelItems() {
+ return model.getItems();
+ }
}
View
116 src/org/onesocialweb/gwt/client/ui/widget/activity/ActivityItemView.java
@@ -12,7 +12,10 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
+ * 2010-08-09 Modified by Luca Faggioli Copyright 2010 Openliven S.r.l
+ * added code to handle comments (replies)
+ *
*/
package org.onesocialweb.gwt.client.ui.widget.activity;
@@ -29,6 +32,7 @@
import org.onesocialweb.gwt.client.ui.widget.StyledFlowPanel;
import org.onesocialweb.gwt.client.ui.widget.StyledLabel;
import org.onesocialweb.gwt.client.ui.widget.StyledTooltipImage;
+import org.onesocialweb.gwt.client.ui.widget.compose.CommentPanel;
import org.onesocialweb.gwt.client.ui.window.ProfileWindow;
import org.onesocialweb.gwt.client.util.FormatHelper;
import org.onesocialweb.gwt.service.OswService;
@@ -36,6 +40,7 @@
import org.onesocialweb.gwt.service.RequestCallback;
import org.onesocialweb.gwt.service.RosterEvent;
import org.onesocialweb.gwt.service.RosterItem;
+import org.onesocialweb.gwt.service.Stream;
import org.onesocialweb.gwt.service.RosterItem.Presence;
import org.onesocialweb.gwt.util.Observer;
import org.onesocialweb.model.acl.AclAction;
@@ -59,18 +64,25 @@
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Widget;
public class ActivityItemView extends FlowPanel implements MouseOverHandler,
HasMouseOverHandlers, MouseOutHandler, HasMouseOutHandlers {
private HTML statusLabel = new HTML();
private HTML infoLabel = new HTML();
+ private final RepliesPanel repliesPanel = new RepliesPanel();
+ private final CommentPanel commentPanel = new CommentPanel();
+
private StyledTooltipImage avatarImage = new StyledTooltipImage("", "link",
"View profile");
private StyledFlowPanel avatarwrapper = new StyledFlowPanel("avatarwrapper");
private StyledTooltipImage infoIcon = new StyledTooltipImage(OswClient
.getInstance().getPreference("theme_folder")
+ "assets/i-info.png", "icon", "");
+ private StyledTooltipImage emptyIcon = new StyledTooltipImage(OswClient
+ .getInstance().getPreference("theme_folder")
+ + "assets/i-empty.png", "icon", "");
private HorizontalPanel hpanel = new HorizontalPanel();
private FlowPanel attachmentswrapper = new StyledFlowPanel("attachments");
private StyledTooltipImage statusIcon = new StyledTooltipImage(OswClient
@@ -81,6 +93,13 @@
private ActivityButtonHandler handler;
private final ActivityEntry activity;
+ protected final StyledFlowPanel replieswrapper = new StyledFlowPanel("author-wrapper");
+
+ private String recipientActivityID = null;
+ //for notification we show the label that "this is a comment
+ //and we prevent the user to comment it itself
+ private boolean commentNotification = false;
+
public ActivityItemView(final ActivityEntry activity) {
this.activity = activity;
@@ -101,7 +120,13 @@ public ActivityItemView(final ActivityEntry activity) {
.iterator();
while (recipients.hasNext()) {
final AtomReplyTo recipient = recipients.next();
- final String recipientJID = recipient.getHref();
+
+ recipientActivityID = extractRecipientActivityID(recipient.getHref());
+ if(recipientActivityID != null) {
+ commentNotification = true;
+ }
+
+ final String recipientJID = extractRecipientJID(recipient.getHref());
final StyledLabel label = new StyledLabel("link", recipientJID);
label.setTitle("View profile of " + recipientJID);
@@ -153,6 +178,9 @@ public void onClick(ClickEvent event) {
flow.add(statuswrapper);
flow.add(attachmentswrapper);
flow.add(infowrapper);
+ flow.add(replieswrapper);
+ replieswrapper.add(emptyIcon);
+
hpanel.add(avatarwrapper);
avatarwrapper.getElement().setAttribute(
@@ -185,12 +213,44 @@ public void onClick(ClickEvent event) {
}
statusLabel.setText(" - " + activity.getTitle());
+
+ if(!commentNotification) {
+ if(activity.hasReplies()) {
+ final StyledLabel repliesLabel = new StyledLabel("replies-link", "Comments: " +
+ activity.getRepliesLink().getCount());
+
+ repliesLabel.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ commentPanel.compose(activity);
+ replieswrapper.add(commentPanel);
+ repliesLabel.setVisible(false);
+ }
+ });
+
+ replieswrapper.add(repliesLabel);
+ } else {
+ final StyledLabel repliesLabel = new StyledLabel("replies-link", "Add a comment");
+
+ repliesLabel.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ commentPanel.compose(activity);
+ replieswrapper.add(commentPanel);
+ repliesLabel.setVisible(false);
+ }
+ });
+
+ replieswrapper.add(repliesLabel);
+ }
+ }
+
String info = "";
info += getFormattedDate(activity.getPublished());
if (!visibility.isEmpty())
info += " - Visible to: " + FormatHelper.implode(visibility, ", ");
// if (location != "") info += " - From: " + location;
// if (tags != "") info += " - Tagged: " + tags;
+ if(commentNotification)
+ info += " - This is a comment to a previous post";
infoLabel.setText(info);
author.setTitle("View profile of " + activity.getActor().getUri());
@@ -285,6 +345,13 @@ public void handleEvent(RosterEvent event) {
}
}
+
+ public ActivityEntry getActivity() {
+ return activity;
+ }
+
+
+
public void onMouseOver(MouseOverEvent event) {
select();
}
@@ -318,6 +385,19 @@ public void setButtonHandler(ActivityButtonHandler handler) {
this.handler = handler;
}
+ @Override
+ protected void onLoad() {
+ super.onLoad();
+
+ if(commentNotification) {
+ Widget parent = getParent();
+ if(parent instanceof InboxPanel) {
+ InboxPanel inbox = (InboxPanel) parent;
+ inbox.updateActivityReplies(recipientActivityID);
+ }
+ }
+ }
+
private void select() {
addStyleName("selected");
handler.handleShow(this.getAbsoluteTop(), this);
@@ -494,4 +574,36 @@ private void setPresence(Presence presence) {
}
}
+ private String extractRecipientJID(String recipientHref) {
+ if(recipientHref.startsWith("xmpp:")) {
+ int i = recipientHref.indexOf("?");
+ if(i == -1) {
+ return "";
+ }
+ else {
+ return recipientHref.substring(5, i);
+ }
+ }
+ else {
+ return recipientHref;
+ }
+ }
+
+ private String extractRecipientActivityID(String recipientHref) {
+
+ if(recipientHref.startsWith("xmpp:")) {
+ int i = recipientHref.indexOf("item=");
+ if(i == -1) {
+ return null;
+ }
+ else {
+ return recipientHref.substring(i+5);
+ }
+ }
+ else {
+ return null;
+ }
+
+ }
+
}
View
36 src/org/onesocialweb/gwt/client/ui/widget/activity/FeedItemView.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2010 Openliven S.r.l.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Author: luca faggioli luca(dot)faggioli(at)openliven(dot)com
+ *
+ */
+package org.onesocialweb.gwt.client.ui.widget.activity;
+
+import org.onesocialweb.model.activity.ActivityEntry;
+
+
+public class FeedItemView extends ActivityItemView {
+
+
+ public FeedItemView(ActivityEntry activity) {
+ super(activity);
+
+ //prevent users to post comments
+ replieswrapper.clear();
+
+ }
+
+
+}
View
6 src/org/onesocialweb/gwt/client/ui/widget/activity/FeedPanel.java
@@ -13,6 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
+ * 2010-08-17 Modified by Luca Faggioli Copyright 2010 Openliven S.r.l
+ * replaced ActivityItemView with FeedItemView in order to prevent users
+ * to post comments to a comment
+ *
*/
package org.onesocialweb.gwt.client.ui.widget.activity;
@@ -37,7 +41,7 @@ public FeedPanel() {
@Override
protected Widget render(ActivityEntry activity) {
- ActivityItemView sa = new ActivityItemView(activity);
+ ActivityItemView sa = new FeedItemView(activity);
sa.setButtonHandler(new ActivityButtonHandler() {
public void handleShow(int top, ActivityItemView sa) {
View
58 src/org/onesocialweb/gwt/client/ui/widget/activity/InboxPanel.java
@@ -13,13 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
+ * 2010-08-19 Modified by Luca Faggioli Copyright 2010 Openliven S.r.l
+ * added updateActivityReplies()
+ *
*/
package org.onesocialweb.gwt.client.ui.widget.activity;
import org.onesocialweb.gwt.client.handler.ActivityButtonHandler;
+import org.onesocialweb.gwt.client.ui.widget.StyledFlowPanel;
+import org.onesocialweb.gwt.client.ui.widget.StyledLabel;
+import org.onesocialweb.gwt.client.ui.widget.compose.CommentPanel;
+import org.onesocialweb.gwt.service.OswServiceFactory;
+import org.onesocialweb.gwt.service.Stream;
import org.onesocialweb.model.activity.ActivityEntry;
import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.user.client.ui.WidgetCollection;
public class InboxPanel extends AbstractActivityPanel<ActivityEntry> {
@@ -35,6 +44,50 @@ public InboxPanel() {
buttons.setVisible(false);
}
+ public void updateActivityReplies(String activityID) {
+
+ Stream<ActivityEntry> replies = OswServiceFactory.getService().getReplies(activityID);
+
+ WidgetCollection activityWidgets = getChildren();
+ for(Widget widget: activityWidgets) {
+ if(widget instanceof ActivityItemView) {
+ ActivityItemView aiv = (ActivityItemView) widget;
+ if(activityID.equals(aiv.getActivity().getId())) {
+ StyledFlowPanel replieswrapper = aiv.replieswrapper;
+ int repliesWidgetCount = replieswrapper.getWidgetCount();
+ for(int i=0; i< repliesWidgetCount; i++) {
+ Widget w = replieswrapper.getWidget(i);
+ if(w instanceof CommentPanel) {
+ CommentPanel commentPanel = (CommentPanel) w;
+ RepliesPanel repliesPanel = commentPanel.getReplies();
+ repliesPanel.setModel(replies);
+ repliesPanel.repaint();
+ } else if(w instanceof StyledLabel) {
+ StyledLabel label = (StyledLabel) w;
+ if(label.isVisible()) {
+ String content = label.getHTML();
+ if("Add a comment".equals(content)) {
+ label.setHTML("Comments: 1");
+ } else {
+ content = content.substring(content.indexOf(":")+2);
+ try {
+ int numReplies = Integer.parseInt(content) + 1;
+ label.setHTML("Comments: " + numReplies);
+ } catch(NumberFormatException e) {
+ //never mind...simply do not change the number of comments in the GUI
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+
+ }
+
@Override
protected Widget render(ActivityEntry activityEntry) {
ActivityItemView sa = new ActivityItemView(activityEntry);
@@ -45,7 +98,10 @@ public void handleShow(int top, ActivityItemView sa) {
// always captured
if (lastSelected != null)
lastSelected.removeStyleName("selected");
- showButtons(top);
+
+ //we do not show the buttons since the functionalities are not implemented
+ //showButtons(top);
+
// force selecting the activity
if (!sa.getStyleName().equals("selected"))
sa.addStyleName("selected");
View
130 src/org/onesocialweb/gwt/client/ui/widget/activity/RepliesPanel.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2010 Openliven S.r.l.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * author luca faggioli luca(dot)faggioli(at)openliven(dot)com
+ *
+ */
+package org.onesocialweb.gwt.client.ui.widget.activity;
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+import org.onesocialweb.gwt.client.handler.ActivityButtonHandler;
+import org.onesocialweb.gwt.client.ui.widget.StyledLabel;
+import org.onesocialweb.gwt.service.Stream;
+import org.onesocialweb.model.activity.ActivityEntry;
+import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.user.client.ui.WidgetCollection;
+
+public class RepliesPanel extends AbstractActivityPanel<ActivityEntry> {
+
+ //private final ActivityButtons buttons = new ActivityButtons();
+
+ //private ActivityItemView lastSelected;
+
+ public RepliesPanel() {
+ }
+
+ public void addNewReplies() {
+
+ if(model.isReady()) {
+ List<ActivityEntry> items = getModelItems();
+ List<ActivityEntry> toBeRemoved = new ArrayList<ActivityEntry>();
+ for (ActivityEntry item : items) {
+ WidgetCollection children = this.getChildren();
+ if(children.size() == 0)
+ break;
+ Iterator it = children.iterator();
+ while(it.hasNext()) {
+ ReplyItemView riv = (ReplyItemView) it.next();
+ if(riv.getActivity().getId().equals(item.getId())) {
+ toBeRemoved.add(item);
+ break;
+ }
+ }
+ }
+ items.removeAll(toBeRemoved);
+ for (ActivityEntry item : items) {
+
+ Widget w = render(item);
+ if (w != null) {
+ if(getWidgetCount() == 0) {
+ insert(render(item), 0);
+ } else {
+ insert(render(item), getWidgetCount());
+ }
+ }
+ }
+ }
+ }
+
+
+ @Override
+ protected Widget render(ActivityEntry activityEntry) {
+ ActivityItemView sa = new ReplyItemView(activityEntry);
+
+ sa.setButtonHandler(new ActivityButtonHandler() {
+ public void handleShow(int top, ActivityItemView sa) {
+ }
+
+ public void handleHide() {
+ }
+ });
+
+ return sa;
+ }
+
+ @Override
+ public void repaint() {
+ addNewReplies();
+ }
+
+
+ @Override
+ protected void addEmptyModelMessage() {
+ //do nothing: we show nothing when the
+ //are no replies for the given activity
+ }
+
+ @Override
+ protected List<ActivityEntry> getModelItems() {
+
+ List<ActivityEntry> items = model.getItems();
+ Collections.sort(items, new ActivityComparator());
+ return items;
+
+ }
+
+ private class ActivityComparator implements Comparator<ActivityEntry> {
+
+ /*
+ * Compares activities based on the publishing date
+ * (non-Javadoc)
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public int compare(ActivityEntry activity1, ActivityEntry activity2) {
+ return activity1.getPublished().compareTo(activity2.getPublished());
+ }
+
+ }
+
+ //private Stream<ActivityEntry> oldModel;
+
+}
View
36 src/org/onesocialweb/gwt/client/ui/widget/activity/ReplyItemView.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2010 Openliven S.r.l.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Author: luca faggioli luca(dot)faggioli(at)openliven(dot)com
+ *
+ */
+package org.onesocialweb.gwt.client.ui.widget.activity;
+
+import org.onesocialweb.model.activity.ActivityEntry;
+
+
+public class ReplyItemView extends ActivityItemView {
+
+
+ public ReplyItemView(ActivityEntry activity) {
+ super(activity);
+
+ //prevent users to post comments
+ replieswrapper.clear();
+
+ }
+
+
+}
View
342 src/org/onesocialweb/gwt/client/ui/widget/compose/CommentPanel.java
@@ -0,0 +1,342 @@
+/*
+ * Copyright 2010 Openliven Srl.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Author: luca faggioli luca(dot)faggioli(at)openliven(dot)com
+ *
+ */
+package org.onesocialweb.gwt.client.ui.widget.compose;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+
+import org.onesocialweb.gwt.client.OswClient;
+import org.onesocialweb.gwt.client.handler.PictureHandler;
+import org.onesocialweb.gwt.client.task.DefaultTaskInfo;
+import org.onesocialweb.gwt.client.task.TaskMonitor;
+import org.onesocialweb.gwt.client.task.TaskInfo.Status;
+import org.onesocialweb.gwt.client.ui.dialog.PictureChooserDialog;
+import org.onesocialweb.gwt.client.ui.event.ComponentEvent;
+import org.onesocialweb.gwt.client.ui.event.ComponentHelper;
+import org.onesocialweb.gwt.client.ui.event.ComponentListener;
+import org.onesocialweb.gwt.client.ui.widget.activity.RepliesPanel;
+import org.onesocialweb.gwt.service.OswService;
+import org.onesocialweb.gwt.service.OswServiceFactory;
+import org.onesocialweb.gwt.service.RequestCallback;
+import org.onesocialweb.gwt.service.Stream;
+import org.onesocialweb.gwt.util.ListModel;
+import org.onesocialweb.model.acl.AclAction;
+import org.onesocialweb.model.acl.AclRule;
+import org.onesocialweb.model.acl.AclSubject;
+import org.onesocialweb.model.activity.ActivityEntry;
+import org.onesocialweb.model.activity.ActivityObject;
+import org.onesocialweb.model.activity.ActivityVerb;
+import org.onesocialweb.model.atom.AtomFactory;
+
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.Image;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.PushButton;
+
+public class CommentPanel extends Composite {
+
+ public static final String EVERYONE = "Everyone";
+
+ private final ListModel<ActivityObject> pictureAttachments = new ListModel<ActivityObject>();
+
+ private final ComponentHelper componentHelper = new ComponentHelper();
+
+ private final InternalComponentListener componentListener = new InternalComponentListener();
+
+ public CommentPanel() {
+ }
+
+
+ public void compose(ActivityEntry parentActivity) {
+ this.parentActivity = parentActivity;
+ composePanel();
+ }
+
+ public RepliesPanel getReplies() {
+ return replies;
+ }
+
+
+ public void reset() {
+ // Empty the text area
+ textareaUpdate.setText("");
+
+ // Tell the listener to ignore events, we´ll fire a single event when we
+ // are done
+ componentListener.setIgnoreEvent(true);
+
+ // Remove all attachments
+ pictureAttachmentPanel.reset();
+ //privacyAttachmentPanel.reset();
+
+ // And hide the panels
+ pictureAttachmentPanel.hide();
+ //privacyAttachmentPanel.hide();
+
+ // Fire a single resize event and reactivate the listener
+ componentHelper.fireComponentResized(this);
+ componentListener.setIgnoreEvent(false);
+ }
+
+ public void addComponentListener(ComponentListener listener) {
+ componentHelper.addComponentListener(listener);
+ }
+
+ public void removeComponentListener(ComponentListener listener) {
+ componentHelper.removeComponentListener(listener);
+ }
+
+ public void hide() {
+ if (isVisible()) {
+ setVisible(false);
+ fireComponentHidden();
+ }
+ }
+
+
+ protected void fireComponentHidden() {
+ componentHelper.fireComponentHidden(this);
+ }
+
+
+ // UI stuff
+ private void composePanel() {
+
+ // Init attachment dialogs
+ pictureChooserDialog = new PictureChooserDialog(new PictureHandler() {
+ public void handlePicture(String pictureUrl) {
+ if (pictureUrl != null && pictureUrl.length() > 0) {
+ OswService service = OswClient.getInstance().getService();
+ ActivityObject object = service.getActivityFactory()
+ .object(ActivityObject.PICTURE);
+ object.addLink(service.getAtomFactory().link(pictureUrl,
+ "alternate", null, null,0));
+ pictureAttachments.add(object);
+ }
+ }
+ });
+
+ Stream<ActivityEntry> repliesModel = OswServiceFactory.getService().getReplies(
+ parentActivity.getId());
+ replies.setModel(repliesModel);
+
+ // Add components to page
+ flow.add(addPhoto);
+ //flow.add(addPrivacy);
+ flow.add(buttonUpdate);
+
+ // Create panel
+ statusPanel.add(replies);
+ statusPanel.add(textareaUpdate);
+ statusPanel.add(attachmentsPanel);
+ statusPanel.add(flow);
+
+ // AttachmentsPanel
+ pictureAttachmentPanel = new PictureAttachmentPanel();
+ pictureAttachmentPanel.setModel(pictureAttachments);
+ pictureAttachmentPanel.addComponentListener(componentListener);
+ attachmentsPanel.add(pictureAttachmentPanel);
+
+ //privacyAttachmentPanel = new PrivacyAttachmentPanel();
+ //privacyAttachmentPanel.addComponentListener(componentListener);
+ //attachmentsPanel.add(privacyAttachmentPanel);
+
+ // Add CSS classes
+ buttonUpdate.addStyleName("buttonUpdate");
+ attachment.addStyleName("updateLabel");
+ flow.addStyleName("options");
+ attachmentsPanel.addStyleName("attachmentWrapper");
+ statusPanel.setStyleName("topPanel");
+
+ // Set tooltips
+ addPhoto.setTitle("Add picture");
+ //addPrivacy.setTitle("Change privacy (default: Everyone)");
+
+ initWidget(statusPanel);
+
+ buttonUpdate.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ postComment();
+ }
+ });
+
+
+ /*addPrivacy.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ privacyAttachmentPanel.show();
+ }
+ });*/
+
+ addPhoto.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ pictureChooserDialog.show();
+ }
+ });
+ }
+
+ private void postComment() {
+
+ buttonUpdate.setEnabled(false);
+ final OswService service = OswServiceFactory.getService();
+
+ Date now = new Date();
+ String status = textareaUpdate.getText();
+
+ if(status==null || "".equals(status))
+ return;
+
+ ActivityObject object = service.getActivityFactory().object(
+ ActivityObject.STATUS_UPDATE);
+ object.addContent(service.getAtomFactory().content(status,
+ "text/plain", null));
+ object.setPublished(now);
+
+ // the basics
+ ActivityEntry entry = service.getActivityFactory().entry();
+ entry.setTitle(status);
+ entry.addVerb(service.getActivityFactory().verb(ActivityVerb.POST));
+ entry.addObject(object);
+ entry.setPublished(now);
+
+ String href = "xmpp:"+parentActivity.getActor().getUri()+
+ "?;node=urn:xmpp:microblog:0;item="+parentActivity.getId();
+ entry.addLink(service.getAtomFactory().link(href, "alternate", null,
+ "text/html", 0));
+ entry.addRecipient(service.getAtomFactory().reply(parentActivity.getId(), href,
+ null, null));
+
+ // add attachments if there are any
+ for (ActivityObject current : pictureAttachments) {
+ entry.addObject(current);
+ }
+
+
+ /*
+ // setup access control
+ AclRule rule = service.getAclFactory().aclRule();
+ rule.addAction(service.getAclFactory().aclAction(AclAction.ACTION_VIEW,
+ AclAction.PERMISSION_GRANT));
+
+ // check privacy settings
+ String visibilityValue = privacyAttachmentPanel.getPrivacyValue();
+
+ if (visibilityValue.equals(EVERYONE)) {
+ rule.addSubject(service.getAclFactory().aclSubject(null,
+ AclSubject.EVERYONE));
+ } else {
+ rule.addSubject(service.getAclFactory().aclSubject(visibilityValue,
+ AclSubject.GROUP));
+ }
+ entry.addAclRule(rule);
+ */
+
+ // we got everything we need -> clean up UI
+ reset();
+
+
+ service.post(entry, new RequestCallback<ActivityEntry>() {
+
+ @Override
+ public void onFailure() {
+
+ }
+
+ @Override
+ public void onSuccess(ActivityEntry result) {
+
+ }
+
+ });
+
+
+ replies.setModel(service.getReplies(parentActivity.getId()));
+ replies.repaint();
+ buttonUpdate.setEnabled(true);
+
+ }
+
+
+ private PictureAttachmentPanel pictureAttachmentPanel;
+ //private PrivacyAttachmentPanel privacyAttachmentPanel;
+ private PictureChooserDialog pictureChooserDialog;
+
+ private final FlowPanel statusPanel = new FlowPanel();
+ private final FlowPanel attachmentsPanel = new FlowPanel();
+ private final FlowPanel flow = new FlowPanel();
+ private final RepliesPanel replies = new RepliesPanel();
+
+ private final Label attachment = new Label("Add:");
+ private final Button buttonUpdate = new Button("Post your comment");
+ private final TextareaUpdate textareaUpdate = new TextareaUpdate();
+
+ /*
+ private final PushButton addPrivacy = new PushButton(new Image(OswClient
+ .getInstance().getPreference("theme_folder")
+ + "assets/i-key.png"));
+ */
+ private final PushButton addPhoto = new PushButton(new Image(OswClient
+ .getInstance().getPreference("theme_folder")
+ + "assets/i-camera2.png"));
+
+ private ActivityEntry parentActivity;
+
+ private class InternalComponentListener implements ComponentListener {
+
+ private boolean ignoreEvent = false;
+
+ public void setIgnoreEvent(boolean ignoreEvent) {
+ this.ignoreEvent = ignoreEvent;
+ }
+
+ @Override
+ public void componentHidden(ComponentEvent e) {
+ if (!ignoreEvent) {
+ componentHelper.fireComponentHidden(e);
+ }
+ }
+
+ @Override
+ public void componentMoved(ComponentEvent e) {
+ if (!ignoreEvent) {
+ componentHelper.fireComponentMoved(e);
+ }
+ }
+
+ @Override
+ public void componentResized(ComponentEvent e) {
+ if (!ignoreEvent) {
+ componentHelper.fireComponentResized(e);
+ }
+ }
+
+ @Override
+ public void componentShown(ComponentEvent e) {
+ if (!ignoreEvent) {
+ componentHelper.fireComponentShown(e);
+ }
+ }
+
+ }
+
+}
View
2  src/org/onesocialweb/gwt/client/ui/widget/compose/NewActivityPanel.java
@@ -174,7 +174,7 @@ public void handlePicture(String pictureUrl) {
ActivityObject object = service.getActivityFactory()
.object(ActivityObject.PICTURE);
object.addLink(service.getAtomFactory().link(pictureUrl,
- "alternate", null, null));
+ "alternate", null, null, 1));
pictureAttachments.add(object);
}
}
View
BIN  war/themes/osw/assets/i-empty.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
18 war/themes/osw/styles/core.css
@@ -12,6 +12,9 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
+ * 2010-08-17 Modified by Luca Faggioli Copyright 2010 Openliven S.r.l
+ * added .replies-link
*
*/
@@ -419,6 +422,20 @@ img.logo {
cursor: pointer;
}
+.replies-link {
+ display: inline;
+ color: #4082D7;
+ cursor: pointer;
+ font-size: .7em;
+ margin: 0px 0px;
+ line-height: 100%;
+}
+
+.replies-link:hover {
+ text-decoration: underline;
+ cursor: pointer;
+}
+
/*
Suggestbox
*****************/
@@ -1222,6 +1239,7 @@ img.logo {
}
+
.statusActivity .gwt-HTML, .contact .gwt-HTML{
display: inline;
line-height: 120%;
Please sign in to comment.
Something went wrong with that request. Please try again.