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, Type type) 

Source Link

Document

Shows a notification message the current page.

Usage

From source file:annis.libgui.Helper.java

License:Apache License

/**
 * Retrieve the meta data for a given document of a corpus.
 *
 * @param toplevelCorpusName specifies the toplevel corpus
 * @param documentName specifies the document.
 * @return returns only the meta data for a single document.
 *///  w  w w .  ja v a2  s. c  o  m
public static List<Annotation> getMetaDataDoc(String toplevelCorpusName, String documentName) {
    List<Annotation> result = new ArrayList<Annotation>();
    WebResource res = Helper.getAnnisWebResource();
    try {
        res = res.path("meta").path("doc").path(urlPathEscape.escape(toplevelCorpusName));
        res = res.path(urlPathEscape.escape(documentName));

        result = res.get(new GenericType<List<Annotation>>() {
        });
    } catch (UniformInterfaceException ex) {
        log.error(null, ex);
        Notification.show("Remote exception: " + ex.getLocalizedMessage(), Notification.Type.WARNING_MESSAGE);
    } catch (ClientHandlerException ex) {
        log.error(null, ex);
        Notification.show("Remote exception: " + ex.getLocalizedMessage(), Notification.Type.WARNING_MESSAGE);
    }
    return result;
}

From source file:annis.libgui.Helper.java

License:Apache License

/**
 * Retrieve all the meta data for a given document of a corpus including the
 * metadata of all corora in the path to the document.
 *
 * @param toplevelCorpusName Specifies the the toplevel corpus
 * @param documentName Specifies the document
 * @return Returns also the metada of the all parent corpora. There must be at
 * least one of them.//ww w  .j a v  a2s .co m
 */
public static List<Annotation> getMetaData(String toplevelCorpusName, String documentName) {
    List<Annotation> result = new ArrayList<Annotation>();
    WebResource res = Helper.getAnnisWebResource();
    try {
        res = res.path("meta").path("doc").path(urlPathEscape.escape(toplevelCorpusName));

        if (documentName != null) {
            res = res.path(urlPathEscape.escape(documentName));
        }

        if (documentName != null && !toplevelCorpusName.equals(documentName)) {
            res = res.path("path");
        }

        result = res.get(new GenericType<List<Annotation>>() {
        });
    } catch (UniformInterfaceException ex) {
        log.error(null, ex);
        Notification.show("Remote exception: " + ex.getLocalizedMessage(), Notification.Type.WARNING_MESSAGE);
    } catch (ClientHandlerException ex) {
        log.error(null, ex);
        Notification.show("Remote exception: " + ex.getLocalizedMessage(), Notification.Type.WARNING_MESSAGE);
    }
    return result;
}

From source file:annis.visualizers.component.tree.TigerTreeVisualizer.java

License:Apache License

@Override
public void writeOutput(VisualizerInput input, OutputStream outstream) {
    AnnisResult result = input.getResult();
    graphtools = new AnnisGraphTools(input);
    List<AbstractImageGraphicsItem> layouts = new LinkedList<AbstractImageGraphicsItem>();

    double width = 0;
    double maxheight = 0;

    for (DirectedGraph<AnnisNode, Edge> g : graphtools.getSyntaxGraphs()) {
        if (g.getEdgeCount() > 0 && g.getVertexCount() > 0) {

            ConstituentLayouter<AbstractImageGraphicsItem> cl = new ConstituentLayouter<AbstractImageGraphicsItem>(
                    g, getBackend(), labeler, styler, input, graphtools);

            AbstractImageGraphicsItem item = cl.createLayout(new LayoutOptions(VerticalOrientation.TOP_ROOT,
                    AnnisGraphTools.detectLayoutDirection(result.getGraph())));

            Rectangle2D treeSize = item.getBounds();

            maxheight = Math.max(maxheight, treeSize.getHeight());
            width += treeSize.getWidth();
            layouts.add(item);/* w  w  w .ja  v  a2 s  .c  o m*/
        }
    }

    BufferedImage image;
    if (width == 0 || maxheight == 0) {
        Notification.show("Can't generate tree visualization.", Notification.Type.WARNING_MESSAGE);
        image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
    } else {
        image = new BufferedImage((int) (width + (layouts.size() - 1) * TREE_DISTANCE + 2 * SIDE_MARGIN),
                (int) (maxheight + 2 * TOP_MARGIN), BufferedImage.TYPE_INT_ARGB);
        Graphics2D canvas = createCanvas(image);
        double xOffset = SIDE_MARGIN;
        for (AbstractImageGraphicsItem item : layouts) {
            AffineTransform t = canvas.getTransform();
            Rectangle2D bounds = item.getBounds();
            canvas.translate(xOffset, TOP_MARGIN + maxheight - bounds.getHeight());
            renderTree(item, canvas);
            xOffset += bounds.getWidth() + TREE_DISTANCE;
            canvas.setTransform(t);
        }
    }
    try {
        ImageIO.write(image, "png", outstream);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

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

License:Apache License

public VisualizationDefinition[] parseDefinitions(String toplevelCorpusName, Properties mappings) {
    InputStream inStreamConfigRaw = null;

    String visConfigName = mappings.getProperty("config");

    if (visConfigName == null) {
        inStreamConfigRaw = HTMLVis.class.getResourceAsStream("defaultvis.config");
    } else {//from  w ww.ja  v  a  2s. c o m
        WebResource resBinary = Helper.getAnnisWebResource().path("query/corpora/").path(toplevelCorpusName)
                .path(toplevelCorpusName).path("binary").path(visConfigName + ".config");

        ClientResponse response = resBinary.get(ClientResponse.class);
        if (response.getStatus() == ClientResponse.Status.OK.getStatusCode()) {
            inStreamConfigRaw = response.getEntityInputStream();
        }
    }

    if (inStreamConfigRaw == null) {
        Notification.show(
                "ERROR: html visualization configuration \"" + visConfigName + "\" not found in database",
                Notification.Type.ERROR_MESSAGE);
    } else {

        try (InputStream inStreamConfig = inStreamConfigRaw) {

            VisParser p = new VisParser(inStreamConfig);
            return p.getDefinitions();
        } catch (IOException | VisParserException ex) {
            log.error("Could not parse the HTML visualization configuration file", ex);
            Notification.show("Could not parse the HTML visualization configuration file", ex.getMessage(),
                    Notification.Type.ERROR_MESSAGE);
        }
    }
    return null;
}

From source file:ar.com.zir.cipres.ui.forms.CipresSystemUserForm.java

@Override
protected void bindAdditionalFields(FieldGroup binder) {
    super.bindAdditionalFields(binder);
    PasswordField pwd = new PasswordField("Contrasea");
    pwd.setRequired(true);//from w  w w.  java2 s .  c  om
    pwd.setImmediate(true);
    pwd.setReadOnly(true);
    pwd.addValueChangeListener((Property.ValueChangeEvent event) -> {
        //            if (isEditing() && getFieldValue("password") != null && getFieldValue("password").equals("000000")) {
        //                Notification.show("Password invlido", Notification.Type.ERROR_MESSAGE);
        //                setFieldValue("password", null);
        //            }
        updateUiPersistence(action, getBeanItem().getBean(), true);
    });
    pwd.addTextChangeListener((TextChangeEvent event) -> {
        if (event.getText().equals("000000")) {
            Notification.show("Password invlido", Notification.Type.ERROR_MESSAGE);
            setFieldValue("password", null);
        }
    });
    pwd.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.EAGER);
    pwd.addStyleName("visible");
    pwd.setNullRepresentation("");
    registerField("password", pwd);
    binder.bind(pwd, "password");
    grid.addComponent(pwd);
    grid.setRows(2);
    grid.addComponent(getTwinCol(binder), 0, 1, 1, 1);
}

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

License:LGPL

public AccountingRecordInputFields(AccountRecordData data) {
    super(3, 1);//w  w  w .jav  a  2 s  . c o m
    AccountingDataProvider dataProvider = AccountingDataProvider.getInstance();
    setSpacing(true);
    // Add AccountNumber
    accountNumberInputField = new AccountNumberInputField();
    accountNumberInputField.setCaption("Erste zwei Stellen:");
    accountNumberInputField.setWidth("3em");
    addComponent(accountNumberInputField, 0, 0);
    // Add DD AccountNames
    ddAccountNames = new ComboBox("Kontenname:");
    ddAccountNames.addItems((Object[]) AccountingDataProvider.getInstance().getAllAccountNames());
    ddAccountNames.setWidth("20em");
    addComponent(ddAccountNames, 1, 0);
    // Add Curreny field
    currencyTextBox = new CurrencyTextBox();
    currencyTextBox.setCaption("Betrag ():");
    currencyTextBox.setWidth("8em");
    addComponent(currencyTextBox, 2, 0);
    // set default values from AccountRecordData
    if (data.accountName != null) {
        if (!dataProvider.containsString(data.accountName)) {
            Notification.show('"' + data.accountName + "\" ist kein zulssiger Kontenname",
                    Type.WARNING_MESSAGE);
        }
        ddAccountNames.setValue(data.accountName);
        ddAccountNames.setEnabled(data.accountName == null || data.accountName.length() == 0);
    }
    if (data.accountNumber > 0) {
        if (!dataProvider.containsNumber(data.accountNumber)) {
            Notification.show('"' + data.accountNumber + "\" ist keine zulssige Kontennummer",
                    Type.WARNING_MESSAGE);
        }
        accountNumberInputField.setValue(Integer.toString(data.accountNumber));
        accountNumberInputField.setEnabled(false);
    }
    if (data.value >= 0.01f) {
        currencyTextBox.setValue(Float.toString(data.value));
        currencyTextBox.setEnabled(false);
    }
}

From source file:at.reisisoft.jku.ce.adaptivelearning.vaadin.ui.topic.accounting.AccountingRecordInputFields.java

License:LGPL

public AccountingRecordInputFields(AccountRecordData data) {
    super(3, 1);//  w ww  .  j  a va 2 s.  co  m
    AccountingDataProvider dataProvider = AccountingDataProvider.getInstance();
    setSpacing(true);
    // Add AccountNumber
    accountNumberInputField = new AccountNumberInputField();
    accountNumberInputField.setCaption("First 2 digits:");
    accountNumberInputField.setWidth("3em");
    addComponent(accountNumberInputField, 0, 0);
    // Add DD AccountNames
    ddAccountNames = new ComboBox("Account name:");
    ddAccountNames.addItems((Object[]) AccountingDataProvider.getInstance().getAllAccountNames());
    ddAccountNames.setWidth("20em");
    addComponent(ddAccountNames, 1, 0);
    // Add Curreny field
    currencyTextBox = new CurrencyTextBox();
    currencyTextBox.setCaption("Figure ():");
    currencyTextBox.setWidth("8em");
    addComponent(currencyTextBox, 2, 0);
    // set default values from AccountRecordData
    if (data.accountName != null) {
        if (!dataProvider.containsString(data.accountName)) {
            Notification.show('"' + data.accountName + "\" is not a known account name", Type.WARNING_MESSAGE);
        }
        ddAccountNames.setValue(data.accountName);
        ddAccountNames.setEnabled(data.accountName == null || data.accountName.length() == 0);
    }
    if (data.accountNumber > 0) {
        if (!dataProvider.containsNumber(data.accountNumber)) {
            Notification.show('"' + data.accountNumber + "\" is not a known account number",
                    Type.WARNING_MESSAGE);
        }
        accountNumberInputField.setValue(Integer.toString(data.accountNumber));
        accountNumberInputField.setEnabled(false);
    }
    if (data.value >= 0.01f) {
        currencyTextBox.setValue(Float.toString(data.value));
        currencyTextBox.setEnabled(false);
    }
}

From source file:by.bigvova.ui.LoginUI.java

License:Apache License

private void login(final String name, final String password, final boolean isRememberMe) {
    try {/* w  ww  .  j a  va2s  .  c o  m*/
        vaadinSecurity.login(name, password, isRememberMe);
    } catch (AuthenticationException ex) {
        Notification.show(ex.getMessage(), Notification.Type.ERROR_MESSAGE);
    } catch (Exception ex) {
        Notification.show(ex.getMessage(), Notification.Type.ERROR_MESSAGE);
    }
}

From source file:co.edu.icesi.academ.client.perfiles.administrador.PanelAlcance.java

License:Open Source License

/**
 * The constructor should first build the main layout, set the composition
 * root and then do any custom initialization.
 * // w w w. j  ava 2  s .  c o  m
 * The constructor will not be automatically regenerated by the visual
 * editor.
 */
public PanelAlcance() {
    buildMainLayout();
    setCompositionRoot(mainLayout);

    tableResultadoAlcance.addContainerProperty("Resultado de aprendizaje", String.class, null);
    tableResultadoAlcance.addContainerProperty("Alcance", ComboBox.class, null);
    tableResultadoAlcance.setSelectable(true);
    tableResultadoAlcance.setImmediate(true);

    table_bloques.addContainerProperty("Bloques", BloqueBO.class, null);
    table_bloques.setSelectable(true);
    table_bloques.setImmediate(true);
    table_bloques.setNullSelectionAllowed(false);
    table_bloques.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            try {
                int i = Integer.parseInt(table_bloques.getValue().toString());
                ControladorAdministrador.getInstance().cargarMateriasAlcance(listBloqueBOs.get(i));
                ControladorAdministrador.getInstance().cargarCompetencias(listBloqueBOs.get(i));
            } catch (Exception e) {
                Notification.show(e.getMessage(), Type.ERROR_MESSAGE);
            }
        }
    });

    tableMaterias.addContainerProperty("Cdigo", String.class, null);
    tableMaterias.addContainerProperty("Materia", MateriaBO.class, null);
    tableMaterias.setSelectable(true);
    tableMaterias.setImmediate(true);
    tableMaterias.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            try {
                int i = Integer.parseInt(tableMaterias.getValue().toString());
                ControladorAdministrador.getInstance().getAcademUI().mostrarNotificacion("Tabla Materias",
                        listMatBOs.get(i) + " materia");
            } catch (Exception e) {
                // ControladorAdministrador.getInstance().cargarMateriasAlcance((BloqueBO)table_bloques.getValue());               
            }
        }
    });

    button_guardarAlcance.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {

        }
    });

    tableCompetencias.addContainerProperty("Competencia", CompetenciaBO.class, null);
    tableCompetencias.setSelectable(true);
    tableCompetencias.setImmediate(true);
    tableCompetencias.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {

        }
    });
}

From source file:co.edu.icesi.academ.client.perfiles.administrador.PanelCrearMateria.java

License:Open Source License

public void crearMateria() {
    String codigo = txt_codigo.getValue();
    String nombre = txt_nombre.getValue();
    if (codigo != "" && nombre != "") {
        MateriaBO materiaBO = new MateriaBO();
        materiaBO.setCodigo(codigo);// w  ww.  j ava2 s.  c  o  m
        materiaBO.setNombre(nombre);
        ControladorAdministrador.getInstance().crearMateria(materiaBO);
        ControladorAdministrador.getInstance().getAcademUI().cerrarVentanaEmergente();
    } else
        Notification.show("Ingreso mal los datos", Type.ERROR_MESSAGE);

}