Example usage for com.vaadin.ui Label setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:ac.uk.icl.dell.vaadin.glycanbuilder.MassOptionsDialog.java

License:Open Source License

@Override
public void initComponents() {
    isotopeSelect = new Select();
    isotopeSelect.addStyleName("igg-mass-options-panel-item");
    isotopeSelect.setNullSelectionAllowed(false);
    isotopeSelect.setNewItemsAllowed(false);
    isotopeSelect.setWidth("120px");

    derivatizationSelect = new Select();
    derivatizationSelect.addStyleName("igg-mass-options-panel-item");
    derivatizationSelect.setNullSelectionAllowed(false);
    derivatizationSelect.setNewItemsAllowed(false);
    derivatizationSelect.setWidth("120px");

    reducingEndSelect = new Select();
    reducingEndSelect.addStyleName("igg-mass-options-panel-item");
    reducingEndSelect.setNullSelectionAllowed(false);
    reducingEndSelect.setImmediate(true);
    reducingEndSelect.setNewItemsAllowed(false);
    reducingEndSelect.setWidth("120px");

    reducingEndSelect.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1067195208212460144L;

        @Override/* w w  w .  ja  v  a  2s.  co  m*/
        public void valueChange(ValueChangeEvent event) {
            if (((String) reducingEndSelect.getValue()).equals("Other...")) {
                otherNameField.setEnabled(true);
                otherMassField.setEnabled(true);
            } else {
                otherNameField.setEnabled(false);
                otherMassField.setEnabled(false);
            }
        }
    });

    otherNameField = new TextField();
    otherNameField.addStyleName("igg-mass-options-panel-item");
    otherNameField.setWidth("120px");

    otherMassField = new TextField();
    otherMassField.addStyleName("igg-mass-options-panel-item");
    otherMassField.setWidth("120px");

    negativeModeField = new CheckBox();
    negativeModeField.addStyleName("igg-mass-options-panel-item");

    hIonCountSelect = new Select("#H ions");
    hIonCountSelect.addStyleName("igg-mass-options-panel-item");
    hIonCountSelect.setNewItemsAllowed(false);
    hIonCountSelect.setWidth("120px");

    naIonCountSelect = new Select("#Na ions");
    naIonCountSelect.addStyleName("igg-mass-options-panel-item");
    naIonCountSelect.setNewItemsAllowed(false);
    naIonCountSelect.setWidth("120px");

    exNAIonCountSelect = new Select("ext. #Na ions");
    exNAIonCountSelect.addStyleName("igg-mass-options-panel-item");
    exNAIonCountSelect.setNewItemsAllowed(false);
    exNAIonCountSelect.setWidth("120px");

    liIonCountSelect = new Select("#Li ions");
    liIonCountSelect.addStyleName("igg-mass-options-panel-item");
    liIonCountSelect.setNewItemsAllowed(false);
    liIonCountSelect.setWidth("120px");

    exLIIonCountSelect = new Select("ext. #Li ions");
    exLIIonCountSelect.addStyleName("igg-mass-options-panel-item");
    exLIIonCountSelect.setNewItemsAllowed(false);
    exLIIonCountSelect.setWidth("120px");

    kIonCountSelect = new Select("#K ions");
    kIonCountSelect.addStyleName("igg-mass-options-panel-item");
    kIonCountSelect.setNewItemsAllowed(false);
    kIonCountSelect.setWidth("120px");

    exKIonCountSelect = new Select("ext. #K ions");
    exKIonCountSelect.addStyleName("igg-mass-options-panel-item");
    exKIonCountSelect.setNewItemsAllowed(false);
    exKIonCountSelect.setWidth("120px");

    clIonCountSelect = new Select("#Cl ions");
    clIonCountSelect.addStyleName("igg-mass-options-panel-item");
    clIonCountSelect.setNewItemsAllowed(false);
    clIonCountSelect.setWidth("120px");

    exClIonCountSelect = new Select("ext. #Cl ions");
    exClIonCountSelect.addStyleName("igg-mass-options-panel-item");
    exClIonCountSelect.setNewItemsAllowed(false);
    exClIonCountSelect.setWidth("120px");

    h2po4IonCountSelect = new Select("#H2PO4 ions");
    h2po4IonCountSelect.addStyleName("igg-mass-options-panel-item");
    h2po4IonCountSelect.setNewItemsAllowed(false);
    h2po4IonCountSelect.setWidth("120px");

    exH2po4IonCountSelect = new Select("ext. #H2PO4 ions");
    exH2po4IonCountSelect.addStyleName("igg-mass-options-panel-item");
    exH2po4IonCountSelect.setNewItemsAllowed(false);
    exH2po4IonCountSelect.setWidth("120px");

    //column,row
    layout.addComponent(new Label("Isotope"), 0, 0, 0, 0);
    layout.addComponent(isotopeSelect, 1, 0, 1, 0);
    layout.addComponent(new Label("Derivatization"), 0, 1, 0, 1);
    layout.addComponent(derivatizationSelect, 1, 1, 1, 1);
    layout.addComponent(new Label("Reducing end"), 0, 2, 0, 2);
    layout.addComponent(reducingEndSelect, 1, 2, 1, 2);

    {
        Label nameLabel = new Label("name");
        nameLabel.setWidth("40px");
        layout.addComponent(nameLabel, 1, 3, 1, 3);
        layout.addComponent(otherNameField, 2, 3, 2, 3);

        layout.setComponentAlignment(nameLabel, Alignment.MIDDLE_RIGHT);
    }

    {
        Label massLabel = new Label("mass");
        massLabel.setWidth("40px");
        layout.addComponent(massLabel, 1, 4, 1, 4);
        layout.addComponent(otherMassField, 2, 4, 2, 4);
        layout.setComponentAlignment(massLabel, Alignment.MIDDLE_RIGHT);
    }

    int row = 5;

    {
        Label divider = new Label("<hr/>", Label.CONTENT_XHTML);

        layout.addComponent(divider, 0, row, 2, row++);
    }

    layout.addComponent(new Label("Negative mode"), 0, row, 0, row);
    layout.addComponent(negativeModeField, 1, row, 1, row++);

    layout.addComponent(hIonCountSelect, 0, row, 0, row++);

    layout.addComponent(naIonCountSelect, 0, row, 0, row);

    layout.addComponent(exNAIonCountSelect, 1, row, 1, row++);

    layout.addComponent(liIonCountSelect, 0, row, 0, row);

    layout.addComponent(exLIIonCountSelect, 1, row, 1, row++);

    layout.addComponent(kIonCountSelect, 0, row, 0, row);

    layout.addComponent(exKIonCountSelect, 1, row, 1, row++);

    {
        Label divider = new Label("<hr/>", Label.CONTENT_XHTML);

        layout.addComponent(divider, 0, row, 2, row++);
    }

    layout.addComponent(clIonCountSelect, 0, row, 0, row);

    layout.addComponent(exClIonCountSelect, 1, row, 1, row++);

    layout.addComponent(h2po4IonCountSelect, 0, row, 0, row);

    layout.addComponent(exH2po4IonCountSelect, 1, row, 1, row++);

    NativeButton update = new NativeButton("Apply mass options");
    update.addListener(new ClickListener() {
        private static final long serialVersionUID = -6188200798103156691L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                config.retrieveData();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            fireMassOptionsChanged(config.getMassOptions(), glycans);
        }
    });

    layout.addComponent(update, 0, row, 0, row);
}

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

License:Apache License

public ExceptionDialog(Throwable ex, String caption) {
    this.cause = ex;
    Preconditions.checkNotNull(ex);//from  ww  w .  ja va 2s.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.controlpanel.CorpusListPanel.java

License:Apache License

public void initCorpusBrowser(String topLevelCorpusName, final Button l) {

    AnnisCorpus c = ui.getQueryState().getAvailableCorpora().getItem(topLevelCorpusName).getBean();
    MetaDataPanel meta = new MetaDataPanel(c.getName());

    CorpusBrowserPanel browse = new CorpusBrowserPanel(c, ui.getQueryController());
    GridLayout infoLayout = new GridLayout(2, 2);
    infoLayout.setSizeFull();/*  w ww  . j a  v  a  2s  . c  o m*/

    String corpusURL = Helper.generateCorpusLink(Sets.newHashSet(topLevelCorpusName));
    Label lblLink = new Label("Link to corpus: <a href=\"" + corpusURL + "\">" + corpusURL + "</a>",
            ContentMode.HTML);
    lblLink.setHeight("-1px");
    lblLink.setWidth("-1px");

    infoLayout.addComponent(meta, 0, 0);
    infoLayout.addComponent(browse, 1, 0);
    infoLayout.addComponent(lblLink, 0, 1, 1, 1);

    infoLayout.setRowExpandRatio(0, 1.0f);
    infoLayout.setColumnExpandRatio(0, 0.5f);
    infoLayout.setColumnExpandRatio(1, 0.5f);
    infoLayout.setComponentAlignment(lblLink, Alignment.MIDDLE_CENTER);

    Window window = new Window("Corpus information for " + c.getName() + " (ID: " + c.getId() + ")",
            infoLayout);
    window.setWidth(70, UNITS_EM);
    window.setHeight(45, UNITS_EM);
    window.setResizable(true);
    window.setModal(false);
    window.setResizeLazy(true);

    window.addCloseListener(new Window.CloseListener() {

        @Override
        public void windowClose(Window.CloseEvent e) {
            l.setEnabled(true);
        }
    });

    UI.getCurrent().addWindow(window);
    window.center();
}

From source file:annis.gui.HelpUsWindow.java

License:Apache License

public HelpUsWindow() {
    setSizeFull();/*  ww w.  j  a v  a  2 s .c o m*/
    layout = new VerticalLayout();
    setContent(layout);

    layout.setSizeFull();
    layout.setMargin(new MarginInfo(false, false, true, false));

    HorizontalLayout hLayout = new HorizontalLayout();
    hLayout.setSizeFull();
    hLayout.setMargin(false);

    VerticalLayout labelLayout = new VerticalLayout();
    labelLayout.setMargin(true);
    labelLayout.setSizeFull();

    Label lblOpenSource = new Label();

    lblOpenSource.setValue("<h1>ANNIS is <a href=\"http://opensource.org/osd\">Open Source</a> "
            + "software.</h1>" + "<p>This means you are free to download the source code and add new "
            + "features or make other adjustments to ANNIS on your own.<p/>"
            + "Here are some examples how you can help ANNIS:" + "<ul>"
            + "<li>Fix or report problems (bugs) you encounter when using the ANNIS software.</li>"
            + "<li>Add new features.</li>" + "<li>Enhance the documentation</li>" + "</ul>"
            + "<p>Feel free to visit our GitHub page for more information: <a href=\"https://github.com/korpling/ANNIS\" target=\"_blank\">https://github.com/korpling/ANNIS</a></p>");
    lblOpenSource.setContentMode(ContentMode.HTML);
    lblOpenSource.setStyleName("opensource");
    lblOpenSource.setWidth("100%");
    lblOpenSource.setHeight("-1px");
    labelLayout.addComponent(lblOpenSource);

    Link lnkFork = new Link();
    lnkFork.setResource(new ExternalResource("https://github.com/korpling/ANNIS"));
    lnkFork.setIcon(
            new ExternalResource("https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png"));
    lnkFork.setTargetName("_blank");

    hLayout.addComponent(labelLayout);
    hLayout.addComponent(lnkFork);
    hLayout.setComponentAlignment(labelLayout, Alignment.TOP_LEFT);
    hLayout.setComponentAlignment(lnkFork, Alignment.TOP_RIGHT);
    hLayout.setExpandRatio(labelLayout, 1.0f);

    layout.addComponent(hLayout);

    final HelpUsWindow finalThis = this;

    btClose = new Button("Close");
    btClose.addClickListener(new OkClickListener(finalThis));
    layout.addComponent(btClose);

    layout.setComponentAlignment(hLayout, Alignment.MIDDLE_CENTER);
    layout.setComponentAlignment(btClose, Alignment.MIDDLE_CENTER);
    layout.setExpandRatio(hLayout, 1.0f);
}

From source file:annis.gui.querybuilder.EdgeWindow.java

License:Apache License

public EdgeWindow(final TigerQueryBuilderCanvas parent, NodeWindow source, NodeWindow target) {
    this.parent = parent;
    this.source = source;
    this.target = target;

    setSizeFull();//from   w w  w .  j ava 2  s. c  o m

    // HACK: use our own border since the one from chameleon does not really work
    addStyleName(ValoTheme.PANEL_BORDERLESS);
    addStyleName("border-layout");
    addStyleName("white-panel");

    VerticalLayout vLayout = new VerticalLayout();
    setContent(vLayout);
    vLayout.setMargin(false);

    HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.addStyleName("toolbar");
    toolbar.setWidth("100%");
    toolbar.setHeight("-1px");
    vLayout.addComponent(toolbar);

    Label lblTitle = new Label("AQL Operator");
    lblTitle.setWidth("100%");

    toolbar.addComponent(lblTitle);
    toolbar.setComponentAlignment(lblTitle, Alignment.MIDDLE_LEFT);
    toolbar.setExpandRatio(lblTitle, 1.0f);

    btClose = new Button();
    btClose.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    btClose.addStyleName(ValoTheme.BUTTON_SMALL);
    btClose.setIcon(FontAwesome.TIMES_CIRCLE);
    btClose.setWidth("-1px");
    btClose.addListener((Button.ClickListener) this);
    toolbar.addComponent(btClose);

    toolbar.setComponentAlignment(btClose, Alignment.MIDDLE_RIGHT);
    toolbar.setExpandRatio(btClose, 0.0f);

    cbOperator = new ComboBox();
    cbOperator.setNewItemsAllowed(false);
    cbOperator.setTextInputAllowed(false);
    cbOperator.setNullSelectionAllowed(true);
    cbOperator.addItem(CUSTOM);
    cbOperator.setItemCaption(CUSTOM, "custom");
    cbOperator.setNullSelectionItemId(CUSTOM);
    cbOperator.setNewItemHandler(new SimpleNewItemHandler(cbOperator));
    cbOperator.setImmediate(true);
    vLayout.addComponent(cbOperator);
    for (AQLOperator o : AQLOperator.values()) {
        cbOperator.addItem(o);
        cbOperator.setItemCaption(o, o.getDescription() + " (" + o.getOp() + ")");
    }
    cbOperator.setValue(AQLOperator.DIRECT_PRECEDENCE);
    cbOperator.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {

            Object val = event.getProperty().getValue();
            if (val instanceof AQLOperator) {
                txtOperator.setValue(((AQLOperator) val).getOp());
            }
        }
    });

    cbOperator.setWidth("100%");
    cbOperator.setHeight("20px");

    txtOperator = new TextField();
    txtOperator.setValue(".");
    txtOperator.setInputPrompt("select operator definition");
    txtOperator.setSizeFull();
    txtOperator.addValueChangeListener(new OperatorValueChangeListener(parent));
    txtOperator.setImmediate(true);

    vLayout.addComponent(txtOperator);

    vLayout.setExpandRatio(cbOperator, 1.0f);

}

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

License:Apache License

public void showNoResult() {
    resultLayout.removeAllComponents();/*from   ww w .j  a  v  a2 s. 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) {/* w w  w  . ja  va2 s. c  o  m*/
    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: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);/*ww  w  .j  av  a2s  .  c o m*/
    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:br.com.anteros.mobileserver.util.UserMessages.java

License:Apache License

public Window confirm(String title, String message, String okTitle, String cancelTitle,
        Button.ClickListener listener) {

    if (title == null) {
        title = CONFIRM_OK_TITLE;/*from   w  w w  .  j  av  a 2 s. com*/
    }
    if (cancelTitle == null) {
        cancelTitle = CONFIRM_CANCEL_TITLE;
    }
    if (okTitle == null) {
        okTitle = CONFIRM_OK_TITLE;
    }

    final Window confirm = new Window(title);
    this.confirm = confirm;
    win.addWindow(confirm);

    confirm.addListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1971800928047045825L;

        public void windowClose(CloseEvent ce) {
            Object data = ce.getWindow().getData();
            if (data != null) {
                try {
                } catch (Exception exception) {
                    error("Unhandled Exception", exception);
                }
            }
        }
    });

    int chrW = 5;
    int chrH = 15;
    int txtWidth = Math.max(250, Math.min(350, message.length() * chrW));
    int btnHeight = 25;
    int vmargin = 100;
    int hmargin = 40;

    int txtHeight = 2 * chrH * (message.length() * chrW) / txtWidth;

    confirm.setWidth((txtWidth + hmargin) + "px");
    confirm.setHeight((vmargin + txtHeight + btnHeight) + "px");
    confirm.getContent().setSizeFull();

    confirm.center();
    confirm.setModal(true);

    Label text = new Label(message);
    text.setWidth("100%");
    text.setHeight("100%");

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setHeight(btnHeight + 5 + "px");
    buttons.setWidth("100%");
    buttons.setSpacing(true);
    buttons.setMargin(false);

    Button cancel = new Button(cancelTitle, listener);
    cancel.setIcon(new ThemeResource("icons/16/no.png"));
    cancel.setData(USER_CONFIRM_CANCEL);
    cancel.setClickShortcut(KeyCode.ESCAPE);
    Button ok = new Button(okTitle, listener);
    ok.setIcon(new ThemeResource("icons/16/yes.png"));
    ok.setData(USER_CONFIRM_OK);
    ok.setClickShortcut(KeyCode.ENTER);
    buttons.addComponent(ok);
    buttons.setExpandRatio(ok, 1);
    buttons.setComponentAlignment(ok, Alignment.MIDDLE_RIGHT);

    buttons.addComponent(cancel);
    buttons.setComponentAlignment(cancel, Alignment.MIDDLE_RIGHT);

    confirm.addComponent(text);
    confirm.addComponent(buttons);
    ((VerticalLayout) confirm.getContent()).setExpandRatio(text, 1f);
    confirm.setResizable(false);
    return confirm;
}

From source file:com.anphat.list.ui.DialogAddMapStaffCustomer.java

private void buildInfoLayout(boolean isCustInfo) {
    infoLayout = new GridLayout();
    infoLayout.setImmediate(true);//from  w w  w .  java2 s . com
    //        infoLayout.setStyleName("custom-feildset");
    //        infoLayout.setCaptionAsHtml(true);
    infoLayout.setWidth("100.0%");
    infoLayout.setHeight("-1px");
    infoLayout.setMargin(true);
    infoLayout.setSpacing(true);
    infoLayout.setColumns(6);
    infoLayout.setRows(1);

    // lblCustCode
    Label lblCustCode = new Label();
    lblCustCode.addStyleName("v-label-bold");
    lblCustCode.setImmediate(true);
    lblCustCode.setWidth("100.0%");
    lblCustCode.setHeight("-1px");

    // tfCustCode
    txtCustCode = new Label();
    txtCustCode.setImmediate(true);
    txtCustCode.setWidth("100.0%");
    txtCustCode.setHeight("-1px");
    // lblCustCode
    Label lblCustName = new Label();
    lblCustName.addStyleName("v-label-bold");
    lblCustName.setImmediate(true);
    lblCustName.setWidth("100.0%");
    lblCustName.setHeight("-1px");

    // tfCustCode
    txtCustName = new Label();
    txtCustName.setImmediate(true);
    txtCustName.setWidth("100.0%");
    txtCustName.setHeight("-1px");

    if (isCustInfo) {
        //            infoLayout.setCaption(BundleUtils.getString("goods.list.panel.caption.customerinfo"));
        //            lblCustCode.setValue(BundleUtils.getString("goods.list.label.customercode"));
        lblCustName.setValue(BundleUtils.getString("goods.list.label.customername"));
    } else {
        //            infoLayout.setCaption(BundleUtils.getString("goods.list.panel.caption.staffInfo"));
        //            lblCustCode.setValue(BundleUtils.getString("lb.deptstaff.emp.code"));
        lblCustName.setValue(BundleUtils.getString("lb.deptstaff.emp.name"));
    }
    //        infoLayout.addComponent(lblCustCode, 0, 0);
    //        infoLayout.addComponent(txtCustCode, 1, 0);
    infoLayout.addComponent(lblCustName, 0, 0);
    infoLayout.addComponent(txtCustName, 1, 0, 5, 0);
}