Example usage for com.vaadin.ui NativeButton addListener

List of usage examples for com.vaadin.ui NativeButton addListener

Introduction

In this page you can find the example usage for com.vaadin.ui NativeButton addListener.

Prototype

@Override
    public Registration addListener(Component.Listener listener) 

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.  j  a va 2 s .  c om
        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:ac.uk.icl.dell.vaadin.glycanbuilder.VaadinGlycanCanvas.java

License:Open Source License

public void appendGeneralToolBar(Panel theToolBarPanel) {
    HorizontalLayout toolBar = new HorizontalLayout();
    toolBar.setWidth("100%");

    toolBar.setStyleName("toolbar");

    NativeButton deleteButton = new NativeButton("Delete");
    deleteButton.setIcon(new ThemeResource("icons/deleteNew.png"));
    deleteButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 1289257412952359727L;

        @Override/*from ww w.j a v a  2  s . c  om*/
        public void buttonClick(ClickEvent event) {
            theCanvas.delete();
        }
    });
    deleteButton.setEnabled(false);

    NativeButton copyButton = new NativeButton("Copy");
    final NativeButton pasteButton = new NativeButton("Paste");
    copyButton.setIcon(new ThemeResource("icons/editcopy.png"));
    copyButton.addListener(new ClickListener() {
        private static final long serialVersionUID = -1740735587078805580L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.copy();
            pasteButton.setEnabled(true);
        }
    });
    copyButton.setEnabled(false);

    pasteButton.setIcon(new ThemeResource("icons/editpaste.png"));
    pasteButton.addListener(new ClickListener() {
        private static final long serialVersionUID = -8732259244009686729L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.paste();
            pasteButton.setEnabled(false);
        }
    });
    pasteButton.setEnabled(false);

    final NativeButton bracketButton = new NativeButton("Bracket");
    bracketButton.setIcon(new ThemeResource("icons/bracket.png"));
    bracketButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 5201094306113759901L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.addBracket();
        }
    });
    bracketButton.setEnabled(false);

    final NativeButton repeatButton = new NativeButton("Repeat");
    repeatButton.setIcon(new ThemeResource("icons/repeat.png"));
    repeatButton.addListener(new ClickListener() {
        private static final long serialVersionUID = -23302591439643695L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                theCanvas.addRepeat();
            } catch (Exception ex) {
                showMessage(ex.getMessage(), "400px", "100px", "Error creating repeat");
            }
        }
    });
    repeatButton.setEnabled(false);

    componentsWithResidueSelectionDependency.add(repeatButton);
    componentsWithResidueSelectionDependency.add(bracketButton);
    componentsWithResidueSelectionDependency.add(deleteButton);
    componentsWithResidueSelectionDependency.add(copyButton);

    final NativeButton orientationButton = new NativeButton("Orientation");

    orientationButton.setIcon(new ThemeResource("icons/" + theCanvas.getOrientationIcon()));
    orientationButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 6621021858668446143L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.changeOrientation();
            orientationButton.setIcon(new ThemeResource("icons/" + theCanvas.getOrientationIcon()));
        }
    });

    final NativeButton selectAllButton = new NativeButton("Select all");

    selectAllButton.setIcon(new ThemeResource("icons/selectall.png"));
    selectAllButton.addListener(new ClickListener() {
        private static final long serialVersionUID = -5848923636575805154L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.selectAll();
            theCanvas.documentUpdated();
        }
    });

    final NativeButton deSelectAllButton = new NativeButton("Select none");

    deSelectAllButton.setIcon(new ThemeResource("icons/deselect.png"));
    deSelectAllButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 8339468775345706027L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.resetSelection();
            theCanvas.documentUpdated();
        }
    });

    final NativeButton moveCWButton = new NativeButton("Move CW");

    moveCWButton.setIcon(new ThemeResource("icons/rotatecw.png"));
    moveCWButton.addListener(new ClickListener() {
        private static final long serialVersionUID = -6061975045440741204L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.onMoveCW();
        }
    });

    componentsWithResidueSelectionDependency.add(moveCWButton);

    final NativeButton moveCCWButton = new NativeButton("Move CCW");

    moveCCWButton.setIcon(new ThemeResource("icons/rotateccw.png"));
    moveCCWButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 3555726070782377309L;

        @Override
        public void buttonClick(ClickEvent event) {
            theCanvas.onMoveCCW();
        }
    });

    componentsWithResidueSelectionDependency.add(moveCCWButton);

    toolBar.addComponent(deleteButton);
    toolBar.addComponent(copyButton);
    toolBar.addComponent(pasteButton);
    toolBar.addComponent(orientationButton);
    toolBar.addComponent(selectAllButton);
    toolBar.addComponent(deSelectAllButton);
    toolBar.addComponent(bracketButton);
    toolBar.addComponent(repeatButton);
    toolBar.addComponent(moveCWButton);
    toolBar.addComponent(moveCCWButton);

    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();

    toolBar.addComponent(layout);
    toolBar.setExpandRatio(layout, 1);

    theToolBarPanel.setContent(toolBar);
}

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

License:Open Source License

@Override
public void recieveSelectionUpdate(double x, double y, double width, double height, boolean mouseMoved) {
    final Residue selectedResidue = theCanvas.getCurrentResidue();

    theCanvas.selectIntersectingRectangles(x, y, width, height, mouseMoved);

    if (theCanvas.getCurrentResidue() != null && selectedResidue == theCanvas.getCurrentResidue()
            && selectedResidue.isRepetition()) {
        final Window window = new Window("Repeatition options");

        WeeLayout layout = new WeeLayout(org.vaadin.weelayout.WeeLayout.Direction.VERTICAL);

        final TextField minRep = new TextField("Minimum");
        final TextField maxRep = new TextField("Maximum");
        NativeButton okBut = new NativeButton("Ok");
        NativeButton cancelBut = new NativeButton("Cancel");

        minRep.setImmediate(true);/*from  w w w.j a v a  2 s. co  m*/
        maxRep.setImmediate(true);

        minRep.setValue(String.valueOf(selectedResidue.getMinRepetitions()));
        maxRep.setValue(String.valueOf(selectedResidue.getMaxRepetitions()));

        okBut.addListener(new ClickListener() {
            private static final long serialVersionUID = -408364885359729326L;

            @Override
            public void buttonClick(ClickEvent event) {
                String minRepNum = (String) minRep.getValue();
                String maxRepNum = (String) maxRep.getValue();

                boolean valid = true;

                try {
                    Integer.parseInt(minRepNum);
                    Integer.parseInt(maxRepNum);
                } catch (NumberFormatException ex) {
                    valid = false;
                }

                if (valid) {
                    selectedResidue.setMinRepetitions((String) minRep.getValue());
                    selectedResidue.setMaxRepetitions((String) maxRep.getValue());

                    theCanvas.documentUpdated();
                }

                getWindow().removeWindow(window);
            }
        });

        cancelBut.addListener(new ClickListener() {
            private static final long serialVersionUID = -657746118918366530L;

            @Override
            public void buttonClick(ClickEvent event) {
                getWindow().removeWindow(window);
            }
        });

        layout.addComponent(minRep, Alignment.TOP_CENTER);
        layout.addComponent(maxRep, Alignment.MIDDLE_CENTER);

        WeeLayout buttonLayout = new WeeLayout(Direction.HORIZONTAL);
        buttonLayout.addComponent(okBut, Alignment.TOP_CENTER);
        buttonLayout.addComponent(cancelBut, Alignment.TOP_CENTER);

        layout.addComponent(buttonLayout, Alignment.BOTTOM_CENTER);

        window.center();
        window.getContent().addComponent(layout);

        window.getContent().setSizeUndefined();
        window.setSizeUndefined();

        getWindow().addWindow(window);
    }
}

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 ww  w.j  a  v a2s .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:de.dimm.vsm.vaadin.VSMCMain.java

protected void createHeader() {
    NativeButton icon = setAppIcon("appIconr",
            "Base V" + callLogicControl("getVersion").toString() + " Gui V" + getVersion());
    icon.addListener(new ClickListener() {

        @Override/*from  w w w  .j av a 2  s  .com*/
        public void buttonClick(ClickEvent event) {
            if (event.isShiftKey()) {
                String chl = callLogicControl("getChangelog", Boolean.TRUE).toString();

                RichTextAreaDlg dlg = new RichTextAreaDlg("ChangeLog", chl, true);
                dlg.setWidth("500px");
                dlg.setHeight("600px");
                app.getMainWindow().addWindow(dlg);
            }
            if (event.isCtrlKey()) {
                String chl = callLogicControl("getGuiChangelog", Boolean.TRUE).toString();

                RichTextAreaDlg dlg = new RichTextAreaDlg("ChangeLog", chl, true);
                dlg.setWidth("500px");
                dlg.setHeight("600px");
                app.getMainWindow().addWindow(dlg);
            }
        }
    });

    header = new AppHeader(this);
    setAppHeader(header.getGui());
}

From source file:de.dimm.vsm.vaadin.VSMCMain.java

public <T> void SelectObject(Class<T> t, String caption, String buttonCaption, List<T> list,
        final SelectObjectCallback cb) {

    if (list.size() == 1) {
        cb.SelectedAction(list.get(0));//from  ww w.ja va  2  s .c o m
        return;
    }
    final NativeSelect sel = new NativeSelect(caption);
    sel.setNewItemsAllowed(false);
    sel.setInvalidAllowed(false);
    sel.setNullSelectionAllowed(false);

    for (int i = 0; i < list.size(); i++) {
        Object object = list.get(i);
        sel.addItem(object);
    }
    if (!list.isEmpty())
        sel.setValue(list.get(0));

    VerticalLayout vl = new VerticalLayout();
    vl.setSpacing(true);
    NativeButton ok = new NativeButton(buttonCaption);

    final Window win = new Window(Txt("Auswahl") + " " + caption);
    win.setWidth("350px");
    win.center();

    ok.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            getRootWin().removeWindow(win);

            cb.SelectedAction(sel.getValue());
        }
    });

    vl.addComponent(sel);
    sel.setWidth("80%");
    vl.addComponent(ok);
    vl.setComponentAlignment(ok, Alignment.BOTTOM_RIGHT);

    vl.setSizeFull();
    win.addComponent(vl);
    getRootWin().addWindow(win);
}

From source file:fr.amapj.view.samples.test003.SidebarMenu.java

License:Open Source License

public SidebarMenu addButton(NativeButton b) {
    addComponent(b);/*w  ww  .  ja va  2 s  . com*/
    b.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            updateButtonStyles();
            event.getButton().addStyleName("selected");
        }
    });
    return this;
}

From source file:nl.amc.biolab.nsg.display.component.ProcessingStatusForm.java

License:Open Source License

@Override
public void attach() {
    super.attach();

    final VaadinTestApplication app = (VaadinTestApplication) getApplication();
    logger.info("Getting attached to. Displaying " + processingStatus);
    final Processing processing = processingStatus.getProcessing();
    if (processingStatus == null || processing == null) {
        return;/*from  w ww .j a v a2s.c om*/
    }

    setDataSource(processingStatus);
    setData(processingStatus);
    logger.info("Continuing being attached to. Displaying " + processingStatus.getStatus() + " for "
            + processing.getDescription() + " with status " + processing.getStatus());

    removeAllComponents();

    addLabelField("processing.description", "Description");
    addLabelField("processing.date", "Creation date");
    final String processingUpdateDate = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss")
            .format(userDataService.getLastestUpdate(processing)); // when the status is last updated

    //dataelements
    if (processingStatus.getSubmissionIOs().size() != 0) {
        Label space = new Label("<div>&nbsp;</div>", Label.CONTENT_XHTML);
        space.setWidth("100%");
        space.setHeight("10px");
        getLayout().addComponent(space);
        submissionTable = new Table();
        submissionTable.setWidth("100%");
        submissionTable.setHeight("300px");
        submissionTable.setSelectable(true);
        submissionTable.setMultiSelect(true);
        submissionTable.setImmediate(true);
        submissionTable.addContainerProperty("input", Label.class, null);
        submissionTable.addContainerProperty("output", Label.class, null);
        submissionTable.addContainerProperty("view history", VerticalLayout.class, null);
        submissionTable.addContainerProperty("status", VerticalLayout.class, null);
        submissionTable.setColumnExpandRatio("input", 30f);
        submissionTable.setColumnExpandRatio("output", 20f);
        submissionTable.setColumnExpandRatio("view history", 20f);
        submissionTable.setColumnExpandRatio("status", 30f);

        for (Map<List<SubmissionIO>, List<SubmissionIO>> map : processingStatus.getSubmissionIOs()) {
            for (List<SubmissionIO> submissionIOinputs : map.keySet()) {
                if (submissionIOinputs.isEmpty()) {
                    logger.error("Skipping a submission with no inputs in processing: "
                            + processingStatus.getProcessing().getDbId());

                    continue;
                }

                //inputs
                StringBuffer inputValue = new StringBuffer();

                for (SubmissionIO submissionIOinput : submissionIOinputs) {
                    DataElement inputElement = submissionIOinput.getDataElement();

                    inputValue.append("<a href='" + userDataService.getDownloadURI(inputElement.getDbId())
                            + "' target='_blank'>" + inputElement.getName() + "</a><br />");
                }

                Label input = new Label(inputValue.toString(), Label.CONTENT_XHTML);
                input.setWidth("-1px");

                //outputs
                VerticalLayout historyLayout = new VerticalLayout();
                historyLayout.setWidth("100%");

                StringBuffer downloadValue = new StringBuffer();
                Label download = null;

                final List<SubmissionIO> outputs = map.get(submissionIOinputs);

                if (outputs.isEmpty()) {
                    download = new Label("No output available", Label.CONTENT_XHTML);
                } else {
                    for (SubmissionIO submissionIOoutput : outputs) {
                        final DataElement outputElement = submissionIOoutput.getDataElement();

                        if (submissionIOoutput.getDataElement().getExisting()) {
                            downloadValue.append("<a href='")
                                    .append(userDataService.getDownloadURI(outputElement.getDbId()))
                                    .append("' target='_blank'>download output</a><br />");
                        }

                        NativeButton viewHistoryButton = new NativeButton("history");

                        viewHistoryButton.addListener(new Button.ClickListener() {
                            private static final long serialVersionUID = 4280267926508263057L;

                            @Override
                            public void buttonClick(ClickEvent event) {
                                final String htmlContent = userDataService
                                        .getDataHistory(outputElement.getDbId());
                                showHTML(htmlContent, app);
                            }
                        });

                        historyLayout.addComponent(viewHistoryButton);
                    }

                    download = new Label(downloadValue.toString(), Label.CONTENT_XHTML);
                    download.setWidth("-1px");
                }

                // status
                VerticalLayout statusLayout = makeSubmissionStatusLayout(submissionIOinputs, processing, app);

                //add table item
                submissionTable.addItem(new Object[] { input, download, historyLayout, statusLayout }, null);
            }
        }

        getLayout().addComponent(submissionTable);
    }

    //total status
    Label space = new Label("<div>&nbsp;</div>", Label.CONTENT_XHTML);

    space.setWidth("100%");
    space.setHeight("10px");

    getLayout().addComponent(space);

    LabelField f = new LabelField();
    LabelField lastUpdateDateFieled = new LabelField();

    lastUpdateDateFieled.setLabelValue("<span style='font-size: 12px'><b>Last updated on:</b>&nbsp;</span>",
            processingUpdateDate);
    f.setLabelValue("<span style='font-size: 12px'><b>Overall status:</b>&nbsp;</span>",
            getStatus(processingStatus.getStatus(), null, false));

    getLayout().addComponent(f);
    getLayout().addComponent(lastUpdateDateFieled);
}

From source file:org.vaadin.training.fundamentals.happening.ui.NavigationComponent.java

License:Apache License

@SuppressWarnings("serial")
private void buildLayout() {
    HorizontalLayout header = new HorizontalLayout();
    header.setWidth("100%");
    header.setHeight("50px");
    Label appName = new Label("Happening Application Header");
    header.addComponent(appName);//from   w w  w. j  a v  a2  s.c  om
    NativeButton listButton = new NativeButton("List");
    listButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            setCurrentView(ListHappeningsView.class, null);
        }
    });

    NativeButton addButton = new NativeButton("Add");
    addButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            setCurrentView(AddNewView.class, null);
        }
    });

    NativeButton logoutButton = new NativeButton("Logout");
    logoutButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            getApplication().close();
        }
    });
    header.addComponent(listButton);
    header.addComponent(addButton);
    header.addComponent(logoutButton);
    addComponent(header);
}