Example usage for com.vaadin.ui Button addListener

List of usage examples for com.vaadin.ui Button addListener

Introduction

In this page you can find the example usage for com.vaadin.ui Button addListener.

Prototype

@Override
public Registration addListener(Class<?> eventType, Object target, Method method) 

Source Link

Document

Registers a new listener with the specified activation method to listen events generated by this component.

Usage

From source file:com.esspl.datagen.DataGenApplication.java

License:Open Source License

private void buildMainLayout() {
    log.debug("DataGenApplication - buildMainLayout() start");
    VerticalLayout rootLayout = new VerticalLayout();
    final Window root = new Window("DATA Gen", rootLayout);
    root.setStyleName("tData");

    setMainWindow(root);/*from w  w w.  ja va  2  s. c o  m*/

    rootLayout.setSizeFull();
    rootLayout.setMargin(false, true, false, true);

    // Top area, containing logo and header
    HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    root.addComponent(top);

    // Create the placeholders for all the components in the top area
    HorizontalLayout header = new HorizontalLayout();

    // Add the components and align them properly
    top.addComponent(header);
    top.setComponentAlignment(header, Alignment.TOP_LEFT);

    top.setStyleName("top");
    top.setHeight("75px"); // Same as the background image height

    // header controls
    Embedded logo = new Embedded();
    logo.setSource(DataGenConstant.LOGO);
    logo.setWidth("100%");
    logo.setStyleName("logo");
    header.addComponent(logo);
    header.setSpacing(false);

    //Show which connection profile is connected
    connectedString = new Label("Connected to - Oracle");
    connectedString.setStyleName("connectedString");
    connectedString.setWidth("500px");
    connectedString.setVisible(false);
    top.addComponent(connectedString);

    //Toolbar
    toolbar = new ToolBar(this);
    top.addComponent(toolbar);
    top.setComponentAlignment(toolbar, Alignment.TOP_RIGHT);

    listing = new Table();
    listing.setHeight("240px");
    listing.setWidth("100%");
    listing.setStyleName("dataTable");
    listing.setImmediate(true);

    // turn on column reordering and collapsing
    listing.setColumnReorderingAllowed(true);
    listing.setColumnCollapsingAllowed(true);
    listing.setSortDisabled(true);

    // Add the table headers
    listing.addContainerProperty("Sl No.", Integer.class, null);
    listing.addContainerProperty("Column Name", TextField.class, null);
    listing.addContainerProperty("Data Type", Select.class, null);
    listing.addContainerProperty("Format", Select.class, null);
    listing.addContainerProperty("Examples", Label.class, null);
    listing.addContainerProperty("Additional Data", HorizontalLayout.class, null);
    listing.setColumnAlignments(new String[] { Table.ALIGN_CENTER, Table.ALIGN_CENTER, Table.ALIGN_CENTER,
            Table.ALIGN_CENTER, Table.ALIGN_CENTER, Table.ALIGN_CENTER });

    //From the starting create 5 rows
    addRow(5);

    //Add different style for IE browser
    WebApplicationContext context = ((WebApplicationContext) getMainWindow().getApplication().getContext());
    WebBrowser browser = context.getBrowser();

    //Create a TabSheet
    tabSheet = new TabSheet();
    tabSheet.setSizeFull();
    if (!browser.isIE()) {
        tabSheet.setStyleName("tabSheet");
    }

    //Generator Tab content start
    generator = new VerticalLayout();
    generator.setMargin(true, true, false, true);

    generateTypeHl = new HorizontalLayout();
    generateTypeHl.setMargin(false, false, false, true);
    generateTypeHl.setSpacing(true);
    List<String> generateTypeList = Arrays.asList(new String[] { "Sql", "Excel", "XML", "CSV" });
    generateType = new OptionGroup("Generation Type", generateTypeList);
    generateType.setNullSelectionAllowed(false); // user can not 'unselect'
    generateType.select("Sql"); // select this by default
    generateType.setImmediate(true); // send the change to the server at once
    generateType.addListener(this); // react when the user selects something
    generateTypeHl.addComponent(generateType);

    //SQL Options
    sqlPanel = new Panel("SQL Options");
    sqlPanel.setHeight("180px");
    if (browser.isIE()) {
        sqlPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanelIE");
    } else {
        sqlPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanel");
    }
    VerticalLayout vl1 = new VerticalLayout();
    vl1.setMargin(false);
    Label lb1 = new Label("DataBase");
    database = new Select();
    database.addItem("Oracle");
    database.addItem("Sql Server");
    database.addItem("My Sql");
    database.addItem("Postgress Sql");
    database.addItem("H2");
    database.select("Oracle");
    database.setWidth("160px");
    database.setNullSelectionAllowed(false);
    HorizontalLayout dbBar = new HorizontalLayout();
    dbBar.setMargin(false, false, false, false);
    dbBar.setSpacing(true);
    dbBar.addComponent(lb1);
    dbBar.addComponent(database);
    vl1.addComponent(dbBar);

    Label tblLabel = new Label("Table Name");
    tblName = new TextField();
    tblName.setWidth("145px");
    tblName.setStyleName("mandatory");
    HorizontalLayout tableBar = new HorizontalLayout();
    tableBar.setMargin(true, false, false, false);
    tableBar.setSpacing(true);
    tableBar.addComponent(tblLabel);
    tableBar.addComponent(tblName);
    vl1.addComponent(tableBar);

    createQuery = new CheckBox("Include CREATE TABLE query");
    createQuery.setValue(true);
    HorizontalLayout createBar = new HorizontalLayout();
    createBar.setMargin(true, false, false, false);
    createBar.addComponent(createQuery);
    vl1.addComponent(createBar);
    sqlPanel.addComponent(vl1);

    generateTypeHl.addComponent(sqlPanel);
    generator.addComponent(generateTypeHl);

    //CSV Option
    csvPanel = new Panel("CSV Options");
    csvPanel.setHeight("130px");
    if (browser.isIE()) {
        csvPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanelIE");
    } else {
        csvPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanel");
    }
    Label delimiter = new Label("Delimiter Character(s)");
    VerticalLayout vl2 = new VerticalLayout();
    vl2.setMargin(false);
    csvDelimiter = new TextField();
    HorizontalLayout csvBar = new HorizontalLayout();
    csvBar.setMargin(true, false, false, false);
    csvBar.setSpacing(true);
    csvBar.addComponent(delimiter);
    csvBar.addComponent(csvDelimiter);
    vl2.addComponent(csvBar);
    csvPanel.addComponent(vl2);

    //XML Options
    xmlPanel = new Panel("XML Options");
    xmlPanel.setHeight("160px");
    if (browser.isIE()) {
        xmlPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanelIE");
    } else {
        xmlPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanel");
    }

    VerticalLayout vl3 = new VerticalLayout();
    vl3.setMargin(false);
    Label lb4 = new Label("Root node name");
    rootNode = new TextField();
    rootNode.setWidth("125px");
    rootNode.setStyleName("mandatory");
    HorizontalLayout nodeBar = new HorizontalLayout();
    nodeBar.setMargin(true, false, false, false);
    nodeBar.setSpacing(true);
    nodeBar.addComponent(lb4);
    nodeBar.addComponent(rootNode);
    vl3.addComponent(nodeBar);

    Label lb5 = new Label("Record node name");
    recordNode = new TextField();
    recordNode.setWidth("112px");
    recordNode.setStyleName("mandatory");
    HorizontalLayout recordBar = new HorizontalLayout();
    recordBar.setMargin(true, false, false, false);
    recordBar.setSpacing(true);
    recordBar.addComponent(lb5);
    recordBar.addComponent(recordNode);
    vl3.addComponent(recordBar);
    xmlPanel.addComponent(vl3);

    HorizontalLayout noOfRowHl = new HorizontalLayout();
    noOfRowHl.setSpacing(true);
    noOfRowHl.setMargin(true, false, false, true);
    noOfRowHl.addComponent(new Label("Number of Results"));
    resultNum = new TextField();
    resultNum.setImmediate(true);
    resultNum.setNullSettingAllowed(false);
    resultNum.setStyleName("mandatory");
    resultNum.addValidator(new IntegerValidator("Number of Results must be an Integer"));
    resultNum.setWidth("5em");
    resultNum.setMaxLength(5);
    resultNum.setValue(50);
    noOfRowHl.addComponent(resultNum);
    generator.addComponent(noOfRowHl);

    HorizontalLayout addRowHl = new HorizontalLayout();
    addRowHl.setMargin(true, false, true, true);
    addRowHl.setSpacing(true);
    addRowHl.addComponent(new Label("Add"));
    rowNum = new TextField();
    rowNum.setImmediate(true);
    rowNum.setNullSettingAllowed(true);
    rowNum.addValidator(new IntegerValidator("Row number must be an Integer"));
    rowNum.setWidth("4em");
    rowNum.setMaxLength(2);
    rowNum.setValue(1);
    addRowHl.addComponent(rowNum);
    rowsBttn = new Button("Row(s)");
    rowsBttn.setIcon(DataGenConstant.ADD);
    rowsBttn.addListener(ClickEvent.class, this, "addRowButtonClick"); // react to clicks
    addRowHl.addComponent(rowsBttn);
    generator.addComponent(addRowHl);

    //Add the Grid
    generator.addComponent(listing);

    //Generate Button
    Button bttn = new Button("Generate");
    bttn.setDescription("Generate Gata");
    bttn.addListener(ClickEvent.class, this, "generateButtonClick"); // react to clicks
    bttn.setIcon(DataGenConstant.VIEW);
    bttn.setStyleName("generate");
    generator.addComponent(bttn);
    //Generator Tab content end

    //Executer Tab content start - new class created to separate execution logic
    executor = new ExecutorView(this);
    //Executer Tab content end

    //Explorer Tab content start - new class created to separate execution logic
    explorer = new ExplorerView(this, databaseSessionManager);
    //explorer.setMargin(true);
    //Explorer Tab content end

    //About Tab content start
    VerticalLayout about = new VerticalLayout();
    about.setMargin(true);
    Label aboutRichText = new Label(DataGenConstant.ABOUT_CONTENT);
    aboutRichText.setContentMode(Label.CONTENT_XHTML);
    about.addComponent(aboutRichText);
    //About Tab content end

    //Help Tab content start
    VerticalLayout help = new VerticalLayout();
    help.setMargin(true);
    Label helpText = new Label(DataGenConstant.HELP_CONTENT);
    helpText.setContentMode(Label.CONTENT_XHTML);
    help.addComponent(helpText);

    Embedded helpScreen = new Embedded();
    helpScreen.setSource(DataGenConstant.HELP_SCREEN);
    help.addComponent(helpScreen);

    Label helpStepsText = new Label(DataGenConstant.HELP_CONTENT_STEPS);
    helpStepsText.setContentMode(Label.CONTENT_XHTML);
    help.addComponent(helpStepsText);
    //Help Tab content end

    //Add the respective contents to the tab sheet
    tabSheet.addTab(generator, "Generator", DataGenConstant.HOME_ICON);
    executorTab = tabSheet.addTab(executor, "Executor", DataGenConstant.EXECUTOR_ICON);
    explorerTab = tabSheet.addTab(explorer, "Explorer", DataGenConstant.EXPLORER_ICON);
    tabSheet.addTab(about, "About", DataGenConstant.ABOUT_ICON);
    tabSheet.addTab(help, "Help", DataGenConstant.HELP_ICON);

    HorizontalLayout content = new HorizontalLayout();
    content.setSizeFull();
    content.addComponent(tabSheet);

    rootLayout.addComponent(content);
    rootLayout.setExpandRatio(content, 1);
    log.debug("DataGenApplication - buildMainLayout() end");
}

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

License:Open Source License

public DataExportView() {
    log.debug("DataExportView-> Loading Constructor.");

    setWidth("95px");
    Button excelButton = new Button("Excel");
    excelButton.setIcon(DataGenConstant.DATAIMPORT_EXCEL_ICON);
    excelButton.setWidth("95px");
    addComponent(excelButton);// ww w. j a  v a  2s.  co  m
    excelButton.addListener(ClickEvent.class, this, "excelExportButtonClick");

    Button sqlButton = new Button("Sql");
    sqlButton.setIcon(DataGenConstant.DATAEXPORT_SQL_ICON);
    sqlButton.setWidth("95px");
    addComponent(sqlButton);
    sqlButton.addListener(ClickEvent.class, this, "sqlExportButtonClick");

}

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

License:Open Source License

public DataImportView() {
    log.debug("DataExportView-> Loading Constructor.");

    setWidth("95px");
    Button excelButton = new Button("Excel");
    excelButton.setIcon(DataGenConstant.DATAIMPORT_EXCEL_ICON);
    excelButton.setWidth("95px");
    addComponent(excelButton);/*from ww w  . j a va 2 s  .c  o  m*/
    excelButton.addListener(ClickEvent.class, this, "excelImportButtonClick");

    Button sqlButton = new Button("Sql");
    sqlButton.setIcon(DataGenConstant.DATAEXPORT_SQL_ICON);
    sqlButton.setWidth("95px");
    addComponent(sqlButton);
    sqlButton.addListener(ClickEvent.class, this, "sqlImportButtonClick");

}

From source file:com.moorevaadin.vaadin7.beanvalidation.BeanValidationRoot.java

License:Apache License

@Override
protected void init(WrappedRequest request) {

    setCaption("Vaadin 7 Bean validation example");

    layout.setMargin(true);/* w  ww  .jav  a 2 s.  c  o m*/

    setContent(layout);

    BeanItem<Person> item = new BeanItem<Person>(new Person());

    group = new FieldGroup(item);

    //group.setFieldFactory(new EnhancedFieldGroupFieldFactory());

    Field<?> gender = group.buildAndBind("Gender", "gender", Select.class);
    firstName = (AbstractTextField) group.buildAndBind("First name", "firstName");
    lastName = (AbstractTextField) group.buildAndBind("Last name", "lastName");
    email = (AbstractTextField) group.buildAndBind("email");
    Field<?> birthdate = group.buildAndBind("Birth date", "birthdate", DateField.class);

    firstName.setNullRepresentation("");
    lastName.setNullRepresentation("");
    email.setNullRepresentation("");

    firstName.addListener(new InstallPersonValidatorBlurListener(firstName, "firstName"));
    lastName.addListener(new InstallPersonValidatorBlurListener(lastName, "lastName"));
    email.addListener(new InstallPersonValidatorBlurListener(email, "email"));

    layout.addComponent(gender);
    layout.addComponent(firstName);
    layout.addComponent(lastName);
    layout.addComponent(email);
    layout.addComponent(birthdate);

    Button commit = new Button("Commit");

    commit.addListener(ClickEvent.class, this, "commit");

    layout.addComponent(commit);
}

From source file:com.morevaadin.vaadin7.custom.CustomComponentView.java

License:Apache License

public CustomComponentView() {

    VerticalLayout layout = new VerticalLayout();

    layout.setMargin(true);//from   w  w w  .ja  v  a2 s .  co m
    layout.setSpacing(true);

    setCompositionRoot(layout);

    Button button = new Button("Vaadin");
    button.addListener(ClickEvent.class, this, "showClick");
    layout.addComponent(button);

    BootstrapButton customButton = new BootstrapButton("Default");
    customButton.addListener(BootstrapClickEvent.class, this, "showClick");
    layout.addComponent(customButton);

    layout.addComponent(new BootstrapButton("Large", Size.LARGE));
    layout.addComponent(new BootstrapButton("Small", Size.SMALL));
    layout.addComponent(new BootstrapButton("Mini", Size.MINI));
    layout.addComponent(new BootstrapButton("Primary", Type.PRIMARY));
    layout.addComponent(new BootstrapButton("Info", Type.INFO));
    layout.addComponent(new BootstrapButton("Success", Type.SUCCESS));
    layout.addComponent(new BootstrapButton("Warning", Type.WARNING));
    layout.addComponent(new BootstrapButton("Danger", Type.DANGER));
    layout.addComponent(new BootstrapButton("Inverse", Type.INVERSE));
}

From source file:org.s23m.cell.editor.semanticdomain.ui.components.ContainmentTreePanel.java

License:Mozilla Public License

private Panel createSearchPanel() {
    final Panel searchPanel = new Panel();
    final HorizontalLayout searchLayout = new HorizontalLayout();
    searchLayout.setWidth(TAB_SHEET_HEIGHT_RATIO);
    searchLayout.setSpacing(true);/*from  www  .j  a v a2s  . c om*/
    searchPanel.addStyleName(Runo.PANEL_LIGHT);
    searchPanel.getLayout().setMargin(true);
    searchPanel.setLayout(searchLayout);

    searchText = new TextField();
    searchText.setWidth(TAB_SHEET_HEIGHT_RATIO);

    final Button searchBtn = new Button();
    searchBtn.setDescription("Search");
    searchBtn.setClickShortcut(KeyCode.ENTER);
    searchBtn.setIcon(EditorIcon.SEARCH.getIconImage());
    searchBtn.setWidth(null);
    searchBtn.addListener(Button.ClickEvent.class, this, INSTANCE_SEARCH_CMD);

    searchPanel.addComponent(searchText);
    searchPanel.addComponent(searchBtn);

    searchLayout.setExpandRatio(searchText, SEARCH_TEXT_EXPANSION_RATIO);

    return searchPanel;
}

From source file:org.s23m.cell.editor.semanticdomain.ui.components.ContainmentTreePanel.java

License:Mozilla Public License

private Panel createOperationsPanel() {
    final Panel operationsPanel = new Panel();
    final HorizontalLayout operationsPanelLayout = new HorizontalLayout();
    operationsPanelLayout.setWidth(TAB_SHEET_HEIGHT_RATIO);
    operationsPanelLayout.setSpacing(true);
    operationsPanel.addStyleName(Runo.PANEL_LIGHT);
    operationsPanel.getLayout().setMargin(true);
    operationsPanel.setLayout(operationsPanelLayout);

    commitButton = new Button();
    commitButton.setDescription("Commit");
    commitButton.setIcon(EditorIcon.PERSIST.getIconImage());
    commitButton.addListener(Button.ClickEvent.class, this, CHANGESET_COMMIT_CMD);

    rollbackButton = new Button();
    rollbackButton.setDescription("Rollback");
    // TODO use a more appropriate icon
    rollbackButton.setIcon(EditorIcon.DELETE.getIconImage());
    rollbackButton.addListener(Button.ClickEvent.class, this, CHANGESET_ROLLBACK_CMD);

    commitButton.setImmediate(true);/*w ww .j a  v  a  2s.c o m*/
    rollbackButton.setImmediate(true);
    commitButton.setEnabled(false);
    rollbackButton.setEnabled(false);

    final Button retrievalBtn = new Button();
    retrievalBtn.setDescription("Retrieve");
    retrievalBtn.setIcon(EditorIcon.RETRIEVE.getIconImage());
    retrievalBtn.setWidth(null);
    retrievalBtn.addListener(Button.ClickEvent.class, this, INSTANCE_RETRIEVAL_CMD);

    operationsPanel.addComponent(retrievalBtn);
    operationsPanel.addComponent(commitButton);
    operationsPanel.addComponent(rollbackButton);

    return operationsPanel;
}