Example usage for com.vaadin.ui VerticalLayout addComponent

List of usage examples for com.vaadin.ui VerticalLayout addComponent

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout addComponent.

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:com.esspl.datagen.ui.ResultSetTable.java

License:Open Source License

public ResultSetTable(ResultSet resultSet, List<String> columns) {
    setSizeFull();/*from w w w .  j  a  v a  2  s  .  c  o  m*/

    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();
    setCompositionRoot(vl);

    Component content;
    try {
        content = createResultsTable(resultSet, columns);
    } catch (Exception ex) {
        content = new Label("Failed to process supplied result set: " + ex.getMessage());
    }

    vl.addComponent(content);

    if (content instanceof Table)
        table = (Table) content;
    else
        table = null;
}

From source file:com.esspl.datagen.ui.ResultView.java

License:Open Source License

public ResultView(final DataGenApplication dataGenApplication, ArrayList<GeneratorBean> rowList) {
    log.debug("ResultView constructor start");
    VerticalLayout layout = (VerticalLayout) this.getContent();
    layout.setMargin(false);// ww  w.j  a  v a  2 s  .  c  o  m
    layout.setSpacing(false);
    layout.setHeight("500px");
    layout.setWidth("600px");

    Button close = new Button("Close", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            log.info("ResultView - Close Button clicked");
            dataGenApplication.getMainWindow().removeWindow(event.getButton().getWindow());
        }
    });
    close.setIcon(DataGenConstant.CLOSE_ICON);

    String dataOption = dataGenApplication.generateType.getValue().toString();
    Generator genrator = null;
    if (dataOption.equalsIgnoreCase("xml")) {
        genrator = new XmlDataGenerator();
    } else if (dataOption.equalsIgnoreCase("sql")) {
        genrator = new SqlDataGenerator();
    } else if (dataOption.equalsIgnoreCase("csv")) {
        genrator = new CsvDataGenerator();
    }

    if (genrator == null) {
        log.info("ResultView - genrator object is null");
        dataGenApplication.getMainWindow().removeWindow(this);
        return;
    }

    //Data generated from respective command class and shown in the modal window
    final TextArea message = new TextArea();
    message.setSizeFull();
    message.setHeight("450px");
    message.setWordwrap(false);
    message.setStyleName("noResizeTextArea");
    message.setValue(genrator.generate(dataGenApplication, rowList));
    layout.addComponent(message);

    Button copy = new Button("Copy", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            log.info("ResultView - Copy Button clicked");
            //As on Unix environment, it gives headless exception we need to handle it
            try {
                //StringSelection stringSelection = new StringSelection(message.getValue().toString());
                Transferable tText = new StringSelection(message.getValue().toString());
                Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
                clipboard.setContents(tText, null);
            } catch (HeadlessException e) {
                dataGenApplication.getMainWindow()
                        .showNotification("Due to some problem Text could not be copied.");
                e.printStackTrace();
            }
        }
    });
    copy.setIcon(DataGenConstant.COPY_ICON);

    Button execute = new Button("Execute", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            log.info("ResultView - Execute Button clicked");
            dataGenApplication.tabSheet.setSelectedTab(dataGenApplication.executor);
            dataGenApplication.executor.setScript(message.getValue().toString());
            dataGenApplication.getMainWindow().removeWindow(event.getButton().getWindow());
        }
    });
    execute.setIcon(DataGenConstant.EXECUTOR_ICON);

    Button export = new Button("Export to File", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            log.info("ResultView - Export to File Button clicked");
            String dataOption = dataGenApplication.generateType.getValue().toString();
            DataGenStreamUtil resource = null;
            try {
                if (dataOption.equalsIgnoreCase("xml")) {
                    File tempFile = File.createTempFile("tmp", ".xml");
                    BufferedWriter out = new BufferedWriter(new FileWriter(tempFile));
                    out.write(message.getValue().toString());
                    out.close();
                    resource = new DataGenStreamUtil(dataGenApplication, "data.xml", "text/xml", tempFile);
                } else if (dataOption.equalsIgnoreCase("csv")) {
                    File tempFile = File.createTempFile("tmp", ".csv");
                    BufferedWriter out = new BufferedWriter(new FileWriter(tempFile));
                    out.write(message.getValue().toString());
                    out.close();
                    resource = new DataGenStreamUtil(dataGenApplication, "data.csv", "text/csv", tempFile);
                } else if (dataOption.equalsIgnoreCase("sql")) {
                    File tempFile = File.createTempFile("tmp", ".sql");
                    BufferedWriter out = new BufferedWriter(new FileWriter(tempFile));
                    out.write(message.getValue().toString());
                    out.close();
                    resource = new DataGenStreamUtil(dataGenApplication, "data.sql", "text/plain", tempFile);
                }
                getWindow().open(resource, "_self");
            } catch (FileNotFoundException e) {
                log.info("ResultView - Export to File Error - " + e.getMessage());
                e.printStackTrace();
            } catch (IOException e) {
                log.info("ResultView - Export to File Error - " + e.getMessage());
                e.printStackTrace();
            } catch (Exception e) {
                log.info("ResultView - Export to File Error - " + e.getMessage());
                e.printStackTrace();
            }
        }
    });
    export.setIcon(DataGenConstant.EXPORT_ICON);

    HorizontalLayout bttnBar = new HorizontalLayout();
    if (dataOption.equalsIgnoreCase("sql")) {
        bttnBar.addComponent(execute);
    }
    bttnBar.addComponent(export);
    bttnBar.addComponent(copy);
    bttnBar.addComponent(close);
    layout.addComponent(bttnBar);
    layout.setComponentAlignment(bttnBar, Alignment.MIDDLE_CENTER);
    log.debug("ResultView constructor end");
}

From source file:com.esspl.datagen.ui.SelectableResultSetTable.java

License:Open Source License

public SelectableResultSetTable(ResultSet resultSet, List<String> columns) {
    setSizeFull();//  www  .  j av  a  2s  . c  om

    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();
    setCompositionRoot(vl);

    Component content;
    try {
        content = createResultsTable(resultSet, columns);
    } catch (Exception ex) {
        content = new Label("Failed to process supplied result set: " + ex.getMessage());
    }

    vl.addComponent(content);

    if (content instanceof Table)
        table = (Table) content;
    else
        table = null;
}

From source file:com.esspl.datagen.ui.TableDataView.java

License:Open Source License

public TableDataView(final JdbcTable table, final Connection connection, final DataGenApplication dataApp) {
    log.debug("TableDataView - constructor start");
    setCaption("Data");
    dataGenApplication = dataApp;//from   w w w .jav a 2  s.c o m
    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();
    setCompositionRoot(vl);

    HorizontalLayout hBar = new HorizontalLayout();
    hBar.setWidth("98%");
    hBar.setHeight("40px");

    rows = new TextField();
    rows.setWidth("50px");
    rows.setImmediate(true);
    rows.addValidator(new IntegerValidator("Rows must be an Integer"));
    Label lbl = new Label("Generate ");

    content = new HorizontalLayout();
    content.setHeight("40px");
    content.setMargin(false, false, false, true);
    content.setSpacing(true);
    content.addComponent(lbl);
    content.setComponentAlignment(lbl, Alignment.MIDDLE_CENTER);
    content.addComponent(rows);
    content.setComponentAlignment(rows, Alignment.MIDDLE_CENTER);

    Button addDataButton = new Button("Row(S) Data", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            log.debug("TableDataView - Generate Data Button clicked");
            populateGenerator(table);
        }
    });
    addDataButton.addStyleName("small");
    addDataButton.setIcon(DataGenConstant.ADD_SMALL);
    content.addComponent(addDataButton);
    content.setComponentAlignment(addDataButton, Alignment.MIDDLE_CENTER);

    Button refreshButton = new Button("Refresh", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            log.debug("TableDataView - Refresh Button clicked");
            refreshDataView(table, connection);
        }
    });
    refreshButton.addStyleName("small");
    refreshButton.setIcon(DataGenConstant.RESET);
    content.addComponent(refreshButton);
    content.setComponentAlignment(refreshButton, Alignment.MIDDLE_CENTER);

    //Tapas:10/08/2012 - Export feature implementation started
    HorizontalLayout expContainer = new HorizontalLayout();
    expContainer.setSpacing(true);

    PopupButton exportButton = new PopupButton("Export");
    exportButton.setComponent(new DataExportView());
    exportButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            //dataApp.getMainWindow().showNotification("Export Button clicked!");
        }
    });
    exportButton.setIcon(DataGenConstant.DATAEXPORT_ICON);
    expContainer.addComponent(exportButton);
    expContainer.setComponentAlignment(exportButton, Alignment.MIDDLE_LEFT);

    //Tapas:10/08/2012 - Import feature implementation started
    PopupButton importButton = new PopupButton("Import");
    importButton.setComponent(new DataImportView());
    importButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            //dataApp.getMainWindow().showNotification("Import Button clicked!");
        }
    });
    importButton.setIcon(DataGenConstant.DATAIMPORT_ICON);
    expContainer.addComponent(importButton);
    expContainer.setComponentAlignment(importButton, Alignment.MIDDLE_RIGHT);

    tableContainer = new VerticalLayout();
    tableContainer.setSizeFull();
    hBar.addComponent(content);
    hBar.setComponentAlignment(content, Alignment.MIDDLE_LEFT);
    hBar.addComponent(expContainer);
    hBar.setComponentAlignment(expContainer, Alignment.MIDDLE_RIGHT);
    vl.addComponent(hBar);
    vl.addComponent(tableContainer);
    vl.setExpandRatio(tableContainer, 1f);

    refreshDataView(table, connection);
    log.debug("TableDataView - constructor end");
}

From source file:com.esspl.datagen.ui.TableSelectorView.java

License:Open Source License

public TableSelectorView(DatabaseSessionManager sessionManager, DataGenApplication dataApp) {
    dataGenApplication = dataApp;/*from   w w  w .j a v a 2 s. c  o m*/
    try {
        connection = sessionManager.getConnection();
        if (connection != null) {
            metadataRetriever = new MetadataRetriever(connection);
        }

        setSizeFull();
        Component selectors = createSelectors();

        VerticalLayout vl = new VerticalLayout();
        vl.setSizeFull();

        tableListContainer = createObjecListContainer();
        Table objectList = new Table(null, tableListContainer);
        objectList.setSizeFull();
        objectList.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
        objectList.setSelectable(true);
        objectList.addListener(new ItemClickListener() {

            @Override
            public void itemClick(ItemClickEvent event) {
                if (null == detailsListener)
                    return;

                JdbcTable item = (JdbcTable) event.getItemId();
                if (null == item)
                    return;
                detailsListener.showDetails(createDetails(item));
            }
        });

        vl.addComponent(selectors);
        vl.addComponent(objectList);
        vl.setExpandRatio(objectList, 1f);
        addComponent(vl);
    } catch (SQLException ex) {
        log.error("failed to create table selector view", ex);
        JdbcUtils.close(connection);
    }
}

From source file:com.etest.pdfgenerator.TQViewer.java

public TQViewer(int tqCoverageId) {
    this.tqCoverageId = tqCoverageId;

    //        setSizeFull();
    setWidth("900px");
    setHeight("600px");
    center();// w w  w  .jav a  2 s . co m

    StreamResource resource = new StreamResource(new TQCoveragePDF(getTQCoverageId()), "TQ.pdf");
    resource.setMIMEType("application/pdf");

    VerticalLayout v = new VerticalLayout();
    v.setSizeFull();
    Embedded e = new Embedded();
    e.setSource(resource);
    e.setSizeFull();
    e.setType(Embedded.TYPE_BROWSER);
    v.addComponent(e);

    setContent(v);
}

From source file:com.etest.pdfviewer.ItemAnalysisOfSubjectReportViewer.java

public ItemAnalysisOfSubjectReportViewer(int tqCoverageId) {
    this.tqCoverageId = tqCoverageId;

    setWidth("900px");
    setHeight("600px");
    center();/*  w  ww .  j av a  2s .com*/

    StreamResource resource = new StreamResource(new ItemAnalysisOfSubjectReportPDF(getTQCoverageId()),
            "ItemAnalysis.pdf");
    resource.setMIMEType("application/pdf");

    VerticalLayout v = new VerticalLayout();
    v.setSizeFull();
    Embedded e = new Embedded();
    e.setSource(resource);
    e.setSizeFull();
    e.setType(Embedded.TYPE_BROWSER);
    v.addComponent(e);

    setContent(v);
}

From source file:com.etest.pdfviewer.ItemAnalysisReportViewer.java

public ItemAnalysisReportViewer(int tqCoverageId) {
    this.tqCoverageId = tqCoverageId;

    setWidth("900px");
    setHeight("600px");
    center();//from w w w .  j  a va  2 s.  c o m

    StreamResource resource = new StreamResource(new ItemAnalysisReportPDF(getTqCoverageId()),
            "ItemAnalysis.pdf");
    resource.setMIMEType("application/pdf");

    VerticalLayout v = new VerticalLayout();
    v.setSizeFull();
    Embedded e = new Embedded();
    e.setSource(resource);
    e.setSizeFull();
    e.setType(Embedded.TYPE_BROWSER);
    v.addComponent(e);

    setContent(v);
}

From source file:com.etest.pdfviewer.MultipleChoiceHelpViewer.java

public MultipleChoiceHelpViewer() {
    setWidth("900px");
    setHeight("600px");
    center();// w  w  w. ja  v a2s.  c  o m

    StreamResource.StreamSource source = new StreamResource.StreamSource() {
        @Override
        public InputStream getStream() {
            try {
                return this.getClass().getResourceAsStream("/files/TestConstRules.pdf");
            } catch (Exception e) {
                e.getMessage();
                return null;
            }
        }
    };

    StreamResource resource = new StreamResource(source, "TestConstRules.pdf");
    resource.setMIMEType("application/pdf");

    VerticalLayout v = new VerticalLayout();
    v.setSizeFull();
    Embedded e = new Embedded();
    e.setSource(resource);
    e.setSizeFull();
    e.setType(Embedded.TYPE_BROWSER);
    v.addComponent(e);

    setContent(v);
}

From source file:com.etest.pdfviewer.SummaryReportViewer.java

public SummaryReportViewer(String summaryType) {
    setCaption(summaryType);//from   ww w. j ava  2s.c o m
    setWidth("900px");
    setHeight("600px");
    center();

    StreamResource resource; //= new StreamResource(new InventoryCasesReportPDF(), "InventoryOfCases.pdf");   
    if (summaryType.equals("Summary: Case vs Items")) {
        resource = new StreamResource(new InventoryCasesReportPDF(), "InventoryOfCases.pdf");
    } else {
        resource = new StreamResource(new InventoryItemsReportPDF(), "InventoryOfItems.pdf");
    }
    resource.setMIMEType("application/pdf");

    VerticalLayout v = new VerticalLayout();
    v.setSizeFull();
    Embedded e = new Embedded();
    e.setSource(resource);
    e.setSizeFull();
    e.setType(Embedded.TYPE_BROWSER);
    v.addComponent(e);

    setContent(v);
}