Package com.vaadin.ui

Examples of com.vaadin.ui.Label$ValueChangeEvent


    @Override
    public void uploadFinished(FinishedEvent event) {
        statusLayout.removeAllComponents();
        final InputStream stream = buffer.getStream();
        if (stream == null) {
            statusLayout.addComponent(new Label(
                    "Upload finished, but output buffer is null!!"));
        } else {
            statusLayout.addComponent(new Label("<b>Name:</b> "
                    + event.getFilename(), ContentMode.HTML));
            statusLayout.addComponent(new Label("<b>Mimetype:</b> "
                    + event.getMIMEType(), ContentMode.HTML));
            statusLayout.addComponent(new Label("<b>Size:</b> "
                    + event.getLength() + " bytes.", ContentMode.HTML));

            statusLayout.addComponent(new Link("Download "
                    + buffer.getFileName(), new StreamResource(buffer, buffer
                    .getFileName())));
View Full Code Here


    private Button interrupt = new Button("Interrupt upload");

    public TestForUpload() {
        setCompositionRoot(main);
        main.addComponent(new Label(
                "This is a simple test for upload application. "
                        + "Upload should work with big files and concurrent "
                        + "requests should not be blocked. Button 'b' reads "
                        + "current state into label below it. Memory receiver "
                        + "streams upload contents into memory. You may track"
                        + "consumption."
                        + "tempfile receiver writes upload to file and "
                        + "should have low memory consumption."));

        main.addComponent(new Label(
                "Clicking on button b updates information about upload components status or same with garbage collector."));

        textField = new TextField("Test field");
        textFieldValue = new Label();
        main.addComponent(textField);
        main.addComponent(textFieldValue);

        up = new Upload("Upload", buffer);
        up.setImmediate(true);
        up.addListener(new Listener() {
            private static final long serialVersionUID = -8319074730512324303L;

            @Override
            public void componentEvent(Event event) {
                // print out all events fired by upload for debug purposes
                System.out.println("Upload fired event | " + event);
            }
        });

        up.addListener(new StartedListener() {
            private static final long serialVersionUID = 5508883803861085154L;

            @Override
            public void uploadStarted(StartedEvent event) {
                pi.setVisible(true);
                pi2.setVisible(true);
                l.setValue("Started uploading file " + event.getFilename());
                textFieldValue
                        .setValue(" TestFields value at the upload start is:"
                                + textField.getValue());
            }
        });

        up.addListener(new Upload.FinishedListener() {
            private static final long serialVersionUID = -3773034195991947371L;

            @Override
            public void uploadFinished(FinishedEvent event) {
                pi.setVisible(false);
                pi2.setVisible(false);
                if (event instanceof Upload.FailedEvent) {
                    Exception reason = ((Upload.FailedEvent) event).getReason();
                    l.setValue("Finished with failure ( " + reason
                            + "  ), idle");
                } else if (event instanceof Upload.SucceededEvent) {
                    l.setValue("Finished with succes, idle");
                } else {
                    l.setValue("Finished with unknow event");
                }

                statusLayout.removeAllComponents();
                final InputStream stream = buffer.getStream();
                if (stream == null) {
                    statusLayout.addComponent(new Label(
                            "Upload finished, but output buffer is null"));
                } else {
                    statusLayout.addComponent(new Label("<b>Name:</b> "
                            + event.getFilename(), ContentMode.HTML));
                    statusLayout.addComponent(new Label("<b>Mimetype:</b> "
                            + event.getMIMEType(), ContentMode.HTML));
                    statusLayout.addComponent(new Label("<b>Size:</b> "
                            + event.getLength() + " bytes.", ContentMode.HTML));

                    statusLayout.addComponent(new Link("Download "
                            + buffer.getFileName(), new StreamResource(buffer,
                            buffer.getFileName())));

                    statusLayout.setVisible(true);
                }

                setBuffer();
            }
        });

        up.addListener(new Upload.ProgressListener() {

            @Override
            public void updateProgress(long readBytes, long contentLenght) {
                pi2.setValue(new Float(readBytes / (float) contentLenght));

                refreshMemUsage();
            }

        });

        final Button b = new Button("Reed state from upload",
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        readState();
                    }
                });

        final Button c = new Button("Force GC", new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                gc();
            }
        });

        main.addComponent(b);
        main.addComponent(c);
        main.addComponent(beSluggish);
        main.addComponent(throwExecption);
        main.addComponent(interrupt);
        interrupt.addListener(new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                up.interruptUpload();
            }
        });

        uploadBufferSelector = new Select("StreamVariable type");
        uploadBufferSelector.setImmediate(true);
        uploadBufferSelector.addItem("memory");
        uploadBufferSelector.setValue("memory");
        uploadBufferSelector.addItem("tempfile");
        uploadBufferSelector
                .addListener(new AbstractField.ValueChangeListener() {
                    @Override
                    public void valueChange(ValueChangeEvent event) {
                        setBuffer();
                    }
                });
        main.addComponent(uploadBufferSelector);

        main.addComponent(up);
        l = new Label("Idle");
        main.addComponent(l);

        pi.setVisible(false);
        pi.setPollingInterval(1000);
        main.addComponent(pi);

        pi2.setVisible(false);
        pi2.setPollingInterval(1000);
        main.addComponent(pi2);

        memoryStatus = new Label();
        main.addComponent(memoryStatus);

        statusLayout.setMargin(true);
        status.setVisible(false);
        main.addComponent(status);
View Full Code Here

        private Button down;

        MyComponent(String name) {
            HorizontalLayout ol = new HorizontalLayout();
            ol.setId(name.replaceAll(" ", ""));
            ol.addComponent(new Label(name));
            up = new Button("up");
            up.addListener(new Button.ClickListener() {
                @Override
                public void buttonClick(ClickEvent event) {
                    int newIndex = order.indexOf(MyComponent.this) - 1;
View Full Code Here

        layout.addStyleName("width-and-height");
        layout.setSizeFull();
        setContent(layout);
        Responsive.makeResponsive(layout);

        layout.addComponent(new Label(
                "Resize the browser window in both dimensions to see the background color change."));
    }
View Full Code Here

    public void init() {
        final LegacyWindow main = new LegacyWindow("Tree filesystem demo");
        setMainWindow(main);

        // Main window contains heading and panel
        main.addComponent(new Label("<h2>Tree demo</h2>", ContentMode.HTML));

        // configure file structure panel
        VerticalLayout explorerLayout = new VerticalLayout();
        explorerLayout.setMargin(true);
        explorerPanel.setContent(explorerLayout);
View Full Code Here

        grids.setSizeFull();
        grids.addComponent(firstGrid);
        grids.addComponent(secondGrid);
        split.addComponent(grids);

        Label description = new Label(
                "<h3>This application demonstrates the Responsive extension in Vaadin.</h3>"
                        + "<p>Drag the splitter to see how the boxes on the left side adapt to "
                        + "different widths. They maintain a width of 100-200px, and always "
                        + "span the entire width of the container.</p><p>This label will "
                        + "adapt its font size and line height for different widths.</p>"
                        + "<p><a href=\"http://vaadin.com/download\">Download "
                        + "Vaadin</a></p>", ContentMode.HTML);
        description.addStyleName("description");
        split.addComponent(description);

        // Add the responsive capabilities to the components
        Responsive.makeResponsive(firstGrid);
        Responsive.makeResponsive(secondGrid);
View Full Code Here

        grid.setWidth("100%");
        grid.addStyleName("grid");
        grid.addStyleName(styleName);

        for (int i = 1; i < 10; i++) {
            Label l = new Label("" + i);
            l.setSizeUndefined();
            grid.addComponent(l);
        }
        return grid;
    }
View Full Code Here

        setMainWindow(mainWindow);
        sp = new HorizontalSplitPanel();
        sp.setSizeFull();
        VerticalLayout naviLayout = new VerticalLayout();
        naviLayout
                .addComponent(new Label(
                        "Click to open a test case.<br/>Right click to open test in a new window<br/><br/>",
                        ContentMode.HTML));
        naviLayout.addComponent(createMenu());
        naviLayout.addComponent(createMissingTestsList());

        sp.setFirstComponent(naviLayout);
        sp.setSplitPosition(250, Sizeable.UNITS_PIXELS);
        VerticalLayout embeddingLayout = new VerticalLayout();
        embeddingLayout.setSizeFull();
        embeddingLayout
                .addComponent(new Label(
                        "<b>Do not use the embedded version for creating automated tests. Open the test in a new window before recording.</b><br/>",
                        ContentMode.HTML));
        applicationEmbedder.setSizeFull();
        embeddingLayout.addComponent(applicationEmbedder);
        embeddingLayout.setExpandRatio(applicationEmbedder, 1);
View Full Code Here

                cls = "missing-deprecated";
            }
            missingTests += "<font class=\"" + cls + "\">"
                    + component.getSimpleName() + "</font><br/>";
        }
        return new Label("<b>Components without a test:</B><br/>"
                + missingTests, ContentMode.HTML);
    }
View Full Code Here

        AbstractComponent result = null;
        final int randint = seededRandom.nextInt(7);
        switch (randint) {
        case 0:
            // Label
            result = new Label();
            result.setCaption("Label component " + caption);
            break;
        case 1:
            // Button
            result = new Button();
            result.setCaption("Button component " + caption);
            break;
        case 2:
            // TextField
            result = new TextField();
            result.setCaption("TextField component " + caption);
            break;
        case 3:
            // Select
            result = new Select("Select " + caption);
            result.setCaption("Select component " + caption);
            ((Select) result).addItem("First item");
            ((Select) result).addItem("Second item");
            ((Select) result).addItem("Third item");
            break;
        case 4:
            // Link
            result = new Link("", new ExternalResource("http://www.vaadin.com"));
            result.setCaption("Link component " + caption);
            break;
        case 5:
            // Link
            VerticalLayout panelLayout = new VerticalLayout();
            panelLayout.setMargin(true);
            result = new Panel(panelLayout);
            result.setCaption("Panel component " + caption);
            panelLayout
                    .addComponent(new Label(
                            "Panel is a container for other components, by default it draws a frame around it's "
                                    + "extremities and may have a caption to clarify the nature of the contained components' purpose."
                                    + " Panel contains an layout where the actual contained components are added, "
                                    + "this layout may be switched on the fly."));
            ((Panel) result).setWidth("250px");
View Full Code Here

TOP

Related Classes of com.vaadin.ui.Label$ValueChangeEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.