Package org.zanata.webtrans.shared.model

Examples of org.zanata.webtrans.shared.model.GlossaryResultItem


    }

    @Override
    public void renderTable(ArrayList<GlossaryResultItem> glossaries) {
        for (int i = 0; i < glossaries.size(); i++) {
            final GlossaryResultItem item = glossaries.get(i);

            resultTable.setWidget(i + 1, SOURCE_COL,
                    new HighlightingLabel(item.getSource()));
            resultTable.setWidget(i + 1, TARGET_COL,
                    new HighlightingLabel(item.getTarget()));

            Button copyButton = new Button(messages.copy());
            copyButton.setTitle(messages.copyTooltip());

            copyButton.addClickHandler(new ClickHandler() {
View Full Code Here


                if (targetTerm == null) {
                    continue;
                }
                String srcTermContent = sourceTerm.getContent();
                String targetTermContent = targetTerm.getContent();
                GlossaryResultItem item =
                        getOrCreateGlossaryResultItem(matchesMap,
                                srcTermContent, targetTermContent,
                                (Float) match[0], searchText);
                item.addSourceId(sourceTerm.getId());
            }
            results = new ArrayList<GlossaryResultItem>(matchesMap.values());
        } catch (ParseException e) {
            if (searchType == SearchType.FUZZY) {
                log.warn("Can't parse fuzzy query '" + searchText + "'");
View Full Code Here

    private static GlossaryResultItem getOrCreateGlossaryResultItem(
            Map<GlossaryKey, GlossaryResultItem> matchesMap,
            String srcTermContent, String targetTermContent, float score,
            String searchText) {
        GlossaryKey key = new GlossaryKey(targetTermContent, srcTermContent);
        GlossaryResultItem item = matchesMap.get(key);
        if (item == null) {
            double percent =
                    100 * LevenshteinUtil.getSimilarity(searchText,
                            srcTermContent);
            item =
                    new GlossaryResultItem(srcTermContent, targetTermContent,
                            score, percent);
            matchesMap.put(key, item);
        }
        return item;
    }
View Full Code Here

    @Override
    public void execute() {
        Log.info("ENTER DummyGetGlossaryCommand.execute()");
        ArrayList<GlossaryResultItem> matches =
                new ArrayList<GlossaryResultItem>();
        matches.add(new GlossaryResultItem("<s>source1</s>",
                "<tr> &lt;suggestion 3</tr>", 3, 100));
        matches.add(new GlossaryResultItem("<s>source1</s>",
                "<tr> &lt;suggestion 3</tr>", 3, 100));
        matches.add(new GlossaryResultItem("<s>source1</s>",
                "<tr> &lt;suggestion 3</tr>", 3, 100));
        matches.add(new GlossaryResultItem("<s>source1</s>",
                "<tr> &lt;suggestion 3</tr>", 3, 100));
        callback.onSuccess(new GetGlossaryResult(action, matches));
        Log.info("EXIT DummyGetGlossaryCommand.execute()");
    }
View Full Code Here

        verify(mockNewCommentText).setText("");
    }

    @Test
    public void show() {
        GlossaryResultItem item = new GlossaryResultItem("", "", 0, 0);
        when(
                mockUserWorkspaceContext.getWorkspaceRestrictions()
                        .isHasGlossaryUpdateAccess()).thenReturn(true);

        glossaryDetailsPresenter.show(item);

        verify(mockDispatcher).execute(getGlossaryDetailsCaptor.capture(),
                getGlossarycallbackCaptor.capture());
        assertThat(getGlossaryDetailsCaptor.getValue().getSourceIdList(),
                Matchers.equalTo(item.getSourceIdList()));
        AsyncCallback<GetGlossaryDetailsResult> callback =
                getGlossarycallbackCaptor.getValue();

        // testing success callback
        GlossaryDetails glossaryDetails = mock(GlossaryDetails.class);
        when(glossaryDetails.getSource()).thenReturn("source text");
        when(glossaryDetails.getTarget()).thenReturn("target text");
        when(glossaryDetails.getSrcLocale()).thenReturn(new LocaleId("en-US"));
        when(glossaryDetails.getTargetLocale()).thenReturn(new LocaleId("zh"));
        when(glossaryDetails.getTarget()).thenReturn("source text");
        when(display.getSrcRef()).thenReturn(srcRef);
        when(display.getTargetText()).thenReturn(targetText);
        when(display.getSourceLabel()).thenReturn(sourceLabel);
        when(display.getTargetLabel()).thenReturn(targetLabel);
        when(messages.entriesLabel(1)).thenReturn("1");

        callback.onSuccess(new GetGlossaryDetailsResult(Lists
                .newArrayList(glossaryDetails)));

        verify(display).setSourceText(item.getSource());
        verify(targetText).setText(item.getSource());
        verify(display).clearEntries();
        verify(display).setSourceText(anyString());
        verify(targetLabel).setText(anyString());
        verify(display).addEntry("1");
        verify(display).show();
View Full Code Here

                !isFocused);
    }

    @Test
    public void showGlossaryDetail() {
        GlossaryResultItem object = new GlossaryResultItem("", "", 0, 0);

        when(messages.searchGlossary()).thenReturn("Search glossary");

        presenter.showGlossaryDetail(object);
View Full Code Here

        verify(glossaryDetailsPresenter).show(object);
    }

    @Test
    public void fireCopyEvent() {
        GlossaryResultItem object = new GlossaryResultItem("", "", 0, 0);
        ArgumentCaptor<InsertStringInEditorEvent> eventCaptor =
                ArgumentCaptor.forClass(InsertStringInEditorEvent.class);

        when(messages.searchGlossary()).thenReturn("Search glossary");
View Full Code Here

        verify(display).startProcessing();
        verify(dispatcher).execute(getGlossaryCaptor.capture(),
                callbackCaptor.capture());
        AsyncCallback<GetGlossaryResult> callback = callbackCaptor.getValue();
        ArrayList<GlossaryResultItem> glossaries =
                Lists.newArrayList(new GlossaryResultItem("source", "target",
                        100, 100));

        // on rpc callback success and result contains glossaries
        callback.onSuccess(new GetGlossaryResult(getGlossaryCaptor.getValue(),
                glossaries));
View Full Code Here

TOP

Related Classes of org.zanata.webtrans.shared.model.GlossaryResultItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.