Example usage for com.vaadin.ui Upload setButtonCaption

List of usage examples for com.vaadin.ui Upload setButtonCaption

Introduction

In this page you can find the example usage for com.vaadin.ui Upload setButtonCaption.

Prototype

public void setButtonCaption(String buttonCaption) 

Source Link

Document

In addition to the actual file chooser, upload components have button that starts actual upload progress.

Usage

From source file:org.universAAL.ucc.controller.desktop.ToolController.java

public void buttonClick(ClickEvent event) {
    if (event.getButton() == toolWin.getuStoreButton()) {
        Embedded em = new Embedded("", new ExternalResource(createLink()));
        em.setType(Embedded.TYPE_BROWSER);
        em.setWidth("100%");
        em.setHeight("850px");
        Window w = new Window("uStore");
        w.setWidth("1250px");
        w.setHeight("800px");
        VerticalLayout v = new VerticalLayout();
        w.center();/*from   w  ww .ja  va  2  s. c  o m*/
        v.addComponent(em);
        w.setContent(v);
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(w);
    }
    if (event.getButton() == toolWin.getOpenAAL()) {
        //         Embedded em = new Embedded("", new ExternalResource(
        //               "http://wiki.openaal.org"));
        //         em.setType(Embedded.TYPE_BROWSER);
        //         em.setWidth("100%");
        //         em.setHeight("800px");
        //         Window w = new Window("openAAL");
        //         w.setWidth("1250px");
        //         w.setHeight("800px");
        //         VerticalLayout v = new VerticalLayout();
        //         w.center();
        //         v.addComponent(em);
        //         w.setContent(v);
        BrowseServicesWindow pw = new BrowseServicesWindow(app);
        PurchasedServicesController pc = new PurchasedServicesController(pw, app);
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(pw);
    }
    if (event.getButton() == toolWin.getInstallButton()) {
        // Later uncomment again only for testing commented out!
        Upload up = new Upload("", new AALServiceReceiver());
        up.setButtonCaption(res.getString("install.button"));
        up.addListener((Upload.FinishedListener) this);
        up.addListener((Upload.FailedListener) this);
        installWindow = new Window(res.getString("install.win.caption"));
        installWindow.setResizable(false);
        installWindow.center();
        installWindow.setWidth("400px");
        VerticalLayout v = new VerticalLayout();
        v.setSizeFull();
        v.setSpacing(true);
        v.setMargin(true);
        v.addComponent(up);
        installWindow.setContent(v);

        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(installWindow);
    }
    if (event.getButton() == toolWin.getLogoutButton()) {
        DesktopController.setCurrentPassword("");
        DesktopController.setCurrentUser("");
        //         if(!DesktopController.web.getSocket().isClosed()) {
        //            try {
        //               DesktopController.web.getSocket().close();
        //            } catch (IOException e) {
        //               e.printStackTrace();
        //            }
        //         }
        app.close();
    }

    if (event.getButton() == toolWin.getUninstallButton()) {
        app.getMainWindow().removeWindow(toolWin);
        List<RegisteredService> ids = new ArrayList<RegisteredService>();
        Document doc = Model.getSrvDocument();
        NodeList nodeList = doc.getElementsByTagName("service");
        for (int i = 0; i < nodeList.getLength(); i++) {
            RegisteredService srv = new RegisteredService();
            Element element = (Element) nodeList.item(i);
            System.err.println(element.getAttribute("serviceId"));
            srv.setServiceId(element.getAttribute("serviceId"));
            NodeList srvChilds = element.getChildNodes();
            for (int j = 0; j < srvChilds.getLength(); j++) {
                Node n = srvChilds.item(j);
                if (n.getNodeName().equals("application")) {
                    Element e = (Element) n;
                    srv.getAppId().add(e.getAttribute("appId"));
                }
                if (n.getNodeName().equals("bundle")) {
                    Element b = (Element) n;
                    srv.getBundleId().add(b.getAttribute("id"));
                    srv.setBundleVersion(b.getAttribute("version"));
                }
                if (n.getNodeName().equals("menuEntry")) {
                    Element e = (Element) n;
                    srv.setMenuName(e.getAttribute("entryName"));
                    srv.setIconURL(e.getAttribute("iconURL"));
                    srv.setProvider(e.getAttribute("vendor"));
                    srv.setServiceClass(e.getAttribute("serviceClass"));
                    srv.setUserID(e.getAttribute("userID"));
                }
            }
            ids.add(srv);
        }
        DeinstallWindow dw = new DeinstallWindow(ids);
        app.getMainWindow().addWindow(dw);
        DeinstallController dc = new DeinstallController(dw, app);
        //         frontend.uninstallService(Activator.getSessionKey(), "28002");
        //         frontend.getInstalledUnitsForService(Activator.getSessionKey(), "28002");
    }

    if (event.getButton() == toolWin.getPersonButton()) {
        AddNewPersonWindow apw = null;
        try {
            apw = new AddNewPersonWindow(null, null, app);
        } catch (JAXBException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(apw);
    }
    if (event.getButton() == toolWin.getConfigButton()) {
        AddNewHardwareWindow anhw = null;
        try {
            anhw = new AddNewHardwareWindow(null, null, app);
        } catch (JAXBException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(anhw);
    }
    if (event.getButton() == toolWin.getEditHW()) {
        RoomsWindow hardWare = null;
        try {
            hardWare = new RoomsWindow(app);
        } catch (JAXBException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(hardWare);

    }

    if (event.getButton() == toolWin.getEditPerson()) {
        HumansWindow hw = null;
        try {
            hw = new HumansWindow(app);
        } catch (JAXBException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(hw);
    }
    if (event.getButton() == toolWin.getEditUC()) {
        WhichBundleShouldBeConfiguredWindow uc = new WhichBundleShouldBeConfiguredWindow("Use Cases");
        app.getMainWindow().removeWindow(toolWin);
        app.getMainWindow().addWindow(uc);

    }

}

From source file:org.vaadin.tori.component.AuthoringComponent.java

License:Apache License

private Upload buildAttachUpload() {
    final Receiver receiver = new Receiver() {

        @Override/*from   w  ww  . j a v a2  s .c  om*/
        public OutputStream receiveUpload(final String filename, final String mimeType) {
            attachmentData = new ByteArrayOutputStream();
            attachmentFileName = filename;
            return attachmentData;
        }
    };

    final Upload attach = new Upload(null, receiver);
    attach.setButtonCaption("Add Attachment...");
    attach.setImmediate(true);
    attach.addSucceededListener(new Upload.SucceededListener() {

        @Override
        public void uploadSucceeded(final SucceededEvent event) {
            attachments.put(attachmentFileName, attachmentData.toByteArray());
            attachmentFileName = null;
            attachmentData = null;
            updateAttachmentList();
        }
    });

    attach.addStartedListener(new Upload.StartedListener() {
        @Override
        public void uploadStarted(final StartedEvent event) {
            if (maxFileSize > 0 && event.getContentLength() > maxFileSize) {
                attach.interruptUpload();
                Notification.show("File size too large");
                return;
            }
        }
    });
    return attach;
}

From source file:ru.codeinside.adm.ui.BusinessCalendar.java

License:Mozilla Public License

public BusinessCalendar() {
    Upload upload = new Upload();
    upload.setImmediate(false);/*from   ww  w  .  j  av  a  2  s. co m*/
    upload.setButtonCaption("  ");
    upload.setReceiver(this);
    upload.addListener(this);

    datesTable = new BusinessDatesTable();
    removeButton = createButton("");

    VerticalLayout vr = new VerticalLayout();
    vr.setSizeFull();
    vr.setSpacing(true);
    vr.setMargin(true);

    HorizontalLayout horLayout = new HorizontalLayout();
    horLayout.setSizeFull();
    horLayout.setSpacing(true);
    horLayout.setMargin(true);
    horLayout.addComponent(upload);
    horLayout.addComponent(removeButton);
    vr.addComponent(horLayout);
    vr.addComponent(datesTable);

    addComponent(vr);
    vr.setExpandRatio(horLayout, .1f);
    vr.setExpandRatio(datesTable, .9f);
    datesTable.addListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            removeButton.setVisible(event.getProperty().getValue() != null);
        }
    });
    setSizeFull();
}

From source file:ru.codeinside.adm.ui.employee.EmployeeWidget.java

License:Mozilla Public License

public EmployeeWidget(boolean lockedFilterValue, TreeTable table) {
    this.table = table;
    Upload upload = new Upload();
    upload.setImmediate(false);/* w  w  w  . ja  v a 2  s  . c o  m*/
    upload.setButtonCaption("  ");
    upload.setReceiver(this);
    upload.addListener(this);
    /*    Panel panel1 = new Panel();
        Button button = new Button("??? ", new Button.ClickListener() {
          @Override
          public void buttonClick(Button.ClickEvent event) {
            try {
              URL url = new URL(getApplication().getURL(), "/registry/structures");
              loadEmployeeData(url.openStream());
            } catch (MalformedURLException e) {
              getWindow().showNotification(" " + e.getMessage());
            } catch (IOException e) {
              getWindow().showNotification(" " + e.getMessage());
            }
          }
        });
        panel1.addComponent(button);*/
    tableEmployee = new TableAllEmployee(lockedFilterValue);
    tableEmployee.setSizeFull();
    HorizontalLayout hr = new HorizontalLayout();
    hr.setSizeFull();
    hr.setHeight("70px");
    hr.setSpacing(true);
    hr.setMargin(true);
    hr.addComponent(upload);
    addComponent(hr);
    addComponent(tableEmployee);
    tableEmployee.addButtonToLayout(hr);
    setExpandRatio(hr, 0.01f);
    setExpandRatio(tableEmployee, 0.99f);
    setSizeFull();
}

From source file:ru.codeinside.gses.webui.manager.DirectoryPanel.java

License:Mozilla Public License

static Component createDirectoryPanel() {
    HorizontalSplitPanel horSplit = new HorizontalSplitPanel();
    horSplit.setSizeFull();/*from   w  w  w .  j a v a  2  s . com*/
    horSplit.setMargin(true);

    Panel panel00 = new Panel();
    Panel panel01 = new Panel();

    Panel panel10 = new Panel();

    horSplit.setFirstComponent(panel00);

    VerticalLayout vl = new VerticalLayout();
    horSplit.setSecondComponent(vl);

    vl.addComponent(panel01);
    vl.addComponent(panel10);

    vl.setSpacing(true);

    horSplit.setWidth("100%");
    vl.setHeight("100%");

    panel00.setHeight("100%");
    panel00.setWidth("100%");

    panel01.setWidth("100%");
    panel01.setHeight("100%");
    panel10.setHeight("100%");
    horSplit.setSplitPosition(35);
    vl.setExpandRatio(panel01, 0.25f);
    vl.setExpandRatio(panel10, 0.75f);

    final Table dirMapTable = ManagerWorkplace.createDirectoryMapTable();
    final FilterTable directoryTable = ManagerWorkplace.createDirectoryTable();
    dirMapTable.setVisible(false);

    final Form createFieldForm = new Form();
    createFieldForm.setCaption(" ?  ?");

    final TextField keyField = new TextField("");
    keyField.setRequired(true);
    keyField.setMaxLength(254);
    createFieldForm.addField("key", keyField);

    final TextField valField = new TextField("");
    valField.setRequired(true);
    valField.setMaxLength(1022);
    createFieldForm.addField("val", valField);
    createFieldForm.setVisible(false);

    Button addButton = new Button("",
            new AddTupleButtonListener(createFieldForm, directoryTable, keyField, valField, dirMapTable));
    createFieldForm.addField("submit", addButton);

    directoryTable.addListener(new DirectoryTableChangeListener(createFieldForm, directoryTable, dirMapTable));

    ManagerWorkplace.buildContainer(directoryTable, createFieldForm, dirMapTable);
    directoryTable.setColumnHeaders(new String[] { "?", "", "" });

    final Form createDirectory = new Form();
    createDirectory.setCaption(" ?");
    final TextField field = new TextField("?");
    field.setRequired(true);
    field.setMaxLength(255);
    field.setRequiredError("  ?");
    createDirectory.addField("name", field);
    Button createButton = new Button("",
            new CreateDirectoryButtonListener(field, createDirectory, directoryTable));
    createDirectory.addField("submit", createButton);

    Panel loadPanel = new Panel();
    loadPanel.setCaption(" ?");

    UploadDirectory events = new UploadDirectory(directoryTable, dirMapTable);

    Upload c = new Upload("", events);
    c.addListener(events);

    c.setButtonCaption("");
    loadPanel.addComponent(c);

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeFull();
    verticalLayout.setSpacing(true);
    verticalLayout.addComponent(loadPanel);
    verticalLayout.addComponent(createDirectory);
    verticalLayout.addComponent(directoryTable);

    panel00.addComponent(verticalLayout);

    panel01.addComponent(createFieldForm);

    dirMapTable.setSizeFull();
    dirMapTable.setPageLength(13);
    panel10.addComponent(dirMapTable);

    return horSplit;
}

From source file:ru.codeinside.gses.webui.manager.ServiceWidget.java

License:Mozilla Public License

public ServiceWidget(ApServiceTable c) {
    this.c = c;/* www .  ja va 2 s . co m*/
    Panel panel = new Panel();
    Upload upload = new Upload();
    upload.setImmediate(false);
    upload.setButtonCaption("");
    upload.setReceiver(this);
    upload.addListener(this);
    panel.addComponent(upload);
    Panel panel1 = new Panel();
    Button button = new Button("??? ", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            URL url;
            try {
                url = new URL(
                        "http://" + getApplication().getURL().getHost() + "/registry-1.0-SNAPSHOT/services");
                loadServiceData(url.openStream());
            } catch (MalformedURLException e) {
                System.out.println(e);
            } catch (IOException e) {
                System.out.println(e);
            }
        }
    });
    panel1.addComponent(button);
    this.setSpacing(true);
    this.addComponent(panel);
}

From source file:views.BatchUpload.java

License:Open Source License

public BatchUpload() {
    setMargin(true);/*from  ww  w .  j a  v  a  2 s . com*/
    setSpacing(true);

    // file upload component
    Upload upload = new Upload("Upload your file here", uploader);
    addComponent(this.upload);
    upload.setEnabled(false);

    // sample registration button
    register = new Button("Register People");
    register.setVisible(false);
    addComponent(register);

    upload.setButtonCaption("Upload");
    // Listen for events regarding the success of upload.
    upload.addFailedListener(uploader);
    upload.addSucceededListener(uploader);
    FinishedListener uploadFinListener = new FinishedListener() {
        /**
         * 
         */
        private static final long serialVersionUID = -8413963075202260180L;

        public void uploadFinished(FinishedEvent event) {
            String uploadError = uploader.getError();
            File file = uploader.getFile();
            if (file.getPath().endsWith("up_")) {
                String msg = "No file selected.";
                logger.warn(msg);
                Styles.notification("Failed to read file.", msg, NotificationType.ERROR);
                if (!file.delete())
                    logger.error("uploaded tmp file " + file.getAbsolutePath() + " could not be deleted!");
            } else {
                if (uploadError == null || uploadError.isEmpty()) {
                    String msg = "Upload successful!";
                    logger.info(msg);
                    //            try {
                    setRegEnabled(false);
                    SQLBatchParser parser = new SQLBatchParser();
                    if (parser.processTSV()) {
                        // TODO = prep.getObjects();
                        Styles.notification("Upload successful",
                                "New people information successfully uploaded and read.",
                                NotificationType.SUCCESS);
                    } else {
                        String error = parser.getError();
                        Styles.notification("Failed to read file.", error, NotificationType.ERROR);
                        if (!file.delete())
                            logger.error(
                                    "uploaded tmp file " + file.getAbsolutePath() + " could not be deleted!");
                    }
                    //            } catch (IOException e) {
                    //              e.printStackTrace();
                    //            }
                } else {
                    Styles.notification("Failed to upload file.", uploadError, NotificationType.ERROR);
                    if (!file.delete())
                        logger.error("uploaded tmp file " + file.getAbsolutePath() + " could not be deleted!");
                }
            }
        }
    };
    upload.addFinishedListener(uploadFinListener);
    // view.initUpload(upload);

    Button.ClickListener cl = new Button.ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        /**
         * 
         */

        @Override
        public void buttonClick(ClickEvent event) {
            String src = event.getButton().getCaption();
            if (src.equals("Register People")) {
                register.setEnabled(false);
            }
        }
    };
    register.addClickListener(cl);
}