Example usage for com.vaadin.ui Upload addSucceededListener

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

Introduction

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

Prototype

public Registration addSucceededListener(SucceededListener listener) 

Source Link

Document

Adds the upload success event listener.

Usage

From source file:fr.amapj.view.views.importdonnees.ImportDonneesView.java

License:Open Source License

private Component getUtilisateurPanel() {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);// w  ww.  jav a2  s  .c o m

    addEmptyLine(layout);
    addLabel(layout,
            "Pour importer les utilisateurs en masse, vous devez remplir un fichier Excel  un certain format.");
    addLabel(layout, "Pour avoir un exemple du fichier  remplir, merci de cliquer sur ce lien :");
    layout.addComponent(LinkCreator.createLink(new EGListeAdherent(Type.EXAMPLE)));
    addEmptyLine(layout);

    addLabel(layout, "Une fois que votre fichier Excel est prt, vous pouvez le charger dans l'application."
            + " Pour cela, cliquez sur le bouton \"Charger les utilisateurs\", slectionnez votre fichier, cliquez sur OK. Les utilisateurs seront alors automatiquement crs, sans mot de passe ");
    addEmptyLine(layout);
    //
    UtilisateurImporter utilisateurImporter = new UtilisateurImporter();
    Upload upload = new Upload(null, utilisateurImporter);
    upload.addSucceededListener(utilisateurImporter);
    upload.setImmediate(true);
    upload.setButtonCaption("Charger les utilisateurs");

    layout.addComponent(upload);

    addEmptyLine(layout);

    return layout;
}

From source file:fr.amapj.view.views.importdonnees.ImportDonneesView.java

License:Open Source License

private Component getProduitPanel() {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);//from ww  w  . j  ava 2s .  c om

    addEmptyLine(layout);
    addLabel(layout,
            "Pour importer les produits et les producteurs en masse, vous devez remplir un fichier Excel  un certain format.");
    addLabel(layout, "Pour avoir un exemple du fichier  remplir, merci de cliquer sur ce lien :");
    layout.addComponent(LinkCreator.createLink(new EGListeProduitProducteur(
            fr.amapj.service.services.edgenerator.excel.EGListeProduitProducteur.Type.EXAMPLE)));
    addEmptyLine(layout);

    addLabel(layout, "Une fois que votre fichier Excel est prt, vous pouvez le charger dans l'application."
            + " Pour cela, cliquez sur le bouton \"Charger les produits et les producteurs\", slectionnez votre fichier, cliquez sur OK. Les produits et les producteurs seront alors automatiquement crs.");

    //

    ProduitImporter produitImporter = new ProduitImporter();
    Upload upload = new Upload(null, produitImporter);
    upload.addSucceededListener(produitImporter);
    upload.setImmediate(true);
    upload.setButtonCaption("Charger les produits et les producteurs");

    addEmptyLine(layout);
    layout.addComponent(upload);
    addEmptyLine(layout);

    return layout;
}

From source file:io.mateu.ui.vaadin.framework.MyUI.java

License:Apache License

/**
 * abre el dilogo para cambiar la foto//from ww w .  ja  va2 s.  c o m
 *
 *
 */
private void uploadFoto() {
    // Create a sub-window and set the content
    Window subWindow = new Window("My photo");

    subWindow.setWidth("475px");

    FormLayout f = new FormLayout();
    f.setMargin(true);

    Label e = new Label();

    Image image = new Image();

    class MyUploader implements Upload.Receiver, Upload.SucceededListener {

        File file;

        public File getFile() {
            return file;
        }

        public OutputStream receiveUpload(String fileName, String mimeType) {
            // Create and return a file output stream

            System.out.println("receiveUpload(" + fileName + "," + mimeType + ")");

            FileOutputStream os = null;
            if (fileName != null && !"".equals(fileName)) {

                long id = fileId++;
                String extension = ".tmp";
                if (fileName == null || "".equals(fileName.trim()))
                    fileName = "" + id + extension;
                if (fileName.lastIndexOf(".") < fileName.length() - 1) {
                    extension = fileName.substring(fileName.lastIndexOf("."));
                    fileName = fileName.substring(0, fileName.lastIndexOf("."));
                }
                File temp = null;
                try {
                    temp = File.createTempFile(fileName, extension);
                    os = new FileOutputStream(file = temp);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            return os;
        }

        public void uploadSucceeded(Upload.SucceededEvent event) {
            // Show the uploaded file in the image viewer
            image.setSource(new FileResource(file));
            System.out.println("uploadSucceeded(" + file.getAbsolutePath() + ")");

        }

        public FileLocator getFileLocator() throws IOException {

            String extension = ".tmp";
            String fileName = file.getName();

            if (file.getName() == null || "".equals(file.getName().trim()))
                fileName = "" + getId();
            if (fileName.lastIndexOf(".") < fileName.length() - 1) {
                extension = fileName.substring(fileName.lastIndexOf("."));
                fileName = fileName.substring(0, fileName.lastIndexOf(".")).replaceAll(" ", "_");
            }

            java.io.File temp = (System.getProperty("tmpdir") == null)
                    ? java.io.File.createTempFile(fileName, extension)
                    : new java.io.File(new java.io.File(System.getProperty("tmpdir")), fileName + extension);

            System.out.println("java.io.tmpdir=" + System.getProperty("java.io.tmpdir"));
            System.out.println("Temp file : " + temp.getAbsolutePath());

            if (System.getProperty("tmpdir") == null || !temp.exists()) {
                System.out.println("writing temp file to " + temp.getAbsolutePath());
                Files.copy(file, temp);
            } else {
                System.out.println("temp file already exists");
            }

            String baseUrl = System.getProperty("tmpurl");
            URL url = null;
            try {
                if (baseUrl == null) {
                    url = file.toURI().toURL();
                } else
                    url = new URL(baseUrl + "/" + file.getName());
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
            return new FileLocator(0, file.getName(), url.toString(), file.getAbsolutePath());
        }
    }
    ;
    MyUploader receiver = new MyUploader();

    Upload upload = new Upload(null, receiver);
    //upload.setImmediateMode(false);
    upload.addSucceededListener(receiver);

    f.addComponent(image);

    f.addComponent(upload);

    f.addComponent(e);

    VerticalLayout v = new VerticalLayout();
    v.addComponent(f);

    HorizontalLayout footer = new HorizontalLayout();
    footer.setWidth("100%");
    footer.setSpacing(true);
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);

    Label footerText = new Label("");
    footerText.setSizeUndefined();

    Button ok = new Button("Change it!", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent clickEvent) {
            e.setValue("Changing photo...");
            try {
                FileLocator loc = receiver.getFileLocator();

                io.mateu.ui.core.client.app.MateuUI.getBaseService()
                        .updateFoto(getApp().getUserData().getLogin(), loc, new AsyncCallback<Void>() {

                            @Override
                            public void onFailure(Throwable caught) {
                                e.setValue("" + caught.getClass().getName() + ": " + caught.getMessage());
                            }

                            @Override
                            public void onSuccess(Void result) {
                                e.setValue("OK!");
                                getApp().getUserData().setPhoto(loc.getUrl());
                                foto = (getApp().getUserData().getPhoto() != null)
                                        ? new ExternalResource(getApp().getUserData().getPhoto())
                                        : new ClassResource("profile-pic-300px.jpg");
                                subWindow.close();

                                refreshSettings();

                            }
                        });

            } catch (IOException e1) {
                e1.printStackTrace();
                io.mateu.ui.core.client.app.MateuUI.alert("" + e1.getClass().getName() + ":" + e1.getMessage());
            }

        }
    });
    ok.addStyleName(ValoTheme.BUTTON_PRIMARY);
    ok.setClickShortcut(ShortcutAction.KeyCode.ENTER);

    Button cancel = new Button("Cancel");

    footer.addComponents(footerText, ok); //, cancel);
    footer.setExpandRatio(footerText, 1);

    v.addComponent(footer);

    subWindow.setContent(v);

    // Center it in the browser window
    subWindow.center();

    subWindow.setModal(true);

    // Open it in the UI
    UI.getCurrent().addWindow(subWindow);

    upload.focus();
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.ValidationManagerUI.java

License:Apache License

private void createRequirementSpecNodeMenu(ContextMenu menu) {
    MenuItem create = menu.addItem(TRANSLATOR.translate("create.requiremnet"), VaadinIcons.PLUS,
            (MenuItem selectedItem) -> {
                Requirement r = new Requirement();
                r.setRequirementSpecNode((RequirementSpecNode) tree.getValue());
                displayRequirement(r, true);
            });//  w  ww  .  j  a v a  2s .c om
    create.setEnabled(checkRight("requirement.modify"));
    MenuItem edit = menu.addItem(TRANSLATOR.translate("edit.req.spec.node"), EDIT_ICON,
            (MenuItem selectedItem) -> {
                displayRequirementSpecNode((RequirementSpecNode) tree.getValue(), true);
            });
    edit.setEnabled(checkRight("requirement.modify"));
    MenuItem importRequirement = menu.addItem(TRANSLATOR.translate("import.requirement"), IMPORT_ICON,
            (MenuItem selectedItem) -> {// Create a sub-window and set the content
                Window subWindow = new VMWindow(TRANSLATOR.translate("import.requirement"));
                VerticalLayout subContent = new VerticalLayout();
                subWindow.setContent(subContent);

                //Add a checkbox to know if file has headers or not
                CheckBox cb = new CheckBox(TRANSLATOR.translate("file.has.header"));

                FileUploader receiver = new FileUploader();
                Upload upload = new Upload(TRANSLATOR.translate("upload.excel"), receiver);
                upload.addSucceededListener((Upload.SucceededEvent event1) -> {
                    try {
                        subWindow.close();
                        //TODO: Display the excel file (partially), map columns and import
                        //Process the file
                        RequirementImporter importer = new RequirementImporter(receiver.getFile(),
                                (RequirementSpecNode) tree.getValue());

                        importer.importFile(cb.getValue());
                        importer.processImport();
                        buildProjectTree(tree.getValue());
                        updateScreen();
                    } catch (RequirementImportException ex) {
                        LOG.log(Level.SEVERE, TRANSLATOR.translate("import.error"), ex);
                        Notification.show(TRANSLATOR.translate("import.unsuccessful"),
                                Notification.Type.ERROR_MESSAGE);
                    } catch (VMException ex) {
                        LOG.log(Level.SEVERE, null, ex);
                    }
                });
                upload.addFailedListener((Upload.FailedEvent event1) -> {
                    LOG.log(Level.SEVERE, "Upload unsuccessful!\n{0}", event1.getReason());
                    Notification.show(TRANSLATOR.translate("upload.unsuccessful"),
                            Notification.Type.ERROR_MESSAGE);
                    subWindow.close();
                });
                subContent.addComponent(cb);
                subContent.addComponent(upload);
                // Open it in the UI
                addWindow(subWindow);
            });
    importRequirement.setEnabled(checkRight("requirement.modify"));
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.ValidationManagerUI.java

License:Apache License

private void createTestCaseMenu(ContextMenu menu) {
    MenuItem create = menu.addItem(TRANSLATOR.translate("create.step"), VaadinIcons.PLUS,
            (MenuItem selectedItem) -> {
                TestCase tc = (TestCase) tree.getValue();
                Step s = new Step();
                s.setStepSequence(tc.getStepList().size() + 1);
                s.setTestCase(tc);// ww  w  .j  av  a 2 s .c  o  m
                displayStep(s, true);
            });
    create.setEnabled(checkRight("requirement.modify"));
    MenuItem edit = menu.addItem(TRANSLATOR.translate("edit.test.case"), EDIT_ICON, (MenuItem selectedItem) -> {
        displayTestCase((TestCase) tree.getValue(), true);
    });
    edit.setEnabled(checkRight("testcase.modify"));
    MenuItem importSteps = menu.addItem(TRANSLATOR.translate("import.step"), IMPORT_ICON,
            (MenuItem selectedItem) -> { // Create a sub-window and set the content
                Window subWindow = new VMWindow(TRANSLATOR.translate("import.test.case.step"));
                VerticalLayout subContent = new VerticalLayout();
                subWindow.setContent(subContent);

                //Add a checkbox to know if file has headers or not
                CheckBox cb = new CheckBox(TRANSLATOR.translate("file.has.header"));

                FileUploader receiver = new FileUploader();
                Upload upload = new Upload(TRANSLATOR.translate("upload.excel"), receiver);
                upload.addSucceededListener((Upload.SucceededEvent event1) -> {
                    try {
                        subWindow.close();
                        //TODO: Display the excel file (partially), map columns and import
                        //Process the file
                        TestCase tc = (TestCase) tree.getValue();
                        StepImporter importer = new StepImporter(receiver.getFile(), tc);
                        importer.importFile(cb.getValue());
                        importer.processImport();
                        SortedMap<Integer, Step> map = new TreeMap<>();
                        tc.getStepList().forEach((s) -> {
                            map.put(s.getStepSequence(), s);
                        });
                        //Now update the sequence numbers
                        int count = 0;
                        for (Entry<Integer, Step> entry : map.entrySet()) {
                            entry.getValue().setStepSequence(++count);
                            try {
                                new StepJpaController(DataBaseManager.getEntityManagerFactory())
                                        .edit(entry.getValue());
                            } catch (Exception ex) {
                                LOG.log(Level.SEVERE, null, ex);
                            }
                        }
                        buildProjectTree(new TestCaseServer(tc.getTestCasePK()).getEntity());
                        updateScreen();
                    } catch (TestCaseImportException ex) {
                        LOG.log(Level.SEVERE, TRANSLATOR.translate("import.error"), ex);
                        Notification.show(TRANSLATOR.translate("import.unsuccessful"),
                                Notification.Type.ERROR_MESSAGE);
                    }
                });
                upload.addFailedListener((Upload.FailedEvent event1) -> {
                    LOG.log(Level.SEVERE, "Upload unsuccessful!\n{0}", event1.getReason());
                    Notification.show(TRANSLATOR.translate("upload.unsuccessful"),
                            Notification.Type.ERROR_MESSAGE);
                    subWindow.close();
                });
                subContent.addComponent(cb);
                subContent.addComponent(upload);
                // Open it in the UI
                addWindow(subWindow);
            });
    importSteps.setEnabled(checkRight("requirement.modify"));
    MenuItem export = menu.addItem(TRANSLATOR.translate("general.export"), VaadinIcons.DOWNLOAD,
            (MenuItem selectedItem) -> {
                TestCase tc = (TestCase) tree.getValue();
                UI.getCurrent().addWindow(TestCaseExporter.getTestCaseExporter(Arrays.asList(tc)));
            });
    export.setEnabled(checkRight("testcase.view"));
    addExecutionDashboard(menu);
}

From source file:org.apache.usergrid.chop.webapp.view.user.KeyListLayout.java

License:Apache License

void addUploadControls() {

    keyNameField.setWidth("290px");
    keyNameField.setValue("key-pair-name");
    addComponent(keyNameField, "left: 0px; top: 50px;");

    Upload upload = new Upload("", this);
    upload.setButtonCaption("Add");
    upload.addSucceededListener(this);

    addComponent(upload, "left: 0px; top: 80px;");
}

From source file:org.bubblecloud.ilves.module.content.AssetFlowlet.java

License:Apache License

@Override
public void initialize() {
    entityManager = getSite().getSiteContext().getObject(EntityManager.class);

    final GridLayout gridLayout = new GridLayout(1, 3);
    gridLayout.setSizeFull();/*from  ww  w . j  a  v a 2s  . c  o m*/
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);

    assetEditor = new ValidatingEditor(
            FieldSetDescriptorRegister.getFieldSetDescriptor(Asset.class).getFieldDescriptors());
    assetEditor.setCaption("Asset");
    assetEditor.addListener(this);
    gridLayout.addComponent(assetEditor, 0, 1);

    final Upload upload = new Upload(getSite().localize("field-file-upload"), new Upload.Receiver() {
        @Override
        public OutputStream receiveUpload(String filename, String mimeType) {
            try {
                temporaryFile = File.createTempFile(entity.getAssetId(), ".upload");
                return new FileOutputStream(temporaryFile, false);
            } catch (IOException e) {
                throw new SiteException("Unable to create temporary file for upload.", e);
            }
        }
    });
    upload.setButtonCaption(getSite().localize("button-start-upload"));
    upload.addSucceededListener(new Upload.SucceededListener() {
        @Override
        public void uploadSucceeded(Upload.SucceededEvent event) {
            if (event.getLength() == 0) {
                return;
            }
            if (temporaryFile.length() > Long
                    .parseLong(PropertiesUtil.getProperty("site", "asset-maximum-size"))) {
                Notification.show(getSite().localize("message-file-too-large"),
                        Notification.Type.ERROR_MESSAGE);
                return;
            }

            entity.setName(event.getFilename().substring(0, event.getFilename().lastIndexOf('.')));
            entity.setExtension(event.getFilename().substring(event.getFilename().lastIndexOf('.') + 1));
            entity.setType(event.getMIMEType());
            entity.setSize((int) event.getLength());

            assetEditor.setItem(new BeanItem<Asset>(entity), assetEditor.isNewItem());
            save();
        }
    });
    gridLayout.addComponent(upload, 0, 0);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    gridLayout.addComponent(buttonLayout, 0, 2);

    saveButton = getSite().getButton("save");
    buttonLayout.addComponent(saveButton);
    saveButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            if (isValid()) {
                save();
            } else {
                Notification.show(getSite().localize("message-invalid-form-asset"),
                        Notification.Type.HUMANIZED_MESSAGE);
            }
        }
    });

    discardButton = getSite().getButton("discard");
    buttonLayout.addComponent(discardButton);
    discardButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            assetEditor.discard();
            if (temporaryFile != null) {
                temporaryFile.deleteOnExit();
                temporaryFile = null;
            }
        }
    });

    editPrivilegesButton = getSite().getButton("edit-privileges");
    buttonLayout.addComponent(editPrivilegesButton);
    editPrivilegesButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            final PrivilegesFlowlet privilegesFlowlet = getFlow().getFlowlet(PrivilegesFlowlet.class);
            privilegesFlowlet.edit(entity.getName(), entity.getAssetId(), "view", "edit");
            getFlow().forward(PrivilegesFlowlet.class);
        }
    });
}

From source file:org.eclipse.hawkbit.ui.artifacts.upload.UploadLayout.java

License:Open Source License

private void buildLayout() {

    final Upload upload = new Upload();
    final UploadHandler uploadHandler = new UploadHandler(null, 0, this,
            multipartConfigElement.getMaxFileSize(), upload, null, null, softwareModuleManagement);
    upload.setButtonCaption(i18n.getMessage("upload.file"));
    upload.setImmediate(true);//  w ww.  j  av a2 s.  c o m
    upload.setReceiver(uploadHandler);
    upload.addSucceededListener(uploadHandler);
    upload.addFailedListener(uploadHandler);
    upload.addFinishedListener(uploadHandler);
    upload.addProgressListener(uploadHandler);
    upload.addStartedListener(uploadHandler);
    upload.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON);
    upload.addStyleName("no-border");

    fileUploadLayout = new HorizontalLayout();
    fileUploadLayout.setSpacing(true);
    fileUploadLayout.addStyleName(SPUIStyleDefinitions.FOOTER_LAYOUT);
    fileUploadLayout.addComponent(upload);
    fileUploadLayout.setComponentAlignment(upload, Alignment.MIDDLE_LEFT);
    fileUploadLayout.addComponent(processBtn);
    fileUploadLayout.setComponentAlignment(processBtn, Alignment.MIDDLE_RIGHT);
    fileUploadLayout.addComponent(discardBtn);
    fileUploadLayout.setComponentAlignment(discardBtn, Alignment.MIDDLE_RIGHT);
    fileUploadLayout.addComponent(uploadStatusButton);
    fileUploadLayout.setComponentAlignment(uploadStatusButton, Alignment.MIDDLE_RIGHT);
    setMargin(false);

    /* create drag-drop wrapper for drop area */
    dropAreaWrapper = new DragAndDropWrapper(createDropAreaLayout());
    dropAreaWrapper.setDropHandler(new DropAreahandler());
    setSizeFull();
    setSpacing(true);
}

From source file:org.hip.vif.web.util.UploadComponent.java

License:Open Source License

private Upload createUpload(final IBibliographyTask inTask) {
    final Upload outUpload = new Upload();
    outUpload.setWidthUndefined();/*from   w  ww .  j  a v a2  s . c  o  m*/
    outUpload.setReceiver(new Upload.Receiver() {
        @Override
        public OutputStream receiveUpload(final String inFilename, // NOPMD
                final String inMimeType) {
            return createStream(inFilename);
        }
    });

    final String lCaption = Activator.getMessages().getMessage("ui.upload.button.lbl"); //$NON-NLS-1$
    outUpload.setButtonCaption(lCaption);
    outUpload.setImmediate(true);
    outUpload.setStyleName("vif-upload"); //$NON-NLS-1$

    outUpload.addStartedListener(new Upload.StartedListener() {
        @Override
        public void uploadStarted(final StartedEvent inEvent) { // NOPMD
            fileInfo = new FileInfo(inEvent.getFilename(), inEvent.getMIMEType());
            tempUpload = null; // NOPMD
            uploadFinished = false;
            outUpload.setVisible(false);
            if (hasDownloads) {
                dialog.setVisible(true); // FF
            }
        }
    });
    outUpload.addFinishedListener(new Upload.FinishedListener() {
        @Override
        public void uploadFinished(final FinishedEvent inEvent) { // NOPMD
            uploadFinished = true;
            outUpload.setVisible(true);
        }
    });
    outUpload.addSucceededListener(new Upload.SucceededListener() {
        @Override
        public void uploadSucceeded(final SucceededEvent inEvent) { // NOPMD
            if (!hasDownloads) {
                handleUpload(inTask, false);
            }
        }
    });
    outUpload.addFailedListener(new Upload.FailedListener() {
        @Override
        public void uploadFailed(final FailedEvent inEvent) { // NOPMD
            handleDeleteTemp();
        }
    });

    return outUpload;
}

From source file:org.ikasan.dashboard.ui.mappingconfiguration.window.MappingConfigurationImportWindow.java

License:BSD License

/**
 * Helper method to initialise this object.
 *///from  ww  w  . jav a2s.  c  om
protected void init() {
    this.setModal(true);
    super.setHeight(40.0f, Unit.PERCENTAGE);
    super.setWidth(40.0f, Unit.PERCENTAGE);
    super.center();
    super.setStyleName("ikasan");

    progressLayout.setSpacing(true);
    progressLayout.setVisible(false);
    progressLayout.addComponent(uploadLabel);

    final Upload upload = new Upload("", receiver);
    upload.addSucceededListener(receiver);

    upload.addFinishedListener(new Upload.FinishedListener() {
        public void uploadFinished(FinishedEvent event) {
            upload.setVisible(false);
            try {
                parseUploadFile();
            } catch (Exception e) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

                Notification.show("Caught exception trying to import a Mapping Configuration!\n", sw.toString(),
                        Notification.Type.ERROR_MESSAGE);
            }
        }
    });

    final Button importButton = new Button("Import");
    importButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            upload.interruptUpload();
        }
    });

    upload.addStartedListener(new Upload.StartedListener() {
        public void uploadStarted(StartedEvent event) {
            // This method gets called immediately after upload is started
            upload.setVisible(false);
        }
    });

    upload.addProgressListener(new Upload.ProgressListener() {
        public void updateProgress(long readBytes, long contentLength) {
            // This method gets called several times during the update

        }

    });

    importButton.setStyleName(ValoTheme.BUTTON_SMALL);
    importButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            try {
                saveImportedMappingConfiguration();
                mappingConfiguration = null;
                progressLayout.setVisible(false);
                upload.setVisible(true);

                IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest()
                        .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER);

                systemEventService.logSystemEvent(MappingConfigurationConstants.MAPPING_CONFIGURATION_SERVICE,
                        "Imported mapping configuration: [Client="
                                + mappingConfiguration.getConfigurationServiceClient().getName()
                                + "] [Source Context=" + mappingConfiguration.getSourceContext().getName()
                                + "] [Target Context=" + mappingConfiguration.getTargetContext().getName()
                                + "] [Type=" + mappingConfiguration.getConfigurationType().getName() + "]",
                        authentication.getName());
            } catch (MappingConfigurationServiceException e) {
                if (e.getCause() instanceof DataIntegrityViolationException) {
                    Notification.show("Caught exception trying to save an imported Mapping Configuration!",
                            "This is due to the fact "
                                    + "that, combined, the client, type, source and target context values are unique for a Mapping Configuration. The values"
                                    + " that are being imported and not unique.",
                            Notification.Type.ERROR_MESSAGE);
                } else {
                    StringWriter sw = new StringWriter();
                    PrintWriter pw = new PrintWriter(sw);
                    e.printStackTrace(pw);

                    Notification.show("Caught exception trying to save an imported Mapping Configuration!\n",
                            sw.toString(), Notification.Type.ERROR_MESSAGE);
                }
            }

            close();
        }
    });

    progressLayout.addComponent(importButton);

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.addComponent(new Label("Select file to upload mapping configurations."));
    layout.addComponent(upload);

    layout.addComponent(progressLayout);

    Button cancelButton = new Button("Cancel");
    cancelButton.setStyleName(ValoTheme.BUTTON_SMALL);

    cancelButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            mappingConfiguration = null;
            progressLayout.setVisible(false);
            upload.setVisible(true);
            close();
        }
    });

    HorizontalLayout hlayout = new HorizontalLayout();
    hlayout.addComponent(cancelButton);

    layout.addComponent(hlayout);

    super.setContent(layout);
}