Example usage for com.vaadin.ui Panel Panel

List of usage examples for com.vaadin.ui Panel Panel

Introduction

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

Prototype

public Panel(String caption) 

Source Link

Document

Creates a new empty panel with caption.

Usage

From source file:gui.views.LoginView.java

public void setUp() {

    // Ein Neuer Kommentar fr Git.
    this.setSizeFull();
    final TextField userlogin = new TextField();
    userlogin.setCaption("Username");

    final PasswordField password = new PasswordField();
    password.setCaption("Passwort");

    VerticalLayout layout = new VerticalLayout();
    layout.addComponent(userlogin);/*from  w  ww . j av a 2  s.  com*/
    layout.addComponent(password);

    Panel panel = new Panel("BitteLogin-Daten eingeben");

    this.addComponent(panel);

    this.setComponentAlignment(panel, Alignment.MIDDLE_CENTER);

    panel.setContent(layout);

    Button buttonLogin = new Button("Login", FontAwesome.SEARCH);
    layout.addComponent(buttonLogin);
    layout.setComponentAlignment(buttonLogin, Alignment.MIDDLE_CENTER);

    panel.setSizeUndefined();

    buttonLogin.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            String user = userlogin.getValue();
            String pw = password.getValue();

            LoginControl.controllogin(user, pw);

        }

    });

}

From source file:helpers.Utils.java

License:Open Source License

public static Panel createInfoBox(String caption, String description) {
    Panel panel = new Panel(caption);
    panel.setIcon(FontAwesome.INFO);//from w  w w  .ja  va  2 s .  c  o  m
    panel.setStyleName(ValoTheme.PANEL_BORDERLESS);
    HorizontalLayout layout = new HorizontalLayout();
    Label label = new Label();
    label.setValue(description);
    layout.addComponent(label);

    panel.setContent(layout);
    return panel;
}

From source file:jp.primecloud.auto.ui.MainView.java

License:Open Source License

@Override
public void attach() {
    setSizeFull();/*ww w  . j a  va  2  s  .  c  o  m*/
    addStyleName("mycloud-panel");
    setMargin(false);
    setSpacing(false);

    // ???
    topBar = new TopBar(this);
    addComponent(topBar);

    // ???
    CssLayout topLayout = new CssLayout();
    topLayout.setWidth("100%");
    topLayout.setHeight("28px");
    topLayout.addStyleName("mycloud-name");
    topLayout.setMargin(true);
    addComponent(topLayout);

    // myCloud??
    myCloudField = new TextField();
    myCloudField.setWidth("80%");
    myCloudField.addStyleName("mycloud-label");
    myCloudField.setEnabled(false);
    myCloudField.setReadOnly(true);
    topLayout.addComponent(myCloudField);

    // Reload
    reloadButton = new Button(ViewProperties.getCaption("button.reload"));
    reloadButton.setDescription(ViewProperties.getCaption("description.reload"));
    reloadButton.addStyleName("sync-button");
    reloadButton.addStyleName("borderless");
    reloadButton.setIcon(Icons.SYNC.resource());
    reloadButton.setEnabled(false);
    reloadButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            refresh();
        }
    });
    topLayout.addComponent(reloadButton);

    // myCloud
    VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();
    mainLayout.setSpacing(false);
    mainLayout.setMargin(false);

    Panel mainPanel = new Panel(mainLayout);
    mainPanel.setSizeFull();
    mainPanel.addStyleName(Reindeer.PANEL_LIGHT);
    addComponent(mainPanel);
    setExpandRatio(mainPanel, 100);

    // 
    tab = new TabSheet();
    tab.setSizeFull();
    tab.setEnabled(false);
    tab.addStyleName(Reindeer.TABSHEET_BORDERLESS);
    mainLayout.addComponent(tab);
    mainLayout.setExpandRatio(tab, 100);

    // 
    String enableService = Config.getProperty("ui.enableService");
    if (enableService == null || BooleanUtils.toBoolean(enableService)) {
        servicePanel = new ServicePanel(this);
        tab.addTab(servicePanel, ViewProperties.getCaption("tab.service"), Icons.SERVICETAB.resource());
    }

    // ?
    serverPanel = new ServerPanel(this);
    tab.addTab(serverPanel, ViewProperties.getCaption("tab.server"), Icons.SERVERTAB.resource());

    // ?
    String enableLoadBalancer = Config.getProperty("ui.enableLoadBalancer");
    if (enableLoadBalancer == null || BooleanUtils.toBoolean(enableLoadBalancer)) {
        loadBalancerPanel = new LoadBalancerPanel(this);
        tab.addTab(loadBalancerPanel, ViewProperties.getCaption("tab.loadbalancer"),
                Icons.LOADBALANCER_TAB.resource());
    }

    // ???????
    tab.addListener(new SelectedTabChangeListener() {
        @Override
        public void selectedTabChange(SelectedTabChangeEvent event) {
            MainView.this.selectedTabChange(event);
        }
    });

    // ?
    Refresher timer = new Refresher();
    timer.setRefreshInterval(15 * 1000); //(msec)
    timer.addListener(new Refresher.RefreshListener() {
        @Override
        public void refresh(Refresher source) {
            if (needsRefresh()) {
                refreshTableOnly();
            }
        }
    });
    mainLayout.addComponent(timer);

    // ?
    showLogin();
}

From source file:life.qbic.components.OfferGeneratorTab.java

License:Open Source License

/**
 * creates the tab to generate the offers with the respective packages
 * @return vaadin component holding the offer generator
 *//*from  w ww. j a  va 2s . c o m*/
static Component createOfferGeneratorTab() {

    Database db = qOfferManager.getDb();
    TabSheet managerTabs = qOfferManager.getManagerTabs();

    ComboBox selectedProjectComboBox = new ComboBox("Select Project");
    selectedProjectComboBox.setInputPrompt("No project selected!");
    selectedProjectComboBox.setDescription("Please select a project before its too late! :P");
    selectedProjectComboBox.addItems(db.getProjects());
    selectedProjectComboBox.setWidth("300px");

    Button completeButton = new Button("Complete");
    completeButton.setDescription("Click here to finalize the offer and save it into the DB!");
    completeButton.setIcon(FontAwesome.CHECK_CIRCLE);
    completeButton.setEnabled(false);

    // get the package ids and names as a bean container
    final BeanItemContainer<String> packageIdsAndNamesContainer = new BeanItemContainer<>(String.class);
    packageIdsAndNamesContainer.addAll(db.getPackageIdsAndNames());

    TwinColSelect selectPackagesTwinColSelect = new TwinColSelect();
    selectPackagesTwinColSelect.setContainerDataSource(packageIdsAndNamesContainer);
    selectPackagesTwinColSelect.setLeftColumnCaption("Available packages");
    selectPackagesTwinColSelect.setRightColumnCaption("Selected packages");
    selectPackagesTwinColSelect.setSizeFull();

    // text field which functions as a filter for the left side of the twin column select
    TextField twinColSelectFilter = new TextField();
    twinColSelectFilter.setCaption("Filter available packages");
    twinColSelectFilter.addTextChangeListener((FieldEvents.TextChangeListener) event -> {
        packageIdsAndNamesContainer.removeAllContainerFilters();
        packageIdsAndNamesContainer.addContainerFilter(new Container.Filter() {

            @Override
            public boolean passesFilter(Object itemId, Item item) throws UnsupportedOperationException {
                return ((String) itemId).toLowerCase().contains(event.getText().toLowerCase())
                        || ((Collection) selectPackagesTwinColSelect.getValue()).contains(itemId);
            }

            @Override
            public boolean appliesToProperty(Object propertyId) {
                return true;
            }
        });
    });

    VerticalLayout right = new VerticalLayout();
    right.setSpacing(true);
    right.setMargin(true);

    VerticalLayout addPackLayout = new VerticalLayout();
    addPackLayout.setMargin(true);
    addPackLayout.setSpacing(true);

    Panel packageDescriptionPanel = new Panel("Package Details");
    packageDescriptionPanel.setContent(right);

    @SuppressWarnings("deprecation")
    Label packageDetailsLabel = new Label("Package details will appear here!", Label.CONTENT_XHTML);
    packageDetailsLabel.addStyleName(ValoTheme.LABEL_BOLD);
    right.addComponent(packageDetailsLabel);

    addListeners(db, managerTabs, selectedProjectComboBox, completeButton, addPackLayout,
            selectPackagesTwinColSelect, packageDescriptionPanel, packageDetailsLabel, twinColSelectFilter);

    addPackLayout.addComponent(selectedProjectComboBox);

    return addPackLayout;
}

From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.AdminAuthView.java

License:Open Source License

public AdminAuthView() {

    setSizeFull();//from w ww . j  a  v  a  2 s.  co m

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

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

    addComponents(header, content);
    setExpandRatio(header, 1);
    setExpandRatio(content, 6);

    welcomeText.setValue("<h1>Welcome to the iCrash Administrator console!</h1>");
    welcomeText.setContentMode(ContentMode.HTML);
    welcomeText.setSizeUndefined();
    header.addComponent(welcomeText);
    header.setComponentAlignment(welcomeText, Alignment.MIDDLE_CENTER);

    Panel controlPanel = new Panel("Administrator control panel");
    controlPanel.setSizeUndefined();

    Panel addCoordPanel = new Panel("Create a new coordinator");
    addCoordPanel.setSizeUndefined();

    Panel messagesPanel = new Panel("Administrator messages");
    messagesPanel.setWidth("580px");

    Table adminMessagesTable = new Table();

    adminMessagesTable.setContainerDataSource(actAdmin.getMessagesDataSource());

    adminMessagesTable.setColumnWidth("inputEvent", 180);
    adminMessagesTable.setSizeFull();

    VerticalLayout controlLayout = new VerticalLayout(controlPanel);
    controlLayout.setSizeFull();
    controlLayout.setMargin(false);
    controlLayout.setComponentAlignment(controlPanel, Alignment.TOP_CENTER);

    VerticalLayout coordOperationsLayout = new VerticalLayout(addCoordPanel);
    coordOperationsLayout.setSizeFull();
    coordOperationsLayout.setMargin(false);
    coordOperationsLayout.setComponentAlignment(addCoordPanel, Alignment.TOP_CENTER);

    /******************************************/
    coordOperationsLayout.setVisible(true); // main layout in the middle
    addCoordPanel.setVisible(false); // ...which contains the panel "Create a new coordinator"
    /******************************************/

    HorizontalLayout messagesExternalLayout = new HorizontalLayout(messagesPanel);
    VerticalLayout messagesInternalLayout = new VerticalLayout(adminMessagesTable);

    messagesExternalLayout.setSizeFull();
    messagesExternalLayout.setMargin(false);
    messagesExternalLayout.setComponentAlignment(messagesPanel, Alignment.TOP_CENTER);

    messagesInternalLayout.setMargin(false);
    messagesInternalLayout.setSizeFull();
    messagesInternalLayout.setComponentAlignment(adminMessagesTable, Alignment.TOP_CENTER);

    messagesPanel.setContent(messagesInternalLayout);

    TextField idCoordAdd = new TextField();
    TextField loginCoord = new TextField();
    PasswordField pwdCoord = new PasswordField();

    Label idCaptionAdd = new Label("ID");
    Label loginCaption = new Label("Login");
    Label pwdCaption = new Label("Password");

    idCaptionAdd.setSizeUndefined();
    idCoordAdd.setSizeUndefined();

    loginCaption.setSizeUndefined();
    loginCoord.setSizeUndefined();

    pwdCaption.setSizeUndefined();
    pwdCoord.setSizeUndefined();

    Button validateNewCoord = new Button("Validate");
    validateNewCoord.setClickShortcut(KeyCode.ENTER);
    validateNewCoord.setStyleName(ValoTheme.BUTTON_PRIMARY);

    GridLayout addCoordinatorLayout = new GridLayout(2, 4);
    addCoordinatorLayout.setSpacing(true);
    addCoordinatorLayout.setMargin(true);
    addCoordinatorLayout.setSizeFull();

    addCoordinatorLayout.addComponents(idCaptionAdd, idCoordAdd, loginCaption, loginCoord, pwdCaption,
            pwdCoord);

    addCoordinatorLayout.addComponent(validateNewCoord, 1, 3);

    addCoordinatorLayout.setComponentAlignment(idCaptionAdd, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(idCoordAdd, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(loginCaption, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(loginCoord, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(pwdCaption, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(pwdCoord, Alignment.MIDDLE_LEFT);

    addCoordPanel.setContent(addCoordinatorLayout);

    content.addComponents(controlLayout, coordOperationsLayout, messagesExternalLayout);
    content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER);
    content.setComponentAlignment(controlLayout, Alignment.TOP_CENTER);
    content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER);

    content.setExpandRatio(controlLayout, 20);
    content.setExpandRatio(coordOperationsLayout, 10);
    content.setExpandRatio(messagesExternalLayout, 28);

    Button addCoordinator = new Button("Add coordinator");
    Button deleteCoordinator = new Button("Delete coordinator");

    addCoordinator.addStyleName(ValoTheme.BUTTON_HUGE);
    deleteCoordinator.addStyleName(ValoTheme.BUTTON_HUGE);
    logoutBtn.addStyleName(ValoTheme.BUTTON_HUGE);

    VerticalLayout buttons = new VerticalLayout();

    buttons.setMargin(true);
    buttons.setSpacing(true);
    buttons.setSizeFull();

    buttons.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    controlPanel.setContent(buttons);

    buttons.addComponents(addCoordinator, deleteCoordinator, logoutBtn);

    /******* DELETE COORDINATOR PANEL BEGIN *********/
    Label idCaptionDel = new Label("ID");
    TextField idCoordDel = new TextField();

    Panel delCoordPanel = new Panel("Delete a coordinator");

    coordOperationsLayout.addComponent(delCoordPanel);
    delCoordPanel.setVisible(false);

    coordOperationsLayout.setComponentAlignment(delCoordPanel, Alignment.TOP_CENTER);
    delCoordPanel.setSizeUndefined();

    GridLayout delCoordinatorLayout = new GridLayout(2, 2);
    delCoordinatorLayout.setSpacing(true);
    delCoordinatorLayout.setMargin(true);
    delCoordinatorLayout.setSizeFull();

    Button deleteCoordBtn = new Button("Delete");
    deleteCoordBtn.setClickShortcut(KeyCode.ENTER);
    deleteCoordBtn.setStyleName(ValoTheme.BUTTON_PRIMARY);

    delCoordinatorLayout.addComponents(idCaptionDel, idCoordDel);

    delCoordinatorLayout.addComponent(deleteCoordBtn, 1, 1);

    delCoordinatorLayout.setComponentAlignment(idCaptionDel, Alignment.MIDDLE_LEFT);
    delCoordinatorLayout.setComponentAlignment(idCoordDel, Alignment.MIDDLE_LEFT);

    delCoordPanel.setContent(delCoordinatorLayout);
    /******* DELETE COORDINATOR PANEL END *********/

    /************************************************* MAIN BUTTONS LOGIC BEGIN *************************************************/

    addCoordinator.addClickListener(event -> {
        if (!addCoordPanel.isVisible()) {
            delCoordPanel.setVisible(false);
            addCoordPanel.setVisible(true);
            idCoordAdd.focus();
        } else
            addCoordPanel.setVisible(false);
    });

    deleteCoordinator.addClickListener(event -> {
        if (!delCoordPanel.isVisible()) {
            addCoordPanel.setVisible(false);
            delCoordPanel.setVisible(true);
            idCoordDel.focus();
        } else
            delCoordPanel.setVisible(false);
    });

    /************************************************* MAIN BUTTONS LOGIC END *************************************************/

    /************************************************* ADD COORDINATOR FORM LOGIC BEGIN *************************************************/
    validateNewCoord.addClickListener(event -> {

        String currentURL = Page.getCurrent().getLocation().toString();
        int strIndexCreator = currentURL.lastIndexOf(AdministratorLauncher.adminPageName);
        String iCrashURL = currentURL.substring(0, strIndexCreator);
        String googleShebang = "#!";
        String coordURL = iCrashURL + CoordinatorServlet.coordinatorsName + googleShebang;

        try {
            sys.oeAddCoordinator(new DtCoordinatorID(new PtString(idCoordAdd.getValue())),
                    new DtLogin(new PtString(loginCoord.getValue())),
                    new DtPassword(new PtString(pwdCoord.getValue())));

            // open new browser tab with the newly created coordinator console...
            // "_blank" instructs the browser to open a new tab instead of a new window...
            // unhappily not all browsers interpret it correctly,
            // some versions of some browsers might still open a new window instead (notably Firefox)!
            Page.getCurrent().open(coordURL + idCoordAdd.getValue(), "_blank");

        } catch (Exception e) {
            e.printStackTrace();
        }

        idCoordAdd.setValue("");
        loginCoord.setValue("");
        pwdCoord.setValue("");

        idCoordAdd.focus();
    });
    /************************************************* ADD COORDINATOR FORM LOGIC END *************************************************/
    /************************************************* DELETE COORDINATOR FORM LOGIC BEGIN *************************************************/
    deleteCoordBtn.addClickListener(event -> {
        IcrashSystem sys = IcrashSystem.getInstance();

        try {
            sys.oeDeleteCoordinator(new DtCoordinatorID(new PtString(idCoordDel.getValue())));
        } catch (Exception e) {
            e.printStackTrace();
        }

        idCoordDel.setValue("");
        idCoordDel.focus();
    });
    /************************************************* DELETE COORDINATOR FORM LOGIC END *************************************************/
}

From source file:metacom.sprut7.AllPu.java

public void init() {
    statePlat = (StatePlat) VaadinSession.getCurrent().getAttribute("statePlat");
    linkRes = statePlat.getLinkRes();//  ww  w  .  ja  v  a  2  s  .  com
    linkPool = statePlat.getLinkPool();
    this.idplat = statePlat.getIdPlat();

    setMargin(true);
    setHeight("100%");
    setStyleName("DolgiWindow");
    setSizeFull();

    pan = new Panel("?     ");
    pan.setWidth("100%");
    pan.setHeight("585px");

    BuildMain();
    addComponent(pan);
    setImmediate(true);
}

From source file:metacom.sprut7.HistoryNalNak.java

private void BuildMain() {
    Statistika stat = new Statistika();
    stat.init(idplat, Statistika.ST_HIST_NN);

    datetime1 = new InlineDateField();
    datetime2 = new InlineDateField();
    // ? /*  ww w . j  av a2  s . c  o  m*/
    Date dt = new java.util.Date();
    final java.util.Calendar calendar = GregorianCalendar.getInstance();
    calendar.setTime(dt);
    year2 = calendar.get(java.util.Calendar.YEAR);
    datetime2.setValue(dt);
    datetime2.setResolution(InlineDateField.RESOLUTION_YEAR);
    datetime2.setImmediate(true);
    datetime2.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            Object value = event.getProperty().getValue();
            if (value == null || !(value instanceof Date)) {
                Notification.show(" ? ");
            } else {
                calendar.setTime((Date) value);
                year2 = calendar.get(java.util.Calendar.YEAR);
                refresh();
            }
        }
    });
    calendar.add(Calendar.YEAR, -3);
    year1 = calendar.get(java.util.Calendar.YEAR);
    datetime1.setResolution(InlineDateField.RESOLUTION_YEAR);
    datetime1.setValue(calendar.getTime());
    datetime1.setImmediate(true);
    datetime1.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            Object value = event.getProperty().getValue();
            if (value == null || !(value instanceof Date)) {
                Notification.show(" ? ");
            } else {
                calendar.setTime((Date) value);
                year1 = calendar.get(java.util.Calendar.YEAR);
                refresh();
            }
        }
    });
    HorizontalLayout hl = new HorizontalLayout();
    hl.addComponent(
            new Label("<font size=\"4\" ><b> ?: </b></font>", ContentMode.HTML));
    hl.addComponent(datetime1);
    hl.addComponent(new Label("<font size=\"4\"><b>  -  </b></font>", ContentMode.HTML));
    hl.addComponent(datetime2);

    pan = new Panel("??  ");
    pan.setWidth("100%");
    //        pan.setHeight("100%");
    pan.setHeight("585px");
    addComponent(hl);
    addComponent(pan);
    refresh();

}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

private Layout getSotisFrontPage() {
    GridSystemLayout layout = new GridSystemLayout(12);
    Label title = new Label(
            "O <strong>SOTIS</strong>  o Repositrio Institucional do Instituto Superior Tcnico.",
            Label.CONTENT_XHTML);
    title.addStyleName(BennuTheme.LABEL_BIG);
    layout.setCell("title", 12, title);

    Label description = new Label(
            "Aqui poder encontrar artigos publicados em <a href=\"\">Revistas</a>, <a href=\"\">Conferncias</a>, <a href=\"\">Livros</a>, <a href=\"\">Manuais</a> e <a href=\"\">Outros</a>, categorizados por <a href=\"\">Unidades de Investigao</a> e <a href=\"\">Unidades Acadmicas</a>.",
            Label.CONTENT_XHTML);
    description.addStyleName(BennuTheme.LABEL_BIG);
    layout.setCell("description", 12, description);

    VerticalLayout searchPanel = new VerticalLayout();
    layout.setCell("search", 2, 8, 2, searchPanel);
    searchPanel.addStyleName("big");
    searchPanel.addStyleName("inset");
    searchPanel.setMargin(true);//from w  w w .  ja v  a 2  s.co m
    searchPanel.setSpacing(true);
    HorizontalLayout searchForm = new HorizontalLayout();
    searchPanel.addComponent(searchForm);
    searchForm.setSpacing(true);
    searchForm.setWidth("100%");

    TextField searchText = new TextField();
    searchForm.addComponent(searchText);
    searchText.setInputPrompt("Introduza o termo a pesquisar");
    searchText.setWidth("100%");

    Button searchSubmit = new Button("Pesquisar");
    searchForm.addComponent(searchSubmit);
    searchSubmit.addStyleName(BennuTheme.BUTTON_DEFAULT);
    searchForm.setExpandRatio(searchText, 1f);

    Link advanced = new Link("advanced search", null);
    searchPanel.addComponent(advanced);

    Panel browseByType = new Panel("Publicaes por Tipo");
    browseByType.addStyleName(BennuTheme.PANEL_LIGHT);
    layout.setCell("type", 4, browseByType);

    Panel browseByDept = new Panel("Publicaes por Departamento");
    browseByDept.addStyleName(BennuTheme.PANEL_LIGHT);
    layout.setCell("dept", 4, browseByDept);

    Panel contacts = new Panel("Contactos");
    contacts.addStyleName(BennuTheme.PANEL_LIGHT);
    layout.setCell("contacts", 4, contacts);

    return layout;
}

From source file:net.antoinecomte.regex.RegExTesterApplication.java

License:Apache License

@Override
public void init() {
    setTheme("chameleon");
    final TextField text = new TextField();

    final TextField regex = new TextField();

    Panel mainPanel = new Panel("Simple Java regular expression tool ");
    mainPanel.setWidth("460px");
    VerticalLayout mainPanelLayout = new VerticalLayout();
    mainPanelLayout.setSpacing(true);//from w w w  .  j a  va2  s . c  o  m
    mainPanelLayout.setMargin(true);
    mainPanel.setContent(mainPanelLayout);
    regex.setCaption("Regular Expression");
    regex.setWidth("400px");
    regex.addStyleName("big");
    regex.setInputPrompt("enter a regular expression here");
    regex.setTextChangeEventMode(TextChangeEventMode.TIMEOUT);
    regex.setImmediate(true);

    text.setCaption("Test input");
    text.setInputPrompt("Enter a test string here");
    text.setTextChangeEventMode(TextChangeEventMode.TIMEOUT);
    text.setImmediate(true);
    text.setWidth("400px");
    text.addStyleName("big");
    result.setSizeUndefined();
    result.setWidth("460px");
    result.setStyleName("light");
    result.setVisible(false);

    regex.addListener(new TextChangeListener() {
        private static final long serialVersionUID = 7783333579512074097L;

        @Override
        public void textChange(TextChangeEvent event) {
            showResult(event.getText(), text.getValue().toString());

        }
    });
    text.addListener(new TextChangeListener() {
        private static final long serialVersionUID = -2294521048305268959L;

        @Override
        public void textChange(TextChangeEvent event) {
            showResult(regex.getValue().toString(), event.getText());
        }
    });
    Window mainWindow = new Window();
    VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSpacing(true);
    mainLayout.setMargin(true);
    mainWindow.setContent(mainLayout);
    mainWindow.addComponent(mainPanel);
    mainPanel.addComponent(regex);
    mainPanel.addComponent(text);
    mainWindow.addComponent(result);
    setMainWindow(mainWindow);
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.admin.AdminScreenProvider.java

License:Apache License

private Component displaySetting(VmSetting s, boolean edit) {
    Panel form = new Panel(TRANSLATOR.translate("setting.detail"));
    FormLayout layout = new FormLayout();
    form.setContent(layout);/*from   w w  w  .j  ava  2  s  .  com*/
    form.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    BeanFieldGroup binder = new BeanFieldGroup(s.getClass());
    binder.setItemDataSource(s);
    Field<?> id = (TextField) binder.buildAndBind(TRANSLATOR.translate("general.setting"), "setting");
    layout.addComponent(id);
    Field bool = binder.buildAndBind(TRANSLATOR.translate("bool.value"), "boolVal");
    bool.setSizeFull();
    layout.addComponent(bool);
    Field integerVal = binder.buildAndBind(TRANSLATOR.translate("int.value"), "intVal");
    integerVal.setSizeFull();
    layout.addComponent(integerVal);
    Field longVal = binder.buildAndBind(TRANSLATOR.translate("long.val"), "longVal");
    longVal.setSizeFull();
    layout.addComponent(longVal);
    Field stringVal = binder.buildAndBind(TRANSLATOR.translate("string.val"), "stringVal", TextArea.class);
    stringVal.setSizeFull();
    layout.addComponent(stringVal);
    Button cancel = new Button(TRANSLATOR.translate("general.cancel"));
    cancel.addClickListener((Button.ClickEvent event) -> {
        binder.discard();
    });
    //Editing existing one
    Button update = new Button(TRANSLATOR.translate("general.update"));
    update.addClickListener((Button.ClickEvent event) -> {
        try {
            binder.commit();
            displaySetting(s);
        } catch (FieldGroup.CommitException ex) {
            LOG.log(Level.SEVERE, null, ex);
            Notification.show(TRANSLATOR.translate("general.error.record.update"), ex.getLocalizedMessage(),
                    Notification.Type.ERROR_MESSAGE);
        }
    });
    boolean blocked = !s.getSetting().startsWith("version.");
    if (blocked) {
        HorizontalLayout hl = new HorizontalLayout();
        hl.addComponent(update);
        hl.addComponent(cancel);
        layout.addComponent(hl);
    }
    binder.setBuffered(true);
    binder.setReadOnly(edit);
    binder.bindMemberFields(form);
    //The version settigns are not modifiable from the GUI
    binder.setEnabled(blocked);
    //Id is always blocked.
    id.setEnabled(false);
    form.setSizeFull();
    return form;
}