Search in sources :

Example 1 with AnnisUI

use of org.corpus_tools.annis.gui.AnnisUI in project ANNIS by korpling.

the class ReferenceLinkEditor method attach.

@Override
public void attach() {
    super.attach();
    if (getUI() instanceof AnnisUI) {
        AnnisUI annisUI = (AnnisUI) getUI();
        UrlShortener shortener = annisUI.getUrlShortener();
        dataProvider = createDataProvider(shortener).withConfigurableFilter();
        grid.setDataProvider(dataProvider);
        addEditableBindings(temporaryColumn, dataProvider, annisUI);
    }
    Optional<OAuth2User> user = Helper.getUser(getUI());
    if (user.isPresent()) {
        Set<String> roles = Helper.getUserRoles(user.get());
        if (roles.contains("admin")) {
            setContent(grid);
        }
    }
}
Also used : OAuth2User(org.springframework.security.oauth2.core.user.OAuth2User) UrlShortener(org.corpus_tools.annis.gui.query_references.UrlShortener) AnnisUI(org.corpus_tools.annis.gui.AnnisUI)

Example 2 with AnnisUI

use of org.corpus_tools.annis.gui.AnnisUI in project ANNIS by korpling.

the class ExceptionDialog method buttonClick.

@Override
public void buttonClick(Button.ClickEvent event) {
    if (event.getButton() == btDetails) {
        if (detailsPanel.isVisible()) {
            detailsPanel.setVisible(false);
            btDetails.setCaption("Show Details");
            layout.setExpandRatio(detailsPanel, 0.0f);
            layout.setExpandRatio(actionsLayout, 1.0f);
        } else {
            detailsPanel.setVisible(true);
            btDetails.setCaption("Hide Details");
            layout.setExpandRatio(detailsPanel, 1.0f);
            layout.setExpandRatio(actionsLayout, 0.0f);
        }
    } else if (event.getButton() == btClose) {
        this.close();
    } else if (event.getButton() == btReportBug) {
        this.close();
        UI ui = UI.getCurrent();
        if (ui instanceof AnnisUI) {
            ((AnnisUI) ui).reportBug(cause);
        }
    }
}
Also used : AnnisUI(org.corpus_tools.annis.gui.AnnisUI) UI(com.vaadin.ui.UI) CommonUI(org.corpus_tools.annis.gui.CommonUI) AnnisUI(org.corpus_tools.annis.gui.AnnisUI)

Example 3 with AnnisUI

use of org.corpus_tools.annis.gui.AnnisUI in project ANNIS by korpling.

the class RawTextVisualizer method createComponent.

@Override
public Panel createComponent(VisualizerInput visInput, VisualizationToggle visToggle) {
    // get config for alignment
    boolean vertical = Boolean.parseBoolean(visInput.getMappings().getOrDefault("vertical", "true"));
    // get the texts
    RawTextWrapper texts = visInput.getRawText();
    // create the main panel
    Panel p = new Panel();
    p.setSizeFull();
    // some layout configuration
    p.addStyleName(ValoTheme.PANEL_BORDERLESS);
    p.addStyleName(PANEL_CLASS);
    // enable webfonts
    p.addStyleName(Helper.CORPUS_FONT_FORCE);
    Layout l;
    // if no text available inform user and exit
    if (texts == null) {
        Label text = new Label(NO_TEXT);
        text.addStyleName(LABEL_CLASS);
        text.setSizeFull();
        p.setContent(text);
        return p;
    }
    if (texts.hasMultipleTexts()) {
        // set the aligmnent
        if (vertical) {
            l = new VerticalLayout();
        } else {
            l = new GridLayout(texts.getTexts().size(), 1);
        }
        // limit the size to the parent panel.
        l.setSizeFull();
        // add the texts to the layout
        for (int i = 0; i < texts.getTexts().size(); i++) {
            String s = texts.getTexts().get(i);
            Label lblText;
            // check if the text is empty
            if (s == null || hasOnlyWhiteSpace(s)) {
                lblText = new Label(NO_TEXT);
            } else {
                lblText = new Label(s, ContentMode.TEXT);
            }
            if (visInput.getUI() instanceof AnnisUI) {
                if (!((AnnisUI) visInput.getUI()).getConfig().isDisableRTL() && Helper.containsRTLText(s)) {
                    lblText.addStyleName("rtl");
                }
            }
            lblText.setCaption("text " + (i + 1));
            lblText.addStyleName(LABEL_CLASS);
            lblText.setWidth(98, Sizeable.Unit.PERCENTAGE);
            l.addComponent(lblText);
        }
        // apply the panel
        p.setContent(l);
        return p;
    }
    Label lblText;
    if (texts.hasTexts() && !hasOnlyWhiteSpace(texts.getFirstText())) {
        lblText = new Label(texts.getFirstText(), ContentMode.TEXT);
        if (visInput.getUI() instanceof AnnisUI) {
            if (!((AnnisUI) visInput.getUI()).getConfig().isDisableRTL() && Helper.containsRTLText(texts.getFirstText())) {
                lblText.addStyleName("rtl");
            }
        }
    } else {
        lblText = new Label(NO_TEXT);
    }
    lblText.setSizeFull();
    lblText.addStyleName(LABEL_CLASS);
    p.setContent(lblText);
    return p;
}
Also used : Panel(com.vaadin.ui.Panel) GridLayout(com.vaadin.ui.GridLayout) VerticalLayout(com.vaadin.ui.VerticalLayout) Layout(com.vaadin.ui.Layout) GridLayout(com.vaadin.ui.GridLayout) AnnisUI(org.corpus_tools.annis.gui.AnnisUI) RawTextWrapper(org.corpus_tools.annis.gui.objects.RawTextWrapper) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout)

Example 4 with AnnisUI

use of org.corpus_tools.annis.gui.AnnisUI in project ANNIS by korpling.

the class SearchOptionsPanel method updateSearchPanelConfigurationInBackground.

public void updateSearchPanelConfigurationInBackground(final Collection<String> corpora) {
    setLoadingState(true);
    // remove custom adjustments
    cbLeftContext.setItems();
    cbRightContext.setItems();
    cbSegmentation.setItems();
    UI ui = getUI();
    if (ui instanceof AnnisUI) {
        // reload the config in the background
        Background.run(new CorpusConfigUpdater((AnnisUI) ui, corpora, true));
    }
}
Also used : UI(com.vaadin.ui.UI) AnnisUI(org.corpus_tools.annis.gui.AnnisUI) AnnisUI(org.corpus_tools.annis.gui.AnnisUI)

Example 5 with AnnisUI

use of org.corpus_tools.annis.gui.AnnisUI in project ANNIS by korpling.

the class ShareQueryReferenceWindow method attach.

@Override
public void attach() {
    super.attach();
    String shortURL = "ERROR";
    UI ui = UI.getCurrent();
    if (query != null && ui instanceof AnnisUI) {
        AnnisUI annisUI = (AnnisUI) ui;
        URI appURI = UI.getCurrent().getPage().getLocation();
        String fragment;
        try {
            fragment = StringUtils.join(query.toCitationFragment(), "&");
            URI url = new URI(appURI.getScheme(), null, appURI.getHost(), appURI.getPort(), appURI.getPath(), null, fragment);
            if (shorten) {
                shortURL = annisUI.getUrlShortener().shortenURL(url, annisUI);
            } else {
                shortURL = url.toASCIIString();
            }
        } catch (URISyntaxException e) {
            log.error("Could not generate query share link", e);
            ExceptionDialog.show(e, "Could not generate query share link", UI.getCurrent());
        }
    }
    txtCitation.setReadOnly(false);
    txtCitation.setValue(shortURL);
    txtCitation.setReadOnly(true);
}
Also used : AnnisUI(org.corpus_tools.annis.gui.AnnisUI) UI(com.vaadin.ui.UI) AnnisUI(org.corpus_tools.annis.gui.AnnisUI) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Aggregations

AnnisUI (org.corpus_tools.annis.gui.AnnisUI)9 UI (com.vaadin.ui.UI)4 URI (java.net.URI)2 ExternalResource (com.vaadin.server.ExternalResource)1 GridLayout (com.vaadin.ui.GridLayout)1 Label (com.vaadin.ui.Label)1 Layout (com.vaadin.ui.Layout)1 Panel (com.vaadin.ui.Panel)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 URISyntaxException (java.net.URISyntaxException)1 LinkedHashSet (java.util.LinkedHashSet)1 ApiException (org.corpus_tools.annis.ApiException)1 CorporaApi (org.corpus_tools.annis.api.CorporaApi)1 CommonUI (org.corpus_tools.annis.gui.CommonUI)1 InstanceConfig (org.corpus_tools.annis.gui.InstanceConfig)1 ExceptionDialog (org.corpus_tools.annis.gui.components.ExceptionDialog)1 QueryUIState (org.corpus_tools.annis.gui.objects.QueryUIState)1 RawTextWrapper (org.corpus_tools.annis.gui.objects.RawTextWrapper)1 UrlShortener (org.corpus_tools.annis.gui.query_references.UrlShortener)1 SCorpusGraph (org.corpus_tools.salt.common.SCorpusGraph)1