Search in sources :

Example 1 with ClientComment

use of de.catma.ui.client.ui.tagger.shared.ClientComment in project catma by forTEXT.

the class VTagger method setPage.

public void setPage(String page, int lineCount, List<ClientComment> comments) {
    logger.info("setting page content");
    Timer timer = new Timer() {

        @Override
        public void run() {
            taggerEditor.setHTML(new HTML(page), lineCount);
            // removing the panel before setting the lines increases the performance
            taggerPanel.remove(commentPanel);
            commentPanel.setLines(taggerEditor.getLines());
            for (ClientComment comment : comments) {
                addComment(comment);
            }
            taggerPanel.add(commentPanel);
        }
    };
    timer.schedule(100);
}
Also used : Timer(com.google.gwt.user.client.Timer) ClientComment(de.catma.ui.client.ui.tagger.shared.ClientComment) HTML(com.google.gwt.user.client.ui.HTML)

Example 2 with ClientComment

use of de.catma.ui.client.ui.tagger.shared.ClientComment 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);
    }
}
Also used : Line(de.catma.ui.client.ui.tagger.editor.Line) CommentLinePanelListener(de.catma.ui.client.ui.tagger.comment.CommentLinePanel.CommentLinePanelListener) ClientCommentReply(de.catma.ui.client.ui.tagger.shared.ClientCommentReply) ClientComment(de.catma.ui.client.ui.tagger.shared.ClientComment)

Example 3 with ClientComment

use of de.catma.ui.client.ui.tagger.shared.ClientComment in project catma by forTEXT.

the class ClientCommentJSONSerializer method fromJSON.

public ClientComment fromJSON(JSONObject jsonObject) {
    String uuid = getStringValueFromStringObject(jsonObject.get(SerializationField.uuid.name()));
    String username = getStringValueFromStringObject(jsonObject.get(SerializationField.username.name()));
    Integer userId = getIntValueFromNumberObject(jsonObject.get(SerializationField.userId.name()));
    String body = getStringValueFromStringObject(jsonObject.get(SerializationField.body.name()));
    JSONArray rangesJSON = (JSONArray) jsonObject.get(SerializationField.ranges.name());
    int replyCount = getIntValueFromNumberObject(jsonObject.get(SerializationField.replyCount.name()));
    List<TextRange> ranges = new ArrayList<TextRange>();
    for (int i = 0; i < rangesJSON.size(); i++) {
        JSONObject trJSON = (JSONObject) rangesJSON.get(i);
        TextRange tr = new TextRange(getIntValueFromNumberObject(trJSON.get(SerializationField.startPos.name())), getIntValueFromNumberObject(trJSON.get(SerializationField.endPos.name())));
        ranges.add(tr);
    }
    return new ClientComment(uuid, username, userId, body, replyCount, ranges);
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) ClientComment(de.catma.ui.client.ui.tagger.shared.ClientComment) JSONArray(com.google.gwt.json.client.JSONArray) ArrayList(java.util.ArrayList) TextRange(de.catma.ui.client.ui.tagger.shared.TextRange) JSONString(com.google.gwt.json.client.JSONString)

Example 4 with ClientComment

use of de.catma.ui.client.ui.tagger.shared.ClientComment 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);
}
Also used : ClientTagInstance(de.catma.ui.client.ui.tagger.shared.ClientTagInstance) ClientComment(de.catma.ui.client.ui.tagger.shared.ClientComment) TaggerEditorListener(de.catma.ui.client.ui.tagger.editor.TaggerEditorListener) TextRange(de.catma.ui.client.ui.tagger.shared.TextRange) CommentPanelListener(de.catma.ui.client.ui.tagger.comment.CommentPanel.CommentPanelListener) Line(de.catma.ui.client.ui.tagger.editor.Line) TaggerEditor(de.catma.ui.client.ui.tagger.editor.TaggerEditor) ClientCommentReply(de.catma.ui.client.ui.tagger.shared.ClientCommentReply) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) List(java.util.List) CommentPanel(de.catma.ui.client.ui.tagger.comment.CommentPanel) HashSet(java.util.HashSet)

Example 5 with ClientComment

use of de.catma.ui.client.ui.tagger.shared.ClientComment in project catma by forTEXT.

the class ClientCommentJSONSerializer method toJSONArrayString.

public String toJSONArrayString(Collection<ClientComment> comments) {
    JSONArray result = new JSONArray();
    int i = 0;
    for (ClientComment comment : comments) {
        result.set(i, toJSONObject(comment));
        i++;
    }
    return result.toString();
}
Also used : ClientComment(de.catma.ui.client.ui.tagger.shared.ClientComment) JSONArray(com.google.gwt.json.client.JSONArray)

Aggregations

ClientComment (de.catma.ui.client.ui.tagger.shared.ClientComment)9 TextRange (de.catma.ui.client.ui.tagger.shared.TextRange)6 Comment (de.catma.document.comment.Comment)4 ClientCommentReply (de.catma.ui.client.ui.tagger.shared.ClientCommentReply)3 Subscribe (com.google.common.eventbus.Subscribe)2 JSONArray (com.google.gwt.json.client.JSONArray)2 ValueOutOfBoundsException (com.vaadin.ui.Slider.ValueOutOfBoundsException)2 Line (de.catma.ui.client.ui.tagger.editor.Line)2 ClientTagInstance (de.catma.ui.client.ui.tagger.shared.ClientTagInstance)2 CommentMessage (de.catma.ui.events.CommentMessage)2 IOException (java.io.IOException)2 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 JsonNodeFactory (com.fasterxml.jackson.databind.node.JsonNodeFactory)1 JSONObject (com.google.gwt.json.client.JSONObject)1 JSONString (com.google.gwt.json.client.JSONString)1 Timer (com.google.gwt.user.client.Timer)1