Example usage for com.vaadin.ui Notification show

List of usage examples for com.vaadin.ui Notification show

Introduction

In this page you can find the example usage for com.vaadin.ui Notification show.

Prototype

public static Notification show(String caption, String description, Type type) 

Source Link

Document

Shows a notification message the current page.

Usage

From source file:annis.gui.resultview.VisualizerPanel.java

License:Apache License

/**
 * This Constructor should be used for {@link ComponentVisualizerPlugin}
 * Visualizer./*from w ww.  j ava 2s .  c  o  m*/
 *
 */
public VisualizerPanel(final ResolverEntry entry, SDocument result, String corpusName, String documentName,
        Set<String> visibleTokenAnnos, Map<String, Long> markedAndCovered,
        @Deprecated Map<String, String> markedAndCoveredMap, @Deprecated Map<String, String> markedExactMap,
        String htmlID, String resultID, SingleResultPanel parent, String segmentationName, PluginSystem ps,
        InstanceConfig instanceConfig) throws IOException {

    this.ps = ps;
    this.instanceConfig = instanceConfig;
    this.entry = entry;
    this.markersExact = markedExactMap;
    this.markersCovered = markedAndCoveredMap;

    this.visCtxChanger = parent;

    this.result = result;
    this.corpusName = corpusName;
    this.documentName = documentName;
    this.visibleTokenAnnos = visibleTokenAnnos;
    this.markedAndCovered = markedAndCovered;
    this.segmentationName = segmentationName;
    this.htmlID = htmlID;
    this.resultID = resultID;

    this.progress = new ProgressBar();
    this.progress.setIndeterminate(true);
    this.progress.setVisible(false);
    this.progress.setEnabled(false);

    this.addStyleName(ChameleonTheme.PANEL_BORDERLESS);
    this.setWidth("100%");

    if (entry != null && ps != null) {
        visPlugin = ps.getVisualizer(entry.getVisType());
        if (visPlugin == null) {
            // fallback to default visualizer if original vis type was not found
            entry.setVisType(PluginSystem.DEFAULT_VISUALIZER);
            visPlugin = ps.getVisualizer(entry.getVisType());
        }

        if (HIDDEN.equalsIgnoreCase(entry.getVisibility())) {
            // build button for visualizer
            btEntry = new Button(entry.getDisplayName());
            btEntry.setIcon(ICON_EXPAND);
            btEntry.setStyleName(ChameleonTheme.BUTTON_BORDERLESS + " " + ChameleonTheme.BUTTON_SMALL);
            btEntry.addClickListener((Button.ClickListener) this);
            btEntry.setDisableOnClick(true);

            addComponent(btEntry);
            addComponent(progress);
        } else {

            if (ISVISIBLE.equalsIgnoreCase(entry.getVisibility())
                    || PRELOADED.equalsIgnoreCase(entry.getVisibility())) {
                // build button for visualizer
                btEntry = new Button(entry.getDisplayName());
                btEntry.setIcon(ICON_COLLAPSE);
                btEntry.setStyleName(ChameleonTheme.BUTTON_BORDERLESS + " " + ChameleonTheme.BUTTON_SMALL);
                btEntry.addClickListener((Button.ClickListener) this);
                addComponent(btEntry);
            }

            addComponent(progress);

            // create the visualizer and calc input
            try {
                vis = createComponent();
                if (vis != null) {
                    vis.setVisible(true);
                    addComponent(vis);
                }
            } catch (Exception ex) {
                Notification.show("Could not create visualizer " + visPlugin.getShortName(), ex.toString(),
                        Notification.Type.TRAY_NOTIFICATION);
                log.error("Could not create visualizer " + visPlugin.getShortName(), ex);
            }

            if (btEntry != null && PRELOADED.equalsIgnoreCase(entry.getVisibility())) {
                btEntry.setIcon(ICON_EXPAND);
                if (vis != null) {
                    vis.setVisible(false);
                }
            }

        }

    } // end if entry not null

}

From source file:annis.gui.SearchUI.java

License:Apache License

@Override
public void notifyCannotPlayMimeType(String mimeType) {
    if (mimeType == null) {
        return;/*from w w  w  . j a  v  a2s  .  c  o m*/
    }

    if (mimeType.startsWith("audio/ogg") || mimeType.startsWith("video/web")) {
        String browserList = "<ul>"
                + "<li>Mozilla Firefox: <a href=\"http://www.mozilla.org/firefox\" target=\"_blank\">http://www.mozilla.org/firefox</a></li>"
                + "<li>Google Chrome: <a href=\"http://www.google.com/chrome\" target=\"_blank\">http://www.google.com/chrome</a></li>"
                + "</ul>";

        WebBrowser browser = getPage().getWebBrowser();

        // IE9 users can install a plugin
        Set<String> supportedByIE9Plugin = new HashSet<String>();
        supportedByIE9Plugin.add("video/webm");
        supportedByIE9Plugin.add("audio/ogg");
        supportedByIE9Plugin.add("video/ogg");

        if (browser.isIE() && browser.getBrowserMajorVersion() >= 9
                && supportedByIE9Plugin.contains(mimeType)) {
            Notification.show("Media file type unsupported by your browser",
                    "Please install the WebM plugin for Internet Explorer 9 from "
                            + "<a href=\"https://tools.google.com/dlpage/webmmf\">https://tools.google.com/dlpage/webmmf</a> "
                            + " or use a browser from the following list "
                            + "(these are known to work with WebM or OGG files)<br/>" + browserList,
                    Notification.Type.WARNING_MESSAGE);
        } else {
            Notification.show("Media file type unsupported by your browser",
                    "Please use a browser from the following list "
                            + "(these are known to work with WebM or OGG files)<br/>" + browserList,
                    Notification.Type.WARNING_MESSAGE);
        }
    } else {
        Notification.show("Media file type \"" + mimeType + "\" unsupported by your browser!",
                "Try to check your browsers documentation how to enable "
                        + "support for the media type or inform the corpus creator about this problem.",
                Notification.Type.WARNING_MESSAGE);
    }

}

From source file:annis.libgui.Helper.java

License:Apache License

/**
 * Loads the corpus config of a specific corpus.
 *
 * @param corpus The name of the corpus, for which the config is fetched.
 * @return A {@link CorpusConfig} object, which wraps a {@link Properties}
 * object. This Properties object stores the corpus configuration as simple
 * key-value pairs./*from w w w  .  j  a v a 2s .  c  o m*/
 */
public static CorpusConfig getCorpusConfig(String corpus) {

    if (corpus == null || corpus.isEmpty()) {
        Notification.show("no corpus is selected", "please select at leas one corpus and execute query again",
                Notification.Type.WARNING_MESSAGE);
        return null;
    }

    CorpusConfig corpusConfig = new CorpusConfig();

    try {
        corpusConfig = Helper.getAnnisWebResource().path("query").path("corpora")
                .path(urlPathEscape.escape(corpus)).path("config").get(CorpusConfig.class);
    } catch (UniformInterfaceException | ClientHandlerException ex) {
        new Notification(ERROR_MESSAGE_CORPUS_PROPS_HEADER, ERROR_MESSAGE_CORPUS_PROPS,
                Notification.Type.WARNING_MESSAGE, true).show(Page.getCurrent());
    }

    return corpusConfig;
}

From source file:annis.libgui.Helper.java

License:Apache License

public static RawTextWrapper getRawText(String corpusName, String documentName) {
    RawTextWrapper texts = null;/*from w  w w  . java  2  s. co m*/
    try {
        WebResource webResource = getAnnisWebResource();
        webResource = webResource.path("query").path("rawtext").path(corpusName).path(documentName);
        texts = webResource.get(RawTextWrapper.class);
    }

    catch (UniformInterfaceException ex) {
        Notification.show("can not retrieve raw text", ex.getLocalizedMessage(),
                Notification.Type.WARNING_MESSAGE);
    } catch (ClientHandlerException ex) {
        Notification.show("can not retrieve raw text", ex.getLocalizedMessage(),
                Notification.Type.WARNING_MESSAGE);
    }

    return texts;
}

From source file:annis.libgui.media.MediaControllerImpl.java

License:Apache License

@Override
public void play(String resultID, double startTime) {
    boolean foundPlayer = false;

    lock.readLock().lock();/* w ww. ja  v  a  2 s.c o m*/
    try {
        MediaPlayer player = getPlayerForResult(resultID);

        if (player != null) {
            closeOtherPlayers(player);

            VisualizationToggle t = visToggle.get(player);
            if (t != null) {
                foundPlayer = true;
                t.toggleVisualizer(true, new CallbackImpl(player, startTime, null));
            }

        }
    } finally {
        lock.readLock().unlock();
    }
    if (!foundPlayer) {
        Notification.show("Could not play media.",
                "If this is a match reference open the actual search interface by following the \"Show in ANNIS search interface\" link.",
                Notification.Type.WARNING_MESSAGE);
    }
}

From source file:annis.libgui.media.MediaControllerImpl.java

License:Apache License

@Override
public void play(String resultID, double startTime, double endTime) {

    boolean foundPlayer = false;
    lock.readLock().lock();//from ww  w .  j  a v a  2s.c  om
    try {
        MediaPlayer player = getPlayerForResult(resultID);

        if (player != null) {
            closeOtherPlayers(player);

            VisualizationToggle t = visToggle.get(player);
            if (t != null) {
                foundPlayer = true;
                t.toggleVisualizer(true, new CallbackImpl(player, startTime, endTime));
            }
        }
    } finally {
        lock.readLock().unlock();
    }
    if (!foundPlayer) {
        Notification.show("Could not play media.",
                "If this is a match reference open the actual search interface by following the \"Show in ANNIS search interface\" link.",
                Notification.Type.WARNING_MESSAGE);
    }
}

From source file:annis.visualizers.htmlvis.HTMLVis.java

License:Apache License

@Override
public Panel createComponent(VisualizerInput vi, VisualizationToggle vt) {
    Panel scrollPanel = new Panel();
    scrollPanel.setSizeFull();//from w w w.  jav a2s .c  o m
    Label lblResult = new Label("ERROR", ContentMode.HTML);
    lblResult.setSizeUndefined();

    List<String> corpusPath = CommonHelper.getCorpusPath(vi.getDocument().getGraph(), vi.getDocument());
    String corpusName = corpusPath.get(corpusPath.size() - 1);
    corpusName = urlPathEscape.escape(corpusName);

    String wrapperClassName = "annis-wrapped-htmlvis-" + corpusName.replaceAll("[^0-9A-Za-z-]", "_");

    scrollPanel.addStyleName(wrapperClassName);

    String visConfigName = vi.getMappings().getProperty("config");
    String hitMarkConfig = vi.getMappings().getProperty("hitmark", "true");
    hitMark = Boolean.parseBoolean(hitMarkConfig);
    mc = vi.getMarkedAndCovered();

    VisualizationDefinition[] definitions = parseDefinitions(corpusName, vi.getMappings());

    if (definitions != null) {

        lblResult.setValue(createHTML(vi.getSResult().getDocumentGraph(), definitions));

        String labelClass = vi.getMappings().getProperty("class", "htmlvis");
        lblResult.addStyleName(labelClass);

        InputStream inStreamCSSRaw = null;
        if (visConfigName == null) {
            inStreamCSSRaw = HTMLVis.class.getResourceAsStream("htmlvis.css");
        } else {
            WebResource resBinary = Helper.getAnnisWebResource().path("query/corpora/").path(corpusName)
                    .path(corpusName).path("binary").path(visConfigName + ".css");

            ClientResponse response = resBinary.get(ClientResponse.class);
            if (response.getStatus() == ClientResponse.Status.OK.getStatusCode()) {
                inStreamCSSRaw = response.getEntityInputStream();
            }
        }
        if (inStreamCSSRaw != null) {
            try (InputStream inStreamCSS = inStreamCSSRaw) {
                String cssContent = IOUtils.toString(inStreamCSS);
                UI currentUI = UI.getCurrent();
                if (currentUI instanceof AnnisBaseUI) {
                    // do not add identical CSS files
                    ((AnnisBaseUI) currentUI).injectUniqueCSS(cssContent, wrapperClassName);
                }
            } catch (IOException ex) {
                log.error("Could not parse the HTML visualizer CSS file", ex);
                Notification.show("Could not parse the HTML visualizer CSS file", ex.getMessage(),
                        Notification.Type.ERROR_MESSAGE);
            }
        }

    }

    if (vi.getMappings().containsKey("debug")) {
        TextArea txtDebug = new TextArea();
        txtDebug.setValue(lblResult.getValue());
        txtDebug.setReadOnly(true);
        txtDebug.setWidth("100%");
        Label sep = new Label("<hr/>", ContentMode.HTML);
        VerticalLayout layout = new VerticalLayout(txtDebug, sep, lblResult);
        layout.setSizeUndefined();
        scrollPanel.setContent(layout);
    } else {
        scrollPanel.setContent(lblResult);
    }

    return scrollPanel;
}

From source file:at.jku.ce.adaptivetesting.vaadin.ui.QuestionManager.java

License:LGPL

public QuestionManager(String quizName, IEngine engine) {
    setMargin(true);/*  w w  w  . j  a v  a2  s .c o  m*/
    questionNo = 0;
    title = HtmlLabel.getCenteredLabel("h1", quizName);
    addComponent(title);
    addComponent(questionHolder);

    addComponent(southLayout);

    next = new Button("Nchste Frage");
    next.addClickListener(e -> {
        e.getButton().setEnabled(false);
        try {
            iEngine.requestCalculation();
        } catch (EngineException e1) {
            Notification.show("Die nchste Frage konnte nicht ausgewhlt werden.",
                    "Bitte wende dich an den Lehrenden.", Type.ERROR_MESSAGE);
            LogHelper.logThrowable(e1);
        }
    });
    southLayout.addComponent(next, 2, 0);
    southLayout.setSizeFull();
    southLayout.setMargin(true);
    // Ensure we have an engine
    if (engine == null) {
        try {
            iEngine = new SimpleEngine();
        } catch (EngineException e1) {
            Notification.show("Test-System konnte nicht gestartet werden", "Bitte wende dich an den Lehrenden.",
                    Type.ERROR_MESSAGE);
            LogHelper.logThrowable(e1);

        }
    } else {
        iEngine = engine;
    }
    // Register to engine events
    iEngine.addQuestionChangeListener(this);
    iEngine.addResultFiredListener(this);
    setResultView(VaadinResultView.class);
}

From source file:at.jku.ce.adaptivetesting.vaadin.ui.QuestionManager.java

License:LGPL

public void startQuiz(StudentData student) {
    iEngine.resetQuestions();//from   w  w  w . ja  v  a 2 s .  co  m
    iEngine.setStudentData(student);
    loadQuestions();
    try {
        iEngine.start();
    } catch (EngineException e) {
        Notification.show("Test-System konnte nicht gestartet werden",
                "Bitte wenden Sie sich an den Lehrenden.", Type.ERROR_MESSAGE);
        LogHelper.logThrowable(e);
    }
}

From source file:at.jku.ce.adaptivetesting.vaadin.ui.topic.accounting.AccountingQuestionManager.java

License:LGPL

@Override
public void loadQuestions() {
    try {/*  w  w w. j a  va2s .c  o m*/
        loadQuestions(new File(VaadinUI.Servlet.getQuestionFolderName()));
    } catch (JAXBException | IOException e1) {
        Notification.show("Questions could not be loaded - FATAL error", e1.getMessage(), Type.ERROR_MESSAGE);
        LogHelper.logThrowable(e1);
    }

}