Example usage for com.vaadin.ui TabSheet getParent

List of usage examples for com.vaadin.ui TabSheet getParent

Introduction

In this page you can find the example usage for com.vaadin.ui TabSheet getParent.

Prototype

@Override
    public HasComponents getParent() 

Source Link

Usage

From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientStatusComponent.java

License:Open Source License

public void updateUI(final ProjectBean currentBean) {
    BeanItemContainer<ExperimentStatusBean> experimentstatusBeans = datahandler
            .computeIvacPatientStatus(currentBean);

    int finishedExperiments = 0;
    status.removeAllComponents();/*from  w  w w  .  jav a  2 s.  co m*/
    status.setWidth(100.0f, Unit.PERCENTAGE);

    // Generate button caption column
    final GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(experimentstatusBeans);
    gpc.addGeneratedProperty("started", new PropertyValueGenerator<String>() {

        @Override
        public Class<String> getType() {
            return String.class;
        }

        @Override
        public String getValue(Item item, Object itemId, Object propertyId) {
            String status = null;

            if ((double) item.getItemProperty("status").getValue() > 0.0) {
                status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.CHECK.getFontFamily()
                        + ";color:" + "#2dd085" + "\">&#x"
                        + Integer.toHexString(FontAwesome.CHECK.getCodepoint()) + ";</span>";
            } else {
                status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.TIMES.getFontFamily()
                        + ";color:" + "#f54993" + "\">&#x"
                        + Integer.toHexString(FontAwesome.TIMES.getCodepoint()) + ";</span>";
            }

            return status.toString();
        }
    });
    gpc.removeContainerProperty("identifier");

    experiments.setContainerDataSource(gpc);
    // experiments.setHeaderVisible(false);
    // experiments.setHeightMode(HeightMode.ROW);
    experiments.setHeightByRows(gpc.size());
    experiments.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS);

    experiments.getColumn("status").setRenderer(new ProgressBarRenderer());
    // experiments.setColumnOrder("started", "code", "description", "status", "download",
    // "runWorkflow");
    experiments.setColumnOrder("started", "code", "description", "status", "workflow");

    experiments.getColumn("workflow").setRenderer(new ButtonRenderer(new RendererClickListener() {
        @Override
        public void click(RendererClickEvent event) {
            ExperimentStatusBean esb = (ExperimentStatusBean) event.getItemId();
            TabSheet parent = (TabSheet) getParent();
            PatientView pv = (PatientView) parent.getParent().getParent();
            WorkflowComponent wp = pv.getWorkflowComponent();

            // TODO WATCH OUT NUMBER OF WORKFLOW TAB IS HARDCODED AT THE MOMENT, NO BETTER SOLUTION
            // FOUND SO FAR, e.g. get Tab by Name ?

            // TODO idea get description of item to navigate to the correct workflow ?!
            if (esb.getDescription().equals("Barcode Generation")) {
                ArrayList<String> message = new ArrayList<String>();
                message.add("clicked");
                message.add(currentBean.getId());
                //TODO navigate to barcode dragon rawwwr
                //          message.add(BarcodeView.navigateToLabel);
                //          state.notifyObservers(message);
            } else if (esb.getDescription().equals("Variant Annotation")) {
                /*
                 * ArrayList<String> message = new ArrayList<String>(); message.add("clicked");
                 * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType");
                 * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&");
                 * sb.append("experiment="); sb.append("Q_WF_NGS_VARIANT_ANNOTATION");
                 * message.add(sb.toString()); message.add(WorkflowView.navigateToLabel);
                 * state.notifyObservers(message);
                 */

                Map<String, String> args = new HashMap<String, String>();
                args.put("id", currentBean.getId());
                args.put("type", "workflowExperimentType");
                args.put("experiment", "Q_WF_NGS_VARIANT_ANNOTATION");
                parent.setSelectedTab(9);
                wp.update(args);

            } else if (esb.getDescription().equals("Epitope Prediction")) {
                /*
                 * ArrayList<String> message = new ArrayList<String>(); message.add("clicked");
                 * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType");
                 * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&");
                 * sb.append("experiment="); sb.append("Q_WF_NGS_EPITOPE_PREDICTION");
                 * message.add(sb.toString()); message.add(WorkflowView.navigateToLabel);
                 * state.notifyObservers(message);
                 */
                Map<String, String> args = new HashMap<String, String>();
                args.put("id", currentBean.getId());
                args.put("type", "workflowExperimentType");
                args.put("experiment", "Q_WF_NGS_EPITOPE_PREDICTION");
                parent.setSelectedTab(9);
                wp.update(args);
            } else if (esb.getDescription().equals("HLA Typing")) {
                /*
                 * ArrayList<String> message = new ArrayList<String>(); message.add("clicked");
                 * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType");
                 * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&");
                 * sb.append("experiment="); sb.append("Q_WF_NGS_HLATYPING"); message.add(sb.toString());
                 * message.add(WorkflowView.navigateToLabel); state.notifyObservers(message);
                 */
                Map<String, String> args = new HashMap<String, String>();
                args.put("id", currentBean.getId());
                args.put("type", "workflowExperimentType");
                args.put("experiment", "Q_WF_NGS_HLATYPING");
                parent.setSelectedTab(9);
                wp.update(args);
            }

            else {
                Notification notif = new Notification("Workflow not (yet) available.", Type.TRAY_NOTIFICATION);
                // Customize it
                notif.setDelayMsec(60000);
                notif.setPosition(Position.MIDDLE_CENTER);
                // Show it in the page
                notif.show(Page.getCurrent());
            }
        }
    }));

    experiments.getColumn("started").setRenderer(new HtmlRenderer());

    ProgressBar progressBar = new ProgressBar();
    progressBar.setCaption("Overall Progress");
    progressBar.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS);
    progressBar.setStyleName("patientprogress");

    status.addComponent(progressBar);
    status.addComponent(experiments);
    status.setComponentAlignment(progressBar, Alignment.MIDDLE_CENTER);
    status.setComponentAlignment(experiments, Alignment.MIDDLE_CENTER);

    /**
     * Defined Experiments for iVac - Barcodes available -> done with project creation (done) -
     * Sequencing done (Status Q_NGS_MEASUREMENT) - Variants annotated (Status
     * Q_NGS_VARIANT_CALLING) - HLA Typing done (STATUS Q_NGS_WF_HLA_TYPING) - Epitope Prediction
     * done (STATUS Q_WF_NGS_EPITOPE_PREDICTION)
     */

    for (Iterator i = experimentstatusBeans.getItemIds().iterator(); i.hasNext();) {
        ExperimentStatusBean statusBean = (ExperimentStatusBean) i.next();

        finishedExperiments += statusBean.getStatus();

        // statusBean.setDownload("Download");
        statusBean.setWorkflow("Run");
    }

    progressBar.setValue((float) finishedExperiments / experimentstatusBeans.size());
}