use of de.catma.ui.client.ui.tagger.shared.ClientCommentReply in project catma by forTEXT.
the class CommentPanel method setLines.
public void setLines(List<Line> lines) {
for (CommentLinePanel panel : panels) {
remove(panel);
}
panels = new ArrayList<CommentLinePanel>(lines.size());
for (Line line : lines) {
CommentLinePanel panel = new CommentLinePanel(line, new CommentLinePanelListener() {
@Override
public void selected(ClientComment comment, Line line) {
CommentLinePanel selectedPanel = panels.get(line.getLineId());
for (CommentLinePanel panel : panels) {
if (!panel.equals(selectedPanel)) {
panel.deselect();
}
}
alignCommentLinePanels(selectedPanel);
commentPanelListener.showCommentHighlight(comment);
if (comment.getReplyCount() > 0) {
commentPanelListener.loadReplies(comment.getUuid());
}
}
@Override
public void edit(ClientComment comment, int x, int y) {
commentPanelListener.edit(comment, x, y);
}
@Override
public void remove(ClientComment comment) {
commentPanelListener.remove(comment);
}
@Override
public void replyTo(ClientComment comment, int x, int y) {
commentPanelListener.replyTo(comment, x, y);
}
@Override
public void edit(ClientComment comment, ClientCommentReply reply, int x, int y) {
commentPanelListener.edit(comment, reply, x, y);
}
@Override
public void remove(ClientComment comment, ClientCommentReply reply) {
commentPanelListener.remove(comment, reply);
}
@Override
public void repliesLoaded(ClientComment comment, Line line) {
CommentLinePanel selectedPanel = panels.get(line.getLineId());
alignCommentLinePanels(selectedPanel);
}
});
panels.add(panel);
add(panel);
panel.getElement().getStyle().setTop(line.getLineElement().getOffsetTop() - PANEL_OFFSET, Unit.PX);
}
}
use of de.catma.ui.client.ui.tagger.shared.ClientCommentReply in project catma by forTEXT.
the class VTagger method initComponents.
private void initComponents() {
taggerEditor = new TaggerEditor(new TaggerEditorListener() {
public void annotationChanged(TaggerEditorEventType type, Object... args) {
switch(type) {
case ADD:
{
ClientTagInstance tagInstance = (ClientTagInstance) args[0];
taggerListener.tagInstanceAdded(tagInstanceJSONSerializer.toJSONObject(tagInstance));
break;
}
case REMOVE:
{
String tagInstanceID = (String) args[0];
boolean reportToServer = (Boolean) args[1];
if (reportToServer) {
taggerListener.tagInstanceRemoved(tagInstanceID);
}
break;
}
}
}
public void annotationSelected(String tagInstancePartID, String lineID) {
taggerListener.tagInstanceSelected(tagInstanceJSONSerializer.toJSONArrayString(tagInstancePartID, lineID));
}
@Override
public void annotationsSelected(HashSet<String> tagInstanceIDs) {
taggerListener.tagInstancesSelected(tagInstanceJSONSerializer.toJSONArrayString(tagInstanceIDs));
}
public void logEvent(String event) {
logToServer(event);
}
@Override
public void contextMenuSelected(int x, int y) {
taggerListener.contextMenuSelected(x, y);
}
@Override
public void addComment(List<TextRange> ranges, int x, int y) {
taggerListener.addComment(ranges, x, y);
}
@Override
public void setAddCommentButtonVisible(boolean visible, Line line) {
commentPanel.setAddCommentButtonVisible(visible, line);
}
});
taggerPanel = new FlowPanel();
taggerPanel.addStyleName("v-tagger-panel");
taggerPanel.add(taggerEditor);
this.commentPanel = new CommentPanel(new CommentPanelListener() {
@Override
public void remove(ClientComment comment) {
taggerListener.removeComment(comment);
}
@Override
public void edit(ClientComment comment, int x, int y) {
taggerListener.editComment(comment, x, y);
}
@Override
public void addComment(int x, int y) {
List<TextRange> ranges = taggerEditor.getSelectedTextRanges();
taggerListener.addComment(ranges, x, y);
}
@Override
public void replyTo(ClientComment comment, int x, int y) {
taggerListener.replyToComment(comment, x, y);
}
@Override
public void loadReplies(String uuid) {
taggerListener.loadReplies(uuid);
}
@Override
public void showCommentHighlight(ClientComment comment) {
taggerEditor.showCommentHighlight(comment);
}
@Override
public void edit(ClientComment comment, ClientCommentReply reply, int x, int y) {
taggerListener.editReply(comment, reply, x, y);
}
@Override
public void remove(ClientComment comment, ClientCommentReply reply) {
taggerListener.removeReply(comment, reply);
}
});
taggerPanel.add(commentPanel);
initWidget(taggerPanel);
}
use of de.catma.ui.client.ui.tagger.shared.ClientCommentReply in project catma by forTEXT.
the class TaggerView method handleReplyChange.
@Subscribe
public void handleReplyChange(ReplyChangeEvent replyChangeEvent) {
switch(replyChangeEvent.getChangeType()) {
case CREATED:
{
try {
tagger.addReply(replyChangeEvent.getComment(), replyChangeEvent.getReply());
} catch (IOException e) {
errorHandler.showAndLogError("Error adding Reply!", e);
}
break;
}
case UPDATED:
{
try {
tagger.updateReply(replyChangeEvent.getComment(), replyChangeEvent.getReply());
} catch (IOException e) {
errorHandler.showAndLogError("Error updating Reply!", e);
}
break;
}
case DELETED:
{
try {
tagger.removeReply(replyChangeEvent.getComment(), replyChangeEvent.getReply());
} catch (IOException e) {
errorHandler.showAndLogError("Error removing Reply!", e);
}
break;
}
}
try {
if (commentTopic != null) {
Comment comment = replyChangeEvent.getComment();
ClientComment clientComment = new ClientComment(comment.getUuid(), comment.getUsername(), comment.getUserId(), comment.getBody(), comment.getReplyCount(), comment.getRanges().stream().map(r -> new TextRange(r.getStartPoint(), r.getEndPoint())).collect(Collectors.toList()));
Reply reply = replyChangeEvent.getReply();
ClientCommentReply clientCommentReply = new ClientCommentReply(reply.getUuid(), reply.getBody(), reply.getUsername(), reply.getUserId(), reply.getCommentUuid());
commentTopic.publish(new CommentMessage(comment.getId(), comment.getIid(), project.getUser().getUserId(), clientComment, comment.getDocumentId(), replyChangeEvent.getChangeType() == ChangeType.DELETED, reply.getId(), clientCommentReply));
}
} catch (Exception e) {
logger.log(Level.WARNING, "error publishing a comment message", e);
}
}
Aggregations