Example usage for com.vaadin.ui Label addStyleName

List of usage examples for com.vaadin.ui Label addStyleName

Introduction

In this page you can find the example usage for com.vaadin.ui Label addStyleName.

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:annis.gui.components.ExceptionDialog.java

License:Apache License

public ExceptionDialog(Throwable ex, String caption) {
    this.cause = ex;
    Preconditions.checkNotNull(ex);//from w  w  w.  j  a v a 2  s.  c o m

    layout = new VerticalLayout();
    setContent(layout);
    layout.setWidth("100%");
    layout.setHeight("-1");

    if (caption == null) {
        setCaption("Unexpected error");
    } else {
        setCaption(caption);
    }

    Label lblInfo = new Label("An unexpected error occured.<br />The error message was:", ContentMode.HTML);
    lblInfo.setHeight("-1px");
    lblInfo.setWidth("100%");
    layout.addComponent(lblInfo);
    lblInfo.addStyleName("exception-message-caption");

    String message = ex.getMessage();
    if (message == null || message.isEmpty()) {
        message = "<no message>";
    }
    Label lblMessage = new Label(message);
    lblMessage.addStyleName("exception-message-content");
    lblMessage.setHeight("-1px");
    lblMessage.setWidth("100%");
    layout.addComponent(lblMessage);

    actionsLayout = new HorizontalLayout();
    actionsLayout.addStyleName("exception-dlg-details");
    actionsLayout.setWidth("100%");
    actionsLayout.setHeight("-1px");
    layout.addComponent(actionsLayout);

    btDetails = new Button("Show Details", this);
    btDetails.setStyleName(BaseTheme.BUTTON_LINK);
    actionsLayout.addComponent(btDetails);

    btReportBug = new Button("Report Problem", this);
    btReportBug.setStyleName(BaseTheme.BUTTON_LINK);
    btReportBug.setVisible(false);
    btReportBug.setIcon(FontAwesome.ENVELOPE_O);
    UI ui = UI.getCurrent();
    if (ui instanceof AnnisUI) {
        btReportBug.setVisible(((AnnisUI) ui).canReportBugs());
    }
    actionsLayout.addComponent(btReportBug);
    actionsLayout.setComponentAlignment(btDetails, Alignment.TOP_LEFT);
    actionsLayout.setComponentAlignment(btReportBug, Alignment.TOP_RIGHT);

    lblStacktrace = new Label(Helper.convertExceptionToMessage(ex), ContentMode.PREFORMATTED);
    detailsPanel = new Panel(lblStacktrace);
    detailsPanel.setWidth("100%");
    detailsPanel.setHeight("300px");
    detailsPanel.setVisible(false);
    lblStacktrace.setSizeUndefined();
    lblStacktrace.setVisible(true);
    layout.addComponent(detailsPanel);

    btClose = new Button("OK", this);
    layout.addComponent(btClose);

    layout.setComponentAlignment(btClose, Alignment.BOTTOM_CENTER);
    layout.setExpandRatio(detailsPanel, 0.0f);
    layout.setExpandRatio(actionsLayout, 1.0f);
}

From source file:annis.gui.ExampleQueriesPanel.java

License:Apache License

/**
 * Sets some layout properties.//  www  .j  av a 2 s.c  o m
 */
private void setUpTable() {
    setSizeFull();
    // expand the table
    table.setSizeFull();

    // Allow selecting items from the table.
    table.setSelectable(false);

    // Send changes in selection immediately to server.
    table.setImmediate(true);

    // set custom style
    table.addStyleName("example-queries-table");

    // put stripes to the table
    table.addStyleName(ChameleonTheme.TABLE_STRIPED);

    // configure columns
    table.addGeneratedColumn(COLUMN_OPEN_CORPUS_BROWSER, new ShowCorpusBrowser());

    table.addGeneratedColumn(COLUMN_EXAMPLE_QUERY, new QueryColumn());

    table.addGeneratedColumn(COLUMN_DESCRIPTION, new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            ExampleQuery eQ = (ExampleQuery) itemId;
            Label l = new Label(eQ.getDescription());
            l.setContentMode(ContentMode.TEXT);
            l.addStyleName(Helper.CORPUS_FONT_FORCE);
            return l;
        }
    });

    table.setVisibleColumns(
            new Object[] { COLUMN_EXAMPLE_QUERY, COLUMN_DESCRIPTION, COLUMN_OPEN_CORPUS_BROWSER });

    table.setColumnExpandRatio(table.getVisibleColumns()[0], 0.40f);
    table.setColumnExpandRatio(table.getVisibleColumns()[1], 0.40f);

    table.setColumnHeader(table.getVisibleColumns()[0], "Example Query");
    table.setColumnHeader(table.getVisibleColumns()[1], "Description");
    table.setColumnHeader(table.getVisibleColumns()[2], "open corpus browser");

}

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

License:Apache License

public void showNoResult() {
    resultLayout.removeAllComponents();//  ww w  . j ava2s  .  c o  m
    currentResults = 0;

    // nothing to show since we have an empty result
    Label lblNoResult = new Label("No matches found.");
    lblNoResult.setWidth("100%");
    lblNoResult.addStyleName("result-view-no-content");

    resultLayout.addComponent(lblNoResult);

    showFinishedSubgraphSearch();
}

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

License:Apache License

public SingleResultPanel(final SDocument result, Match match, long resultNumber,
        ResolverProvider resolverProvider, PluginSystem ps, AnnisUI ui, Set<String> visibleTokenAnnos,
        String segmentationName, QueryController controller, InstanceConfig instanceConfig,
        DisplayedResultQuery query) {/* ww  w  . jav a 2 s  .  c om*/
    this.ps = ps;
    this.ui = ui;
    this.result = result;
    this.segmentationName = segmentationName;
    this.queryController = controller;
    this.resultNumber = resultNumber;
    this.resolverProvider = resolverProvider;
    this.visibleTokenAnnos = visibleTokenAnnos;
    this.instanceConfig = instanceConfig;
    this.query = query;
    this.match = match;

    calculateHelperVariables();

    setWidth("100%");
    setHeight("-1px");

    if (query != null && query.getSelectedMatches().contains(resultNumber)) {
        addStyleName("selected-match");
    }

    infoBar = new HorizontalLayout();
    infoBar.addStyleName("info-bar");
    infoBar.setWidth("100%");
    infoBar.setHeight("-1px");

    Label lblNumber = new Label("" + (resultNumber + 1));
    infoBar.addComponent(lblNumber);
    lblNumber.setSizeUndefined();

    btInfo = new Button();
    btInfo.setStyleName(ValoTheme.BUTTON_BORDERLESS);
    btInfo.setIcon(ICON_RESOURCE);
    btInfo.setDescription("Show metadata");
    btInfo.addClickListener((Button.ClickListener) this);
    infoBar.addComponent(btInfo);

    btLink = new Button();
    btLink.setStyleName(ValoTheme.BUTTON_BORDERLESS);
    btLink.setIcon(FontAwesome.SHARE_ALT);
    btLink.setDescription("Share match reference");
    btLink.setDisableOnClick(true);
    btLink.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            showShareSingleMatchGenerator();
        }
    });
    infoBar.addComponent(btLink);

    /**
     * Extract the top level corpus name and the document name of this single
     * result.
     */
    path = CommonHelper.getCorpusPath(result.getGraph(), result);
    Collections.reverse(path);
    corpusName = path.get(0);
    documentName = path.get(path.size() - 1);

    MinMax minMax = getIds(result.getDocumentGraph());

    // build label
    StringBuilder sb = new StringBuilder("Path: ");
    sb.append(StringUtils.join(path, " > "));
    sb.append(" (" + minMax.segName + " ").append(minMax.min);
    sb.append(" - ").append(minMax.max).append(")");

    Label lblPath = new Label(sb.toString());
    lblPath.addStyleName("path-label");

    lblPath.setWidth("100%");
    lblPath.setHeight("-1px");
    infoBar.addComponent(lblPath);
    infoBar.setExpandRatio(lblPath, 1.0f);
    infoBar.setSpacing(false);

    this.visualizerState = new HashMap<>();

    // init context combox
    lftCtxCombo = new ComboBox();
    rghtCtxCombo = new ComboBox();

    lftCtxCombo.setWidth(50, Unit.PIXELS);
    rghtCtxCombo.setWidth(50, Unit.PIXELS);

    lftCtxCombo.setNullSelectionAllowed(false);
    rghtCtxCombo.setNullSelectionAllowed(false);

    lftCtxCombo.addStyleName(ValoTheme.COMBOBOX_SMALL);
    rghtCtxCombo.addStyleName(ValoTheme.COMBOBOX_SMALL);

    IndexedContainer lftCtxContainer = new IndexedContainer();
    IndexedContainer rghtCtxContainer = new IndexedContainer();

    // and a property for sorting
    lftCtxContainer.addContainerProperty("number", Integer.class, 0);
    rghtCtxContainer.addContainerProperty("number", Integer.class, 0);

    for (int i = 0; i < 30; i += 5) {
        lftCtxContainer.addItem(i).getItemProperty("number").setValue(i);
        rghtCtxContainer.addItem(i).getItemProperty("number").setValue(i);
    }

    int lftContextIdx = query == null ? 0 : query.getLeftContext();
    lftCtxContainer.addItemAt(lftContextIdx, lftContextIdx);
    lftCtxContainer.sort(new Object[] { "number" }, new boolean[] { true });

    int rghtCtxIdx = query == null ? 0 : query.getRightContext();
    rghtCtxContainer.addItem(rghtCtxIdx);

    rghtCtxContainer.sort(new Object[] { "number" }, new boolean[] { true });

    lftCtxCombo.setContainerDataSource(lftCtxContainer);
    rghtCtxCombo.setContainerDataSource(rghtCtxContainer);

    lftCtxCombo.select(lftContextIdx);
    rghtCtxCombo.select(rghtCtxIdx);

    lftCtxCombo.setNewItemsAllowed(true);
    rghtCtxCombo.setNewItemsAllowed(true);

    lftCtxCombo.setImmediate(true);
    rghtCtxCombo.setImmediate(true);

    lftCtxCombo.setNewItemHandler(new AddNewItemHandler(lftCtxCombo));
    rghtCtxCombo.setNewItemHandler(new AddNewItemHandler(rghtCtxCombo));

    lftCtxCombo.addValueChangeListener(new ContextChangeListener(resultNumber, true));
    rghtCtxCombo.addValueChangeListener(new ContextChangeListener(resultNumber, false));

    Label leftCtxLabel = new Label("left context: ");
    Label rightCtxLabel = new Label("right context: ");

    leftCtxLabel.setWidth("-1px");
    rightCtxLabel.setWidth("-1px");

    HorizontalLayout ctxLayout = new HorizontalLayout();
    ctxLayout.setSpacing(true);
    ctxLayout.addComponents(leftCtxLabel, lftCtxCombo, rightCtxLabel, rghtCtxCombo);
    infoBar.addComponent(ctxLayout);

    addComponent(infoBar);
    initVisualizer();
}

From source file:annis.visualizers.component.RawTextVisualizer.java

License:Apache License

@Override
public Panel createComponent(VisualizerInput visInput, VisualizationToggle visToggle) {

    // get config for alignment
    boolean vertical = Boolean.parseBoolean(visInput.getMappings().getProperty("vertical", "true"));

    // get the texts
    RawTextWrapper texts = visInput.getRawText();

    // create the main panel
    Panel p = new Panel();
    p.setSizeFull();/*from w  ww  . ja  va 2 s .c  o  m*/

    // some layout configuration
    p.addStyleName(ChameleonTheme.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);
            }

            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);
    } else {
        lblText = new Label(NO_TEXT);
    }

    lblText.setSizeFull();
    lblText.addStyleName(LABEL_CLASS);
    p.setContent(lblText);

    return p;
}

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 ww.ja  va  2  s. com*/
    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.peppol.webgui.app.MainWindow.java

License:Mozilla Public License

@SuppressWarnings("serial")
private void initUI() {

    final VerticalLayout root = new VerticalLayout();
    root.setMargin(false);//from  w w  w .  jav  a  2 s.c om
    setContent(root);

    // createTopBar();
    // Changed with menuBar -- under testing
    createMenuBar();
    // Changed with custom layout using bootstrap -- under testing
    // createHeaderMenu();

    final UserFolder<File> userFolder = new UserFolder<File>();
    final long polling = 20000;
    int draftInvoicesNum = um.countItemsInSpace(um.getDrafts());
    int inboxInvoicesNum = um.countItemsInSpace(um.getInbox());
    int outboxInvoicesNum = um.countItemsInSpace(um.getOutbox());
    //Buttons
    final NativeButton inboxInvoices = new NativeButton("Invoices (" + inboxInvoicesNum + ")");
    final NativeButton outboxInvoices = new NativeButton("Invoices (" + outboxInvoicesNum + ")");
    final NativeButton draftInvoices = new NativeButton("Invoices (" + draftInvoicesNum + ")");

    //thread
    final Thread tFolderCount = new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                while (true) {
                    int countDrafts = um.countItemsInSpace(um.getDrafts());
                    int countInbox = um.countItemsInSpace(um.getInbox());
                    int countOutbox = um.countItemsInSpace(um.getOutbox());
                    synchronized (MainWindow.this.getApplication()) {
                        String labelD = draftInvoices.getCaption();
                        labelD = labelD.replaceFirst("[\\d]+", "" + countDrafts);
                        draftInvoices.setCaption(labelD);

                        String labelI = inboxInvoices.getCaption();
                        labelI = labelI.replaceFirst("[\\d]+", "" + countInbox);
                        inboxInvoices.setCaption(labelI);

                        String labelO = outboxInvoices.getCaption();
                        labelO = labelO.replaceFirst("[\\d]+", "" + countOutbox);
                        outboxInvoices.setCaption(labelO);

                        itemsPanel.reloadTable(userFolder);
                    }
                    Thread.sleep(polling);
                }
            } catch (InterruptedException e) {
                System.out.println("Thread folders interrupted!!!");
            }
        }
    });

    // ------ START: Left NavBar -------
    final CssLayout leftNavBar = new CssLayout();
    leftNavBar.setStyleName("sidebar-menu");
    leftNavBar.setSizeFull();
    leftNavBar.setWidth("220px");

    // User theUser = (User) getApplication().getUser();
    final Label homeLbl = new Label("HOME");
    homeLbl.addStyleName("blue");
    leftNavBar.addComponent(homeLbl);

    leftNavBar.addComponent(new Label("INBOX"));
    final NativeButton catalogueBtn = new NativeButton("Catalogue");
    leftNavBar.addComponent(catalogueBtn);
    leftNavBar.addComponent(new NativeButton("Orders"));
    //leftNavBar.addComponent (new NativeButton ("Invoices"));
    //int inboxInvoicesNum = um.countItemsInSpace(um.getInbox());
    //inboxInvoices = new NativeButton ("Invoices ("+inboxInvoicesNum+")");
    inboxInvoices.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            inboxInvoices.setCaption("Invoices (" + um.countItemsInSpace(um.getInbox()) + ")");
            userFolder.setFolder(um.getInbox().getFolder());
            userFolder.setName(um.getInbox().getName());
            showInitialMainContent(userFolder);
            draftInvoices.removeStyleName("v-bold-nativebuttoncaption");
        }
    });
    leftNavBar.addComponent(inboxInvoices);

    leftNavBar.addComponent(new Label("DRAFTS"));
    leftNavBar.addComponent(new NativeButton("Catalogue"));
    leftNavBar.addComponent(new NativeButton("Orders"));
    //int draftInvoicesNum = um.countItemsInSpace(um.getDrafts());
    //draftInvoices = new NativeButton ("Invoices ("+draftInvoicesNum+")");
    draftInvoices.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            draftInvoices.setCaption("Invoices (" + um.countItemsInSpace(um.getDrafts()) + ")");
            userFolder.setFolder(um.getDrafts().getFolder());
            userFolder.setName(um.getDrafts().getName());
            showInitialMainContent(userFolder);
            draftInvoices.removeStyleName("v-bold-nativebuttoncaption");
        }
    });
    leftNavBar.addComponent(draftInvoices);

    leftNavBar.addComponent(new Label("OUTBOX"));
    leftNavBar.addComponent(new NativeButton("Catalogue"));
    leftNavBar.addComponent(new NativeButton("Orders"));
    //leftNavBar.addComponent (new NativeButton ("Invoices"));
    //int outboxInvoicesNum = um.countItemsInSpace(um.getOutbox());
    //outboxInvoices = new NativeButton ("Invoices ("+outboxInvoicesNum+")");
    outboxInvoices.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            outboxInvoices.setCaption("Invoices (" + um.countItemsInSpace(um.getOutbox()) + ")");
            userFolder.setFolder(um.getOutbox().getFolder());
            userFolder.setName(um.getOutbox().getName());
            showInitialMainContent(userFolder);
            draftInvoices.removeStyleName("v-bold-nativebuttoncaption");
        }
    });
    leftNavBar.addComponent(outboxInvoices);

    leftNavBar.addComponent(new Label("SETTINGS"));
    leftNavBar.addComponent(new NativeButton("My Profile"));
    leftNavBar.addComponent(new NativeButton("Customers"));
    leftNavBar.addComponent(new NativeButton("Suppliers"));

    final Embedded peppolLogoImg = new Embedded(null, new ExternalResource("img/peppol_logo.png"));

    peppolLogoImg.setStyleName("logo");
    leftNavBar.addComponent(peppolLogoImg);

    middleContentLayout.addComponent(leftNavBar);

    /*Button refreshButton = new Button("Refresh");
    refreshButton.addListener(new Button.ClickListener() {
      @Override
      public void buttonClick(ClickEvent event) {
         int draftInvoices = um.countItemsInSpace(um.getDrafts());
         invoices.setCaption("Invoices ("+draftInvoices+")");
      }
    });
    leftNavBar.addComponent(refreshButton);*/

    //workaround so that thread refreshes UI. It seems that when a ProgressIndicator is present,
    //all components receive server side refreshes
    ProgressIndicator p = new ProgressIndicator();
    p.setPollingInterval((int) polling);
    p.setWidth("0px");
    p.setHeight("0px");
    leftNavBar.addComponent(p);

    showInitialMainContent(null);
    draftInvoices.click();
    tFolderCount.start();
    draftInvoices.addStyleName("v-bold-nativebuttoncaption");
}

From source file:at.peppol.webgui.app.MainWindow.java

License:Mozilla Public License

public void showInitialMainContent(UserFolder<?> userFolder) {
    // ------ START: Main Content -------
    final VerticalLayout mainContentLayout = new VerticalLayout();

    mainContentLayout.addStyleName("margin");
    final VerticalLayout topmain = new VerticalLayout();
    topmain.setSpacing(true);/*from   w ww. j av  a2 s.  com*/
    topmain.setWidth("100%");
    final Label bigPAWGLabel = new Label("PEPPOL Post Award Web GUI");
    bigPAWGLabel.setStyleName("huge");
    topmain.addComponent(bigPAWGLabel);
    final Label blahContent = new Label(
            "This is a mockup of the GUI that is going" + " to be the PAWG. It is created by the Greek"
                    + " and Austrian teams as a fine replacement " + " of the Demo Client");
    blahContent.setWidth("80%");
    blahContent.addStyleName("big");
    //topmain.addComponent (blahContent);
    //HorizontalLayout itemsPanel = new ShowItemsPanel("Items", um, userFolder);

    final ShowItemsPanel itemsPanel = new ShowItemsPanel("Items", um, userFolder);
    this.itemsPanel = itemsPanel;
    topmain.addComponent(itemsPanel);
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setSpacing(true);
    topmain.addComponent(buttonsLayout);
    Button loadButton = new Button("Load invoice");
    //topmain.addComponent(loadButton);
    buttonsLayout.addComponent(loadButton);
    loadButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Table table = itemsPanel.getTable();
            if (table.getValue() != null) {
                //InvoiceType inv = (InvoiceType)table.getItem(table.getValue()).getItemProperty("invoice").getValue();
                //InvoiceBean invBean = (InvoiceBean)table.getItem(table.getValue());
                InvoiceBean invBean = ((InvoiceBeanContainer) table.getContainerDataSource())
                        .getItem(table.getValue()).getBean();
                //System.out.println("Invoice is: "+invBean);
                showInvoiceForm(invBean);
            }
        }
    });

    Button sendButton = new Button("Send invoice");
    buttonsLayout.addComponent(sendButton);
    sendButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            try {
                Table table = itemsPanel.getTable();
                if (table.getValue() != null) {
                    InvoiceBean invBean = ((InvoiceBeanContainer) table.getContainerDataSource())
                            .getItem(table.getValue()).getBean();
                    String path = invBean.getFolderEntryID();
                    FileSystemResource s = new FileSystemResource(path);
                    SendInvoice.sendDocument(s);

                    //file is sent. move invoice to outbox
                    um.moveInvoice(invBean, um.getDrafts(), um.getOutbox());
                    //itemsPanel.getTable().requestRepaint();
                    itemsPanel.init(um.getDrafts());
                }
            } catch (FileNotFoundException e) {
                getWindow().showNotification("Could not find invoice file", Notification.TYPE_ERROR_MESSAGE);
            } catch (Exception e) {
                getWindow().showNotification("Could not send invoice. AP connection error",
                        Notification.TYPE_ERROR_MESSAGE);
                e.printStackTrace();
            }
        }
    });

    final Button learnMoreBtn = new Button("Learn More >>");
    learnMoreBtn.addStyleName("tall default");
    //topmain.addComponent (learnMoreBtn);

    mainContentLayout.addComponent(topmain);
    // ------ END: Main Content ---------
    mainContentLayout.setHeight("100%");
    mainContentLayout.setSizeFull();

    mainContentLayout.setSpacing(true);
    mainContentLayout.setWidth("100%");
    middleContentLayout.setWidth("100%");
    middleContentLayout.setHeight("100%");
    middleContentLayout.setMargin(true);
    // --------
    addComponent(middleContentLayout);
    addComponent(footerLayout);
    if (mainContentComponent != null) {
        middleContentLayout.replaceComponent(mainContentComponent, mainContentLayout);
    } else {
        middleContentLayout.addComponent(mainContentLayout);
    }
    middleContentLayout.setExpandRatio(mainContentLayout, 1);
    mainContentComponent = mainContentLayout;
}

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

License:Apache License

private Component buildLabels() {
    CssLayout labels = new CssLayout();
    labels.addStyleName("labels");

    Label welcome = new Label("Welcome");
    welcome.setSizeUndefined();//from   w w  w. j  av a2s .  c  o m
    welcome.addStyleName(ValoTheme.LABEL_H4);
    welcome.addStyleName(ValoTheme.LABEL_COLORED);
    labels.addComponent(welcome);

    Label title = new Label("QuickTickets Dashboard");
    title.setSizeUndefined();
    title.addStyleName(ValoTheme.LABEL_H3);
    title.addStyleName(ValoTheme.LABEL_LIGHT);
    labels.addComponent(title);
    return labels;
}

From source file:by.bigvova.views.HomeView.java

License:Apache License

public HomeView() {
    setSpacing(true);//from  w  w w.j  av a 2 s .co m
    setMargin(true);
    setSizeFull();

    Label header = new Label("   -=FoodNote=-");
    header.addStyleName(ValoTheme.LABEL_H1);
    addComponent(header);
    Label body = new Label(
            "<h3> ?? ? ? <b>CRUD</b> ?  ? <b>enterprise</b> ."
                    + "   ?  ?? ,    ?  ? .</h3>"
                    + "? ?:" + "<ul>"
                    + "<li>?  ?  <b>Spring Boot</b>, ? ? - propertie .</li>"
                    + "<li>? ?  ?? ? ???   <b>Repository</b> - <b>Spring Data JPA</b>, <b>Hibernate</b> (<b>JdbcTemplate</b>  ?).</li>"
                    + "<li> ?? - ?? ,  :</li>"
                    + "<ul>" + "<li>  - <b>PostgreSQL</b></li>"
                    + "<li>connection pool - <b>HikariCP</b></li>" + "</ul>"
                    + "<li>? - <b>EhCache</b>.</li>"
                    + "<li> ? -  <b>EventBus</b>, ? <b>Google Guava</b>.</li>"
                    + "<li>?,  - <b>Spring Security</b>:</li>"
                    + "<ul>"
                    + "<li>    , ? <b>UserDetails</b></li>"
                    + "<li> ??   ? <b>BCrypt</b></li>"
                    + "<li>  <b>Remember Me</b> ??</li>"
                    + "</ul>" + "<li>? - <b>JUnit4</b></li>"
                    + "<li> - <b>slf4j</b>, <b>logback</b></li>"
                    + "<li>Front-end - <b>Vaadin framework</b>, <b>GWT</b></li>"
                    + "<li>   <b>Docker</b>      ? <b>Ubuntu Server 14.04</b></li>"
                    + "</ul>"
                    + "<p>? Spring Boot - Vaadin ?? : <a href=\"https://github.com/peholmst/vaadin4spring\">vaadin4spring</a></p>"
                    + "<p> ? <a href=\"https://github.com/BigVOVA/FoodNote\">github.com/BigVOVA/FoodNote</a></p>");
    body.setContentMode(ContentMode.HTML);
    VerticalLayout bodyLayout = new VerticalLayout();
    bodyLayout.setWidth(100, Unit.PERCENTAGE);
    bodyLayout.setMargin(new MarginInfo(false, true, false, true));
    bodyLayout.addComponent(body);
    Panel panel = new Panel();
    panel.setSizeFull();
    panel.setContent(bodyLayout);
    addComponent(panel);
    setExpandRatio(panel, 1);
}