Example usage for com.vaadin.ui HorizontalLayout iterator

List of usage examples for com.vaadin.ui HorizontalLayout iterator

Introduction

In this page you can find the example usage for com.vaadin.ui HorizontalLayout iterator.

Prototype

@Override
public Iterator<Component> iterator() 

Source Link

Document

Gets the component container iterator for going trough all the components in the container.

Usage

From source file:org.hip.vif.admin.groupadmin.ui.ContributionsListView.java

License:Open Source License

private void disableOtherButtons(final Button inButton, final HorizontalLayout inButtons) {
    final Iterator<Component> lIterator = inButtons.iterator();
    while (lIterator.hasNext()) {
        final Component lComponent = lIterator.next();
        if (lComponent instanceof Button) {
            if (!inButton.equals(lComponent)) {
                lComponent.setEnabled(false);
            }//www  .jav a2  s  .co  m
        }
    }
}

From source file:qbic.vaadincomponents.InputFilesComponent.java

License:Open Source License

/**
 * returns the currently selected datasets by the user. If no datasets are selected, the list is
 * simply empty Note that no db selections are returned.
 * /*from  w  w w.ja  va  2s.  com*/
 * @return
 */
public List<DatasetBean> getSelectedDatasets() {
    List<DatasetBean> selectedDatasets = new ArrayList<DatasetBean>();

    java.util.Iterator<Component> tabs = inputFileForm.iterator();
    while (tabs.hasNext()) {
        Tab tab = inputFileForm.getTab(tabs.next());
        HorizontalLayout current = (HorizontalLayout) tab.getComponent();
        java.util.Iterator<Component> grids = current.iterator();

        while (grids.hasNext()) {
            Grid currentGrid = (Grid) grids.next();
            // returns one (in single-selection mode) or all (in multi-selection mode) selected items
            Collection<Object> selected = currentGrid.getSelectedRows();
            for (Object o : selected) {
                if (o instanceof DatasetBean) {
                    DatasetBean selectedBean = (DatasetBean) o;
                    selectedDatasets.add(selectedBean);
                }
            }
        }
    }
    if (selectedDatasets.size() == 0) {
        helpers.Utils.Notification("No dataset selected", "Please select at least one dataset.", "error");
    }
    return selectedDatasets;
}

From source file:qbic.vaadincomponents.InputFilesComponent.java

License:Open Source License

/**
 * returns the currently selected datasets by the user as a map with the tab names (defined in the
 * input file CTD) as keys. If no datasets are selected, the Map is simply empty Note that no db
 * selections are returned.//from   w  ww  .j  a  v  a  2  s .c  om
 * 
 * @return
 */
public Map<String, List<DatasetBean>> getSelectedDatasetsAsMap() {
    Map<String, List<DatasetBean>> selectedDatasets = new HashMap<String, List<DatasetBean>>();

    java.util.Iterator<Component> tabs = inputFileForm.iterator();
    while (tabs.hasNext()) {
        List<DatasetBean> tempList = new ArrayList<DatasetBean>();

        Tab tab = inputFileForm.getTab(tabs.next());
        HorizontalLayout current = (HorizontalLayout) tab.getComponent();
        java.util.Iterator<Component> grids = current.iterator();
        while (grids.hasNext()) {
            Grid currentGrid = (Grid) grids.next();
            // returns one (in single-selection mode) or all (in multi-selection mode) selected items
            Collection<Object> selected = currentGrid.getSelectedRows();
            for (Object o : selected) {
                if (o instanceof DatasetBean) {
                    DatasetBean selectedBean = (DatasetBean) o;
                    tempList.add(selectedBean);
                }
            }
        }
        selectedDatasets.put(tab.getCaption(), tempList);
    }
    if (selectedDatasets.size() == 0) {
        helpers.Utils.Notification("No dataset selected", "Please select at least one dataset.", "error");
        // showError("Please select at least one dataset.");
    }
    return selectedDatasets;
}

From source file:qbic.vaadincomponents.InputFilesComponent.java

License:Open Source License

/**
 * returns true if at least one dataset was selected for each tab
 * /*  ww w .  j  a  v a2 s.c o  m*/
 * @return
 */
boolean hasDastasetSelected() {
    java.util.Iterator<Component> tabs = inputFileForm.iterator();
    while (tabs.hasNext()) {
        Tab tab = inputFileForm.getTab(tabs.next());
        HorizontalLayout current = (HorizontalLayout) tab.getComponent();
        java.util.Iterator<Component> grids = current.iterator();
        while (grids.hasNext()) {
            Grid currentGrid = (Grid) grids.next();
            // getSelectedRows returns one (in single-selection mode) or all (in multi-selection mode)
            // selected items
            if (currentGrid.getSelectedRows().size() == 0)
                return false;
        }
    }
    return true;
}

From source file:qbic.vaadincomponents.InputFilesComponent.java

License:Open Source License

/**
 * updates workflow parameters with the currently selected datasets and databases. Be aware that
 * it is not checked, whether the correct workflow is given as parameter
 * /*from   w  w  w . j av  a  2 s. c o m*/
 * @param wf
 * @return false if nothing is selected for some tabs or wf is null or wf is empty
 */
public boolean updateWorkflow(Workflow wf, WorkflowViewController controller) {
    if (wf == null || wf.getData() == null || wf.getData().getData() == null
            || wf.getData().getData().isEmpty())
        return false;

    java.util.Iterator<Component> i = inputFileForm.iterator();
    InputList inpList = wf.getData();
    while (i.hasNext()) {
        Tab tab = inputFileForm.getTab(i.next());

        HorizontalLayout current = (HorizontalLayout) tab.getComponent();
        java.util.Iterator<Component> j = current.iterator();
        while (j.hasNext()) {
            Grid currentGrid = (Grid) j.next();

            String caption = tab.getCaption();

            if (currentGrid.getSelectionModel() instanceof SingleSelectionModel) {
                Object selectionSingle = currentGrid.getSelectedRow();
                // Quick solution
                // TODO Fixed?!
                // if (selectionSingle == null) {
                // if (caption.equals("InputFiles.1.Germline Mutations")
                // || caption.equals("InputFiles.1.bam")) {
                // continue;
                // } else {
                if (selectionSingle == null) {
                    if (wf.getData().getData().get(caption).isRequired()) {
                        helpers.Utils.Notification("Missing input file(s)",
                                "Nothing selected for required input file category" + caption, "error");
                        return false;
                    } else {
                        continue;
                    }
                }

                else {
                    if (selectionSingle instanceof FastaBean) {
                        FastaBean selectedBean = (FastaBean) selectionSingle;
                        inpList.getData().get(caption).setValue(selectedBean.getPath());
                    } else {
                        DatasetBean selectedBean = (DatasetBean) selectionSingle;
                        try {
                            inpList.getData().get(caption)
                                    .setValue(controller.getDatasetsNfsPath(selectedBean));
                        } catch (Exception e) {
                            LOGGER.error("could not retrieve nfs path. Using datasetbeans getfullpath instead. "
                                    + e.getMessage(), e.getStackTrace());
                            inpList.getData().get(caption).setValue(selectedBean.getFullPath());
                        }
                    }
                }

            } else {
                Collection<Object> selectionMulti = currentGrid.getSelectedRows();
                // if ((selectionMulti == null || selectionMulti.isEmpty())
                // && (!caption.equals("InputFiles.1.fastq"))) {
                if ((selectionMulti == null || selectionMulti.isEmpty())) {

                    if (wf.getData().getData().get(caption).isRequired()) {
                        helpers.Utils.Notification("Missing input file(s)",
                                "Nothing selected for required input file(s) category" + caption, "warning");
                        return false;
                    }

                    else {
                        continue;
                    }
                } else {

                    List<String> selectedPaths = new ArrayList<String>();

                    for (Object o : selectionMulti) {
                        DatasetBean selectedBean = (DatasetBean) o;
                        try {
                            selectedPaths.add(controller.getDatasetsNfsPath(selectedBean));
                        } catch (Exception e) {
                            LOGGER.error("could not retrieve nfs path. Using datasetbeans getfullpath instead. "
                                    + e.getMessage(), e.getStackTrace());
                            selectedPaths.add(selectedBean.getFullPath());
                        }
                    }
                    inpList.getData().get(caption).setValue(selectedPaths);
                }
            }
        }
    }
    return true;
}