Example usage for com.vaadin.ui Window setSizeFull

List of usage examples for com.vaadin.ui Window setSizeFull

Introduction

In this page you can find the example usage for com.vaadin.ui Window setSizeFull.

Prototype

@Override
    public void setSizeFull() 

Source Link

Usage

From source file:br.gov.sp.saovicente.MyVaadinApplication.java

License:Apache License

@Override
public void init() {

    final Window mainWindow = new Window("Sampleinvientchart2 Application");
    mainWindow.setSizeFull();
    setMainWindow(mainWindow);/*w  w  w.j  ava2s . co  m*/

    mgberr = new MessageBox(getMainWindow(), "My message ERRO...", MessageBox.Icon.ERROR, "Hello World!",
            new MessageBox.ButtonConfig(ButtonType.OK, "Ok"));

    mgbinf = new MessageBox(getMainWindow(), "My message INFO...", MessageBox.Icon.INFO, "Hello World!",
            new MessageBox.ButtonConfig(ButtonType.OK, "Ok"));

    mgbquest = new MessageBox(getMainWindow(), "My message QUESTION...", MessageBox.Icon.QUESTION,
            "Hello World!", new MessageBox.ButtonConfig(ButtonType.YES, "YES"),
            new MessageBox.ButtonConfig(ButtonType.NO, "NO"));

    mgbnone = new MessageBox(getMainWindow(), "My message NONE...", MessageBox.Icon.QUESTION, "Hello World!",
            new MessageBox.ButtonConfig(ButtonType.OK, "Ok"));

    mgbwarn = new MessageBox(getMainWindow(), "My message WARN...", MessageBox.Icon.WARN, "Hello World!",
            new MessageBox.ButtonConfig(ButtonType.OK, "Ok"));

    infomacao = new Button("Informao");

    infomacao.addListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            mgbinf.show(new MessageBox.EventListener() {

                public void buttonClicked(ButtonType buttonType) {
                }
            });
        }
    });

    erro = new Button("Erro");

    erro.addListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            mgberr.show(new MessageBox.EventListener() {

                public void buttonClicked(ButtonType buttonType) {
                    System.out.println("Este boto foi pressionado: " + buttonType);
                }
            });
        }
    });

    none = new Button("None");

    none.addListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            mgbnone.show(new MessageBox.EventListener() {

                public void buttonClicked(ButtonType buttonType) {
                    System.out.println("Este boto foi pressionado: " + buttonType);
                }
            });
        }
    });

    question = new Button("Question");

    question.addListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            mgbquest.show(new MessageBox.EventListener() {

                public void buttonClicked(ButtonType buttonType) {
                    if (buttonType.toString().equals("YES")) {
                        mainWindow.open(new ExternalResource("http://10.171.0.9:8080/bic/"));
                        System.out.println("Este boto foi pressionado: " + buttonType);
                    } else if (buttonType.toString().equals("NO")) {
                        mainWindow.open(new ExternalResource("http://localhost:8080/modelo/"));
                    }
                }
            });
        }
    });

    warn = new Button("Warn");

    warn.addListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            mgbwarn.show(new MessageBox.EventListener() {

                public void buttonClicked(ButtonType buttonType) {
                    System.out.println("Este boto foi pressionado: " + buttonType);
                }
            });
        }
    });

    HorizontalLayout botao = new HorizontalLayout();
    botao.setSpacing(true);
    botao.addComponent(erro);
    botao.addComponent(warn);
    botao.addComponent(none);
    botao.addComponent(infomacao);
    botao.addComponent(question);

    // CustomDateField df = new CustomDateField();
    //df.setbTwelveHourClock(false);
    // df.setbTwelveHourClock(true);
    // mainWindow.addComponent(df);
    //mainWindow.addComponent(new WidgetSetTest());

    mainWindow.addComponent(botao);

}

From source file:com.dungnv.streetfood.ui.RichTextWinDowUI.java

public void addAction() {
    btnEdit.addClickListener(new Button.ClickListener() {
        @Override/*  w  w w. j av  a  2  s  .c  o m*/
        public void buttonClick(Button.ClickEvent event) {
            Window window = new Window();
            window.setSizeFull();
            window.setResizable(false);
            window.setClosable(false);
            window.setContent(layoutWindow);
            UI.getCurrent().addWindow(window);

        }
    });

    btnCloseWindow.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            UI.getCurrent().removeWindow(event.getButton().findAncestor(Window.class));
        }
    });
}

From source file:com.expressui.core.MainApplication.java

License:Open Source License

@Override
public void init() {
    currentInstance.set(this);

    setTheme(getCustomTheme());//  ww w .java  2 s. c  o  m
    customizeConfirmDialogStyle();

    Window mainWindow = new Window();
    setMainWindow(mainWindow);
    mainWindow.addStyleName("e-main-window");
    mainWindow.setCaption(getTypeCaption());

    VerticalLayout mainLayout = new VerticalLayout();
    String id = StringUtil.generateDebugId("e", this, mainLayout, "mainLayout");
    mainLayout.setDebugId(id);

    mainWindow.setSizeFull();
    mainLayout.setSizeFull();
    mainWindow.setContent(mainLayout);

    setLogoutURL(getApplicationProperties().getRestartApplicationUrl());

    configureLeftMenuBar(mainMenuBar.getLeftMenuBarRoot());
    configureRightMenuBar(mainMenuBar.getRightMenuBarRoot());
    mainLayout.addComponent(mainMenuBar);

    pageLayoutTabSheet = new TabSheet();
    id = StringUtil.generateDebugId("e", this, pageLayoutTabSheet, "pageLayoutTabSheet");
    pageLayoutTabSheet.setDebugId(id);

    pageLayoutTabSheet.addStyleName("e-main-page-layout");
    pageLayoutTabSheet.setSizeFull();
    mainLayout.addComponent(pageLayoutTabSheet);
    mainLayout.setExpandRatio(pageLayoutTabSheet, 1.0f);

    Link expressUILink = new Link(uiMessageSource.getMessage("mainApplication.footerMessage"),
            new ExternalResource(uiMessageSource.getMessage("mainApplication.footerLink")));
    expressUILink.setTargetName("_blank");
    expressUILink.setIcon(new ThemeResource("../expressui/favicon.png"));
    expressUILink.setSizeUndefined();
    mainLayout.addComponent(expressUILink);
    mainLayout.setComponentAlignment(expressUILink, Alignment.TOP_CENTER);

    configureSessionTimeout(mainWindow);
    postWire();
    onDisplay();
}

From source file:com.hivesys.dashboard.view.search.TextualView.java

public void UpdateSearchPane(String searchString) {
    css.removeAllComponents();/*from  w  w w.  j  ava2  s  . c  o m*/

    SearchResponse response = ElasticSearchContext.getInstance().searchSimpleQuery(searchString);
    logResponse(response);
    SearchHits results = response.getHits();

    Label labelResultSummary = new Label("About " + results.getHits().length + " results found <br><br>",
            ContentMode.HTML);
    css.addComponent(labelResultSummary);

    for (SearchHit hit : results) {
        CssLayout cssResult = new CssLayout();
        cssResult.setStyleName("search-result");

        try {
            String filename = DocumentDB.getInstance().getDocumentNameFromHash(hit.getId());
            String boxviewID = DocumentDB.getInstance().getBoxViewIDFromHash(hit.getId());

            String highlight = "";
            HighlightField objhighlight = hit.highlightFields().get("file");
            if (objhighlight != null) {
                for (Text fgmt : objhighlight.getFragments()) {
                    highlight += fgmt.string() + "<br>";
                }
            }

            Button lblfileName = new Button(filename);
            lblfileName.addClickListener((Button.ClickEvent event) -> {
                if (boxviewID != null) {
                    String url = BoxViewDocuments.getInstance().getViewURL(boxviewID);
                    if (url != null || !url.equals("")) {
                        url = BoxViewDocuments.getInstance().getViewURL(boxviewID);
                        BrowserFrame bframe = new BrowserFrame(filename, new ExternalResource(url));
                        VerticalLayout vlayout = new VerticalLayout(bframe);

                        final Window w = new Window();
                        w.setSizeFull();
                        w.setModal(true);
                        w.setWindowMode(WindowMode.MAXIMIZED);
                        w.setContent(vlayout);
                        vlayout.setSizeFull();
                        vlayout.setMargin(true);
                        w.setResizable(false);
                        w.setDraggable(false);

                        UI.getCurrent().addWindow(w);
                        bframe.setSizeFull();
                        return;
                    }
                    Notification.show("Preview not available for this document!");
                }
            });
            lblfileName.setPrimaryStyleName("filename");

            Label lblHighlight = new Label(highlight, ContentMode.HTML);
            lblHighlight.setStyleName("highlight");

            cssResult.addComponent(lblfileName);
            cssResult.addComponent(lblHighlight);

            css.addComponent(cssResult);
            css.addComponent(new Label("<br>", ContentMode.HTML));

        } catch (SQLException ex) {
        }

    }

}

From source file:com.terralcode.gestion.frontend.view.widgets.appointment.AppointmentComplaintsPanel.java

private void openComplaintWindow(Complaint complaint) {

    WebBrowser webBrowser = Page.getCurrent().getWebBrowser();

    Window window = new Window("Registro de Queja");
    window.setModal(true);/*from   w  ww  .  j a v  a 2s . c o  m*/
    if (webBrowser.getScreenWidth() < 1024) {
        window.setSizeFull();
    } else {
        window.setHeight(90.0f, Unit.PERCENTAGE);
        window.setWidth(90.0f, Unit.PERCENTAGE);
    }

    //        TextField nameField = new TextField();
    //        nameField.setInputPrompt("Introduzca el ttulo de la queja");
    //        nameField.setWidth("100%");
    TextArea notesArea = new TextArea();
    notesArea.setInputPrompt("Introduzca el contenido de la queja");
    notesArea.setSizeFull();
    //        CheckBox doneField = new CheckBox("Atendido");

    HorizontalLayout horizontal = new HorizontalLayout();
    horizontal.setSpacing(true);
    horizontal.addComponent(createDeleteButton(window));
    horizontal.addComponent(createOkButton(window));

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    layout.setMargin(true);
    layout.addComponent(complaintType);
    layout.addComponent(notesArea);
    //        layout.addComponent(doneField);
    layout.addComponent(horizontal);
    layout.setComponentAlignment(horizontal, Alignment.MIDDLE_RIGHT);
    layout.setExpandRatio(complaintType, 1);
    layout.setExpandRatio(notesArea, 8);
    //        layout.setExpandRatio(doneField, 1);
    layout.setExpandRatio(horizontal, 1);

    BeanItem beanItem = new BeanItem<>(complaint);
    fieldGroup = new BeanFieldGroup<>(Complaint.class);
    fieldGroup.setItemDataSource(beanItem);
    fieldGroup.bind(complaintType, "complaintType");
    fieldGroup.bind(notesArea, "notes");
    //        fieldGroup.bind(doneField, "done");

    window.setContent(layout);
    getUI().addWindow(window);

    //        Window windowComplaint = new Window(complaintView);
    //        WidgetActions actions = new WidgetActions(){
    //
    //            @Override
    //            public void saveAction() {
    //                refreshBind();
    //                windowComplaint.close();
    //            }
    //
    //            @Override
    //            public void deleteAction() {
    //                appointment.getComplaints().remove(complaint);
    //                refreshBind();
    //                windowComplaint.close();
    //            }
    //            
    //        };
    //        complaintView.bind(complaint);
    //        complaintView.setActions(actions);
    //        getUI().addWindow(windowComplaint);
}

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

License:Open Source License

/**
 * Precondition: {DatasetView#table} has to be initialized. e.g. with
 * {DatasetView#buildFilterTable} If it is not, strange behaviour has to be expected. builds the
 * Layout of this view./*  w w w.  j  a va2s.c  o  m*/
 */
private void buildLayout() {
    this.vert.removeAllComponents();

    int browserWidth = UI.getCurrent().getPage().getBrowserWindowWidth();
    int browserHeight = UI.getCurrent().getPage().getBrowserWindowHeight();

    this.vert.setWidth("100%");
    this.setWidth(String.format("%spx", (browserWidth * 0.6)));
    // this.setHeight(String.format("%spx", (browserHeight * 0.8)));

    VerticalLayout statistics = new VerticalLayout();
    HorizontalLayout statContent = new HorizontalLayout();
    statContent.setCaption("Statistics");
    statContent.setIcon(FontAwesome.BAR_CHART_O);
    statContent.addComponent(new Label(String.format("%s registered dataset(s).", numberOfDatasets)));
    statContent.setMargin(true);
    statContent.setSpacing(true);
    statistics.addComponent(statContent);
    statistics.setMargin(true);
    this.vert.addComponent(statistics);

    // Table (containing datasets) section
    VerticalLayout tableSection = new VerticalLayout();
    HorizontalLayout tableSectionContent = new HorizontalLayout();

    tableSectionContent.setCaption("Registered Datasets");
    tableSectionContent.setIcon(FontAwesome.FLASK);
    tableSectionContent.addComponent(this.table);

    tableSectionContent.setMargin(true);
    tableSection.setMargin(true);

    tableSection.addComponent(tableSectionContent);
    this.vert.addComponent(tableSection);

    table.setWidth("100%");
    tableSection.setWidth("100%");
    tableSectionContent.setWidth("100%");

    // this.table.setSizeFull();

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setHeight(null);
    buttonLayout.setWidth("100%");
    buttonLayout.setSpacing(false);

    final Button visualize = new Button(VISUALIZE_BUTTON_CAPTION);
    buttonLayout.addComponent(this.download);
    buttonLayout.addComponent(visualize);

    Button checkAll = new Button("Select all datasets");
    checkAll.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            for (Object itemId : table.getItemIds()) {
                ((CheckBox) table.getItem(itemId).getItemProperty("Select").getValue()).setValue(true);
            }
        }
    });

    Button uncheckAll = new Button("Unselect all datasets");
    uncheckAll.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            for (Object itemId : table.getItemIds()) {
                ((CheckBox) table.getItem(itemId).getItemProperty("Select").getValue()).setValue(false);
            }
        }
    });

    buttonLayout.addComponent(checkAll);
    buttonLayout.addComponent(uncheckAll);
    /**
     * prepare download.
     */
    download.setResource(new ExternalResource("javascript:"));
    download.setEnabled(false);
    visualize.setEnabled(false);

    for (final Object itemId : this.table.getItemIds()) {
        setCheckedBox(itemId, (String) this.table.getItem(itemId).getItemProperty("CODE").getValue());
    }

    /*
     * Update the visualize button. It is only enabled, if the files can be visualized.
     */
    this.table.addValueChangeListener(new ValueChangeListener() {
        /**
         * 
         */
        private static final long serialVersionUID = -4875903343717437913L;

        /**
         * check for what selection can be visualized. If so, enable the button. TODO change to
         * checked.
         */
        @Override
        public void valueChange(ValueChangeEvent event) {
            // Nothing selected or more than one selected.
            Set<Object> selectedValues = (Set<Object>) event.getProperty().getValue();
            if (selectedValues == null || selectedValues.size() == 0 || selectedValues.size() > 1) {
                visualize.setEnabled(false);
                return;
            }
            // if one selected check whether its dataset type is either fastqc or qcml.
            // For now we only visulize these two file types.
            Iterator<Object> iterator = selectedValues.iterator();
            Object next = iterator.next();
            String datasetType = (String) table.getItem(next).getItemProperty("Dataset Type").getValue();
            String fileName = (String) table.getItem(next).getItemProperty("File Name").getValue();
            // TODO: No hardcoding!!
            // if (datasetType.equals("FASTQC") || datasetType.equals("QCML") ||
            // datasetType.equals("BAM")
            // || datasetType.equals("VCF")) {
            if (datasetType.equals("Q_WF_MS_QUALITYCONTROL_RESULTS")
                    && (fileName.endsWith(".html") || fileName.endsWith(".qcML"))) {
                visualize.setEnabled(true);
            } else if (datasetType.equals("Q_WF_MS_QUALITYCONTROL_LOGS")
                    && (fileName.endsWith(".err") || fileName.endsWith(".out"))) {
                visualize.setEnabled(true);
            } else {
                visualize.setEnabled(false);
            }
        }
    });

    // TODO Workflow Views should get those data and be happy
    /*
     * Send message that in datasetview the following was selected. WorkflowViews get those messages
     * and save them, if it is valid information for them.
     */
    this.table.addValueChangeListener(new ValueChangeListener() {
        /**
         * 
         */
        private static final long serialVersionUID = -3554627008191389648L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            // Nothing selected or more than one selected.
            Set<Object> selectedValues = (Set<Object>) event.getProperty().getValue();
            State state = (State) UI.getCurrent().getSession().getAttribute("state");
            ArrayList<String> message = new ArrayList<String>();
            message.add("DataSetView");
            if (selectedValues != null && selectedValues.size() == 1) {
                Iterator<Object> iterator = selectedValues.iterator();
                Object next = iterator.next();
                String datasetType = (String) table.getItem(next).getItemProperty("Dataset Type").getValue();
                message.add(datasetType);
                String project = (String) table.getItem(next).getItemProperty("Project").getValue();

                String space = datahandler.getOpenBisClient().getProjectByCode(project).getSpaceCode();// .getIdentifier().split("/")[1];
                message.add(project);
                message.add((String) table.getItem(next).getItemProperty("Sample").getValue());
                // message.add((String) table.getItem(next).getItemProperty("Sample Type").getValue());
                message.add((String) table.getItem(next).getItemProperty("dl_link").getValue());
                message.add((String) table.getItem(next).getItemProperty("File Name").getValue());
                message.add(space);
                // state.notifyObservers(message);
            } else {
                message.add("null");
            } // TODO
              // state.notifyObservers(message);

        }
    });

    // TODO get the GV to work here. Together with reverse proxy
    // Assumes that table Value Change listner is enabling or disabling the button if preconditions
    // are not fullfilled
    visualize.addClickListener(new ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 9015273307461506369L;

        @Override
        public void buttonClick(ClickEvent event) {
            Set<Object> selectedValues = (Set<Object>) table.getValue();
            Iterator<Object> iterator = selectedValues.iterator();
            Object next = iterator.next();
            String datasetCode = (String) table.getItem(next).getItemProperty("CODE").getValue();
            String datasetFileName = (String) table.getItem(next).getItemProperty("File Name").getValue();
            URL url;
            try {
                Object parent = table.getParent(next);
                if (parent != null) {
                    String parentDatasetFileName = (String) table.getItem(parent).getItemProperty("File Name")
                            .getValue();
                    url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode,
                            parentDatasetFileName + "/" + datasetFileName);
                } else {
                    url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode, datasetFileName);
                }

                Window subWindow = new Window(
                        "QC of Sample: " + (String) table.getItem(next).getItemProperty("Sample").getValue());
                VerticalLayout subContent = new VerticalLayout();
                subContent.setMargin(true);
                subWindow.setContent(subContent);
                QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent();
                // Put some components in it
                Resource res = null;
                String datasetType = (String) table.getItem(next).getItemProperty("Dataset Type").getValue();
                final RequestHandler rh = new ProxyForGenomeViewerRestApi();
                boolean rhAttached = false;
                if (datasetType.equals("Q_WF_MS_QUALITYCONTROL_RESULTS") && datasetFileName.endsWith(".qcML")) {
                    QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                    StreamResource streamres = new StreamResource(re, datasetFileName);
                    streamres.setMIMEType("application/xml");
                    res = streamres;
                } else if (datasetType.equals("Q_WF_MS_QUALITYCONTROL_RESULTS")
                        && datasetFileName.endsWith(".html")) {
                    QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                    StreamResource streamres = new StreamResource(re, datasetFileName);
                    streamres.setMIMEType("text/html");
                    res = streamres;
                } else if (datasetType.equals("Q_WF_MS_QUALITYCONTROL_LOGS")
                        && (datasetFileName.endsWith(".err") || datasetFileName.endsWith(".out"))) {
                    QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                    StreamResource streamres = new StreamResource(re, datasetFileName);
                    streamres.setMIMEType("text/plain");
                    res = streamres;
                } else if (datasetType.equals("FASTQC")) {
                    res = new ExternalResource(url);
                } else if (datasetType.equals("BAM") || datasetType.equals("VCF")) {
                    String filePath = (String) table.getItem(next).getItemProperty("dl_link").getValue();
                    filePath = String.format("/store%s", filePath.split("store")[1]);
                    String fileId = (String) table.getItem(next).getItemProperty("File Name").getValue();
                    // fileId = "control.1kg.panel.samples.vcf.gz";
                    // UI.getCurrent().getSession().addRequestHandler(rh);
                    rhAttached = true;
                    ThemeDisplay themedisplay = (ThemeDisplay) VaadinService.getCurrentRequest()
                            .getAttribute(WebKeys.THEME_DISPLAY);
                    String hostTmp = "http://localhost:7778/vizrest/rest";// "http://localhost:8080/web/guest/mainportlet?p_p_id=QbicmainportletApplicationPortlet_WAR_QBiCMainPortlet_INSTANCE_5pPd5JQ8uGOt&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_cacheability=cacheLevelPage&p_p_col_id=column-1&p_p_col_count=1";
                    // hostTmp +=
                    // "&qbicsession=" + UI.getCurrent().getSession().getAttribute("gv-restapi-session")
                    // + "&someblabla=";
                    // String hostTmp = themedisplay.getURLPortal() +
                    // UI.getCurrent().getPage().getLocation().getPath() + "?qbicsession=" +
                    // UI.getCurrent().getSession().getAttribute("gv-restapi-session") + "&someblabla=" ;
                    // String host = Base64.encode(hostTmp.getBytes());
                    String title = (String) table.getItem(next).getItemProperty("Sample").getValue();
                    // res =
                    // new ExternalResource(
                    // String
                    // .format(
                    // "http://localhost:7778/genomeviewer/?host=%s&title=%s&fileid=%s&featuretype=alignments&filepath=%s&removeZeroGenotypes=false",
                    // host, title, fileId, filePath));
                }
                BrowserFrame frame = new BrowserFrame("", res);
                if (rhAttached) {
                    frame.addDetachListener(new DetachListener() {

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

                        @Override
                        public void detach(DetachEvent event) {
                            UI.getCurrent().getSession().removeRequestHandler(rh);
                        }

                    });
                }

                frame.setSizeFull();
                subContent.addComponent(frame);

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

                frame.setHeight((int) (ui.getPage().getBrowserWindowHeight() * 0.8), Unit.PIXELS);
                // Open it in the UI
                ui.addWindow(subWindow);
            } catch (MalformedURLException e) {
                LOGGER.error(String.format("Visualization failed because of malformedURL for dataset: %s",
                        datasetCode));
                Notification.show(
                        "Given dataset has no file attached to it!! Please Contact your project manager. Or check whether it already has some data",
                        Notification.Type.ERROR_MESSAGE);
            }
        }
    });

    this.vert.addComponent(buttonLayout);

}

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

License:Open Source License

/**
 * Precondition: {DatasetView#table} has to be initialized. e.g. with
 * {DatasetView#buildFilterTable} If it is not, strange behaviour has to be expected. builds the
 * Layout of this view./*from w w  w . j av  a2s .  c o  m*/
 */
private void buildLayout(Boolean dataAvailable, String projectType) {
    vert.removeAllComponents();

    // Table (containing datasets) section
    VerticalLayout tableSection = new VerticalLayout();
    HorizontalLayout tableSectionContent = new HorizontalLayout();

    VerticalLayout projDescription = new VerticalLayout();
    VerticalLayout projDescriptionContent = new VerticalLayout();

    tableSectionContent.setMargin(new MarginInfo(false, false, false, false));
    projDescriptionContent.setMargin(new MarginInfo(false, false, false, false));

    descHorz.addComponent(descContent);
    descHorz.addComponent(descEdit);
    descHorz.setComponentAlignment(descEdit, Alignment.TOP_RIGHT);
    descHorz.setExpandRatio(descContent, 0.9f);
    descHorz.setExpandRatio(descEdit, 0.1f);

    projDescriptionContent.addComponent(descHorz);
    projDescriptionContent.addComponent(peopleInCharge);
    // descContent.setWidth("80%");
    projDescriptionContent.addComponent(descriptionPanel);
    projDescriptionContent.addComponent(statusPanel);
    // longDescription.setWidth("80%");
    // projDescriptionContent.addComponent(experimentLabel);
    // projDescriptionContent.addComponent(statusContent);

    // statusContent.setSpacing(true);
    // statusContent.setMargin(new MarginInfo(false, false, false, true));

    if (projectType.equals("patient")) {
        String patientInfo = "";
        Boolean available = false;

        SearchCriteria sampleSc = new SearchCriteria();
        sampleSc.addMatchClause(
                MatchClause.createAttributeMatch(MatchClauseAttribute.TYPE, "Q_BIOLOGICAL_ENTITY"));
        SearchCriteria projectSc = new SearchCriteria();
        projectSc.addMatchClause(
                MatchClause.createAttributeMatch(MatchClauseAttribute.PROJECT, projectBean.getCode()));
        sampleSc.addSubCriteria(SearchSubCriteria.createExperimentCriteria(projectSc));

        SearchCriteria experimentSc = new SearchCriteria();
        experimentSc.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.TYPE,
                model.ExperimentType.Q_EXPERIMENTAL_DESIGN.name()));
        sampleSc.addSubCriteria(SearchSubCriteria.createExperimentCriteria(experimentSc));
        List<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample> samples = datahandler.getOpenBisClient()
                .getFacade().searchForSamples(sampleSc);
        for (ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample sample : samples) {
            if (sample.getProperties().get("Q_ADDITIONAL_INFO") != null) {
                available = true;
                String[] splitted = sample.getProperties().get("Q_ADDITIONAL_INFO").split(";");
                for (String s : splitted) {
                    String[] splitted2 = s.split(":");
                    patientInfo += String.format("<p><u>%s</u>: %s </p> ", splitted2[0], splitted2[1]);
                }
            }
        }

        if (available) {
            patientInformation.setValue(patientInfo);
        } else {
            patientInformation.setValue("No patient information provided.");
        }

        updateHLALayout();
        projDescriptionContent.addComponent(patientInformation);
        projDescriptionContent.addComponent(hlaTypeLabel);

        // Vaccine Designer

        /*
         * Button vaccineDesigner = new Button("Vaccine Designer");
         * vaccineDesigner.setStyleName(ValoTheme.BUTTON_PRIMARY);
         * vaccineDesigner.setIcon(FontAwesome.CUBES);
         * 
         * vaccineDesigner.addClickListener(new ClickListener() {
         * 
         * @Override public void buttonClick(ClickEvent event) {
         * 
         * ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); StringBuilder
         * sb = new StringBuilder("type="); sb.append("vaccinedesign"); sb.append("&");
         * sb.append("id="); sb.append(projectBean.getId()); message.add(sb.toString());
         * message.add(VaccineDesignerView.navigateToLabel); state.notifyObservers(message);
         */
        // UI.getCurrent().getNavigator()
        // .navigateTo(String.format(VaccineDesignerView.navigateToLabel));
        // }
        // });

        // projDescriptionContent.addComponent(vaccineDesigner);

    }

    projDescriptionContent.addComponent(tsvDownloadContent);

    projDescription.addComponent(projDescriptionContent);

    projDescriptionContent.setSpacing(true);
    projDescription.setMargin(new MarginInfo(false, false, true, true));
    projDescription.setWidth("100%");
    projDescription.setSpacing(true);

    // descriptionLabel.setWidth("100%");
    // tableSection.addComponent(descriptionLabel);
    tableSectionContent.addComponent(this.datasetTable);

    projDescriptionContent.addComponent(contact);

    tableSection.setMargin(new MarginInfo(true, false, false, true));
    tableSection.setSpacing(true);

    tableSection.addComponent(tableSectionContent);

    this.vert.addComponent(projDescription);

    datasetTable.setWidth("100%");
    tableSection.setWidth("100%");
    tableSectionContent.setWidth("100%");

    // this.table.setSizeFull();

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setMargin(new MarginInfo(false, false, true, false));
    buttonLayout.setHeight(null);
    // buttonLayout.setWidth("100%");
    buttonLayout.setSpacing(true);

    this.download.setEnabled(false);
    buttonLayout.setSpacing(true);

    Button checkAll = new Button("Select all datasets");
    checkAll.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            for (Object itemId : datasetTable.getItemIds()) {
                ((CheckBox) datasetTable.getItem(itemId).getItemProperty("Select").getValue()).setValue(true);
            }
        }
    });

    Button uncheckAll = new Button("Unselect all datasets");
    uncheckAll.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            for (Object itemId : datasetTable.getItemIds()) {
                ((CheckBox) datasetTable.getItem(itemId).getItemProperty("Select").getValue()).setValue(false);
            }
        }
    });

    buttonLayout.addComponent(checkAll);
    buttonLayout.addComponent(uncheckAll);

    buttonLayout.addComponent(checkAll);
    buttonLayout.addComponent(uncheckAll);
    buttonLayout.addComponent(this.download);
    /**
     * prepare download.
     */
    download.setResource(new ExternalResource("javascript:"));
    download.setEnabled(false);

    for (final Object itemId : this.datasetTable.getItemIds()) {
        setCheckedBox(itemId, (String) this.datasetTable.getItem(itemId).getItemProperty("CODE").getValue());
    }

    /*
     * Send message that in datasetview the following was selected. WorkflowViews get those messages
     * and save them, if it is valid information for them.
     */
    this.datasetTable.addValueChangeListener(new ValueChangeListener() {
        /**
         * 
         */
        private static final long serialVersionUID = -3554627008191389648L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            // Nothing selected or more than one selected.
            Set<Object> selectedValues = (Set<Object>) event.getProperty().getValue();
            State state = (State) UI.getCurrent().getSession().getAttribute("state");
            ArrayList<String> message = new ArrayList<String>();
            message.add("DataSetView");
            if (selectedValues != null && selectedValues.size() == 1) {
                Iterator<Object> iterator = selectedValues.iterator();
                Object next = iterator.next();
                String datasetType = (String) datasetTable.getItem(next).getItemProperty("Dataset Type")
                        .getValue();
                message.add(datasetType);
                String project = (String) datasetTable.getItem(next).getItemProperty("Project").getValue();

                String space = datahandler.getOpenBisClient().getProjectByCode(project).getSpaceCode();// .getIdentifier().split("/")[1];
                message.add(project);
                message.add((String) datasetTable.getItem(next).getItemProperty("Sample").getValue());
                // message.add((String) table.getItem(next).getItemProperty("Sample Type").getValue());
                message.add((String) datasetTable.getItem(next).getItemProperty("dl_link").getValue());
                message.add((String) datasetTable.getItem(next).getItemProperty("File Name").getValue());
                message.add(space);
                // state.notifyObservers(message);
            } else {
                message.add("null");
            } // TODO
              // state.notifyObservers(message);

        }
    });

    this.datasetTable.addItemClickListener(new ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            if (!event.isDoubleClick()) {
                String datasetCode = (String) datasetTable.getItem(event.getItemId()).getItemProperty("CODE")
                        .getValue();
                String datasetFileName = (String) datasetTable.getItem(event.getItemId())
                        .getItemProperty("File Name").getValue();
                URL url;
                try {
                    Resource res = null;
                    Object parent = datasetTable.getParent(event.getItemId());
                    if (parent != null) {
                        String parentDatasetFileName = (String) datasetTable.getItem(parent)
                                .getItemProperty("File Name").getValue();
                        url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode,
                                parentDatasetFileName + "/" + datasetFileName);
                    } else {
                        url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode, datasetFileName);
                    }

                    Window subWindow = new Window();
                    VerticalLayout subContent = new VerticalLayout();
                    subContent.setMargin(true);
                    subWindow.setContent(subContent);
                    QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent();
                    Boolean visualize = false;

                    if (datasetFileName.endsWith(".pdf")) {
                        QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                        StreamResource streamres = new StreamResource(re, datasetFileName);
                        streamres.setMIMEType("application/pdf");
                        res = streamres;
                        visualize = true;
                    }

                    if (visualize) {
                        LOGGER.debug("Is resource null?: " + String.valueOf(res == null));
                        BrowserFrame frame = new BrowserFrame("", res);

                        frame.setSizeFull();
                        subContent.addComponent(frame);

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

                        frame.setHeight((int) (ui.getPage().getBrowserWindowHeight() * 0.9), Unit.PIXELS);

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

                } catch (MalformedURLException e) {
                    LOGGER.error(String.format("Visualization failed because of malformedURL for dataset: %s",
                            datasetCode));
                    Notification.show(
                            "Given dataset has no file attached to it!! Please Contact your project manager. Or check whether it already has some data",
                            Notification.Type.ERROR_MESSAGE);
                }
            }
        }
    });

    // this.vert.addComponent(buttonLayout);
    if (dataAvailable) {
        this.vert.addComponent(tableSection);
        tableSection.addComponent(buttonLayout);
        projDescription.setMargin(new MarginInfo(false, false, false, true));
    }
}

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

License:Open Source License

/**
 * // w w w.  j a  v a2 s. c om
 * @param datahandler
 * @param request
 * @param user
 */
public void buildMainLayout(DataHandler datahandler, VaadinRequest request, String user) {
    State state = (State) UI.getCurrent().getSession().getAttribute("state");
    MultiscaleController multiscaleController = new MultiscaleController(datahandler.getOpenBisClient(), user);

    final HomeView homeView = new HomeView(datahandler, "Your Projects", user, state, resUrl,
            manager.getTmpFolder());
    DatasetView datasetView = new DatasetView(datahandler, state, resUrl);
    final SampleView sampleView = new SampleView(datahandler, state, resUrl, multiscaleController);
    // BarcodeView barcodeView =
    // new BarcodeView(datahandler.getOpenBisClient(), manager.getBarcodeScriptsFolder(),
    // manager.getBarcodePathVariable());
    final ExperimentView experimentView = new ExperimentView(datahandler, state, resUrl, multiscaleController);
    // ChangePropertiesView changepropertiesView = new ChangePropertiesView(datahandler);

    final AddPatientView addPatientView = new AddPatientView(datahandler, state, resUrl);

    final SearchResultsView searchResultsView = new SearchResultsView(datahandler, "Search results", user,
            state, resUrl);

    Submitter submitter = null;
    try {
        submitter = WorkflowSubmitterFactory.getSubmitter(Type.guseSubmitter, manager);
    } catch (Exception e1) {
        e1.printStackTrace();
    }

    WorkflowViewController controller = new WorkflowViewController(submitter, datahandler, user);

    final ProjectView projectView = new ProjectView(datahandler, state, resUrl, controller, manager);
    final PatientView patientView = new PatientView(datahandler, state, resUrl, controller, manager);

    VerticalLayout navigatorContent = new VerticalLayout();
    // navigatorContent.setResponsive(true);

    final Navigator navigator = new Navigator(UI.getCurrent(), navigatorContent);

    navigator.addView(DatasetView.navigateToLabel, datasetView);
    navigator.addView(SampleView.navigateToLabel, sampleView);
    navigator.addView("", homeView);
    navigator.addView(ProjectView.navigateToLabel, projectView);
    // navigator.addView(BarcodeView.navigateToLabel, barcodeView);
    navigator.addView(ExperimentView.navigateToLabel, experimentView);
    navigator.addView(PatientView.navigateToLabel, patientView);
    navigator.addView(AddPatientView.navigateToLabel, addPatientView);
    navigator.addView(SearchResultsView.navigateToLabel, searchResultsView);

    setNavigator(navigator);

    // Production
    // mainLayout = new VerticalLayout();
    for (Window w : getWindows()) {
        w.setSizeFull();
    }

    mainLayout = new GridLayout(3, 3);
    mainLayout.setResponsive(true);
    mainLayout.setWidth(100, Unit.PERCENTAGE);

    mainLayout.addComponent(navigatorContent, 0, 1, 2, 1);
    mainLayout.setColumnExpandRatio(0, 0.2f);
    mainLayout.setColumnExpandRatio(1, 0.3f);
    mainLayout.setColumnExpandRatio(2, 0.5f);

    // Production
    // HorizontalLayout treeViewAndLevelView = new HorizontalLayout();
    // HorizontalLayout headerView = new HorizontalLayout();
    // headerView.setSpacing(false);
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    // final HorizontalLayout labelLayout = new HorizontalLayout();
    // headerView.addComponent(buttonLayout);
    // headerView.addComponent(labelLayout);

    Button homeButton = new Button("Home");
    homeButton.setIcon(FontAwesome.HOME);
    homeButton.setResponsive(true);
    homeButton.setStyleName(ValoTheme.BUTTON_LARGE);
    homeButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            navigator.navigateTo("");
        }

    });

    // Production
    buttonLayout.addComponent(homeButton);
    // mainLayout.addComponent(homeButton, 0, 0);

    Boolean includePatientCreation = false;

    List<Project> projects = datahandler.getOpenBisClient().getOpenbisInfoService()
            .listProjectsOnBehalfOfUser(datahandler.getOpenBisClient().getSessionToken(), user);
    int numberOfProjects = 0;
    for (Project project : projects) {
        if (project.getSpaceCode().contains("IVAC")) {
            includePatientCreation = true;
        }
        numberOfProjects += 1;
    }

    // add patient button
    if (includePatientCreation) {
        Button addPatient = new Button("Add Patient");
        addPatient.setIcon(FontAwesome.PLUS);
        addPatient.setStyleName(ValoTheme.BUTTON_LARGE);
        addPatient.setResponsive(true);
        // addPatient.setStyleName("addpatient");

        addPatient.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                UI.getCurrent().getNavigator().navigateTo(String.format(AddPatientView.navigateToLabel));
            }
        });

        // Production
        buttonLayout.addComponent(addPatient);
        // mainLayout.addComponent(addPatient, 1, 0);
    }

    mainLayout.addComponent(buttonLayout, 0, 0);

    Button header = new Button(String.format("Total number of projects: %s", numberOfProjects));
    header.setIcon(FontAwesome.HAND_O_RIGHT);
    header.setStyleName(ValoTheme.BUTTON_LARGE);
    header.addStyleName(ValoTheme.BUTTON_BORDERLESS);

    // Production
    // labelLayout.addComponent(header);
    // labelLayout.setWidth(null);

    SearchEngineView searchBarView = new SearchEngineView(datahandler);

    // headerView.setWidth("100%");
    // Production
    // headerView.addComponent(searchBarView);
    // headerView.setComponentAlignment(searchBarView, Alignment.TOP_RIGHT);
    // searchBarView.setSizeUndefined();
    // treeViewAndLevelView.addComponent(navigatorContent);
    // mainLayout.addComponent(headerView);
    // mainLayout.addComponent(treeViewAndLevelView);

    mainLayout.addComponent(header, 1, 0);
    mainLayout.addComponent(searchBarView, 2, 0);

    // Production
    VerticalLayout versionLayout = new VerticalLayout();
    versionLayout.setWidth(100, Unit.PERCENTAGE);
    Label versionLabel = new Label(String.format("version: %s", version));
    Label revisionLabel = new Label(String.format("rev: %s", revision));
    revisionLabel.setWidth(null);
    versionLabel.setWidth(null);

    versionLayout.addComponent(versionLabel);
    if (!isInProductionMode()) {
        versionLayout.addComponent(revisionLabel);
    }
    // versionLayout.setMargin(new MarginInfo(true, false, false, false));
    // mainLayout.addComponent(versionLayout);
    mainLayout.addComponent(versionLayout, 0, 2, 2, 2);
    mainLayout.setRowExpandRatio(2, 1.0f);
    // mainLayout.setSpacing(true);

    versionLayout.setComponentAlignment(versionLabel, Alignment.MIDDLE_RIGHT);
    versionLayout.setComponentAlignment(revisionLabel, Alignment.BOTTOM_RIGHT);

    mainLayout.setComponentAlignment(searchBarView, Alignment.BOTTOM_RIGHT);

    setContent(mainLayout);
    // getContent().setSizeFull();

    // "Responsive design"
    /*
     * getPage().addBrowserWindowResizeListener(new BrowserWindowResizeListener() {
     * 
     * @Override public void browserWindowResized(BrowserWindowResizeEvent event) { int height =
     * event.getHeight(); int width = event.getWidth(); WebBrowser browser =
     * event.getSource().getWebBrowser(); // tv.rebuildLayout(height, width, browser); if
     * (currentView instanceof HomeView) { homeView.updateView(height, width, browser); } else if
     * (currentView instanceof ProjectView) { projectView.updateView(height, width, browser); } else
     * if (currentView instanceof ExperimentView) { experimentView.updateView(height, width,
     * browser); } else if (currentView instanceof PatientView) { patientView.updateView(height,
     * width, browser); } else if (currentView instanceof AddPatientView) {
     * addPatientView.updateView(height, width, browser); } } });
     * 
     * navigator.addViewChangeListener(new ViewChangeListener() {
     * 
     * @Override public boolean beforeViewChange(ViewChangeEvent event) { int height =
     * getPage().getBrowserWindowHeight(); int width = getPage().getBrowserWindowWidth(); WebBrowser
     * browser = getPage().getWebBrowser(); // View oldView = event.getOldView(); //
     * this.setEnabled(oldView, false);
     * 
     * currentView = event.getNewView(); if (currentView instanceof HomeView) {
     * homeView.updateView(height, width, browser); } if (currentView instanceof ProjectView) {
     * projectView.updateView(height, width, browser); } if (currentView instanceof ExperimentView)
     * { experimentView.updateView(height, width, browser); } if (currentView instanceof SampleView)
     * { sampleView.updateView(height, width, browser); } else if (currentView instanceof
     * PatientView) { patientView.updateView(height, width, browser); } else if (currentView
     * instanceof AddPatientView) { addPatientView.updateView(height, width, browser); } return
     * true; }
     * 
     * private void setEnabled(View view, boolean enabled) { // tv.setEnabled(enabled); if (view
     * instanceof HomeView) { homeView.setEnabled(enabled); } if (view instanceof ProjectView) {
     * projectView.setEnabled(enabled); } if (view instanceof ExperimentView) {
     * experimentView.setEnabled(enabled); } if (view instanceof SampleView) {
     * sampleView.setEnabled(enabled); } }
     * 
     * @Override public void afterViewChange(ViewChangeEvent event) { currentView =
     * event.getNewView(); // this.setEnabled(currentView, true); Object currentBean = null; if
     * (currentView instanceof ProjectView) { // TODO refactoring currentBean = new HashMap<String,
     * AbstractMap.SimpleEntry<String, Long>>();
     * 
     * // Production // labelLayout.removeAllComponents(); Button header = new
     * Button(projectView.getHeaderLabel()); header.setStyleName(ValoTheme.BUTTON_LARGE);
     * header.addStyleName(ValoTheme.BUTTON_BORDERLESS); header.setIcon(FontAwesome.HAND_O_RIGHT);
     * 
     * // labelLayout.addComponent(header); } else if (currentView instanceof HomeView) {
     * currentBean = new HashMap<String, AbstractMap.SimpleEntry<String, Long>>();
     * 
     * // labelLayout.removeAllComponents(); Button header = new Button(homeView.getHeader());
     * header.setStyleName(ValoTheme.BUTTON_LARGE);
     * header.addStyleName(ValoTheme.BUTTON_BORDERLESS); header.setIcon(FontAwesome.HAND_O_RIGHT);
     * 
     * // labelLayout.addComponent(header); // currentBean = projectView.getCurrentBean(); } else if
     * (currentView instanceof ExperimentView) { currentBean = experimentView.getCurrentBean();
     * 
     * } else if (currentView instanceof SampleView) { // TODO refactoring currentBean = new
     * HashMap<String, AbstractMap.SimpleEntry<String, Long>>();
     * 
     * // labelLayout.removeAllComponents(); Button header = new Button(sampleView.getHeader());
     * header.setStyleName(ValoTheme.BUTTON_LARGE);
     * header.addStyleName(ValoTheme.BUTTON_BORDERLESS); header.setIcon(FontAwesome.HAND_O_RIGHT);
     * 
     * // labelLayout.addComponent(header);
     * 
     * } else if (currentView instanceof DatasetView) { currentBean = new HashMap<String,
     * AbstractMap.SimpleEntry<String, Long>>(); } else if (currentView instanceof PatientView) {
     * currentBean = new HashMap<String, AbstractMap.SimpleEntry<String, Long>>();
     * 
     * // labelLayout.removeAllComponents(); Button header = new
     * Button(patientView.getHeaderLabel()); header.setStyleName(ValoTheme.BUTTON_LARGE);
     * header.addStyleName(ValoTheme.BUTTON_BORDERLESS); header.setIcon(FontAwesome.HAND_O_RIGHT);
     * // labelLayout.addComponent(header); } else if (currentView instanceof AddPatientView) {
     * currentBean = new HashMap<String, AbstractMap.SimpleEntry<String, Long>>();
     * 
     * // labelLayout.removeAllComponents(); Button header = new Button(addPatientView.getHeader());
     * header.setStyleName(ValoTheme.BUTTON_LARGE);
     * header.addStyleName(ValoTheme.BUTTON_BORDERLESS); header.setIcon(FontAwesome.HAND_O_RIGHT);
     * // labelLayout.addComponent(header); } try { PortletSession portletSession =
     * QbicmainportletUI.getCurrent().getPortletSession(); if (portletSession != null) {
     * portletSession.setAttribute("qbic_download", currentBean, PortletSession.APPLICATION_SCOPE);
     * } } catch (NullPointerException e) { // nothing to do. during initialization that might
     * happen. Nothing to worry about }
     * 
     * 
     * }
     * 
     * });
     */

    /*
     * // go to correct page String requestParams = Page.getCurrent().getUriFragment();
     * 
     * // LOGGER.debug("used urifragement: " + requestParams); if (requestParams != null) {
     * navigator.navigateTo(requestParams.startsWith("!") ? requestParams.substring(1) :
     * requestParams); } else { navigator.navigateTo(""); }
     */
}

From source file:dmc.forecaster.vaadin.VaadingaeApplication.java

License:Open Source License

@Override
public void init() {

    Window mainWindow = new Window("Financial Forecaster (v3)");
    mainWindow.setSizeFull();

    // Create the application data instance
    AppData sessionData = new AppData(this);

    // Register it as a listener in the application context
    getContext().addTransactionListener(sessionData);

    TabPanel tabs = new TabPanel();

    mainWindow.addComponent(tabs);/*from  w w w.  j  a  v a 2  s .  c  om*/
    setMainWindow(mainWindow);

    setTheme("forecaster");

}

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

License:Apache License

private void displayChildCreationWizard() {
    Wizard w = new Wizard();
    Window cw = new VMWindow();
    TemplateNodeComponent tc = new TemplateNodeComponent(new TemplateNode(), true);
    w.addStep(new WizardStep() {

        @Override//from  w  w w  .j av a 2  s.c  o  m
        public String getCaption() {
            return TRANSLATOR.translate("general.add.child");
        }

        @Override
        public Component getContent() {
            return tc;
        }

        @Override
        public boolean onAdvance() {
            return tc.isValid();
        }

        @Override
        public boolean onBack() {
            return false;
        }
    });
    w.addListener(new WizardProgressListener() {
        @Override
        public void activeStepChanged(WizardStepActivationEvent event) {
            //Do nothing
        }

        @Override
        public void stepSetChanged(WizardStepSetChangedEvent event) {
            //Do nothing
        }

        @Override
        public void wizardCompleted(WizardCompletedEvent event) {
            try {
                //Add the item
                TemplateNode tn = tc.getNode(), parent = null;
                Template template = null;
                if (tree.getValue() instanceof TemplateNodePK) {
                    TemplateNodeServer node = new TemplateNodeServer((TemplateNodePK) tree.getValue());
                    template = node.getTemplate();
                    parent = node.getEntity();
                } else if (tree.getValue() instanceof Template) {
                    template = (Template) tree.getValue();
                }
                tn.setTemplate(template);
                if (parent != null) {
                    tn.setTemplateNode(parent);
                }
                new TemplateNodeJpaController(DataBaseManager.getEntityManagerFactory()).create(tn);
                addTemplateNode(tn);
                UI.getCurrent().removeWindow(cw);
            } catch (Exception ex) {
                Exceptions.printStackTrace(ex);
            }
        }

        @Override
        public void wizardCancelled(WizardCancelledEvent event) {
            UI.getCurrent().removeWindow(cw);
        }
    });
    cw.setContent(w);
    cw.setSizeFull();
    UI.getCurrent().addWindow(cw);
}