Example usage for com.vaadin.ui Button addListener

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

Introduction

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

Prototype

@Override
    public Registration addListener(Component.Listener listener) 

Source Link

Usage

From source file:annis.gui.CitationWindow.java

License:Apache License

public CitationWindow(String query, Set<String> corpora, int contextLeft, int contextRight) {
    super("Citation");

    VerticalLayout wLayout = new VerticalLayout();
    setContent(wLayout);/*  ww  w  .  jav  a  2  s . c  om*/
    wLayout.setSizeFull();

    String url = Helper.generateCitation(query, corpora, contextLeft, contextRight, null, 0, 10);

    TextArea txtCitation = new TextArea();

    txtCitation.setWidth("100%");
    txtCitation.setHeight("100%");
    txtCitation.addStyleName(ChameleonTheme.TEXTFIELD_BIG);
    txtCitation.addStyleName("citation");
    txtCitation.setValue(url);
    txtCitation.setWordwrap(true);
    txtCitation.setReadOnly(true);

    wLayout.addComponent(txtCitation);

    Button btOk = new Button("OK");
    btOk.addListener((Button.ClickListener) this);
    btOk.setSizeUndefined();

    wLayout.addComponent(btOk);

    wLayout.setExpandRatio(txtCitation, 1.0f);
    wLayout.setComponentAlignment(btOk, Alignment.BOTTOM_CENTER);

    setWidth("400px");
    setHeight("200px");

}

From source file:annis.gui.SearchUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    super.init(request);

    this.instanceConfig = getInstanceConfig(request);

    getPage().setTitle(instanceConfig.getInstanceDisplayName() + " (ANNIS Corpus Search)");

    queryController = new QueryController(this);

    refresh = new Refresher();
    // deactivate refresher by default
    refresh.setRefreshInterval(-1);//  w  w w  . jav a 2  s  .c om
    refresh.addListener(queryController);
    addExtension(refresh);

    // always get the resize events directly
    setImmediate(true);

    VerticalLayout mainLayout = new VerticalLayout();
    setContent(mainLayout);

    mainLayout.setSizeFull();
    mainLayout.setMargin(false);

    final ScreenshotMaker screenshot = new ScreenshotMaker(this);
    addExtension(screenshot);

    css = new CSSInject(this);

    HorizontalLayout layoutToolbar = new HorizontalLayout();
    layoutToolbar.setWidth("100%");
    layoutToolbar.setHeight("-1px");

    mainLayout.addComponent(layoutToolbar);
    layoutToolbar.addStyleName("toolbar");
    layoutToolbar.addStyleName("border-layout");

    Button btAboutAnnis = new Button("About ANNIS");
    btAboutAnnis.addStyleName(ChameleonTheme.BUTTON_SMALL);
    btAboutAnnis.setIcon(new ThemeResource("info.gif"));

    btAboutAnnis.addClickListener(new AboutClickListener());

    btBugReport = new Button("Report Bug");
    btBugReport.addStyleName(ChameleonTheme.BUTTON_SMALL);
    btBugReport.setDisableOnClick(true);
    btBugReport.setIcon(new ThemeResource("../runo/icons/16/email.png"));
    btBugReport.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            screenshot.makeScreenshot();
            btBugReport.setCaption("bug report is initialized...");
        }
    });

    String bugmail = (String) VaadinSession.getCurrent().getAttribute("bug-e-mail");
    if (bugmail != null && !bugmail.isEmpty() && !bugmail.startsWith("${")
            && new EmailValidator("").isValid(bugmail)) {
        this.bugEMailAddress = bugmail;
    }
    btBugReport.setVisible(this.bugEMailAddress != null);

    lblUserName = new Label("not logged in");
    lblUserName.setWidth("-1px");
    lblUserName.setHeight("-1px");
    lblUserName.addStyleName("right-aligned-text");

    btLoginLogout = new Button("Login", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (isLoggedIn()) {
                // logout
                Helper.setUser(null);
                Notification.show("Logged out", Notification.Type.TRAY_NOTIFICATION);
                updateUserInformation();
            } else {
                showLoginWindow();
            }
        }
    });
    btLoginLogout.setSizeUndefined();
    btLoginLogout.setStyleName(ChameleonTheme.BUTTON_SMALL);
    btLoginLogout.setIcon(new ThemeResource("../runo/icons/16/user.png"));

    Button btOpenSource = new Button("Help us to make ANNIS better!");
    btOpenSource.setStyleName(BaseTheme.BUTTON_LINK);
    btOpenSource.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Window w = new HelpUsWindow();
            w.setCaption("Help us to make ANNIS better!");
            w.setModal(true);
            w.setResizable(true);
            w.setWidth("600px");
            w.setHeight("500px");
            addWindow(w);
            w.center();
        }
    });

    layoutToolbar.addComponent(btAboutAnnis);
    layoutToolbar.addComponent(btBugReport);
    layoutToolbar.addComponent(btOpenSource);
    layoutToolbar.addComponent(lblUserName);
    layoutToolbar.addComponent(btLoginLogout);

    layoutToolbar.setSpacing(true);
    layoutToolbar.setComponentAlignment(btAboutAnnis, Alignment.MIDDLE_LEFT);
    layoutToolbar.setComponentAlignment(btBugReport, Alignment.MIDDLE_LEFT);
    layoutToolbar.setComponentAlignment(btOpenSource, Alignment.MIDDLE_CENTER);
    layoutToolbar.setComponentAlignment(lblUserName, Alignment.MIDDLE_RIGHT);
    layoutToolbar.setComponentAlignment(btLoginLogout, Alignment.MIDDLE_RIGHT);
    layoutToolbar.setExpandRatio(btOpenSource, 1.0f);

    //HorizontalLayout hLayout = new HorizontalLayout();
    final HorizontalSplitPanel hSplit = new HorizontalSplitPanel();
    hSplit.setSizeFull();

    mainLayout.addComponent(hSplit);
    mainLayout.setExpandRatio(hSplit, 1.0f);

    AutoGeneratedQueries autoGenQueries = new AutoGeneratedQueries("example queries", this);

    controlPanel = new ControlPanel(queryController, instanceConfig, autoGenQueries);
    controlPanel.setWidth(100f, Layout.Unit.PERCENTAGE);
    controlPanel.setHeight(100f, Layout.Unit.PERCENTAGE);
    hSplit.setFirstComponent(controlPanel);

    tutorial = new TutorialPanel();
    tutorial.setHeight("99%");

    mainTab = new TabSheet();
    mainTab.setSizeFull();
    mainTab.addTab(autoGenQueries, "example queries");
    mainTab.addTab(tutorial, "Tutorial");

    queryBuilder = new QueryBuilderChooser(queryController, this, instanceConfig);
    mainTab.addTab(queryBuilder, "Query Builder");

    hSplit.setSecondComponent(mainTab);
    hSplit.setSplitPosition(CONTROL_PANEL_WIDTH, Unit.PIXELS);
    hSplit.addSplitterClickListener(new AbstractSplitPanel.SplitterClickListener() {
        @Override
        public void splitterClick(AbstractSplitPanel.SplitterClickEvent event) {
            if (event.isDoubleClick()) {
                if (hSplit.getSplitPosition() == CONTROL_PANEL_WIDTH) {
                    // make small
                    hSplit.setSplitPosition(0.0f, Unit.PIXELS);
                } else {
                    // reset to default width
                    hSplit.setSplitPosition(CONTROL_PANEL_WIDTH, Unit.PIXELS);
                }
            }
        }
    });
    // hLayout.setExpandRatio(mainTab, 1.0f);

    addAction(new ShortcutListener("^Query builder") {
        @Override
        public void handleAction(Object sender, Object target) {
            mainTab.setSelectedTab(queryBuilder);
        }
    });

    addAction(new ShortcutListener("Tutor^eial") {
        @Override
        public void handleAction(Object sender, Object target) {
            mainTab.setSelectedTab(tutorial);
        }
    });

    getPage().addUriFragmentChangedListener(this);

    getSession().addRequestHandler(new RequestHandler() {
        @Override
        public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response)
                throws IOException {
            checkCitation(request);

            if (request.getPathInfo() != null && request.getPathInfo().startsWith("/vis-iframe-res/")) {
                String uuidString = StringUtils.removeStart(request.getPathInfo(), "/vis-iframe-res/");
                UUID uuid = UUID.fromString(uuidString);
                IFrameResourceMap map = VaadinSession.getCurrent().getAttribute(IFrameResourceMap.class);
                if (map == null) {
                    response.setStatus(404);
                } else {
                    IFrameResource res = map.get(uuid);
                    if (res != null) {
                        response.setStatus(200);
                        response.setContentType(res.getMimeType());
                        response.getOutputStream().write(res.getData());
                    }
                }
                return true;
            }

            return false;
        }
    });

    getSession().setAttribute(MediaController.class, new MediaControllerImpl());

    getSession().setAttribute(PDFController.class, new PDFControllerImpl());

    loadInstanceFonts();

    checkCitation(request);
    lastQueriedFragment = "";
    evaluateFragment(getPage().getUriFragment());

    updateUserInformation();
}

From source file:annis.visualizers.component.rst.RSTPanel.java

License:Apache License

RSTPanel(VisualizerInput visInput) {
    String btWidth = "30px";
    HorizontalLayout grid = new HorizontalLayout();
    final int scrollStep = 200;

    // the calculation of the output json is done here.
    final RSTImpl rstView = new RSTImpl(visInput);
    rstView.setId(UUID.randomUUID().toString());

    this.setHeight("-1px");
    this.setWidth("100%");
    grid.setHeight("-1px");
    grid.setWidth("100%");

    final Button buttonLeft = new Button();
    buttonLeft.setWidth(btWidth);/*  w  w w  .  ja  v  a 2 s . co  m*/
    buttonLeft.setHeight("100%");
    buttonLeft.addStyleName("left-button");
    buttonLeft.setEnabled(false);

    final Button buttonRight = new Button();
    buttonRight.setWidth(btWidth);
    buttonRight.setHeight("100%");
    buttonRight.addStyleName("right-button");

    buttonLeft.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (rstView.getScrollLeft() < scrollStep) {
                buttonLeft.setEnabled(false);
                rstView.setScrollLeft(0);
            } else {
                //if the right button was deactivated set it back
                rstView.setScrollLeft(rstView.getScrollLeft() - scrollStep);
            }

            buttonRight.setEnabled(true);
        }
    });

    buttonRight.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            renderInfo.calculate("#" + rstView.getId() + " canvas");
        }
    });

    renderInfo = new CssRenderInfo(new CssRenderInfo.Callback() {
        @Override
        public void renderInfoReceived(int width, int height) {
            if (width - rstView.getScrollLeft() > scrollStep) {
                buttonLeft.setEnabled(true);
                rstView.setScrollLeft(rstView.getScrollLeft() + scrollStep);
            } else {
                rstView.setScrollLeft(rstView.getScrollLeft() - (width - rstView.getScrollLeft()));

                buttonLeft.setEnabled(true);
                buttonRight.setEnabled(false);
            }
        }
    });
    rstView.addExtension(renderInfo);

    grid.addComponent(buttonLeft);
    grid.addComponent(rstView);
    grid.addComponent(buttonRight);
    setContent(grid);
    grid.setExpandRatio(rstView, 1.0f);
}

From source file:app.MyVaadinApplication.java

License:Apache License

@Override
public void init() {

    window = new Window("My Vaadin Application");
    setMainWindow(window);//from  w ww.ja v  a  2s .c o m
    Button button = new Button("Click Me");
    button.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            window.addComponent(new Label("Thank you for clicking"));
        }
    });
    window.addComponent(button);

}

From source file:at.meikel.nentis.Nentis.java

License:Apache License

private void initMain(TabSheet tabSheet) {
    final VerticalLayout mainTab = new VerticalLayout();
    tabSheet.addTab(mainTab);//from  ww w . j ava2  s.  c o m
    tabSheet.getTab(mainTab).setCaption("Main");

    final HorizontalLayout buttons = new HorizontalLayout();
    mainTab.addComponent(buttons);

    final VerticalLayout state = new VerticalLayout();
    mainTab.addComponent(state);

    final VerticalLayout info = new VerticalLayout();
    mainTab.addComponent(info);

    Button createTicket = new Button("Create a new ticket");
    createTicket.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent clickEvent) {
            state.removeAllComponents();
            Ticket ticket = nentisApi.createTicket("Ticket (" + new Date() + ")");
            state.addComponent(
                    new Label("Ticket #" + ticket.getId() + " [" + ticket.getDescription() + "] created."));
        }
    });
    buttons.addComponent(createTicket);

    Button listAllTickets = new Button("List all existing tickets");
    listAllTickets.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent clickEvent) {
            state.removeAllComponents();
            List<Ticket> allTickets = nentisApi.getAllTickets();
            info.removeAllComponents();
            if (allTickets != null) {
                for (Ticket ticket : allTickets) {
                    info.addComponent(new Label(
                            "Ticket #" + ticket.getId() + " [" + ticket.getDescription() + "] created."));
                }
            }
        }
    });
    buttons.addComponent(listAllTickets);

    final Button openSubWindow = new Button("Open a sub window");
    openSubWindow.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent clickEvent) {
            buttons.removeComponent(openSubWindow);
            Window subWindow = new Window("Sub window");
            mainWindow.addWindow(subWindow);
        }
    });
    buttons.addComponent(openSubWindow);
}

From source file:at.meikel.sudoku.MyVaadinApplication.java

License:Apache License

@Override
public void init() {
    window = new Window("My Vaadin Application");
    setMainWindow(window);//from w  ww.j a  v a 2s  .  c om
    Button button = new Button("Click Me");
    button.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            window.addComponent(new Label("Thank you for clicking"));
        }
    });
    window.addComponent(button);

}

From source file:at.peppol.webgui.app.components.InvoiceLineAllowanceChargeForm.java

License:Mozilla Public License

private void initElements() {

    final GridLayout grid = new GridLayout(4, 4);
    final VerticalLayout outerLayout = new VerticalLayout();
    hiddenContent = new VerticalLayout();
    hiddenContent.setSpacing(true);//from  w  w w  . jav a2s.co m
    hiddenContent.setMargin(true);

    table = new InvoiceLineAllowanceChargeTable(lineAllowanceChargeList);
    table.setSelectable(true);
    table.setImmediate(true);
    table.setNullSelectionAllowed(false);
    table.setHeight(150, UNITS_PIXELS);
    table.setFooterVisible(false);
    table.addStyleName("striped strong");

    VerticalLayout tableContainer = new VerticalLayout();
    tableContainer.addComponent(table);
    tableContainer.setMargin(false, true, false, false);

    Button addButton = new Button("Add new");
    Button editButton = new Button("Edit selected");
    Button deleteButton = new Button("Delete selected");

    VerticalLayout buttonsContainer = new VerticalLayout();
    buttonsContainer.setSpacing(true);
    buttonsContainer.addComponent(addButton);
    buttonsContainer.addComponent(editButton);
    buttonsContainer.addComponent(deleteButton);

    InvoiceLineAllowanceChargeTableEditor editor = new InvoiceLineAllowanceChargeTableEditor(editMode, inv);
    Label label = new Label("<h3>Adding allowance/charge line</h3>", Label.CONTENT_XHTML);
    addButton.addListener(editor.addButtonListener(editButton, deleteButton, hiddenContent, table,
            lineAllowanceChargeList, label));
    label = new Label("<h3>Edit allowance/charge line</h3>", Label.CONTENT_XHTML);
    editButton.addListener(editor.editButtonListener(addButton, deleteButton, hiddenContent, table,
            lineAllowanceChargeList, label));
    deleteButton.addListener(editor.deleteButtonListener(table));

    Panel outerPanel = new Panel(prefix + " Allowances/Charges");
    //outerPanel.setStyleName("light");     

    // ---- HIDDEN FORM BEGINS -----
    VerticalLayout formLayout = new VerticalLayout();
    formLayout.addComponent(hiddenContent);
    hiddenContent.setVisible(false);
    // ---- HIDDEN FORM ENDS -----

    grid.setSizeUndefined();
    grid.addComponent(tableContainer, 0, 0);
    grid.addComponent(buttonsContainer, 1, 0);

    outerPanel.addComponent(grid);
    outerPanel.addComponent(formLayout);
    outerLayout.addComponent(outerPanel);
    outerPanel.requestRepaintAll();

    VerticalLayout mainLayout = new VerticalLayout();
    final VerticalLayout showHideContentLayout = new VerticalLayout();
    showHideContentLayout.addComponent(outerPanel);
    HorizontalLayout showHideButtonLayout = new HorizontalLayout();
    Button btn = new Button("Show/Hide Allowances/Charges", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            // TODO Auto-generated method stub
            showHideContentLayout.setVisible(!showHideContentLayout.isVisible());
        }
    });
    showHideButtonLayout.setWidth("100%");
    showHideButtonLayout.addComponent(btn);
    showHideButtonLayout.setComponentAlignment(btn, Alignment.MIDDLE_RIGHT);

    //mainLayout.addComponent(showHideButtonLayout);
    mainLayout.addComponent(showHideContentLayout);
    //showHideContentLayout.setVisible(false);    

    addComponent(mainLayout);

}

From source file:at.peppol.webgui.app.components.InvoiceLineCommodityClassificationForm.java

License:Mozilla Public License

private void initElements() {

    final GridLayout grid = new GridLayout(4, 4);
    final VerticalLayout outerLayout = new VerticalLayout();
    hiddenContent = new VerticalLayout();
    hiddenContent.setSpacing(true);//from  ww w. j av  a 2 s  .  co  m
    hiddenContent.setMargin(true);

    table = new InvoiceLineCommodityClassificationTable(lineCommodityList);
    table.setSelectable(true);
    table.setImmediate(true);
    table.setNullSelectionAllowed(false);
    table.setHeight(150, UNITS_PIXELS);
    table.setFooterVisible(false);
    table.addStyleName("striped strong");

    VerticalLayout tableContainer = new VerticalLayout();
    tableContainer.addComponent(table);
    tableContainer.setMargin(false, true, false, false);

    Button addButton = new Button("Add new");
    Button editButton = new Button("Edit selected");
    Button deleteButton = new Button("Delete selected");

    VerticalLayout buttonsContainer = new VerticalLayout();
    buttonsContainer.setSpacing(true);
    buttonsContainer.addComponent(addButton);
    buttonsContainer.addComponent(editButton);
    buttonsContainer.addComponent(deleteButton);

    InvoiceLineCommodityClassificationTableEditor editor = new InvoiceLineCommodityClassificationTableEditor(
            editMode);
    Label label = new Label("<h3>Adding commodity classification line</h3>", Label.CONTENT_XHTML);
    addButton.addListener(
            editor.addButtonListener(editButton, deleteButton, hiddenContent, table, lineCommodityList, label));
    label = new Label("<h3>Edit commodity classification line</h3>", Label.CONTENT_XHTML);
    editButton.addListener(
            editor.editButtonListener(addButton, deleteButton, hiddenContent, table, lineCommodityList, label));
    deleteButton.addListener(editor.deleteButtonListener(table));

    Panel outerPanel = new Panel(prefix + " Commodity Classifications");
    //outerPanel.setStyleName("light");     

    // ---- HIDDEN FORM BEGINS -----
    VerticalLayout formLayout = new VerticalLayout();
    formLayout.addComponent(hiddenContent);
    hiddenContent.setVisible(false);
    // ---- HIDDEN FORM ENDS -----

    grid.setSizeUndefined();
    grid.addComponent(tableContainer, 0, 0);
    grid.addComponent(buttonsContainer, 1, 0);

    outerPanel.addComponent(grid);
    outerPanel.addComponent(formLayout);
    outerLayout.addComponent(outerPanel);
    outerPanel.requestRepaintAll();

    VerticalLayout mainLayout = new VerticalLayout();
    final VerticalLayout showHideContentLayout = new VerticalLayout();
    showHideContentLayout.addComponent(outerPanel);
    HorizontalLayout showHideButtonLayout = new HorizontalLayout();
    Button btn = new Button("Show/Hide Allowances/Charges", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            // TODO Auto-generated method stub
            showHideContentLayout.setVisible(!showHideContentLayout.isVisible());
        }
    });
    showHideButtonLayout.setWidth("100%");
    showHideButtonLayout.addComponent(btn);
    showHideButtonLayout.setComponentAlignment(btn, Alignment.MIDDLE_RIGHT);

    //mainLayout.addComponent(showHideButtonLayout);
    mainLayout.addComponent(showHideContentLayout);
    //showHideContentLayout.setVisible(false);    

    addComponent(mainLayout);

}

From source file:at.peppol.webgui.app.components.InvoiceLineOrderForm.java

License:Mozilla Public License

private void initElements() {

    final GridLayout grid = new GridLayout(4, 4);
    final VerticalLayout outerLayout = new VerticalLayout();
    hiddenContent = new VerticalLayout();
    hiddenContent.setSpacing(true);//from w ww .  ja v a2  s . c o m
    hiddenContent.setMargin(true);

    table = new InvoiceLineOrderReferenceTable(lineOrderList);
    table.setSelectable(true);
    table.setImmediate(true);
    table.setNullSelectionAllowed(false);
    table.setHeight(150, UNITS_PIXELS);
    table.setFooterVisible(false);
    table.addStyleName("striped strong");

    VerticalLayout tableContainer = new VerticalLayout();
    tableContainer.addComponent(table);
    tableContainer.setMargin(false, true, false, false);

    Button addButton = new Button("Add new");
    Button editButton = new Button("Edit selected");
    Button deleteButton = new Button("Delete selected");

    VerticalLayout buttonsContainer = new VerticalLayout();
    buttonsContainer.setSpacing(true);
    buttonsContainer.addComponent(addButton);
    buttonsContainer.addComponent(editButton);
    buttonsContainer.addComponent(deleteButton);

    InvoiceLineOrderReferenceTableEditor editor = new InvoiceLineOrderReferenceTableEditor(editMode);
    Label label = new Label("<h3>Adding order line</h3>", Label.CONTENT_XHTML);
    addButton.addListener(
            editor.addButtonListener(editButton, deleteButton, hiddenContent, table, lineOrderList, label));
    label = new Label("<h3>Edit order line</h3>", Label.CONTENT_XHTML);
    editButton.addListener(
            editor.editButtonListener(addButton, deleteButton, hiddenContent, table, lineOrderList, label));
    deleteButton.addListener(editor.deleteButtonListener(table));

    Panel outerPanel = new Panel(prefix + " Referencing Orders");
    //outerPanel.setStyleName("light");     

    // ---- HIDDEN FORM BEGINS -----
    VerticalLayout formLayout = new VerticalLayout();
    formLayout.addComponent(hiddenContent);
    hiddenContent.setVisible(false);
    // ---- HIDDEN FORM ENDS -----

    grid.setSizeUndefined();
    grid.addComponent(tableContainer, 0, 0);
    grid.addComponent(buttonsContainer, 1, 0);

    outerPanel.addComponent(grid);
    outerPanel.addComponent(formLayout);
    outerLayout.addComponent(outerPanel);
    outerPanel.requestRepaintAll();

    VerticalLayout mainLayout = new VerticalLayout();
    final VerticalLayout showHideContentLayout = new VerticalLayout();
    showHideContentLayout.addComponent(outerPanel);
    HorizontalLayout showHideButtonLayout = new HorizontalLayout();
    Button btn = new Button("Show/Hide Allowances/Charges", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            // TODO Auto-generated method stub
            showHideContentLayout.setVisible(!showHideContentLayout.isVisible());
        }
    });
    showHideButtonLayout.setWidth("100%");
    showHideButtonLayout.addComponent(btn);
    showHideButtonLayout.setComponentAlignment(btn, Alignment.MIDDLE_RIGHT);

    //mainLayout.addComponent(showHideButtonLayout);
    mainLayout.addComponent(showHideContentLayout);
    //showHideContentLayout.setVisible(false);    

    addComponent(mainLayout);

}

From source file:at.peppol.webgui.app.components.InvoiceUploadWindow.java

License:Mozilla Public License

public InvoiceUploadWindow() {
    this.setSpacing(true);
    subwindow = new Window("Upload Invoice");
    subwindow.addComponent(status);/*from  ww w  . jav a 2  s. co  m*/
    subwindow.addComponent(progressLayout);
    subwindow.addComponent(upload);
    subwindow.addStyleName("upload-popup");
    subwindow.setModal(true);

    upload.setImmediate(true);
    upload.setButtonCaption("Select local invoice");

    progressLayout.setSpacing(true);
    progressLayout.setVisible(false);
    progressLayout.addComponent(pi);
    progressLayout.setComponentAlignment(pi, Alignment.MIDDLE_LEFT);

    final Button cancelProcessing = new Button("Cancel");
    cancelProcessing.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(final com.vaadin.ui.Button.ClickEvent event) {
            upload.interruptUpload();
        }
    });
    cancelProcessing.setStyleName("small");
    progressLayout.addComponent(cancelProcessing);
    upload.addListener(new Upload.StartedListener() {

        @Override
        public void uploadStarted(final StartedEvent event) {
            // This method gets called immediately after upload is started
            upload.setVisible(false);
            progressLayout.setVisible(true);
            pi.setValue(Float.valueOf(0f));
            pi.setPollingInterval(500);
            status.setValue("Uploading file \"" + event.getFilename() + "\"");
        }
    });

    upload.addListener(new Upload.ProgressListener() {

        public void updateProgress(final long readBytes, final long contentLength) {
            // This method gets called several times during the update
            pi.setValue(new Float(readBytes / (float) contentLength));
        }
    });

    upload.addListener(new Upload.SucceededListener() {

        @Override
        public void uploadSucceeded(final SucceededEvent event) {
            // This method gets called when the upload finished successfully
            status.setValue("Uploading file \"" + event.getFilename() + "\" succeeded");
            if (ur != null) {
                ur.setSuccess(true);
            } else {
                logger.warn("Invoice upload succeeded, but no Upload request present!");
            }
        }
    });

    upload.addListener(new Upload.FailedListener() {

        @Override
        public void uploadFailed(final FailedEvent event) {
            status.setValue("Uploading interrupted");
            if (ur != null) {
                ur.setSuccess(false);
            } else {
                logger.warn("Invoice upload failed, but no Upload request present!");
            }
        }
    });

    upload.addListener(new Upload.FinishedListener() {

        @Override
        public void uploadFinished(final FinishedEvent event) {
            // This method gets called always when the upload finished, either
            // succeeding or failing
            progressLayout.setVisible(false);
            upload.setVisible(true);
            upload.setCaption("Select another file more filesss");
        }
    });

}