Example usage for com.vaadin.ui Upload addFailedListener

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

Introduction

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

Prototype

public Registration addFailedListener(FailedListener listener) 

Source Link

Document

Adds the upload interrupted event listener.

Usage

From source file:com.wcs.wcslib.vaadin.widget.multifileupload.component.SmartMultiUpload.java

License:Apache License

private void initSingleUpload() {
    upload = new CustomUpload();
    Upload singleUpload = (Upload) upload;
    singleUpload.setReceiver(new Upload.Receiver() {
        @Override//from w  ww.  j  a  va2 s  .  co m
        public OutputStream receiveUpload(String filename, String mimeType) {
            return handler.getOutputStream();
        }
    });
    singleUpload.setImmediate(true);

    SimpleFileUploadListener uploadEventListener = new SimpleFileUploadListener(handler);
    singleUpload.addStartedListener(uploadEventListener);
    singleUpload.addProgressListener(uploadEventListener);
    singleUpload.addFailedListener(uploadEventListener);
    singleUpload.addFinishedListener(uploadEventListener);
}

From source file:control.ExperimentImportController.java

License:Open Source License

public void init(final String user) {
    ExperimentImportController control = this;
    Upload upload = new Upload("Upload your file here", uploader);
    view.initView(upload);/*from   ww  w.jav  a 2s  .  c  om*/
    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();
            view.resetAfterUpload();
            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 {
                        view.setRegEnabled(false);
                        prep = new SamplePreparator();
                        Map<String, Set<String>> experimentTypeVocabularies = new HashMap<String, Set<String>>();
                        experimentTypeVocabularies.put("Q_ANTIBODY", vocabs.getAntibodiesMap().keySet());
                        experimentTypeVocabularies.put("Q_CHROMATOGRAPHY_TYPE",
                                vocabs.getChromTypesMap().keySet());
                        experimentTypeVocabularies.put("Q_MS_DEVICE",
                                new HashSet<String>(vocabs.getDeviceMap().values()));
                        experimentTypeVocabularies.put("Q_MS_LCMS_METHOD",
                                new HashSet<String>(vocabs.getLcmsMethods()));

                        VocabularyValidator validator = new VocabularyValidator(experimentTypeVocabularies);
                        boolean readSuccess = prep.processTSV(file, getImportType());
                        boolean vocabValid = false;
                        if (readSuccess) {
                            msProperties = prep.getSpecialExperimentsOfTypeOrNull("Q_MS_MEASUREMENT");
                            mhcProperties = prep.getSpecialExperimentsOfTypeOrNull("Q_MHC_LIGAND_EXTRACTION");
                            List<Map<String, Object>> metadataList = new ArrayList<Map<String, Object>>();
                            if (msProperties != null)
                                metadataList.addAll(msProperties.values());
                            if (mhcProperties != null)
                                metadataList.addAll(mhcProperties.values());
                            vocabValid = validator.validateExperimentMetadata(metadataList);
                        }
                        if (readSuccess && vocabValid) {
                            List<SampleSummaryBean> summaries = prep.getSummary();
                            for (SampleSummaryBean s : summaries) {
                                String translation = reverseTaxMap.get(s.getFullSampleContent());
                                if (translation != null)
                                    s.setSampleContent(translation);
                            }
                            Styles.notification("Upload successful",
                                    "Experiment was successfully uploaded and read.", NotificationType.SUCCESS);
                            switch (getImportType()) {
                            // Standard hierarchic QBiC design
                            case QBIC:
                                view.setSummary(summaries);
                                view.setProcessed(prep.getProcessed());
                                view.setRegEnabled(true);
                                projectInfo = prep.getProjectInfo();
                                break;
                            // Standard non-hierarchic design without QBiC specific keywords
                            case Standard:
                                Map<String, List<String>> catToVocabulary = new HashMap<String, List<String>>();
                                catToVocabulary.put("Species", new ArrayList<String>(taxMap.keySet()));
                                catToVocabulary.put("Tissues", new ArrayList<String>(tissueMap.keySet()));
                                catToVocabulary.put("Analytes", new ArrayList<String>(analytesVocabulary));
                                Map<String, List<String>> missingCategoryToValues = new HashMap<String, List<String>>();
                                missingCategoryToValues.put("Species",
                                        new ArrayList<String>(prep.getSpeciesSet()));
                                missingCategoryToValues.put("Tissues",
                                        new ArrayList<String>(prep.getTissueSet()));
                                missingCategoryToValues.put("Analytes",
                                        new ArrayList<String>(prep.getAnalyteSet()));
                                initMissingInfoListener(prep, missingCategoryToValues, catToVocabulary);
                                break;
                            // MHC Ligands that have already been measured (Filenames exist)
                            case MHC_Ligands_Finished:
                                catToVocabulary = new HashMap<String, List<String>>();
                                catToVocabulary.put("Species", new ArrayList<String>(taxMap.keySet()));
                                catToVocabulary.put("Tissues", new ArrayList<String>(tissueMap.keySet()));
                                catToVocabulary.put("Analytes", new ArrayList<String>(analytesVocabulary));
                                missingCategoryToValues = new HashMap<String, List<String>>();
                                missingCategoryToValues.put("Species",
                                        new ArrayList<String>(prep.getSpeciesSet()));
                                missingCategoryToValues.put("Tissues",
                                        new ArrayList<String>(prep.getTissueSet()));
                                missingCategoryToValues.put("Analytes",
                                        new ArrayList<String>(prep.getAnalyteSet()));
                                initMissingInfoListener(prep, missingCategoryToValues, catToVocabulary);
                                break;
                            default:
                                logger.error("Error parsing tsv: " + prep.getError());
                                // view.showError(prep.getError());
                                Styles.notification("Failed to read file.", prep.getError(),
                                        NotificationType.ERROR);
                                break;
                            }
                        } else {
                            if (!readSuccess) {
                                String error = prep.getError();
                                Styles.notification("Failed to read file.", error, NotificationType.ERROR);
                            } else {
                                String error = validator.getError();
                                Styles.notification("Failed to process file.", error, NotificationType.ERROR);
                            }
                            if (!file.delete())
                                logger.error("uploaded tmp file " + file.getAbsolutePath()
                                        + " could not be deleted!");
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                } else {
                    // view.showError(error);
                    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 All")) {
                view.getRegisterButton().setEnabled(false);
                view.showRegistration();
                // collect experiment information
                complexExperiments = new ArrayList<OpenbisExperiment>();
                complexExperiments
                        .addAll(collectComplexExperiments(msProperties, ExperimentType.Q_MS_MEASUREMENT));
                complexExperiments.addAll(
                        collectComplexExperiments(mhcProperties, ExperimentType.Q_MHC_LIGAND_EXTRACTION));
                openbisCreator.registerProjectWithExperimentsAndSamplesBatchWise(view.getSamples(),
                        projectInfo.getDescription(), complexExperiments, view.getProgressBar(),
                        view.getProgressLabel(), new RegisteredSamplesReadyRunnable(view, control), user,
                        projectInfo.isPilot());
                List<String> tsv = prep.getOriginalTSV();
                switch (getImportType()) {
                case Standard:
                case MHC_Ligands_Finished:
                    String tsvContent = addBarcodesToTSV(tsv, view.getSamples(), getImportType());
                    view.setTSVWithBarcodes(tsvContent,
                            uploader.getFileNameWithoutExtension() + "_with_barcodes");
                    break;
                default:
                    break;
                }
            }
        }

        private Collection<? extends OpenbisExperiment> collectComplexExperiments(
                Map<String, Map<String, Object>> propsMap, ExperimentType type) {
            List<OpenbisExperiment> res = new ArrayList<OpenbisExperiment>();
            if (propsMap != null) {
                for (String code : propsMap.keySet())
                    res.add(new OpenbisExperiment(code, type, propsMap.get(code)));
            }
            return res;
        }
    };
    view.getRegisterButton().addClickListener(cl);
}

From source file:cz.zcu.pia.social.network.frontend.components.profile.profile.ComponentEditProfile.java

@Override
@PostConstruct/*from   www.  j  a v  a  2 s.  c o m*/
public void postConstruct() {
    receiver = appContext.getBean(ImageUploader.class);
    Upload upload = new Upload(msgs.getMessage("upload.image"), receiver);
    upload.setButtonCaption(msgs.getMessage("upload"));
    upload.addSucceededListener(receiver);

    upload.addFailedListener(new Upload.FailedListener() {

        @Override
        public void uploadFailed(Upload.FailedEvent event) {
            Notification.show(msgs.getMessage("upload.not.ok"));
        }
    });
    this.layout.addComponent(upload, "upload");
    super.postConstruct();

    this.password.setVisible(false);
    this.passwordRepeat.setVisible(false);
    this.validation.setVisible(false);

}

From source file:cz.zcu.pia.social.network.frontend.components.profile.profile.ComponentProfile.java

/**
 * Post Construct//w ww.jav a 2 s .c  om
 */
@PostConstruct
public void postConstruct() {
    if (!securityHelper.isAuthenticated()) {
        ((MyUI) UI.getCurrent().getUI()).getNavigator().navigateTo(ViewHome.NAME);
        return;
    }
    Users user = usersService.getUserByUsername(securityHelper.getLogedInUser().getUsername());
    if (user == null) {
        return;
    }

    this.addComponent(editProfile);
    editProfile.setUser(user);
    editProfile.setVisible(false);
    editProfile.setParentReference(this);

    setLabels(user);
    editButton = new Button(msgs.getMessage("edit"));
    editButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            buttonEditFunction(event);
        }
    });

    if (securityHelper.getLogedInUser().getUserImageName() != null) {
        reloadImage();

    } else {
        ImageUploader receiver = appContext.getBean(ImageUploader.class);
        receiver.setParentReference(this);
        Upload upload = new Upload(msgs.getMessage("upload.image"), receiver);
        upload.setButtonCaption(msgs.getMessage("upload"));
        upload.addSucceededListener(receiver);

        upload.addFailedListener(new Upload.FailedListener() {

            @Override
            public void uploadFailed(Upload.FailedEvent event) {
                Notification.show(msgs.getMessage("upload.not.ok"));
            }
        });
        layout.addComponent(upload, "picture");

    }

    fullname = new Label(user.getName() + " " + user.getSurname());
    layout.addComponent(fullname, "name");

    Label usernameLabel = new Label(msgs.getMessage("username") + ":");
    Label postsLabel = new Label(msgs.getMessage("number-of-posts") + ":");
    Label followersLabel = new Label(msgs.getMessage("number-of-followers") + ":");

    usernameLabel.setWidth(LABEL_WIDTH, Unit.PIXELS);
    postsLabel.setWidth(LABEL_WIDTH, Unit.PIXELS);
    followersLabel.setWidth(LABEL_WIDTH, Unit.PIXELS);

    layout.addComponent(usernameLabel, "usernameLabel");
    layout.addComponent(postsLabel, "numberPostsLabel");
    layout.addComponent(followersLabel, "numberFollowersLabel");

    layout.addComponent(username, "username");
    layout.addComponent(numberOfposts, "numberPosts");
    layout.addComponent(numberOfFollowers, "numberFollowers");
    layout.addComponent(editButton, "button");
}

From source file:facs.components.UploadBox.java

License:Open Source License

public UploadBox() {
    this.setCaption(CAPTION);
    // there has to be a device selected.
    devices = new NativeSelect("Devices");
    devices.setDescription("Select a device in order to upload information for that specific devices.");
    devices.setNullSelectionAllowed(false);
    deviceNameToId = new HashMap<String, Integer>();
    for (DeviceBean bean : DBManager.getDatabaseInstance().getDevices()) {
        deviceNameToId.put(bean.getName(), bean.getId());
        devices.addItem(bean.getName());
        // System.out.println("Bean.getName: " + bean.getName() + " Bean.getId: " + bean.getId());
    }//from   w  ww  .jav  a 2s  . co m
    occupationGrid = new Grid();
    occupationGrid.setSizeFull();

    // Create the upload component and handle all its events
    final Upload upload = new Upload();
    upload.setReceiver(this);
    upload.addProgressListener(this);
    upload.addFailedListener(this);
    upload.addSucceededListener(this);
    upload.setVisible(false);

    // one can only upload csvs, if a device was selected.
    devices.addValueChangeListener(new ValueChangeListener() {

        /**
         * 
         */
        private static final long serialVersionUID = 7890499571475184208L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            upload.setVisible(event.getProperty().getValue() != null);
        }
    });

    // Put the upload and image display in a panel
    // Panel panel = new Panel(UPLOAD_CAPTION);
    // panel.setWidth("100%");
    VerticalLayout panelContent = new VerticalLayout();
    panelContent.setSpacing(true);
    // panel.setContent(panelContent);
    panelContent.addComponent(devices);
    panelContent.addComponent(upload);
    panelContent.addComponent(progress);
    panelContent.addComponent(occupationGrid);

    panelContent.setMargin(true);
    panelContent.setSpacing(true);

    progress.setVisible(false);

    setCompositionRoot(panelContent);
}

From source file:fi.aalto.drumbeat.drumbeatUI.DrumbeatinterfaceUI.java

License:Open Source License

@SuppressWarnings("deprecation")
private void createTab_Datasets() {
    VerticalLayout tab_datasets = new VerticalLayout();
    tab_datasets.setCaption("Data sets");
    tabsheet.addTab(tab_datasets);/*from w w  w . ja  v  a2  s  .co m*/
    tab_datasets.addComponent(datasets_tree);
    Link void_link = new Link("Void description of the data sets",
            new ExternalResource("http://drumbeat.cs.hut.fi/void.ttl"));
    tab_datasets.addComponent(void_link);
    Panel p_model = new Panel("Upload and convert an IFC file");
    p_model.setWidth("900");
    tab_datasets.addComponent(p_model);

    HorizontalLayout hor1 = new HorizontalLayout();
    hor1.setSizeFull(); // Use all available space
    hor1.setMargin(true);
    p_model.setContent(hor1);

    VerticalLayout upload_selections = new VerticalLayout();
    hor1.addComponent(upload_selections);

    upload_selections.addComponent(sites_tree_4upload);
    VerticalLayout upload_panels = new VerticalLayout();
    hor1.addComponent(upload_panels);

    Panel p_model_file = new Panel("Upload a file");
    p_model_file.setWidth("400");
    upload_panels.addComponent(p_model_file);

    Panel p_model_url = new Panel("Upload from a URL");
    p_model_url.setWidth("400");
    upload_panels.addComponent(p_model_url);

    // Create the upload with a caption and set receiver later
    Upload upload = new Upload("Select a file and press Upload", drumbeat_fileReceiver);
    upload.addSucceededListener(drumbeat_fileReceiver);
    upload.addFailedListener(drumbeat_fileReceiver);
    p_model_file.setContent(upload);

    url_textField.setImmediate(true);
    Button button = new Button("Upload from the URL", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            drumbeat_fileReceiver.receiveFileFromURL(url_textField.getValue());
        }
    });

    HorizontalLayout url_upload = new HorizontalLayout();
    url_upload.setSizeUndefined();
    url_upload.addComponent(url_textField);
    url_upload.addComponent(button);
    url_upload.setSpacing(true);
    p_model_url.setContent(url_upload);

    bim_projects_selection.setInvalidAllowed(false);
    bim_projects_selection.setNullSelectionAllowed(false);
    bim_projects_selection.setNewItemsAllowed(false);
    bim_projects_selection.setWidth("400");
    final VerticalLayout project_browser = new VerticalLayout();
    bim_projects_selection.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = -5188369735622627751L;

        public void valueChange(ValueChangeEvent event) {
            if (bim_projects_selection.getValue() != null) {
                htmlView_BIMProject(project_browser, bim_projects.get(bim_projects_selection.getValue()));
            }
        }
    });

    tab_datasets.addComponent(bim_projects_selection);
    tab_datasets.addComponent(project_browser);
}

From source file:fi.vtt.RVaadin.RUpload.java

License:Apache License

/**
 * Contruct an upload element for R (implemented as Vaadin CustomComponent).
 * /*from ww  w  .j  a  va2s . co m*/
 * @param caption
 *            String caption or null
 * @param R
 *            the corresponding RSession to upload the files to
 */
public RUpload(String caption, RContainer R) {

    /* Create the RUpload custom component */
    super.setSizeUndefined();
    root = new Panel(caption);
    root.setWidth("90ex");

    setCompositionRoot(root);

    HorizontalLayout hbox = new HorizontalLayout();
    hbox.setWidth("100%");

    /* Create the Upload component */
    final Upload upload = new Upload("Choose file", this);
    upload.setButtonCaption("Submit");

    /* Listen for events regarding the success of upload. */
    upload.addSucceededListener(this);
    upload.addFailedListener(this);
    hbox.addComponent(upload);

    Label hfill = new Label();
    hbox.addComponent(hfill);
    hbox.setExpandRatio(hfill, 1.0f);

    remove = new Button("Remove", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            String current = getSelection();

            if (current != null) {
                /* Delete the file */
                delete(current);

                /* Update the lists and the notification area */
                int i = fileNames.indexOf(current);
                fileNames.remove(i);
                mimeTypes.remove(i);
                uploadedFiles.removeItem(current);

                /* Gray out the button, if this was the last item */
                if (fileNames.isEmpty()) {
                    remove.setEnabled(false);
                }
            }
        }
    });

    hbox.addComponent(remove);
    remove.setEnabled(false);
    hbox.setComponentAlignment(remove, Alignment.BOTTOM_RIGHT);

    /* Notification area for already uploaded files */
    uploadedFiles = new ListSelect("Already submitted files");
    uploadedFiles.setMultiSelect(false);
    uploadedFiles.setNullSelectionAllowed(false);
    uploadedFiles.setHeight("4em");
    uploadedFiles.setWidth("100%");

    // Changed for Vaadin 7, not tested!!
    VerticalLayout vbox = new VerticalLayout();
    vbox.addComponent(hbox);
    vbox.addComponent(uploadedFiles);
    root.setContent(vbox);

    /* Bind the component to the given R session */
    this.R = R;
}

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);
            });/*from  w  ww  . ja v  a2  s.  c  o  m*/
    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);/*w ww.  j a va2  s . c om*/
                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.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 a  v  a2  s  .  co  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);
}